From f4c442d6cecf757b94a681a2bf10dea81f2deb91 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Sun, 28 Jun 2020 09:17:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E5=8F=B0=E5=89=8D=E5=90=8E=E7=AB=AF?= =?UTF-8?q?=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: f4cd35e8dae827272959d2ec8922dcd698edeb7c Former-commit-id: af6fed96be2b6198c5514b82c257243314db5109 --- projects/IoTCenter/Api/SiteController.cs | 66 +++++++++++++++++++ projects/WebMVC/wwwroot/index.html | 60 +++++++++++++++-- projects/WebMVC/wwwroot/index2.html | 60 ++--------------- projects/WebMVC/wwwroot/js/common.js | 3 +- projects/WebMVC/wwwroot/js/components.js | 2 +- projects/WebMVC/wwwroot/js/config.js | 2 +- projects/WebMVC/wwwroot/js/signalr.js | 1 - projects/WebMVC/wwwroot/pages/admin/home.html | 14 ++++ projects/WebMVC/wwwroot/pages/admin/list.html | 14 ++++ projects/WebMVC/wwwroot/pages/device.html | 3 +- projects/WebMVC/wwwroot/pages/home.html | 4 +- projects/WebMVC/wwwroot/pages/node.html | 3 +- projects/WebMVC/wwwroot/pages/nodes.html | 4 +- projects/WebMVC/wwwroot/pages/organs.html | 2 +- projects/WebMVC/wwwroot/pages/product.html | 4 +- .../{components => pages/shared}/layout.html | 36 ++++++---- 16 files changed, 192 insertions(+), 86 deletions(-) create mode 100644 projects/IoTCenter/Api/SiteController.cs create mode 100644 projects/WebMVC/wwwroot/pages/admin/home.html create mode 100644 projects/WebMVC/wwwroot/pages/admin/list.html rename projects/WebMVC/wwwroot/{components => pages/shared}/layout.html (80%) diff --git a/projects/IoTCenter/Api/SiteController.cs b/projects/IoTCenter/Api/SiteController.cs new file mode 100644 index 00000000..db0679d9 --- /dev/null +++ b/projects/IoTCenter/Api/SiteController.cs @@ -0,0 +1,66 @@ +using Application.Domain.Entities; +using Infrastructure.Application.Services.Settings; +using Infrastructure.Data; +using Infrastructure.Extensions; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace IoTCenter.Api.Controllers +{ + [ApiVersion("1.0")] + [Route("api/v{version:apiVersion}/[controller]/[action]")] + [ApiController] + public class SiteController : ControllerBase + { + private readonly ILogger _logger; + private readonly ISettingService _settingService; + private readonly IRepository _userRepo; + + public SiteController( + ILogger logger, + ISettingService settingService, + IRepository userRepo) + { + this._logger = logger; + this._settingService = settingService; + this._userRepo = userRepo; + } + + public IActionResult GetSite() + { + try + { + var username = User.Identity.IsAuthenticated ? this.HttpContext.User.Identity.Name : null; + var permissions = new List(); + if (User.Identity.IsAuthenticated) + { + permissions = this._userRepo.ReadOnlyTable() + .Where(o => o.UserName == username) + .SelectMany(o => o.UserRoles) + .Select(o => o.Role) + .SelectMany(o => o.RolePermissions) + .Select(o => o.Permission) + .Select(o => o.Number) + .ToList(); + } + return Ok(new + { + logo = this._settingService.GetSetting("logo").Value, + name = this._settingService.GetSetting("name").Value, + copyright = this._settingService.GetSetting("copyright").Value, + version = Helper.Instance.GetVersion(), + username, + permissions + }); + } + catch (Exception ex) + { + this._logger.LogError(ex, ex.Message); + return Problem(ex.Message); + } + } + } +} \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/index.html b/projects/WebMVC/wwwroot/index.html index 1258669c..caec820b 100644 --- a/projects/WebMVC/wwwroot/index.html +++ b/projects/WebMVC/wwwroot/index.html @@ -1,12 +1,58 @@ - - + + + + + + + + + + + + - - + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/index2.html b/projects/WebMVC/wwwroot/index2.html index caec820b..1258669c 100644 --- a/projects/WebMVC/wwwroot/index2.html +++ b/projects/WebMVC/wwwroot/index2.html @@ -1,58 +1,12 @@ - - + + - - - - - - - - - - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - + + - \ No newline at end of file + diff --git a/projects/WebMVC/wwwroot/js/common.js b/projects/WebMVC/wwwroot/js/common.js index 0a3b8cba..6c333548 100644 --- a/projects/WebMVC/wwwroot/js/common.js +++ b/projects/WebMVC/wwwroot/js/common.js @@ -32,7 +32,7 @@ function update(list, item, key) { list.push(item); result = true; } - console.log(result ? 'insert' : 'update' + ' data by ' + key); + //console.log(result ? 'insert' : 'update' + ' data by ' + key); return result; } //delete @@ -87,7 +87,6 @@ function execApi(number, method, query) { loading.show(); axios.post(config.baseUrl+'/IoTCenter/api/v1/api/execApi', { connectionId, number, method, query }) .then(function (response) { - console.log(response); }) .catch(function (error) { console.log(error); diff --git a/projects/WebMVC/wwwroot/js/components.js b/projects/WebMVC/wwwroot/js/components.js index ebc7c6df..a58e0c3b 100644 --- a/projects/WebMVC/wwwroot/js/components.js +++ b/projects/WebMVC/wwwroot/js/components.js @@ -1,5 +1,5 @@ Vue.component('layout', function (resolve, reject) { - axios.get("/components/layout.html").then(function (response) { + axios.get("/pages/shared/layout.html").then(function (response) { resolve(parseModel(response)); }); }); \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/js/config.js b/projects/WebMVC/wwwroot/js/config.js index dc008f03..3795c833 100644 --- a/projects/WebMVC/wwwroot/js/config.js +++ b/projects/WebMVC/wwwroot/js/config.js @@ -1,4 +1,4 @@ var config = { - baseUrl: 'http://localhost',//window.location.protocol + '//' + window.location.hostname, + baseUrl: window.location.protocol + '//' + window.location.host, isMobile: /(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent) }; \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/js/signalr.js b/projects/WebMVC/wwwroot/js/signalr.js index d8d2dacc..916e308d 100644 --- a/projects/WebMVC/wwwroot/js/signalr.js +++ b/projects/WebMVC/wwwroot/js/signalr.js @@ -22,7 +22,6 @@ connection.on('Connected', function (id) { }); connection.on("ServerToClient", function (method, message, to, from) { - console.log(method + ':' + message); PubSub.publish(method, {message:message,to:to,from:from}); }); connect(); \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/pages/admin/home.html b/projects/WebMVC/wwwroot/pages/admin/home.html new file mode 100644 index 00000000..9ffb89c5 --- /dev/null +++ b/projects/WebMVC/wwwroot/pages/admin/home.html @@ -0,0 +1,14 @@ + + \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/pages/admin/list.html b/projects/WebMVC/wwwroot/pages/admin/list.html new file mode 100644 index 00000000..c5c19891 --- /dev/null +++ b/projects/WebMVC/wwwroot/pages/admin/list.html @@ -0,0 +1,14 @@ + + \ No newline at end of file diff --git a/projects/WebMVC/wwwroot/pages/device.html b/projects/WebMVC/wwwroot/pages/device.html index 01e3fb70..90464323 100644 --- a/projects/WebMVC/wwwroot/pages/device.html +++ b/projects/WebMVC/wwwroot/pages/device.html @@ -1,5 +1,5 @@