增加功能:增加新用户提示信息,Notification页面重新布局

This commit is contained in:
Argo-MacBookPro 2018-08-26 19:40:21 +08:00
parent f4f2cbace8
commit 0746993635
7 changed files with 55 additions and 49 deletions

View File

@ -78,10 +78,10 @@ namespace Bootstrap.Admin.Controllers.Api
/// <param name="value"></param> /// <param name="value"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet("{id}")] [HttpGet("{id}")]
public Notifications Get(string id) public object Get(string id)
{ {
var ret = new Notifications(); var ret = new object();
if (id == "newusers" || id == "all") ret.Users = UserHelper.RetrieveNewUsers().OrderByDescending(u => u.RegisterTime).ToList(); if (id == "newusers") ret = UserHelper.RetrieveNewUsers().ToList();
return ret; return ret;
} }

View File

@ -1,19 +1,30 @@
@model Bootstrap.Admin.Models.NavigatorBarModel @model NavigatorBarModel
@{ @{
ViewBag.Title = "通知管理"; ViewBag.Title = "通知管理";
Layout = "~/Views/Shared/_Admin.cshtml"; Layout = "~/Views/Shared/_Admin.cshtml";
} }
@section Javascript {
<script src="~/js/noti.js"></script>
}
@section css { @section css {
<link href="~/css/tasks.css" rel="stylesheet" /> <environment include="Development">
<link href="~/css/bootstrap-table.css" rel="stylesheet" />
</environment>
<environment exclude="Development">
<link href="~/css/bootstrap-table.min.css" rel="stylesheet" />
</environment>
}
@section Javascript {
<environment include="Development">
<script src="~/js/bootstrap-table.js"></script>
<script src="~/js/bootstrap-table-zh-CN.js"></script>
</environment>
<environment exclude="Development">
<script src="~/js/bootstrap-table.min.js"></script>
<script src="~/js/bootstrap-table-zh-CN.min.js"></script>
</environment>
<script src="~/js/noti.js"></script>
} }
<div class="card"> <div class="card">
<div class="card-header">用户注册<span class="pull-right"><a id="refreshUsers" href="javascript:;" class="fa fa-refresh" title="点击刷新" data-toggle="tooltip" data-placement="left"></a></span></div> <div class="card-header">用户注册<span class="pull-right"><a id="refreshUsers" href="javascript:;" class="fa fa-refresh" title="点击刷新" data-toggle="tooltip" data-placement="left"></a></span></div>
<div class="card-body"> <div class="card-body" style="padding-top: 25px;">
<div class="tasks-widget"> <table></table>
<ul id="tasks-users" class="task-list ui-sortable"></ul>
</div>
</div> </div>
</div> </div>

View File

@ -51,7 +51,7 @@
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<div class="input-group-text"> <div class="input-group-text">
<span class="fa fa-user"></span> <span class="fa fa-user-plus"></span>
</div> </div>
</div> </div>
<input type="text" id="userName" autocomplete="off" class="form-control" placeholder="登陆账号不可为空" value="" maxlength="50" remote="api/New/" data-remote-msg="此用户已存在" data-valid="true" /> <input type="text" id="userName" autocomplete="off" class="form-control" placeholder="登陆账号不可为空" value="" maxlength="50" remote="api/New/" data-remote-msg="此用户已存在" data-valid="true" />
@ -62,7 +62,7 @@
<div class="input-group"> <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<div class="input-group-text"> <div class="input-group-text">
<span class="fa fa-user"></span> <span class="fa fa-user-circle-o"></span>
</div> </div>
</div> </div>
<input type="text" id="displayName" class="form-control" value="" placeholder="显示名称不可为空" maxlength="50" data-valid="true" /> <input type="text" id="displayName" class="form-control" value="" placeholder="显示名称不可为空" maxlength="50" data-valid="true" />

View File

