更新个人中心

This commit is contained in:
Argo-MacBookPro 2018-06-07 12:25:03 +08:00
parent 26e2c32180
commit 7308de7138
18 changed files with 63 additions and 179 deletions

View File

@ -8,7 +8,7 @@ using System.Linq;
namespace Bootstrap.Admin.Controllers.Api
{
[Route("api/[controller]")]
public class HomeController : Controller
public class CssController : Controller
{
/// <summary>
/// 获得当前样式接口

View File

@ -1,9 +1,8 @@
using Bootstrap.DataAccess;
using Bootstrap.Security;
using Longbow.Cache;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Admin.Controllers.Api
{
@ -19,11 +18,10 @@ namespace Bootstrap.Admin.Controllers.Api
/// <param name="value"></param>
/// <returns></returns>
[HttpPost]
public bool Post(JObject value)
public bool Post([FromBody]BootstrapDict value)
{
//保存个性化设置
dynamic json = value;
return DictHelper.SaveSettings((string)json.name, (string)json.code, (string)json.category);
return DictHelper.SaveSettings(value);
}
/// <summary>
///

View File

@ -31,7 +31,7 @@ namespace Bootstrap.Admin.Controllers.Api
/// </summary>
/// <returns></returns>
[HttpPut]
public bool Put(User value)
public bool Put([FromBody]User value)
{
if (value.UserStatus == 3)
{
@ -79,19 +79,9 @@ namespace Bootstrap.Admin.Controllers.Api
/// <summary>
///
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
[HttpGet]
public BootstrapUser Get(string userName)
{
return BootstrapUser.RetrieveUserByUserName(userName);
}
/// <summary>
///
/// </summary>
/// <param name="value"></param>
[HttpPost]
public bool Post(User value)
public bool Post([FromBody]User value)
{
value.Description = string.Format("管理员{0}创建用户", User.Identity.Name);
value.ApprovedBy = User.Identity.Name;

View File

@ -1,11 +1,6 @@
using Bootstrap.Admin.Models;
using Bootstrap.DataAccess;
using Bootstrap.Security;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace Bootstrap.Admin.Controllers
{
@ -23,20 +18,5 @@ namespace Bootstrap.Admin.Controllers
var v = new HeaderBarModel(User.Identity) { HomeUrl = DictHelper.RetrieveHomeUrl() };
return v.HomeUrl.StartsWith("~/") ? (ActionResult)View(v) : Redirect(v.HomeUrl);
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public async Task<IActionResult> Lock()
{
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
var user = BootstrapUser.RetrieveUserByUserName(User.Identity.Name);
return View(new LockModel
{
UserName = user.UserName,
DisplayName = user.DisplayName,
ReturnUrl = Request.Path
});
}
}
}

View File

@ -1,17 +0,0 @@
namespace Bootstrap.Admin.Models
{
/// <summary>
///
/// </summary>
public class LockModel : LoginModel
{
/// <summary>
///
/// </summary>
public string DisplayName { get; set; }
/// <summary>
///
/// </summary>
public string ReturnUrl { get; set; }
}
}

View File

@ -8,6 +8,7 @@
<script src="~/js/fileinput.js"></script>
<script src="~/js/fileinput.zh.js"></script>
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/longbow.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
<script src="~/js/Profiles.js"></script>
}
@ -17,8 +18,8 @@
}
<div class="panel panel-default">
<div class="panel-heading">基本资料</div>
<div class="panel-body">
<form id="infoDataForm" name="infoDataForm" class="form-inline" role="form">
<div class="panel-body" data-toggle="LgbValidate" data-valid-button="#btnSaveDisplayName">
<form class="form-inline" role="form">
<div class="row">
<div class="form-group col-xs-12 col-sm-6">
<label class="control-label" for="userName">登陆名称</label>
@ -26,45 +27,45 @@
</div>
<div class="form-group col-xs-12 col-sm-6">
<label class="control-label" for="DisplayName">显示名称</label>
<input type="text" class="form-control" id="displayName" name="displayName" value="@Model.DisplayName" placeholder="不可为空50字以内" maxlength="50" />
<input type="text" class="form-control" id="displayName" name="displayName" value="@Model.DisplayName" placeholder="不可为空50字以内" maxlength="50" data-valid="true" />
</div>
</div>
</form>
<div class="modal-footer">
<button id="btnSaveDisplayName" class="btn btn-default" type="button" disabled data-admin="@User.IsInRole("Administrators")"><i class="fa fa-save"></i><span>保存</span></button>
<button id="btnSaveDisplayName" data-method="user" class="btn btn-default" type="button" disabled data-admin="@User.IsInRole("Administrators")"><i class="fa fa-save"></i><span>保存</span></button>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">修改密码</div>
<div class="panel-body">
<form id="passwordDataForm" name="passwordDataForm" class="form-inline" role="form">
<div class="panel-body" data-toggle="LgbValidate" data-valid-button="#btnSavePassword">
<form class="form-inline" role="form">
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label" for="currentPassword">原密码: </label>
<input type="password" class="form-control" id="currentPassword" name="currentPassword" placeholder="原密码50字以内" maxlength="50" />
<input type="password" class="form-control" id="currentPassword" name="currentPassword" placeholder="原密码50字以内" maxlength="50" data-valid="true" />
</div>
</div>
<div class="row">
<div class="form-group col-sm-6 col-xs-12">
<label class="control-label" for="newPassword">新密码: </label>
<input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="新密码50字以内" maxlength="50" />
<input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="新密码50字以内" maxlength="50" data-valid="true" />
</div>
<div class="form-group col-sm-6 col-xs-12">
<label class="control-label" for="confirmPassword">确认密码: </label>
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" placeholder="与新密码一致50字以内" maxlength="50" />
<input type="password" class="form-control" id="confirmPassword" name="confirmPassword" placeholder="与新密码一致50字以内" maxlength="50" data-valid="true" />
</div>
</div>
</form>
<div class="modal-footer">
<button id="btnSavePassword" class="btn btn-default" type="button" disabled data-admin="@User.IsInRole("Administrators")"><i class="fa fa-save"></i><span>保存</span></button>
<button id="btnSavePassword" data-method="password" class="btn btn-default" type="button" disabled data-admin="@User.IsInRole("Administrators")"><i class="fa fa-save"></i><span>保存</span></button>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">网站皮肤</div>
<div class="panel-body">
<form id="cssDataForm" name="cssDataForm" class="form-inline" role="form">
<form class="form-inline" role="form">
<div class="row">
<div class="form-group col-xs-12">
<label class="control-label" for="userName">样式</label>
@ -86,7 +87,7 @@
</div>
</form>
<div class="modal-footer">
<button id="btnSaveCss" class="btn btn-default" type="button" disabled data-admin="@User.IsInRole("Administrators")"><i class="fa fa-save"></i><span>保存</span></button>
<button id="btnSaveCss" data-method="css" class="btn btn-default" type="button" disabled data-admin="@User.IsInRole("Administrators")"><i class="fa fa-save"></i><span>保存</span></button>
</div>
</div>
</div>

View File

@ -1,35 +0,0 @@
@model Bootstrap.Admin.Models.LockModel
@{
ViewBag.Title = "系统登陆";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@section css {
<link href="~/css/lock.css" rel="stylesheet" />
}
@section javascript {
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
<script src="~/js/lock.js"></script>
}
<div class="lock-wrapper">
<div id="time"></div>
<div class="lock-box text-center">
<img alt="lock avatar" src="~/images/logo2.jpg" />
<h1>@Model.DisplayName</h1>
<span class="locked">系统已锁定</span>
<form role="form" class="form-inline" method="post" autocomplete="off" action="~/Home/Login?ReturnUrl=@Model.ReturnUrl">
<input type="text" name="username" class="hide" value="@Model.UserName" />
<div class="form-group col-lg-12">
<div class="input-group">
<span class="glyphicon glyphicon-lock input-group-addon"></span>
<input type="password" name="password" class="form-control" value="" autocomplete="off" placeholder="密码" />
<span class="input-group-btn">
<button class="btn btn-lock" type="submit">
<i class="glyphicon glyphicon-arrow-right"></i>
</button>
</span>
</div>
</div>
</form>
</div>
</div>

View File

@ -4,9 +4,9 @@
@section css {
<link href="~/css/sweetalert.css" rel="stylesheet" />
<link href="~/css/toastr.css" rel="stylesheet" />
@RenderSection("css", false)
<link href="~/css/admin.css" rel="stylesheet" />
<link href="~/css/admin-responsive.css" rel="stylesheet" />
@RenderSection("css", false)
}
@section javascript {
<script src="~/js/sweetalert.js"></script>

View File

@ -10,6 +10,7 @@
<script src="~/js/bootstrap-table.js"></script>
<script src="~/js/bootstrap-table-zh-CN.js"></script>
<script src="~/js/jquery.validate.js"></script>
<script src="~/js/longbow.validate.js"></script>
<script src="~/js/messages_zh.js"></script>
@RenderSection("Javascript", false)
}

View File

@ -4,11 +4,11 @@
@section css {
<link href="~/css/bootstrap.css" rel="stylesheet">
<link href="~/css/bootstrap-theme.css" rel="stylesheet">
<link href="~/css/nprogress.css" rel="stylesheet" />
<link href="~/css/font-awesome.css" rel="stylesheet" />
<link href="~/css/nprogress.css" rel="stylesheet" />
@RenderSection("css", false)
<link href="~/css/site.css" rel="stylesheet" />
<link href="~/css/site-responsive.css" rel="stylesheet" />
@RenderSection("css", false)
}
@section javascript {
<script src="~/js/bootstrap.js"></script>
@ -16,7 +16,6 @@
<script src="~/js/Longbow.Common.js"></script>
@RenderSection("Javascript", false)
}
<a id="pathBase" href="~/" class="hidden"></a>
@Html.Partial("Header")
@RenderBody()
@Html.Partial("Footer")

View File

@ -18,6 +18,7 @@
</div>
<![endif]-->
@RenderBody()
<a id="pathBase" href="~/" class="hidden"></a>
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="~/js/jquery-3.1.1.js"></script>
@RenderSection("Javascript", false)

View File

@ -244,7 +244,7 @@
// Menus
Menu = {
url: 'api/Menus/',
iconView: '../Admin/IconView',
iconView: 'Admin/IconView',
title: "授权菜单"
};
@ -256,7 +256,8 @@
// Dicts
Dicts = {
url: 'api/Dicts/'
url: 'api/Dicts/',
css: 'api/Css/',
};
// Profiles
@ -454,7 +455,7 @@
$(function () {
// loading customer css
$.bc({
url: "api/Home", swal: false, method: 'get',
url: Dicts.css, swal: false, method: 'get',
callback: function (result) {
if (result.length > 0)
$('head').append($.format('<link href="{0}css/{1}" rel="stylesheet" type="text/css" />', $('#pathBase').attr('href'), result));

View File

@ -20,32 +20,6 @@
if (!!url) $headerIcon.attr('src', url);
});
$('#infoDataForm').autoValidate({
displayName: {
required: true,
maxlength: 50
}
}, {
button: ['btnSaveDisplayName']
});
$('#passwordDataForm').autoValidate({
currentPassword: {
required: true,
maxlength: 50
},
newPassword: {
required: true,
maxlength: 50
},
confirmPassword: {
required: true,
equalTo: "#newPassword",
maxlength: 50
}
}, {
button: ['btnSavePassword']
});
var bsa = new BootstrapAdmin({
url: Profiles.url,
bootstrapTable: null,
@ -57,20 +31,18 @@
UserName: "userName",
Css: "css"
}
}),
click: {
assign: [{
id: 'btnSavePassword',
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
})
});
$('button[data-method]').on('click', function (e) {
var $this = $(this);
var data = bsa.dataEntity.get();
switch ($this.attr('data-method')) {
case 'password':
data.UserStatus = 2;
$.bc({ url: User.url, method: "PUT", data: data, title: "更改密码" });
}
}
}, {
id: 'btnSaveDisplayName',
click: function (row, data) {
if ($(this).attr('data-valid') == "true") {
break;
case 'user':
data.UserStatus = 1;
$.bc({
url: User.url, method: "PUT", data: data, title: "修改用户显示名称",
@ -80,18 +52,13 @@
}
}
});
}
}
}, {
id: 'btnSaveCss',
click: function (row, data) {
break;
case 'css':
data.UserStatus = 3;
$.bc({ url: User.url, method: "PUT", data: data, title: "保存样式" });
}
}]
break;
}
});
$('button[data-admin="False"]').removeAttr('disabled');
$('#kvFileinputModal').appendTo('body');
});

