From 1b6314e685acf63ad27fa45576cd2625a1282efc Mon Sep 17 00:00:00 2001 From: Eric Nguyen Date: Thu, 12 Oct 2023 20:25:22 +0700 Subject: [PATCH] clean up cors policy --- .../Controllers/PostContentApiController.cs | 55 +- src/applications/Mixcore/Startup.cs | 22 +- .../wwwroot/mix-app/js/app-portal.min.js | 9114 ++++++++--------- .../wwwroot/mix-app/js/app-shared.min.js | 1112 +- .../components/mix-column-editor/view.html | 2 +- .../mix.portal/Controllers/MixDbController.cs | 52 +- src/platform/core/mix-heart | 2 +- .../mix.constant/Constants/MixCorsPolicies.cs | 7 + src/platform/mix.library/Startup/Cors.cs | 9 + .../Repositories/MixRepoDbRepository.cs | 19 +- .../mix.signalr/Models/SignalRMessageModel.cs | 12 +- 11 files changed, 5254 insertions(+), 5152 deletions(-) create mode 100644 src/platform/mix.constant/Constants/MixCorsPolicies.cs diff --git a/src/applications/Mixcore/Controllers/PostContentApiController.cs b/src/applications/Mixcore/Controllers/PostContentApiController.cs index 04ffadcf0..9e4805542 100644 --- a/src/applications/Mixcore/Controllers/PostContentApiController.cs +++ b/src/applications/Mixcore/Controllers/PostContentApiController.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Cors; +using Microsoft.AspNetCore.Mvc; +using Mix.Heart.Exceptions; using Mix.Heart.Extensions; using Mix.Heart.Helpers; using Mix.Lib.Models.Common; @@ -9,6 +11,7 @@ namespace Mixcore.Controllers { + [EnableCors(MixCorsPolicies.PublicApis)] [Route("api/v2/rest/mixcore/post-content")] public sealed class PostContentApiController : MixQueryApiControllerBase { @@ -29,8 +32,8 @@ public PostContentApiController( IMixMetadataService metadataService, MixRepoDbRepository repoDbRepository, IPortalHubClientService portalHub, - IMixTenantService mixTenantService) - : base(httpContextAccessor, configuration, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _postService = postService; @@ -42,36 +45,48 @@ public PostContentApiController( [HttpPost("filter")] public async Task>> Filter([FromBody] FilterContentRequestDto req) { - var searchRequest = BuildSearchRequest(req); - searchRequest.Predicate = searchRequest.Predicate.AndAlsoIf( - !string.IsNullOrEmpty(req.MixDatabaseName), m => m.MixDatabaseName == req.MixDatabaseName); - if (!string.IsNullOrEmpty(req.MixDatabaseName) && req.Queries.Count > 0) + try { - _mixRepoDbRepository.InitTableName(req.MixDatabaseName); - var listData = await _mixRepoDbRepository.GetListByAsync(req.Queries, "id, parentId"); - if (listData != null) + var searchRequest = BuildSearchRequest(req); + searchRequest.Predicate = searchRequest.Predicate.AndAlsoIf( + !string.IsNullOrEmpty(req.MixDatabaseName), m => m.MixDatabaseName == req.MixDatabaseName); + if (!string.IsNullOrEmpty(req.MixDatabaseName) && req.Queries.Count > 0) { - List allowIds = new(); - foreach (var data in listData) + _mixRepoDbRepository.InitTableName(req.MixDatabaseName); + var listData = await _mixRepoDbRepository.GetListByAsync(req.Queries, "Id, ParentId"); + if (listData != null) { - allowIds.Add(ReflectionHelper.ParseObject(data).Value("parentId")); + List allowIds = new(); + foreach (var data in listData) + { + // used JObject.FromObject to keep original reponse fieldName + allowIds.Add(JObject.FromObject(data).Value("ParentId")); + } + searchRequest.Predicate = searchRequest.Predicate.AndAlso(m => allowIds.Contains(m.Id)); } - searchRequest.Predicate = searchRequest.Predicate.AndAlso(m => allowIds.Contains(m.Id)); } + var result = await Repository.GetPagingAsync(searchRequest.Predicate, searchRequest.PagingData); + foreach (var item in result.Items) + { + await item.LoadAdditionalDataAsync(_repoDbRepository, _metadataService, CacheService); + } + return Ok(ParseSearchResult(req, result)); } - var result = await Repository.GetPagingAsync(searchRequest.Predicate, searchRequest.PagingData); - foreach (var item in result.Items) + catch (MixException) { - await item.LoadAdditionalDataAsync(_repoDbRepository, _metadataService, CacheService); + throw; + } + catch (Exception ex) + { + throw new MixException(MixErrorStatus.Badrequest, ex); } - return Ok(ParseSearchResult(req, result)); } protected override async Task> SearchHandler(SearchRequestDto req, CancellationToken cancellationToken = default) { var searchPostQuery = new SearchPostQueryModel(Request, req, CurrentTenant.Id); - - var result= await _postService.SearchPosts(searchPostQuery, cancellationToken); + + var result = await _postService.SearchPosts(searchPostQuery, cancellationToken); foreach (var item in result.Items) { await item.LoadAdditionalDataAsync(_mixRepoDbRepository, _metadataService, CacheService); diff --git a/src/applications/Mixcore/Startup.cs b/src/applications/Mixcore/Startup.cs index a3af3c818..242f39d2d 100644 --- a/src/applications/Mixcore/Startup.cs +++ b/src/applications/Mixcore/Startup.cs @@ -45,7 +45,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } - app.UseMixCors(); app.UseMixTenant(); @@ -53,13 +52,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseRouting(); - // must go between app.UseRouting() and app.UseEndpoints. - app.UseMixAuth(); - - app.UseMixApps(Assembly.GetExecutingAssembly(), Configuration, env.ContentRootPath, env.IsDevelopment()); - - app.UseResponseCompression(); - app.UseMixResponseCaching(); + // Typically, UseStaticFiles is called before UseCors. Apps that use JavaScript to retrieve static files cross site must call UseCors before UseStaticFiles. app.UseMixStaticFiles(env.ContentRootPath); app.UseStaticFiles(); app.UseStaticFiles(new StaticFileOptions @@ -68,6 +61,19 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) Path.Combine(env.ContentRootPath, MixFolders.TemplatesFolder)) }); + // UseCors must be placed after UseRouting and before UseAuthorization. This is to ensure that CORS headers are included in the response for both authorized and unauthorized calls. + app.UseMixCors(); + + // must go between app.UseRouting() and app.UseEndpoints. + app.UseMixAuth(); + + app.UseMixApps(Assembly.GetExecutingAssembly(), Configuration, env.ContentRootPath, env.IsDevelopment()); + + app.UseResponseCompression(); + app.UseMixResponseCaching(); + + + if (GlobalConfigService.Instance.AppSettings.IsHttps) { app.UseHttpsRedirection(); diff --git a/src/applications/Mixcore/wwwroot/mix-app/js/app-portal.min.js b/src/applications/Mixcore/wwwroot/mix-app/js/app-portal.min.js index 5eb916463..63cd5cd99 100644 --- a/src/applications/Mixcore/wwwroot/mix-app/js/app-portal.min.js +++ b/src/applications/Mixcore/wwwroot/mix-app/js/app-portal.min.js @@ -1,4 +1,4 @@ -/* Sat Sep 23 2023 13:55:58 GMT+0700 (Indochina Time) */"use strict"; +/* Thu Oct 12 2023 19:21:38 GMT+0700 (Indochina Time) */"use strict"; var app = angular.module("MixPortal", [ "angularCroppie", "ui.bootstrap", @@ -167,6 +167,181 @@ app.factory("TemplateService", [ }, ]); +"use strict"; +app.controller("AppSettingsController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$timeout", + "$location", + "AuthService", + "ApiService", + "CommonService", + "AppSettingsServices", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $timeout, + $location, + authService, + apiService, + commonService, + appSettingsServices + ) { + $scope.appSettings = null; + $scope.errors = []; + $scope.statuses = ngAppSettings.contentStatuses; + $scope.cultures = $rootScope.globalSettings.cultures; + $scope.settingTypes = [ + "Global", + "Log", + "RateLimit", + "Kiotviet", + "Authentication", + "Portal", + "EPPlus", + "IPSecurity", + "MixHeart", + "Quartz", + "Smtp", + "Endpoint", + "Azure", + "Ocelot", + "Storage", + "Queue", + "Payments", + "GoogleFirebase", + "GoogleCredential", + ]; + $scope.type = "Global"; + $scope.getAppSettings = async function (type) { + $rootScope.isBusy = true; + $scope.type = type; + $scope.appSettings = null; + setTimeout(async () => { + var resp = await appSettingsServices.getAppSettings($scope.type); + if (resp && resp.success) { + $scope.appSettings = JSON.stringify(resp.data, null, "\t"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }, 200); + }; + $scope.updateAppSettings = function (content) { + $scope.appSettings = content; + }; + $scope.loadAppSettings = async function () { + $rootScope.isBusy = true; + await $scope.getAppSettings("Global"); + + await apiService.initAllSettings(); + $scope.mixConfigurations = $rootScope.mixConfigurations; + $rootScope.isBusy = false; + $scope.$apply(); + + // load portal menus + // commonService.loadJsonData("portal-menus.json").then((resp) => { + // $scope.menus = resp.data.items; + // $rootScope.isBusy = false; + // $scope.$apply(); + // }); + }; + + $scope.stopApplication = async function () { + $rootScope.isBusy = true; + await commonService.stopApplication(); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + }; + $scope.clearCache = async function () { + $rootScope.isBusy = true; + await commonService.clearCache(); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + }; + $scope.saveAppSettings = async function (appSettings) { + $rootScope.isBusy = true; + var resp = await appSettingsServices.saveAppSettings( + $scope.type, + appSettings + ); + if (resp && resp.success) { + $scope.appSettings = resp.data; + $rootScope.showMessage( + "Please stop application to restart application pool", + "warning" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.factory("AppSettingsServices", [ + "$http", + "$rootScope", + "ApiService", + "CommonService", + function ($http, $rootScope, apiService, commonService) { + //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; + + var appSettingssServiceFactory = {}; + + var settings = $rootScope.globalSettings; + + var _getAppSettings = async function (name) { + var url = `/rest/settings/${name}`; + + var req = { + method: "GET", + url: url, + }; + return await apiService.sendRequest(req); + }; + + var _saveAppSettings = async function (name, appSettings) { + var url = `/rest/settings/${name}`; + var req = { + method: "POST", + url: url, + data: appSettings, + }; + return await apiService.sendRequest(req); + }; + // var _saveAppSettings = async function (name, content) { + // var apiUrl = "/admin/app-settings/save-global/" + name; + // var req = { + // method: "POST", + // url: apiUrl, + // data: JSON.stringify(content), + // }; + // return await apiService.sendRequest(req); + // }; + + appSettingssServiceFactory.getAppSettings = _getAppSettings; + appSettingssServiceFactory.saveAppSettings = _saveAppSettings; + return appSettingssServiceFactory; + }, +]); + "use strict"; app.controller("MixApplicationController", [ "$scope", @@ -200,7 +375,7 @@ app.controller("MixApplicationController", [ $scope.current = null; $scope.themeRequest = angular.copy(ngAppSettings.request); $scope.themeRequest.orderBy = "createdDatetime"; - $scope.themeRequest.mixDatabaseName = "mixcorePortalApp"; + $scope.themeRequest.mixDatabaseName = "mixApplicationPackage"; $scope.themeRequest.queries = [ { fieldName: "mixcoreVersion", value: "2.0.1" }, ]; @@ -323,22 +498,22 @@ app.factory("MixApplicationRestService", [ ]); "use strict"; -app.controller("AuditLogController", [ +app.controller("ConfigurationController", [ "$scope", "$rootScope", "ngAppSettings", - "$location", "$routeParams", - "AuthService", - "AuditLogRestService", + "$location", + "ConfigurationService", + "ApiService", function ( $scope, $rootScope, ngAppSettings, - $location, $routeParams, - authService, - service + $location, + service, + apiService ) { BaseRestCtrl.call( this, @@ -349,111 +524,83 @@ app.controller("AuditLogController", [ ngAppSettings, service ); - BaseHub.call(this, $scope); - authService.fillAuthData(); - $scope.request.status = null; - $scope.messages = []; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - - $scope.connect = () => { - $scope.startConnection( - "log-stream-hub", - authService.authentication.accessToken, - (err) => { - if ( - authService.authentication.refreshToken && - err.message.indexOf("401") >= 0 - ) { - authService.refreshToken().then(async () => { - $scope.startConnection( - "log-stream-hub", - authService.authentication.accessToken - ); - }); - } - } - ); + $scope.init = function () { + $scope.request.category = $routeParams.category || ""; + $scope.getList(); }; - $scope.receiveMessage = function (msg) { - switch (msg.action) { - case "MyConnection": - $scope.hubRequest.from = msg.data; - $scope.$apply(); - break; - case "NewMessage": - $scope.newMessage(msg); - - break; + $scope.getSingleSuccessCallback = function () { + $scope.cates = ngAppSettings.enums?.configuration_cates; + $scope.appSettings = $rootScope.globalSettings; + $scope.request.category = $routeParams.category || ""; + if (!$scope.viewmodel.id) { + $scope.viewmodel.dataType = "Text"; } - }; - $scope.newMessage = function (msg) { - msg.style = $scope.getMessageType(msg.type); - if (msg.data) { - msg.data = JSON.parse(msg.data); + if (!$scope.viewmodel.category) { + $scope.viewmodel.category = "Site"; } - $scope.messages.push(msg); - $scope.$apply(); - - setTimeout(() => { - $("body,html").animate( - { - scrollTop: $("#log-stream-container").height(), // Scroll to top of body - }, - 500 - ); - }, 200); }; - $scope.getMessageType = function (type) { - switch (type) { - case "Success": - return "success"; - case "Error": - return "danger"; - case "Warning": - return "warning"; - case "Info": - return "info"; - default: - return "default"; - } + $scope.saveSuccessCallback = function () { + apiService.getAllSettings().then(function () { + // $location.url($scope.referrerUrl); + $rootScope.isBusy = false; + $scope.$apply(); + }); }; - $scope.view = function (item) { - item.objClass = item.success ? "text-success" : "text-danger"; - $rootScope.preview("object", item, null, "modal-lg"); + $scope.removeCallback = function () { + apiService.getAllSettings().then(function () { + $location.url($scope.referrerUrl); + }); + }; + + $scope.generateName = function () { + $scope.viewmodel.keyword = $rootScope.generateKeyword( + $scope.viewmodel.keyword, + "_", + true + ); }; }, ]); "use strict"; -app.factory("AuditLogRestService", [ +app.factory("ConfigurationService", [ "BaseRestService", - function (baseService) { + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { var serviceFactory = Object.create(baseService); - serviceFactory.initService("/rest", "mix-log/audit-log", true); - var _search = async function (objData, queries = null) { - var data = serviceFactory.parseQuery(objData); + serviceFactory.init("configuration"); - var url = `${this.prefixUrl}/search`; + var _uploadConfiguration = async function (configurationFile) { + //var container = $(this).parents('.model-configuration').first().find('.custom-file').first(); + if ( + configurationFile.file !== undefined && + configurationFile.file !== null + ) { + // Create FormData object + var files = new FormData(); - if (data) { - url += "?"; - url = url.concat(data); - if (queries) { - url += "&"; - var extraQueries = serviceFactory.parseQuery(queries); - url = url.concat(extraQueries); - } + // Looping over all files and add it to FormData object + files.append(configurationFile.file.name, configurationFile.file); + + // Adding one more key to FormData object + files.append("fileFolder", configurationFile.folder); + files.append("title", configurationFile.title); + files.append("description", configurationFile.description); + + var req = { + url: this.prefixUrl + "/upload", + type: "POST", + headers: {}, + contentType: false, // Not to set any content header + processData: false, // Not to process data + data: files, + }; + + return await apiService.sendRequest(req); } - var req = { - serviceBase: this.serviceBase, - apiVersion: this.apiVersion, - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); }; - serviceFactory.getList = _search; + serviceFactory.uploadConfiguration = _uploadConfiguration; return serviceFactory; }, ]); @@ -542,285 +689,386 @@ app.factory("CultureService", [ ]); "use strict"; -app.controller("AppSettingsController", [ +app.controller("DomainController", [ "$scope", "$rootScope", "ngAppSettings", + "$location", "$routeParams", - "$timeout", + "DomainRestService", + function ( + $scope, + $rootScope, + ngAppSettings, + $location, + $routeParams, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.request.columns = [ + "id", + "displayName", + "host", + "createdDateTime", + "createdBy", + ]; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + }, +]); + +"use strict"; +app.factory("DomainRestService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-domain"); + return serviceFactory; + }, +]); + +"use strict"; +app.controller("AuditLogController", [ + "$scope", + "$rootScope", + "ngAppSettings", "$location", + "$routeParams", "AuthService", - "ApiService", - "CommonService", - "AppSettingsServices", + "AuditLogRestService", function ( $scope, $rootScope, ngAppSettings, - $routeParams, - $timeout, $location, + $routeParams, authService, - apiService, - commonService, - appSettingsServices + service ) { - $scope.appSettings = null; - $scope.errors = []; - $scope.statuses = ngAppSettings.contentStatuses; - $scope.cultures = $rootScope.globalSettings.cultures; - $scope.settingTypes = [ - "Global", - "Log", - "RateLimit", - "Kiotviet", - "Authentication", - "Portal", - "EPPlus", - "IPSecurity", - "MixHeart", - "Quartz", - "Smtp", - "Endpoint", - "Azure", - "Ocelot", - "Storage", - "Queue", - "Payments", - "GoogleFirebase", - "GoogleCredential", - ]; - $scope.type = "Global"; - $scope.getAppSettings = async function (type) { - $rootScope.isBusy = true; - $scope.type = type; - $scope.appSettings = null; - setTimeout(async () => { - var resp = await appSettingsServices.getAppSettings($scope.type); - if (resp && resp.success) { - $scope.appSettings = JSON.stringify(resp.data, null, "\t"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + BaseHub.call(this, $scope); + authService.fillAuthData(); + $scope.request.status = null; + $scope.messages = []; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + + $scope.connect = () => { + $scope.startConnection( + "log-stream-hub", + authService.authentication.accessToken, + (err) => { + if ( + authService.authentication.refreshToken && + err.message.indexOf("401") >= 0 + ) { + authService.refreshToken().then(async () => { + $scope.startConnection( + "log-stream-hub", + authService.authentication.accessToken + ); + }); } - $rootScope.isBusy = false; - $scope.$apply(); } - }, 200); - }; - $scope.updateAppSettings = function (content) { - $scope.appSettings = content; + ); }; - $scope.loadAppSettings = async function () { - $rootScope.isBusy = true; - await $scope.getAppSettings("Global"); - - await apiService.initAllSettings(); - $scope.mixConfigurations = $rootScope.mixConfigurations; - $rootScope.isBusy = false; - $scope.$apply(); + $scope.receiveMessage = function (msg) { + switch (msg.action) { + case "MyConnection": + $scope.hubRequest.from = msg.data; + $scope.$apply(); + break; + case "NewMessage": + $scope.newMessage(msg); - // load portal menus - // commonService.loadJsonData("portal-menus.json").then((resp) => { - // $scope.menus = resp.data.items; - // $rootScope.isBusy = false; - // $scope.$apply(); - // }); + break; + } }; + $scope.newMessage = function (msg) { + msg.style = $scope.getMessageType(msg.type); + if (msg.data) { + msg.data = JSON.parse(msg.data); + } + $scope.messages.push(msg); + $scope.$apply(); - $scope.stopApplication = async function () { - $rootScope.isBusy = true; - await commonService.stopApplication(); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - }; - $scope.clearCache = async function () { - $rootScope.isBusy = true; - await commonService.clearCache(); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - }; - $scope.saveAppSettings = async function (appSettings) { - $rootScope.isBusy = true; - var resp = await appSettingsServices.saveAppSettings( - $scope.type, - appSettings - ); - if (resp && resp.success) { - $scope.appSettings = resp.data; - $rootScope.showMessage( - "Please stop application to restart application pool", - "warning" + setTimeout(() => { + $("body,html").animate( + { + scrollTop: $("#log-stream-container").height(), // Scroll to top of body + }, + 500 ); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $scope.$apply(); + }, 200); + }; + $scope.getMessageType = function (type) { + switch (type) { + case "Success": + return "success"; + case "Error": + return "danger"; + case "Warning": + return "warning"; + case "Info": + return "info"; + default: + return "default"; } }; + $scope.view = function (item) { + item.objClass = item.success ? "text-success" : "text-danger"; + $rootScope.preview("object", item, null, "modal-lg"); + }; }, ]); "use strict"; -app.factory("AppSettingsServices", [ - "$http", - "$rootScope", - "ApiService", - "CommonService", - function ($http, $rootScope, apiService, commonService) { - //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; - - var appSettingssServiceFactory = {}; - - var settings = $rootScope.globalSettings; +app.factory("AuditLogRestService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.initService("/rest", "mix-log/audit-log", true); + var _search = async function (objData, queries = null) { + var data = serviceFactory.parseQuery(objData); - var _getAppSettings = async function (name) { - var url = `/rest/settings/${name}`; + var url = `${this.prefixUrl}/search`; + if (data) { + url += "?"; + url = url.concat(data); + if (queries) { + url += "&"; + var extraQueries = serviceFactory.parseQuery(queries); + url = url.concat(extraQueries); + } + } var req = { + serviceBase: this.serviceBase, + apiVersion: this.apiVersion, method: "GET", url: url, }; - return await apiService.sendRequest(req); - }; - - var _saveAppSettings = async function (name, appSettings) { - var url = `/rest/settings/${name}`; - var req = { - method: "POST", - url: url, - data: appSettings, - }; - return await apiService.sendRequest(req); + return await this.getRestApiResult(req); }; - // var _saveAppSettings = async function (name, content) { - // var apiUrl = "/admin/app-settings/save-global/" + name; - // var req = { - // method: "POST", - // url: apiUrl, - // data: JSON.stringify(content), - // }; - // return await apiService.sendRequest(req); - // }; - - appSettingssServiceFactory.getAppSettings = _getAppSettings; - appSettingssServiceFactory.saveAppSettings = _saveAppSettings; - return appSettingssServiceFactory; + serviceFactory.getList = _search; + return serviceFactory; }, ]); "use strict"; -app.controller("ConfigurationController", [ +app.controller("CustomerController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", + "$timeout", "$location", - "ConfigurationService", - "ApiService", + "CustomerServices", function ( $scope, $rootScope, ngAppSettings, $routeParams, + $timeout, $location, - service, - apiService + customerServices ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.init = function () { - $scope.request.category = $routeParams.category || ""; - $scope.getList(); + $scope.request = angular.copy(ngAppSettings.request); + $scope.request.contentStatuses = ["Active"]; + $scope.request.status = "0"; + $scope.activedCustomer = null; + $scope.relatedCustomers = []; + $rootScope.isBusy = false; + $scope.data = { + pageIndex: 0, + pageSize: 1, + totalItems: 0, }; - $scope.getSingleSuccessCallback = function () { - $scope.cates = ngAppSettings.enums?.configuration_cates; - $scope.appSettings = $rootScope.globalSettings; - $scope.request.category = $routeParams.category || ""; - if (!$scope.viewmodel.id) { - $scope.viewmodel.dataType = "Text"; - } - if (!$scope.viewmodel.category) { - $scope.viewmodel.category = "Site"; - } + $scope.errors = []; + + $scope.range = function (max) { + var input = []; + for (var i = 1; i <= max; i += 1) input.push(i); + return input; }; - $scope.saveSuccessCallback = function () { - apiService.getAllSettings().then(function () { - // $location.url($scope.referrerUrl); + + $scope.loadCustomer = async function () { + $rootScope.isBusy = true; + var id = $routeParams.id; + var response = await customerServices.getCustomer(id, "portal"); + if (response.success) { + $scope.activedCustomer = response.data; + $rootScope.initEditor(); $rootScope.isBusy = false; $scope.$apply(); - }); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } }; - $scope.removeCallback = function () { - apiService.getAllSettings().then(function () { - $location.url($scope.referrerUrl); - }); + $scope.loadCustomers = async function (pageIndex) { + if (pageIndex !== undefined) { + $scope.request.pageIndex = pageIndex; + } + if ($scope.request.fromDate !== null) { + var d = new Date($scope.request.fromDate); + $scope.request.fromDate = d.toISOString(); + } + if ($scope.request.toDate !== null) { + var d = new Date($scope.request.toDate); + $scope.request.toDate = d.toISOString(); + } + var resp = await customerServices.getCustomers($scope.request); + if (resp && resp.success) { + $scope.data = resp.data; + //$("html, body").animate({ "scrollTop": "0px" }, 500); + $.each($scope.data.items, function (i, customer) { + $.each($scope.activedCustomers, function (i, e) { + if (e.customerId === customer.id) { + customer.isHidden = true; + } + }); + }); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $scope.$apply(); + } }; - $scope.generateName = function () { - $scope.viewmodel.keyword = $rootScope.generateKeyword( - $scope.viewmodel.keyword, - "_", - true + $scope.removeCustomer = function (id) { + $rootScope.showConfirm( + $scope, + "removeCustomerConfirmed", + [id], + null, + "Remove Customer", + "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; + + $scope.removeCustomerConfirmed = async function (id) { + var result = await customerServices.removeCustomer(id); + if (result.success) { + $rootScope.showMessage("success", "success"); + $scope.loadCustomers(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.saveCustomer = async function (customer) { + customer.content = $(".editor-content").val(); + var resp = await customerServices.saveCustomer(customer); + if (resp && resp.success) { + $scope.activedCustomer = resp.data; + $rootScope.showMessage("Update successfully!", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + //$location.path('/admin/customer/details/' + resp.data.id); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $scope.$apply(); + } + }; }, ]); "use strict"; -app.factory("ConfigurationService", [ - "BaseRestService", - "ApiService", +app.factory("CustomerServices", [ + "$http", + "$rootScope", + "ApiService", "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("configuration"); + function ($http, $rootScope, apiService, commonService) { + //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; - var _uploadConfiguration = async function (configurationFile) { - //var container = $(this).parents('.model-configuration').first().find('.custom-file').first(); - if ( - configurationFile.file !== undefined && - configurationFile.file !== null - ) { - // Create FormData object - var files = new FormData(); + var customersServiceFactory = {}; - // Looping over all files and add it to FormData object - files.append(configurationFile.file.name, configurationFile.file); + var settings = $rootScope.globalSettings; - // Adding one more key to FormData object - files.append("fileFolder", configurationFile.folder); - files.append("title", configurationFile.title); - files.append("description", configurationFile.description); + var _getCustomer = async function (id, type) { + var apiUrl = "/queen-beauty/customer/"; + var url = apiUrl + "details/" + type; + if (id) { + url += "/" + id; + } + var req = { + method: "GET", + url: url, + }; + return await apiService.sendRequest(req); + }; - var req = { - url: this.prefixUrl + "/upload", - type: "POST", - headers: {}, - contentType: false, // Not to set any content header - processData: false, // Not to process data - data: files, - }; + var _initCustomer = async function (type) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "GET", + url: apiUrl + "init/" + type, + }; + return await apiService.sendRequest(req); + }; - return await apiService.sendRequest(req); - } + var _getCustomers = async function (request) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "POST", + url: apiUrl + "list", + data: JSON.stringify(request), + }; + + return await apiService.sendRequest(req); }; - serviceFactory.uploadConfiguration = _uploadConfiguration; - return serviceFactory; + + var _removeCustomer = async function (id) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "GET", + url: apiUrl + "delete/" + id, + }; + return await apiService.sendRequest(req); + }; + + var _saveCustomer = async function (customer) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "POST", + url: apiUrl + "save", + data: JSON.stringify(customer), + }; + return await apiService.sendRequest(req); + }; + + customersServiceFactory.getCustomer = _getCustomer; + customersServiceFactory.initCustomer = _initCustomer; + customersServiceFactory.getCustomers = _getCustomers; + customersServiceFactory.removeCustomer = _removeCustomer; + customersServiceFactory.saveCustomer = _saveCustomer; + return customersServiceFactory; }, ]); @@ -916,14 +1164,15 @@ app.factory("DashboardServices", [ ]); "use strict"; -app.controller("CustomerController", [ +app.controller("FileController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$timeout", "$location", - "CustomerServices", + "AuthService", + "FileServices", function ( $scope, $rootScope, @@ -931,13 +1180,23 @@ app.controller("CustomerController", [ $routeParams, $timeout, $location, - customerServices + authService, + fileServices ) { - $scope.request = angular.copy(ngAppSettings.request); - $scope.request.contentStatuses = ["Active"]; - $scope.request.status = "0"; - $scope.activedCustomer = null; - $scope.relatedCustomers = []; + $scope.request = { + pageSize: "10", + pageIndex: 0, + status: "Published", + orderBy: "CreatedDateTime", + direction: "Desc", + fromDate: null, + toDate: null, + keyword: "", + key: "", + }; + + $scope.activedFile = null; + $scope.relatedFiles = []; $rootScope.isBusy = false; $scope.data = { pageIndex: 0, @@ -951,14 +1210,25 @@ app.controller("CustomerController", [ for (var i = 1; i <= max; i += 1) input.push(i); return input; }; - - $scope.loadCustomer = async function () { + $scope.loadPage = async function (folder) { + if (folder) { + $scope.request.folder += $scope.request.folder !== "" ? "/" : ""; + $scope.request.folder += folder; + } + $location.url( + "/admin/file/list?folder=" + encodeURIComponent($scope.request.folder) + ); + }; + $scope.loadFile = async function () { $rootScope.isBusy = true; - var id = $routeParams.id; - var response = await customerServices.getCustomer(id, "portal"); + $scope.listUrl = "/admin/file/list?folder/" + $routeParams.folder; + $rootScope.isBusy = true; + var response = await fileServices.getFile( + $routeParams.folder, + $routeParams.filename + ); if (response.success) { - $scope.activedCustomer = response.data; - $rootScope.initEditor(); + $scope.activedFile = response.data; $rootScope.isBusy = false; $scope.$apply(); } else { @@ -967,26 +1237,34 @@ app.controller("CustomerController", [ $scope.$apply(); } }; - $scope.loadCustomers = async function (pageIndex) { - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } - if ($scope.request.fromDate !== null) { - var d = new Date($scope.request.fromDate); - $scope.request.fromDate = d.toISOString(); + $scope.loadFiles = async function (folder) { + if (folder) { + $scope.request.folder += + $scope.request.folder !== "" + ? "MixContent/StaticFiles" + : "MixContent/StaticFiles"; + $scope.request.folder += folder; + } else { + $scope.request.folder = $routeParams.folder + ? $routeParams.folder + : "MixContent/StaticFiles"; } - if ($scope.request.toDate !== null) { - var d = new Date($scope.request.toDate); - $scope.request.toDate = d.toISOString(); + if ($routeParams.folder) { + $scope.backUrl = + "/admin/file/list?folder=" + + $routeParams.folder.substring( + 0, + $routeParams.folder.lastIndexOf("/") + ); } - var resp = await customerServices.getCustomers($scope.request); + $rootScope.isBusy = true; + var resp = await fileServices.getFiles($scope.request); if (resp && resp.success) { $scope.data = resp.data; - //$("html, body").animate({ "scrollTop": "0px" }, 500); - $.each($scope.data.items, function (i, customer) { - $.each($scope.activedCustomers, function (i, e) { - if (e.customerId === customer.id) { - customer.isHidden = true; + $.each($scope.data.items, function (i, file) { + $.each($scope.activedFiles, function (i, e) { + if (e.fileId === file.id) { + file.isHidden = true; } }); }); @@ -996,71 +1274,62 @@ app.controller("CustomerController", [ if (resp) { $rootScope.showErrors(resp.errors); } + $rootScope.isBusy = false; $scope.$apply(); } }; - $scope.removeCustomer = function (id) { - $rootScope.showConfirm( - $scope, - "removeCustomerConfirmed", - [id], - null, - "Remove Customer", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeCustomerConfirmed = async function (id) { - var result = await customerServices.removeCustomer(id); - if (result.success) { - $rootScope.showMessage("success", "success"); - $scope.loadCustomers(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); + $scope.removeFile = async function (id) { + if (confirm("Are you sure!")) { + $rootScope.isBusy = true; + var resp = await fileServices.removeFile(id); + if (resp && resp.success) { + $scope.loadFiles(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } } }; - $scope.saveCustomer = async function (customer) { - customer.content = $(".editor-content").val(); - var resp = await customerServices.saveCustomer(customer); + $scope.saveFile = async function (file) { + $rootScope.isBusy = true; + var resp = await fileServices.saveFile(file); if (resp && resp.success) { - $scope.activedCustomer = resp.data; + $scope.activedFile = resp.data; $rootScope.showMessage("Update successfully!", "success"); $rootScope.isBusy = false; $scope.$apply(); - //$location.path('/admin/customer/details/' + resp.data.id); } else { if (resp) { $rootScope.showErrors(resp.errors); } + $rootScope.isBusy = false; $scope.$apply(); } }; + $scope.updateTemplateContent = function (content) { + $scope.activedFile.content = content; + }; }, ]); "use strict"; -app.factory("CustomerServices", [ +app.factory("FileServices", [ "$http", "$rootScope", "ApiService", "CommonService", - function ($http, $rootScope, apiService, commonService) { - //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; - - var customersServiceFactory = {}; - - var settings = $rootScope.globalSettings; - - var _getCustomer = async function (id, type) { - var apiUrl = "/queen-beauty/customer/"; - var url = apiUrl + "details/" + type; - if (id) { - url += "/" + id; - } + "BaseRestService", + function ($http, $rootScope, apiService, commonService, baseService) { + var filesServiceFactory = angular.copy(baseService); + filesServiceFactory.initService("/rest", "mix-storage/file-system", true); + var _getFile = async function (folder, filename) { + var url = + this.prefixUrl + "/details?folder=" + folder + "&filename=" + filename; var req = { method: "GET", url: url, @@ -1068,232 +1337,10 @@ app.factory("CustomerServices", [ return await apiService.sendRequest(req); }; - var _initCustomer = async function (type) { - var apiUrl = "/queen-beauty/customer/"; + var _initFile = async function (type) { var req = { method: "GET", - url: apiUrl + "init/" + type, - }; - return await apiService.sendRequest(req); - }; - - var _getCustomers = async function (request) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "POST", - url: apiUrl + "list", - data: JSON.stringify(request), - }; - - return await apiService.sendRequest(req); - }; - - var _removeCustomer = async function (id) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "GET", - url: apiUrl + "delete/" + id, - }; - return await apiService.sendRequest(req); - }; - - var _saveCustomer = async function (customer) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "POST", - url: apiUrl + "save", - data: JSON.stringify(customer), - }; - return await apiService.sendRequest(req); - }; - - customersServiceFactory.getCustomer = _getCustomer; - customersServiceFactory.initCustomer = _initCustomer; - customersServiceFactory.getCustomers = _getCustomers; - customersServiceFactory.removeCustomer = _removeCustomer; - customersServiceFactory.saveCustomer = _saveCustomer; - return customersServiceFactory; - }, -]); - -"use strict"; -app.controller("FileController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$timeout", - "$location", - "AuthService", - "FileServices", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $timeout, - $location, - authService, - fileServices - ) { - $scope.request = { - pageSize: "10", - pageIndex: 0, - status: "Published", - orderBy: "CreatedDateTime", - direction: "Desc", - fromDate: null, - toDate: null, - keyword: "", - key: "", - }; - - $scope.activedFile = null; - $scope.relatedFiles = []; - $rootScope.isBusy = false; - $scope.data = { - pageIndex: 0, - pageSize: 1, - totalItems: 0, - }; - $scope.errors = []; - - $scope.range = function (max) { - var input = []; - for (var i = 1; i <= max; i += 1) input.push(i); - return input; - }; - $scope.loadPage = async function (folder) { - if (folder) { - $scope.request.folder += $scope.request.folder !== "" ? "/" : ""; - $scope.request.folder += folder; - } - $location.url( - "/admin/file/list?folder=" + encodeURIComponent($scope.request.folder) - ); - }; - $scope.loadFile = async function () { - $rootScope.isBusy = true; - $scope.listUrl = "/admin/file/list?folder/" + $routeParams.folder; - $rootScope.isBusy = true; - var response = await fileServices.getFile( - $routeParams.folder, - $routeParams.filename - ); - if (response.success) { - $scope.activedFile = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.loadFiles = async function (folder) { - if (folder) { - $scope.request.folder += - $scope.request.folder !== "" - ? "MixContent/StaticFiles" - : "MixContent/StaticFiles"; - $scope.request.folder += folder; - } else { - $scope.request.folder = $routeParams.folder - ? $routeParams.folder - : "MixContent/StaticFiles"; - } - if ($routeParams.folder) { - $scope.backUrl = - "/admin/file/list?folder=" + - $routeParams.folder.substring( - 0, - $routeParams.folder.lastIndexOf("/") - ); - } - $rootScope.isBusy = true; - var resp = await fileServices.getFiles($scope.request); - if (resp && resp.success) { - $scope.data = resp.data; - $.each($scope.data.items, function (i, file) { - $.each($scope.activedFiles, function (i, e) { - if (e.fileId === file.id) { - file.isHidden = true; - } - }); - }); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.removeFile = async function (id) { - if (confirm("Are you sure!")) { - $rootScope.isBusy = true; - var resp = await fileServices.removeFile(id); - if (resp && resp.success) { - $scope.loadFiles(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - - $scope.saveFile = async function (file) { - $rootScope.isBusy = true; - var resp = await fileServices.saveFile(file); - if (resp && resp.success) { - $scope.activedFile = resp.data; - $rootScope.showMessage("Update successfully!", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.updateTemplateContent = function (content) { - $scope.activedFile.content = content; - }; - }, -]); - -"use strict"; -app.factory("FileServices", [ - "$http", - "$rootScope", - "ApiService", - "CommonService", - "BaseRestService", - function ($http, $rootScope, apiService, commonService, baseService) { - var filesServiceFactory = angular.copy(baseService); - filesServiceFactory.initService("/rest", "mix-storage/file-system", true); - var _getFile = async function (folder, filename) { - var url = - this.prefixUrl + "/details?folder=" + folder + "&filename=" + filename; - var req = { - method: "GET", - url: url, - }; - return await apiService.sendRequest(req); - }; - - var _initFile = async function (type) { - var req = { - method: "GET", - url: this.prefixUrl + "/init/" + type, + url: this.prefixUrl + "/init/" + type, }; return await apiService.sendRequest(req); }; @@ -1357,20 +1404,23 @@ app.factory("FileServices", [ ]); "use strict"; -app.controller("DomainController", [ +app.controller("LocalizeController", [ "$scope", "$rootScope", "ngAppSettings", - "$location", "$routeParams", - "DomainRestService", + "$location", + "LocalizeService", + "ApiService", + "CommonService", function ( $scope, $rootScope, ngAppSettings, - $location, $routeParams, - service + $location, + service, + commonService ) { BaseRestCtrl.call( this, @@ -1381,80 +1431,190 @@ app.controller("DomainController", [ ngAppSettings, service ); - $scope.request.columns = [ - "id", - "displayName", - "host", - "createdDateTime", - "createdBy", - ]; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - }, -]); - -"use strict"; -app.factory("DomainRestService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-domain"); - return serviceFactory; - }, -]); -"use strict"; -app.controller("ImportFileController", [ - "$scope", - "$rootScope", - "ImportFileServices", - "TranslatorService", - "AppSettingsService", - function ( - $scope, - $rootScope, - service, - translatorService, - AppSettingsService - ) { - $scope.saveImportFile = async function () { - $rootScope.isBusy = true; - var form = document.getElementById("frm-import"); - var frm = new FormData(); - frm.append("assets", form["assets"].files[0]); - var response = await service.saveImportFile(frm); - if (response.success) { - $scope.viewmodel = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); + $scope.getSingleSuccessCallback = function () { + $scope.cates = ngAppSettings.enums.configuration_cates; + $scope.appSettings = $rootScope.globalSettings; + $scope.request.category = $routeParams.category || ""; + if (!$scope.viewmodel.id) { + $scope.viewmodel.dataType = "Text"; + } + if (!$scope.viewmodel.category) { + $scope.viewmodel.category = "Site"; + } + }; + $scope.saveSuccessCallback = function () { + apiService.getAllSettings().then(function () { + // $location.url($scope.referrerUrl); $rootScope.isBusy = false; $scope.$apply(); + }); + }; + $scope.removeCallback = function () { + apiService.getAllSettings().then(function () { + $location.url($scope.referrerUrl); + }); + }; + + $scope.generateName = function () { + $scope.viewmodel.keyword = $rootScope.generateKeyword( + $scope.viewmodel.keyword, + "_", + true + ); + }; + }, +]); + +"use strict"; +app.factory("LocalizeService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("language"); + + var _uploadLanguage = async function (languageFile) { + //var container = $(this).parents('.model-language').first().find('.custom-file').first(); + if (languageFile.file !== undefined && languageFile.file !== null) { + // Create FormData object + var files = new FormData(); + + // Looping over all files and add it to FormData object + files.append(languageFile.file.name, languageFile.file); + + // Adding one more key to FormData object + files.append("fileFolder", languageFile.folder); + files.append("title", languageFile.title); + files.append("description", languageFile.description); + + var req = { + url: this.prefixUrl + "/upload", + type: "POST", + headers: {}, + contentType: false, // Not to set any content header + processData: false, // Not to process data + data: files, + }; + + return await apiService.sendRequest(req); } }; + serviceFactory.uploadLanguage = _uploadLanguage; + return serviceFactory; }, ]); "use strict"; -app.factory("ImportFileServices", [ +app.controller("loginController", [ "$rootScope", - "BaseService", - function ($rootScope, baseService) { - //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; + "$scope", + "ngAppSettings", + "$location", + "AuthService", + "ngAppSettings", + function ( + $rootScope, + $scope, + ngAppSettings, + $location, + authService, + ngAuthSettings + ) { + if ( + authService.authentication && + authService.authentication.isAuth && + authService.authentication.isAdmin + ) { + authService.referredUrl = $location.path(); + $location.path("/admin"); + } - var serviceFactory = {}; + $scope.pageClass = "page-login"; - var settings = $rootScope.globalSettings; - var serviceFactory = Object.create(baseService); - serviceFactory.init("portal", true); - var _saveImportFile = async function (frm) { - var apiUrl = this.prefixUrl + "/" + settings.lang + "/import"; - return await this.ajaxSubmitForm(frm, apiUrl); + $scope.loginData = { + username: "", + password: "", + rememberme: true, }; - serviceFactory.saveImportFile = _saveImportFile; - return serviceFactory; + $scope.message = ""; + $scope.$on("$viewContentLoaded", function () { + $rootScope.isBusy = false; + }); + $scope.login = async function () { + if (authService.referredUrl === "/init/login") { + authService.referredUrl = "/admin"; + } + $rootScope.isBusy = true; + var result = await authService.login($scope.loginData); + if (result.success) { + if ($routeParams.ReturnUrl) { + window.top.location = $routeParams.ReturnUrl; + } else if ( + document.referrer && + document.referrer.indexOf("init") === -1 + ) { + window.top.location = document.referrer; + } else { + window.top.location = "/"; + } + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + + $scope.authExternalProvider = function (provider) { + var redirectUri = + location.protocol + "//" + location.host + "/authcomplete.html"; + + var externalProviderUrl = + ngAuthSettings.apiServiceBaseUri + + "api/Account/ExternalLogin?provider=" + + provider + + "&response_type=token&client_id=" + + ngAuthSettings.clientId + + "&redirect_uri=" + + redirectUri; + window.$windowScope = $scope; + + var oauthWindow = window.open( + externalProviderUrl, + "Authenticate Account", + "location=0,status=0,width=600,height=750" + ); + }; + + $scope.authCompletedCB = function (fragment) { + $scope.$apply(function () { + if (fragment.haslocalaccount === "False") { + authService.logOut(); + + authService.externalAuthData = { + provider: fragment.provider, + username: fragment.external_user_name, + externalAccessToken: fragment.external_access_token, + }; + + $location.path("/associate"); + } else { + //Obtain access token and redirect to orders + var externalData = { + provider: fragment.provider, + externalAccessToken: fragment.external_access_token, + }; + authService.obtainAccessToken(externalData).then( + function (response) { + $location.path("/orders"); + }, + function (err) { + $scope.message = err.error_description; + } + ); + } + }); + }; }, ]); @@ -1673,23 +1833,26 @@ app.factory("JsonDataService", [ ]); "use strict"; -app.controller("LocalizeController", [ +app.controller("MixDatabaseController", [ "$scope", "$rootScope", + "$location", "ngAppSettings", "$routeParams", - "$location", - "LocalizeService", - "ApiService", - "CommonService", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + "RestMixDatabasePortalService", + "RestMixDatabaseContextService", function ( $scope, $rootScope, + $location, ngAppSettings, $routeParams, - $location, - service, - commonService + databaseDataService, + databaseColumnService, + databaseService, + dbContextService ) { BaseRestCtrl.call( this, @@ -1698,208 +1861,262 @@ app.controller("LocalizeController", [ $location, $routeParams, ngAppSettings, - service + databaseService ); - - $scope.getSingleSuccessCallback = function () { - $scope.cates = ngAppSettings.enums.configuration_cates; - $scope.appSettings = $rootScope.globalSettings; - $scope.request.category = $routeParams.category || ""; - if (!$scope.viewmodel.id) { - $scope.viewmodel.dataType = "Text"; - } - if (!$scope.viewmodel.category) { - $scope.viewmodel.category = "Site"; - } + $scope.defaultAttr = null; + $scope.actions = ["Delete"]; + $scope.viewmodelType = "mix-database"; + // $scope.request.selects = 'id,title,name,createdDateTime'; + $scope.orders = [ + { title: "Id", value: "Id" }, + { title: "Name", value: "Name" }, + { title: "Created Date", value: "CreatedDateTime" }, + ]; + $scope.request.orderBy = "CreatedDateTime"; + $scope.request.columns = "id,displayName,systemName,type,createdDatetime"; + $scope.request.searchColumns = "displayName,systemName"; + $scope.saveDatabase = function () { + $scope.save($scope.viewmodel); }; - $scope.saveSuccessCallback = function () { - apiService.getAllSettings().then(function () { - // $location.url($scope.referrerUrl); + + $scope.getSingleSuccessCallback = async function () { + $scope.viewmodel.mixDatabaseContextId = $routeParams.mixDatabaseContextId; + if ($scope.viewmodel.mixDatabaseContextId) { + var resp = await dbContextService.getSingle([ + $scope.viewmodel.mixDatabaseContextId, + ]); + if (resp.success) { + $scope.dbContext = resp.data; + } + } + if (!$scope.defaultAttr) { + var getDefaultAttr = await databaseColumnService.getDefault(); + if (getDefaultAttr.success) { + $scope.defaultAttr = getDefaultAttr.data; + $scope.defaultAttr.options = []; + } + $scope.$apply(); + } + }; + $scope.migrate = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.migrate($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + "Please restart pool to apply new db schema", + "warning" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot migrate database"]); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + $scope.backup = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.backup($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + `Backup ${$scope.viewmodel.systemName} is queued`, + "success" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot backup database"]); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + $scope.restore = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.restore($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + `Restore ${$scope.viewmodel.systemName} is queued`, + "success" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot restore database"]); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + $scope.updateSchema = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.updateSchema($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + "Please restart pool to apply new db schema", + "warning" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot update database"]); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + + $scope.back = function () { + window.history.back(); + }; + }, +]); + +"use strict"; +app.controller("ImportFileController", [ + "$scope", + "$rootScope", + "ImportFileServices", + "TranslatorService", + "AppSettingsService", + function ( + $scope, + $rootScope, + service, + translatorService, + AppSettingsService + ) { + $scope.saveImportFile = async function () { + $rootScope.isBusy = true; + var form = document.getElementById("frm-import"); + var frm = new FormData(); + frm.append("assets", form["assets"].files[0]); + var response = await service.saveImportFile(frm); + if (response.success) { + $scope.viewmodel = response.data; $rootScope.isBusy = false; $scope.$apply(); - }); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } }; - $scope.removeCallback = function () { - apiService.getAllSettings().then(function () { - $location.url($scope.referrerUrl); - }); + }, +]); + +"use strict"; +app.factory("ImportFileServices", [ + "$rootScope", + "BaseService", + function ($rootScope, baseService) { + //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; + + var serviceFactory = {}; + + var settings = $rootScope.globalSettings; + var serviceFactory = Object.create(baseService); + serviceFactory.init("portal", true); + var _saveImportFile = async function (frm) { + var apiUrl = this.prefixUrl + "/" + settings.lang + "/import"; + return await this.ajaxSubmitForm(frm, apiUrl); }; + serviceFactory.saveImportFile = _saveImportFile; + return serviceFactory; + }, +]); + +"use strict"; +app.controller("MixDatabaseContextController", [ + "$scope", + "$rootScope", + "$location", + "ngAppSettings", + "$routeParams", + "RestMixDatabaseContextService", + function ( + $scope, + $rootScope, + $location, + ngAppSettings, + $routeParams, + mixdbContextService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + mixdbContextService + ); + $scope.defaultAttr = null; + $scope.databaseProvider = ["MySQL", "PostgreSQL", "SQLITE", "SQLSERVER"]; + $scope.actions = ["Delete"]; + // $scope.request.selects = 'id,title,name,createdDateTime'; + $scope.orders = [ + { title: "Id", value: "Id" }, + { title: "Name", value: "DisplayName" }, + { title: "Created Date", value: "CreatedDateTime" }, + ]; + $scope.request.orderBy = "CreatedDateTime"; + $scope.request.columns = "id,displayName,systemName,type,createdDatetime"; + $scope.request.searchColumns = "displayName,systemName"; + $scope.saveDatabase = function () { + $scope.save($scope.viewmodel); + }; $scope.generateName = function () { - $scope.viewmodel.keyword = $rootScope.generateKeyword( - $scope.viewmodel.keyword, + $scope.viewmodel.systemName = $rootScope.generateKeyword( + $scope.viewmodel.displayName, "_", + true, true ); }; + $scope.getSingleSuccessCallback = async function () {}; }, ]); "use strict"; -app.factory("LocalizeService", [ +app.factory("RestMixDatabaseContextService", [ "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { + function (baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("language"); - - var _uploadLanguage = async function (languageFile) { - //var container = $(this).parents('.model-language').first().find('.custom-file').first(); - if (languageFile.file !== undefined && languageFile.file !== null) { - // Create FormData object - var files = new FormData(); - - // Looping over all files and add it to FormData object - files.append(languageFile.file.name, languageFile.file); - - // Adding one more key to FormData object - files.append("fileFolder", languageFile.folder); - files.append("title", languageFile.title); - files.append("description", languageFile.description); - - var req = { - url: this.prefixUrl + "/upload", - type: "POST", - headers: {}, - contentType: false, // Not to set any content header - processData: false, // Not to process data - data: files, - }; + serviceFactory.init("mixdb-context"); - return await apiService.sendRequest(req); - } + var _getByName = async function (name) { + var url = `${this.prefixUrl}/get-by-name/${name}`; + var req = { + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); }; - serviceFactory.uploadLanguage = _uploadLanguage; + serviceFactory.getByName = _getByName; return serviceFactory; }, ]); "use strict"; -app.controller("loginController", [ - "$rootScope", +app.controller("MixDatabaseDataController", [ "$scope", + "$rootScope", "ngAppSettings", + "$routeParams", "$location", - "AuthService", - "ngAppSettings", + "MixDbService", function ( - $rootScope, $scope, + $rootScope, ngAppSettings, - $location, - authService, - ngAuthSettings - ) { - if ( - authService.authentication && - authService.authentication.isAuth && - authService.authentication.isAdmin - ) { - authService.referredUrl = $location.path(); - $location.path("/admin"); - } - - $scope.pageClass = "page-login"; - - $scope.loginData = { - username: "", - password: "", - rememberme: true, - }; - - $scope.message = ""; - $scope.$on("$viewContentLoaded", function () { - $rootScope.isBusy = false; - }); - $scope.login = async function () { - if (authService.referredUrl === "/init/login") { - authService.referredUrl = "/admin"; - } - $rootScope.isBusy = true; - var result = await authService.login($scope.loginData); - if (result.success) { - if ($routeParams.ReturnUrl) { - window.top.location = $routeParams.ReturnUrl; - } else if ( - document.referrer && - document.referrer.indexOf("init") === -1 - ) { - window.top.location = document.referrer; - } else { - window.top.location = "/"; - } - } - $rootScope.isBusy = false; - $scope.$apply(); - }; - - $scope.authExternalProvider = function (provider) { - var redirectUri = - location.protocol + "//" + location.host + "/authcomplete.html"; - - var externalProviderUrl = - ngAuthSettings.apiServiceBaseUri + - "api/Account/ExternalLogin?provider=" + - provider + - "&response_type=token&client_id=" + - ngAuthSettings.clientId + - "&redirect_uri=" + - redirectUri; - window.$windowScope = $scope; - - var oauthWindow = window.open( - externalProviderUrl, - "Authenticate Account", - "location=0,status=0,width=600,height=750" - ); - }; - - $scope.authCompletedCB = function (fragment) { - $scope.$apply(function () { - if (fragment.haslocalaccount === "False") { - authService.logOut(); - - authService.externalAuthData = { - provider: fragment.provider, - username: fragment.external_user_name, - externalAccessToken: fragment.external_access_token, - }; - - $location.path("/associate"); - } else { - //Obtain access token and redirect to orders - var externalData = { - provider: fragment.provider, - externalAccessToken: fragment.external_access_token, - }; - authService.obtainAccessToken(externalData).then( - function (response) { - $location.path("/orders"); - }, - function (err) { - $scope.message = err.error_description; - } - ); - } - }); - }; - }, -]); - -"use strict"; -app.controller("MixDatabaseDataController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "MixDbService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, + $routeParams, $location, mixDbService ) { @@ -2238,151 +2455,6 @@ app.controller("MixDatabaseDataController", [ }, ]); -"use strict"; -app.controller("MixDatabaseController", [ - "$scope", - "$rootScope", - "$location", - "ngAppSettings", - "$routeParams", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "RestMixDatabasePortalService", - "RestMixDatabaseContextService", - function ( - $scope, - $rootScope, - $location, - ngAppSettings, - $routeParams, - databaseDataService, - databaseColumnService, - databaseService, - dbContextService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - databaseService - ); - $scope.defaultAttr = null; - $scope.actions = ["Delete"]; - $scope.viewmodelType = "mix-database"; - // $scope.request.selects = 'id,title,name,createdDateTime'; - $scope.orders = [ - { title: "Id", value: "Id" }, - { title: "Name", value: "Name" }, - { title: "Created Date", value: "CreatedDateTime" }, - ]; - $scope.request.orderBy = "CreatedDateTime"; - $scope.request.columns = "id,displayName,systemName,type,createdDatetime"; - $scope.request.searchColumns = "displayName,systemName"; - $scope.saveDatabase = function () { - $scope.save($scope.viewmodel); - }; - - $scope.getSingleSuccessCallback = async function () { - $scope.viewmodel.mixDatabaseContextId = $routeParams.mixDatabaseContextId; - if ($scope.viewmodel.mixDatabaseContextId) { - var resp = await dbContextService.getSingle([ - $scope.viewmodel.mixDatabaseContextId, - ]); - if (resp.success) { - $scope.dbContext = resp.data; - } - } - if (!$scope.defaultAttr) { - var getDefaultAttr = await databaseColumnService.getDefault(); - if (getDefaultAttr.success) { - $scope.defaultAttr = getDefaultAttr.data; - $scope.defaultAttr.options = []; - } - $scope.$apply(); - } - }; - $scope.migrate = async function () { - if ($scope.viewmodel.id) { - $rootScope.isBusy = true; - var result = await databaseService.migrate($scope.viewmodel); - if (result.success) { - $rootScope.showMessage( - "Please restart pool to apply new db schema", - "warning" - ); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot migrate database"]); - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - $scope.backup = async function () { - if ($scope.viewmodel.id) { - $rootScope.isBusy = true; - var result = await databaseService.backup($scope.viewmodel); - if (result.success) { - $rootScope.showMessage( - `Backup ${$scope.viewmodel.systemName} is queued`, - "success" - ); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot backup database"]); - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - $scope.restore = async function () { - if ($scope.viewmodel.id) { - $rootScope.isBusy = true; - var result = await databaseService.restore($scope.viewmodel); - if (result.success) { - $rootScope.showMessage( - `Restore ${$scope.viewmodel.systemName} is queued`, - "success" - ); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot restore database"]); - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - $scope.updateSchema = async function () { - if ($scope.viewmodel.id) { - $rootScope.isBusy = true; - var result = await databaseService.updateSchema($scope.viewmodel); - if (result.success) { - $rootScope.showMessage( - "Please restart pool to apply new db schema", - "warning" - ); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot update database"]); - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - - $scope.back = function () { - window.history.back(); - }; - }, -]); - "use strict"; app.controller("ModuleController", [ "$scope", @@ -2694,78 +2766,6 @@ app.factory("ModuleRestService", [ }, ]); -"use strict"; -app.controller("MixDatabaseContextController", [ - "$scope", - "$rootScope", - "$location", - "ngAppSettings", - "$routeParams", - "RestMixDatabaseContextService", - function ( - $scope, - $rootScope, - $location, - ngAppSettings, - $routeParams, - mixdbContextService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - mixdbContextService - ); - $scope.defaultAttr = null; - $scope.databaseProvider = ["MySQL", "PostgreSQL", "SQLITE", "SQLSERVER"]; - $scope.actions = ["Delete"]; - // $scope.request.selects = 'id,title,name,createdDateTime'; - $scope.orders = [ - { title: "Id", value: "Id" }, - { title: "Name", value: "DisplayName" }, - { title: "Created Date", value: "CreatedDateTime" }, - ]; - $scope.request.orderBy = "CreatedDateTime"; - $scope.request.columns = "id,displayName,systemName,type,createdDatetime"; - $scope.request.searchColumns = "displayName,systemName"; - $scope.saveDatabase = function () { - $scope.save($scope.viewmodel); - }; - $scope.generateName = function () { - $scope.viewmodel.systemName = $rootScope.generateKeyword( - $scope.viewmodel.displayName, - "_", - true, - true - ); - }; - $scope.getSingleSuccessCallback = async function () {}; - }, -]); - -"use strict"; -app.factory("RestMixDatabaseContextService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mixdb-context"); - - var _getByName = async function (name) { - var url = `${this.prefixUrl}/get-by-name/${name}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - serviceFactory.getByName = _getByName; - return serviceFactory; - }, -]); - "use strict"; app.controller("ModuleDataController", [ "$scope", @@ -3087,13 +3087,14 @@ app.factory("ModuleGalleryService", [ ]); "use strict"; -app.controller("ModulePostController", [ +app.controller("PageGalleryController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "ModulePostRestService", + "PageGalleryService", + "PostRestService", "ApiService", "CommonService", function ( @@ -3103,6 +3104,8 @@ app.controller("ModulePostController", [ $routeParams, $location, service, + postService, + apiService, commonService ) { BaseCtrl.call( @@ -3113,34 +3116,20 @@ app.controller("ModulePostController", [ ngAppSettings, service ); - $scope.request.culture = $rootScope.globalSettings.defaultCulture; $scope.cates = ["Site", "System"]; $scope.others = []; $scope.mixConfigurations = $rootScope.globalSettings; + $scope.pageId = $routeParams.id; $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.translate = $rootScope.translate; - $scope.moduleIds = $routeParams.moduleIds || $routeParams.id; - $scope.pageIds = $routeParams.page_ids; - $scope.type = $routeParams.type; - $scope.template = $routeParams.template || ""; - - $scope.init = function () { - $scope.createUrl = `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; - $scope.getList(); - }; - $scope.getList = async function (pageIndex) { + $scope.getList = async function () { $rootScope.isBusy = true; - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } var id = $routeParams.id; - $scope.moduleContentId = $routeParams.id; - $scope.request.parentId = id; + $scope.request.query = "&page_id=" + id; + var response = await service.getList($scope.request); $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - var response = await service.search($scope.request); if (response.success) { $scope.data = response.data; $rootScope.isBusy = false; @@ -3151,24 +3140,20 @@ app.controller("ModulePostController", [ $scope.$apply(); } }; - $scope.preview = function (item) { - item.editUrl = "/admin/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); - }; - $scope.remove = function (id) { + $scope.remove = function (pageId, postId) { $rootScope.showConfirm( $scope, "removeConfirmed", - [id], + [pageId, postId], null, "Remove", "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; - $scope.removeConfirmed = async function (id) { + $scope.removeConfirmed = async function (pageId, postId) { $rootScope.isBusy = true; - var result = await service.delete(id); + var result = await service.delete(pageId, postId); if (result.success) { if ($scope.removeCallback) { $rootScope.executeFunctionByName( @@ -3185,8 +3170,6 @@ app.controller("ModulePostController", [ } }; - $scope.removeCallback = function () {}; - $scope.saveOthers = async function () { var response = await service.saveList($scope.others); if (response.success) { @@ -3223,142 +3206,36 @@ app.controller("ModulePostController", [ ]); "use strict"; -app.factory("ModulePostRestService", [ +app.factory("PageGalleryService", [ "$rootScope", "ApiService", "CommonService", - "BaseRestService", + "BaseService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("module-post"); - - var _search = async function (objData) { - var data = serviceFactory.parseQuery(objData); - var url = this.prefixUrl; - - if (data) { - url += "/search?"; - url = url.concat(data); - } + serviceFactory.init("page-post"); + var _delete = async function (pageId, postId) { + var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; var req = { - serviceBase: this.serviceBase, method: "GET", url: url, }; - return await this.getRestApiResult(req); - }; - - var _delete = async function (id) { - var url = this.prefixUrl + "/" + id; - var req = { - method: "DELETE", - url: url, - }; return await apiService.sendRequest(req); }; - var _updateInfos = async function (modules) { + var _updateInfos = async function (pages) { var req = { method: "POST", url: this.prefixUrl + "/update-infos", - data: JSON.stringify(modules), + data: JSON.stringify(pages), }; return await apiService.sendRequest(req); }; - serviceFactory.search = _search; serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; return serviceFactory; }, ]); -"use strict"; -app.controller("OrderDetailController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$location", - "$routeParams", - "RestOrderDetailService", - function ( - $scope, - $rootScope, - ngAppSettings, - $location, - $routeParams, - service - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - BaseHub.call(this, $scope); - $scope.progress = 0; - $scope.viewMode = "list"; - $scope.current = null; - - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - - $scope.init = async function () { - $scope.startConnection("mixEcommerceHub", null, (err) => { - console.log(err); - }); - $scope.onConnected = () => { - $scope.joinRoom("Admin"); - }; - await $scope.getThemes(); - }; - $scope.receiveMessage = function (resp) { - let msg = JSON.parse(resp); - switch (msg.action) { - case "Downloading": - var index = $scope.data.items.findIndex( - (m) => m.id == $scope.current.id - ); - var progress = Math.round(msg.message); - if (index >= 0) { - $scope.progress = progress; - if (progress == 100) { - $scope.installStatus = "Installing"; - } - $scope.$apply(); - } - break; - - default: - console.log(msg); - break; - } - }; - }, -]); - -"use strict"; -app.factory("RestOrderDetailService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.initService("/rest/ecommerce", "order-detail"); - var _updateOrderStatus = async function (id, objData) { - var url = `${this.prefixUrl}/update-order-status/${id}`; - var req = { - serviceBase: this.serviceBase, - method: "POST", - url: url, - data: JSON.stringify(objData), - }; - return await this.getRestApiResult(req); - }; - serviceFactory.updateOrderStatus = _updateOrderStatus; - return serviceFactory; - }, -]); - "use strict"; app.controller("PageController", [ "$scope", @@ -3716,13 +3593,13 @@ app.factory("PageRestService", [ ]); "use strict"; -app.controller("PageGalleryController", [ +app.controller("PagePostController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "PageGalleryService", + "PagePostRestService", "PostRestService", "ApiService", "CommonService", @@ -3734,7 +3611,6 @@ app.controller("PageGalleryController", [ $location, service, postService, - apiService, commonService ) { BaseCtrl.call( @@ -3745,20 +3621,39 @@ app.controller("PageGalleryController", [ ngAppSettings, service ); + $scope.request.culture = $rootScope.globalSettings.defaultCulture; $scope.cates = ["Site", "System"]; $scope.others = []; $scope.mixConfigurations = $rootScope.globalSettings; - $scope.pageId = $routeParams.id; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.getList = async function () { - $rootScope.isBusy = true; - var id = $routeParams.id; - $scope.request.query = "&page_id=" + id; - var response = await service.getList($scope.request); + $scope.init = function () { + $scope.pageId = $routeParams.id; + $scope.type = $routeParams.type || ""; + $scope.template = $routeParams.template || ""; + $scope.pageIds = $routeParams.page_ids || $routeParams.id || ""; + $scope.moduleIds = $routeParams.module_ids || ""; $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; + $scope.request.orderBy === "Priority" && + $scope.request.direction === "Asc"; + $scope.createUrl = + $routeParams.post_type === "gallery" + ? "/admin/post/create-gallery" + : `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; + $scope.updateUrl = + $routeParams.post_type === "gallery" + ? "/admin/post/gallery-details" + : "/admin/post/details"; + }; + $scope.getList = async function (pageIndex) { + if (pageIndex !== undefined) { + $scope.request.pageIndex = pageIndex; + } + $rootScope.isBusy = true; + var id = $routeParams.id; + $scope.request.query = "&page_id=" + id; + var response = await service.getList($scope.request); + $scope.canDrag = + $scope.request.orderBy === "Priority" && + $scope.request.direction === "Asc"; if (response.success) { $scope.data = response.data; $rootScope.isBusy = false; @@ -3769,6 +3664,10 @@ app.controller("PageGalleryController", [ $scope.$apply(); } }; + $scope.preview = function (item) { + item.editUrl = "/admin/post/details/" + item.id; + $rootScope.preview("post", item, item.title, "modal-lg"); + }; $scope.remove = function (pageId, postId) { $rootScope.showConfirm( $scope, @@ -3779,10 +3678,13 @@ app.controller("PageGalleryController", [ "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; + $scope.back = function () { + window.history.back(); + }; - $scope.removeConfirmed = async function (pageId, postId) { + $scope.removeConfirmed = async function (id) { $rootScope.isBusy = true; - var result = await service.delete(pageId, postId); + var result = await service.delete(id); if (result.success) { if ($scope.removeCallback) { $rootScope.executeFunctionByName( @@ -3793,7 +3695,7 @@ app.controller("PageGalleryController", [ } $scope.getList(); } else { - $rootScope.showMessage("failed"); + $rootScope.showErrors(result.errors); $rootScope.isBusy = false; $scope.$apply(); } @@ -3835,21 +3737,21 @@ app.controller("PageGalleryController", [ ]); "use strict"; -app.factory("PageGalleryService", [ +app.factory("PagePostRestService", [ "$rootScope", "ApiService", "CommonService", - "BaseService", + "BaseRestService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("page-post"); - var _delete = async function (pageId, postId) { - var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; + serviceFactory.init("mix-page-post"); + var _delete = async function (id) { + var url = this.prefixUrl + "/delete/" + id; var req = { method: "GET", url: url, }; - return await apiService.sendRequest(req); + return await apiService.getApiResult(req); }; var _updateInfos = async function (pages) { var req = { @@ -3857,7 +3759,7 @@ app.factory("PageGalleryService", [ url: this.prefixUrl + "/update-infos", data: JSON.stringify(pages), }; - return await apiService.sendRequest(req); + return await apiService.getApiResult(req); }; serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; @@ -3866,14 +3768,13 @@ app.factory("PageGalleryService", [ ]); "use strict"; -app.controller("PagePostController", [ +app.controller("ModulePostController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "PagePostRestService", - "PostRestService", + "ModulePostRestService", "ApiService", "CommonService", function ( @@ -3883,7 +3784,6 @@ app.controller("PagePostController", [ $routeParams, $location, service, - postService, commonService ) { BaseCtrl.call( @@ -3898,35 +3798,30 @@ app.controller("PagePostController", [ $scope.cates = ["Site", "System"]; $scope.others = []; $scope.mixConfigurations = $rootScope.globalSettings; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.translate = $rootScope.translate; + $scope.moduleIds = $routeParams.moduleIds || $routeParams.id; + $scope.pageIds = $routeParams.page_ids; + $scope.type = $routeParams.type; + $scope.template = $routeParams.template || ""; + $scope.init = function () { - $scope.pageId = $routeParams.id; - $scope.type = $routeParams.type || ""; - $scope.template = $routeParams.template || ""; - $scope.pageIds = $routeParams.page_ids || $routeParams.id || ""; - $scope.moduleIds = $routeParams.module_ids || ""; - $scope.canDrag = - $scope.request.orderBy === "Priority" && - $scope.request.direction === "Asc"; - $scope.createUrl = - $routeParams.post_type === "gallery" - ? "/admin/post/create-gallery" - : `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; - $scope.updateUrl = - $routeParams.post_type === "gallery" - ? "/admin/post/gallery-details" - : "/admin/post/details"; + $scope.createUrl = `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; + $scope.getList(); }; $scope.getList = async function (pageIndex) { + $rootScope.isBusy = true; if (pageIndex !== undefined) { $scope.request.pageIndex = pageIndex; } - $rootScope.isBusy = true; var id = $routeParams.id; - $scope.request.query = "&page_id=" + id; - var response = await service.getList($scope.request); + $scope.moduleContentId = $routeParams.id; + $scope.request.parentId = id; $scope.canDrag = - $scope.request.orderBy === "Priority" && - $scope.request.direction === "Asc"; + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; + var response = await service.search($scope.request); if (response.success) { $scope.data = response.data; $rootScope.isBusy = false; @@ -3941,19 +3836,16 @@ app.controller("PagePostController", [ item.editUrl = "/admin/post/details/" + item.id; $rootScope.preview("post", item, item.title, "modal-lg"); }; - $scope.remove = function (pageId, postId) { + $scope.remove = function (id) { $rootScope.showConfirm( $scope, "removeConfirmed", - [pageId, postId], + [id], null, "Remove", "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; - $scope.back = function () { - window.history.back(); - }; $scope.removeConfirmed = async function (id) { $rootScope.isBusy = true; @@ -3968,12 +3860,14 @@ app.controller("PagePostController", [ } $scope.getList(); } else { - $rootScope.showErrors(result.errors); + $rootScope.showMessage("failed"); $rootScope.isBusy = false; $scope.$apply(); } }; + $scope.removeCallback = function () {}; + $scope.saveOthers = async function () { var response = await service.saveList($scope.others); if (response.success) { @@ -4010,30 +3904,48 @@ app.controller("PagePostController", [ ]); "use strict"; -app.factory("PagePostRestService", [ +app.factory("ModulePostRestService", [ "$rootScope", "ApiService", "CommonService", "BaseRestService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-page-post"); - var _delete = async function (id) { - var url = this.prefixUrl + "/delete/" + id; + serviceFactory.init("module-post"); + + var _search = async function (objData) { + var data = serviceFactory.parseQuery(objData); + var url = this.prefixUrl; + + if (data) { + url += "/search?"; + url = url.concat(data); + } var req = { + serviceBase: this.serviceBase, method: "GET", url: url, }; - return await apiService.getApiResult(req); + return await this.getRestApiResult(req); }; - var _updateInfos = async function (pages) { + + var _delete = async function (id) { + var url = this.prefixUrl + "/" + id; + var req = { + method: "DELETE", + url: url, + }; + return await apiService.sendRequest(req); + }; + var _updateInfos = async function (modules) { var req = { method: "POST", url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), + data: JSON.stringify(modules), }; - return await apiService.getApiResult(req); + return await apiService.sendRequest(req); }; + serviceFactory.search = _search; serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; return serviceFactory; @@ -4041,22 +3953,26 @@ app.factory("PagePostRestService", [ ]); "use strict"; -app.controller("QueueLogController", [ +app.controller("PermissionController", [ "$scope", "$rootScope", "ngAppSettings", - "$location", "$routeParams", - "AuthService", - "QueueLogRestService", + "$location", + "ApiService", + "CommonService", + "PermissionService", + "RestPortalPageNavigationService", function ( $scope, $rootScope, ngAppSettings, - $location, $routeParams, - authService, - service + $location, + apiService, + commonService, + service, + navService ) { BaseRestCtrl.call( this, @@ -4067,78 +3983,118 @@ app.controller("QueueLogController", [ ngAppSettings, service ); - authService.fillAuthData(); - $scope.request.status = null; - $scope.messages = []; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.getListSuccessCallback = function () { - angular.forEach($scope.data.items, function (e) { - switch (e.state) { - case "ACK": - e.objClass = "text-success"; - break; - case "NACK": - e.objClass = "text-warning"; - break; - case "FAILED": - e.objClass = "text-danger"; - break; - default: - e.objClass = "text-info"; - break; + $scope.request.level = 0; + $scope.miOptions = ngAppSettings.miIcons; + $scope.initDialog = function () { + $("#dlg-permission").on("shown.bs.modal", function () { + $scope.initCurrentPath(); + }); + }; + + $scope.initCurrentPath = async function () { + var resp = await service.getDefault(); + if (resp && resp.success) { + $scope.viewmodel = resp.data; + $scope.viewmodel.url = $location.url(); + $rootScope.isBusy = false; + $scope.$applyAsync(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + if ($scope.getSingleFailCallback) { + $scope.getSingleFailCallback(); } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.saveSuccessCallback = function () { + $scope.getSingle(); + }; + + $scope.dragStart = function (index) { + $scope.minPriority = $scope.data.items[0].priority; + $scope.dragStartIndex = index; + }; + $scope.updateOrders = function (index) { + if (index > $scope.dragStartIndex) { + $scope.data.items.splice($scope.dragStartIndex, 1); + } else { + $scope.data.items.splice($scope.dragStartIndex + 1, 1); + } + angular.forEach($scope.data.items, function (e, i) { + e.priority = $scope.minPriority + i; + service.saveFields(e.id, { priority: e.priority }).then((resp) => { + $rootScope.isBusy = false; + $scope.$apply(); + }); }); }; - $scope.view = function (item) { - switch (item.state) { - case "ACK": - item.objClass = "text-success"; - break; - case "NACK": - item.objClass = "text-warning"; - break; - case "FAILED": - item.objClass = "text-danger"; - break; - default: - item.objClass = "text-info"; - break; + + $scope.updateChildInfos = async function (items) { + $rootScope.isBusy = true; + var resp = await service.updateChildInfos(items); + if (resp && resp.success) { + $scope.activedPage = resp.data; + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); } - $rootScope.preview("object", item, null, "modal-lg"); }; + $("#dlg-favorite").on("show.bs.modal", function (event) { + $scope.initCurrentPath(); + }); }, ]); "use strict"; -app.factory("QueueLogRestService", [ +app.factory("PermissionService", [ "BaseRestService", - function (baseService) { - var serviceFactory = angular.copy(baseService); - serviceFactory.initService("/rest", "mix-log/queue-log", true); - var _search = async function (objData, queries = null) { - var data = serviceFactory.parseQuery(objData); - - var url = `${this.prefixUrl}/search`; + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.initService("/rest/mix-services", "permission", true); + var _updateInfos = async function (pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), + }; + return await apiService.sendRequest(req); + }; - if (data) { - url += "?"; - url = url.concat(data); - if (queries) { - url += "&"; - var extraQueries = serviceFactory.parseQuery(queries); - url = url.concat(extraQueries); - } - } + var _updateChildInfos = async function (pages) { var req = { - serviceBase: this.serviceBase, - apiVersion: this.apiVersion, - method: "GET", - url: url, + method: "POST", + url: this.prefixUrl + "/update-child-infos", + data: JSON.stringify(pages), }; - return await this.getRestApiResult(req); + return await apiService.sendRequest(req); }; - serviceFactory.getList = _search; + + serviceFactory.updateInfos = _updateInfos; + serviceFactory.updateChildInfos = _updateChildInfos; + return serviceFactory; + }, +]); + +"use strict"; +app.factory("RestPortalPageNavigationService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("portal-page-navigation", true); + return serviceFactory; }, ]); @@ -4637,153 +4593,6 @@ app.factory("PostRestService", [ }, ]); -"use strict"; -app.controller("PermissionController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "ApiService", - "CommonService", - "PermissionService", - "RestPortalPageNavigationService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - apiService, - commonService, - service, - navService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.request.level = 0; - $scope.miOptions = ngAppSettings.miIcons; - $scope.initDialog = function () { - $("#dlg-permission").on("shown.bs.modal", function () { - $scope.initCurrentPath(); - }); - }; - - $scope.initCurrentPath = async function () { - var resp = await service.getDefault(); - if (resp && resp.success) { - $scope.viewmodel = resp.data; - $scope.viewmodel.url = $location.url(); - $rootScope.isBusy = false; - $scope.$applyAsync(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - if ($scope.getSingleFailCallback) { - $scope.getSingleFailCallback(); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.saveSuccessCallback = function () { - $scope.getSingle(); - }; - - $scope.dragStart = function (index) { - $scope.minPriority = $scope.data.items[0].priority; - $scope.dragStartIndex = index; - }; - $scope.updateOrders = function (index) { - if (index > $scope.dragStartIndex) { - $scope.data.items.splice($scope.dragStartIndex, 1); - } else { - $scope.data.items.splice($scope.dragStartIndex + 1, 1); - } - angular.forEach($scope.data.items, function (e, i) { - e.priority = $scope.minPriority + i; - service.saveFields(e.id, { priority: e.priority }).then((resp) => { - $rootScope.isBusy = false; - $scope.$apply(); - }); - }); - }; - - $scope.updateChildInfos = async function (items) { - $rootScope.isBusy = true; - var resp = await service.updateChildInfos(items); - if (resp && resp.success) { - $scope.activedPage = resp.data; - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $("#dlg-favorite").on("show.bs.modal", function (event) { - $scope.initCurrentPath(); - }); - }, -]); - -"use strict"; -app.factory("PermissionService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.initService("/rest/mix-services", "permission", true); - var _updateInfos = async function (pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), - }; - return await apiService.sendRequest(req); - }; - - var _updateChildInfos = async function (pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-child-infos", - data: JSON.stringify(pages), - }; - return await apiService.sendRequest(req); - }; - - serviceFactory.updateInfos = _updateInfos; - serviceFactory.updateChildInfos = _updateChildInfos; - return serviceFactory; - }, -]); - -"use strict"; -app.factory("RestPortalPageNavigationService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("portal-page-navigation", true); - - return serviceFactory; - }, -]); - "use strict"; app.controller("RoleController", [ "$scope", @@ -4877,60 +4686,251 @@ app.factory("RoleService", [ ]); "use strict"; -app.controller("SchedulerController", [ +app.controller("OrderDetailController", [ "$scope", "$rootScope", - "$routeParams", + "ngAppSettings", "$location", - "SchedulerService", - function ($scope, $rootScope, $routeParams, $location, service) { - $scope.jobs = []; - $scope.intervalTypes = [ - "Second", - "Minute", - "Hour", - "Day", - "Week", - "Month", - "Year", - ]; - $scope.templates = { - "Mix.Scheduler.Jobs.KeepPoolAliveJob": { - domain: "https://example.com", - }, - "Mix.Scheduler.Jobs.PublishScheduledPostsJob": {}, - "Mix.Scheduler.Jobs.SendMessageQueueJob": { - data: { - topic: "", - action: "", - data: {}, - }, - }, - "Mix.Scheduler.Jobs.SendPortalMessageJob": { - data: { - topic: "", - action: "", - data: "", - }, - }, - }; - $scope.schedule = { - jobData: { - data: { - type: "Info", - from: { - connectionId: "", - userName: "", - avatar: "", - }, - title: "value", - message: "content", - data: {}, - }, - }, - cronExpression: null, - name: null, - groupName: null, + "$routeParams", + "RestOrderDetailService", + function ( + $scope, + $rootScope, + ngAppSettings, + $location, + $routeParams, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + BaseHub.call(this, $scope); + $scope.progress = 0; + $scope.viewMode = "list"; + $scope.current = null; + + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + + $scope.init = async function () { + $scope.startConnection("mixEcommerceHub", null, (err) => { + console.log(err); + }); + $scope.onConnected = () => { + $scope.joinRoom("Admin"); + }; + await $scope.getThemes(); + }; + $scope.receiveMessage = function (resp) { + let msg = JSON.parse(resp); + switch (msg.action) { + case "Downloading": + var index = $scope.data.items.findIndex( + (m) => m.id == $scope.current.id + ); + var progress = Math.round(msg.message); + if (index >= 0) { + $scope.progress = progress; + if (progress == 100) { + $scope.installStatus = "Installing"; + } + $scope.$apply(); + } + break; + + default: + console.log(msg); + break; + } + }; + }, +]); + +"use strict"; +app.factory("RestOrderDetailService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.initService("/rest/ecommerce", "order-detail"); + var _updateOrderStatus = async function (id, objData) { + var url = `${this.prefixUrl}/update-order-status/${id}`; + var req = { + serviceBase: this.serviceBase, + method: "POST", + url: url, + data: JSON.stringify(objData), + }; + return await this.getRestApiResult(req); + }; + serviceFactory.updateOrderStatus = _updateOrderStatus; + return serviceFactory; + }, +]); + +"use strict"; +app.controller("QueueLogController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$location", + "$routeParams", + "AuthService", + "QueueLogRestService", + function ( + $scope, + $rootScope, + ngAppSettings, + $location, + $routeParams, + authService, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + authService.fillAuthData(); + $scope.request.status = null; + $scope.messages = []; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.getListSuccessCallback = function () { + angular.forEach($scope.data.items, function (e) { + switch (e.state) { + case "ACK": + e.objClass = "text-success"; + break; + case "NACK": + e.objClass = "text-warning"; + break; + case "FAILED": + e.objClass = "text-danger"; + break; + default: + e.objClass = "text-info"; + break; + } + }); + }; + $scope.view = function (item) { + switch (item.state) { + case "ACK": + item.objClass = "text-success"; + break; + case "NACK": + item.objClass = "text-warning"; + break; + case "FAILED": + item.objClass = "text-danger"; + break; + default: + item.objClass = "text-info"; + break; + } + $rootScope.preview("object", item, null, "modal-lg"); + }; + }, +]); + +"use strict"; +app.factory("QueueLogRestService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = angular.copy(baseService); + serviceFactory.initService("/rest", "mix-log/queue-log", true); + var _search = async function (objData, queries = null) { + var data = serviceFactory.parseQuery(objData); + + var url = `${this.prefixUrl}/search`; + + if (data) { + url += "?"; + url = url.concat(data); + if (queries) { + url += "&"; + var extraQueries = serviceFactory.parseQuery(queries); + url = url.concat(extraQueries); + } + } + var req = { + serviceBase: this.serviceBase, + apiVersion: this.apiVersion, + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + serviceFactory.getList = _search; + return serviceFactory; + }, +]); + +"use strict"; +app.controller("SchedulerController", [ + "$scope", + "$rootScope", + "$routeParams", + "$location", + "SchedulerService", + function ($scope, $rootScope, $routeParams, $location, service) { + $scope.jobs = []; + $scope.intervalTypes = [ + "Second", + "Minute", + "Hour", + "Day", + "Week", + "Month", + "Year", + ]; + $scope.templates = { + "Mix.Scheduler.Jobs.KeepPoolAliveJob": { + domain: "https://example.com", + }, + "Mix.Scheduler.Jobs.PublishScheduledPostsJob": {}, + "Mix.Scheduler.Jobs.SendMessageQueueJob": { + data: { + topic: "", + action: "", + data: {}, + }, + }, + "Mix.Scheduler.Jobs.SendPortalMessageJob": { + data: { + topic: "", + action: "", + data: "", + }, + }, + }; + $scope.schedule = { + jobData: { + data: { + type: "Info", + from: { + connectionId: "", + userName: "", + avatar: "", + }, + title: "value", + message: "content", + data: {}, + }, + }, + cronExpression: null, + name: null, + groupName: null, jobName: null, description: null, startAt: null, @@ -5245,183 +5245,7 @@ app.factory("SchedulerService", [ ]); "use strict"; -app.controller("ServiceController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "RestMixDatabasePortalService", - "ApiService", - "CommonService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service, - commonService - ) { - BaseODataCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - $scope.defaultId = "default"; - $scope.parentId = null; - $scope.parentType = null; - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.mixConfigurations = $rootScope.globalSettings; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.init = async function () { - $scope.mixDatabaseId = $routeParams.mixDatabaseId; - $scope.mixDatabaseName = $routeParams.mixDatabaseName; - $scope.dataContentId = $routeParams.dataContentId; - }; - $scope.saveSuccessCallback = function () { - $rootScope.isBusy = false; - $scope.$apply(); - // if($scope.parentId){ - // $location.url('/admin/mix-database-data/details?dataContentId='+ $scope.parentId); - // } - // else{ - // $location.url('/admin/mix-database-data/list?mixDatabaseId='+ $scope.viewmodel.mixDatabaseId); - // } - }; - $scope.getList = async function () { - $rootScope.isBusy = true; - $scope.mixDatabaseId = $routeParams.mixDatabaseId; - $scope.mixDatabaseName = $routeParams.mixDatabaseName; - var type = $routeParams.type; - var parentId = $routeParams.parentId; - var response = await service.getList( - "read", - $scope.request, - $scope.mixDatabaseId, - $scope.mixDatabaseName, - type, - parentId - ); - $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; - if (response) { - $scope.data = response; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors("Failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.getSingle = async function () { - $rootScope.isBusy = true; - var id = $routeParams.id || $scope.defaultId; - $scope.mixDatabaseId = $routeParams.mixDatabaseId; - $scope.mixDatabaseName = $routeParams.mixDatabaseName; - var resp = await service.getSingle("portal", [ - id, - $scope.mixDatabaseId, - $scope.mixDatabaseName, - ]); - if (resp) { - $scope.viewmodel = resp; - $scope.viewmodel.parentType = $scope.parentType; - $scope.viewmodel.parentId = $scope.parentId; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors("Failed"); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.preview = function (item) { - item.editUrl = "/admin/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); - }; - $scope.edit = function (data) { - $scope.goToPath( - "/admin/mix-database-data/details?dataContentId=" + - data.id + - "&mixDatabaseId=" + - $scope.mixDatabaseId - ); - }; - $scope.remove = function (data) { - $rootScope.showConfirm( - $scope, - "removeConfirmed", - [data.id], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeConfirmed = async function (dataContentId) { - $rootScope.isBusy = true; - var result = await service.delete([dataContentId]); - if (result.success) { - if ($scope.removeCallback) { - $rootScope.executeFunctionByName( - "removeCallback", - $scope.removeCallbackArgs, - $scope - ); - } - $scope.getList(); - } else { - $rootScope.showErrors(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.saveOthers = async function () { - var response = await service.saveList($scope.others); - if (response.success) { - $scope.getList(); - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.controller("StoreController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "CryptoService", - "ThemeService", - "StoreService", - function ( - $scope, - $rootScope, - ngAppSettings, - cryptoService, - themeService, - service - ) { - }, -]); - -"use strict"; -app.controller("SocialFeedController", [ +app.controller("SocialFeedController", [ "$rootScope", "$scope", "$http", @@ -5690,91 +5514,248 @@ app.controller("SocialFeedController", [ ]); "use strict"; -app.controller("TemplateController", [ +app.controller("ServiceController", [ "$scope", "$rootScope", + "ngAppSettings", "$routeParams", "$location", - "ngAppSettings", - "AuthService", - "TemplateService", + "RestMixDatabasePortalService", + "ApiService", + "CommonService", function ( $scope, $rootScope, + ngAppSettings, $routeParams, $location, - ngAppSettings, - authService, - service + service, + commonService ) { - BaseRestCtrl.call( + BaseODataCtrl.call( this, $scope, $rootScope, - $location, $routeParams, ngAppSettings, service ); - BaseHub.call(this, $scope); - $scope.folderTypes = [ - "Masters", - "Layouts", - "Pages", - "Modules", - "Forms", - "Edms", - "Products", - "Posts", - "Widgets", - ]; - $scope.isInitHub = false; - $scope.room = null; - $scope.members = []; - $scope.activedPane = null; - $scope.canRename = true; - $scope.user = null; - $scope.selectPane = function (pane) { - $scope.activedPane = pane; - }; + $scope.defaultId = "default"; + $scope.parentId = null; + $scope.parentType = null; + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.mixConfigurations = $rootScope.globalSettings; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; $scope.init = async function () { - authService.fillAuthData().then(function () { - $scope.user = { - username: authService.authentication.info.username, - avatar: authService.authentication.info.avatar, - }; - $scope.canEdit = true; - // $scope.startConnection("editFileHub", () => { - // let id = $routeParams.id || $rootScope.generateUUID(); - // $scope.room = `Template-${id}`; - // $scope.joinRoom(); - // }); - }); - }; - $scope.validate = function () { - $scope.viewmodel.displayName = $scope.viewmodel.fileName; - $scope.viewmodel.extension = ".cshtml"; - return true; - }; - $scope.loadFolder = function (d) { - $location.url( - "/admin/template/list/" + - $routeParams.themeId + - "?folderType=" + - encodeURIComponent(d) - ); + $scope.mixDatabaseId = $routeParams.mixDatabaseId; + $scope.mixDatabaseName = $routeParams.mixDatabaseName; + $scope.dataContentId = $routeParams.dataContentId; }; - $scope.loadParams = async function () { - $rootScope.isBusy = true; - $scope.themeId = $routeParams.themeId; - $scope.folderType = $routeParams.folderType; + $scope.saveSuccessCallback = function () { + $rootScope.isBusy = false; + $scope.$apply(); + // if($scope.parentId){ + // $location.url('/admin/mix-database-data/details?dataContentId='+ $scope.parentId); + // } + // else{ + // $location.url('/admin/mix-database-data/list?mixDatabaseId='+ $scope.viewmodel.mixDatabaseId); + // } }; - $scope.getSingle = async function () { + $scope.getList = async function () { $rootScope.isBusy = true; - var id = $routeParams.id; - $scope.folderType = $routeParams.folderType; - - if (id) { + $scope.mixDatabaseId = $routeParams.mixDatabaseId; + $scope.mixDatabaseName = $routeParams.mixDatabaseName; + var type = $routeParams.type; + var parentId = $routeParams.parentId; + var response = await service.getList( + "read", + $scope.request, + $scope.mixDatabaseId, + $scope.mixDatabaseName, + type, + parentId + ); + $scope.canDrag = + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; + if (response) { + $scope.data = response; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors("Failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.getSingle = async function () { + $rootScope.isBusy = true; + var id = $routeParams.id || $scope.defaultId; + $scope.mixDatabaseId = $routeParams.mixDatabaseId; + $scope.mixDatabaseName = $routeParams.mixDatabaseName; + var resp = await service.getSingle("portal", [ + id, + $scope.mixDatabaseId, + $scope.mixDatabaseName, + ]); + if (resp) { + $scope.viewmodel = resp; + $scope.viewmodel.parentType = $scope.parentType; + $scope.viewmodel.parentId = $scope.parentId; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors("Failed"); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.preview = function (item) { + item.editUrl = "/admin/post/details/" + item.id; + $rootScope.preview("post", item, item.title, "modal-lg"); + }; + $scope.edit = function (data) { + $scope.goToPath( + "/admin/mix-database-data/details?dataContentId=" + + data.id + + "&mixDatabaseId=" + + $scope.mixDatabaseId + ); + }; + $scope.remove = function (data) { + $rootScope.showConfirm( + $scope, + "removeConfirmed", + [data.id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + + $scope.removeConfirmed = async function (dataContentId) { + $rootScope.isBusy = true; + var result = await service.delete([dataContentId]); + if (result.success) { + if ($scope.removeCallback) { + $rootScope.executeFunctionByName( + "removeCallback", + $scope.removeCallbackArgs, + $scope + ); + } + $scope.getList(); + } else { + $rootScope.showErrors(result.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.saveOthers = async function () { + var response = await service.saveList($scope.others); + if (response.success) { + $scope.getList(); + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.controller("TemplateController", [ + "$scope", + "$rootScope", + "$routeParams", + "$location", + "ngAppSettings", + "AuthService", + "TemplateService", + function ( + $scope, + $rootScope, + $routeParams, + $location, + ngAppSettings, + authService, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + BaseHub.call(this, $scope); + $scope.folderTypes = [ + "Masters", + "Layouts", + "Pages", + "Modules", + "Forms", + "Edms", + "Products", + "Posts", + "Widgets", + ]; + $scope.isInitHub = false; + $scope.room = null; + $scope.members = []; + $scope.activedPane = null; + $scope.canRename = true; + $scope.user = null; + $scope.selectPane = function (pane) { + $scope.activedPane = pane; + }; + $scope.init = async function () { + authService.fillAuthData().then(function () { + $scope.user = { + username: authService.authentication.info.username, + avatar: authService.authentication.info.avatar, + }; + $scope.canEdit = true; + // $scope.startConnection("editFileHub", () => { + // let id = $routeParams.id || $rootScope.generateUUID(); + // $scope.room = `Template-${id}`; + // $scope.joinRoom(); + // }); + }); + }; + $scope.validate = function () { + $scope.viewmodel.displayName = $scope.viewmodel.fileName; + $scope.viewmodel.extension = ".cshtml"; + return true; + }; + $scope.loadFolder = function (d) { + $location.url( + "/admin/template/list/" + + $routeParams.themeId + + "?folderType=" + + encodeURIComponent(d) + ); + }; + $scope.loadParams = async function () { + $rootScope.isBusy = true; + $scope.themeId = $routeParams.themeId; + $scope.folderType = $routeParams.folderType; + }; + $scope.getSingle = async function () { + $rootScope.isBusy = true; + var id = $routeParams.id; + $scope.folderType = $routeParams.folderType; + + if (id) { var resp = await service.getSingle([id], { folderType: $scope.folderType, }); @@ -5921,23 +5902,39 @@ app.controller("TemplateController", [ ]); "use strict"; -app.controller("ThemeController", [ +app.controller("StoreController", [ "$scope", "$rootScope", "ngAppSettings", - "$routeParams", - "$location", + "CryptoService", "ThemeService", - "ApiService", - "CommonService", + "StoreService", + function ( + $scope, + $rootScope, + ngAppSettings, + cryptoService, + themeService, + service + ) { + }, +]); + +"use strict"; +app.controller("TenantController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$location", + "$routeParams", + "TenantRestService", function ( $scope, $rootScope, ngAppSettings, - $routeParams, $location, - service, - commonService + $routeParams, + service ) { BaseRestCtrl.call( this, @@ -5948,39 +5945,90 @@ app.controller("ThemeController", [ ngAppSettings, service ); - $scope.exportData = null; - $scope.exportThemeDto = { - isIncludeAssets: true, - isIncludeTemplates: true, - isIncludeConfigurations: true, - isIncludePermissions: true, - cultureIds: [], - content: { - pageIds: [], - pageContentIds: [], - postIds: [], - postContentIds: [], - moduleIds: [], - moduleContentIds: [], - mixDatabaseIds: [], - }, - associations: { - pageIds: [], - pageContentIds: [], - postIds: [], - postContentIds: [], - moduleIds: [], - moduleContentIds: [], - mixDatabaseIds: [], - }, - }; - - $scope.getSingleSuccessCallback = function () { - $scope.assets = null; - $scope.theme = null; - }; - - $scope.syncTemplates = async function (id) { + $scope.request.columns = [ + "id", + "displayName", + "systemName", + "primaryDomain", + "createdDateTime", + "createdBy", + ]; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + }, +]); + +"use strict"; +app.factory("TenantRestService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-tenant"); + return serviceFactory; + }, +]); + +"use strict"; +app.controller("ThemeController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "ThemeService", + "ApiService", + "CommonService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + commonService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.exportData = null; + $scope.exportThemeDto = { + isIncludeAssets: true, + isIncludeTemplates: true, + isIncludeConfigurations: true, + isIncludePermissions: true, + cultureIds: [], + content: { + pageIds: [], + pageContentIds: [], + postIds: [], + postContentIds: [], + moduleIds: [], + moduleContentIds: [], + mixDatabaseIds: [], + }, + associations: { + pageIds: [], + pageContentIds: [], + postIds: [], + postContentIds: [], + moduleIds: [], + moduleContentIds: [], + mixDatabaseIds: [], + }, + }; + + $scope.getSingleSuccessCallback = function () { + $scope.assets = null; + $scope.theme = null; + }; + + $scope.syncTemplates = async function (id) { $rootScope.isBusy = true; var response = await service.syncTemplates(id); if (response.success) { @@ -6067,54 +6115,6 @@ app.controller("ThemeController", [ }, ]); -"use strict"; -app.controller("TenantController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$location", - "$routeParams", - "TenantRestService", - function ( - $scope, - $rootScope, - ngAppSettings, - $location, - $routeParams, - service - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.request.columns = [ - "id", - "displayName", - "systemName", - "primaryDomain", - "createdDateTime", - "createdBy", - ]; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - }, -]); - -"use strict"; -app.factory("TenantRestService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-tenant"); - return serviceFactory; - }, -]); - "use strict"; app.controller("ThemeImportController", [ "$scope", @@ -6201,231 +6201,102 @@ app.controller("ThemeImportController", [ ]); "use strict"; -app.controller("UrlAliasController", [ +app.controller("UserController", [ "$scope", "$rootScope", + "$location", "ngAppSettings", "$routeParams", - "$location", - "UrlAliasService", - "ApiService", - "CommonService", + "AuthService", + "UserServices", + "RestMixDatabaseDataPortalService", + "MixDbService", function ( $scope, $rootScope, + $location, ngAppSettings, $routeParams, - $location, - service, - apiService, - commonService + authService, + userServices, + dataService, + mixDbService ) { - BaseCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.mixConfigurations = $rootScope.globalSettings; - $scope.pageId = $routeParams.id; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.getList = async function () { - $rootScope.isBusy = true; + $scope.request = { + pageSize: "10", + pageIndex: 0, + status: "Published", + orderBy: "CreatedDateTime", + direction: "Desc", + fromDate: null, + toDate: null, + keyword: "", + }; + + $scope.mediaFile = { + file: null, + fullPath: "", + folder: "User", + title: "", + description: "", + }; + $scope.activedUser = null; + $scope.relatedUsers = []; + $rootScope.isBusy = false; + $scope.data = { + pageIndex: 0, + pageSize: 1, + totalItems: 0, + }; + $scope.errors = []; + + $scope.range = function (max) { + var input = []; + for (var i = 1; i <= max; i += 1) input.push(i); + return input; + }; + + $scope.loadUser = async function () { var id = $routeParams.id; - $scope.request.query = "&page_id=" + id; - var response = await service.getList($scope.request); - $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; + if (id) { + $rootScope.isBusy = true; + var response = await userServices.getUser(id, "portal"); + if (response.success) { + $scope.activedUser = response.data; + $scope.loadAdditionalData(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + $scope.loadAdditionalData = async function () { + mixDbService.initDbName("sysUserData"); + const getData = await mixDbService.getSingleByParent( + "User", + $scope.activedUser.id + ); + if (getData.success) { + $scope.additionalData = getData.data; + if (!$rootScope.isInRole("Owner")) { + $scope.activedUser.roles = $scope.activedUser.roles.filter( + (role) => role.description != "Owner" + ); + } + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $scope.additionalData = {}; + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.loadMyProfile = async function () { + $rootScope.isBusy = true; + var response = await userServices.getMyProfile(); if (response.success) { - $scope.data = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.remove = function (id) { - $rootScope.showConfirm( - $scope, - "removeConfirmed", - [id], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeConfirmed = async function (id) { - $rootScope.isBusy = true; - var result = await service.delete(id); - if (result.success) { - if ($scope.removeCallback) { - $rootScope.executeFunctionByName( - "removeCallback", - $scope.removeCallbackArgs, - $scope - ); - } - $scope.getList(); - } else { - $rootScope.showErrors(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.updateInfos = async function (index) { - $scope.data.items.splice(index, 1); - $rootScope.isBusy = true; - var startIndex = $scope.data.items[0].priority - 1; - for (var i = 0; i < $scope.data.items.length; i++) { - $scope.data.items[i].priority = startIndex + i + 1; - } - var resp = await service.updateInfos($scope.data.items); - if (resp && resp.success) { - $scope.activedPage = resp.data; - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.factory("UrlAliasService", [ - "$rootScope", - "ApiService", - "CommonService", - "BaseRestService", - function ($rootScope, apiService, commonService, baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.initService("/rest/mix-portal", "mix-url-alias"); - - var _updateInfos = async function (pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), - }; - return await apiService.sendRequest(req); - }; - serviceFactory.updateInfos = _updateInfos; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("UserController", [ - "$scope", - "$rootScope", - "$location", - "ngAppSettings", - "$routeParams", - "AuthService", - "UserServices", - "RestMixDatabaseDataPortalService", - "MixDbService", - function ( - $scope, - $rootScope, - $location, - ngAppSettings, - $routeParams, - authService, - userServices, - dataService, - mixDbService - ) { - $scope.request = { - pageSize: "10", - pageIndex: 0, - status: "Published", - orderBy: "CreatedDateTime", - direction: "Desc", - fromDate: null, - toDate: null, - keyword: "", - }; - - $scope.mediaFile = { - file: null, - fullPath: "", - folder: "User", - title: "", - description: "", - }; - $scope.activedUser = null; - $scope.relatedUsers = []; - $rootScope.isBusy = false; - $scope.data = { - pageIndex: 0, - pageSize: 1, - totalItems: 0, - }; - $scope.errors = []; - - $scope.range = function (max) { - var input = []; - for (var i = 1; i <= max; i += 1) input.push(i); - return input; - }; - - $scope.loadUser = async function () { - var id = $routeParams.id; - if (id) { - $rootScope.isBusy = true; - var response = await userServices.getUser(id, "portal"); - if (response.success) { - $scope.activedUser = response.data; - $scope.loadAdditionalData(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - $scope.loadAdditionalData = async function () { - mixDbService.initDbName("sysUserData"); - const getData = await mixDbService.getSingleByParent( - "User", - $scope.activedUser.id - ); - if (getData.success) { - $scope.additionalData = getData.data; - if (!$rootScope.isInRole("Owner")) { - $scope.activedUser.roles = $scope.activedUser.roles.filter( - (role) => role.description != "Owner" - ); - } - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $scope.additionalData = {}; - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.loadMyProfile = async function () { - $rootScope.isBusy = true; - var response = await userServices.getMyProfile(); - if (response.success) { - $scope.activedUser = response.data; + $scope.activedUser = response.data; $rootScope.isBusy = false; $scope.$apply(); } else { @@ -6748,43 +6619,172 @@ app.factory("UserServices", [ ]); "use strict"; -function PageDetailsController($scope, $element, $attrs) { - var ctrl = this; - ctrl.activedPage = null; - ctrl.relatedPages = []; - ctrl.data = []; - ctrl.errors = []; - ctrl.range = function (max) { - var input = []; - for (var i = 1; i <= max; i += 1) input.push(i); - return input; - }; - ctrl.loadPage = function (pageId) { - ctrl.isBusy = true; - var url = "/" + ctrl.currentLanguage + "/page/details/be/" + pageId; //byPage/' + pageId; - ctrl.mixConfigurations.method = "GET"; - ctrl.mixConfigurations.url = url; // + '/true'; - ctrl.mixConfigurations.data = ctrl.request; - $.ajax(ctrl.mixConfigurations).done(function (response) { +app.controller("UrlAliasController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "UrlAliasService", + "ApiService", + "CommonService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + apiService, + commonService + ) { + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.mixConfigurations = $rootScope.globalSettings; + $scope.pageId = $routeParams.id; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.getList = async function () { + $rootScope.isBusy = true; + var id = $routeParams.id; + $scope.request.query = "&page_id=" + id; + var response = await service.getList($scope.request); + $scope.canDrag = + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; if (response.success) { - ctrl.activedPage = response.data; - ctrl.initEditor(); + $scope.data = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); } - ctrl.isBusy = false; - ctrl.$apply(); - }); - }; - ctrl.loadPages = function (pageIndex) { - ctrl.isBusy = true; - if (pageIndex !== undefined) { - ctrl.request.pageIndex = pageIndex; - } - if (ctrl.request.fromDate !== null) { - ctrl.request.fromDate = ctrl.request.fromDate.toISOString(); - } - if (ctrl.request.toDate !== null) { - ctrl.request.toDate = ctrl.request.toDate.toISOString(); - } + }; + $scope.remove = function (id) { + $rootScope.showConfirm( + $scope, + "removeConfirmed", + [id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + + $scope.removeConfirmed = async function (id) { + $rootScope.isBusy = true; + var result = await service.delete(id); + if (result.success) { + if ($scope.removeCallback) { + $rootScope.executeFunctionByName( + "removeCallback", + $scope.removeCallbackArgs, + $scope + ); + } + $scope.getList(); + } else { + $rootScope.showErrors(result.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.updateInfos = async function (index) { + $scope.data.items.splice(index, 1); + $rootScope.isBusy = true; + var startIndex = $scope.data.items[0].priority - 1; + for (var i = 0; i < $scope.data.items.length; i++) { + $scope.data.items[i].priority = startIndex + i + 1; + } + var resp = await service.updateInfos($scope.data.items); + if (resp && resp.success) { + $scope.activedPage = resp.data; + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.factory("UrlAliasService", [ + "$rootScope", + "ApiService", + "CommonService", + "BaseRestService", + function ($rootScope, apiService, commonService, baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.initService("/rest/mix-portal", "mix-url-alias"); + + var _updateInfos = async function (pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), + }; + return await apiService.sendRequest(req); + }; + serviceFactory.updateInfos = _updateInfos; + return serviceFactory; + }, +]); + +"use strict"; +function PageDetailsController($scope, $element, $attrs) { + var ctrl = this; + ctrl.activedPage = null; + ctrl.relatedPages = []; + ctrl.data = []; + ctrl.errors = []; + ctrl.range = function (max) { + var input = []; + for (var i = 1; i <= max; i += 1) input.push(i); + return input; + }; + ctrl.loadPage = function (pageId) { + ctrl.isBusy = true; + var url = "/" + ctrl.currentLanguage + "/page/details/be/" + pageId; //byPage/' + pageId; + ctrl.mixConfigurations.method = "GET"; + ctrl.mixConfigurations.url = url; // + '/true'; + ctrl.mixConfigurations.data = ctrl.request; + $.ajax(ctrl.mixConfigurations).done(function (response) { + if (response.success) { + ctrl.activedPage = response.data; + ctrl.initEditor(); + } + ctrl.isBusy = false; + ctrl.$apply(); + }); + }; + ctrl.loadPages = function (pageIndex) { + ctrl.isBusy = true; + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; + } + if (ctrl.request.fromDate !== null) { + ctrl.request.fromDate = ctrl.request.fromDate.toISOString(); + } + if (ctrl.request.toDate !== null) { + ctrl.request.toDate = ctrl.request.toDate.toISOString(); + } var url = "/" + ctrl.currentLanguage + "/page/list"; //byPage/' + pageId; ctrl.mixConfigurations.method = "POST"; ctrl.mixConfigurations.url = url; // + '/true'; @@ -6982,22 +6982,6 @@ modules.component("roleAssociations", { ], }); -app.component("appSettingsAuth", { - templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/auth/view.html", - controller: [ - "ngAppSettings", - function (ngAppSettings) { - var ctrl = this; - }, - ], - bindings: { - appSettings: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - app.component("appSettingsDefault", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/default/view.html", @@ -7042,6 +7026,22 @@ app.component("appSettingsDefault", { }, }); +app.component("appSettingsAuth", { + templateUrl: + "/mix-app/views/app-portal/pages/app-settings/components/auth/view.html", + controller: [ + "ngAppSettings", + function (ngAppSettings) { + var ctrl = this; + }, + ], + bindings: { + appSettings: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("appSettingsGeneral", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/general/view.html", @@ -7073,33 +7073,38 @@ app.component("appSettingsGeneral", { }, }); -modules.component("portalMenus", { +app.component("appSettingsHeart", { templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/portal-menus/view.html", - bindings: { - data: "=", - allowedTypes: "=", - }, + "/mix-app/views/app-portal/pages/app-settings/components/heart/view.html", + bindings: {}, controller: [ "$rootScope", "$scope", - "$location", - "ApiService", - "CommonService", "ngAppSettings", + "AppSettingsServices", + "CommonService", function ( $rootScope, $scope, - $location, - apiService, - commonService, - ngAppSettings + ngAppSettings, + settingService, + commonService ) { var ctrl = this; - // ctrl.icons = []; - ctrl.translate = $rootScope.translate; - ctrl.init = function () { - ctrl.icons = ngAppSettings.icons; + ctrl.$onInit = function () { + ctrl.databaseProviders = ngAppSettings.enums.database_providers; + ctrl.cacheModes = ngAppSettings.enums.cache_modes; + settingService.getAppSettings("mix_heart").then((resp) => { + ctrl.appSettings = resp.data; + $scope.$apply; + }); + }; + ctrl.clearCache = async function () { + $rootScope.isBusy = true; + await commonService.clearCache(); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); }; }, ], @@ -7119,53 +7124,48 @@ app.component("appSettingsSmtp", { }, }); -app.component("customerMain", { +modules.component("portalMenus", { templateUrl: - "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", + "/mix-app/views/app-portal/pages/app-settings/components/portal-menus/view.html", bindings: { - customer: "=", - onDelete: "&", - onUpdate: "&", + data: "=", + allowedTypes: "=", }, -}); - -app.component("appSettingsHeart", { - templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/heart/view.html", - bindings: {}, controller: [ "$rootScope", "$scope", - "ngAppSettings", - "AppSettingsServices", + "$location", + "ApiService", "CommonService", + "ngAppSettings", function ( $rootScope, $scope, - ngAppSettings, - settingService, - commonService + $location, + apiService, + commonService, + ngAppSettings ) { var ctrl = this; - ctrl.$onInit = function () { - ctrl.databaseProviders = ngAppSettings.enums.database_providers; - ctrl.cacheModes = ngAppSettings.enums.cache_modes; - settingService.getAppSettings("mix_heart").then((resp) => { - ctrl.appSettings = resp.data; - $scope.$apply; - }); - }; - ctrl.clearCache = async function () { - $rootScope.isBusy = true; - await commonService.clearCache(); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); + // ctrl.icons = []; + ctrl.translate = $rootScope.translate; + ctrl.init = function () { + ctrl.icons = ngAppSettings.icons; }; }, ], }); +app.component("customerMain", { + templateUrl: + "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", + bindings: { + customer: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("customerOrders", { templateUrl: "/mix-app/views/app-portal/pages/customer/components/orders/customer-orders.html", @@ -7258,40 +7258,34 @@ app.component("mixDatabaseMain", { }, }); -app.component("moduleAdvanced", { - templateUrl: - "/mix-app/views/app-portal/pages/module/components/module-advanced/view.html", +app.component("mixdbContextDatabases", { bindings: { model: "=", - additionalData: "=", }, + templateUrl: + "/mix-app/views/app-portal/pages/mixdb-context/components/mix-databases/view.html", controller: [ "$rootScope", - function ($rootScope) { + "$scope", + "RestMixDatabasePortalService", + function ($rootScope, $scope, databaseService) { var ctrl = this; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; + ctrl.request = $rootScope.getRequest(); + ctrl.$onInit = () => { + ctrl.globalSettings = $rootScope.globalSettings; + ctrl.isInRole = $rootScope.isInRole; + ctrl.request.mixDatabaseContextId = ctrl.model.id; + ctrl.loadDatabases(); }; - }, - ], -}); - -app.component("moduleContent", { - templateUrl: - "/mix-app/views/app-portal/pages/module/components/module-content/view.html", - bindings: { - model: "=", - additionalData: "=", - }, - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.$onInit = function () { - ctrl.backUrl = `/admin/module/details`; + ctrl.loadDatabases = async function () { + if (ctrl.model.id) { + var resp = await databaseService.getList(ctrl.request); + if (resp && resp.success) { + ctrl.data = resp.data; + $scope.$apply(); + } + } }; - ctrl.mixConfigurations = $rootScope.globalSettings; }, ], }); @@ -7326,6 +7320,44 @@ app.component("moduleMain", { }, }); +app.component("moduleContent", { + templateUrl: + "/mix-app/views/app-portal/pages/module/components/module-content/view.html", + bindings: { + model: "=", + additionalData: "=", + }, + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.$onInit = function () { + ctrl.backUrl = `/admin/module/details`; + }; + ctrl.mixConfigurations = $rootScope.globalSettings; + }, + ], +}); + +app.component("moduleAdvanced", { + templateUrl: + "/mix-app/views/app-portal/pages/module/components/module-advanced/view.html", + bindings: { + model: "=", + additionalData: "=", + }, + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + }; + }, + ], +}); + app.component("moduleType", { templateUrl: "/mix-app/views/app-portal/pages/module/components/module-type/view.html", @@ -7341,38 +7373,115 @@ app.component("moduleType", { }, }); -app.component("mixdbContextDatabases", { +app.component("pageMain", { + templateUrl: "/mix-app/views/app-portal/pages/page/components/main/main.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope) { + var ctrl = this; + ctrl.mixConfigurations = $rootScope.globalSettings; + // ctrl.setPageType = function (type) { + // ctrl.page.type = $index; + // } + ctrl.generateSeo = function () { + if (ctrl.page) { + if (ctrl.page.seoName === null || ctrl.page.seoName === "") { + ctrl.page.seoName = $rootScope.generateKeyword( + ctrl.page.title, + "-" + ); + } + if (ctrl.page.seoTitle === null || ctrl.page.seoTitle === "") { + ctrl.page.seoTitle = ctrl.page.title; + } + if ( + ctrl.page.seoDescription === null || + ctrl.page.seoDescription === "" + ) { + ctrl.page.seoDescription = ctrl.page.excerpt; + } + if (ctrl.page.seoKeywords === null || ctrl.page.seoKeywords === "") { + ctrl.page.seoKeywords = ctrl.page.title; + } + } + }; + }, + ], bindings: { - model: "=", + page: "=", + onDelete: "&", + onUpdate: "&", }, +}); + +app.component("pageModules", { templateUrl: - "/mix-app/views/app-portal/pages/mixdb-context/components/mix-databases/view.html", + "/mix-app/views/app-portal/pages/page/components/modules/modules.html", + bindings: { + page: "=", + onDelete: "&?", + onUpdate: "&?", + }, controller: [ - "$rootScope", "$scope", - "RestMixDatabasePortalService", - function ($rootScope, $scope, databaseService) { + "ngAppSettings", + "ModuleRestService", + function ($scope, ngAppSettings, moduleService) { var ctrl = this; - ctrl.request = $rootScope.getRequest(); - ctrl.$onInit = () => { - ctrl.globalSettings = $rootScope.globalSettings; - ctrl.isInRole = $rootScope.isInRole; - ctrl.request.mixDatabaseContextId = ctrl.model.id; - ctrl.loadDatabases(); + ctrl.modules = []; + ctrl.request = angular.copy(ngAppSettings.request); + + ctrl.$onInit = async () => { + ctrl.request.columns = [ + "id", + "title", + "systemName", + "createdDateTime", + "type", + ]; + ctrl.request.culture = ctrl.page.specificulture; + ctrl.loadModules(); }; - ctrl.loadDatabases = async function () { - if (ctrl.model.id) { - var resp = await databaseService.getList(ctrl.request); - if (resp && resp.success) { - ctrl.data = resp.data; - $scope.$apply(); - } + ctrl.loadModules = async () => { + let getModules = await moduleService.getList(ctrl.request); + if (getModules.success) { + ctrl.modules = getModules.data.items; + $scope.$apply(); + } + }; + ctrl.select = async (associations) => { + ctrl.associations = associations; + if (ctrl.onUpdate) { + ctrl.onUpdate({ associations: associations }); } }; }, ], }); +app.component("pageAdvanced", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/page-advanced/view.html", + bindings: { + model: "=", + additionalData: "=", + }, + controller: [ + "$rootScope", + "$scope", + function ($rootScope, $scope) { + var ctrl = this; + + ctrl.translate = $rootScope.translate; + ctrl.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + }; + }, + ], +}); + app.component("pageGeneral", { templateUrl: "/mix-app/views/app-portal/pages/page/components/general/general.html", @@ -7480,42 +7589,69 @@ app.component("pageGeneral", { }, }); -app.component("pageMain", { - templateUrl: "/mix-app/views/app-portal/pages/page/components/main/main.html", +app.component("pageType", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/page-type/view.html", + bindings: { + model: "=", + }, + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.localizeSettings = $rootScope.globalSettings; + }, + ], +}); + +app.component("pageContent", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/page-content/view.html", + bindings: { + additionalData: "=", + model: "=", + }, controller: [ "$rootScope", "$scope", - "ngAppSettings", function ($rootScope, $scope) { var ctrl = this; - ctrl.mixConfigurations = $rootScope.globalSettings; - // ctrl.setPageType = function (type) { - // ctrl.page.type = $index; - // } + ctrl.translate = $rootScope.translate; + ctrl.$onInit = function () { + ctrl.backUrl = `/admin/page/details`; + }; ctrl.generateSeo = function () { - if (ctrl.page) { - if (ctrl.page.seoName === null || ctrl.page.seoName === "") { - ctrl.page.seoName = $rootScope.generateKeyword( - ctrl.page.title, + if ($scope.viewmodel) { + if (ctrl.model.seoName === null || ctrl.model.seoName === "") { + ctrl.model.seoName = $rootScope.generateKeyword( + ctrl.model.title, "-" ); } - if (ctrl.page.seoTitle === null || ctrl.page.seoTitle === "") { - ctrl.page.seoTitle = ctrl.page.title; + if (ctrl.model.seoTitle === null || ctrl.model.seoTitle === "") { + ctrl.model.seoTitle = ctrl.model.title; } if ( - ctrl.page.seoDescription === null || - ctrl.page.seoDescription === "" + ctrl.model.seoDescription === null || + ctrl.model.seoDescription === "" ) { - ctrl.page.seoDescription = ctrl.page.excerpt; + ctrl.model.seoDescription = ctrl.model.excerpt; } - if (ctrl.page.seoKeywords === null || ctrl.page.seoKeywords === "") { - ctrl.page.seoKeywords = ctrl.page.title; + if ( + ctrl.model.seoKeywords === null || + ctrl.model.seoKeywords === "" + ) { + ctrl.model.seoKeywords = ctrl.model.title; } } }; }, ], +}); + +app.component("pageParents", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/parents/parents.html", bindings: { page: "=", onDelete: "&", @@ -7523,145 +7659,63 @@ app.component("pageMain", { }, }); -app.component("pageModules", { +app.component("pagePlugPlay", { templateUrl: - "/mix-app/views/app-portal/pages/page/components/modules/modules.html", + "/mix-app/views/app-portal/pages/page/components/plug-play/plug-play.html", bindings: { page: "=", - onDelete: "&?", - onUpdate: "&?", + onDelete: "&", + onUpdate: "&", }, - controller: [ - "$scope", - "ngAppSettings", - "ModuleRestService", - function ($scope, ngAppSettings, moduleService) { - var ctrl = this; - ctrl.modules = []; - ctrl.request = angular.copy(ngAppSettings.request); - - ctrl.$onInit = async () => { - ctrl.request.columns = [ - "id", - "title", - "systemName", - "createdDateTime", - "type", - ]; - ctrl.request.culture = ctrl.page.specificulture; - ctrl.loadModules(); - }; - ctrl.loadModules = async () => { - let getModules = await moduleService.getList(ctrl.request); - if (getModules.success) { - ctrl.modules = getModules.data.items; - $scope.$apply(); - } - }; - ctrl.select = async (associations) => { - ctrl.associations = associations; - if (ctrl.onUpdate) { - ctrl.onUpdate({ associations: associations }); - } - }; - }, - ], -}); - -app.component("pageAdvanced", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/page-advanced/view.html", - bindings: { - model: "=", - additionalData: "=", - }, - controller: [ - "$rootScope", - "$scope", - function ($rootScope, $scope) { - var ctrl = this; - - ctrl.translate = $rootScope.translate; - ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - }; - }, - ], }); -app.component("pageContent", { +app.component("productRelated", { templateUrl: - "/mix-app/views/app-portal/pages/page/components/page-content/view.html", - bindings: { - additionalData: "=", - model: "=", - }, - controller: [ - "$rootScope", - "$scope", - function ($rootScope, $scope) { - var ctrl = this; - ctrl.translate = $rootScope.translate; - ctrl.$onInit = function () { - ctrl.backUrl = `/admin/page/details`; - }; - ctrl.generateSeo = function () { - if ($scope.viewmodel) { - if (ctrl.model.seoName === null || ctrl.model.seoName === "") { - ctrl.model.seoName = $rootScope.generateKeyword( - ctrl.model.title, - "-" - ); - } - if (ctrl.model.seoTitle === null || ctrl.model.seoTitle === "") { - ctrl.model.seoTitle = ctrl.model.title; - } - if ( - ctrl.model.seoDescription === null || - ctrl.model.seoDescription === "" - ) { - ctrl.model.seoDescription = ctrl.model.excerpt; - } - if ( - ctrl.model.seoKeywords === null || - ctrl.model.seoKeywords === "" - ) { - ctrl.model.seoKeywords = ctrl.model.title; - } + "/mix-app/views/app-portal/pages/product/components/related/productRelated.html", + controller: function () { + var ctrl = this; + ctrl.activeProduct = function (pr) { + var currentItem = null; + $.each(ctrl.product.productNavs, function (i, e) { + if (e.relatedProductId === pr.id) { + e.isActived = pr.isActived; + currentItem = e; + return false; } - }; - }, - ], -}); - -app.component("pageParents", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/parents/parents.html", + }); + if (currentItem === null) { + currentItem = { + relatedProductId: pr.id, + sourceProductId: ctrl.product.id, + specificulture: ctrl.product.specificulture, + priority: ctrl.product.productNavs.length + 1, + relatedProduct: pr, + isActived: true, + }; + pr.isHidden = true; + ctrl.product.productNavs.push(currentItem); + } + }; + }, bindings: { - page: "=", + product: "=", + list: "=", onDelete: "&", onUpdate: "&", }, }); -app.component("pageType", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/page-type/view.html", - bindings: { - model: "=", - }, +app.component("pageSeo", { + templateUrl: "/mix-app/views/app-portal/pages/page/components/seo/seo.html", controller: [ "$rootScope", function ($rootScope) { var ctrl = this; - ctrl.localizeSettings = $rootScope.globalSettings; + ctrl.translate = function (keyword) { + return $rootScope.translate(keyword); + }; }, ], -}); - -app.component("pagePlugPlay", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/plug-play/plug-play.html", bindings: { page: "=", onDelete: "&", @@ -7669,14 +7723,34 @@ app.component("pagePlugPlay", { }, }); -app.component("pageSeo", { - templateUrl: "/mix-app/views/app-portal/pages/page/components/seo/seo.html", +app.component("permissionMain", { + templateUrl: + "/mix-app/views/app-portal/pages/permission/components/main/main.html", controller: [ "$rootScope", - function ($rootScope) { + "$scope", + "ngAppSettings", + "$routeParams", + function ($rootScope, $scope, ngAppSettings, $routeParams) { var ctrl = this; - ctrl.translate = function (keyword) { - return $rootScope.translate(keyword); + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.icons = ngAppSettings.icons; + ctrl.setPageType = function (type) { + ctrl.page.type = $index; + }; + ctrl.generateKeyword = function (text) { + if (!$routeParams.id && text) { + ctrl.page.textKeyword = + "portal_" + + text + .replace(/[^a-zA-Z0-9]+/g, "_") + .replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2") + .replace(/([a-z])([A-Z])/g, "$1-$2") + .replace(/([0-9])([^0-9])/g, "$1-$2") + .replace(/([^0-9])([0-9])/g, "$1-$2") + .replace(/-+/g, "_") + .toLowerCase(); + } }; }, ], @@ -7687,76 +7761,149 @@ app.component("pageSeo", { }, }); -app.component("productRelated", { +app.component("permissionParents", { templateUrl: - "/mix-app/views/app-portal/pages/product/components/related/productRelated.html", - controller: function () { - var ctrl = this; - ctrl.activeProduct = function (pr) { - var currentItem = null; - $.each(ctrl.product.productNavs, function (i, e) { - if (e.relatedProductId === pr.id) { - e.isActived = pr.isActived; - currentItem = e; - return false; - } - }); - if (currentItem === null) { - currentItem = { - relatedProductId: pr.id, - sourceProductId: ctrl.product.id, - specificulture: ctrl.product.specificulture, - priority: ctrl.product.productNavs.length + 1, - relatedProduct: pr, - isActived: true, - }; - pr.isHidden = true; - ctrl.product.productNavs.push(currentItem); - } - }; - }, + "/mix-app/views/app-portal/pages/permission/components/parents/parents.html", bindings: { - product: "=", - list: "=", + page: "=", onDelete: "&", onUpdate: "&", }, }); -modules.component("postFilterList", { +app.component("permissionPlugPlay", { templateUrl: - "/mix-app/views/app-portal/pages/post/components/filter-list/filter-list.html", + "/mix-app/views/app-portal/pages/permission/components/plug-play/plug-play.html", bindings: { - request: "=", - key: "=?", - orders: "=?", - createUrl: "=", - createText: "=", - categories: "=", - postTypes: "=", - callback: "&", + page: "=", + prefixParent: "=", + prefixChild: "=", + searchText: "=", + onDelete: "&", + onUpdate: "&", }, controller: [ - "$scope", "$rootScope", - "ngAppSettings", - "RestMixDatabaseDataPortalService", - "CultureService", - function ($scope, $rootScope, ngAppSettings, dataService, cultureService) { + "$scope", + "$location", + "$element", + "PermissionService", + function ($rootScope, $scope, $location, $element, service) { var ctrl = this; - ctrl.dateRange = { + ctrl.type = "Children"; + ctrl.goToPath = $rootScope.goToPath; + ctrl.request = { + pageSize: "5", + pageIndex: 0, + status: "Published", + orderBy: "CreatedDateTime", + direction: "Desc", fromDate: null, toDate: null, }; - ctrl.request = angular.copy(ngAppSettings.request); - + ctrl.pages = []; ctrl.init = function () { - if (!ctrl.orders) { - ctrl.orders = ngAppSettings.orders; - } - ctrl.directions = ngAppSettings.directions; - ctrl.pageSizes = ngAppSettings.pageSizes; - ctrl.statuses = []; + if (ctrl.page) { + ctrl.request.exceptIds = ctrl.page.parentNavs + .map((p) => p.pageId) + .concat(ctrl.page.childNavs.map((p) => p.pageId)); + if (ctrl.request.exceptIds.indexOf(ctrl.page.id) === -1) { + ctrl.request.exceptIds.push(ctrl.page.id); + } + ctrl.getList(); + } + }; + ctrl.selectPane = function (pane) { + if (ctrl.page) { + ctrl.type = pane.header; + ctrl.request.keyword = ""; + ctrl.init(); + } + }; + + ctrl.selectItem = (nav) => { + if (ctrl.type == "Parents") { + if ( + !$rootScope.findObjectByKey(ctrl.page.parentNavs, "pageId", nav.id) + ) { + ctrl.page.parentNavs.push({ + isActived: true, + pageId: ctrl.page.id, + parentId: nav.id, + description: nav.textDefault, + status: "Published", + parent: nav, + }); + } + } else { + if ( + !$rootScope.findObjectByKey(ctrl.page.childNavs, "pageId", nav.id) + ) { + ctrl.page.childNavs.push({ + isActived: true, + pageId: nav.id, + parentId: ctrl.page.id, + description: nav.textDefault, + status: "Published", + page: nav, + }); + } + } + }; + + ctrl.getList = async function () { + $rootScope.isBusy = true; + var resp = await service.getList(ctrl.request); + if (resp && resp.success) { + ctrl.pages = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors || ["Failed"]); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], +}); + +modules.component("postFilterList", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/filter-list/filter-list.html", + bindings: { + request: "=", + key: "=?", + orders: "=?", + createUrl: "=", + createText: "=", + categories: "=", + postTypes: "=", + callback: "&", + }, + controller: [ + "$scope", + "$rootScope", + "ngAppSettings", + "RestMixDatabaseDataPortalService", + "CultureService", + function ($scope, $rootScope, ngAppSettings, dataService, cultureService) { + var ctrl = this; + ctrl.dateRange = { + fromDate: null, + toDate: null, + }; + ctrl.request = angular.copy(ngAppSettings.request); + + ctrl.init = function () { + if (!ctrl.orders) { + ctrl.orders = ngAppSettings.orders; + } + ctrl.directions = ngAppSettings.directions; + ctrl.pageSizes = ngAppSettings.pageSizes; + ctrl.statuses = []; var statuses = ngAppSettings.contentStatuses; if (ctrl.request && ctrl.request.contentStatuses) { statuses = ctrl.request.contentStatuses; @@ -7813,35 +7960,6 @@ modules.component("postFilterList", { ], }); -app.component("postGeneral", { - templateUrl: - "/mix-app/views/app-portal/pages/post/components/general/view.html", - controller: [ - "$rootScope", - "ngAppSettings", - function ($rootScope, ngAppSettings) { - var ctrl = this; - ctrl.dataTypes = $rootScope.globalSettings.dataTypes; - ctrl.$onInit = function () {}; - ctrl.addProperty = function (type) { - var i = $(".property").length; - ctrl.post.properties.push({ - title: "", - name: "", - value: null, - dataType: "text", - }); - }; - }, - ], - bindings: { - post: "=", - isAdmin: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - app.component("postMain", { templateUrl: "/mix-app/views/app-portal/pages/post/components/main/view.html", bindings: { @@ -7876,6 +7994,35 @@ app.component("postMain", { ], }); +app.component("postGeneral", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/general/view.html", + controller: [ + "$rootScope", + "ngAppSettings", + function ($rootScope, ngAppSettings) { + var ctrl = this; + ctrl.dataTypes = $rootScope.globalSettings.dataTypes; + ctrl.$onInit = function () {}; + ctrl.addProperty = function (type) { + var i = $(".property").length; + ctrl.post.properties.push({ + title: "", + name: "", + value: null, + dataType: "text", + }); + }; + }, + ], + bindings: { + post: "=", + isAdmin: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("postMedias", { templateUrl: "/mix-app/views/app-portal/pages/post/components/medias/view.html", @@ -8293,215 +8440,68 @@ app.component("postSeo", { }, }); -app.component("permissionMain", { +modules.component("rolePageNav", { templateUrl: - "/mix-app/views/app-portal/pages/permission/components/main/main.html", + "/mix-app/views/app-portal/pages/role/components/role-page-navigation/role-page-navigations.html", + bindings: { + prefix: "=", + page: "=", + callback: "&", + }, controller: [ "$rootScope", "$scope", "ngAppSettings", - "$routeParams", - function ($rootScope, $scope, ngAppSettings, $routeParams) { + "RoleService", + function ($rootScope, $scope, ngAppSettings, roleServices) { var ctrl = this; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.icons = ngAppSettings.icons; - ctrl.setPageType = function (type) { - ctrl.page.type = $index; - }; - ctrl.generateKeyword = function (text) { - if (!$routeParams.id && text) { - ctrl.page.textKeyword = - "portal_" + - text - .replace(/[^a-zA-Z0-9]+/g, "_") - .replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2") - .replace(/([a-z])([A-Z])/g, "$1-$2") - .replace(/([0-9])([^0-9])/g, "$1-$2") - .replace(/([^0-9])([0-9])/g, "$1-$2") - .replace(/-+/g, "_") - .toLowerCase(); + ctrl.selected = null; + ctrl.updateOrders = function (index) { + ctrl.data.splice(index, 1); + for (var i = 0; i < ctrl.data.length; i++) { + ctrl.data[i].priority = i + 1; } }; + //ctrl.change = async function () { + // //var permission = ctrl.page.navPermission; + // //$rootScope.isBusy = true; + // //var resp = await roleServices.updatePermission(permission); + // //if (resp && resp.success) { + // // $rootScope.showMessage('Update successfully!', 'success'); + // // $rootScope.isBusy = false; + // // $scope.$apply(); + // //} + // //else { + // // if (resp) { $rootScope.showErrors(resp.errors); } + // // $rootScope.isBusy = false; + // // $scope.$apply(); + // //} + //}; }, ], - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, }); -app.component("permissionParents", { +app.component("serviceMain", { templateUrl: - "/mix-app/views/app-portal/pages/permission/components/parents/parents.html", + "/mix-app/views/app-portal/pages/service/components/main/view.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.gennerateName = function () { + if ( + !ctrl.model.id || + ctrl.model.name === null || + ctrl.model.name === "" + ) { + ctrl.model.name = $rootScope.generateKeyword(ctrl.model.title, "_"); + } + }; + }, + ], bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("permissionPlugPlay", { - templateUrl: - "/mix-app/views/app-portal/pages/permission/components/plug-play/plug-play.html", - bindings: { - page: "=", - prefixParent: "=", - prefixChild: "=", - searchText: "=", - onDelete: "&", - onUpdate: "&", - }, - controller: [ - "$rootScope", - "$scope", - "$location", - "$element", - "PermissionService", - function ($rootScope, $scope, $location, $element, service) { - var ctrl = this; - ctrl.type = "Children"; - ctrl.goToPath = $rootScope.goToPath; - ctrl.request = { - pageSize: "5", - pageIndex: 0, - status: "Published", - orderBy: "CreatedDateTime", - direction: "Desc", - fromDate: null, - toDate: null, - }; - ctrl.pages = []; - ctrl.init = function () { - if (ctrl.page) { - ctrl.request.exceptIds = ctrl.page.parentNavs - .map((p) => p.pageId) - .concat(ctrl.page.childNavs.map((p) => p.pageId)); - if (ctrl.request.exceptIds.indexOf(ctrl.page.id) === -1) { - ctrl.request.exceptIds.push(ctrl.page.id); - } - ctrl.getList(); - } - }; - ctrl.selectPane = function (pane) { - if (ctrl.page) { - ctrl.type = pane.header; - ctrl.request.keyword = ""; - ctrl.init(); - } - }; - - ctrl.selectItem = (nav) => { - if (ctrl.type == "Parents") { - if ( - !$rootScope.findObjectByKey(ctrl.page.parentNavs, "pageId", nav.id) - ) { - ctrl.page.parentNavs.push({ - isActived: true, - pageId: ctrl.page.id, - parentId: nav.id, - description: nav.textDefault, - status: "Published", - parent: nav, - }); - } - } else { - if ( - !$rootScope.findObjectByKey(ctrl.page.childNavs, "pageId", nav.id) - ) { - ctrl.page.childNavs.push({ - isActived: true, - pageId: nav.id, - parentId: ctrl.page.id, - description: nav.textDefault, - status: "Published", - page: nav, - }); - } - } - }; - - ctrl.getList = async function () { - $rootScope.isBusy = true; - var resp = await service.getList(ctrl.request); - if (resp && resp.success) { - ctrl.pages = resp.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors || ["Failed"]); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, - ], -}); - -modules.component("rolePageNav", { - templateUrl: - "/mix-app/views/app-portal/pages/role/components/role-page-navigation/role-page-navigations.html", - bindings: { - prefix: "=", - page: "=", - callback: "&", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "RoleService", - function ($rootScope, $scope, ngAppSettings, roleServices) { - var ctrl = this; - ctrl.selected = null; - ctrl.updateOrders = function (index) { - ctrl.data.splice(index, 1); - for (var i = 0; i < ctrl.data.length; i++) { - ctrl.data[i].priority = i + 1; - } - }; - //ctrl.change = async function () { - // //var permission = ctrl.page.navPermission; - // //$rootScope.isBusy = true; - // //var resp = await roleServices.updatePermission(permission); - // //if (resp && resp.success) { - // // $rootScope.showMessage('Update successfully!', 'success'); - // // $rootScope.isBusy = false; - // // $scope.$apply(); - // //} - // //else { - // // if (resp) { $rootScope.showErrors(resp.errors); } - // // $rootScope.isBusy = false; - // // $scope.$apply(); - // //} - //}; - }, - ], -}); - -app.component("serviceMain", { - templateUrl: - "/mix-app/views/app-portal/pages/service/components/main/view.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.gennerateName = function () { - if ( - !ctrl.model.id || - ctrl.model.name === null || - ctrl.model.name === "" - ) { - ctrl.model.name = $rootScope.generateKeyword(ctrl.model.title, "_"); - } - }; - }, - ], - bindings: { - model: "=", + model: "=", }, }); @@ -8949,79 +8949,6 @@ app.component("themeExportPosts", { }, }); -app.component("themeImportMixDatabases", { - templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-mix-databases/view.html", - bindings: { - importThemeDto: "=", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope, ngAppSettings) { - var ctrl = this; - var service = $rootScope.getRestService("mix-database"); - ctrl.selectAllContent = false; - ctrl.selectAllData = false; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = async () => { - ctrl.data = ctrl.importThemeDto.mixDatabases; - }; - - ctrl.selectContent = (mixDatabase, selected) => { - ctrl.selectAllContent = ctrl.selectAllContent && selected; - ctrl.selectAllData = ctrl.selectAllData && selected; - mixDatabase.isImportData = selected && mixDatabase.isImportData; - ctrl.importThemeDto.content.mixDatabaseIds = ctrl.updateArray( - ctrl.importThemeDto.content.mixDatabaseIds, - [mixDatabase.id], - selected - ); - if (!selected) { - ctrl.selectData(mixDatabase, false); - } - }; - ctrl.selectData = (mixDatabase, selected) => { - ctrl.selectAllData = ctrl.selectAllData && selected; - ctrl.importThemeDto.associations.mixDatabaseIds = ctrl.updateArray( - ctrl.importThemeDto.associations.mixDatabaseIds, - [mixDatabase.id], - selected - ); - }; - ctrl.updateArray = function (src, arr, selected) { - if (selected) { - src = ctrl.unionArray(src, arr); - } else { - src = src.filter((m) => arr.indexOf(m) < 0); - } - return src; - }; - ctrl.selectAll = function (arr) { - angular.forEach(arr, function (e) { - ctrl.selectContent(e, ctrl.selectAllContent); - ctrl.selectData(e, ctrl.selectAllData); - e.isActived = ctrl.selectAllContent; - e.isImportData = ctrl.selectAllData; - }); - }; - ctrl.validate = (mixDatabase) => { - if ( - ctrl.importThemeDto.invalidDatabaseNames.indexOf( - mixDatabase.systemName - ) >= 0 - ) { - return `${mixDatabase.systemName} is invalid`; - } - }; - ctrl.unionArray = (a, b) => { - return [...new Set([...a, ...b])]; - }; - }, - ], -}); - app.component("themeImportCultures", { templateUrl: "/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html", @@ -9092,48 +9019,121 @@ app.component("themeImportCultures", { }, }); -app.component("themeImportModules", { +app.component("themeImportMixDatabases", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-modules/view.html", + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-mix-databases/view.html", + bindings: { + importThemeDto: "=", + }, controller: [ "$rootScope", "$scope", "ngAppSettings", function ($rootScope, $scope, ngAppSettings) { var ctrl = this; - var service = $rootScope.getRestService("mix-module"); + var service = $rootScope.getRestService("mix-database"); ctrl.selectAllContent = false; ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { - ctrl.getList(); - }; - ctrl.getList = async (moduleIndex) => { - if (moduleIndex !== undefined) { - ctrl.request.moduleIndex = moduleIndex; - } - if (ctrl.request.fromDate !== null) { - var d = new Date(ctrl.request.fromDate); - ctrl.request.fromDate = d.toISOString(); - } - if (ctrl.request.toDate !== null) { - var d = new Date(ctrl.request.toDate); - ctrl.request.toDate = d.toISOString(); - } - let getData = await service.getList(ctrl.request); - if (getData.success) { - ctrl.data = getData.data; - } + ctrl.data = ctrl.importThemeDto.mixDatabases; }; - ctrl.selectContent = (module, selected) => { + + ctrl.selectContent = (mixDatabase, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - module.isImportData = selected && module.isImportData; - let contentIds = module.contents.map(function (obj) { - return obj.id; - }); - ctrl.importThemeDto.content.moduleIds = ctrl.updateArray( - ctrl.importThemeDto.content.moduleIds, + mixDatabase.isImportData = selected && mixDatabase.isImportData; + ctrl.importThemeDto.content.mixDatabaseIds = ctrl.updateArray( + ctrl.importThemeDto.content.mixDatabaseIds, + [mixDatabase.id], + selected + ); + if (!selected) { + ctrl.selectData(mixDatabase, false); + } + }; + ctrl.selectData = (mixDatabase, selected) => { + ctrl.selectAllData = ctrl.selectAllData && selected; + ctrl.importThemeDto.associations.mixDatabaseIds = ctrl.updateArray( + ctrl.importThemeDto.associations.mixDatabaseIds, + [mixDatabase.id], + selected + ); + }; + ctrl.updateArray = function (src, arr, selected) { + if (selected) { + src = ctrl.unionArray(src, arr); + } else { + src = src.filter((m) => arr.indexOf(m) < 0); + } + return src; + }; + ctrl.selectAll = function (arr) { + angular.forEach(arr, function (e) { + ctrl.selectContent(e, ctrl.selectAllContent); + ctrl.selectData(e, ctrl.selectAllData); + e.isActived = ctrl.selectAllContent; + e.isImportData = ctrl.selectAllData; + }); + }; + ctrl.validate = (mixDatabase) => { + if ( + ctrl.importThemeDto.invalidDatabaseNames.indexOf( + mixDatabase.systemName + ) >= 0 + ) { + return `${mixDatabase.systemName} is invalid`; + } + }; + ctrl.unionArray = (a, b) => { + return [...new Set([...a, ...b])]; + }; + }, + ], +}); + +app.component("themeImportModules", { + templateUrl: + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-modules/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope, ngAppSettings) { + var ctrl = this; + var service = $rootScope.getRestService("mix-module"); + ctrl.selectAllContent = false; + ctrl.selectAllData = false; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = async () => { + ctrl.getList(); + }; + ctrl.getList = async (moduleIndex) => { + if (moduleIndex !== undefined) { + ctrl.request.moduleIndex = moduleIndex; + } + if (ctrl.request.fromDate !== null) { + var d = new Date(ctrl.request.fromDate); + ctrl.request.fromDate = d.toISOString(); + } + if (ctrl.request.toDate !== null) { + var d = new Date(ctrl.request.toDate); + ctrl.request.toDate = d.toISOString(); + } + let getData = await service.getList(ctrl.request); + if (getData.success) { + ctrl.data = getData.data; + } + }; + ctrl.selectContent = (module, selected) => { + ctrl.selectAllContent = ctrl.selectAllContent && selected; + ctrl.selectAllData = ctrl.selectAllData && selected; + module.isImportData = selected && module.isImportData; + let contentIds = module.contents.map(function (obj) { + return obj.id; + }); + ctrl.importThemeDto.content.moduleIds = ctrl.updateArray( + ctrl.importThemeDto.content.moduleIds, [module.id], selected ); @@ -9632,6 +9632,17 @@ modules.component("layoutPortalHeader", { bindings: {}, }); +modules.component("layoutPortalSidebar", { + templateUrl: + "/mix-app/views/app-portal/components/_layout-portal-sidebar/view.html", + controller: [ + function () { + var ctrl = this; + }, + ], + bindings: {}, +}); + modules.component("layoutPortalModals", { templateUrl: "/mix-app/views/app-portal/components/_layout-portal-modals/view.html", @@ -9750,256 +9761,157 @@ modules.component("aceEditor", { }, }); -modules.component("layoutPortalSidebar", { +modules.component("additionalValue", { templateUrl: - "/mix-app/views/app-portal/components/_layout-portal-sidebar/view.html", + "/mix-app/views/app-portal/components/additional-value/view.html", + bindings: { + additionalData: "=?", + additionalDataId: "=?", + parentType: "=?", + parentId: "=?", + mixDatabaseName: "=?", + backUrl: "=?", + }, controller: [ - function () { + "$rootScope", + "$scope", + "RestMixDatabaseDataPortalService", + function ($rootScope, $scope, dataService) { var ctrl = this; + ctrl.value = {}; + ctrl.column = { dataType: "Text" }; + ctrl.selectedCol = null; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = async function () { + if (!ctrl.additionalData) { + if (!ctrl.additionalDataId) { + const obj = { + parentType: ctrl.parentType, + parentId: ctrl.parentId, + databaseName: ctrl.mixDatabaseName, + }; + const getData = await dataService.getAdditionalData(obj); + if (getData.success) { + ctrl.additionalData = getData.data; + ctrl.additionalData.mixDatabaseName = ctrl.mixDatabaseName; + ctrl.additionalData.parentType = ctrl.parentType; + $scope.$apply(); + } else { + $rootScope.showErrors(getData.errors); + } + } else { + var getData = await dataService.getSingle([ctrl.additionalDataId]); + ctrl.additionalData = getData.data; + $scope.$apply(); + } + } + if (ctrl.additionalData.id == "00000000-0000-0000-0000-000000000000") { + ctrl.additionalData.id = null; + } + }; }, ], - bindings: {}, }); -modules.component("actions", { - templateUrl: "/mix-app/views/app-portal/components/actions/actions.html", - bindings: { - primaryUrl: "=", - primaryTitle: "=", - primaryIcon: "=", - previewUrl: "=", - backUrl: "=", - contentUrl: "=", - onClearCache: "&?", - onSubmit: "&?", - }, +modules.component("confirm", { + templateUrl: "/mix-app/views/app-portal/components/confirm/confirm.html", controller: [ "$rootScope", "$scope", - "$location", - function ($rootScope, $scope, $location) { + "ngAppSettings", + function ($rootScope, $scope) { var ctrl = this; - ctrl.visible = $rootScope.visible; - ctrl.back = function () { - if (ctrl.backUrl) { - $location.url(ctrl.backUrl); - } else { - window.history.back(); - } - }; - ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - }; - ctrl.submit = function ($event) { - if (ctrl.onSubmit) { - $event.preventDefault(); - ctrl.onSubmit(); - return; + ctrl.executeFunctionByName = async function ( + functionName, + args, + context + ) { + var result = await $rootScope.executeFunctionByName( + functionName, + args, + context + ); + if (result) { + $scope.$apply(); } }; - ctrl.clearCache = function () { - ctrl.onClearCache(); - }; }, ], + bindings: { + message: "=", + }, }); -modules.component("additionalColumn", { +modules.component("filterList", { templateUrl: - "/mix-app/views/app-portal/components/additional-column/view.html", - bindings: { - model: "=", - additionalData: "=", - }, + "/mix-app/views/app-portal/components/filter-list/filter-list.html", controller: [ - "$rootScope", "$scope", - "RestMixDatabaseColumnPortalService", - "RestMixDatabaseDataPortalService", - function ($rootScope, $scope, columnService, dataService) { + "$rootScope", + "ngAppSettings", + "CultureService", + function ($scope, $rootScope, ngAppSettings, cultureService) { var ctrl = this; - ctrl.value = {}; - ctrl.column = { - dataType: "Text", - mixDatabaseName: "sysAdditionalColumn", - mixDatabaseId: 6, - status: "Published", + ctrl.dateRange = { + fromDate: null, + toDate: null, }; - ctrl.selectedCol = null; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = async function () {}; - ctrl.addAttr = async function () { - if (ctrl.column.name) { - var current = $rootScope.findObjectByKey( - ctrl.additionalData.columns, - "name", - ctrl.column.name - ); - if (current) { - $rootScope.showErrors(["Field " + ctrl.column.name + " existed!"]); - } else { - ctrl.column.priority = ctrl.additionalData.columns.length + 1; - $rootScope.isBusy = true; - var saveField = await columnService.create(ctrl.column); - $rootScope.isBusy = false; - if (saveField.success) { - ctrl.additionalData.columns.push(saveField.data); - if (ctrl.additionalData.parentId) { - await dataService.save(ctrl.additionalData); - } - //reset column option - ctrl.column.title = ""; - ctrl.column.name = ""; - ctrl.column.dataType = "Text"; - } else { - $rootScope.showErrors(saveField.errors); - } - $scope.$apply(); - } - } else { - $rootScope.showErrors(["Please add column Name"]); - } - }; - - ctrl.generateName = function (col) { - col.name = $rootScope.generateKeyword(col.title, "_", true, true); - }; - ctrl.showReferences = function (col) { - ctrl.colRef = col; - $("#modal-navs").modal("show"); - }; - ctrl.referenceCallback = async function (selected) { - if (selected && selected.length) { - ctrl.colRef.reference = selected; - ctrl.colRef.referenceId = selected[0].id; - await columnService.save(ctrl.colRef); + ctrl.searchMethods = ["Equal", "Like"]; + ctrl.init = async function () { + if (!ctrl.arrOrderby) { + ctrl.arrOrderby = [ + "Title", + "Priority", + "CreatedDateTime", + "LastModified", + "Status", + ]; } - $("#modal-navs").modal("hide"); + ctrl.request.orderBy = ctrl.request.orderBy || ctrl.arrOrderby[0]; + ctrl.directions = ["Asc", "Desc"]; + ctrl.pageSizes = [5, 10, 15, 20]; + ctrl.statuses = $rootScope.globalSettings.statuses; }; - ctrl.updateOrders = function (index) { - if (index > ctrl.dragStartIndex) { - ctrl.additionalData.columns.splice(ctrl.dragStartIndex, 1); + ctrl.changeLang = function (culture) { + if (culture) { + ctrl.selectedCulture = culture; + ctrl.request.culture = culture.specificulture; } else { - ctrl.additionalData.columns.splice(ctrl.dragStartIndex + 1, 1); + ctrl.selectedCulture = null; + ctrl.request.culture = null; } - angular.forEach(ctrl.additionalData.columns, function (e, i) { - e.priority = i; - }); - }; - - ctrl.dragStart = function (index) { - ctrl.dragStartIndex = index; + ctrl.apply(0); }; - - ctrl.removeAttribute = function (val, index) { - $rootScope.showConfirm( - ctrl, - "removeAttributeConfirmed", - [val, index], - null, - "Remove Field", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); + ctrl.apply = function (pageIndex) { + $rootScope.setRequest(ctrl.request, ctrl.key); + ctrl.callback({ pageIndex: pageIndex }); }; - ctrl.removeAttributeConfirmed = async function (val, index) { - if (val.id) { - $rootScope.isBusy = true; - var result = await columnService.delete([val.id]); - if (result.success) { - ctrl.additionalData.columns.splice(index, 1); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } + ctrl.updateDate = function () { + ctrl.request.pageIndex = 0; + if (Date.parse(ctrl.dateRange.fromDate)) { + ctrl.request.fromDate = new Date( + ctrl.dateRange.fromDate + ).toISOString(); } else { - ctrl.additionalData.columns.splice(index, 1); - } - }; - }, - ], -}); - -modules.component("additionalValue", { - templateUrl: - "/mix-app/views/app-portal/components/additional-value/view.html", - bindings: { - additionalData: "=?", - additionalDataId: "=?", - parentType: "=?", - parentId: "=?", - mixDatabaseName: "=?", - backUrl: "=?", - }, - controller: [ - "$rootScope", - "$scope", - "RestMixDatabaseDataPortalService", - function ($rootScope, $scope, dataService) { - var ctrl = this; - ctrl.value = {}; - ctrl.column = { dataType: "Text" }; - ctrl.selectedCol = null; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = async function () { - if (!ctrl.additionalData) { - if (!ctrl.additionalDataId) { - const obj = { - parentType: ctrl.parentType, - parentId: ctrl.parentId, - databaseName: ctrl.mixDatabaseName, - }; - const getData = await dataService.getAdditionalData(obj); - if (getData.success) { - ctrl.additionalData = getData.data; - ctrl.additionalData.mixDatabaseName = ctrl.mixDatabaseName; - ctrl.additionalData.parentType = ctrl.parentType; - $scope.$apply(); - } else { - $rootScope.showErrors(getData.errors); - } - } else { - var getData = await dataService.getSingle([ctrl.additionalDataId]); - ctrl.additionalData = getData.data; - $scope.$apply(); - } - } - if (ctrl.additionalData.id == "00000000-0000-0000-0000-000000000000") { - ctrl.additionalData.id = null; + $scope.request.fromDate = null; } - }; - }, - ], -}); - -modules.component("confirm", { - templateUrl: "/mix-app/views/app-portal/components/confirm/confirm.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope) { - var ctrl = this; - ctrl.executeFunctionByName = async function ( - functionName, - args, - context - ) { - var result = await $rootScope.executeFunctionByName( - functionName, - args, - context - ); - if (result) { - $scope.$apply(); + if (Date.parse(ctrl.dateRange.toDate)) { + ctrl.request.toDate = new Date(ctrl.dateRange.toDate).toISOString(); + } else { + ctrl.request.toDate = null; } + $rootScope.setRequest(ctrl.request, ctrl.key); + ctrl.callback({ pageIndex: 0 }); }; }, ], bindings: { - message: "=", + request: "=", + key: "=?", + arrOrderby: "=?", + createUrl: "=", + createText: "=", + callback: "&", }, }); @@ -10213,77 +10125,122 @@ modules.component("funding", { bindings: {}, }); -modules.component("filterList", { +modules.component("additionalColumn", { templateUrl: - "/mix-app/views/app-portal/components/filter-list/filter-list.html", + "/mix-app/views/app-portal/components/additional-column/view.html", + bindings: { + model: "=", + additionalData: "=", + }, controller: [ - "$scope", "$rootScope", - "ngAppSettings", - "CultureService", - function ($scope, $rootScope, ngAppSettings, cultureService) { + "$scope", + "RestMixDatabaseColumnPortalService", + "RestMixDatabaseDataPortalService", + function ($rootScope, $scope, columnService, dataService) { var ctrl = this; - ctrl.dateRange = { - fromDate: null, - toDate: null, + ctrl.value = {}; + ctrl.column = { + dataType: "Text", + mixDatabaseName: "sysAdditionalColumn", + mixDatabaseId: 6, + status: "Published", }; - ctrl.searchMethods = ["Equal", "Like"]; - ctrl.init = async function () { - if (!ctrl.arrOrderby) { - ctrl.arrOrderby = [ - "Title", - "Priority", - "CreatedDateTime", - "LastModified", - "Status", - ]; + ctrl.selectedCol = null; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = async function () {}; + ctrl.addAttr = async function () { + if (ctrl.column.name) { + var current = $rootScope.findObjectByKey( + ctrl.additionalData.columns, + "name", + ctrl.column.name + ); + if (current) { + $rootScope.showErrors(["Field " + ctrl.column.name + " existed!"]); + } else { + ctrl.column.priority = ctrl.additionalData.columns.length + 1; + $rootScope.isBusy = true; + var saveField = await columnService.create(ctrl.column); + $rootScope.isBusy = false; + if (saveField.success) { + ctrl.additionalData.columns.push(saveField.data); + if (ctrl.additionalData.parentId) { + await dataService.save(ctrl.additionalData); + } + //reset column option + ctrl.column.title = ""; + ctrl.column.name = ""; + ctrl.column.dataType = "Text"; + } else { + $rootScope.showErrors(saveField.errors); + } + $scope.$apply(); + } + } else { + $rootScope.showErrors(["Please add column Name"]); } - ctrl.request.orderBy = ctrl.request.orderBy || ctrl.arrOrderby[0]; - ctrl.directions = ["Asc", "Desc"]; - ctrl.pageSizes = [5, 10, 15, 20]; - ctrl.statuses = $rootScope.globalSettings.statuses; }; - ctrl.changeLang = function (culture) { - if (culture) { - ctrl.selectedCulture = culture; - ctrl.request.culture = culture.specificulture; - } else { - ctrl.selectedCulture = null; - ctrl.request.culture = null; - } - ctrl.apply(0); + + ctrl.generateName = function (col) { + col.name = $rootScope.generateKeyword(col.title, "_", true, true); }; - ctrl.apply = function (pageIndex) { - $rootScope.setRequest(ctrl.request, ctrl.key); - ctrl.callback({ pageIndex: pageIndex }); + ctrl.showReferences = function (col) { + ctrl.colRef = col; + $("#modal-navs").modal("show"); }; - ctrl.updateDate = function () { - ctrl.request.pageIndex = 0; - if (Date.parse(ctrl.dateRange.fromDate)) { - ctrl.request.fromDate = new Date( - ctrl.dateRange.fromDate - ).toISOString(); + ctrl.referenceCallback = async function (selected) { + if (selected && selected.length) { + ctrl.colRef.reference = selected; + ctrl.colRef.referenceId = selected[0].id; + await columnService.save(ctrl.colRef); + } + $("#modal-navs").modal("hide"); + }; + ctrl.updateOrders = function (index) { + if (index > ctrl.dragStartIndex) { + ctrl.additionalData.columns.splice(ctrl.dragStartIndex, 1); } else { - $scope.request.fromDate = null; + ctrl.additionalData.columns.splice(ctrl.dragStartIndex + 1, 1); } - if (Date.parse(ctrl.dateRange.toDate)) { - ctrl.request.toDate = new Date(ctrl.dateRange.toDate).toISOString(); + angular.forEach(ctrl.additionalData.columns, function (e, i) { + e.priority = i; + }); + }; + + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + }; + + ctrl.removeAttribute = function (val, index) { + $rootScope.showConfirm( + ctrl, + "removeAttributeConfirmed", + [val, index], + null, + "Remove Field", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + ctrl.removeAttributeConfirmed = async function (val, index) { + if (val.id) { + $rootScope.isBusy = true; + var result = await columnService.delete([val.id]); + if (result.success) { + ctrl.additionalData.columns.splice(index, 1); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(result.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } } else { - ctrl.request.toDate = null; + ctrl.additionalData.columns.splice(index, 1); } - $rootScope.setRequest(ctrl.request, ctrl.key); - ctrl.callback({ pageIndex: 0 }); }; }, ], - bindings: { - request: "=", - key: "=?", - arrOrderby: "=?", - createUrl: "=", - createText: "=", - callback: "&", - }, }); modules.component("githubContributers", { @@ -10567,6 +10524,153 @@ modules.component("googleAnalytic", { ], }); +modules.component("actions", { + templateUrl: "/mix-app/views/app-portal/components/actions/actions.html", + bindings: { + primaryUrl: "=", + primaryTitle: "=", + primaryIcon: "=", + previewUrl: "=", + backUrl: "=", + contentUrl: "=", + onClearCache: "&?", + onSubmit: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "$location", + function ($rootScope, $scope, $location) { + var ctrl = this; + ctrl.visible = $rootScope.visible; + ctrl.back = function () { + if (ctrl.backUrl) { + $location.url(ctrl.backUrl); + } else { + window.history.back(); + } + }; + ctrl.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + }; + ctrl.submit = function ($event) { + if (ctrl.onSubmit) { + $event.preventDefault(); + ctrl.onSubmit(); + return; + } + }; + ctrl.clearCache = function () { + ctrl.onClearCache(); + }; + }, + ], +}); + +(function (angular) { + app.component("headerNav", { + templateUrl: + "/mix-app/views/app-portal/components/header-nav/headerNav.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "localStorageService", + "CommonService", + "ApiService", + "AuthService", + "CultureService", + function ( + $rootScope, + $scope, + ngAppSettings, + localStorageService, + commonService, + apiService, + authService, + cultureService + ) { + var ctrl = this; + ctrl.appSettings = $rootScope.globalSettings; + ctrl.isInRole = $rootScope.isInRole; + this.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + ctrl.mixConfigurations = $rootScope.mixConfigurations; + cultureService.getList(ngAppSettings.request).then((resp) => { + ctrl.cultures = resp.data.items; + ctrl.selectedCulture = ctrl.cultures.find( + (m) => + m.specificulture == $rootScope.globalSettings.defaultCulture + ); + $scope.$apply(); + }); + authService.fillAuthData().then(() => { + if ( + authService.authentication && + authService.authentication.info.userData + ) { + ctrl.avatar = authService.authentication.info.userData.avatar; + } + }); + }; + ctrl.translate = $rootScope.translate; + ctrl.getConfiguration = function (keyword, isWrap, defaultText) { + return $rootScope.getConfiguration(keyword, isWrap, defaultText); + }; + ctrl.changeLang = function (culture) { + $rootScope.globalSettings.defaultCulture = culture.specificulture; + localStorageService.set("globalSettings", $rootScope.globalSettings); + window.top.location = location.href; + }; + ctrl.logOut = function () { + $rootScope.logOut(); + }; + ctrl.addPermission = function () { + $("#dlg-permission").modal("show"); + }; + ctrl.addBookmark = function () { + $("#dlg-bookmark").modal("show"); + }; + ctrl.toggleSidebar = function () { + $(".main-sidebar").toggle(); + $(".sub-sidebar").toggle(); + // $('.navbar-brand').toggle(); + }; + ctrl.clearCache = async function () { + $rootScope.isBusy = true; + await commonService.clearCache(); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + }; + ctrl.showHelper = function (url) { + $rootScope.helperUrl = url; + $("#dev-helper-modal").modal("show"); + }; + ctrl.generateSitemap = async function () { + $rootScope.isBusy = true; + var resp = await commonService.genrateSitemap(); + if (resp) { + window.top.location.href = + "/admin/file/details?folder=" + + resp.fileFolder + + "&filename=" + + resp.filename + + resp.extension; + } else { + $rootScope.isBusy = false; + $rootScope.showErrors(["Server error"]); + } + }; + }, + ], + bindings: { + breadCrumbs: "=", + settings: "=", + }, + }); +})(window.angular); + modules.component("highFrequencyMessages", { templateUrl: "/mix-app/views/app-portal/components/high-frequency-messages/view.html", @@ -10744,110 +10848,6 @@ app.controller("HighFrequencyMessagesController", [ }, ]); -(function (angular) { - app.component("headerNav", { - templateUrl: - "/mix-app/views/app-portal/components/header-nav/headerNav.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "localStorageService", - "CommonService", - "ApiService", - "AuthService", - "CultureService", - function ( - $rootScope, - $scope, - ngAppSettings, - localStorageService, - commonService, - apiService, - authService, - cultureService - ) { - var ctrl = this; - ctrl.appSettings = $rootScope.globalSettings; - ctrl.isInRole = $rootScope.isInRole; - this.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - ctrl.mixConfigurations = $rootScope.mixConfigurations; - cultureService.getList(ngAppSettings.request).then((resp) => { - ctrl.cultures = resp.data.items; - ctrl.selectedCulture = ctrl.cultures.find( - (m) => - m.specificulture == $rootScope.globalSettings.defaultCulture - ); - $scope.$apply(); - }); - authService.fillAuthData().then(() => { - if ( - authService.authentication && - authService.authentication.info.userData - ) { - ctrl.avatar = authService.authentication.info.userData.avatar; - } - }); - }; - ctrl.translate = $rootScope.translate; - ctrl.getConfiguration = function (keyword, isWrap, defaultText) { - return $rootScope.getConfiguration(keyword, isWrap, defaultText); - }; - ctrl.changeLang = function (culture) { - $rootScope.globalSettings.defaultCulture = culture.specificulture; - localStorageService.set("globalSettings", $rootScope.globalSettings); - window.top.location = location.href; - }; - ctrl.logOut = function () { - $rootScope.logOut(); - }; - ctrl.addPermission = function () { - $("#dlg-permission").modal("show"); - }; - ctrl.addBookmark = function () { - $("#dlg-bookmark").modal("show"); - }; - ctrl.toggleSidebar = function () { - $(".main-sidebar").toggle(); - $(".sub-sidebar").toggle(); - // $('.navbar-brand').toggle(); - }; - ctrl.clearCache = async function () { - $rootScope.isBusy = true; - await commonService.clearCache(); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - }; - ctrl.showHelper = function (url) { - $rootScope.helperUrl = url; - $("#dev-helper-modal").modal("show"); - }; - ctrl.generateSitemap = async function () { - $rootScope.isBusy = true; - var resp = await commonService.genrateSitemap(); - if (resp) { - window.top.location.href = - "/admin/file/details?folder=" + - resp.fileFolder + - "&filename=" + - resp.filename + - resp.extension; - } else { - $rootScope.isBusy = false; - $rootScope.showErrors(["Server error"]); - } - }; - }, - ], - bindings: { - breadCrumbs: "=", - settings: "=", - }, - }); -})(window.angular); - modules.component("hubMessages", { templateUrl: "/mix-app/views/app-portal/components/hub-messages/hub-messages.html", @@ -10969,6 +10969,30 @@ app.controller("HubMessagesController", [ }, ]); +modules.component("jumbotrons", { + templateUrl: + "/mix-app/views/app-portal/components/jumbotrons/jumbotrons.html", + controller: [ + "$rootScope", + "$scope", + "$location", + function ($rootScope, $scope, $location) { + var ctrl = this; + ctrl.translate = function (keyword) { + return $rootScope.translate(keyword); + }; + // ctrl.back = function () { + // ctrl.backUrl = ctrl.backUrl || '/admin'; + // $location.path(ctrl.backUrl); + // }; + }, + ], + bindings: { + tagName: "=", + tagType: "=", + }, +}); + modules.component("jsonBuilder", { templateUrl: "/mix-app/views/app-portal/components/json-builder/view.html", bindings: { @@ -11260,232 +11284,40 @@ modules.component("jsonBuilder", { ], }); -modules.component("jumbotrons", { - templateUrl: - "/mix-app/views/app-portal/components/jumbotrons/jumbotrons.html", - controller: [ - "$rootScope", - "$scope", - "$location", - function ($rootScope, $scope, $location) { - var ctrl = this; - ctrl.translate = function (keyword) { - return $rootScope.translate(keyword); - }; - // ctrl.back = function () { - // ctrl.backUrl = ctrl.backUrl || '/admin'; - // $location.path(ctrl.backUrl); - // }; - }, - ], - bindings: { - tagName: "=", - tagType: "=", - }, -}); +// const { data } = require("jquery"); -modules.component("logStream", { - templateUrl: "/mix-app/views/app-portal/components/log-stream/view.html", - controller: "LogStreamController", - bindings: {}, -}); -app.controller("LogStreamController", [ - "$scope", - "$rootScope", - "AuthService", - function ($scope, $rootScope, authService) { - BaseHub.call(this, $scope); - authService.fillAuthData(); - $scope.keyword = ""; - $scope.newMsgCount = 0; - $scope.messages = []; - $scope.onConnected = () => { - // $scope.joinRoom("portal"); - }; - $scope.init = function () { - $scope.startConnection( - "log-stream-hub", - authService.authentication.accessToken, - (err) => { - if ( - authService.authentication.refreshToken && - err.message.indexOf("401") >= 0 - ) { - authService.refreshToken().then(async () => { - $scope.startConnection( - "log-stream-hub", - authService.authentication.accessToken - ); - }); - } - } - ); - }; - $scope.readMessages = function () { - $scope.newMsgCount = 0; - $("#modal-log-stream").modal("show"); - $scope.scrollToBot(); - }; - $scope.receiveMessage = function (msg) { - switch (msg.action) { - case "NewMessage": - $scope.newMessage(msg); - break; - } - }; - $scope.newMessage = function (msg) { - msg.style = $scope.getMessageType(msg.type); - if ( - msg.data && - !angular.isObject(msg.data) && - msg.data.indexOf("{") == 0 - ) { - msg.data = JSON.parse(msg.data); - } - $scope.messages.push(msg); - $scope.$apply(); - $scope.scrollToBot(); - }; - $scope.scrollToBot = () => { - let container = $("#modal-log-stream").find(".modal-body")[0]; - setTimeout(() => { - let h = $("#modal-log-stream").find(".table").height(); - $(container).animate( - { - scrollTop: h, // Scroll to top of body - }, - 500 - ); - }, 200); - }; - $scope.getMessageType = function (type) { - switch (type) { - case "Success": - return "success"; - case "Error": - $scope.newMsgCount += 1; - return "danger"; - case "Warning": - return "warning"; - case "Info": - return "info"; - default: - return "default"; - } - }; +modules.component("listMixColumn", { + templateUrl: "/mix-app/views/app-portal/components/list-mix-column/view.html", + bindings: { + header: "=", + columns: "=", + relationships: "=", + removeAttributes: "=", }, -]); - -modules.component("mainSideBar", { - templateUrl: - "/mix-app/views/app-portal/components/main-side-bar/main-side-bar.html", controller: [ "$rootScope", "$scope", "ngAppSettings", - "TranslatorService", - "ApiService", - "CommonService", + "RestMixRelationshipPortalService", + "RestMixDatabasePortalService", + "RestMixDatabaseColumnPortalService", function ( $rootScope, $scope, ngAppSettings, - translatorService, - apiService, - commonService + relationshipService, + databaseService, + service ) { var ctrl = this; - ctrl.items = []; - ctrl.init = async function () { - var resp = await apiService.getPortalMenus(); - if (resp.success && resp.data && resp.data.length) { - ctrl.items = resp.data; - } else { - ctrl.items = JSON.parse($("#portal-menus").val()).items; - } - }; - }, - ], - bindings: { - items: "=?", - }, -}); - -modules.component("mainSideBarDynamic", { - templateUrl: - "/mix-app/views/app-portal/components/main-side-bar-dynamic/main-side-bar-dynamic.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "CommonService", - "TranslatorService", - "AuthService", - function ( - $rootScope, - $scope, - ngAppSettings, - commonService, - translatorService, - authService - ) { - var ctrl = this; - ctrl.init = function () { - // commonService.getPermissions().then(function (response) { - // if (response && response.success) { - // ctrl.isInit = true; - // ctrl.roles = response.data; - // if (ctrl.roles.data) { - // ctrl.role = ctrl.roles.data[0]; - // } - // $rootScope.isBusy = false; - // $scope.$apply(); - // } - // }); - }; - }, - ], - bindings: { - roles: "=", - activedRole: "=", - translate: "&", - }, -}); - -// const { data } = require("jquery"); - -modules.component("listMixColumn", { - templateUrl: "/mix-app/views/app-portal/components/list-mix-column/view.html", - bindings: { - header: "=", - columns: "=", - relationships: "=", - removeAttributes: "=", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "RestMixRelationshipPortalService", - "RestMixDatabasePortalService", - "RestMixDatabaseColumnPortalService", - function ( - $rootScope, - $scope, - ngAppSettings, - relationshipService, - databaseService, - service - ) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.selectedCol = null; - ctrl.relationshipTypes = ["OneToMany"]; - ctrl.defaultRelationship = { - parentId: null, - type: "OneToMany", - childId: null, - displayName: null, + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.selectedCol = null; + ctrl.relationshipTypes = ["OneToMany"]; + ctrl.defaultRelationship = { + parentId: null, + type: "OneToMany", + childId: null, + displayName: null, }; ctrl.$onInit = async function () { ctrl.dataTypes = $rootScope.globalSettings.dataTypes; @@ -11663,43 +11495,152 @@ modules.component("listMixColumn", { ], }); -modules.component("mainSideBarItem", { +modules.component("logStream", { + templateUrl: "/mix-app/views/app-portal/components/log-stream/view.html", + controller: "LogStreamController", + bindings: {}, +}); +app.controller("LogStreamController", [ + "$scope", + "$rootScope", + "AuthService", + function ($scope, $rootScope, authService) { + BaseHub.call(this, $scope); + authService.fillAuthData(); + $scope.keyword = ""; + $scope.newMsgCount = 0; + $scope.messages = []; + $scope.onConnected = () => { + // $scope.joinRoom("portal"); + }; + $scope.init = function () { + $scope.startConnection( + "log-stream-hub", + authService.authentication.accessToken, + (err) => { + if ( + authService.authentication.refreshToken && + err.message.indexOf("401") >= 0 + ) { + authService.refreshToken().then(async () => { + $scope.startConnection( + "log-stream-hub", + authService.authentication.accessToken + ); + }); + } + } + ); + }; + $scope.readMessages = function () { + $scope.newMsgCount = 0; + $("#modal-log-stream").modal("show"); + $scope.scrollToBot(); + }; + $scope.receiveMessage = function (msg) { + switch (msg.action) { + case "NewMessage": + $scope.newMessage(msg); + break; + } + }; + $scope.newMessage = function (msg) { + msg.style = $scope.getMessageType(msg.type); + if ( + msg.data && + !angular.isObject(msg.data) && + msg.data.indexOf("{") == 0 + ) { + msg.data = JSON.parse(msg.data); + } + $scope.messages.push(msg); + $scope.$apply(); + $scope.scrollToBot(); + }; + $scope.scrollToBot = () => { + let container = $("#modal-log-stream").find(".modal-body")[0]; + setTimeout(() => { + let h = $("#modal-log-stream").find(".table").height(); + $(container).animate( + { + scrollTop: h, // Scroll to top of body + }, + 500 + ); + }, 200); + }; + $scope.getMessageType = function (type) { + switch (type) { + case "Success": + return "success"; + case "Error": + $scope.newMsgCount += 1; + return "danger"; + case "Warning": + return "warning"; + case "Info": + return "info"; + default: + return "default"; + } + }; + }, +]); + +modules.component("mainSideBar", { templateUrl: - "/mix-app/views/app-portal/components/main-side-bar-item/main-side-bar-item.html", + "/mix-app/views/app-portal/components/main-side-bar/main-side-bar.html", controller: [ "$rootScope", - function ($rootScope) { + "$scope", + "ngAppSettings", + "TranslatorService", + "ApiService", + "CommonService", + function ( + $rootScope, + $scope, + ngAppSettings, + translatorService, + apiService, + commonService + ) { var ctrl = this; - ctrl.translate = $rootScope.translate; - ctrl.addClass = function (obj) { - obj.currentTarget.classList.add("btn-group-lg"); - //alert(obj); - }; - ctrl.removeClass = function (obj) { - obj.currentTarget.classList.remove("btn-group-lg"); - //alert(obj); + ctrl.items = []; + ctrl.init = async function () { + var resp = await apiService.getPortalMenus(); + if (resp.success && resp.data && resp.data.length) { + ctrl.items = resp.data; + } else { + ctrl.items = JSON.parse($("#portal-menus").val()).items; + } }; }, ], bindings: { - item: "=", + items: "=?", }, }); -modules.component("mainSideBarItemDynamic", { +modules.component("mainSideBarItem", { templateUrl: - "/mix-app/views/app-portal/components/main-side-bar-item-dynamic/main-side-bar-item-dynamic.html", + "/mix-app/views/app-portal/components/main-side-bar-item/main-side-bar-item.html", controller: [ "$rootScope", function ($rootScope) { var ctrl = this; ctrl.translate = $rootScope.translate; + ctrl.addClass = function (obj) { + obj.currentTarget.classList.add("btn-group-lg"); + //alert(obj); + }; + ctrl.removeClass = function (obj) { + obj.currentTarget.classList.remove("btn-group-lg"); + //alert(obj); + }; }, ], bindings: { - iconSize: "=", - linkStyle: "=", - itemStyle: "=", item: "=", }, }); @@ -11867,44 +11808,103 @@ modules.component("mediaFileUpload", { ], }); -modules.component("mediaUpload", { +modules.component("mainSideBarItemDynamic", { templateUrl: - "/mix-app/views/app-portal/components/media-upload/media-upload.html", + "/mix-app/views/app-portal/components/main-side-bar-item-dynamic/main-side-bar-item-dynamic.html", controller: [ - "$scope", "$rootScope", - "MediaService", - "ApiService", - "CommonService", - function ($scope, $rootScope, service, apiService, commonService) { + function ($rootScope) { var ctrl = this; - ctrl.default = { - title: "", - description: "", - status: "Published", - fileFolder: "Medias", - mediaFile: { - file: null, - fullPath: "", - folderName: "Media", - fileFolder: "", - fileName: "", - extension: "", - content: "", - fileStream: "", - }, - }; - ctrl.viewmodel = angular.copy(ctrl.default); - ctrl.onInsert = function (data) { - if (ctrl.onUpdate) { - ctrl.onUpdate(); - } - }; - ctrl.save = async function (data) { - $rootScope.isBusy = true; - var resp = await service.save(data); - if (resp && resp.success) { - $scope.viewmodel = resp.data; + ctrl.translate = $rootScope.translate; + }, + ], + bindings: { + iconSize: "=", + linkStyle: "=", + itemStyle: "=", + item: "=", + }, +}); + +modules.component("mainSideBarDynamic", { + templateUrl: + "/mix-app/views/app-portal/components/main-side-bar-dynamic/main-side-bar-dynamic.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "CommonService", + "TranslatorService", + "AuthService", + function ( + $rootScope, + $scope, + ngAppSettings, + commonService, + translatorService, + authService + ) { + var ctrl = this; + ctrl.init = function () { + // commonService.getPermissions().then(function (response) { + // if (response && response.success) { + // ctrl.isInit = true; + // ctrl.roles = response.data; + // if (ctrl.roles.data) { + // ctrl.role = ctrl.roles.data[0]; + // } + // $rootScope.isBusy = false; + // $scope.$apply(); + // } + // }); + }; + }, + ], + bindings: { + roles: "=", + activedRole: "=", + translate: "&", + }, +}); + +modules.component("mediaUpload", { + templateUrl: + "/mix-app/views/app-portal/components/media-upload/media-upload.html", + controller: [ + "$scope", + "$rootScope", + "MediaService", + "ApiService", + "CommonService", + function ($scope, $rootScope, service, apiService, commonService) { + var ctrl = this; + ctrl.default = { + title: "", + description: "", + status: "Published", + fileFolder: "Medias", + mediaFile: { + file: null, + fullPath: "", + folderName: "Media", + fileFolder: "", + fileName: "", + extension: "", + content: "", + fileStream: "", + }, + }; + ctrl.viewmodel = angular.copy(ctrl.default); + ctrl.onInsert = function (data) { + if (ctrl.onUpdate) { + ctrl.onUpdate(); + } + }; + ctrl.save = async function (data) { + $rootScope.isBusy = true; + var resp = await service.save(data); + if (resp && resp.success) { + $scope.viewmodel = resp.data; $rootScope.showMessage("success", "success"); $rootScope.isBusy = false; ctrl.viewmodel = angular.copy(ctrl.default); @@ -12393,340 +12393,123 @@ modules.component("mixDatabaseDataFilter", { ], }); -modules.component("mixDatabaseDataValueEditor", { +modules.component("mixDatabaseDataValues", { templateUrl: - "/mix-app/views/app-portal/components/mix-database-data-value-editor/view.html", + "/mix-app/views/app-portal/components/mix-database-data-values/view.html", bindings: { - mixDatabaseDataValue: "=?", - parentType: "=?", + database: "=?", + mixDatabaseName: "=?", + mixDatabaseTitle: "=?", + mixDatabaseId: "=?", + parentName: "=?", parentId: "=?", - isShowTitle: "=?", + guidParentId: "=?", + header: "=?", + data: "=?", + canDrag: "=?", + queries: "=?", + filterType: "=?", + compareType: "=?", + selectedList: "=?", + selectSingle: "=?", + database: "=?", + onFilterList: "&?", + onApplyList: "&?", + onSendMail: "&?", + onUpdate: "&?", + onDuplicate: "&?", + onDelete: "&?", }, controller: [ "$rootScope", "$scope", - "ngAppSettings", "$location", - "RestRelatedMixDatabasePortalService", - "RestMixDatabaseDataPortalService", + "$routeParams", + "ngAppSettings", + "RestMixDatabasePortalService", + "MixDbService", function ( $rootScope, $scope, - ngAppSettings, $location, - navService, + $routeParams, + ngAppSettings, + databaseService, dataService ) { var ctrl = this; - ctrl.goToPath = $rootScope.goToPath; - ctrl.icons = ngAppSettings.icons; - ctrl.refData = null; - ctrl.defaultDataModel = null; - ctrl.refDataModel = { - id: null, - data: null, + ctrl.intShowColumn = 3; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.actions = ["Delete", "SendMail"]; + ctrl.filterTypes = ["contain", "equal"]; + ctrl.compareTypes = ["or", "and"]; + ctrl.selectedProp = null; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = async function () { + dataService.initDbName(ctrl.mixDatabaseName); + ctrl.request.name = ctrl.mixDatabaseName; + ctrl.request.parentName = ctrl.parentName; + ctrl.request.parentId = ctrl.parentId; + ctrl.request.guidParentId = ctrl.guidParentId; + if (!ctrl.selectedList) { + ctrl.selectedList = { + action: "Delete", + data: [], + }; + } + if (!ctrl.database) { + var getDatabase = await databaseService.getByName( + ctrl.mixDatabaseName + ); + if (getDatabase.success) { + ctrl.database = getDatabase.data; + $scope.$apply(); + } + } + if (!ctrl.data) { + await ctrl.loadData(); + } + ctrl.createUrl = `/admin/mix-database-data/create?mixDatabaseId=${ + ctrl.database.id + }&mixDatabaseName=${ctrl.database.systemName}&mixDatabaseTitle=${ + ctrl.database.displayName + }&dataContentId=default&guidParentId=${ + ctrl.guidParentId || "" + }&parentId=${ctrl.parentId || ""}&parentName=${ctrl.parentName || ""}`; + $scope.$apply(); }; - ctrl.refRequest = angular.copy(ngAppSettings.request); - ctrl.refRequest.pageSize = 100; - ctrl.dataTypes = $rootScope.globalSettings.dataTypes; - ctrl.previousId = null; - ctrl.$doCheck = function () { - if ( - ctrl.mixDatabaseDataValue && - ctrl.previousId !== ctrl.mixDatabaseDataValue.id - ) { - ctrl.previousId = ctrl.mixDatabaseDataValue.id; - ctrl.initData(); + ctrl.loadData = async function () { + dataService.initDbName(ctrl.mixDatabaseName); + ctrl.request.queries = []; + if (ctrl.queries) { + Object.keys(ctrl.queries).forEach((e) => { + if (ctrl.queries[e]) { + ctrl.request.queries.push({ + fieldName: e, + value: ctrl.queries[e], + }); + } + }); } - }.bind(ctrl); - ctrl.$onInit = function () { - ctrl.initData(); + var getData = await dataService.filter(ctrl.request); + ctrl.data = getData.data; + ctrl.selectedIds = ctrl.data.items.map((m) => m.id); + $scope.$apply(); }; - ctrl.initData = async function () { - setTimeout(() => { - if (!ctrl.mixDatabaseDataValue.id) { - ctrl.initDefaultValue(); - } - switch (ctrl.mixDatabaseDataValue.dataType.toLowerCase()) { - case "datetime": - case "date": - case "time": - if (ctrl.mixDatabaseDataValue.dateTimeValue) { - ctrl.mixDatabaseDataValue.dateObj = new Date( - ctrl.mixDatabaseDataValue.dateTimeValue - ); - $scope.$apply(); - } - break; - case "reference": // reference - if ( - ctrl.mixDatabaseDataValue.column.referenceId && - ctrl.parentId - ) { - ctrl.mixDatabaseDataValue.integerValue = - ctrl.mixDatabaseDataValue.column.referenceId; - // navService.getSingle(["default"]).then((resp) => { - // ctrl.defaultDataModel = resp; - // ctrl.defaultDataModel.mixDatabaseId = - // ctrl.mixDatabaseDataValue.column.referenceId; - // ctrl.refDataModel = angular.copy(ctrl.defaultDataModel); - // }); - // ctrl.loadRefData(); - } - break; - default: - if ( - ctrl.mixDatabaseDataValue.column && - ctrl.mixDatabaseDataValue.column.isEncrypt && - ctrl.mixDatabaseDataValue.encryptValue - ) { - var encryptedData = { - key: ctrl.mixDatabaseDataValue.encryptKey, - data: ctrl.mixDatabaseDataValue.encryptValue, - }; - ctrl.mixDatabaseDataValue.stringValue = - $rootScope.decrypt(encryptedData); - } - if ( - ctrl.mixDatabaseDataValue.column && - !ctrl.mixDatabaseDataValue.stringValue - ) { - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.column.defaultValue; - $scope.$apply(); - } - break; - } - }, 200); - }; - ctrl.initDefaultValue = async function () { - switch (ctrl.mixDatabaseDataValue.dataType) { - case "datetime": - case "date": - case "time": - if (ctrl.mixDatabaseDataValue.column.defaultValue) { - ctrl.mixDatabaseDataValue.dateObj = new Date( - ctrl.mixDatabaseDataValue.column.defaultValue - ); - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.column.defaultValue; - } - break; - case "double": - if (ctrl.mixDatabaseDataValue.column.defaultValue) { - ctrl.mixDatabaseDataValue.doubleValue = parseFloat( - ctrl.mixDatabaseDataValue.column.defaultValue - ); - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.column.defaultValue; - } - break; - case "boolean": - if (ctrl.mixDatabaseDataValue.column.defaultValue) { - ctrl.mixDatabaseDataValue.booleanValue = - ctrl.mixDatabaseDataValue.column.defaultValue == "true"; - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.column.defaultValue; - } - break; - - default: - if (ctrl.mixDatabaseDataValue.column.defaultValue) { - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.column.defaultValue; - } - break; - } - }; - ctrl.updateStringValue = async function (dataType) { - switch (dataType.toLowerCase()) { - case "datetime": - case "date": - case "time": - if (ctrl.mixDatabaseDataValue.dateObj) { - ctrl.mixDatabaseDataValue.dateTimeValue = - ctrl.mixDatabaseDataValue.dateObj.toISOString(); - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.dateTimeValue; - } - break; - case "double": - if (ctrl.mixDatabaseDataValue.doubleValue) { - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.doubleValue.toString(); - } - break; - case "boolean": - if (ctrl.mixDatabaseDataValue.booleanValue != null) { - ctrl.mixDatabaseDataValue.stringValue = - ctrl.mixDatabaseDataValue.booleanValue.toString(); - } - break; - - default: - break; - } - }; - - ctrl.updateRefData = function (nav) { - ctrl.goToPath(`/admin/mix-database-data/details?dataContentId=${nav.data.id} - &mixDatabaseId=${nav.data.mixDatabaseId} - &parentId=${ctrl.parentId} - &parentType=${ctrl.parentType}`); - // ctrl.refDataModel = nav; - // var e = $(".pane-form-" + ctrl.mixDatabaseDataValue.column.referenceId)[0]; - // angular.element(e).triggerHandler('click'); - // $location.url('/admin/mix-database-data/details?dataContentId='+ item.id +'&mixDatabaseId=' + item.mixDatabaseId+'&parentType=' + item.parentType+'&parentId=' + item.parentId); - }; - - ctrl.removeRefData = async function (nav) { - $rootScope.showConfirm( - ctrl, - "removeRefDataConfirmed", - [nav], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - ctrl.removeRefDataConfirmed = async function (nav) { - $rootScope.isBusy = true; - var result = await navService.delete([ - nav.parentId, - nav.parentType, - nav.id, - ]); - if (result.success) { - $rootScope.removeObjectByKey(ctrl.refData, "id", nav.id); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErros(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, - ], -}); - -modules.component("mixDatabaseDataValues", { - templateUrl: - "/mix-app/views/app-portal/components/mix-database-data-values/view.html", - bindings: { - database: "=?", - mixDatabaseName: "=?", - mixDatabaseTitle: "=?", - mixDatabaseId: "=?", - parentName: "=?", - parentId: "=?", - guidParentId: "=?", - header: "=?", - data: "=?", - canDrag: "=?", - queries: "=?", - filterType: "=?", - compareType: "=?", - selectedList: "=?", - selectSingle: "=?", - database: "=?", - onFilterList: "&?", - onApplyList: "&?", - onSendMail: "&?", - onUpdate: "&?", - onDuplicate: "&?", - onDelete: "&?", - }, - controller: [ - "$rootScope", - "$scope", - "$location", - "$routeParams", - "ngAppSettings", - "RestMixDatabasePortalService", - "MixDbService", - function ( - $rootScope, - $scope, - $location, - $routeParams, - ngAppSettings, - databaseService, - dataService - ) { - var ctrl = this; - ctrl.intShowColumn = 3; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.actions = ["Delete", "SendMail"]; - ctrl.filterTypes = ["contain", "equal"]; - ctrl.compareTypes = ["or", "and"]; - ctrl.selectedProp = null; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = async function () { - dataService.initDbName(ctrl.mixDatabaseName); - ctrl.request.name = ctrl.mixDatabaseName; - ctrl.request.parentName = ctrl.parentName; - ctrl.request.parentId = ctrl.parentId; - ctrl.request.guidParentId = ctrl.guidParentId; - if (!ctrl.selectedList) { - ctrl.selectedList = { - action: "Delete", - data: [], - }; - } - if (!ctrl.database) { - var getDatabase = await databaseService.getByName( - ctrl.mixDatabaseName - ); - if (getDatabase.success) { - ctrl.database = getDatabase.data; - $scope.$apply(); - } - } - if (!ctrl.data) { - await ctrl.loadData(); - } - ctrl.createUrl = `/admin/mix-database-data/create?mixDatabaseId=${ - ctrl.database.id - }&mixDatabaseName=${ctrl.database.systemName}&mixDatabaseTitle=${ - ctrl.database.displayName - }&dataContentId=default&guidParentId=${ - ctrl.guidParentId || "" - }&parentId=${ctrl.parentId || ""}&parentName=${ctrl.parentName || ""}`; - $scope.$apply(); - }; - ctrl.loadData = async function () { - dataService.initDbName(ctrl.mixDatabaseName); - ctrl.request.queries = []; - if (ctrl.queries) { - Object.keys(ctrl.queries).forEach((e) => { - if (ctrl.queries[e]) { - ctrl.request.queries.push({ - fieldName: e, - value: ctrl.queries[e], - }); - } - }); - } - var getData = await dataService.filter(ctrl.request); - ctrl.data = getData.data; - ctrl.selectedIds = ctrl.data.items.map((m) => m.id); - $scope.$apply(); - }; - ctrl.select = function (item) { - if (item.isSelected) { - if (ctrl.selectSingle == "true") { - ctrl.selectedList.data.items = []; - ctrl.selectedList.data.items.push(item); - } else { - var current = $rootScope.findObjectByKey( - ctrl.selectedList, - "id", - item.id - ); - if (!current) { - ctrl.selectedList.data.items.push(item); - } + ctrl.select = function (item) { + if (item.isSelected) { + if (ctrl.selectSingle == "true") { + ctrl.selectedList.data.items = []; + ctrl.selectedList.data.items.push(item); + } else { + var current = $rootScope.findObjectByKey( + ctrl.selectedList, + "id", + item.id + ); + if (!current) { + ctrl.selectedList.data.items.push(item); + } } } else { $rootScope.removeObject(ctrl.selectedList, item.id); @@ -12842,312 +12625,217 @@ modules.component("mixDatabaseDataValues", { ], }); -modules.component("mixDatabaseForm", { +modules.component("mixDatabaseDataValueEditor", { templateUrl: - "/mix-app/views/app-portal/components/mix-database-form/view.html", + "/mix-app/views/app-portal/components/mix-database-data-value-editor/view.html", bindings: { - mixDatabaseId: "=?", - mixDatabaseName: "=?", - mixDatabaseTitle: "=?", - mixDatabaseType: "=?", + mixDatabaseDataValue: "=?", + parentType: "=?", parentId: "=?", - parentType: "=?", // MixContentType - parentName: "=?", - postId: "=?", - pageId: "=?", - moduleId: "=?", - columns: "=?", - references: "=?", - mixDataContentId: "=?", - mixDataContent: "=?", - intParentId: "=?", - guidParentId: "=?", - defaultId: "=", - backUrl: "=?", - level: "=?", - hideAction: "=?", - onSave: "&?", - onSaveSuccess: "&?", + isShowTitle: "=?", }, controller: [ "$rootScope", "$scope", - "$routeParams", + "ngAppSettings", "$location", - "RestMixAssociationPortalService", - "RestMixDatabasePortalService", - "MixDbService", - "AuthService", + "RestRelatedMixDatabasePortalService", + "RestMixDatabaseDataPortalService", function ( $rootScope, $scope, - $routeParams, + ngAppSettings, $location, - associationService, - databaseService, - service, - authService + navService, + dataService ) { var ctrl = this; - BaseHub.call(this, ctrl); - ctrl.isBusy = false; - ctrl.attributes = []; - ctrl.isInRole = $rootScope.isInRole; - ctrl.defaultData = null; - ctrl.selectedProp = null; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = async function () { - ctrl.level = ctrl.level || 0; - ctrl.canSave = ctrl.onSave != undefined; - let getDatabase = await databaseService.getByName(ctrl.mixDatabaseName); - ctrl.database = getDatabase.data; - service.initDbName(ctrl.mixDatabaseName); - await ctrl.loadData(); - ctrl.connectHub(); - ctrl.isBusy = false; - $scope.$apply(); + ctrl.goToPath = $rootScope.goToPath; + ctrl.icons = ngAppSettings.icons; + ctrl.refData = null; + ctrl.defaultDataModel = null; + ctrl.refDataModel = { + id: null, + data: null, }; - ctrl.connectHub = () => { - ctrl.startConnection( - "mixDbCommandHub", - authService.authentication.accessToken, - (err) => { - if ( - authService.authentication.refreshToken && - err.message.indexOf("401") >= 0 - ) { - authService.refreshToken().then(async () => { - $scope.startConnection( - "mixDbCommandHub", - authService.authentication.accessToken + ctrl.refRequest = angular.copy(ngAppSettings.request); + ctrl.refRequest.pageSize = 100; + ctrl.dataTypes = $rootScope.globalSettings.dataTypes; + ctrl.previousId = null; + ctrl.$doCheck = function () { + if ( + ctrl.mixDatabaseDataValue && + ctrl.previousId !== ctrl.mixDatabaseDataValue.id + ) { + ctrl.previousId = ctrl.mixDatabaseDataValue.id; + ctrl.initData(); + } + }.bind(ctrl); + ctrl.$onInit = function () { + ctrl.initData(); + }; + ctrl.initData = async function () { + setTimeout(() => { + if (!ctrl.mixDatabaseDataValue.id) { + ctrl.initDefaultValue(); + } + switch (ctrl.mixDatabaseDataValue.dataType.toLowerCase()) { + case "datetime": + case "date": + case "time": + if (ctrl.mixDatabaseDataValue.dateTimeValue) { + ctrl.mixDatabaseDataValue.dateObj = new Date( + ctrl.mixDatabaseDataValue.dateTimeValue ); - }); - } + $scope.$apply(); + } + break; + case "reference": // reference + if ( + ctrl.mixDatabaseDataValue.column.referenceId && + ctrl.parentId + ) { + ctrl.mixDatabaseDataValue.integerValue = + ctrl.mixDatabaseDataValue.column.referenceId; + // navService.getSingle(["default"]).then((resp) => { + // ctrl.defaultDataModel = resp; + // ctrl.defaultDataModel.mixDatabaseId = + // ctrl.mixDatabaseDataValue.column.referenceId; + // ctrl.refDataModel = angular.copy(ctrl.defaultDataModel); + // }); + // ctrl.loadRefData(); + } + break; + default: + if ( + ctrl.mixDatabaseDataValue.column && + ctrl.mixDatabaseDataValue.column.isEncrypt && + ctrl.mixDatabaseDataValue.encryptValue + ) { + var encryptedData = { + key: ctrl.mixDatabaseDataValue.encryptKey, + data: ctrl.mixDatabaseDataValue.encryptValue, + }; + ctrl.mixDatabaseDataValue.stringValue = + $rootScope.decrypt(encryptedData); + } + if ( + ctrl.mixDatabaseDataValue.column && + !ctrl.mixDatabaseDataValue.stringValue + ) { + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.column.defaultValue; + $scope.$apply(); + } + break; } - ); - }; - ctrl.hubCreateData = function () { - let msg = { - connectionId: ctrl.hubRequest.from.connectionId, - mixDbName: ctrl.mixDatabaseName, - requestedBy: "", - body: ctrl.mixDataContent, - }; - if (!ctrl.mixDataContent.id) { - ctrl.connection.invoke("CreateData", JSON.stringify(msg)); - } else { - ctrl.connection.invoke("UpdateData", JSON.stringify(msg)); - } - $rootScope.showMessage("Request Sent", "success"); + }, 200); }; - ctrl.receiveMessage = function (msg) { - switch (msg.action) { - case "MyConnection": - ctrl.hubRequest.from = msg.data; - break; - case "NewMessage": - if (msg.type == "Success") { - $rootScope.showMessage(msg.title, "success"); - ctrl.back(); + ctrl.initDefaultValue = async function () { + switch (ctrl.mixDatabaseDataValue.dataType) { + case "datetime": + case "date": + case "time": + if (ctrl.mixDatabaseDataValue.column.defaultValue) { + ctrl.mixDatabaseDataValue.dateObj = new Date( + ctrl.mixDatabaseDataValue.column.defaultValue + ); + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.column.defaultValue; } - if (msg.type == "Error") { - $rootScope.showErrors([msg.title]); + break; + case "double": + if (ctrl.mixDatabaseDataValue.column.defaultValue) { + ctrl.mixDatabaseDataValue.doubleValue = parseFloat( + ctrl.mixDatabaseDataValue.column.defaultValue + ); + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.column.defaultValue; } break; - } - }; - ctrl.back = function () { - if (ctrl.backUrl) { - $location.url(ctrl.backUrl); - } else { - window.history.back(); - } - }; - ctrl.translate = (keyword) => { - return $rootScope.translate(keyword); - }; - ctrl.loadData = async function () { - /* - If input is data id => load ctrl.mixDataContent from service and handle it independently - */ - ctrl.isBusy = true; - if (!ctrl.mixDataContent && ctrl.mixDataContentId) { - service.initDbName(ctrl.mixDatabaseName); - var getData = await service.getSingle([ctrl.mixDataContentId], { - loadNestedData: true, - }); - ctrl.mixDataContent = getData.data; - if (ctrl.mixDataContent) { - ctrl.mixDataContent.intParentId = ctrl.intParentId; - ctrl.mixDataContent.guidParentId = ctrl.guidParentId; - ctrl.mixDataContent.parentType = ctrl.parentType; - // ctrl.mixDatabaseId = ctrl.mixDataContent.mixDatabaseId; - // ctrl.mixDatabaseName = ctrl.mixDataContent.mixDatabaseName; - ctrl.mixDatabaseTitle = - ctrl.mixDatabaseTitle || - $routeParams.mixDatabaseTitle || - ctrl.mixDatabaseName; - ctrl.backUrl = - ctrl.backUrl ?? - `/admin/mix-database-data/list?mixDatabaseId=${ctrl.mixDataContent.mixDatabaseId}&mixDatabaseName=${ctrl.mixDatabaseName}&mixDatabaseTitle=${ctrl.mixDatabaseTitle}`; - // await ctrl.loadDefaultModel(); - ctrl.isBusy = false; - $scope.$apply(); - } else { - if (getData) { - $rootScope.showErrors(getData.errors); + case "boolean": + if (ctrl.mixDatabaseDataValue.column.defaultValue) { + ctrl.mixDatabaseDataValue.booleanValue = + ctrl.mixDatabaseDataValue.column.defaultValue == "true"; + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.column.defaultValue; } - ctrl.isBusy = false; - $scope.$apply(); - } - } - if ( - !ctrl.mixDataContent && - (ctrl.mixDatabaseName || ctrl.mixDatabaseId) && - !ctrl.defaultData - ) { - ctrl.mixDataContent = {}; - if (ctrl.parentId) { - ctrl.mixDataContent.parentId = ctrl.parentId; - } - // await ctrl.loadDefaultModel(); - ctrl.isBusy = false; - } - if ($routeParams.parentId && $routeParams.parentName) { - var getAssociation = await associationService.getAssociation( - $routeParams.parentName, - ctrl.mixDatabaseName, - $routeParams.parentId, - ctrl.mixDataContent.id - ); - if (getAssociation.success) { - ctrl.association = getAssociation.data; - } else { - ctrl.association = { - parentId: $routeParams.parentId, - parentDatabaseName: $routeParams.parentName, - childDatabaseName: ctrl.mixDatabaseName, - }; - } - var parentIdNameFieldName = `${$routeParams.parentName - .charAt(0) - .toLowerCase()}${ - $routeParams.parentName.slice(1) || $routeParams.parentName - }Id`; - if (!ctrl.mixDataContent[parentIdNameFieldName]) { - ctrl.mixDataContent[parentIdNameFieldName] = $routeParams.parentId; - } - } - }; + break; - ctrl.reload = async function () { - ctrl.mixDataContent = angular.copy(ctrl.defaultData); - }; - ctrl.loadSelected = function () { - if (ctrl.selectedList.data.length) { - ctrl.mixDataContent = ctrl.selectedList.data[0]; - ctrl.mixDataContent.mixDatabaseId = ctrl.mixDatabaseId; - ctrl.mixDataContent.mixDatabaseName = ctrl.mixDatabaseName; - ctrl.mixDataContent.intParentId = ctrl.intParentId; - ctrl.mixDataContent.guidParentId = ctrl.guidParentId; - ctrl.mixDataContent.parentType = ctrl.parentType; - } - }; - ctrl.submit = async function () { - if (ctrl.validate()) { - if (ctrl.onSave) { - ctrl.onSave({ data: ctrl.mixDataContent }); - } else { - ctrl.isBusy = true; - service.initDbName(ctrl.mixDatabaseName); - var saveResult = await service.save(ctrl.mixDataContent); - if (saveResult.success) { - ctrl.mixDataContent = saveResult.data; - if (ctrl.association) { - let result = await ctrl.saveAssociation(ctrl.mixDataContent); - if (result.success) { - ctrl.isBusy = false; - $rootScope.showMessage("success"); - $scope.$apply(); - } else { - ctrl.isBusy = false; - $rootScope.showErrors(result.errors); - $scope.$apply(); - } - } else { - if (ctrl.onSaveSuccess) { - ctrl.onSaveSuccess({ data: ctrl.mixDataContent }); - } - ctrl.isBusy = false; - $rootScope.showMessage("success"); - $scope.$apply(); - } - } else { - ctrl.isBusy = false; - if (saveResult) { - $rootScope.showErrors(saveResult.errors); - } - $scope.$apply(); + default: + if (ctrl.mixDatabaseDataValue.column.defaultValue) { + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.column.defaultValue; } - } + break; } }; - ctrl.saveAssociation = async function (data) { - ctrl.association.childId = data.id; - return await associationService.save(ctrl.association); - }; - ctrl.validate = function () { - var isValid = true; - ctrl.errors = []; - angular.forEach(ctrl.columns, function (column) { - if (column.regex) { - var regex = RegExp(column.regex, "g"); - isValid = regex.test(ctrl.mixDataContent.data[column.name]); - if (!isValid) { - ctrl.errors.push(`${column.name} is not match Regex`); + ctrl.updateStringValue = async function (dataType) { + switch (dataType.toLowerCase()) { + case "datetime": + case "date": + case "time": + if (ctrl.mixDatabaseDataValue.dateObj) { + ctrl.mixDatabaseDataValue.dateTimeValue = + ctrl.mixDatabaseDataValue.dateObj.toISOString(); + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.dateTimeValue; } - } - if (!isValid) { - $rootScope.showErrors(ctrl.errors); - } - if (isValid && column.isEncrypt) { - ctrl.mixDataContent.data[column.name] = $rootScope.encrypt( - ctrl.mixDataContent.data[column.name] - ); - } - }); - return isValid; - }; - ctrl.showContentFilter = function ($event) { - $rootScope.showContentFilter(ctrl.loadSelectedLink); - }; - ctrl.loadSelectedLink = function (data, type) { - if (data) { - ctrl.mixDataContent.data.target_id = data.id; - ctrl.mixDataContent.data.title = data.title; - ctrl.mixDataContent.data.type = type; - ctrl.mixDataContent.data.uri = data.detailUrl; + break; + case "double": + if (ctrl.mixDatabaseDataValue.doubleValue) { + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.doubleValue.toString(); + } + break; + case "boolean": + if (ctrl.mixDatabaseDataValue.booleanValue != null) { + ctrl.mixDatabaseDataValue.stringValue = + ctrl.mixDatabaseDataValue.booleanValue.toString(); + } + break; + + default: + break; } }; - ctrl.filterData = function (attributeName) { - if (ctrl.mixDataContent) { - var attr = $rootScope.findObjectByKey( - ctrl.mixDataContent.data, - "mixDatabaseColumnName", - attributeName - ); - if (!attr) { - attr = angular.copy( - $rootScope.findObjectByKey( - ctrl.defaultData.data, - "mixDatabaseColumnName", - attributeName - ) - ); - mixDatabaseColumn; - ctrl.mixDataContent.data.push(attr); - } - return attr; + + ctrl.updateRefData = function (nav) { + ctrl.goToPath(`/admin/mix-database-data/details?dataContentId=${nav.data.id} + &mixDatabaseId=${nav.data.mixDatabaseId} + &parentId=${ctrl.parentId} + &parentType=${ctrl.parentType}`); + // ctrl.refDataModel = nav; + // var e = $(".pane-form-" + ctrl.mixDatabaseDataValue.column.referenceId)[0]; + // angular.element(e).triggerHandler('click'); + // $location.url('/admin/mix-database-data/details?dataContentId='+ item.id +'&mixDatabaseId=' + item.mixDatabaseId+'&parentType=' + item.parentType+'&parentId=' + item.parentId); + }; + + ctrl.removeRefData = async function (nav) { + $rootScope.showConfirm( + ctrl, + "removeRefDataConfirmed", + [nav], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + ctrl.removeRefDataConfirmed = async function (nav) { + $rootScope.isBusy = true; + var result = await navService.delete([ + nav.parentId, + nav.parentType, + nav.id, + ]); + if (result.success) { + $rootScope.removeObjectByKey(ctrl.refData, "id", nav.id); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErros(result.errors); + $rootScope.isBusy = false; + $scope.$apply(); } }; }, @@ -13495,90 +13183,312 @@ modules.component("mixDatabaseNavValues", { ], }); -modules.component("mixFileExtract", { +modules.component("mixDatabaseForm", { templateUrl: - "/mix-app/views/app-portal/components/mix-file-extract/view.html", + "/mix-app/views/app-portal/components/mix-database-form/view.html", bindings: { - folder: "=?", - accept: "=?", - onFail: "&?", - onSuccess: "&?", + mixDatabaseId: "=?", + mixDatabaseName: "=?", + mixDatabaseTitle: "=?", + mixDatabaseType: "=?", + parentId: "=?", + parentType: "=?", // MixContentType + parentName: "=?", + postId: "=?", + pageId: "=?", + moduleId: "=?", + columns: "=?", + references: "=?", + mixDataContentId: "=?", + mixDataContent: "=?", + intParentId: "=?", + guidParentId: "=?", + defaultId: "=", + backUrl: "=?", + level: "=?", + hideAction: "=?", + onSave: "&?", + onSaveSuccess: "&?", }, controller: [ "$rootScope", "$scope", - "ngAppSettings", - "FileServices", - function ($rootScope, $scope, ngAppSettings, fileService) { + "$routeParams", + "$location", + "RestMixAssociationPortalService", + "RestMixDatabasePortalService", + "MixDbService", + "AuthService", + function ( + $rootScope, + $scope, + $routeParams, + $location, + associationService, + databaseService, + service, + authService + ) { var ctrl = this; - ctrl.mediaFile = {}; - ctrl.isAdmin = $rootScope.isAdmin; - ctrl.mediaNavs = []; - ctrl.$onInit = function () { - ctrl.id = Math.floor(Math.random() * 100); + BaseHub.call(this, ctrl); + ctrl.isBusy = false; + ctrl.attributes = []; + ctrl.isInRole = $rootScope.isInRole; + ctrl.defaultData = null; + ctrl.selectedProp = null; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = async function () { + ctrl.level = ctrl.level || 0; + ctrl.canSave = ctrl.onSave != undefined; + let getDatabase = await databaseService.getByName(ctrl.mixDatabaseName); + ctrl.database = getDatabase.data; + service.initDbName(ctrl.mixDatabaseName); + await ctrl.loadData(); + ctrl.connectHub(); + ctrl.isBusy = false; + $scope.$apply(); }; - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - const file = files[0]; - ctrl.file = file; - ctrl.mediaFile.folder = ctrl.folder ? ctrl.folder : "Media"; - ctrl.mediaFile.title = ctrl.title ? ctrl.title : ""; - ctrl.mediaFile.description = ctrl.description ? ctrl.description : ""; - ctrl.mediaFile.file = file; - if (ctrl.auto == "true") { - ctrl.uploadFile(file); + ctrl.connectHub = () => { + ctrl.startConnection( + "mixDbCommandHub", + authService.authentication.accessToken, + (err) => { + if ( + authService.authentication.refreshToken && + err.message.indexOf("401") >= 0 + ) { + authService.refreshToken().then(async () => { + $scope.startConnection( + "mixDbCommandHub", + authService.authentication.accessToken + ); + }); + } + } + ); + }; + ctrl.hubCreateData = function () { + let msg = { + connectionId: ctrl.hubRequest.from.connectionId, + mixDbName: ctrl.mixDatabaseName, + requestedBy: "", + body: ctrl.mixDataContent, + }; + if (!ctrl.mixDataContent.id) { + ctrl.connection.invoke("CreateData", JSON.stringify(msg)); + } else { + ctrl.connection.invoke("UpdateData", JSON.stringify(msg)); + } + $rootScope.showMessage("Request Sent", "success"); + }; + ctrl.receiveMessage = function (msg) { + switch (msg.action) { + case "MyConnection": + ctrl.hubRequest.from = msg.data; + break; + case "NewMessage": + if (msg.type == "Success") { + $rootScope.showMessage(msg.title, "success"); + ctrl.back(); + } + if (msg.type == "Error") { + $rootScope.showErrors([msg.title]); + } + break; + } + }; + ctrl.back = function () { + if (ctrl.backUrl) { + $location.url(ctrl.backUrl); + } else { + window.history.back(); + } + }; + ctrl.translate = (keyword) => { + return $rootScope.translate(keyword); + }; + ctrl.loadData = async function () { + /* + If input is data id => load ctrl.mixDataContent from service and handle it independently + */ + ctrl.isBusy = true; + if (!ctrl.mixDataContent && ctrl.mixDataContentId) { + service.initDbName(ctrl.mixDatabaseName); + var getData = await service.getSingle([ctrl.mixDataContentId], { + loadNestedData: true, + }); + ctrl.mixDataContent = getData.data; + if (ctrl.mixDataContent) { + ctrl.mixDataContent.intParentId = ctrl.intParentId; + ctrl.mixDataContent.guidParentId = ctrl.guidParentId; + ctrl.mixDataContent.parentType = ctrl.parentType; + // ctrl.mixDatabaseId = ctrl.mixDataContent.mixDatabaseId; + // ctrl.mixDatabaseName = ctrl.mixDataContent.mixDatabaseName; + ctrl.mixDatabaseTitle = + ctrl.mixDatabaseTitle || + $routeParams.mixDatabaseTitle || + ctrl.mixDatabaseName; + ctrl.backUrl = + ctrl.backUrl ?? + `/admin/mix-database-data/list?mixDatabaseId=${ctrl.mixDataContent.mixDatabaseId}&mixDatabaseName=${ctrl.mixDatabaseName}&mixDatabaseTitle=${ctrl.mixDatabaseTitle}`; + // await ctrl.loadDefaultModel(); + ctrl.isBusy = false; + $scope.$apply(); } else { - ctrl.getBase64(file); + if (getData) { + $rootScope.showErrors(getData.errors); + } + ctrl.isBusy = false; + $scope.$apply(); + } + } + if ( + !ctrl.mixDataContent && + (ctrl.mixDatabaseName || ctrl.mixDatabaseId) && + !ctrl.defaultData + ) { + ctrl.mixDataContent = {}; + if (ctrl.parentId) { + ctrl.mixDataContent.parentId = ctrl.parentId; + } + // await ctrl.loadDefaultModel(); + ctrl.isBusy = false; + } + if ($routeParams.parentId && $routeParams.parentName) { + var getAssociation = await associationService.getAssociation( + $routeParams.parentName, + ctrl.mixDatabaseName, + $routeParams.parentId, + ctrl.mixDataContent.id + ); + if (getAssociation.success) { + ctrl.association = getAssociation.data; + } else { + ctrl.association = { + parentId: $routeParams.parentId, + parentDatabaseName: $routeParams.parentName, + childDatabaseName: ctrl.mixDatabaseName, + }; + } + var parentIdNameFieldName = `${$routeParams.parentName + .charAt(0) + .toLowerCase()}${ + $routeParams.parentName.slice(1) || $routeParams.parentName + }Id`; + if (!ctrl.mixDataContent[parentIdNameFieldName]) { + ctrl.mixDataContent[parentIdNameFieldName] = $routeParams.parentId; } } }; - ctrl.getBase64 = function (file) { - if (file !== null) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = function () { - if (ctrl.mediaFile) { - ctrl.mediaFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.fileStream = reader.result; + ctrl.reload = async function () { + ctrl.mixDataContent = angular.copy(ctrl.defaultData); + }; + ctrl.loadSelected = function () { + if (ctrl.selectedList.data.length) { + ctrl.mixDataContent = ctrl.selectedList.data[0]; + ctrl.mixDataContent.mixDatabaseId = ctrl.mixDatabaseId; + ctrl.mixDataContent.mixDatabaseName = ctrl.mixDatabaseName; + ctrl.mixDataContent.intParentId = ctrl.intParentId; + ctrl.mixDataContent.guidParentId = ctrl.guidParentId; + ctrl.mixDataContent.parentType = ctrl.parentType; + } + }; + ctrl.submit = async function () { + if (ctrl.validate()) { + if (ctrl.onSave) { + ctrl.onSave({ data: ctrl.mixDataContent }); + } else { + ctrl.isBusy = true; + service.initDbName(ctrl.mixDatabaseName); + var saveResult = await service.save(ctrl.mixDataContent); + if (saveResult.success) { + ctrl.mixDataContent = saveResult.data; + if (ctrl.association) { + let result = await ctrl.saveAssociation(ctrl.mixDataContent); + if (result.success) { + ctrl.isBusy = false; + $rootScope.showMessage("success"); + $scope.$apply(); + } else { + ctrl.isBusy = false; + $rootScope.showErrors(result.errors); + $scope.$apply(); + } + } else { + if (ctrl.onSaveSuccess) { + ctrl.onSaveSuccess({ data: ctrl.mixDataContent }); + } + ctrl.isBusy = false; + $rootScope.showMessage("success"); + $scope.$apply(); + } + } else { + ctrl.isBusy = false; + if (saveResult) { + $rootScope.showErrors(saveResult.errors); + } + $scope.$apply(); } - $rootScope.isBusy = false; - $scope.$apply(); - }; - reader.onerror = function (error) { - $rootScope.isBusy = false; - $rootScope.showErrors([error]); - }; - } else { - return null; + } } }; - - ctrl.uploadFile = async function () { - if (ctrl.file) { - $rootScope.isBusy = true; - var response = await fileService.extractFile(ctrl.file, ctrl.folder); - if (response) { - if (ctrl.onSuccess) { - ctrl.onSuccess(); + ctrl.saveAssociation = async function (data) { + ctrl.association.childId = data.id; + return await associationService.save(ctrl.association); + }; + ctrl.validate = function () { + var isValid = true; + ctrl.errors = []; + angular.forEach(ctrl.columns, function (column) { + if (column.regex) { + var regex = RegExp(column.regex, "g"); + isValid = regex.test(ctrl.mixDataContent.data[column.name]); + if (!isValid) { + ctrl.errors.push(`${column.name} is not match Regex`); } - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot upload file"]); - $rootScope.isBusy = false; - $scope.$apply(); } - } else { - $rootScope.showErrors(["Please choose file"]); + if (!isValid) { + $rootScope.showErrors(ctrl.errors); + } + if (isValid && column.isEncrypt) { + ctrl.mixDataContent.data[column.name] = $rootScope.encrypt( + ctrl.mixDataContent.data[column.name] + ); + } + }); + return isValid; + }; + ctrl.showContentFilter = function ($event) { + $rootScope.showContentFilter(ctrl.loadSelectedLink); + }; + ctrl.loadSelectedLink = function (data, type) { + if (data) { + ctrl.mixDataContent.data.target_id = data.id; + ctrl.mixDataContent.data.title = data.title; + ctrl.mixDataContent.data.type = type; + ctrl.mixDataContent.data.uri = data.detailUrl; + } + }; + ctrl.filterData = function (attributeName) { + if (ctrl.mixDataContent) { + var attr = $rootScope.findObjectByKey( + ctrl.mixDataContent.data, + "mixDatabaseColumnName", + attributeName + ); + if (!attr) { + attr = angular.copy( + $rootScope.findObjectByKey( + ctrl.defaultData.data, + "mixDatabaseColumnName", + attributeName + ) + ); + mixDatabaseColumn; + ctrl.mixDataContent.data.push(attr); + } + return attr; } }; }, @@ -13703,54 +13613,144 @@ modules.component("mixDatabaseNavs", { $rootScope.isBusy = false; $scope.$apply(); } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + ctrl.update = function (data) { + ctrl.onUpdate({ + data: data, + }); + }; + + ctrl.delete = function (data) { + ctrl.onDelete({ + data: data, + }); + }; + + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + ctrl.minPriority = ctrl.mixDatabaseNavs[0].priority; + }; + ctrl.updateOrders = function (index) { + if (index > ctrl.dragStartIndex) { + ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex, 1); + } else { + ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex + 1, 1); + } + var arrNavs = []; + angular.forEach(ctrl.mixDatabaseNavs, function (e, i) { + e.priority = ctrl.minPriority + i; + var keys = { + parentId: e.parentId, + parentType: e.parentType, + id: e.id, + }; + var properties = { + priority: e.priority, + }; + arrNavs.push({ + keys: keys, + properties: properties, + }); + }); + navService.saveProperties("portal", arrNavs).then((resp) => { + $rootScope.isBusy = false; + $scope.$apply(); + }); + }; + }, + ], +}); + +modules.component("mixFileExtract", { + templateUrl: + "/mix-app/views/app-portal/components/mix-file-extract/view.html", + bindings: { + folder: "=?", + accept: "=?", + onFail: "&?", + onSuccess: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "FileServices", + function ($rootScope, $scope, ngAppSettings, fileService) { + var ctrl = this; + ctrl.mediaFile = {}; + ctrl.isAdmin = $rootScope.isAdmin; + ctrl.mediaNavs = []; + ctrl.$onInit = function () { + ctrl.id = Math.floor(Math.random() * 100); + }; + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + const file = files[0]; + ctrl.file = file; + ctrl.mediaFile.folder = ctrl.folder ? ctrl.folder : "Media"; + ctrl.mediaFile.title = ctrl.title ? ctrl.title : ""; + ctrl.mediaFile.description = ctrl.description ? ctrl.description : ""; + ctrl.mediaFile.file = file; + if (ctrl.auto == "true") { + ctrl.uploadFile(file); + } else { + ctrl.getBase64(file); + } + } + }; + + ctrl.getBase64 = function (file) { + if (file !== null) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function () { + if (ctrl.mediaFile) { + ctrl.mediaFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.fileStream = reader.result; + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + reader.onerror = function (error) { + $rootScope.isBusy = false; + $rootScope.showErrors([error]); + }; + } else { + return null; } }; - ctrl.update = function (data) { - ctrl.onUpdate({ - data: data, - }); - }; - - ctrl.delete = function (data) { - ctrl.onDelete({ - data: data, - }); - }; - - ctrl.dragStart = function (index) { - ctrl.dragStartIndex = index; - ctrl.minPriority = ctrl.mixDatabaseNavs[0].priority; - }; - ctrl.updateOrders = function (index) { - if (index > ctrl.dragStartIndex) { - ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex, 1); + ctrl.uploadFile = async function () { + if (ctrl.file) { + $rootScope.isBusy = true; + var response = await fileService.extractFile(ctrl.file, ctrl.folder); + if (response) { + if (ctrl.onSuccess) { + ctrl.onSuccess(); + } + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot upload file"]); + $rootScope.isBusy = false; + $scope.$apply(); + } } else { - ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex + 1, 1); + $rootScope.showErrors(["Please choose file"]); } - var arrNavs = []; - angular.forEach(ctrl.mixDatabaseNavs, function (e, i) { - e.priority = ctrl.minPriority + i; - var keys = { - parentId: e.parentId, - parentType: e.parentType, - id: e.id, - }; - var properties = { - priority: e.priority, - }; - arrNavs.push({ - keys: keys, - properties: properties, - }); - }); - navService.saveProperties("portal", arrNavs).then((resp) => { - $rootScope.isBusy = false; - $scope.$apply(); - }); }; }, ], @@ -13845,41 +13845,6 @@ modules.component("mixFileUpload", { ], }); -modules.component("mixSelectIcons", { - templateUrl: - "/mix-app/views/app-portal/components/mix-select-icons/mix-select-icons.html", - controller: [ - "$rootScope", - "$scope", - "$location", - "$element", - function ($rootScope, $scope, $location, $element) { - var ctrl = this; - ctrl.limitTo = 20; - ctrl.container = $element[0].querySelector(".list-icon"); - ctrl.translate = function (keyword) { - return $rootScope.translate(keyword); - }; - ctrl.showMore = () => { - if ( - ctrl.container.scrollTop >= ctrl.container.scrollHeight - 200 && - ctrl.limitTo < ctrl.options.length - ) { - ctrl.limitTo *= 2; - } - }; - ctrl.select = function (ico) { - ctrl.data = ico.class; - }; - }, - ], - bindings: { - data: "=", - prefix: "=", - options: "=", - }, -}); - "use strict"; app.controller("MixNavigationController", [ "$scope", @@ -14001,6 +13966,41 @@ app.controller("MixNavigationController", [ }, ]); +modules.component("mixSelectIcons", { + templateUrl: + "/mix-app/views/app-portal/components/mix-select-icons/mix-select-icons.html", + controller: [ + "$rootScope", + "$scope", + "$location", + "$element", + function ($rootScope, $scope, $location, $element) { + var ctrl = this; + ctrl.limitTo = 20; + ctrl.container = $element[0].querySelector(".list-icon"); + ctrl.translate = function (keyword) { + return $rootScope.translate(keyword); + }; + ctrl.showMore = () => { + if ( + ctrl.container.scrollTop >= ctrl.container.scrollHeight - 200 && + ctrl.limitTo < ctrl.options.length + ) { + ctrl.limitTo *= 2; + } + }; + ctrl.select = function (ico) { + ctrl.data = ico.class; + }; + }, + ], + bindings: { + data: "=", + prefix: "=", + options: "=", + }, +}); + modules.component("mixTemplateEditor", { templateUrl: "/mix-app/views/app-portal/components/mix-template-editor/view.html", @@ -14083,6 +14083,30 @@ modules.component("mixTemplateEditor", { ], }); +app.component("modalCroppie", { + templateUrl: "/mix-app/views/app-portal/components/modal-croppie/view.html", + bidings: { + resolve: "<", + close: "&", + dismiss: "&", + }, + controller: function () { + var $ctrl = this; + $ctrl.fileUrl = "test"; + $ctrl.$onInit = function () { + $ctrl.file = $ctrl.resolve.file; + }; + + $ctrl.ok = function () { + $ctrl.close({ $value: $ctrl.fileUrl }); + }; + + $ctrl.cancel = function () { + $ctrl.dismiss({ $value: "cancel" }); + }; + }, +}); + modules.component("mixValueEditor", { templateUrl: "/mix-app/views/app-portal/components/mix-value-editor/view.html", @@ -14271,8 +14295,142 @@ modules.component("modalBookmark", { } else { ctrl.bookmarks.push(ctrl.model); } - localStorageService.set("bookmarks", ctrl.bookmarks); - ctrl.model = angular.copy(ctrl.defaultModel); + localStorageService.set("bookmarks", ctrl.bookmarks); + ctrl.model = angular.copy(ctrl.defaultModel); + }; + }, + ], +}); + +modules.component("modalNavDatas", { + templateUrl: "/mix-app/views/app-portal/components/modal-nav-datas/view.html", + bindings: { + mixDatabaseId: "=?", + mixDatabaseName: "=?", + parentDatabaseName: "=?", + guidParentId: "=?", + parentId: "=?", + parentType: "=?", + type: "=?", + columnDisplay: "=?", + selectedIds: "=?", + selectedList: "=?", + selectCallback: "&?", + save: "&", + }, + controller: [ + "$rootScope", + "$scope", + "$location", + "$routeParams", + "ngAppSettings", + "RestMixAssociationPortalService", + "RestMixDatabasePortalService", + "MixDbService", + function ( + $rootScope, + $scope, + $location, + $routeParams, + ngAppSettings, + associationService, + databaseService, + dataService + ) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.navs = []; + + ctrl.queries = {}; + ctrl.data = { items: [] }; + ctrl.$onInit = async function () { + ctrl.association = { + parentId: ctrl.parentId, + guidParentId: ctrl.guidParentId, + parentDatabaseName: ctrl.parentDatabaseName, + childDatabaseName: ctrl.mixDatabaseName, + }; + dataService.initDbName(ctrl.mixDatabaseName); + ctrl.request.name = ctrl.mixDatabaseName; + ctrl.request.parentName = ctrl.parentName; + // ctrl.request.parentId = ctrl.parentId; + if (!ctrl.database) { + var getDatabase = await databaseService.getByName( + ctrl.mixDatabaseName + ); + if (getDatabase.success) { + ctrl.database = getDatabase.data; + $scope.$apply(); + } + } + if (!ctrl.data) { + await ctrl.loadData(); + } + }; + ctrl.select = async (item) => { + $rootScope.isBusy = true; + if (item.isSelected && (ctrl.parentId || ctrl.guidParentId)) { + ctrl.association.childId = item.id; + let result = await associationService.save(ctrl.association); + if (result.success) { + item.associationId = result.data.id; + } + $rootScope.handleResponse(result); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + let result = await associationService.deleteAssociation( + ctrl.parentDatabaseName, + ctrl.mixDatabaseName, + ctrl.parentId, + ctrl.guidParentId, + item.id + ); + $rootScope.handleResponse(result); + $rootScope.isBusy = false; + $scope.$apply(); + } + if (ctrl.selectCallback) { + ctrl.selectCallback(); + } + }; + + ctrl.filter = function () { + ctrl.data = []; + ctrl.loadData(); + }; + ctrl.loadData = async function () { + dataService.initDbName(ctrl.mixDatabaseName); + ctrl.request.queries = []; + if (ctrl.queries) { + Object.keys(ctrl.queries).forEach((e) => { + if (ctrl.queries[e]) { + ctrl.request.queries.push({ + fieldName: e, + value: ctrl.queries[e], + compareOperator: 'Like', + }); + } + }); + } + var getData = await dataService.filter(ctrl.request); + ctrl.data = getData.data; + angular.forEach(ctrl.data.items, (e) => { + if (ctrl.selectedIds.includes(e.id)) { + e.isSelected = true; + } + }); + $scope.$apply(); + }; + ctrl.update = function (data) { + let url = `/admin/mix-database-data/details?dataContentId=${ + data.id + }&mixDatabaseName=${ctrl.mixDatabaseName}&mixDatabaseTitle=${ + ctrl.mixDatabaseTitle + }&parentId=${ctrl.parentId || ""}&parentName=${ + ctrl.parentName || "" + }&guidParentId=${ctrl.guidParentId || ""}`; + $location.url(url); }; }, ], @@ -14446,30 +14604,6 @@ modules.component("modalContentFilter", { ], }); -app.component("modalCroppie", { - templateUrl: "/mix-app/views/app-portal/components/modal-croppie/view.html", - bidings: { - resolve: "<", - close: "&", - dismiss: "&", - }, - controller: function () { - var $ctrl = this; - $ctrl.fileUrl = "test"; - $ctrl.$onInit = function () { - $ctrl.file = $ctrl.resolve.file; - }; - - $ctrl.ok = function () { - $ctrl.close({ $value: $ctrl.fileUrl }); - }; - - $ctrl.cancel = function () { - $ctrl.dismiss({ $value: "cancel" }); - }; - }, -}); - modules.component("modalHelper", { templateUrl: "/mix-app/views/app-portal/components/modal-helper/modal-helper.html", @@ -14605,135 +14739,159 @@ modules.component("modalHelper", { ], }); -modules.component("modalNavDatas", { - templateUrl: "/mix-app/views/app-portal/components/modal-nav-datas/view.html", +modules.component("modalNavPages", { + templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", bindings: { - mixDatabaseId: "=?", - mixDatabaseName: "=?", - parentDatabaseName: "=?", - guidParentId: "=?", - parentId: "=?", - parentType: "=?", - type: "=?", - columnDisplay: "=?", - selectedIds: "=?", - selectedList: "=?", - selectCallback: "&?", + srcField: "=", + srcId: "=", + query: "=", + selected: "=", save: "&", }, controller: [ "$rootScope", "$scope", - "$location", - "$routeParams", "ngAppSettings", - "RestMixAssociationPortalService", - "RestMixDatabasePortalService", - "MixDbService", - function ( - $rootScope, - $scope, - $location, - $routeParams, - ngAppSettings, - associationService, - databaseService, - dataService - ) { + "PageRestService", + function ($rootScope, $scope, ngAppSettings, pageService) { var ctrl = this; ctrl.request = angular.copy(ngAppSettings.request); ctrl.navs = []; - - ctrl.queries = {}; ctrl.data = { items: [] }; - ctrl.$onInit = async function () { - ctrl.association = { - parentId: ctrl.parentId, - guidParentId: ctrl.guidParentId, - parentDatabaseName: ctrl.parentDatabaseName, - childDatabaseName: ctrl.mixDatabaseName, - }; - dataService.initDbName(ctrl.mixDatabaseName); - ctrl.request.name = ctrl.mixDatabaseName; - ctrl.request.parentName = ctrl.parentName; - // ctrl.request.parentId = ctrl.parentId; - if (!ctrl.database) { - var getDatabase = await databaseService.getByName( - ctrl.mixDatabaseName - ); - if (getDatabase.success) { - ctrl.database = getDatabase.data; - $scope.$apply(); - } + ctrl.loadData = async function (pageIndex) { + ctrl.request.query = ctrl.query + ctrl.srcId; + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; } - if (!ctrl.data) { - await ctrl.loadData(); + if (ctrl.request.fromDate !== null) { + var d = new Date(ctrl.request.fromDate); + ctrl.request.fromDate = d.toISOString(); } - }; - ctrl.select = async (item) => { - $rootScope.isBusy = true; - if (item.isSelected && (ctrl.parentId || ctrl.guidParentId)) { - ctrl.association.childId = item.id; - let result = await associationService.save(ctrl.association); - if (result.success) { - item.associationId = result.data.id; - } - $rootScope.handleResponse(result); + if (ctrl.request.toDate !== null) { + var d = new Date(ctrl.request.toDate); + ctrl.request.toDate = d.toISOString(); + } + var response = await pageService.getList(ctrl.request); + if (response.success) { + ctrl.data = response.data; + ctrl.navs = []; + angular.forEach(response.data.items, function (e) { + var item = { + priority: e.priority, + description: e.title, + pageId: e.id, + image: e.thumbnailUrl, + specificulture: e.specificulture, + status: "Published", + isActived: false, + }; + item[ctrl.srcField] = ctrl.srcId; + ctrl.navs.push(item); + }); $rootScope.isBusy = false; $scope.$apply(); } else { - let result = await associationService.deleteAssociation( - ctrl.parentDatabaseName, - ctrl.mixDatabaseName, - ctrl.parentId, - ctrl.guidParentId, - item.id - ); - $rootScope.handleResponse(result); + $rootScope.showErrors(response.errors); $rootScope.isBusy = false; $scope.$apply(); } - if (ctrl.selectCallback) { - ctrl.selectCallback(); - } - }; - - ctrl.filter = function () { - ctrl.data = []; - ctrl.loadData(); }; - ctrl.loadData = async function () { - dataService.initDbName(ctrl.mixDatabaseName); - ctrl.request.queries = []; - if (ctrl.queries) { - Object.keys(ctrl.queries).forEach((e) => { - if (ctrl.queries[e]) { - ctrl.request.queries.push({ - fieldName: e, - value: ctrl.queries[e], - compareOperator: 'Like', - }); - } + ctrl.saveSelected = function () { + ctrl.selected = $rootScope.filterArray( + ctrl.navs, + ["isActived"], + [true] + ); + setTimeout(() => { + ctrl.save().then(() => { + ctrl.loadPages(); }); + }, 500); + }; + }, + ], +}); + +modules.component("modalNavPosts", { + templateUrl: + "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", + bindings: { + srcColumn: "=", + srcId: "=", + query: "=", + selected: "=", + save: "&", + }, + controller: [ + "$rootScope", + "$scope", + "$routeParams", + "ngAppSettings", + "PostRestService", + function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.navs = []; + ctrl.associations = []; + ctrl.data = { items: [] }; + ctrl.loadPosts = async function (pageIndex) { + // ctrl.request.query = ctrl.query + ctrl.srcId; + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; + } + if (ctrl.request.fromDate !== null) { + var d = new Date(ctrl.request.fromDate); + ctrl.request.fromDate = d.toISOString(); + } + if (ctrl.request.toDate !== null) { + var d = new Date(ctrl.request.toDate); + ctrl.request.toDate = d.toISOString(); + } + if ($routeParams.type) { + ctrl.request.postType = $routeParams.type; + } else { + ctrl.request.postType = ""; + } + var response = await postService.getList(ctrl.request); + if (response.success) { + ctrl.data = response.data; + // ctrl.navs = []; + // angular.forEach(response.data.items, function (e) { + // var item = { + // priority: e.priority, + // description: e.title, + // postId: e.id, + // image: e.thumbnailUrl, + // specificulture: e.specificulture, + // post: e, + // status: "Published", + // isActived: false, + // }; + // item[ctrl.srcColumn] = ctrl.srcId; + // ctrl.navs.push(item); + // }); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); } - var getData = await dataService.filter(ctrl.request); - ctrl.data = getData.data; - angular.forEach(ctrl.data.items, (e) => { - if (ctrl.selectedIds.includes(e.id)) { - e.isSelected = true; - } - }); - $scope.$apply(); }; - ctrl.update = function (data) { - let url = `/admin/mix-database-data/details?dataContentId=${ - data.id - }&mixDatabaseName=${ctrl.mixDatabaseName}&mixDatabaseTitle=${ - ctrl.mixDatabaseTitle - }&parentId=${ctrl.parentId || ""}&parentName=${ - ctrl.parentName || "" - }&guidParentId=${ctrl.guidParentId || ""}`; - $location.url(url); + ctrl.select = async (associations) => { + ctrl.associations = associations; + }; + ctrl.saveSelected = function () { + ctrl.selected = $rootScope.filterArray( + ctrl.navs, + ["isActived"], + [true] + ); + setTimeout(() => { + ctrl.save().then(() => { + ctrl.loadPosts(); + }); + }, 500); }; }, ], @@ -15033,164 +15191,6 @@ modules.component("modalNavMetas", { ], }); -modules.component("modalNavPages", { - templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", - bindings: { - srcField: "=", - srcId: "=", - query: "=", - selected: "=", - save: "&", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "PageRestService", - function ($rootScope, $scope, ngAppSettings, pageService) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.navs = []; - ctrl.data = { items: [] }; - ctrl.loadData = async function (pageIndex) { - ctrl.request.query = ctrl.query + ctrl.srcId; - if (pageIndex !== undefined) { - ctrl.request.pageIndex = pageIndex; - } - if (ctrl.request.fromDate !== null) { - var d = new Date(ctrl.request.fromDate); - ctrl.request.fromDate = d.toISOString(); - } - if (ctrl.request.toDate !== null) { - var d = new Date(ctrl.request.toDate); - ctrl.request.toDate = d.toISOString(); - } - var response = await pageService.getList(ctrl.request); - if (response.success) { - ctrl.data = response.data; - ctrl.navs = []; - angular.forEach(response.data.items, function (e) { - var item = { - priority: e.priority, - description: e.title, - pageId: e.id, - image: e.thumbnailUrl, - specificulture: e.specificulture, - status: "Published", - isActived: false, - }; - item[ctrl.srcField] = ctrl.srcId; - ctrl.navs.push(item); - }); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - ctrl.saveSelected = function () { - ctrl.selected = $rootScope.filterArray( - ctrl.navs, - ["isActived"], - [true] - ); - setTimeout(() => { - ctrl.save().then(() => { - ctrl.loadPages(); - }); - }, 500); - }; - }, - ], -}); - -modules.component("modalNavPosts", { - templateUrl: - "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", - bindings: { - srcColumn: "=", - srcId: "=", - query: "=", - selected: "=", - save: "&", - }, - controller: [ - "$rootScope", - "$scope", - "$routeParams", - "ngAppSettings", - "PostRestService", - function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.navs = []; - ctrl.associations = []; - ctrl.data = { items: [] }; - ctrl.loadPosts = async function (pageIndex) { - // ctrl.request.query = ctrl.query + ctrl.srcId; - if (pageIndex !== undefined) { - ctrl.request.pageIndex = pageIndex; - } - if (ctrl.request.fromDate !== null) { - var d = new Date(ctrl.request.fromDate); - ctrl.request.fromDate = d.toISOString(); - } - if (ctrl.request.toDate !== null) { - var d = new Date(ctrl.request.toDate); - ctrl.request.toDate = d.toISOString(); - } - if ($routeParams.type) { - ctrl.request.postType = $routeParams.type; - } else { - ctrl.request.postType = ""; - } - var response = await postService.getList(ctrl.request); - if (response.success) { - ctrl.data = response.data; - // ctrl.navs = []; - // angular.forEach(response.data.items, function (e) { - // var item = { - // priority: e.priority, - // description: e.title, - // postId: e.id, - // image: e.thumbnailUrl, - // specificulture: e.specificulture, - // post: e, - // status: "Published", - // isActived: false, - // }; - // item[ctrl.srcColumn] = ctrl.srcId; - // ctrl.navs.push(item); - // }); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - ctrl.select = async (associations) => { - ctrl.associations = associations; - }; - ctrl.saveSelected = function () { - ctrl.selected = $rootScope.filterArray( - ctrl.navs, - ["isActived"], - [true] - ); - setTimeout(() => { - ctrl.save().then(() => { - ctrl.loadPosts(); - }); - }, 500); - }; - }, - ], -}); - modules.component("modalNavs", { templateUrl: "/mix-app/views/app-portal/components/modal-navs/view.html", bindings: { @@ -15315,65 +15315,23 @@ modules.component("modalNavs", { ["isActived"], [true] ); - if (ctrl.save) { - ctrl.save({ selected: ctrl.selected }); - } - }; - }, - ], -}); - -modules.component("modalPermission", { - templateUrl: - "/mix-app/views/app-portal/components/modal-permission/modal-permission.html", - controller: "PermissionController", - bindings: { - message: "=", - }, -}); - -modules.component("modalTemplate", { - templateUrl: "/mix-app/views/app-portal/components/modal-template/view.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "TemplateService", - function ($rootScope, $scope, ngAppSettings, service) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = function () { - ctrl.modal = $("#modal-template"); - ctrl.request.status = null; - ctrl.request.pageSize = 10; - ctrl.modal.on("shown.bs.modal", function () { - ctrl.search(); - }); - }; - ctrl.search = async function (pageIndex) { - if (ctrl.request.keyword.indexOf("/") > 0) { - let params = ctrl.request.keyword.split("/"); - ctrl.request.folderType = params[0]; - ctrl.request.keyword = params[1]; - } - ctrl.request.pageIndex = pageIndex || ctrl.request.pageIndex; - $rootScope.isBusy = true; - var resp = await service.getList(ctrl.request); - if (resp && resp.success) { - ctrl.data = resp.data; - } - $rootScope.isBusy = false; - $scope.$apply(); - }; - ctrl.edit = function (item) { - let path = `/admin/template/details/${item.folderType}/${item.id}`; - ctrl.modal.modal("hide"); - $rootScope.goToPath(path); + if (ctrl.save) { + ctrl.save({ selected: ctrl.selected }); + } }; }, ], }); +modules.component("modalPermission", { + templateUrl: + "/mix-app/views/app-portal/components/modal-permission/modal-permission.html", + controller: "PermissionController", + bindings: { + message: "=", + }, +}); + modules.component("monacoEditor", { templateUrl: "/mix-app/views/app-portal/components/monaco-editor/view.html", bindings: { @@ -15572,6 +15530,88 @@ modules.component("monacoEditor", { ], }); +modules.component("portalThemeSettings", { + templateUrl: + "/mix-app/views/app-portal/components/portal-theme-settings/view.html", + bindings: { + showLink: "=", + }, + controller: [ + "$rootScope", + "$scope", + "AppSettingsServices", + function ($rootScope, $scope, appSettingsServices) { + var ctrl = this; + this.$onInit = function () { + ctrl.portalThemeSettings = + $rootScope.globalSettings.portalThemeSettings; + }; + ctrl.applyThemeSettings = function () { + $rootScope.globalSettings.portalThemeSettings = + ctrl.portalThemeSettings; + }; + ctrl.saveThemeSettings = async function () { + var resp = await appSettingsServices.saveAppSettings( + "PortalThemeSettings", + ctrl.portalThemeSettings + ); + if (resp && resp.success) { + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $scope.$apply(); + } + }; + }, + ], +}); + +modules.component("modalTemplate", { + templateUrl: "/mix-app/views/app-portal/components/modal-template/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "TemplateService", + function ($rootScope, $scope, ngAppSettings, service) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = function () { + ctrl.modal = $("#modal-template"); + ctrl.request.status = null; + ctrl.request.pageSize = 10; + ctrl.modal.on("shown.bs.modal", function () { + ctrl.search(); + }); + }; + ctrl.search = async function (pageIndex) { + if (ctrl.request.keyword.indexOf("/") > 0) { + let params = ctrl.request.keyword.split("/"); + ctrl.request.folderType = params[0]; + ctrl.request.keyword = params[1]; + } + ctrl.request.pageIndex = pageIndex || ctrl.request.pageIndex; + $rootScope.isBusy = true; + var resp = await service.getList(ctrl.request); + if (resp && resp.success) { + ctrl.data = resp.data; + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + ctrl.edit = function (item) { + let path = `/admin/template/details/${item.folderType}/${item.id}`; + ctrl.modal.modal("hide"); + $rootScope.goToPath(path); + }; + }, + ], +}); + modules.component("navigators", { templateUrl: "/mix-app/views/app-portal/components/navigations/navigations.html", @@ -15709,46 +15749,6 @@ modules.component("navigators", { ], }); -modules.component("portalThemeSettings", { - templateUrl: - "/mix-app/views/app-portal/components/portal-theme-settings/view.html", - bindings: { - showLink: "=", - }, - controller: [ - "$rootScope", - "$scope", - "AppSettingsServices", - function ($rootScope, $scope, appSettingsServices) { - var ctrl = this; - this.$onInit = function () { - ctrl.portalThemeSettings = - $rootScope.globalSettings.portalThemeSettings; - }; - ctrl.applyThemeSettings = function () { - $rootScope.globalSettings.portalThemeSettings = - ctrl.portalThemeSettings; - }; - ctrl.saveThemeSettings = async function () { - var resp = await appSettingsServices.saveAppSettings( - "PortalThemeSettings", - ctrl.portalThemeSettings - ); - if (resp && resp.success) { - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $scope.$apply(); - } - }; - }, - ], -}); - modules.component("propertiesStructure", { templateUrl: "/mix-app/views/app-portal/components/properties-structure/view.html", @@ -16283,67 +16283,6 @@ modules.component("toastHelper", { ], }); -modules.component("urlAlias", { - templateUrl: "/mix-app/views/app-portal/components/url-alias/url-alias.html", - controller: [ - "$rootScope", - "$scope", - "UrlAliasService", - function ($rootScope, $scope, service) { - var ctrl = this; - ctrl.$onInit = function () { - ctrl.updateUrl(); - }; - ctrl.updateUrl = function () { - ctrl.url = - $rootScope.globalSettings.domain + - "/" + - $rootScope.mixConfigurations.lang + - "/" + - ctrl.urlAlias.alias; - }; - ctrl.remove = function () { - if (ctrl.urlAlias.id > 0) { - $rootScope.showConfirm( - ctrl, - "removeConfirmed", - [ctrl.urlAlias.id], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - } else { - if (ctrl.removeCallback) { - ctrl.removeCallback({ index: ctrl.index }); - } - } - }; - - ctrl.removeConfirmed = async function (id) { - $rootScope.isBusy = true; - var result = await service.delete(id); - if (result.success) { - if (ctrl.removeCallback) { - ctrl.removeCallback({ index: ctrl.index }); - } - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, - ], - bindings: { - urlAlias: "=", - index: "=", - callback: "&", - removeCallback: "&", - }, -}); - app.factory("ConnectionManager", [ function () { var serviceFactory = {}; @@ -17196,6 +17135,67 @@ app.factory("ViewModel", [ }, ]); +modules.component("urlAlias", { + templateUrl: "/mix-app/views/app-portal/components/url-alias/url-alias.html", + controller: [ + "$rootScope", + "$scope", + "UrlAliasService", + function ($rootScope, $scope, service) { + var ctrl = this; + ctrl.$onInit = function () { + ctrl.updateUrl(); + }; + ctrl.updateUrl = function () { + ctrl.url = + $rootScope.globalSettings.domain + + "/" + + $rootScope.mixConfigurations.lang + + "/" + + ctrl.urlAlias.alias; + }; + ctrl.remove = function () { + if (ctrl.urlAlias.id > 0) { + $rootScope.showConfirm( + ctrl, + "removeConfirmed", + [ctrl.urlAlias.id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + } else { + if (ctrl.removeCallback) { + ctrl.removeCallback({ index: ctrl.index }); + } + } + }; + + ctrl.removeConfirmed = async function (id) { + $rootScope.isBusy = true; + var result = await service.delete(id); + if (result.success) { + if (ctrl.removeCallback) { + ctrl.removeCallback({ index: ctrl.index }); + } + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], + bindings: { + urlAlias: "=", + index: "=", + callback: "&", + removeCallback: "&", + }, +}); + !(function (t) { var e = {}; function i(n) { diff --git a/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js b/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js index 86f2995c4..9daf20096 100644 --- a/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js +++ b/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js @@ -2671,11 +2671,17 @@ appShared.factory("StoreService", [ "BaseRestService", function (baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("", null, "en-us", "https://market.mixcore.net", "v2"); + serviceFactory.init( + "", + null, + "en-us", + "https://dev-mixcore.azurewebsites.net", + "v2" + ); // Define more service methods here var _getThemes = async function (objData) { var data = serviceFactory.parseQuery(objData); - var url = "/rest/post-content/filter"; + var url = "/rest/mixcore/post-content/filter"; var req = { serviceBase: this.serviceBase, apiVersion: this.apiVersion, @@ -2962,157 +2968,6 @@ appShared.factory("TranslatorService", [ }, ]); -"use strict"; -appShared.factory("MixDbService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = angular.copy(baseService); - serviceFactory.init("mix-db"); - var _initDbName = function (name) { - serviceFactory.init(`mix-db/${name}`); - }; - var _filter = async function (request) { - var url = `${this.prefixUrl}/filter`; - var req = { - serviceBase: this.serviceBase, - method: "POST", - url: url, - data: request, - }; - return await this.getRestApiResult(req); - }; - var _export = async function (request) { - var url = `${this.prefixUrl}/export`; - var req = { - serviceBase: this.serviceBase, - method: "POST", - url: url, - data: request, - }; - return await this.getRestApiResult(req); - }; - var _import = async function (file) { - var url = `${this.prefixUrl}/import`; - var frm = new FormData(); - frm.append("file", file); - return await this.ajaxSubmitForm(frm, url); - }; - var _getSingleByParent = async function (parentType, parentId) { - var url = `${this.prefixUrl}/get-by-parent/${parentType}/${parentId}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - serviceFactory.initDbName = _initDbName; - serviceFactory.filter = _filter; - serviceFactory.export = _export; - serviceFactory.import = _import; - serviceFactory.getSingleByParent = _getSingleByParent; - return serviceFactory; - }, -]); - -"use strict"; -appShared.factory("RestMixDatabasePortalService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-database"); - var _migrate = async function (data) { - var url = `${this.prefixUrl}/migrate/${data.systemName}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - var _backup = async function (data) { - var url = `${this.prefixUrl}/backup/${data.systemName}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - var _restore = async function (data) { - var url = `${this.prefixUrl}/restore/${data.systemName}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - var _updateSchema = async function (data) { - var url = `${this.prefixUrl}/update/${data.systemName}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - var _getByName = async function (name) { - var url = `${this.prefixUrl}/get-by-name/${name}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - serviceFactory.migrate = _migrate; - serviceFactory.backup = _backup; - serviceFactory.restore = _restore; - serviceFactory.updateSchema = _updateSchema; - serviceFactory.getByName = _getByName; - return serviceFactory; - }, -]); - -"use strict"; -appShared.factory("RestMixAssociationPortalService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-db-association"); - - serviceFactory.getAssociation = async ( - parentDbName, - childDbName, - parentId, - childId - ) => { - var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${ - parentId || guidParentId - }/${childId}`; - var req = { - serviceBase: serviceFactory.serviceBase, - apiVersion: serviceFactory.apiVersion, - method: "GET", - url: url, - }; - return await serviceFactory.getRestApiResult(req); - }; - serviceFactory.deleteAssociation = async ( - parentDbName, - childDbName, - parentId, - guidParentId, - childId - ) => { - var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${parentId}/${childId}`; - var req = { - serviceBase: serviceFactory.serviceBase, - apiVersion: serviceFactory.apiVersion, - method: "DELETE", - url: url, - }; - return await serviceFactory.getRestApiResult(req); - }; - return serviceFactory; - }, -]); - "use strict"; appShared.factory("RestMixDatabaseColumnPortalService", [ "BaseRestService", @@ -3134,26 +2989,6 @@ appShared.factory("RestMixDatabaseColumnPortalService", [ }, ]); -"use strict"; -appShared.factory("RestMixDatabaseDataValuePortalService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-database-data-value"); - return serviceFactory; - }, -]); - -"use strict"; -appShared.factory("RestMixRelationshipPortalService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-database-relationship"); - return serviceFactory; - }, -]); - "use strict"; appShared.factory("RestMixDatabaseDataClientService", [ "BaseRestService", @@ -3286,6 +3121,167 @@ appShared.factory("RestMixDatabaseDataPortalService", [ }, ]); +"use strict"; +appShared.factory("RestMixAssociationPortalService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-db-association"); + + serviceFactory.getAssociation = async ( + parentDbName, + childDbName, + parentId, + childId + ) => { + var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${ + parentId || guidParentId + }/${childId}`; + var req = { + serviceBase: serviceFactory.serviceBase, + apiVersion: serviceFactory.apiVersion, + method: "GET", + url: url, + }; + return await serviceFactory.getRestApiResult(req); + }; + serviceFactory.deleteAssociation = async ( + parentDbName, + childDbName, + parentId, + guidParentId, + childId + ) => { + var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${parentId}/${childId}`; + var req = { + serviceBase: serviceFactory.serviceBase, + apiVersion: serviceFactory.apiVersion, + method: "DELETE", + url: url, + }; + return await serviceFactory.getRestApiResult(req); + }; + return serviceFactory; + }, +]); + +"use strict"; +appShared.factory("MixDbService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = angular.copy(baseService); + serviceFactory.init("mix-db"); + var _initDbName = function (name) { + serviceFactory.init(`mix-db/${name}`); + }; + var _filter = async function (request) { + var url = `${this.prefixUrl}/filter`; + var req = { + serviceBase: this.serviceBase, + method: "POST", + url: url, + data: request, + }; + return await this.getRestApiResult(req); + }; + var _export = async function (request) { + var url = `${this.prefixUrl}/export`; + var req = { + serviceBase: this.serviceBase, + method: "POST", + url: url, + data: request, + }; + return await this.getRestApiResult(req); + }; + var _import = async function (file) { + var url = `${this.prefixUrl}/import`; + var frm = new FormData(); + frm.append("file", file); + return await this.ajaxSubmitForm(frm, url); + }; + var _getSingleByParent = async function (parentType, parentId) { + var url = `${this.prefixUrl}/get-by-parent/${parentType}/${parentId}`; + var req = { + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + serviceFactory.initDbName = _initDbName; + serviceFactory.filter = _filter; + serviceFactory.export = _export; + serviceFactory.import = _import; + serviceFactory.getSingleByParent = _getSingleByParent; + return serviceFactory; + }, +]); + +"use strict"; +appShared.factory("RestMixDatabasePortalService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-database"); + var _migrate = async function (data) { + var url = `${this.prefixUrl}/migrate/${data.systemName}`; + var req = { + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + var _backup = async function (data) { + var url = `${this.prefixUrl}/backup/${data.systemName}`; + var req = { + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + var _restore = async function (data) { + var url = `${this.prefixUrl}/restore/${data.systemName}`; + var req = { + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + var _updateSchema = async function (data) { + var url = `${this.prefixUrl}/update/${data.systemName}`; + var req = { + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + var _getByName = async function (name) { + var url = `${this.prefixUrl}/get-by-name/${name}`; + var req = { + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + serviceFactory.migrate = _migrate; + serviceFactory.backup = _backup; + serviceFactory.restore = _restore; + serviceFactory.updateSchema = _updateSchema; + serviceFactory.getByName = _getByName; + return serviceFactory; + }, +]); + +"use strict"; +appShared.factory("RestMixDatabaseDataValuePortalService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-database-data-value"); + return serviceFactory; + }, +]); + "use strict"; appShared.factory("RestMvcModuleDataService", [ "BaseRestService", @@ -3306,23 +3302,11 @@ appShared.factory("RestMvcModuleDataService", [ ]); "use strict"; -appShared.factory("RestRelatedAttributeDataFormService", [ +appShared.factory("RestMixRelationshipPortalService", [ "BaseRestService", function (baseService) { - var serviceFactory = angular.copy(baseService); - serviceFactory.init("mix-data-content-association/form"); - return serviceFactory; - }, -]); - -"use strict"; -appShared.factory("RestRelatedAttributeDataPortalService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = angular.copy(baseService); - serviceFactory.init("mix-data-content-association"); + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-database-relationship"); return serviceFactory; }, ]); @@ -3349,6 +3333,28 @@ appShared.factory("RestPostService", [ }, ]); +"use strict"; +appShared.factory("RestRelatedAttributeDataFormService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = angular.copy(baseService); + serviceFactory.init("mix-data-content-association/form"); + return serviceFactory; + }, +]); + +"use strict"; +appShared.factory("RestRelatedAttributeDataPortalService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = angular.copy(baseService); + serviceFactory.init("mix-data-content-association"); + return serviceFactory; + }, +]); + "use strict"; function BaseCtrl($scope, $rootScope, $routeParams, ngAppSettings, service) { @@ -4710,167 +4716,6 @@ appShared.controller("MvcPostController", [ }, ]); -sharedComponents.component("addressEditor", { - templateUrl: "/mix-app/views/app-shared/components/address-editor/view.html", - bindings: { - province: "=", - provinceClass: "=?", - district: "=", - districtClass: "=?", - ward: "=", - wardClass: "=?", - }, - controller: "AddressEditorController", -}); - -sharedComponents.controller("AddressEditorController", [ - "$rootScope", - "$scope", - "ApiService", - function PortalTemplateController($rootScope, $scope, apiService) { - var ctrl = this; - ctrl.provinceEndpoint = "/rest/shared/json-data/provinces.json/true"; - ctrl.districtEndpoint = "/rest/shared/json-data/districts.json/true"; - ctrl.wardEndpoint = "/rest/shared/json-data/wards.json/true"; - ctrl.$onInit = async function () { - ctrl.provinceClass = - ctrl.provinceClass || "form-select form-control mb-3"; - ctrl.districtClass = - ctrl.districtClass || "form-select form-control mb-3"; - ctrl.wardClass = ctrl.wardClass || "form-select form-control mb-3"; - - ctrl.provinceOptions = await apiService.getApiResult({ - url: ctrl.provinceEndpoint, - }); - $scope.$apply(); - $rootScope.$watch( - () => { - return ctrl.province; - }, - async function (newVal, oldVal) { - if (newVal != oldVal || !ctrl.district) { - if (!ctrl.allDistrictOptions) { - ctrl.allDistrictOptions = await apiService.getApiResult({ - url: ctrl.districtEndpoint, - }); - ctrl.districtOptions = ctrl.allDistrictOptions.filter( - (m) => m["province"] == ctrl.province - ); - $scope.$apply(); - } else { - ctrl.districtOptions = ctrl.allDistrictOptions.filter( - (m) => m["province"] == ctrl.province - ); - } - } - } - ); - $rootScope.$watch( - () => { - return ctrl.district; - }, - async function (newVal, oldVal) { - if (newVal != oldVal) { - if (!ctrl.allWardOptions) { - ctrl.allWardOptions = await apiService.getApiResult({ - url: ctrl.wardEndpoint, - }); - ctrl.wardOptions = ctrl.allWardOptions.filter( - (m) => m["district"] == ctrl.district - ); - $scope.$apply(); - } else { - ctrl.wardOptions = ctrl.allWardOptions.filter( - (m) => m["district"] == ctrl.district - ); - } - } - } - ); - }; - }, -]); - -sharedComponents.component("apiFile", { - templateUrl: "/mix-app/views/app-shared/components/api-file/api-file.html", - controller: [ - "$rootScope", - "$scope", - "Upload", - function PortalTemplateController($rootScope, $scope, uploader) { - var ctrl = this; - ctrl.accept = ctrl.accept || "application/zip"; - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - const file = files[0]; - ctrl.postedFile = file; - } - }; - - ctrl.uploadFile = function (file) { - // Create FormData object - var files = new FormData(); - var folder = ctrl.folder; - var title = ctrl.title; - var description = ctrl.description; - // Looping over all files and add it to FormData object - files.append(file.name, file); - - // Adding one more key to FormData object - files.append("fileFolder", folder); - files.append("title", title); - files.append("description", description); - $.ajax({ - url: "/" + $rootScope.mixConfigurations.lang + "/media/upload", //'/tts/UploadImage', - type: "POST", - contentType: false, // Not to set any content header - processData: false, // Not to process data - data: files, - success: function (result) { - ctrl.src = result.data.fullPath; - $scope.$apply(); - }, - error: function (err) { - return ""; - }, - }); - }; - ctrl.getBase64 = function (file) { - if (file !== null) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = function () { - var index = reader.result.indexOf(",") + 1; - var base64 = reader.result.substring(index); - ctrl.postedFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.postedFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - ctrl.postedFile.fileStream = reader.result; - $rootScope.isBusy = false; - $scope.$apply(); - }; - reader.onerror = function (error) {}; - } else { - return null; - } - }; - }, - ], - bindings: { - header: "=", - accept: "=", - title: "=", - postedFile: "=", - formName: "=", - isBase64: "=", - }, -}); - sharedComponents.component("azureStorage", { templateUrl: "/mix-app/views/app-shared/components/azure-storage/view.html", bindings: { @@ -4951,33 +4796,114 @@ sharedComponents.component("azureStorage", { ); promises.push(blockBlobClient.uploadBrowserData(file)); } - await Promise.all(promises); - reportStatus("Done."); - listFiles(); - } catch (error) { - reportStatus(error.message); + await Promise.all(promises); + reportStatus("Done."); + listFiles(); + } catch (error) { + reportStatus(error.message); + } + }; + + ctrl.deleteFiles = async () => { + try { + if (fileList.selectedOptions.length > 0) { + reportStatus("Deleting files..."); + for (const option of fileList.selectedOptions) { + await containerClient.deleteBlob(option.text); + } + reportStatus("Done."); + listFiles(); + } else { + reportStatus("No files selected."); + } + } catch (error) { + reportStatus(error.message); + } + }; + }, + ], +}); + +sharedComponents.component("addressEditor", { + templateUrl: "/mix-app/views/app-shared/components/address-editor/view.html", + bindings: { + province: "=", + provinceClass: "=?", + district: "=", + districtClass: "=?", + ward: "=", + wardClass: "=?", + }, + controller: "AddressEditorController", +}); + +sharedComponents.controller("AddressEditorController", [ + "$rootScope", + "$scope", + "ApiService", + function PortalTemplateController($rootScope, $scope, apiService) { + var ctrl = this; + ctrl.provinceEndpoint = "/rest/shared/json-data/provinces.json/true"; + ctrl.districtEndpoint = "/rest/shared/json-data/districts.json/true"; + ctrl.wardEndpoint = "/rest/shared/json-data/wards.json/true"; + ctrl.$onInit = async function () { + ctrl.provinceClass = + ctrl.provinceClass || "form-select form-control mb-3"; + ctrl.districtClass = + ctrl.districtClass || "form-select form-control mb-3"; + ctrl.wardClass = ctrl.wardClass || "form-select form-control mb-3"; + + ctrl.provinceOptions = await apiService.getApiResult({ + url: ctrl.provinceEndpoint, + }); + $scope.$apply(); + $rootScope.$watch( + () => { + return ctrl.province; + }, + async function (newVal, oldVal) { + if (newVal != oldVal || !ctrl.district) { + if (!ctrl.allDistrictOptions) { + ctrl.allDistrictOptions = await apiService.getApiResult({ + url: ctrl.districtEndpoint, + }); + ctrl.districtOptions = ctrl.allDistrictOptions.filter( + (m) => m["province"] == ctrl.province + ); + $scope.$apply(); + } else { + ctrl.districtOptions = ctrl.allDistrictOptions.filter( + (m) => m["province"] == ctrl.province + ); + } + } } - }; - - ctrl.deleteFiles = async () => { - try { - if (fileList.selectedOptions.length > 0) { - reportStatus("Deleting files..."); - for (const option of fileList.selectedOptions) { - await containerClient.deleteBlob(option.text); + ); + $rootScope.$watch( + () => { + return ctrl.district; + }, + async function (newVal, oldVal) { + if (newVal != oldVal) { + if (!ctrl.allWardOptions) { + ctrl.allWardOptions = await apiService.getApiResult({ + url: ctrl.wardEndpoint, + }); + ctrl.wardOptions = ctrl.allWardOptions.filter( + (m) => m["district"] == ctrl.district + ); + $scope.$apply(); + } else { + ctrl.wardOptions = ctrl.allWardOptions.filter( + (m) => m["district"] == ctrl.district + ); } - reportStatus("Done."); - listFiles(); - } else { - reportStatus("No files selected."); } - } catch (error) { - reportStatus(error.message); } - }; - }, - ], -}); + ); + }; + }, +]); sharedComponents.component("barCode", { templateUrl: "/mix-app/views/app-shared/components/bar-code/view.html", @@ -5055,6 +4981,86 @@ sharedComponents.component("barCode", { ], }); +sharedComponents.component("apiFile", { + templateUrl: "/mix-app/views/app-shared/components/api-file/api-file.html", + controller: [ + "$rootScope", + "$scope", + "Upload", + function PortalTemplateController($rootScope, $scope, uploader) { + var ctrl = this; + ctrl.accept = ctrl.accept || "application/zip"; + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + const file = files[0]; + ctrl.postedFile = file; + } + }; + + ctrl.uploadFile = function (file) { + // Create FormData object + var files = new FormData(); + var folder = ctrl.folder; + var title = ctrl.title; + var description = ctrl.description; + // Looping over all files and add it to FormData object + files.append(file.name, file); + + // Adding one more key to FormData object + files.append("fileFolder", folder); + files.append("title", title); + files.append("description", description); + $.ajax({ + url: "/" + $rootScope.mixConfigurations.lang + "/media/upload", //'/tts/UploadImage', + type: "POST", + contentType: false, // Not to set any content header + processData: false, // Not to process data + data: files, + success: function (result) { + ctrl.src = result.data.fullPath; + $scope.$apply(); + }, + error: function (err) { + return ""; + }, + }); + }; + ctrl.getBase64 = function (file) { + if (file !== null) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function () { + var index = reader.result.indexOf(",") + 1; + var base64 = reader.result.substring(index); + ctrl.postedFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.postedFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.postedFile.fileStream = reader.result; + $rootScope.isBusy = false; + $scope.$apply(); + }; + reader.onerror = function (error) {}; + } else { + return null; + } + }; + }, + ], + bindings: { + header: "=", + accept: "=", + title: "=", + postedFile: "=", + formName: "=", + isBase64: "=", + }, +}); + sharedComponents.component("breadcrumbs", { templateUrl: "/mix-app/views/app-shared/components/breadcrumbs/breadcrumbs.html", @@ -5669,6 +5675,55 @@ sharedComponents.component("googlePay", { }); })(window.angular); +appShared.component("loginPopup", { + templateUrl: "/mix-app/views/app-shared/components/login-popup/view.html", + controller: "LoginPopupController", +}); + +appShared.controller("LoginPopupController", [ + "$scope", + "$rootScope", + "AuthService", + "ApiService", + "CommonService", + function LoginPopupController( + $scope, + $rootScope, + authService, + commonService + ) { + $scope.loginData = { + username: "", + password: "", + rememberMe: false, + }; + $scope.login = async function () { + var result = await authService.loginPopup($scope.loginData); + if (result && result.success) { + $rootScope.isBusy = false; + $scope.message = result.errors[0]; + $("#login-popup").modal("hide"); + $scope.$apply(); + + if ($rootScope.loginCallbackRequest) { + if ($rootScope.loginCallbackType == "rest") { + apiService.sendRequest($rootScope.loginCallbackRequest); + } else { + apiService.getRestResult($rootScope.loginCallbackRequest); + } + $rootScope.loginCallbackRequest = null; + $rootScope.loginCallbackType = null; + } + } else { + $rootScope.goToSiteUrl("/security/login"); + } + }; + $scope.closeDialog = function () { + $("#login-popup").modal("hide"); + }; + }, +]); + sharedComponents.component("limitString", { templateUrl: "/mix-app/views/app-shared/components/limit-string/limit-string.html", @@ -5824,61 +5879,19 @@ appShared.component("mediaNavs", { prefix: "=", sourceFieldName: "=", isSingle: "=", - output: "=", - loadMedia: "&", - onDelete: "&", - onUpdate: "&", - }, -}); - -appShared.component("loginPopup", { - templateUrl: "/mix-app/views/app-shared/components/login-popup/view.html", - controller: "LoginPopupController", -}); - -appShared.controller("LoginPopupController", [ - "$scope", - "$rootScope", - "AuthService", - "ApiService", - "CommonService", - function LoginPopupController( - $scope, - $rootScope, - authService, - commonService - ) { - $scope.loginData = { - username: "", - password: "", - rememberMe: false, - }; - $scope.login = async function () { - var result = await authService.loginPopup($scope.loginData); - if (result && result.success) { - $rootScope.isBusy = false; - $scope.message = result.errors[0]; - $("#login-popup").modal("hide"); - $scope.$apply(); - - if ($rootScope.loginCallbackRequest) { - if ($rootScope.loginCallbackType == "rest") { - apiService.sendRequest($rootScope.loginCallbackRequest); - } else { - apiService.getRestResult($rootScope.loginCallbackRequest); - } - $rootScope.loginCallbackRequest = null; - $rootScope.loginCallbackType = null; - } - } else { - $rootScope.goToSiteUrl("/security/login"); - } - }; - $scope.closeDialog = function () { - $("#login-popup").modal("hide"); - }; + output: "=", + loadMedia: "&", + onDelete: "&", + onUpdate: "&", }, -]); +}); + +sharedComponents.component("message", { + templateUrl: "/mix-app/views/app-shared/components/message/message.html", + bindings: { + message: "=", + }, +}); "use strict"; appShared.controller("MediaController", [ @@ -6181,10 +6194,13 @@ sharedComponents.component("medias", { bindings: {}, }); -sharedComponents.component("message", { - templateUrl: "/mix-app/views/app-shared/components/message/message.html", +sharedComponents.component("messengerPrivate", { + templateUrl: + "/mix-app/views/app-shared/components/messenger-private/index.html", + controller: "MessengerController", bindings: { message: "=", + connectionId: "=", }, }); @@ -6360,16 +6376,6 @@ sharedComponents.component("messenger", { }, }); -sharedComponents.component("messengerPrivate", { - templateUrl: - "/mix-app/views/app-shared/components/messenger-private/index.html", - controller: "MessengerController", - bindings: { - message: "=", - connectionId: "=", - }, -}); - sharedComponents.component("mixColumnEditor", { templateUrl: "/mix-app/views/app-shared/components/mix-column-editor/view.html", @@ -8729,40 +8735,6 @@ sharedComponents.component("previewPopup", { }, }); -sharedComponents.component("qrCode", { - templateUrl: "/mix-app/views/app-shared/components/qr-code/view.html", - controller: [ - "$rootScope", - "$element", - function ($rootScope, $element) { - var ctrl = this; - - ctrl.$onInit = function () { - setTimeout(() => { - if (ctrl.model) { - ctrl.generate(); - } - }, 200); - }; - ctrl.initOutput = function () { - ctrl.element = $element[0].querySelector(".qr-output"); - ctrl.generate(); - }; - ctrl.generate = function () { - $(ctrl.element).empty(); - $(ctrl.element).qrcode(ctrl.model); - }; - ctrl.download = function () { - $rootScope.downloadCanvasImage(ctrl.element.querySelector("canvas")); - }; - }, - ], - bindings: { - model: "=", - viewOnly: "=?", - }, -}); - sharedComponents.component("quillEditor", { templateUrl: "/mix-app/views/app-shared/components/quill-editor/view.html", controller: [ @@ -8861,6 +8833,40 @@ sharedComponents.component("quillEditor", { }, }); +sharedComponents.component("qrCode", { + templateUrl: "/mix-app/views/app-shared/components/qr-code/view.html", + controller: [ + "$rootScope", + "$element", + function ($rootScope, $element) { + var ctrl = this; + + ctrl.$onInit = function () { + setTimeout(() => { + if (ctrl.model) { + ctrl.generate(); + } + }, 200); + }; + ctrl.initOutput = function () { + ctrl.element = $element[0].querySelector(".qr-output"); + ctrl.generate(); + }; + ctrl.generate = function () { + $(ctrl.element).empty(); + $(ctrl.element).qrcode(ctrl.model); + }; + ctrl.download = function () { + $rootScope.downloadCanvasImage(ctrl.element.querySelector("canvas")); + }; + }, + ], + bindings: { + model: "=", + viewOnly: "=?", + }, +}); + sharedComponents.component("recaptcha", { templateUrl: "/mix-app/views/app-shared/components/recaptcha/recaptcha.html", controller: [ @@ -9352,6 +9358,20 @@ sharedComponents.component("snowy", { bindings: {}, }); +sharedComponents.component("statuses", { + templateUrl: "/mix-app/views/app-shared/components/statuses/statuses.html", + controller: [ + "$rootScope", + "ngAppSettings", + function ($rootScope, ngAppSettings) { + this.contentStatuses = ngAppSettings.contentStatuses; + }, + ], + bindings: { + status: "=", + }, +}); + sharedComponents.component("starRating", { templateUrl: "/mix-app/views/app-shared/components/star-rating/star-rating.html", @@ -9396,18 +9416,49 @@ appShared.controller("StarRatingController", [ }, ]); -sharedComponents.component("statuses", { - templateUrl: "/mix-app/views/app-shared/components/statuses/statuses.html", - controller: [ - "$rootScope", - "ngAppSettings", - function ($rootScope, ngAppSettings) { - this.contentStatuses = ngAppSettings.contentStatuses; +"use trick"; +sharedComponents.directive("pane", function () { + return { + require: "^tabs", + restrict: "E", + transclude: true, + scope: { header: "@", id: "@", icon: "@" }, + link: function (scope, element, attrs, tabsController) { + tabsController.addPane(scope); }, - ], - bindings: { - status: "=", - }, + template: + '
' + + "
", + replace: true, + }; +}); + +sharedComponents.directive("tabs", function () { + return { + restrict: "E", + transclude: true, + scope: { + selectCallback: "&", + }, + controller: function ($scope, $element) { + var panes = ($scope.panes = []); + + $scope.select = function (pane) { + angular.forEach(panes, function (pane) { + pane.selected = false; + }); + pane.selected = true; + this.selectCallback({ pane: pane }); + }; + + this.addPane = function (pane) { + if (panes.length === 0) $scope.select(pane); + panes.push(pane); + }; + }, + templateUrl: "/mix-app/views/app-shared/components/tabs/tabs.html", + replace: true, + }; }); sharedComponents.component("mixStore", { @@ -9444,7 +9495,7 @@ sharedComponents.component("mixStore", { }, { title: "Mix Portal App", - value: "mixcorePortalApp", + value: "mixApplicationPackage", }, ]; ctrl.init = async function () { @@ -9595,9 +9646,9 @@ sharedComponents.component("mixStore", { }); "use trick"; -sharedComponents.directive("pane", function () { +sharedComponents.directive("paneH", function () { return { - require: "^tabs", + require: "^tabs-h", restrict: "E", transclude: true, scope: { header: "@", id: "@", icon: "@" }, @@ -9611,7 +9662,7 @@ sharedComponents.directive("pane", function () { }; }); -sharedComponents.directive("tabs", function () { +sharedComponents.directive("tabsH", function () { return { restrict: "E", transclude: true, @@ -9634,18 +9685,32 @@ sharedComponents.directive("tabs", function () { panes.push(pane); }; }, - templateUrl: "/mix-app/views/app-shared/components/tabs/tabs.html", + templateUrl: + "/mix-app/views/app-shared/components/tabs-horizontal/tabs.html", replace: true, }; }); +sharedComponents.component("tags", { + templateUrl: "/mix-app/views/app-shared/components/tags/tags.html", + controller: [ + "$scope", + function ($scope) { + var ctrl = this; + }, + ], + bindings: { + input: "=", + }, +}); + "use trick"; -sharedComponents.directive("paneH", function () { +sharedComponents.directive("paneV", function () { return { - require: "^tabs-h", + require: "^tabs-v", restrict: "E", transclude: true, - scope: { header: "@", id: "@", icon: "@" }, + scope: { header: "@", id: "@", icon: "@", class: "@" }, link: function (scope, element, attrs, tabsController) { tabsController.addPane(scope); }, @@ -9656,7 +9721,7 @@ sharedComponents.directive("paneH", function () { }; }); -sharedComponents.directive("tabsH", function () { +sharedComponents.directive("tabsV", function () { return { restrict: "E", transclude: true, @@ -9679,25 +9744,11 @@ sharedComponents.directive("tabsH", function () { panes.push(pane); }; }, - templateUrl: - "/mix-app/views/app-shared/components/tabs-horizontal/tabs.html", + templateUrl: "/mix-app/views/app-shared/components/tabs-verticle/tabs.html", replace: true, }; }); -sharedComponents.component("tags", { - templateUrl: "/mix-app/views/app-shared/components/tags/tags.html", - controller: [ - "$scope", - function ($scope) { - var ctrl = this; - }, - ], - bindings: { - input: "=", - }, -}); - sharedComponents.component("tagsView", { templateUrl: "/mix-app/views/app-shared/components/tags-view/view.html", controller: [ @@ -9728,51 +9779,6 @@ sharedComponents.component("tagsView", { }, }); -"use trick"; -sharedComponents.directive("paneV", function () { - return { - require: "^tabs-v", - restrict: "E", - transclude: true, - scope: { header: "@", id: "@", icon: "@", class: "@" }, - link: function (scope, element, attrs, tabsController) { - tabsController.addPane(scope); - }, - template: - '
' + - "
", - replace: true, - }; -}); - -sharedComponents.directive("tabsV", function () { - return { - restrict: "E", - transclude: true, - scope: { - selectCallback: "&", - }, - controller: function ($scope, $element) { - var panes = ($scope.panes = []); - - $scope.select = function (pane) { - angular.forEach(panes, function (pane) { - pane.selected = false; - }); - pane.selected = true; - this.selectCallback({ pane: pane }); - }; - - this.addPane = function (pane) { - if (panes.length === 0) $scope.select(pane); - panes.push(pane); - }; - }, - templateUrl: "/mix-app/views/app-shared/components/tabs-verticle/tabs.html", - replace: true, - }; -}); - sharedComponents.component("trumbowyg", { templateUrl: "/mix-app/views/app-shared/components/trumbowyg/trumbowyg.html", bindings: { @@ -10369,7 +10375,7 @@ appShared.controller("VideoCallController", [ $scope.request.uid = $scope.user.info.id; $scope.request.data = $scope.user.info; $scope.message.connection = $scope.user.info; - $scope.connection.invoke("join", $scope.request); + $scope.connection.invoke("join", window.location.host); }; $scope.toggle = function () { $scope.isHide = !$scope.isHide; diff --git a/src/applications/Mixcore/wwwroot/mix-app/views/app-shared/components/mix-column-editor/view.html b/src/applications/Mixcore/wwwroot/mix-app/views/app-shared/components/mix-column-editor/view.html index 953bc2587..30bec9d9f 100644 --- a/src/applications/Mixcore/wwwroot/mix-app/views/app-shared/components/mix-column-editor/view.html +++ b/src/applications/Mixcore/wwwroot/mix-app/views/app-shared/components/mix-column-editor/view.html @@ -1 +1 @@ -
Loading...
{{$ctrl.translate($ctrl.column.systemName)}}: {{$ctrl.translate($ctrl.editor)}}
\ No newline at end of file +
Loading...
{{$ctrl.translate($ctrl.column.systemName)}}: {{$ctrl.translate($ctrl.editor)}}
\ No newline at end of file diff --git a/src/modules/mix.portal/Controllers/MixDbController.cs b/src/modules/mix.portal/Controllers/MixDbController.cs index a5eb67986..b9ac9939a 100644 --- a/src/modules/mix.portal/Controllers/MixDbController.cs +++ b/src/modules/mix.portal/Controllers/MixDbController.cs @@ -233,7 +233,57 @@ public async Task> UpdatePriority(string dbName, int id, [ } [HttpGet("get-by-parent/{parentType}/{parentId}")] - public async Task> GetSingleByParent(MixContentType parentType, string parentId, [FromQuery] bool loadNestedData) + public async Task> GetSingleByParent(MixContentType parentType, int parentId, [FromQuery] bool loadNestedData) + { + dynamic obj = await _repository.GetSingleByParentAsync(parentType, parentId); + if (obj != null) + { + try + { + var data = ReflectionHelper.ParseObject(obj); + foreach (var item in _mixDb.Relationships) + { + if (loadNestedData) + { + + List queries = GetAssociationQueries(item.SourceDatabaseName, item.DestinateDatabaseName, data.id); + var associations = await _associationRepository.GetListByAsync(queries); + if (associations is { Count: > 0 }) + { + var nestedIds = JArray.FromObject(associations).Select(m => m.Value(ChildIdFieldName)).ToList(); + _repository.InitTableName(item.DestinateDatabaseName); + List query = new() { new(IdFieldName, Operation.In, nestedIds) }; + var nestedData = await _repository.GetListByAsync(query); + if (nestedData != null) + { + data.Add(new JProperty(item.DisplayName, JArray.FromObject(nestedData))); + } + } + } + else + { + data.Add(new JProperty( + $"{item.DisplayName}Url", + $"{CurrentTenant.Configurations.Domain}/api/v2/rest/mix-portal/mix-db/{item.DestinateDatabaseName}?ParentId={data.id}&ParentName={item.SourceDatabaseName}")); + } + } + return Ok(data); + } + catch (MixException) + { + throw; + } + catch (Exception ex) + { + throw new MixException(MixErrorStatus.Badrequest, ex); + } + } + return NotFound(); + //throw new MixException(MixErrorStatus.NotFound, id); + } + + [HttpGet("get-by-guid-parent/{parentType}/{parentId}")] + public async Task> GetSingleByGuidParent(MixContentType parentType, Guid parentId, [FromQuery] bool loadNestedData) { dynamic obj = await _repository.GetSingleByParentAsync(parentType, parentId); if (obj != null) diff --git a/src/platform/core/mix-heart b/src/platform/core/mix-heart index 4b9ac633b..cff3fe8ca 160000 --- a/src/platform/core/mix-heart +++ b/src/platform/core/mix-heart @@ -1 +1 @@ -Subproject commit 4b9ac633bf6a986cbe590c49b9de9a4aec04bdbd +Subproject commit cff3fe8ca72f557964e85fc776ee99760ba53386 diff --git a/src/platform/mix.constant/Constants/MixCorsPolicies.cs b/src/platform/mix.constant/Constants/MixCorsPolicies.cs new file mode 100644 index 000000000..995dde60b --- /dev/null +++ b/src/platform/mix.constant/Constants/MixCorsPolicies.cs @@ -0,0 +1,7 @@ +namespace Mix.Constant.Constants +{ + public class MixCorsPolicies + { + public const string PublicApis = "PublicApis"; + } +} \ No newline at end of file diff --git a/src/platform/mix.library/Startup/Cors.cs b/src/platform/mix.library/Startup/Cors.cs index be8dfa03a..7d29ef524 100644 --- a/src/platform/mix.library/Startup/Cors.cs +++ b/src/platform/mix.library/Startup/Cors.cs @@ -8,6 +8,7 @@ public static partial class ServiceCollectionExtensions public static IServiceCollection AddMixCors(this IServiceCollection services) { + var mixEndpointService = services.GetService(); origins = mixEndpointService.Endpoints .Where(e => !string.IsNullOrEmpty(e)) @@ -30,6 +31,14 @@ public static IServiceCollection AddMixCors(this IServiceCollection services) builder.AllowAnyHeader(); builder.AllowAnyMethod(); }); + + options.AddPolicy(name: MixCorsPolicies.PublicApis, + builder => + { + builder.AllowAnyOrigin(); + builder.AllowAnyHeader(); + builder.AllowAnyMethod(); + }); }); return services; } diff --git a/src/platform/mix.repodb/Repositories/MixRepoDbRepository.cs b/src/platform/mix.repodb/Repositories/MixRepoDbRepository.cs index 7d36a5c8e..986d7d848 100644 --- a/src/platform/mix.repodb/Repositories/MixRepoDbRepository.cs +++ b/src/platform/mix.repodb/Repositories/MixRepoDbRepository.cs @@ -169,11 +169,11 @@ private List ParseSearchQuery(IEnumerable searchQu Operation op = ParseMixOperator(item); if (op == Operation.In || op == Operation.NotIn) { - queries.Add(new QueryField(item.FieldName, op, item.Value.ToString()!.Split(','))); + queries.Add(new QueryField(item.FieldName.ToTitleCase(), op, item.Value.ToString()!.Split(','))); } else { - queries.Add(new QueryField(item.FieldName, op, item.Value)); + queries.Add(new QueryField(item.FieldName.ToTitleCase(), op, item.Value)); } } return queries; @@ -227,8 +227,7 @@ private Operation ParseMixOperator(SearchQueryField field) } catch (Exception ex) { - Console.Error.WriteLine(ex.Message); - return default; + throw new MixException(MixErrorStatus.Badrequest, ex); } } @@ -245,7 +244,7 @@ private Operation ParseMixOperator(SearchQueryField field) { Console.Error.WriteLine(ex.Message); RollbackTransaction(); - return default; + throw new MixException(MixErrorStatus.Badrequest, ex); } finally { @@ -262,7 +261,7 @@ private Operation ParseMixOperator(SearchQueryField field) _tableName, new List() { new QueryField("ParentType", parentType.ToString()), - new QueryField("ParentId", parentId.ToString()) + new QueryField("ParentId", parentId) }, commandTimeout: _settings.CommandTimeout, transaction: _dbTransaction, @@ -272,7 +271,7 @@ private Operation ParseMixOperator(SearchQueryField field) { await MixLogService.LogExceptionAsync(ex); RollbackTransaction(); - return default; + throw new MixException(MixErrorStatus.Badrequest, ex); } finally { @@ -296,7 +295,7 @@ private Operation ParseMixOperator(SearchQueryField field) { await MixLogService.LogExceptionAsync(ex); RollbackTransaction(); - return default; + throw new MixException(MixErrorStatus.Badrequest, ex); } finally { @@ -324,7 +323,7 @@ private Operation ParseMixOperator(SearchQueryField field) { await MixLogService.LogExceptionAsync(ex); RollbackTransaction(); - return default; + throw new MixException(MixErrorStatus.Badrequest, ex); } finally { @@ -353,7 +352,7 @@ private Operation ParseMixOperator(SearchQueryField field) { await MixLogService.LogExceptionAsync(ex); RollbackTransaction(); - return default; + throw new MixException(MixErrorStatus.Badrequest, ex); } finally { diff --git a/src/platform/mix.signalr/Models/SignalRMessageModel.cs b/src/platform/mix.signalr/Models/SignalRMessageModel.cs index e5fc765b1..71cfee52a 100644 --- a/src/platform/mix.signalr/Models/SignalRMessageModel.cs +++ b/src/platform/mix.signalr/Models/SignalRMessageModel.cs @@ -2,6 +2,8 @@ using Mix.SignalR.Enums; using Newtonsoft.Json.Linq; using System; +using System.Collections; +using System.Reflection.Metadata; namespace Mix.SignalR.Models { @@ -12,7 +14,15 @@ public SignalRMessageModel() } public SignalRMessageModel(object data) { - Data = ReflectionHelper.ParseObject(data).ToString(Newtonsoft.Json.Formatting.None); + Type valueType = data.GetType(); + if (valueType.IsArray || valueType.IsAssignableTo(typeof(IList))) + { + Data = ReflectionHelper.ParseArray(data).ToString(Newtonsoft.Json.Formatting.None); + } + else + { + Data = ReflectionHelper.ParseObject(data).ToString(Newtonsoft.Json.Formatting.None); + } } public HubUserModel From { get; set; } public string Title { get; set; }