@ -339,7 +339,7 @@ label.dropdown-item:first-child {
line-height: normal; line-height: normal;
} }
.cache-item .btn { .cache-item .btn, td .btn:not(.btn-lg) {
margin-left: 5px; margin-left: 5px;
font-size: 0.75rem; font-size: 0.75rem;
padding: 1px 5px; padding: 1px 5px;

View File

@ -108,7 +108,7 @@ input.pending {
} }
/*Bootstrap Table BUG */ /*Bootstrap Table BUG */
.fixed-table-container { .bootstrap-table .table thead > tr > th {
border-top: none; border-top: none;
} }

View File

@ -72,7 +72,7 @@
swal: false, swal: false,
callback: function (result) { callback: function (result) {
if ($.isArray(result)) { if ($.isArray(result)) {
var html = '<div class="cache-item"><i class="fa fa-ellipsis-v"></i><div><span data-toggle="tooltip" title="{2}">{2}</span><span class="badge badge-pill badge-success">{0}</span></div><span title="{3}">{3}</span><div><span>{7}</span><button class="btn btn-danger btn-xs" title="{1}" data-url="{5}?cacheKey={1}" data-toggle="tooltip" data-self="{6}" data-placement="left"><i class="fa fa-trash-o"></i></button></div></div>'; var html = '<div class="cache-item"><i class="fa fa-ellipsis-v"></i><div><span data-toggle="tooltip" title="{2}">{2}</span><span class="badge badge-pill badge-success">{0}</span></div><span title="{3}">{3}</span><div><span>{7}</span><button class="btn btn-danger" title="{1}" data-url="{5}?cacheKey={1}" data-toggle="tooltip" data-self="{6}" data-placement="left"><i class="fa fa-trash-o"></i></button></div></div>';
var content = result.sort(function (x, y) { var content = result.sort(function (x, y) {
return x.Key > y.Key ? 1 : -1; return x.Key > y.Key ? 1 : -1;
}).map(function (ele) { }).map(function (ele) {

View File

@ -1,40 +1,35 @@
$(function () { $(function () {
var $btnRefreshUser = $('#refreshUsers'); var $table = $('table').smartTable({
var htmlNewUsersHeader = '<li class="task-header"><div class="task-title notifi"><span class="task-title-sp">登陆名称</span><span class="task-value">显示名称/备注</span><span class="task-time">注册时间</span><div class="pull-right task-oper">操作</div></div></li>'; url: Notifications.url + "newusers",
var htmlNewUsers = '<li class="list-primary"><i class="fa fa-ellipsis-v"></i><div class="task-title notifi"><span class="task-title-sp">{0}</span><span class="task-value">{4}{1}</span><span class="task-time">{2}</span><div class="pull-right hidden-phone"><button class="btn btn-success btn-xs fa fa-check" data-toggle="tooltip" data-id="{3}" data-result="1" title="同意授权"></button><button class="btn btn-danger btn-xs fa fa-remove" data-toggle="tooltip" data-id="{3}" data-result="0" title="拒绝授权"></button></div></div></li>'; sidePagination: "client",
showToggle: false,
function listData() { showRefresh: false,
$btnRefreshUser.toggleClass('fa-spin'); showColumns: false,
var $taskUsers = $('#tasks-users'); columns: [
$taskUsers.html(htmlNewUsersHeader); { title: "登陆名称", field: "UserName" },
$.bc({ { title: "显示名称", field: "DisplayName" },
Id: 'newusers', url: Notifications.url, method: 'GET', swal: false, { title: "说明信息", field: "Description" },
callback: function (result) { { title: "注册时间", field: "RegisterTime" },
if (result) { {
var content = result.Users.map(function (noti) { title: "操作", field: "Id", formatter: function (value, row, index, field) {
return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.Id, noti.DisplayName); return $.format('<button class="btn btn-success" data-toggle="tooltip" data-id="{0}" data-result="1" title="同意授权"><i class="fa fa-check"></i></button> <button class="btn btn-danger" data-toggle="tooltip" data-id="{0}" data-result="0" title="拒绝授权"><i class="fa fa-remove"></i></button>', value);
}).join('');
$taskUsers.append(content);
$('#tasks-users').find('[data-toggle="tooltip"]').tooltip();
} }
$btnRefreshUser.toggleClass('fa-spin'); }
]
}).on('click', 'button[data-id]', function () {
var $this = $(this);
var id = $this.attr('data-id');
var result = $this.attr('data-result');
$.bc({
id: id, url: User.url, method: "PUT", data: { type: "user", userIds: result }, title: result == "1" ? "授权用户" : "拒绝用户",
callback: function (result) {
$table.bootstrapTable('refresh');
$.pullNotification($('.header .nav').reloadWidget());
} }
}); });
}
listData();
$btnRefreshUser.tooltip().on('click', function () {
listData();
}); });
$('#tasks-users').on('click', 'button', function () { $('#refreshUsers').tooltip().on('click', function () {
var id = $(this).attr('data-id'); $table.bootstrapTable('refresh');
var result = $(this).attr('data-result');
$.bc({
Id: id, url: User.url, method: "PUT", data: { type: "user", userIds: result }, title: result == "1" ? "授权用户" : "拒绝用户",
callback: function (result) {
listData({ ctl: $('#refreshUsers') });
}
});
}); });
}); });