View File

@ -162,12 +162,12 @@
});
$.bc({
url: 'api/Home', swal: false,
url: Dicts.css, swal: false,
callback: function (result) {
var html = result.map(function (ele, index) { return $.format('<li><a href="#" data-val="{1}">{0}</a></li>', ele.Name, ele.Code); }).join('');
$('#cssContainer').append(html);
$.bc({
url: 'api/Home', swal: false, method: 'get',
url: Dicts.css, swal: false, method: 'get',
callback: function (result) {
if (result.length > 0)
$('.lgbDropdown').lgbDropdown('val', result);

View File

@ -110,7 +110,7 @@
required: true,
maxlength: 50,
remote: {
url: "../api/Users/",
url: $.formatUrl("/api/Users/"),
type: "PUT",
data: {
UserStatus: 9

View File

@ -100,7 +100,7 @@ namespace Bootstrap.DataAccess
/// <param name="keys"></param>
internal static void ClearCache(IEnumerable<string> keys)
{
CacheManager.Clear(k => keys.Any(key => key == k));
CacheManager.Clear(keys);
CacheManager.CorsClear(keys);
}
}

View File

@ -94,7 +94,7 @@ namespace Bootstrap.DataAccess
/// <param name="code"></param>
/// <param name="category"></param>
/// <returns></returns>
public static bool SaveSettings(string name, string code, string category)
public static bool SaveSettings(BootstrapDict dict)
{
var ret = false;
string sql = "Update Dicts set Code = @Code where Category = @Category and Name = @Name";
@ -102,9 +102,9 @@ namespace Bootstrap.DataAccess
{
using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql))
{
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", name));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", code));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", category));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", dict.Name));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", dict.Code));
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", dict.Category));
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
}
CacheCleanUtility.ClearCache(dictIds: string.Empty);

View File

@ -45,7 +45,6 @@ INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [C
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (12, 0, N'通知管理', 120, N'fa fa-bell', N'~/Admin/Notifications', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (13, 0, N'系统日志', 130, N'fa fa-gears', N'~/Admin/Logs', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (14, 0, N'程序异常', 140, N'fa fa-cubes', N'~/Admin/Exceptions', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (15, 0, N'锁定屏幕', 10, N'fa fa-lock', N'~/Home/Lock', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (16, 0, N'工具集合', 160, N'fa fa-gavel', N'#', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (17, 16, N'客户端测试', 10, N'fa fa-wrench', N'~/Admin/Mobile', N'0')
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (18, 16, N'API文档', 10, N'fa fa-wrench', N'~/Admin/Api', N'0')
@ -79,7 +78,6 @@ INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (1, 2)
INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (2, 2)
INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (3, 2)
INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (10, 2)
INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (15, 2)
INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (16, 2)
INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (17, 2)
INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (18, 2)