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 @@