From 403f61b671a28aa0ca3b052f9e04e5c23cfacb49 Mon Sep 17 00:00:00 2001 From: Eric Nguyen Date: Wed, 18 Oct 2023 20:36:33 +0700 Subject: [PATCH] fix bugs --- .../wwwroot/mix-app/js/app-portal.min.js | 3720 +++++++++-------- .../Controllers/MixApplicationController.cs | 14 +- .../Domain/Services/MixApplicationService.cs | 7 +- 3 files changed, 1877 insertions(+), 1864 deletions(-) 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 2c2927847..402910c9c 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 @@ -/* Mon Oct 16 2023 12:19:03 GMT+0700 (Indochina Time) */"use strict"; +/* Wed Oct 18 2023 20:25:46 GMT+0700 (Indochina Time) */"use strict"; var app = angular.module("MixPortal", [ "angularCroppie", "ui.bootstrap", @@ -503,6 +503,8 @@ app.controller("MixApplicationController", [ }; $scope.select = function (theme) { $scope.viewmodel.packageFilePath = theme.additionalData.builtSourceCode; + $scope.viewmodel.displayName = theme.additionalData.title; + $scope.generateBaseHref(true); $scope.current = theme; // TODO: verify user - theme to enable install $scope.current.canInstall = true; @@ -556,6 +558,114 @@ app.factory("MixApplicationRestService", [ }, ]); +"use strict"; +app.controller("ConfigurationController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "ConfigurationService", + "ApiService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + apiService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.init = function () { + $scope.request.category = $routeParams.category || ""; + $scope.getList(); + }; + $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("ConfigurationService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("configuration"); + + 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(); + + // 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); + } + }; + serviceFactory.uploadConfiguration = _uploadConfiguration; + return serviceFactory; + }, +]); + "use strict"; app.controller("AuditLogController", [ "$scope", @@ -692,114 +802,6 @@ app.factory("AuditLogRestService", [ }, ]); -"use strict"; -app.controller("ConfigurationController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "ConfigurationService", - "ApiService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service, - apiService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.init = function () { - $scope.request.category = $routeParams.category || ""; - $scope.getList(); - }; - $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("ConfigurationService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("configuration"); - - 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(); - - // 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); - } - }; - serviceFactory.uploadConfiguration = _uploadConfiguration; - return serviceFactory; - }, -]); - "use strict"; app.controller("CultureController", [ "$scope", @@ -1947,26 +1949,20 @@ app.controller("loginController", [ ]); "use strict"; -app.controller("MixDatabaseController", [ +app.controller("MixDatabaseDataController", [ "$scope", "$rootScope", - "$location", "ngAppSettings", "$routeParams", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "RestMixDatabasePortalService", - "RestMixDatabaseContextService", + "$location", + "MixDbService", function ( $scope, $rootScope, - $location, ngAppSettings, $routeParams, - databaseDataService, - databaseColumnService, - databaseService, - dbContextService + $location, + mixDbService ) { BaseRestCtrl.call( this, @@ -1975,146 +1971,7 @@ app.controller("MixDatabaseController", [ $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("MixDatabaseDataController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "MixDbService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - mixDbService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - mixDbService + mixDbService ); $scope.queries = {}; $scope.data = null; @@ -2443,12 +2300,15 @@ app.controller("MixDatabaseDataController", [ ]); "use strict"; -app.controller("MixDatabaseContextController", [ +app.controller("MixDatabaseController", [ "$scope", "$rootScope", "$location", "ngAppSettings", "$routeParams", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + "RestMixDatabasePortalService", "RestMixDatabaseContextService", function ( $scope, @@ -2456,7 +2316,10 @@ app.controller("MixDatabaseContextController", [ $location, ngAppSettings, $routeParams, - mixdbContextService + databaseDataService, + databaseColumnService, + databaseService, + dbContextService ) { BaseRestCtrl.call( this, @@ -2465,15 +2328,15 @@ app.controller("MixDatabaseContextController", [ $location, $routeParams, ngAppSettings, - mixdbContextService + databaseService ); $scope.defaultAttr = null; - $scope.databaseProvider = ["MySQL", "PostgreSQL", "SQLITE", "SQLSERVER"]; $scope.actions = ["Delete"]; + $scope.viewmodelType = "mix-database"; // $scope.request.selects = 'id,title,name,createdDateTime'; $scope.orders = [ { title: "Id", value: "Id" }, - { title: "Name", value: "DisplayName" }, + { title: "Name", value: "Name" }, { title: "Created Date", value: "CreatedDateTime" }, ]; $scope.request.orderBy = "CreatedDateTime"; @@ -2482,43 +2345,182 @@ app.controller("MixDatabaseContextController", [ $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"); + $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(); + } + } + }; - var _getByName = async function (name) { - var url = `${this.prefixUrl}/get-by-name/${name}`; - var req = { - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); + $scope.back = function () { + window.history.back(); }; - serviceFactory.getByName = _getByName; - return serviceFactory; }, ]); "use strict"; -app.controller("ModuleController", [ +app.controller("MixDatabaseContextController", [ "$scope", "$rootScope", - "ngAppSettings", + "$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("ModuleController", [ + "$scope", + "$rootScope", + "ngAppSettings", "$location", "$routeParams", "ModuleRestService", @@ -3924,6 +3926,181 @@ app.factory("PageGalleryService", [ }, ]); +"use strict"; +app.controller("PagePostController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "PagePostRestService", + "PostRestService", + "ApiService", + "CommonService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + postService, + commonService + ) { + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + $scope.request.culture = $rootScope.globalSettings.defaultCulture; + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.mixConfigurations = $rootScope.globalSettings; + $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.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; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $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.remove = function (pageId, postId) { + $rootScope.showConfirm( + $scope, + "removeConfirmed", + [pageId, postId], + 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; + 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.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(); + } + }; + $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("PagePostRestService", [ + "$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; + var req = { + method: "GET", + url: url, + }; + return await apiService.getApiResult(req); + }; + var _updateInfos = async function (pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), + }; + return await apiService.getApiResult(req); + }; + serviceFactory.delete = _delete; + serviceFactory.updateInfos = _updateInfos; + return serviceFactory; + }, +]); + "use strict"; app.controller("PermissionController", [ "$scope", @@ -4566,182 +4743,7 @@ app.factory("PostRestService", [ ]); "use strict"; -app.controller("PagePostController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "PagePostRestService", - "PostRestService", - "ApiService", - "CommonService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service, - postService, - commonService - ) { - BaseCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - $scope.request.culture = $rootScope.globalSettings.defaultCulture; - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.mixConfigurations = $rootScope.globalSettings; - $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.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; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $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.remove = function (pageId, postId) { - $rootScope.showConfirm( - $scope, - "removeConfirmed", - [pageId, postId], - 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; - 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.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(); - } - }; - $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("PagePostRestService", [ - "$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; - var req = { - method: "GET", - url: url, - }; - return await apiService.getApiResult(req); - }; - var _updateInfos = async function (pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), - }; - return await apiService.getApiResult(req); - }; - serviceFactory.delete = _delete; - serviceFactory.updateInfos = _updateInfos; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("QueueLogController", [ +app.controller("QueueLogController", [ "$scope", "$rootScope", "ngAppSettings", @@ -4843,6 +4845,98 @@ app.factory("QueueLogRestService", [ }, ]); +"use strict"; +app.controller("RoleController", [ + "$scope", + "$rootScope", + "$location", + "$routeParams", + "ngAppSettings", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + "RoleService", + function ( + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + dataService, + columnService, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.role = { name: "" }; + $scope.initPermissions = async function () { + let backUrl = "/admin/role/list"; + $scope.createUrl = `/admin/mix-database-data/create?mixDatabaseName=sysPermission&dataContentId=default&guidParentId=${$scope.viewmodel.id}&parentType=Role&backUrl=${backUrl}`; + $scope.updateUrl = "/admin/mix-database-data/details"; + }; + + $scope.createRole = async function () { + $rootScope.isBusy = true; + var result = await service.createRole($scope.role.name); + if (result.success) { + $scope.role.name = ""; + $scope.getList(); + } else { + $rootScope.showErrors(result.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.factory("RoleService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.initService("/rest/mix-account", "role", true); + + var _getPermissions = async function () { + var req = { + method: "GET", + url: this.prefixUrl + "/permissions", + }; + return await apiService.sendRequest(req); + }; + + var _updatePermission = async function (permission) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-permission", + data: JSON.stringify(permission), + }; + return await apiService.sendRequest(req); + }; + var _createRole = function (name) { + var req = { + method: "POST", + url: this.prefixUrl + "/create", + data: JSON.stringify(name), + }; + + return apiService.sendRequest(req); + }; + serviceFactory.createRole = _createRole; + serviceFactory.getPermissions = _getPermissions; + serviceFactory.updatePermission = _updatePermission; + return serviceFactory; + }, +]); + "use strict"; app.controller("SchedulerController", [ "$scope", @@ -5211,98 +5305,6 @@ app.factory("SchedulerService", [ }, ]); -"use strict"; -app.controller("RoleController", [ - "$scope", - "$rootScope", - "$location", - "$routeParams", - "ngAppSettings", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "RoleService", - function ( - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - dataService, - columnService, - service - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.role = { name: "" }; - $scope.initPermissions = async function () { - let backUrl = "/admin/role/list"; - $scope.createUrl = `/admin/mix-database-data/create?mixDatabaseName=sysPermission&dataContentId=default&guidParentId=${$scope.viewmodel.id}&parentType=Role&backUrl=${backUrl}`; - $scope.updateUrl = "/admin/mix-database-data/details"; - }; - - $scope.createRole = async function () { - $rootScope.isBusy = true; - var result = await service.createRole($scope.role.name); - if (result.success) { - $scope.role.name = ""; - $scope.getList(); - } else { - $rootScope.showErrors(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.factory("RoleService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.initService("/rest/mix-account", "role", true); - - var _getPermissions = async function () { - var req = { - method: "GET", - url: this.prefixUrl + "/permissions", - }; - return await apiService.sendRequest(req); - }; - - var _updatePermission = async function (permission) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-permission", - data: JSON.stringify(permission), - }; - return await apiService.sendRequest(req); - }; - var _createRole = function (name) { - var req = { - method: "POST", - url: this.prefixUrl + "/create", - data: JSON.stringify(name), - }; - - return apiService.sendRequest(req); - }; - serviceFactory.createRole = _createRole; - serviceFactory.getPermissions = _getPermissions; - serviceFactory.updatePermission = _updatePermission; - return serviceFactory; - }, -]); - "use strict"; app.controller("ServiceController", [ "$scope", @@ -7087,46 +7089,15 @@ app.component("appSettingsDefault", { ctrl.trackedProperties = angular.copy(ctrl.properties); ctrl.appSettings.AppSettings.DefaultPostAttr = JSON.stringify( ctrl.properties - ); - } - }.bind(ctrl); - }, - ], - bindings: { - appSettings: "=", - cultures: "=", - statuses: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("appSettingsGeneral", { - templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/general/view.html", - controller: [ - "$rootScope", - "$scope", - "CryptoService", - "CommonService", - function ($rootScope, $scope, cryptoService, commonService) { - var ctrl = this; - ctrl.$onInit = () => { - var key = cryptoService.parseKeys(ctrl.appSettings.apiEncryptKey); - ctrl.apiKey = key.key; - ctrl.iv = key.iv; - }; - ctrl.stopApplication = async function () { - $rootScope.isBusy = true; - await commonService.stopApplication(); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - }; + ); + } + }.bind(ctrl); }, ], bindings: { appSettings: "=", + cultures: "=", + statuses: "=", onDelete: "&", onUpdate: "&", }, @@ -7169,6 +7140,51 @@ app.component("appSettingsHeart", { ], }); +app.component("appSettingsGeneral", { + templateUrl: + "/mix-app/views/app-portal/pages/app-settings/components/general/view.html", + controller: [ + "$rootScope", + "$scope", + "CryptoService", + "CommonService", + function ($rootScope, $scope, cryptoService, commonService) { + var ctrl = this; + ctrl.$onInit = () => { + var key = cryptoService.parseKeys(ctrl.appSettings.apiEncryptKey); + ctrl.apiKey = key.key; + ctrl.iv = key.iv; + }; + ctrl.stopApplication = async function () { + $rootScope.isBusy = true; + await commonService.stopApplication(); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + }; + }, + ], + bindings: { + appSettings: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + +app.component("appSettingsSmtp", { + templateUrl: + "/mix-app/views/app-portal/pages/app-settings/components/smtp/view.html", + controller: [ + "ngAppSettings", + function (ngAppSettings) { + var ctrl = this; + }, + ], + bindings: { + appSettings: "=", + }, +}); + modules.component("portalMenus", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/portal-menus/view.html", @@ -7201,20 +7217,6 @@ modules.component("portalMenus", { ], }); -app.component("appSettingsSmtp", { - templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/smtp/view.html", - controller: [ - "ngAppSettings", - function (ngAppSettings) { - var ctrl = this; - }, - ], - bindings: { - appSettings: "=", - }, -}); - app.component("customerMain", { templateUrl: "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", @@ -7349,6 +7351,25 @@ app.component("mixdbContextDatabases", { ], }); +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("moduleMain", { templateUrl: "/mix-app/views/app-portal/pages/module/components/main/main.html", @@ -7379,25 +7400,6 @@ app.component("moduleMain", { }, }); -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("moduleContent", { templateUrl: "/mix-app/views/app-portal/pages/module/components/module-content/view.html", @@ -7582,6 +7584,27 @@ app.component("pageMain", { }, }); +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("pageModules", { templateUrl: "/mix-app/views/app-portal/pages/page/components/modules/modules.html", @@ -7627,27 +7650,6 @@ app.component("pageModules", { ], }); -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", { templateUrl: "/mix-app/views/app-portal/pages/page/components/page-content/view.html", @@ -7787,137 +7789,47 @@ app.component("permissionMain", { "/mix-app/views/app-portal/pages/permission/components/main/main.html", controller: [ "$rootScope", - "$scope", - "ngAppSettings", - "$routeParams", - function ($rootScope, $scope, ngAppSettings, $routeParams) { - 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(); - } - }; - }, - ], - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("permissionParents", { - templateUrl: - "/mix-app/views/app-portal/pages/permission/components/parents/parents.html", - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -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; - } - angular.forEach(statuses, function (val, i) { - ctrl.statuses.push({ - value: val, - title: val, - }); - }); - }; - ctrl.addMetadataQuery = () => { - ctrl.request.metadataQueries.push({ - fieldName: "", - value: "", - isRequired: false, - }); - }; - ctrl.clearMetadataQuery = () => { - ctrl.request.metadataQueries = []; - ctrl.apply(); - }; - 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.apply = function (pageIndex) { - $rootScope.setRequest(ctrl.request, ctrl.key); - ctrl.callback({ pageIndex: pageIndex }); + "$scope", + "ngAppSettings", + "$routeParams", + function ($rootScope, $scope, ngAppSettings, $routeParams) { + var ctrl = this; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.icons = ngAppSettings.icons; + ctrl.setPageType = function (type) { + ctrl.page.type = $index; }; - ctrl.updateDate = function () { - if (Date.parse(ctrl.dateRange.fromDate)) { - ctrl.request.fromDate = new Date( - ctrl.dateRange.fromDate - ).toISOString(); - } else { - $scope.request.fromDate = null; - } - if (Date.parse(ctrl.dateRange.toDate)) { - ctrl.request.toDate = new Date(ctrl.dateRange.toDate).toISOString(); - } else { - ctrl.request.toDate = null; + 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(); } - $rootScope.setRequest(ctrl.request, ctrl.key); - ctrl.callback({ pageIndex: 0 }); }; }, ], + bindings: { + page: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + +app.component("permissionParents", { + templateUrl: + "/mix-app/views/app-portal/pages/permission/components/parents/parents.html", + bindings: { + page: "=", + onDelete: "&", + onUpdate: "&", + }, }); app.component("permissionPlugPlay", { @@ -8019,6 +7931,96 @@ app.component("permissionPlugPlay", { ], }); +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; + } + angular.forEach(statuses, function (val, i) { + ctrl.statuses.push({ + value: val, + title: val, + }); + }); + }; + ctrl.addMetadataQuery = () => { + ctrl.request.metadataQueries.push({ + fieldName: "", + value: "", + isRequired: false, + }); + }; + ctrl.clearMetadataQuery = () => { + ctrl.request.metadataQueries = []; + ctrl.apply(); + }; + 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.apply = function (pageIndex) { + $rootScope.setRequest(ctrl.request, ctrl.key); + ctrl.callback({ pageIndex: pageIndex }); + }; + ctrl.updateDate = function () { + if (Date.parse(ctrl.dateRange.fromDate)) { + ctrl.request.fromDate = new Date( + ctrl.dateRange.fromDate + ).toISOString(); + } else { + $scope.request.fromDate = null; + } + 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 }); + }; + }, + ], +}); + app.component("postGeneral", { templateUrl: "/mix-app/views/app-portal/pages/post/components/general/view.html", @@ -8048,6 +8050,40 @@ app.component("postGeneral", { }, }); +app.component("postMain", { + templateUrl: "/mix-app/views/app-portal/pages/post/components/main/view.html", + bindings: { + post: "=", + }, + controller: [ + "$rootScope", + "$scope", + function ($rootScope, $scope) { + var ctrl = this; + ctrl.translate = $rootScope.translate; + ctrl.generateSeo = function () { + if (ctrl.post) { + if (!ctrl.post.seoName) { + ctrl.post.seoName = $rootScope.generateKeyword( + ctrl.post.title, + "-" + ); + } + if (!ctrl.post.seoTitle) { + ctrl.post.seoTitle = ctrl.post.title; + } + if (!ctrl.post.seoDescription === null) { + ctrl.post.seoDescription = ctrl.post.excerpt; + } + if (!ctrl.post.seoKeywords) { + ctrl.post.seoKeywords = ctrl.post.title; + } + } + }; + }, + ], +}); + app.component("postMedias", { templateUrl: "/mix-app/views/app-portal/pages/post/components/medias/view.html", @@ -8091,6 +8127,16 @@ app.component("postMedias", { }, }); +app.component("postParents", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/parents/view.html", + bindings: { + post: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("postModules", { templateUrl: "/mix-app/views/app-portal/pages/post/components/modules/view.html", @@ -8184,165 +8230,27 @@ app.component("postModules", { }, }); -app.component("postMain", { - templateUrl: "/mix-app/views/app-portal/pages/post/components/main/view.html", - bindings: { - post: "=", - }, - controller: [ - "$rootScope", - "$scope", - function ($rootScope, $scope) { - var ctrl = this; - ctrl.translate = $rootScope.translate; - ctrl.generateSeo = function () { - if (ctrl.post) { - if (!ctrl.post.seoName) { - ctrl.post.seoName = $rootScope.generateKeyword( - ctrl.post.title, - "-" - ); - } - if (!ctrl.post.seoTitle) { - ctrl.post.seoTitle = ctrl.post.title; - } - if (!ctrl.post.seoDescription === null) { - ctrl.post.seoDescription = ctrl.post.excerpt; - } - if (!ctrl.post.seoKeywords) { - ctrl.post.seoKeywords = ctrl.post.title; - } - } - }; - }, - ], -}); - -app.component("postParents", { - templateUrl: - "/mix-app/views/app-portal/pages/post/components/parents/view.html", - bindings: { - post: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - app.component("postAdvanced", { templateUrl: - "/mix-app/views/app-portal/pages/post/components/post-advanced/view.html", - bindings: { - model: "=", - additionalData: "=", - }, - controller: [ - "$rootScope", - "$scope", - "$routeParams", - function ($rootScope, $scope, $routeParams) { - var ctrl = this; - ctrl.translate = $rootScope.translate; - ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - if ($routeParams.template) { - ctrl.defaultTemplate = $routeParams.template; - } - if ($routeParams.layout) { - ctrl.defaultLayout = $routeParams.layout; - } - }; - }, - ], -}); - -app.component("postContent", { - templateUrl: - "/mix-app/views/app-portal/pages/post/components/post-content/view.html", + "/mix-app/views/app-portal/pages/post/components/post-advanced/view.html", bindings: { model: "=", additionalData: "=", - loadingData: "=", }, controller: [ "$rootScope", "$scope", - "ngAppSettings", - "PostRestService", - function ($rootScope, $scope, ngAppSettings, service) { + "$routeParams", + function ($rootScope, $scope, $routeParams) { var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); ctrl.translate = $rootScope.translate; - ctrl.relatedData = {}; ctrl.$onInit = function () { - ctrl.backUrl = `/admin/post/details`; - }; - ctrl.generateSeo = function () { - if (ctrl.model) { - 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; - } - } - }; - ctrl.getListRelated = async function (pageIndex) { - 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(); + ctrl.isAdmin = $rootScope.isAdmin; + if ($routeParams.template) { + ctrl.defaultTemplate = $routeParams.template; } - var resp = await service.getList(ctrl.request); - if (resp && resp.success) { - ctrl.relatedData = angular.copy(resp.data); - ctrl.relatedData.items = []; - angular.forEach(resp.data.items, (element) => { - var existed = $rootScope.findObjectByKey( - ctrl.model.postNavs, - ["sourceId", "destinationId"], - [ctrl.model.id, element.id] - ); - - var obj = { - description: element.title, - destinationId: element.id, - image: element.image, - isActived: existed !== null, - sourceId: ctrl.model.id, - specificulture: ctrl.model.specificulture, - status: "Published", - }; - - ctrl.relatedData.items.push(obj); - }); - console.log(ctrl.relatedData); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(getData.errors); - $rootScope.isBusy = false; - $scope.$apply(); + if ($routeParams.layout) { + ctrl.defaultLayout = $routeParams.layout; } }; }, @@ -8490,6 +8398,100 @@ modules.component("relatedPosts", { ], }); +app.component("postContent", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/post-content/view.html", + bindings: { + model: "=", + additionalData: "=", + loadingData: "=", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "PostRestService", + function ($rootScope, $scope, ngAppSettings, service) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.translate = $rootScope.translate; + ctrl.relatedData = {}; + ctrl.$onInit = function () { + ctrl.backUrl = `/admin/post/details`; + }; + ctrl.generateSeo = function () { + if (ctrl.model) { + 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; + } + } + }; + ctrl.getListRelated = async function (pageIndex) { + 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 resp = await service.getList(ctrl.request); + if (resp && resp.success) { + ctrl.relatedData = angular.copy(resp.data); + ctrl.relatedData.items = []; + angular.forEach(resp.data.items, (element) => { + var existed = $rootScope.findObjectByKey( + ctrl.model.postNavs, + ["sourceId", "destinationId"], + [ctrl.model.id, element.id] + ); + + var obj = { + description: element.title, + destinationId: element.id, + image: element.image, + isActived: existed !== null, + sourceId: ctrl.model.id, + specificulture: ctrl.model.specificulture, + status: "Published", + }; + + ctrl.relatedData.items.push(obj); + }); + console.log(ctrl.relatedData); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(getData.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], +}); + app.component("postSeo", { templateUrl: "/mix-app/views/app-portal/pages/post/components/seo/view.html", bindings: { @@ -8551,87 +8553,17 @@ app.component("serviceMain", { ctrl.gennerateName = function () { if ( !ctrl.model.id || - ctrl.model.name === null || - ctrl.model.name === "" - ) { - ctrl.model.name = $rootScope.generateKeyword(ctrl.model.title, "_"); - } - }; - }, - ], - bindings: { - model: "=", - }, -}); - -app.component("themeExportCultures", { - templateUrl: - "/mix-app/views/app-portal/pages/theme/components/theme-export-cultures/view.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope, ngAppSettings) { - var ctrl = this; - var service = $rootScope.getRestService("culture"); - ctrl.selectAllContent = false; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = async () => { - ctrl.getList(); - }; - ctrl.getList = async (cultureIndex) => { - if (cultureIndex !== undefined) { - ctrl.request.cultureIndex = cultureIndex; - } - 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 = (culture, selected) => { - ctrl.selectAllContent = ctrl.selectAllContent && selected; - ctrl.selectAllData = ctrl.selectAllData && selected; - culture.isExportData = selected && culture.isExportData; - ctrl.updateContent([culture.id], selected); - }; - ctrl.updateContent = function (arr, selected) { - if (selected) { - ctrl.exportThemeDto.cultureIds = ctrl.unionArray( - ctrl.exportThemeDto.cultureIds, - arr - ); - } else { - ctrl.exportThemeDto.cultureIds = - ctrl.exportThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); - ctrl.updateData(arr, false); - } - }; - ctrl.selectAll = function (arr) { - // ctrl.selectedList.data = []; - var ids = arr.map(function (obj) { - return obj.id; - }); - ctrl.updateContent(ids, ctrl.selectAllContent); - angular.forEach(arr, function (e) { - e.isActived = ctrl.selectAllContent; - }); - }; - ctrl.unionArray = (a, b) => { - return [...new Set([...a, ...b])]; - }; - }, - ], - bindings: { - exportThemeDto: "=", + ctrl.model.name === null || + ctrl.model.name === "" + ) { + ctrl.model.name = $rootScope.generateKeyword(ctrl.model.title, "_"); + } + }; }, + ], + bindings: { + model: "=", + }, }); app.component("themeExportMixDatabases", { @@ -8715,6 +8647,76 @@ app.component("themeExportMixDatabases", { }, }); +app.component("themeExportCultures", { + templateUrl: + "/mix-app/views/app-portal/pages/theme/components/theme-export-cultures/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope, ngAppSettings) { + var ctrl = this; + var service = $rootScope.getRestService("culture"); + ctrl.selectAllContent = false; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = async () => { + ctrl.getList(); + }; + ctrl.getList = async (cultureIndex) => { + if (cultureIndex !== undefined) { + ctrl.request.cultureIndex = cultureIndex; + } + 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 = (culture, selected) => { + ctrl.selectAllContent = ctrl.selectAllContent && selected; + ctrl.selectAllData = ctrl.selectAllData && selected; + culture.isExportData = selected && culture.isExportData; + ctrl.updateContent([culture.id], selected); + }; + ctrl.updateContent = function (arr, selected) { + if (selected) { + ctrl.exportThemeDto.cultureIds = ctrl.unionArray( + ctrl.exportThemeDto.cultureIds, + arr + ); + } else { + ctrl.exportThemeDto.cultureIds = + ctrl.exportThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); + ctrl.updateData(arr, false); + } + }; + ctrl.selectAll = function (arr) { + // ctrl.selectedList.data = []; + var ids = arr.map(function (obj) { + return obj.id; + }); + ctrl.updateContent(ids, ctrl.selectAllContent); + angular.forEach(arr, function (e) { + e.isActived = ctrl.selectAllContent; + }); + }; + ctrl.unionArray = (a, b) => { + return [...new Set([...a, ...b])]; + }; + }, + ], + bindings: { + exportThemeDto: "=", + }, +}); + app.component("themeExportModules", { templateUrl: "/mix-app/views/app-portal/pages/theme/components/theme-export-modules/view.html", @@ -8909,6 +8911,76 @@ app.component("themeExportPages", { }, }); +app.component("themeImportCultures", { + templateUrl: + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope, ngAppSettings) { + var ctrl = this; + var service = $rootScope.getRestService("culture"); + ctrl.selectAllContent = false; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = async () => { + ctrl.getList(); + }; + ctrl.getList = async (cultureIndex) => { + if (cultureIndex !== undefined) { + ctrl.request.cultureIndex = cultureIndex; + } + 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 = (culture, selected) => { + ctrl.selectAllContent = ctrl.selectAllContent && selected; + ctrl.selectAllData = ctrl.selectAllData && selected; + culture.isImportData = selected && culture.isImportData; + ctrl.updateContent([culture.id], selected); + }; + ctrl.updateContent = function (arr, selected) { + if (selected) { + ctrl.importThemeDto.cultureIds = ctrl.unionArray( + ctrl.importThemeDto.cultureIds, + arr + ); + } else { + ctrl.importThemeDto.cultureIds = + ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); + ctrl.updateData(arr, false); + } + }; + ctrl.selectAll = function (arr) { + // ctrl.selectedList.data = []; + var ids = arr.map(function (obj) { + return obj.id; + }); + ctrl.updateContent(ids, ctrl.selectAllContent); + angular.forEach(arr, function (e) { + e.isActived = ctrl.selectAllContent; + }); + }; + ctrl.unionArray = (a, b) => { + return [...new Set([...a, ...b])]; + }; + }, + ], + bindings: { + importThemeDto: "=", + }, +}); + app.component("themeExportPosts", { templateUrl: "/mix-app/views/app-portal/pages/theme/components/theme-export-posts/view.html", @@ -9008,76 +9080,6 @@ app.component("themeExportPosts", { }, }); -app.component("themeImportCultures", { - templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope, ngAppSettings) { - var ctrl = this; - var service = $rootScope.getRestService("culture"); - ctrl.selectAllContent = false; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = async () => { - ctrl.getList(); - }; - ctrl.getList = async (cultureIndex) => { - if (cultureIndex !== undefined) { - ctrl.request.cultureIndex = cultureIndex; - } - 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 = (culture, selected) => { - ctrl.selectAllContent = ctrl.selectAllContent && selected; - ctrl.selectAllData = ctrl.selectAllData && selected; - culture.isImportData = selected && culture.isImportData; - ctrl.updateContent([culture.id], selected); - }; - ctrl.updateContent = function (arr, selected) { - if (selected) { - ctrl.importThemeDto.cultureIds = ctrl.unionArray( - ctrl.importThemeDto.cultureIds, - arr - ); - } else { - ctrl.importThemeDto.cultureIds = - ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); - ctrl.updateData(arr, false); - } - }; - ctrl.selectAll = function (arr) { - // ctrl.selectedList.data = []; - var ids = arr.map(function (obj) { - return obj.id; - }); - ctrl.updateContent(ids, ctrl.selectAllContent); - angular.forEach(arr, function (e) { - e.isActived = ctrl.selectAllContent; - }); - }; - ctrl.unionArray = (a, b) => { - return [...new Set([...a, ...b])]; - }; - }, - ], - bindings: { - importThemeDto: "=", - }, -}); - app.component("themeImportMixDatabases", { templateUrl: "/mix-app/views/app-portal/pages/theme-import/components/theme-import-mix-databases/view.html", @@ -9710,7 +9712,50 @@ modules.component("layoutPortalSidebar", { var ctrl = this; }, ], - bindings: {}, + bindings: {}, +}); + +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(); + }; + }, + ], }); modules.component("aceEditor", { @@ -9820,49 +9865,6 @@ modules.component("aceEditor", { }, }); -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(); - }; - }, - ], -}); - modules.component("additionalColumn", { templateUrl: "/mix-app/views/app-portal/components/additional-column/view.html", @@ -10383,6 +10385,43 @@ modules.component("githubContributers", { bindings: {}, }); +modules.component("githubReleases", { + templateUrl: "/mix-app/views/app-portal/components/github-releases/view.html", + controller: [ + "$rootScope", + "$http", + function ($rootScope, $http) { + var ctrl = this; + ctrl.items = []; + ctrl.init = function () { + var req = { + method: "GET", + url: "https://api.github.com/repos/mixcore/mix.core/releases", + }; + ctrl.getGithubApiResult(req); + }; + + ctrl.getGithubApiResult = async function (req) { + return $http(req).then( + function (resp) { + if (resp.status == "200") { + ctrl.items = resp.data; + } else { + } + }, + function (error) { + return { + success: false, + errors: [error.statusText || error.status], + }; + } + ); + }; + }, + ], + bindings: {}, +}); + modules.component("googleAnalytic", { templateUrl: "/mix-app/views/app-portal/components/google-analytic/view.html", bindings: { @@ -10589,43 +10628,6 @@ modules.component("googleAnalytic", { ], }); -modules.component("githubReleases", { - templateUrl: "/mix-app/views/app-portal/components/github-releases/view.html", - controller: [ - "$rootScope", - "$http", - function ($rootScope, $http) { - var ctrl = this; - ctrl.items = []; - ctrl.init = function () { - var req = { - method: "GET", - url: "https://api.github.com/repos/mixcore/mix.core/releases", - }; - ctrl.getGithubApiResult(req); - }; - - ctrl.getGithubApiResult = async function (req) { - return $http(req).then( - function (resp) { - if (resp.status == "200") { - ctrl.items = resp.data; - } else { - } - }, - function (error) { - return { - success: false, - errors: [error.statusText || error.status], - }; - } - ); - }; - }, - ], - bindings: {}, -}); - (function (angular) { app.component("headerNav", { templateUrl: @@ -10841,147 +10843,26 @@ app.controller("HighFrequencyMessagesController", [ ((doc && doc.scrollLeft) || (body && body.scrollLeft) || 0) - ((doc && doc.clientLeft) || (body && body.clientLeft) || 0); event.pageY = - event.clientY + - ((doc && doc.scrollTop) || (body && body.scrollTop) || 0) - - ((doc && doc.clientTop) || (body && body.clientTop) || 0); - } - let x = (event.pageX / screen.width) * 100; - let y = (event.pageY / screen.height) * 100; - if ( - !$scope.mousePos || - ($scope.mousePos.x != x && $scope.mousePos.y != y) - ) { - $scope.moved = true; - $scope.mousePos = { - x: x, - y: y, - }; - } - }; - - $scope.newMessage = function (msg) { - msg.style = $scope.getMessageType(msg.type); - $scope.messages.push(msg); - if ( - !msg.from || - msg.from.connectionId != $scope.hubRequest.from.connectionId - ) { - $scope.newMsgCount += 1; - $rootScope.showMessage(msg.title, msg.style); - } - $scope.$apply(); - }; - $scope.removeMember = function (member) { - var index = $scope.members.findIndex( - (x) => x.username === member.username - ); - if (index >= 0) { - $scope.members.splice(index, 1); - } - $scope.$apply(); - }; - - $scope.newMember = function (member) { - var index = $scope.members.findIndex( - (x) => x.username === member.username - ); - if (index < 0) { - $scope.members.splice(0, 0, member); - } - $scope.$apply(); - }; - $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"; - } - }; - }, -]); - -modules.component("hubMessages", { - templateUrl: - "/mix-app/views/app-portal/components/hub-messages/hub-messages.html", - controller: "HubMessagesController", - bindings: {}, -}); -app.controller("HubMessagesController", [ - "$scope", - "$rootScope", - "AuthService", - function ($scope, $rootScope, authService) { - BaseHub.call(this, $scope); - authService.fillAuthData(); - $scope.newMsgCount = 0; - $scope.messages = []; - $scope.onConnected = () => { - // $scope.joinRoom("portal"); - }; - $scope.init = function () { - $scope.startConnection( - "portalHub", - authService.authentication.accessToken, - (err) => { - if ( - authService.authentication.refreshToken && - err.message.indexOf("401") >= 0 - ) { - authService.refreshToken().then(async () => { - $scope.startConnection( - "portalHub", - authService.authentication.accessToken - ); - }); - } - } - ); - }; - $scope.readMessages = function () { - $scope.newMsgCount = 0; - $("#modal-hub-messages").modal("show"); - }; - $scope.receiveMessage = function (msg) { - switch (msg.action) { - case "MyConnection": - $scope.hubRequest.from = msg.data; - $scope.$apply(); - break; - case "MemberList": - // filter unique member by username - $scope.members = msg.data.filter( - (value, index, array) => - array.indexOf(array.find((u) => u.username == value.username)) === - index - ); - $scope.$apply(); - break; - case "NewMember": - $scope.newMember(msg.data); - break; - case "MemberOffline": - $scope.removeMember(msg.data); - case "NewMessage": - $scope.newMessage(msg); - break; + event.clientY + + ((doc && doc.scrollTop) || (body && body.scrollTop) || 0) - + ((doc && doc.clientTop) || (body && body.clientTop) || 0); } - }; - $scope.newMessage = function (msg) { - msg.style = $scope.getMessageType(msg.type); + let x = (event.pageX / screen.width) * 100; + let y = (event.pageY / screen.height) * 100; if ( - msg.data && - !angular.isObject(msg.data) && - msg.data.indexOf("{") == 0 + !$scope.mousePos || + ($scope.mousePos.x != x && $scope.mousePos.y != y) ) { - msg.data = JSON.parse(msg.data); + $scope.moved = true; + $scope.mousePos = { + x: x, + y: y, + }; } + }; + + $scope.newMessage = function (msg) { + msg.style = $scope.getMessageType(msg.type); $scope.messages.push(msg); if ( !msg.from || @@ -11319,29 +11200,126 @@ modules.component("jsonBuilder", { ], }); -modules.component("jumbotrons", { +modules.component("hubMessages", { 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: "=", - }, + "/mix-app/views/app-portal/components/hub-messages/hub-messages.html", + controller: "HubMessagesController", + bindings: {}, }); +app.controller("HubMessagesController", [ + "$scope", + "$rootScope", + "AuthService", + function ($scope, $rootScope, authService) { + BaseHub.call(this, $scope); + authService.fillAuthData(); + $scope.newMsgCount = 0; + $scope.messages = []; + $scope.onConnected = () => { + // $scope.joinRoom("portal"); + }; + $scope.init = function () { + $scope.startConnection( + "portalHub", + authService.authentication.accessToken, + (err) => { + if ( + authService.authentication.refreshToken && + err.message.indexOf("401") >= 0 + ) { + authService.refreshToken().then(async () => { + $scope.startConnection( + "portalHub", + authService.authentication.accessToken + ); + }); + } + } + ); + }; + $scope.readMessages = function () { + $scope.newMsgCount = 0; + $("#modal-hub-messages").modal("show"); + }; + $scope.receiveMessage = function (msg) { + switch (msg.action) { + case "MyConnection": + $scope.hubRequest.from = msg.data; + $scope.$apply(); + break; + case "MemberList": + // filter unique member by username + $scope.members = msg.data.filter( + (value, index, array) => + array.indexOf(array.find((u) => u.username == value.username)) === + index + ); + $scope.$apply(); + break; + case "NewMember": + $scope.newMember(msg.data); + break; + case "MemberOffline": + $scope.removeMember(msg.data); + 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); + if ( + !msg.from || + msg.from.connectionId != $scope.hubRequest.from.connectionId + ) { + $scope.newMsgCount += 1; + $rootScope.showMessage(msg.title, msg.style); + } + $scope.$apply(); + }; + $scope.removeMember = function (member) { + var index = $scope.members.findIndex( + (x) => x.username === member.username + ); + if (index >= 0) { + $scope.members.splice(index, 1); + } + $scope.$apply(); + }; + + $scope.newMember = function (member) { + var index = $scope.members.findIndex( + (x) => x.username === member.username + ); + if (index < 0) { + $scope.members.splice(0, 0, member); + } + $scope.$apply(); + }; + $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"; + } + }; + }, +]); // const { data } = require("jquery"); @@ -11554,6 +11532,65 @@ modules.component("listMixColumn", { ], }); +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("mainSideBar", { + templateUrl: + "/mix-app/views/app-portal/components/main-side-bar/main-side-bar.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "TranslatorService", + "ApiService", + "CommonService", + function ( + $rootScope, + $scope, + ngAppSettings, + translatorService, + apiService, + commonService + ) { + 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("logStream", { templateUrl: "/mix-app/views/app-portal/components/log-stream/view.html", controller: "LogStreamController", @@ -11644,42 +11681,7 @@ app.controller("LogStreamController", [ } }; }, -]); - -modules.component("mainSideBar", { - templateUrl: - "/mix-app/views/app-portal/components/main-side-bar/main-side-bar.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "TranslatorService", - "ApiService", - "CommonService", - function ( - $rootScope, - $scope, - ngAppSettings, - translatorService, - apiService, - commonService - ) { - 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: @@ -11722,43 +11724,43 @@ modules.component("mainSideBarDynamic", { }, }); -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: "=", }, }); -modules.component("mainSideBarItem", { +modules.component("mainSideBarItemDynamic", { 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-item-dynamic/main-side-bar-item-dynamic.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: "=", }, }); @@ -13556,6 +13558,96 @@ modules.component("mixDatabaseNavValues", { ], }); +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.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 { + $rootScope.showErrors(["Please choose file"]); + } + }; + }, + ], +}); + modules.component("mixDatabaseNavs", { templateUrl: "/mix-app/views/app-portal/components/mix-database-navs/view.html", @@ -13654,164 +13746,74 @@ modules.component("mixDatabaseNavs", { if (nav.id) { result = await navService.delete([nav.id]); $(".pane-container-" + nav.data.id) - .parent() - .remove(); - } - if (result && result.success) { - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - } - }; - - ctrl.active = async function (nav) { - $rootScope.isBusy = true; - var result; - result = await navService.save(nav); - if (result && result.success) { - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $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]); - }; + .parent() + .remove(); + } + if (result && result.success) { + $rootScope.isBusy = false; + $scope.$apply(); } else { - return null; + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; } }; - 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(); - } + ctrl.active = async function (nav) { + $rootScope.isBusy = true; + var result; + result = await navService.save(nav); + if (result && result.success) { + $rootScope.isBusy = false; + $scope.$apply(); } else { - $rootScope.showErrors(["Please choose file"]); + $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(); + }); }; }, ], @@ -14743,58 +14745,216 @@ modules.component("modalNavDatas", { $rootScope.isBusy = false; $scope.$apply(); } else { - let result = await associationService.deleteAssociation( - ctrl.parentDatabaseName, - ctrl.mixDatabaseName, - ctrl.parentId, - ctrl.guidParentId, - item.id - ); - $rootScope.handleResponse(result); + 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); + }; + }, + ], +}); + +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("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(); } - 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(); }); - } - 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); + }, 500); }; }, ], @@ -15021,232 +15181,74 @@ modules.component("modalNavMetas", { nav.level = level; if (isSelected) { nav.isActived = true; - if (nav.intParentId) { - var saveResult = await navService.save(nav); - nav.id = saveResult.data.id; - $rootScope.showMessage("success", "success"); - ctrl.filterData(); - $scope.$apply(); - } - } - - if (!isSelected) { - await ctrl.removeNav(idx); - if (ctrl.selectCallback) { - ctrl.selectCallback({ data: nav }); - } - return; - } - }; - ctrl.removeNav = async function (idx) { - var nav = ctrl.selectedList.items[idx]; - ctrl.selectedValues.splice(idx, 1); - ctrl.selectedList.items.splice(idx, 1); - ctrl.filterData(); - if (nav && nav.id) { - await navService.delete([nav.id]); - $rootScope.showMessage("success", "success"); - $scope.$apply(); - } - }; - ctrl.disableNavitem = function (nav, isDisable) { - nav.disabled = isDisable; - }; - ctrl.createData = function () { - if (ctrl.newTitle) { - var tmp = $rootScope.findObjectByKey( - ctrl.data.items, - "title", - ctrl.newTitle - ); - if (!tmp) { - ctrl.isBusy = true; - ctrl.mixDatabaseData.intParentId = 0; - ctrl.mixDatabaseData.parentType = "Set"; - ctrl.mixDatabaseData.data.title = ctrl.newTitle; - ctrl.mixDatabaseData.data.slug = $rootScope.generateKeyword( - ctrl.newTitle, - "-" - ); - ctrl.mixDatabaseData.data.type = ctrl.type; - dataService.save(ctrl.mixDatabaseData).then((resp) => { - if (resp.success) { - ctrl.mixDatabaseData.id = resp.data; - ctrl.data.items.push(ctrl.mixDatabaseData); - ctrl.reload(); - ctrl.select(resp.data.id, true); - ctrl.filterData(); - ctrl.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(resp.errors); - ctrl.isBusy = false; - $scope.$apply(); - } - }); - } else { - tmp.isActived = true; - ctrl.select(tmp); - } - } - }; - }, - ], -}); - -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 (nav.intParentId) { + var saveResult = await navService.save(nav); + nav.id = saveResult.data.id; + $rootScope.showMessage("success", "success"); + ctrl.filterData(); + $scope.$apply(); + } } - if ($routeParams.type) { - ctrl.request.postType = $routeParams.type; - } else { - ctrl.request.postType = ""; + + if (!isSelected) { + await ctrl.removeNav(idx); + if (ctrl.selectCallback) { + ctrl.selectCallback({ data: nav }); + } + return; } - 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; + }; + ctrl.removeNav = async function (idx) { + var nav = ctrl.selectedList.items[idx]; + ctrl.selectedValues.splice(idx, 1); + ctrl.selectedList.items.splice(idx, 1); + ctrl.filterData(); + if (nav && nav.id) { + await navService.delete([nav.id]); + $rootScope.showMessage("success", "success"); $scope.$apply(); } }; - ctrl.select = async (associations) => { - ctrl.associations = associations; + ctrl.disableNavitem = function (nav, isDisable) { + nav.disabled = isDisable; }; - ctrl.saveSelected = function () { - ctrl.selected = $rootScope.filterArray( - ctrl.navs, - ["isActived"], - [true] - ); - setTimeout(() => { - ctrl.save().then(() => { - ctrl.loadPosts(); - }); - }, 500); + ctrl.createData = function () { + if (ctrl.newTitle) { + var tmp = $rootScope.findObjectByKey( + ctrl.data.items, + "title", + ctrl.newTitle + ); + if (!tmp) { + ctrl.isBusy = true; + ctrl.mixDatabaseData.intParentId = 0; + ctrl.mixDatabaseData.parentType = "Set"; + ctrl.mixDatabaseData.data.title = ctrl.newTitle; + ctrl.mixDatabaseData.data.slug = $rootScope.generateKeyword( + ctrl.newTitle, + "-" + ); + ctrl.mixDatabaseData.data.type = ctrl.type; + dataService.save(ctrl.mixDatabaseData).then((resp) => { + if (resp.success) { + ctrl.mixDatabaseData.id = resp.data; + ctrl.data.items.push(ctrl.mixDatabaseData); + ctrl.reload(); + ctrl.select(resp.data.id, true); + ctrl.filterData(); + ctrl.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(resp.errors); + ctrl.isBusy = false; + $scope.$apply(); + } + }); + } else { + tmp.isActived = true; + ctrl.select(tmp); + } + } }; }, ], @@ -16328,83 +16330,6 @@ modules.component("templateEditor", { ], }); -modules.component("toastHelper", { - templateUrl: - "/mix-app/views/app-portal/components/toast-helper/toast-helper.html", - bindings: { - url: "=?", - title: "=?", - }, - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.visible = $rootScope.visible; - }, - ], -}); - -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 = {}; @@ -17257,6 +17182,83 @@ 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: "&", + }, +}); + +modules.component("toastHelper", { + templateUrl: + "/mix-app/views/app-portal/components/toast-helper/toast-helper.html", + bindings: { + url: "=?", + title: "=?", + }, + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.visible = $rootScope.visible; + }, + ], +}); + !(function (t) { var e = {}; function i(n) { diff --git a/src/modules/mix.portal/Controllers/MixApplicationController.cs b/src/modules/mix.portal/Controllers/MixApplicationController.cs index 9faecefb5..206e86bc7 100644 --- a/src/modules/mix.portal/Controllers/MixApplicationController.cs +++ b/src/modules/mix.portal/Controllers/MixApplicationController.cs @@ -46,7 +46,7 @@ public async Task> Install([FromBody] MixA await _applicationService.Install(app, cancellationToken); return base.Ok(app); } - + [HttpPost] [Route("restore-package")] public async Task> Restore([FromBody] RestoreMixApplicationPackageDto dto, CancellationToken cancellationToken = default) @@ -65,7 +65,7 @@ protected override async Task UpdateHandler(int id, MixApplicationViewModel data await _applicationService.UpdatePackage(data, data.PackageFilePath, cancellationToken); } await base.UpdateHandler(id, data, cancellationToken); - + } protected override async Task> SearchHandler(SearchRequestDto req, CancellationToken cancellationToken = default) { @@ -77,6 +77,16 @@ protected override async Task> Sear return result; } + protected override async Task DeleteHandler(MixApplicationViewModel data, CancellationToken cancellationToken = default) + { + await base.DeleteHandler(data, cancellationToken); + if (data.TemplateId.HasValue) + { + await MixViewTemplateViewModel.GetRepository(Uow, CacheService).DeleteAsync(data.TemplateId.Value); + } + MixFileHelper.DeleteFolder(data.DeployUrl); + } + #endregion } } diff --git a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs index efeec5899..66ee382f8 100644 --- a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs +++ b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs @@ -17,6 +17,7 @@ namespace Mix.Portal.Domain.Services public sealed class MixApplicationService : TenantServiceBase, IMixApplicationService { static string[] excludeFileNames = { "jquery", "index" }; + static string allowExtensionsPattern = "js|css|png|jpg|jpeg|gif|svg|webm|mp3|mp4|wmv"; private readonly IQueueService _queueService; private readonly IThemeService _themeService; private readonly MixIdentityService _mixIdentityService; @@ -119,7 +120,7 @@ private async Task ModifyFilesAndFolders(string deployUrl, string topFolder, str } - Regex regex = new("((\\\"|\\'|\\(|\\`){1}(\\.)?(\\/)?(([0-9a-zA-Z\\/\\._-])+)\\.{1}(\\w+)(\"|\\'|\\(|\\`){1})"); + Regex regex = new($"((\\\"|\\'|\\(\\/|\\`)(\\.)?(\\/)?(([0-9a-zA-Z\\/\\._-])+)\\.({allowExtensionsPattern})(\"|\\'|\\)|\\`))"); Regex baseHrefRegex = new("(base href=\"(.+?)\")"); indexFile.Content = indexFile.Content.Replace("[basePath]/", string.Empty); indexFile.Content = regex.Replace(indexFile.Content, $"$2/{deployUrl}/$5.$7$2"); @@ -134,7 +135,7 @@ private async Task ModifyFilesAndFolders(string deployUrl, string topFolder, str template ??= new(_cmsUow) { MixThemeId = activeTheme.Id, - FileName = name, + FileName = $"MixApp_{name}", FileFolder = $"{MixFolders.TemplatesFolder}/{CurrentTenant.SystemName}/{activeTheme.SystemName}/{MixTemplateFolderType.Pages}", FolderType = MixTemplateFolderType.Pages, Extension = MixFileExtensions.CsHtml, @@ -165,7 +166,7 @@ private Task ReplaceContent(FileModel file, string folders, string deployUrl) try { _ = AlertAsync(_hubContext.Clients.Group("Theme"), "Status", 200, $"Modifying {file.Filename}{file.Extension}"); - Regex rg = new("((\\\"|\\'|\\(\\/|\\`){1}(\\.)?(\\/)?(([0-9a-zA-Z\\/\\._-])+)\\.{1}(\\w+)(\"|\\'|\\)|\\`){1})"); + Regex rg = new($"((\\\"|\\'|\\(\\/|\\`)(\\.)?(\\/)?(([0-9a-zA-Z\\/\\._-])+)\\.({allowExtensionsPattern})(\"|\\'|\\)|\\`))"); if (rg.IsMatch(file.Content)) { file.Content = rg.Replace(file.Content, $"$2/{deployUrl}/$5.$7$2");