From bd335d3d9ea5d6e9e84771582c0e94f5ed41b672 Mon Sep 17 00:00:00 2001 From: Phat Date: Mon, 18 Sep 2023 22:33:50 +0700 Subject: [PATCH] Update endpoints --- .../wwwroot/mix-app/js/app-portal.min.js | 3154 ++++++++--------- 1 file changed, 1577 insertions(+), 1577 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 b1ba687c6..06949013c 100644 --- a/src/applications/Mixcore/wwwroot/mix-app/js/app-portal.min.js +++ b/src/applications/Mixcore/wwwroot/mix-app/js/app-portal.min.js @@ -1,4 +1,4 @@ -/* Sat Sep 16 2023 00:51:39 GMT+0700 (Indochina Time) */"use strict"; +/* Sat Sep 16 2023 01:02:01 GMT+0700 (Indochina Time) */"use strict"; var app = angular.module("MixPortal", [ "angularCroppie", "ui.bootstrap", @@ -167,161 +167,6 @@ app.factory("TemplateService", [ }, ]); -"use strict"; -app.controller("MixApplicationController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$location", - "$routeParams", - "MixApplicationRestService", - "StoreService", - function ( - $scope, - $rootScope, - ngAppSettings, - $location, - $routeParams, - service, - storeService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - BaseHub.call(this, $scope); - $scope.progress = 0; - $scope.viewMode = "list"; - $scope.current = null; - $scope.themeRequest = angular.copy(ngAppSettings.request); - $scope.themeRequest.orderBy = "createdDatetime"; - $scope.themeRequest.mixDatabaseName = "mixcorePortalApp"; - $scope.themeRequest.queries = [ - { fieldName: "mixcoreVersion", value: "2.0.1" }, - ]; - $scope.request.columns = [ - "id", - "displayName", - "baseRoute", - "detailUrl", - "createdDateTime", - "createdBy", - ]; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - - $scope.init = async function () { - $scope.startConnection("mixThemeHub", null, (err) => { - console.log(err); - }); - $scope.onConnected = () => { - $scope.joinRoom("Theme"); - }; - await $scope.getThemes(); - }; - $scope.install = async function () { - $rootScope.isBusy = true; - $scope.installStatus = "Downloading"; - var resp = await service.install($scope.viewmodel); - if (resp && resp.success) { - $scope.data = resp.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors || ["Failed"]); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.receiveMessage = function (resp) { - let msg = JSON.parse(resp); - switch (msg.action) { - case "Downloading": - var index = $scope.data.items.findIndex( - (m) => m.id == $scope.current.id - ); - var progress = Math.round(msg.message); - if (index >= 0) { - $scope.progress = progress; - if (progress == 100) { - $scope.installStatus = "Installing"; - } - $scope.$apply(); - } - break; - - default: - console.log(msg); - break; - } - }; - $scope.getThemes = async function () { - $rootScope.isBusy = true; - if ($scope.themeRequest.fromDate !== null) { - var d = new Date($scope.themeRequest.fromDate); - $scope.themeRequest.fromDate = d.toISOString(); - } - if ($scope.themeRequest.toDate !== null) { - var dt = new Date($scope.themeRequest.toDate); - $scope.themeRequest.toDate = dt.toISOString(); - } - var resp = await storeService.getThemes($scope.themeRequest); - if (resp && resp.success) { - $scope.data = resp.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors || ["Failed"]); - } - if ($scope.getListFailCallback) { - $scope.getListFailCallback(); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.select = function (theme) { - $scope.viewmodel.packateFilePath = theme.additionalData.source; - $scope.current = theme; - // TODO: verify user - theme to enable install - $scope.current.canInstall = true; - $scope.viewMode = "detail"; - }; - $scope.back = function () { - $scope.viewMode = "list"; - }; - }, -]); - -"use strict"; -app.factory("MixApplicationRestService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-application"); - var _install = async function (objData) { - var url = `${this.prefixUrl}/install`; - var req = { - serviceBase: this.serviceBase, - method: "POST", - url: url, - data: JSON.stringify(objData), - }; - return await this.getRestApiResult(req); - }; - serviceFactory.install = _install; - return serviceFactory; - }, -]); - "use strict"; app.controller("AppSettingsController", [ "$scope", @@ -498,22 +343,22 @@ app.factory("AppSettingsServices", [ ]); "use strict"; -app.controller("AuditLogController", [ +app.controller("MixApplicationController", [ "$scope", "$rootScope", "ngAppSettings", "$location", "$routeParams", - "AuthService", - "AuditLogRestService", + "MixApplicationRestService", + "StoreService", function ( $scope, $rootScope, ngAppSettings, $location, $routeParams, - authService, - service + service, + storeService ) { BaseRestCtrl.call( this, @@ -525,47 +370,202 @@ app.controller("AuditLogController", [ service ); BaseHub.call(this, $scope); - authService.fillAuthData(); - $scope.request.status = null; - $scope.messages = []; + $scope.progress = 0; + $scope.viewMode = "list"; + $scope.current = null; + $scope.themeRequest = angular.copy(ngAppSettings.request); + $scope.themeRequest.orderBy = "createdDatetime"; + $scope.themeRequest.mixDatabaseName = "mixcorePortalApp"; + $scope.themeRequest.queries = [ + { fieldName: "mixcoreVersion", value: "2.0.1" }, + ]; + $scope.request.columns = [ + "id", + "displayName", + "baseRoute", + "detailUrl", + "createdDateTime", + "createdBy", + ]; $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.connect = () => { - $scope.startConnection( - "log-stream-hub", - authService.authentication.accessToken, - (err) => { - if ( - authService.authentication.refreshToken && - err.message.indexOf("401") >= 0 - ) { - authService.refreshToken().then(async () => { - $scope.startConnection( - "log-stream-hub", - authService.authentication.accessToken - ); - }); - } + $scope.init = async function () { + $scope.startConnection("mixThemeHub", null, (err) => { + console.log(err); + }); + $scope.onConnected = () => { + $scope.joinRoom("Theme"); + }; + await $scope.getThemes(); + }; + $scope.install = async function () { + $rootScope.isBusy = true; + $scope.installStatus = "Downloading"; + var resp = await service.install($scope.viewmodel); + if (resp && resp.success) { + $scope.data = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors || ["Failed"]); } - ); + $rootScope.isBusy = false; + $scope.$apply(); + } }; - $scope.receiveMessage = function (msg) { + $scope.receiveMessage = function (resp) { + let msg = JSON.parse(resp); switch (msg.action) { - case "MyConnection": - $scope.hubRequest.from = msg.data; - $scope.$apply(); + case "Downloading": + var index = $scope.data.items.findIndex( + (m) => m.id == $scope.current.id + ); + var progress = Math.round(msg.message); + if (index >= 0) { + $scope.progress = progress; + if (progress == 100) { + $scope.installStatus = "Installing"; + } + $scope.$apply(); + } break; - case "NewMessage": - $scope.newMessage(msg); + default: + console.log(msg); break; } }; - $scope.newMessage = function (msg) { - msg.style = $scope.getMessageType(msg.type); - if (msg.data) { - msg.data = JSON.parse(msg.data); + $scope.getThemes = async function () { + $rootScope.isBusy = true; + if ($scope.themeRequest.fromDate !== null) { + var d = new Date($scope.themeRequest.fromDate); + $scope.themeRequest.fromDate = d.toISOString(); + } + if ($scope.themeRequest.toDate !== null) { + var dt = new Date($scope.themeRequest.toDate); + $scope.themeRequest.toDate = dt.toISOString(); + } + var resp = await storeService.getThemes($scope.themeRequest); + if (resp && resp.success) { + $scope.data = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors || ["Failed"]); + } + if ($scope.getListFailCallback) { + $scope.getListFailCallback(); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.select = function (theme) { + $scope.viewmodel.packateFilePath = theme.additionalData.source; + $scope.current = theme; + // TODO: verify user - theme to enable install + $scope.current.canInstall = true; + $scope.viewMode = "detail"; + }; + $scope.back = function () { + $scope.viewMode = "list"; + }; + }, +]); + +"use strict"; +app.factory("MixApplicationRestService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-application"); + var _install = async function (objData) { + var url = `${this.prefixUrl}/install`; + var req = { + serviceBase: this.serviceBase, + method: "POST", + url: url, + data: JSON.stringify(objData), + }; + return await this.getRestApiResult(req); + }; + serviceFactory.install = _install; + return serviceFactory; + }, +]); + +"use strict"; +app.controller("AuditLogController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$location", + "$routeParams", + "AuthService", + "AuditLogRestService", + function ( + $scope, + $rootScope, + ngAppSettings, + $location, + $routeParams, + authService, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + BaseHub.call(this, $scope); + authService.fillAuthData(); + $scope.request.status = null; + $scope.messages = []; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + + $scope.connect = () => { + $scope.startConnection( + "log-stream-hub", + authService.authentication.accessToken, + (err) => { + if ( + authService.authentication.refreshToken && + err.message.indexOf("401") >= 0 + ) { + authService.refreshToken().then(async () => { + $scope.startConnection( + "log-stream-hub", + authService.authentication.accessToken + ); + }); + } + } + ); + }; + $scope.receiveMessage = function (msg) { + switch (msg.action) { + case "MyConnection": + $scope.hubRequest.from = msg.data; + $scope.$apply(); + break; + case "NewMessage": + $scope.newMessage(msg); + + break; + } + }; + $scope.newMessage = function (msg) { + msg.style = $scope.getMessageType(msg.type); + if (msg.data) { + msg.data = JSON.parse(msg.data); } $scope.messages.push(msg); $scope.$apply(); @@ -718,6 +718,89 @@ app.factory("ConfigurationService", [ }, ]); +"use strict"; +app.controller("CultureController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "CultureService", + "CommonService", + "ApiService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + service, + commonService, + apiService + ) { + $scope.selected = null; + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + $scope.loadCultures = async function () { + var getCultures = await commonService.loadJsonData("cultures"); + $scope.cultures = getCultures.data.items; + $scope.$apply(); + }; + $scope.saveSuccessCallback = function () { + apiService + .initAllSettings() + .then(() => (window.location.href = "/admin/language/list")); + }; + $scope.removeCallback = function () { + apiService + .initAllSettings() + .then(() => (window.location.href = "/admin/language/list")); + }; + $scope.changeData = function (selected) { + if (selected) { + $scope.viewmodel.specificulture = selected.specificulture; + $scope.viewmodel.displayName = selected.fullName; + $scope.viewmodel.icon = selected.icon; + } + }; + }, +]); + +"use strict"; +app.factory("CultureService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("culture"); + var _updateInfos = async function (pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), + }; + return await apiService.sendRequest(req); + }; + + var _syncTemplates = async function (id) { + var apiUrl = "/culture/"; + var url = apiUrl + "sync/" + id; + var req = { + method: "GET", + url: url, + }; + return await apiService.sendRequest(req); + }; + + serviceFactory.syncTemplates = _syncTemplates; + serviceFactory.updateInfos = _updateInfos; + return serviceFactory; + }, +]); + "use strict"; app.controller("CustomerController", [ "$scope", @@ -1011,127 +1094,44 @@ app.factory("DashboardServices", [ ]); "use strict"; -app.controller("CultureController", [ +app.controller("DomainController", [ "$scope", "$rootScope", "ngAppSettings", + "$location", "$routeParams", - "CultureService", - "CommonService", - "ApiService", + "DomainRestService", function ( $scope, $rootScope, ngAppSettings, + $location, $routeParams, - service, - commonService, - apiService + service ) { - $scope.selected = null; - BaseCtrl.call( + BaseRestCtrl.call( this, $scope, $rootScope, + $location, $routeParams, ngAppSettings, service ); - $scope.loadCultures = async function () { - var getCultures = await commonService.loadJsonData("cultures"); - $scope.cultures = getCultures.data.items; - $scope.$apply(); - }; - $scope.saveSuccessCallback = function () { - apiService - .initAllSettings() - .then(() => (window.location.href = "/admin/language/list")); - }; - $scope.removeCallback = function () { - apiService - .initAllSettings() - .then(() => (window.location.href = "/admin/language/list")); - }; - $scope.changeData = function (selected) { - if (selected) { - $scope.viewmodel.specificulture = selected.specificulture; - $scope.viewmodel.displayName = selected.fullName; - $scope.viewmodel.icon = selected.icon; - } - }; + $scope.request.columns = [ + "id", + "displayName", + "host", + "createdDateTime", + "createdBy", + ]; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; }, ]); "use strict"; -app.factory("CultureService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("culture"); - var _updateInfos = async function (pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), - }; - return await apiService.sendRequest(req); - }; - - var _syncTemplates = async function (id) { - var apiUrl = "/culture/"; - var url = apiUrl + "sync/" + id; - var req = { - method: "GET", - url: url, - }; - return await apiService.sendRequest(req); - }; - - serviceFactory.syncTemplates = _syncTemplates; - serviceFactory.updateInfos = _updateInfos; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("DomainController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$location", - "$routeParams", - "DomainRestService", - function ( - $scope, - $rootScope, - ngAppSettings, - $location, - $routeParams, - service - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.request.columns = [ - "id", - "displayName", - "host", - "createdDateTime", - "createdBy", - ]; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - }, -]); - -"use strict"; -app.factory("DomainRestService", [ +app.factory("DomainRestService", [ "BaseRestService", function (baseService) { var serviceFactory = Object.create(baseService); @@ -1864,136 +1864,6 @@ app.controller("loginController", [ }, ]); -"use strict"; -app.controller("MixDatabaseController", [ - "$scope", - "$rootScope", - "$location", - "ngAppSettings", - "$routeParams", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "RestMixDatabasePortalService", - function ( - $scope, - $rootScope, - $location, - ngAppSettings, - $routeParams, - databaseDataService, - databaseColumnService, - databaseService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - databaseService - ); - $scope.defaultAttr = null; - $scope.actions = ["Delete"]; - $scope.viewmodelType = "mix-database"; - // $scope.request.selects = 'id,title,name,createdDateTime'; - $scope.orders = [ - { title: "Id", value: "Id" }, - { title: "Name", value: "Name" }, - { title: "Created Date", value: "CreatedDateTime" }, - ]; - $scope.request.orderBy = "CreatedDateTime"; - $scope.request.columns = "id,displayName,systemName,type,createdDatetime"; - $scope.request.searchColumns = "displayName,systemName"; - $scope.saveDatabase = function () { - $scope.save($scope.viewmodel); - }; - - $scope.getSingleSuccessCallback = async function () { - 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(); - } - } - }; - }, -]); - "use strict"; app.controller("MixDatabaseDataController", [ "$scope", @@ -2346,26 +2216,24 @@ app.controller("MixDatabaseDataController", [ ]); "use strict"; -app.controller("ModuleController", [ +app.controller("MixDatabaseController", [ "$scope", "$rootScope", - "ngAppSettings", "$location", + "ngAppSettings", "$routeParams", - "ModuleRestService", - "SharedModuleDataService", "RestMixDatabaseDataPortalService", "RestMixDatabaseColumnPortalService", + "RestMixDatabasePortalService", function ( $scope, $rootScope, - ngAppSettings, $location, + ngAppSettings, $routeParams, - moduleServices, - moduleDataService, - dataService, - columnService + databaseDataService, + databaseColumnService, + databaseService ) { BaseRestCtrl.call( this, @@ -2374,29 +2242,161 @@ app.controller("ModuleController", [ $location, $routeParams, ngAppSettings, - moduleServices, - "product" + databaseService ); - $scope.request.culture = $rootScope.globalSettings.defaultCulture; - $scope.viewmodelType = "module"; - $scope.contentUrl = ""; - $scope.getSingleSuccessCallback = function () { - $scope.loadAdditionalData(); + $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); + }; - if ($scope.viewmodel.id > 0) { - // module => list post or list product - if ($scope.viewmodel.type.localeCompare("ListPost") == 0) { - $scope.contentUrl = "/admin/module-post/list/" + $scope.viewmodel.id; - } else if ($scope.viewmodel.type.localeCompare("Data") == 0) { - $scope.contentUrl = "/admin/module-data/list/" + $scope.viewmodel.id; + $scope.getSingleSuccessCallback = async function () { + if (!$scope.defaultAttr) { + var getDefaultAttr = await databaseColumnService.getDefault(); + if (getDefaultAttr.success) { + $scope.defaultAttr = getDefaultAttr.data; + $scope.defaultAttr.options = []; } + $scope.$apply(); } - if ($scope.viewmodel.sysCategories) { - angular.forEach($scope.viewmodel.sysCategories, function (e) { - e.attributeData.obj.isActived = true; - }); - } - + }; + $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(); + } + } + }; + }, +]); + +"use strict"; +app.controller("ModuleController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$location", + "$routeParams", + "ModuleRestService", + "SharedModuleDataService", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + function ( + $scope, + $rootScope, + ngAppSettings, + $location, + $routeParams, + moduleServices, + moduleDataService, + dataService, + columnService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + moduleServices, + "product" + ); + $scope.request.culture = $rootScope.globalSettings.defaultCulture; + $scope.viewmodelType = "module"; + $scope.contentUrl = ""; + $scope.getSingleSuccessCallback = function () { + $scope.loadAdditionalData(); + + if ($scope.viewmodel.id > 0) { + // module => list post or list product + if ($scope.viewmodel.type.localeCompare("ListPost") == 0) { + $scope.contentUrl = "/admin/module-post/list/" + $scope.viewmodel.id; + } else if ($scope.viewmodel.type.localeCompare("Data") == 0) { + $scope.contentUrl = "/admin/module-data/list/" + $scope.viewmodel.id; + } + } + if ($scope.viewmodel.sysCategories) { + angular.forEach($scope.viewmodel.sysCategories, function (e) { + e.attributeData.obj.isActived = true; + }); + } + if ($scope.viewmodel.sysTags) { angular.forEach($scope.viewmodel.sysTags, function (e) { e.attributeData.obj.isActived = true; @@ -3250,80 +3250,51 @@ app.factory("RestOrderDetailService", [ ]); "use strict"; -app.controller("PageController", [ +app.controller("PageGalleryController", [ "$scope", "$rootScope", "ngAppSettings", - "$location", "$routeParams", - "PageRestService", - "PagePostRestService", - "UrlAliasService", - "RestMixDatabasePortalService", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "MixDbService", + "$location", + "PageGalleryService", + "PostRestService", + "ApiService", + "CommonService", function ( $scope, $rootScope, ngAppSettings, - $location, $routeParams, + $location, service, - pagePostRestService, - urlAliasService, - databaseService, - dataService, - columnService, - mixDbService + postService, + apiService, + commonService ) { - BaseRestCtrl.call( + BaseCtrl.call( this, $scope, $rootScope, - $location, $routeParams, ngAppSettings, service ); - $scope.request.culture = $rootScope.globalSettings.defaultCulture; - var pageModuleService = $rootScope.getRestService("mix-page-module"); - $scope.viewmodelType = "page"; - $scope.request.query = "level=0"; - $scope.pageType = {}; - $scope.pageTypes = $rootScope.globalSettings.pageTypes; - $scope.selectedCategories = []; - $scope.selectedTags = []; - $scope.selectedModules = []; - $scope.pageData = { - posts: [], - products: [], - data: [], - }; - $scope.request.columns = [ - "id", - "title", - "createdDateTime", - "type", - "image", - ]; - $scope.additionalData = null; - $scope.temp = null; - $scope.postRequest = angular.copy(ngAppSettings.request); - $scope.additionalDatabaseRequest = angular.copy(ngAppSettings.request); - ($scope.additionalDatabaseRequest.searchColumns = "Type"), - ($scope.additionalDatabaseRequest.searchMethod = "Equal"), - ($scope.additionalDatabaseRequest.keyword = "AdditionalData"); + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.mixConfigurations = $rootScope.globalSettings; + $scope.pageId = $routeParams.id; $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.loadPosts = async function () { + $scope.getList = async function () { $rootScope.isBusy = true; var id = $routeParams.id; - $scope.postRequest.query += "&page_id=" + id; - var response = await pagePostRestService.getList($scope.postRequest); - + $scope.request.query = "&page_id=" + id; + var response = await service.getList($scope.request); + $scope.canDrag = + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; if (response.success) { - $scope.pageData.posts = response.data; + $scope.data = response.data; $rootScope.isBusy = false; $scope.$apply(); } else { @@ -3332,64 +3303,46 @@ app.controller("PageController", [ $scope.$apply(); } }; - $scope.$watch("additionalDatabase", function (newValue, oldValue) { - console.log(newValue, oldValue); - }); - $scope.init = async function () { - await $scope.loadAdditionalDatabases(); - await $scope.getSingle(); - }; - $scope.initList = function () { - $scope.additionalDatabases.splice(0, 0, { - systemName: "", - displayName: "All", - id: 0, - }); - $scope.getList(); - }; - $scope.getSingleSuccessCallback = function () { - mixDbService.initDbName($scope.viewmodel.mixDatabaseName); - $scope.additionalDatabase = $rootScope.findObjectByKey( - $scope.additionalDatabases, - "systemName", - $scope.viewmodel.mixDatabaseName + $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?" ); - if ($scope.additionalDatabase) { - $scope.loadAdditionalData(); - } - if ($routeParams.template) { - $scope.viewmodel.view = $rootScope.findObjectByKey( - $scope.viewmodel.templates, - "fileName", - $routeParams.template - ); - } - $scope.$apply(); - }; - $scope.getListSuccessCallback = function () { - $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; }; - $scope.loadAdditionalData = async function () { - $scope.loadingData = true; - const getData = await mixDbService.getSingleByParent( - "Page", - $scope.viewmodel.id - ); - if (getData.success) { - $scope.additionalData = getData.data; - $scope.loadingData = false; - } else { - $scope.additionalData = { - parentType: "Page", - }; - $scope.loadingData = false; + + $scope.removeConfirmed = async function (pageId, postId) { + $rootScope.isBusy = true; + var result = await service.delete(pageId, postId); + if (result.success) { + if ($scope.removeCallback) { + $rootScope.executeFunctionByName( + "removeCallback", + $scope.removeCallbackArgs, + $scope + ); + } + $scope.getList(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); } - $scope.$apply(); }; - $scope.showChilds = function (id) { - $("#childs-" + id).toggleClass("collapse"); + + $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); @@ -3412,186 +3365,26 @@ app.controller("PageController", [ $scope.$apply(); } }; - $scope.selPageType = function () { - $scope.request.query = "level=0&pageType=" + $scope.pageType; - $scope.getList(); - }; - $scope.selectModule = (associations) => { - if (associations) { - $scope.selectedModules = associations; - } - }; - $scope.goUp = async function (items, index) { - items[index].priority -= 1; - items[index - 1].priority += 1; - }; - - $scope.goDown = async function (items, index) { - items[index].priority += 1; - items[index - 1].priority -= 1; - }; - - $scope.saveSuccessCallback = async function () { - var result = await $scope.savePageModules(); - result = result && (await $scope.saveAdditionalData()); - if (result) { - $rootScope.showMessage("Saved", "success"); - } - $rootScope.isBusy = false; - $scope.$apply(); - }; - $scope.loadAdditionalDatabases = async function () { - let getTypes = await databaseService.getList( - $scope.additionalDatabaseRequest - ); - if (getTypes.success) { - $scope.additionalDatabases = getTypes.data.items; - $scope.additionalDatabases.splice(0, 0, { - systemName: null, - displayName: "All", - id: 0, - }); - if ($scope.request.mixDatabaseName) { - $scope.additionalDatabase = $rootScope.findObjectByKey( - $scope.additionalDatabases, - "mixDatabaseName", - $scope.request.mixDatabaseName - ); - } - $scope.request.mixDatabaseName = $routeParams.type || ""; - $scope.$apply(); - } - }; - $scope.onSelectType = async function () { - if ( - $scope.viewmodel && - $scope.additionalDatabase && - $scope.additionalDatabase.systemName - ) { - $scope.viewmodel.mixDatabaseName = $scope.additionalDatabase.systemName; - mixDbService.initDbName($scope.viewmodel.mixDatabaseName); - await $scope.loadAdditionalData(); - } else { - $scope.viewmodel.mixDatabaseName = null; - $scope.additionalData = null; - } - $scope.request.mixDatabaseName = $scope.additionalDatabase.systemName; - $scope.createUrl = `/admin/page/create?type=${$scope.request.mixDatabaseName}`; - if ($routeParams.template) { - $scope.createUrl += `&template=${$routeParams.template}`; - } - if ( - $scope.additionalDatabase && - (!$scope.viewmodel || !$scope.viewmodel.id) - ) { - await $scope.getDefault($scope.request.mixDatabaseName); - } - if ($scope.pageName == "pageList") { - await $scope.filter(); - } - }; - $scope.getDefault = async function (type = null) { - $rootScope.isBusy = true; - type = type || $routeParams.type; - var resp = await service.getDefault({ - type: type || "", - template: $routeParams.template || "", - }); - if (resp.success) { - $scope.viewmodel = resp.data; - mixDbService.initDbName($scope.viewmodel.mixDatabaseName); - if ($scope.getSingleSuccessCallback) { - $scope.getSingleSuccessCallback(); - } - - // $scope.viewmodel.createdDateTime = Date.now(); - $scope.viewmodel.createdBy = $rootScope.authentication.username; - - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - if ($scope.getSingleFailCallback) { - $scope.getSingleFailCallback(); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.saveAdditionalData = async () => { - if ($scope.additionalDatabase.systemName && $scope.additionalData) { - $scope.additionalData.isClone = $scope.viewmodel.isClone; - $scope.additionalData.cultures = $scope.viewmodel.cultures; - $scope.additionalData.intParentId = $scope.viewmodel.id; - $scope.additionalData.parentType = "Page"; - let result = await dataService.save($scope.additionalData); - if (!result.success) { - $rootScope.showErrors(result.errors); - } - return result.success; - } - }; - $scope.savePageModules = async () => { - angular.forEach($scope.selectedModules, (e) => { - e.parentId = $scope.viewmodel.id; - }); - var result = await pageModuleService.saveMany($scope.selectedModules); - if (!result.success) { - $rootScope.showErrors(result.errors); - } - return result.success; - }; - $scope.saveColumns = async function () { - let result = await columnService.saveMany($scope.additionalData.columns); - if (result.success) { - $rootScope.showMessage("success", "success"); - } - }; - - $scope.validate = async function () { - return true; - // Add default alias if create new page - // if (!$scope.viewmodel.id && !$scope.viewmodel.urlAliases.length) { - // // Ex: en-us/page-seo-name - // // await $scope.addAlias($scope.viewmodel.specificulture + '/' + $scope.viewmodel.seoName); - // return true; - // } else { - // return true; - // } - }; - $scope.addAlias = async function (alias) { - var getAlias = await urlAliasService.getDefault(); - if (getAlias.success) { - if (alias) { - getAlias.data.alias = alias; - } - $scope.viewmodel.urlAliases.push(getAlias.data); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(getAlias.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.removeAliasCallback = async function (index) { - $scope.viewmodel.urlAliases.splice(index, 1); - $scope.$apply(); - }; }, ]); "use strict"; -app.factory("PageRestService", [ +app.factory("PageGalleryService", [ "$rootScope", "ApiService", "CommonService", - "BaseRestService", + "BaseService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-page-content"); + serviceFactory.init("page-post"); + var _delete = async function (pageId, postId) { + var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; + var req = { + method: "GET", + url: url, + }; + return await apiService.sendRequest(req); + }; var _updateInfos = async function (pages) { var req = { method: "POST", @@ -3600,19 +3393,20 @@ app.factory("PageRestService", [ }; return await apiService.sendRequest(req); }; + serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; return serviceFactory; }, ]); "use strict"; -app.controller("PageGalleryController", [ +app.controller("PagePostController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "PageGalleryService", + "PagePostRestService", "PostRestService", "ApiService", "CommonService", @@ -3624,7 +3418,6 @@ app.controller("PageGalleryController", [ $location, service, postService, - apiService, commonService ) { BaseCtrl.call( @@ -3635,20 +3428,39 @@ app.controller("PageGalleryController", [ ngAppSettings, service ); + $scope.request.culture = $rootScope.globalSettings.defaultCulture; $scope.cates = ["Site", "System"]; $scope.others = []; $scope.mixConfigurations = $rootScope.globalSettings; - $scope.pageId = $routeParams.id; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.getList = async function () { + $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 !== "0"; + $scope.request.orderBy === "Priority" && + $scope.request.direction === "Asc"; if (response.success) { $scope.data = response.data; $rootScope.isBusy = false; @@ -3659,8 +3471,12 @@ app.controller("PageGalleryController", [ $scope.$apply(); } }; - $scope.remove = function (pageId, postId) { - $rootScope.showConfirm( + $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], @@ -3669,10 +3485,13 @@ app.controller("PageGalleryController", [ "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; + $scope.back = function () { + window.history.back(); + }; - $scope.removeConfirmed = async function (pageId, postId) { + $scope.removeConfirmed = async function (id) { $rootScope.isBusy = true; - var result = await service.delete(pageId, postId); + var result = await service.delete(id); if (result.success) { if ($scope.removeCallback) { $rootScope.executeFunctionByName( @@ -3683,7 +3502,7 @@ app.controller("PageGalleryController", [ } $scope.getList(); } else { - $rootScope.showMessage("failed"); + $rootScope.showErrors(result.errors); $rootScope.isBusy = false; $scope.$apply(); } @@ -3725,21 +3544,21 @@ app.controller("PageGalleryController", [ ]); "use strict"; -app.factory("PageGalleryService", [ +app.factory("PagePostRestService", [ "$rootScope", "ApiService", "CommonService", - "BaseService", + "BaseRestService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("page-post"); - var _delete = async function (pageId, postId) { - var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; + serviceFactory.init("mix-page-post"); + var _delete = async function (id) { + var url = this.prefixUrl + "/delete/" + id; var req = { method: "GET", url: url, }; - return await apiService.sendRequest(req); + return await apiService.getApiResult(req); }; var _updateInfos = async function (pages) { var req = { @@ -3747,7 +3566,7 @@ app.factory("PageGalleryService", [ url: this.prefixUrl + "/update-infos", data: JSON.stringify(pages), }; - return await apiService.sendRequest(req); + return await apiService.getApiResult(req); }; serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; @@ -3756,69 +3575,80 @@ app.factory("PageGalleryService", [ ]); "use strict"; -app.controller("PagePostController", [ +app.controller("PageController", [ "$scope", "$rootScope", "ngAppSettings", - "$routeParams", "$location", + "$routeParams", + "PageRestService", "PagePostRestService", - "PostRestService", - "ApiService", - "CommonService", + "UrlAliasService", + "RestMixDatabasePortalService", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + "MixDbService", function ( $scope, $rootScope, ngAppSettings, - $routeParams, $location, + $routeParams, service, - postService, - commonService + pagePostRestService, + urlAliasService, + databaseService, + dataService, + columnService, + mixDbService ) { - BaseCtrl.call( + BaseRestCtrl.call( this, $scope, $rootScope, + $location, $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"; + var pageModuleService = $rootScope.getRestService("mix-page-module"); + $scope.viewmodelType = "page"; + $scope.request.query = "level=0"; + $scope.pageType = {}; + $scope.pageTypes = $rootScope.globalSettings.pageTypes; + $scope.selectedCategories = []; + $scope.selectedTags = []; + $scope.selectedModules = []; + $scope.pageData = { + posts: [], + products: [], + data: [], }; - $scope.getList = async function (pageIndex) { - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } + $scope.request.columns = [ + "id", + "title", + "createdDateTime", + "type", + "image", + ]; + $scope.additionalData = null; + $scope.temp = null; + $scope.postRequest = angular.copy(ngAppSettings.request); + $scope.additionalDatabaseRequest = angular.copy(ngAppSettings.request); + ($scope.additionalDatabaseRequest.searchColumns = "Type"), + ($scope.additionalDatabaseRequest.searchMethod = "Equal"), + ($scope.additionalDatabaseRequest.keyword = "AdditionalData"); + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.loadPosts = async function () { $rootScope.isBusy = true; var id = $routeParams.id; - $scope.request.query = "&page_id=" + id; - var response = await service.getList($scope.request); - $scope.canDrag = - $scope.request.orderBy === "Priority" && - $scope.request.direction === "Asc"; + $scope.postRequest.query += "&page_id=" + id; + var response = await pagePostRestService.getList($scope.postRequest); + if (response.success) { - $scope.data = response.data; + $scope.pageData.posts = response.data; $rootScope.isBusy = false; $scope.$apply(); } else { @@ -3827,104 +3657,274 @@ app.controller("PagePostController", [ $scope.$apply(); } }; - $scope.preview = function (item) { - item.editUrl = "/admin/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); + $scope.$watch("additionalDatabase", function (newValue, oldValue) { + console.log(newValue, oldValue); + }); + $scope.init = async function () { + await $scope.loadAdditionalDatabases(); + await $scope.getSingle(); }; - $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.initList = function () { + $scope.additionalDatabases.splice(0, 0, { + systemName: "", + displayName: "All", + id: 0, + }); + $scope.getList(); + }; + $scope.getSingleSuccessCallback = function () { + mixDbService.initDbName($scope.viewmodel.mixDatabaseName); + $scope.additionalDatabase = $rootScope.findObjectByKey( + $scope.additionalDatabases, + "systemName", + $scope.viewmodel.mixDatabaseName ); + if ($scope.additionalDatabase) { + $scope.loadAdditionalData(); + } + if ($routeParams.template) { + $scope.viewmodel.view = $rootScope.findObjectByKey( + $scope.viewmodel.templates, + "fileName", + $routeParams.template + ); + } + $scope.$apply(); }; - $scope.back = function () { - window.history.back(); + $scope.getListSuccessCallback = function () { + $scope.canDrag = + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; }; - - $scope.removeConfirmed = async function (id) { + $scope.loadAdditionalData = async function () { + $scope.loadingData = true; + const getData = await mixDbService.getSingleByParent( + "Page", + $scope.viewmodel.id + ); + if (getData.success) { + $scope.additionalData = getData.data; + $scope.loadingData = false; + } else { + $scope.additionalData = { + parentType: "Page", + }; + $scope.loadingData = false; + } + $scope.$apply(); + }; + $scope.showChilds = function (id) { + $("#childs-" + id).toggleClass("collapse"); + }; + $scope.updateInfos = async function (index) { + $scope.data.items.splice(index, 1); $rootScope.isBusy = true; - var result = await service.delete(id); - if (result.success) { - if ($scope.removeCallback) { - $rootScope.executeFunctionByName( - "removeCallback", - $scope.removeCallbackArgs, - $scope + 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(); + } + }; + $scope.selPageType = function () { + $scope.request.query = "level=0&pageType=" + $scope.pageType; + $scope.getList(); + }; + $scope.selectModule = (associations) => { + if (associations) { + $scope.selectedModules = associations; + } + }; + $scope.goUp = async function (items, index) { + items[index].priority -= 1; + items[index - 1].priority += 1; + }; + + $scope.goDown = async function (items, index) { + items[index].priority += 1; + items[index - 1].priority -= 1; + }; + + $scope.saveSuccessCallback = async function () { + var result = await $scope.savePageModules(); + result = result && (await $scope.saveAdditionalData()); + if (result) { + $rootScope.showMessage("Saved", "success"); + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + $scope.loadAdditionalDatabases = async function () { + let getTypes = await databaseService.getList( + $scope.additionalDatabaseRequest + ); + if (getTypes.success) { + $scope.additionalDatabases = getTypes.data.items; + $scope.additionalDatabases.splice(0, 0, { + systemName: null, + displayName: "All", + id: 0, + }); + if ($scope.request.mixDatabaseName) { + $scope.additionalDatabase = $rootScope.findObjectByKey( + $scope.additionalDatabases, + "mixDatabaseName", + $scope.request.mixDatabaseName ); } - $scope.getList(); + $scope.request.mixDatabaseName = $routeParams.type || ""; + $scope.$apply(); + } + }; + $scope.onSelectType = async function () { + if ( + $scope.viewmodel && + $scope.additionalDatabase && + $scope.additionalDatabase.systemName + ) { + $scope.viewmodel.mixDatabaseName = $scope.additionalDatabase.systemName; + mixDbService.initDbName($scope.viewmodel.mixDatabaseName); + await $scope.loadAdditionalData(); + } else { + $scope.viewmodel.mixDatabaseName = null; + $scope.additionalData = null; + } + $scope.request.mixDatabaseName = $scope.additionalDatabase.systemName; + $scope.createUrl = `/admin/page/create?type=${$scope.request.mixDatabaseName}`; + if ($routeParams.template) { + $scope.createUrl += `&template=${$routeParams.template}`; + } + if ( + $scope.additionalDatabase && + (!$scope.viewmodel || !$scope.viewmodel.id) + ) { + await $scope.getDefault($scope.request.mixDatabaseName); + } + if ($scope.pageName == "pageList") { + await $scope.filter(); + } + }; + $scope.getDefault = async function (type = null) { + $rootScope.isBusy = true; + type = type || $routeParams.type; + var resp = await service.getDefault({ + type: type || "", + template: $routeParams.template || "", + }); + if (resp.success) { + $scope.viewmodel = resp.data; + mixDbService.initDbName($scope.viewmodel.mixDatabaseName); + if ($scope.getSingleSuccessCallback) { + $scope.getSingleSuccessCallback(); + } + + // $scope.viewmodel.createdDateTime = Date.now(); + $scope.viewmodel.createdBy = $rootScope.authentication.username; + + $rootScope.isBusy = false; + $scope.$apply(); } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + if ($scope.getSingleFailCallback) { + $scope.getSingleFailCallback(); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.saveAdditionalData = async () => { + if ($scope.additionalDatabase.systemName && $scope.additionalData) { + $scope.additionalData.isClone = $scope.viewmodel.isClone; + $scope.additionalData.cultures = $scope.viewmodel.cultures; + $scope.additionalData.intParentId = $scope.viewmodel.id; + $scope.additionalData.parentType = "Page"; + let result = await dataService.save($scope.additionalData); + if (!result.success) { + $rootScope.showErrors(result.errors); + } + return result.success; + } + }; + $scope.savePageModules = async () => { + angular.forEach($scope.selectedModules, (e) => { + e.parentId = $scope.viewmodel.id; + }); + var result = await pageModuleService.saveMany($scope.selectedModules); + if (!result.success) { $rootScope.showErrors(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); } + return result.success; }; - - $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.saveColumns = async function () { + let result = await columnService.saveMany($scope.additionalData.columns); + if (result.success) { + $rootScope.showMessage("success", "success"); } }; - $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"); + + $scope.validate = async function () { + return true; + // Add default alias if create new page + // if (!$scope.viewmodel.id && !$scope.viewmodel.urlAliases.length) { + // // Ex: en-us/page-seo-name + // // await $scope.addAlias($scope.viewmodel.specificulture + '/' + $scope.viewmodel.seoName); + // return true; + // } else { + // return true; + // } + }; + $scope.addAlias = async function (alias) { + var getAlias = await urlAliasService.getDefault(); + if (getAlias.success) { + if (alias) { + getAlias.data.alias = alias; + } + $scope.viewmodel.urlAliases.push(getAlias.data); $rootScope.isBusy = false; $scope.$apply(); } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } + $rootScope.showErrors(getAlias.errors); $rootScope.isBusy = false; $scope.$apply(); } }; + $scope.removeAliasCallback = async function (index) { + $scope.viewmodel.urlAliases.splice(index, 1); + $scope.$apply(); + }; }, ]); "use strict"; -app.factory("PagePostRestService", [ +app.factory("PageRestService", [ "$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); - }; + serviceFactory.init("mix-page-content"); var _updateInfos = async function (pages) { var req = { method: "POST", url: this.prefixUrl + "/update-infos", data: JSON.stringify(pages), }; - return await apiService.getApiResult(req); + return await apiService.sendRequest(req); }; - serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; return serviceFactory; }, @@ -4651,98 +4651,6 @@ 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", @@ -5111,6 +5019,98 @@ 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", @@ -5537,25 +5537,6 @@ app.controller("SocialFeedController", [ }, ]); -"use strict"; -app.controller("StoreController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "CryptoService", - "ThemeService", - "StoreService", - function ( - $scope, - $rootScope, - ngAppSettings, - cryptoService, - themeService, - service - ) { - }, -]); - "use strict"; app.controller("TemplateController", [ "$scope", @@ -5787,6 +5768,25 @@ app.controller("TemplateController", [ }, ]); +"use strict"; +app.controller("StoreController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "CryptoService", + "ThemeService", + "StoreService", + function ( + $scope, + $rootScope, + ngAppSettings, + cryptoService, + themeService, + service + ) { + }, +]); + "use strict"; app.controller("TenantController", [ "$scope", @@ -6865,37 +6865,6 @@ app.component("appSettingsAuth", { }, }); -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("appSettingsDefault", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/default/view.html", @@ -6940,6 +6909,37 @@ app.component("appSettingsDefault", { }, }); +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("appSettingsHeart", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/heart/view.html", @@ -7009,16 +7009,6 @@ modules.component("portalMenus", { ], }); -app.component("customerMain", { - templateUrl: - "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", - bindings: { - customer: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - app.component("appSettingsSmtp", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/smtp/view.html", @@ -7033,6 +7023,16 @@ app.component("appSettingsSmtp", { }, }); +app.component("customerMain", { + templateUrl: + "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", + bindings: { + customer: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("customerOrders", { templateUrl: "/mix-app/views/app-portal/pages/customer/components/orders/customer-orders.html", @@ -7151,6 +7151,25 @@ 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", @@ -7335,25 +7354,6 @@ app.component("pageMain", { }, }); -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("pageModules", { templateUrl: "/mix-app/views/app-portal/pages/page/components/modules/modules.html", @@ -7854,6 +7854,49 @@ app.component("postMain", { ], }); +app.component("postMedias", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/medias/view.html", + controller: function () { + var ctrl = this; + ctrl.activeMedia = function (media) { + var currentItem = null; + if (ctrl.post.mediaNavs === null) { + ctrl.post.mediaNavs = []; + } + $.each(ctrl.post.mediaNavs, function (i, e) { + if (e.mediaId === media.id) { + e.isActived = media.isActived; + currentItem = e; + return false; + } + }); + if (currentItem === null) { + currentItem = { + description: + media.description !== "undefined" ? media.description : "", + image: media.filePath, + mediaId: media.id, + post: ctrl.post.id, + specificulture: media.specificulture, + position: 0, + priority: ctrl.post.mediaNavs.length + 1, + isActived: true, + }; + media.isHidden = true; + ctrl.post.mediaNavs.push(currentItem); + } + }; + }, + bindings: { + post: "=", + medias: "=", + loadMedia: "&", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("postModules", { templateUrl: "/mix-app/views/app-portal/pages/post/components/modules/view.html", @@ -7928,63 +7971,20 @@ app.component("postModules", { 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(); - } - }; - }, - ], - bindings: { - post: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("postMedias", { - templateUrl: - "/mix-app/views/app-portal/pages/post/components/medias/view.html", - controller: function () { - var ctrl = this; - ctrl.activeMedia = function (media) { - var currentItem = null; - if (ctrl.post.mediaNavs === null) { - ctrl.post.mediaNavs = []; - } - $.each(ctrl.post.mediaNavs, function (i, e) { - if (e.mediaId === media.id) { - e.isActived = media.isActived; - currentItem = e; - return false; - } - }); - if (currentItem === null) { - currentItem = { - description: - media.description !== "undefined" ? media.description : "", - image: media.filePath, - mediaId: media.id, - post: ctrl.post.id, - specificulture: media.specificulture, - position: 0, - priority: ctrl.post.mediaNavs.length + 1, - isActived: true, - }; - media.isHidden = true; - ctrl.post.mediaNavs.push(currentItem); - } - }; - }, + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], bindings: { post: "=", - medias: "=", - loadMedia: "&", onDelete: "&", onUpdate: "&", }, @@ -8923,25 +8923,25 @@ app.component("themeImportMixDatabases", { ], }); -app.component("themeImportModules", { +app.component("themeImportPages", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-modules/view.html", + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-pages/view.html", controller: [ "$rootScope", "$scope", "ngAppSettings", function ($rootScope, $scope, ngAppSettings) { var ctrl = this; - var service = $rootScope.getRestService("mix-module"); + var service = $rootScope.getRestService("mix-page"); ctrl.selectAllContent = false; ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { ctrl.getList(); }; - ctrl.getList = async (moduleIndex) => { - if (moduleIndex !== undefined) { - ctrl.request.moduleIndex = moduleIndex; + ctrl.getList = async (pageIndex) => { + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; } if (ctrl.request.fromDate !== null) { var d = new Date(ctrl.request.fromDate); @@ -8956,39 +8956,39 @@ app.component("themeImportModules", { ctrl.data = getData.data; } }; - ctrl.selectContent = (module, selected) => { + ctrl.selectContent = (page, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - module.isImportData = selected && module.isImportData; - let contentIds = module.contents.map(function (obj) { + page.isImportData = selected && page.isImportData; + let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.content.moduleIds = ctrl.updateArray( - ctrl.importThemeDto.content.moduleIds, - [module.id], + ctrl.importThemeDto.content.pageIds = ctrl.updateArray( + ctrl.importThemeDto.content.pageIds, + [page.id], selected ); - ctrl.importThemeDto.content.moduleContentIds = ctrl.updateArray( - ctrl.importThemeDto.content.moduleContentIds, + ctrl.importThemeDto.content.pageContentIds = ctrl.updateArray( + ctrl.importThemeDto.content.pageContentIds, contentIds, selected ); if (!selected) { - ctrl.selectData(module, false); + ctrl.selectData(page, false); } }; - ctrl.selectData = (module, selected) => { + ctrl.selectData = (page, selected) => { ctrl.selectAllData = ctrl.selectAllData && selected; - let contentIds = module.contents.map(function (obj) { + let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.associations.moduleIds = ctrl.updateArray( - ctrl.importThemeDto.associations.moduleIds, - [module.id], + ctrl.importThemeDto.associations.pageIds = ctrl.updateArray( + ctrl.importThemeDto.associations.pageIds, + [page.id], selected ); - ctrl.importThemeDto.associations.moduleContentIds = ctrl.updateArray( - ctrl.importThemeDto.associations.moduleContentIds, + ctrl.importThemeDto.associations.pageContentIds = ctrl.updateArray( + ctrl.importThemeDto.associations.pageContentIds, contentIds, selected ); @@ -9019,25 +9019,25 @@ app.component("themeImportModules", { }, }); -app.component("themeImportPages", { +app.component("themeImportPosts", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-pages/view.html", + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-posts/view.html", controller: [ "$rootScope", "$scope", "ngAppSettings", function ($rootScope, $scope, ngAppSettings) { var ctrl = this; - var service = $rootScope.getRestService("mix-page"); + var service = $rootScope.getRestService("mix-post"); ctrl.selectAllContent = false; ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { ctrl.getList(); }; - ctrl.getList = async (pageIndex) => { - if (pageIndex !== undefined) { - ctrl.request.pageIndex = pageIndex; + ctrl.getList = async (postIndex) => { + if (postIndex !== undefined) { + ctrl.request.postIndex = postIndex; } if (ctrl.request.fromDate !== null) { var d = new Date(ctrl.request.fromDate); @@ -9052,39 +9052,39 @@ app.component("themeImportPages", { ctrl.data = getData.data; } }; - ctrl.selectContent = (page, selected) => { + ctrl.selectContent = (post, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - page.isImportData = selected && page.isImportData; - let contentIds = page.contents.map(function (obj) { + post.isImportData = selected && post.isImportData; + let contentIds = post.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.content.pageIds = ctrl.updateArray( - ctrl.importThemeDto.content.pageIds, - [page.id], + ctrl.importThemeDto.content.postIds = ctrl.updateArray( + ctrl.importThemeDto.content.postIds, + [post.id], selected ); - ctrl.importThemeDto.content.pageContentIds = ctrl.updateArray( - ctrl.importThemeDto.content.pageContentIds, + ctrl.importThemeDto.content.postContentIds = ctrl.updateArray( + ctrl.importThemeDto.content.postContentIds, contentIds, selected ); if (!selected) { - ctrl.selectData(page, false); + ctrl.selectData(post, false); } }; - ctrl.selectData = (page, selected) => { + ctrl.selectData = (post, selected) => { ctrl.selectAllData = ctrl.selectAllData && selected; - let contentIds = page.contents.map(function (obj) { + let contentIds = post.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.associations.pageIds = ctrl.updateArray( - ctrl.importThemeDto.associations.pageIds, - [page.id], + ctrl.importThemeDto.associations.postIds = ctrl.updateArray( + ctrl.importThemeDto.associations.postIds, + [post.id], selected ); - ctrl.importThemeDto.associations.pageContentIds = ctrl.updateArray( - ctrl.importThemeDto.associations.pageContentIds, + ctrl.importThemeDto.associations.postContentIds = ctrl.updateArray( + ctrl.importThemeDto.associations.postContentIds, contentIds, selected ); @@ -9115,25 +9115,25 @@ app.component("themeImportPages", { }, }); -app.component("themeImportPosts", { +app.component("themeImportModules", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-posts/view.html", + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-modules/view.html", controller: [ "$rootScope", "$scope", "ngAppSettings", function ($rootScope, $scope, ngAppSettings) { var ctrl = this; - var service = $rootScope.getRestService("mix-post"); + var service = $rootScope.getRestService("mix-module"); ctrl.selectAllContent = false; ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { ctrl.getList(); }; - ctrl.getList = async (postIndex) => { - if (postIndex !== undefined) { - ctrl.request.postIndex = postIndex; + ctrl.getList = async (moduleIndex) => { + if (moduleIndex !== undefined) { + ctrl.request.moduleIndex = moduleIndex; } if (ctrl.request.fromDate !== null) { var d = new Date(ctrl.request.fromDate); @@ -9148,39 +9148,39 @@ app.component("themeImportPosts", { ctrl.data = getData.data; } }; - ctrl.selectContent = (post, selected) => { + ctrl.selectContent = (module, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - post.isImportData = selected && post.isImportData; - let contentIds = post.contents.map(function (obj) { + module.isImportData = selected && module.isImportData; + let contentIds = module.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.content.postIds = ctrl.updateArray( - ctrl.importThemeDto.content.postIds, - [post.id], + ctrl.importThemeDto.content.moduleIds = ctrl.updateArray( + ctrl.importThemeDto.content.moduleIds, + [module.id], selected ); - ctrl.importThemeDto.content.postContentIds = ctrl.updateArray( - ctrl.importThemeDto.content.postContentIds, + ctrl.importThemeDto.content.moduleContentIds = ctrl.updateArray( + ctrl.importThemeDto.content.moduleContentIds, contentIds, selected ); if (!selected) { - ctrl.selectData(post, false); + ctrl.selectData(module, false); } }; - ctrl.selectData = (post, selected) => { + ctrl.selectData = (module, selected) => { ctrl.selectAllData = ctrl.selectAllData && selected; - let contentIds = post.contents.map(function (obj) { + let contentIds = module.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.associations.postIds = ctrl.updateArray( - ctrl.importThemeDto.associations.postIds, - [post.id], + ctrl.importThemeDto.associations.moduleIds = ctrl.updateArray( + ctrl.importThemeDto.associations.moduleIds, + [module.id], selected ); - ctrl.importThemeDto.associations.postContentIds = ctrl.updateArray( - ctrl.importThemeDto.associations.postContentIds, + ctrl.importThemeDto.associations.moduleContentIds = ctrl.updateArray( + ctrl.importThemeDto.associations.moduleContentIds, contentIds, selected ); @@ -11091,30 +11091,6 @@ modules.component("jsonBuilder", { ], }); -modules.component("jumbotrons", { - templateUrl: - "/mix-app/views/app-portal/components/jumbotrons/jumbotrons.html", - controller: [ - "$rootScope", - "$scope", - "$location", - function ($rootScope, $scope, $location) { - var ctrl = this; - ctrl.translate = function (keyword) { - return $rootScope.translate(keyword); - }; - // ctrl.back = function () { - // ctrl.backUrl = ctrl.backUrl || '/admin'; - // $location.path(ctrl.backUrl); - // }; - }, - ], - bindings: { - tagName: "=", - tagType: "=", - }, -}); - // const { data } = require("jquery"); modules.component("listMixColumn", { @@ -11326,6 +11302,30 @@ 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("logStream", { templateUrl: "/mix-app/views/app-portal/components/log-stream/view.html", controller: "LogStreamController", @@ -14864,10 +14864,11 @@ modules.component("modalNavMetas", { ], }); -modules.component("modalNavPages", { - templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", +modules.component("modalNavPosts", { + templateUrl: + "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", bindings: { - srcField: "=", + srcColumn: "=", srcId: "=", query: "=", selected: "=", @@ -14876,15 +14877,17 @@ modules.component("modalNavPages", { controller: [ "$rootScope", "$scope", + "$routeParams", "ngAppSettings", - "PageRestService", - function ($rootScope, $scope, ngAppSettings, pageService) { + "PostRestService", + function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { var ctrl = this; ctrl.request = angular.copy(ngAppSettings.request); ctrl.navs = []; + ctrl.associations = []; ctrl.data = { items: [] }; - ctrl.loadData = async function (pageIndex) { - ctrl.request.query = ctrl.query + ctrl.srcId; + ctrl.loadPosts = async function (pageIndex) { + // ctrl.request.query = ctrl.query + ctrl.srcId; if (pageIndex !== undefined) { ctrl.request.pageIndex = pageIndex; } @@ -14896,23 +14899,29 @@ modules.component("modalNavPages", { var d = new Date(ctrl.request.toDate); ctrl.request.toDate = d.toISOString(); } - var response = await pageService.getList(ctrl.request); + 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, - pageId: e.id, - image: e.thumbnailUrl, - specificulture: e.specificulture, - status: "Published", - isActived: false, - }; - item[ctrl.srcField] = ctrl.srcId; - ctrl.navs.push(item); - }); + // 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 { @@ -14921,6 +14930,9 @@ modules.component("modalNavPages", { $scope.$apply(); } }; + ctrl.select = async (associations) => { + ctrl.associations = associations; + }; ctrl.saveSelected = function () { ctrl.selected = $rootScope.filterArray( ctrl.navs, @@ -14929,19 +14941,18 @@ modules.component("modalNavPages", { ); setTimeout(() => { ctrl.save().then(() => { - ctrl.loadPages(); + ctrl.loadPosts(); }); }, 500); }; }, ], }); - -modules.component("modalNavPosts", { - templateUrl: - "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", + +modules.component("modalNavPages", { + templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", bindings: { - srcColumn: "=", + srcField: "=", srcId: "=", query: "=", selected: "=", @@ -14950,17 +14961,15 @@ modules.component("modalNavPosts", { controller: [ "$rootScope", "$scope", - "$routeParams", "ngAppSettings", - "PostRestService", - function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { + "PageRestService", + function ($rootScope, $scope, ngAppSettings, pageService) { 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; + ctrl.loadData = async function (pageIndex) { + ctrl.request.query = ctrl.query + ctrl.srcId; if (pageIndex !== undefined) { ctrl.request.pageIndex = pageIndex; } @@ -14972,29 +14981,23 @@ modules.component("modalNavPosts", { 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); + 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, - // postId: e.id, - // image: e.thumbnailUrl, - // specificulture: e.specificulture, - // post: e, - // status: "Published", - // isActived: false, - // }; - // item[ctrl.srcColumn] = ctrl.srcId; - // ctrl.navs.push(item); - // }); + 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 { @@ -15003,9 +15006,6 @@ modules.component("modalNavPosts", { $scope.$apply(); } }; - ctrl.select = async (associations) => { - ctrl.associations = associations; - }; ctrl.saveSelected = function () { ctrl.selected = $rootScope.filterArray( ctrl.navs, @@ -15014,7 +15014,7 @@ modules.component("modalNavPosts", { ); setTimeout(() => { ctrl.save().then(() => { - ctrl.loadPosts(); + ctrl.loadPages(); }); }, 500); }; @@ -15699,82 +15699,250 @@ modules.component("propertiesStructure", { } else { ctrl.columns.splice(ctrl.dragStartIndex + 1, 1); } - angular.forEach(ctrl.columns, function (e, i) { - e.priority = i; - }); + angular.forEach(ctrl.columns, function (e, i) { + e.priority = i; + }); + }; + }, + ], + bindings: { + header: "=", + columns: "=", + }, +}); + +modules.component("propertiesValue", { + templateUrl: + "/mix-app/views/app-portal/components/properties-value/view.html", + bindings: { + title: "=", + columns: "=", + properties: "=", + }, + controller: [ + "$rootScope", + "$scope", + function ($rootScope, $scope) { + var ctrl = this; + ctrl.defaultAttr = { + title: "", + name: "", + default: null, + options: [], + priority: 0, + dataType: 7, + isGroupBy: false, + isSelect: false, + isDisplay: true, + width: 3, + }; + ctrl.selectedProp = null; + ctrl.mixConfigurations = $rootScope.globalSettings; + + ctrl.$doCheck = function () { + if ( + angular.toJson(ctrl.columns) != angular.toJson(ctrl.trackedColumns) + ) { + ctrl.trackedColumns = angular.copy(ctrl.columns); + ctrl.trackedProperties = angular.copy(ctrl.properties); + ctrl.loadEditors(); + } + }.bind(ctrl); + + ctrl.loadEditors = function () { + ctrl.properties = []; + for (let i = 0; i < ctrl.columns.length; i++) { + var col = ctrl.columns[i]; + var oldObj = + $rootScope.findObjectByKey( + ctrl.trackedProperties, + "name", + col.systemName + ) || {}; + + ctrl.properties.push({ + title: col.displayName, + name: col.systemName, + dataType: col.dataType, + value: oldObj.value || col.defaultValue, + options: col.options, + }); + } + }; + + ctrl.addAttr = function () { + if (ctrl.columns) { + var t = angular.copy(ctrl.defaultAttr); + ctrl.columns.push(t); + } + }; + }, + ], +}); + +modules.component("serviceHubPortal", { + templateUrl: + "/mix-app/views/app-portal/components/service-hub-portal/view.html", + bindings: { + mixDatabaseName: "=", + isSave: "=?", + }, + controller: [ + "$rootScope", + "$scope", + "RestMixDatabaseColumnPortalService", + "RestMixDatabaseDataClientService", + "UserServices", + function ($rootScope, $scope, columnService, service, userServices) { + var ctrl = this; + BaseHub.call(this, ctrl); + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.user = { + loggedIn: false, + connection: {}, + }; + ctrl.mixDatabaseData = null; + ctrl.isHide = true; + ctrl.hideContact = true; + ctrl.columns = []; + ctrl.members = []; + ctrl.errors = []; + ctrl.messages = { + items: [], + }; + ctrl.message = { connection: {}, content: "" }; + ctrl.request = { + uid: "", + specificulture: "", + action: "", + objectType: null, + data: {}, + room: "", + isMyself: true, + isSave: false, + }; + ctrl.init = function () { + ctrl.mixDatabaseId = ctrl.mixDatabaseId || 0; + ctrl.request.specificulture = service.lang; + ctrl.request.room = ctrl.mixDatabaseName; + ctrl.request.isSave = ctrl.isSave == "true" || false; + ctrl.startConnection("serviceHub", ctrl.checkLoginStatus); + }; + ctrl.loadData = async function () { + /* + If input is data id => load ctrl.mixDatabaseData from service and handle it independently + Else modify input ctrl.mixDatabaseData + */ + $rootScope.isBusy = true; + var getDefault = await service.initData(ctrl.mixDatabaseName); + if (getDefault.success) { + ctrl.defaultData = getDefault.data; + ctrl.defaultData.data.user_name = ctrl.user.connection.name; + ctrl.defaultData.data.user_id = ctrl.user.connection.id; + ctrl.defaultData.data.user_avatar = ctrl.user.connection.avatar; + ctrl.defaultData.data.data_type = 9; + ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); + $rootScope.isBusy = false; + } + var getFields = await columnService.initData(ctrl.mixDatabaseName); + if (getFields.success) { + ctrl.columns = getFields.data; + } + }; + ctrl.submit = async function () { + if (ctrl.validate()) { + ctrl.request.action = "send_group_message"; + ctrl.request.uid = ctrl.user.connection.id; + ctrl.request.data = ctrl.mixDatabaseData.data; + ctrl.request.connection = ctrl.user.connection; + ctrl.connection.invoke("HandleRequest", JSON.stringify(ctrl.request)); + ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); + } + }; + ctrl.validate = function () { + var isValid = true; + ctrl.errors = []; + angular.forEach(ctrl.columns, function (column) { + if (column.regex) { + var regex = RegExp(column.regex, "g"); + isValid = regex.test(ctrl.mixDatabaseData.data[column.name]); + if (!isValid) { + ctrl.errors.push(`${column.name} is not match Regex`); + } + } + if (isValid && column.isEncrypt) { + ctrl.mixDatabaseData.data[column.name] = $rootScope.encrypt( + ctrl.mixDatabaseData.data[column.name] + ); + } + }); + return isValid; + }; + ctrl.receiveMessage = function (msg) { + switch (msg.responseKey) { + case "NewMember": + ctrl.newMember(msg.data); + // $('.widget-conversation').scrollTop = $('.widget-conversation')[0].scrollHeight; + break; + case "NewMessage": + ctrl.newMessage(msg.data); + break; + case "ConnectSuccess": + ctrl.user.loggedIn = true; + ctrl.initListMember(msg.data); + $scope.$apply(); + break; + case "PreviousMessages": + ctrl.messages = msg.data; + $scope.$apply(); + break; + case "MemberOffline": + ctrl.removeMember(msg.data); + break; + case "Error": + console.error(msg.data); + break; + } }; - }, - ], - bindings: { - header: "=", - columns: "=", - }, -}); - -modules.component("propertiesValue", { - templateUrl: - "/mix-app/views/app-portal/components/properties-value/view.html", - bindings: { - title: "=", - columns: "=", - properties: "=", - }, - controller: [ - "$rootScope", - "$scope", - function ($rootScope, $scope) { - var ctrl = this; - ctrl.defaultAttr = { - title: "", - name: "", - default: null, - options: [], - priority: 0, - dataType: 7, - isGroupBy: false, - isSelect: false, - isDisplay: true, - width: 3, + ctrl.newMessage = function (msg) { + ctrl.messages.items.push(msg); + $scope.$apply(); }; - ctrl.selectedProp = null; - ctrl.mixConfigurations = $rootScope.globalSettings; - - ctrl.$doCheck = function () { - if ( - angular.toJson(ctrl.columns) != angular.toJson(ctrl.trackedColumns) - ) { - ctrl.trackedColumns = angular.copy(ctrl.columns); - ctrl.trackedProperties = angular.copy(ctrl.properties); - ctrl.loadEditors(); + ctrl.newMember = function (member) { + var m = $rootScope.findObjectByKey(ctrl.members, "id", member.id); + if (!m) { + ctrl.members.push(member); } - }.bind(ctrl); - - ctrl.loadEditors = function () { - ctrl.properties = []; - for (let i = 0; i < ctrl.columns.length; i++) { - var col = ctrl.columns[i]; - var oldObj = - $rootScope.findObjectByKey( - ctrl.trackedProperties, - "name", - col.systemName - ) || {}; + $scope.$apply(); + }; + ctrl.join = async function () { + ctrl.request.action = "join_group"; + ctrl.request.uid = ctrl.user.connection.id; + ctrl.request.data = ctrl.user.connection; + ctrl.message.connection = ctrl.user.connection; + ctrl.connection.invoke("HandleRequest", JSON.stringify(ctrl.request)); + await ctrl.loadData(); + $scope.$apply(); + }; + ctrl.initListMember = function (data) { + data.forEach((member) => { + var index = ctrl.members.findIndex((x) => x.id === member.id); + if (index < 0) { + ctrl.members.splice(0, 0, member); + } + }); - ctrl.properties.push({ - title: col.displayName, - name: col.systemName, - dataType: col.dataType, - value: oldObj.value || col.defaultValue, - options: col.options, - }); - } + $scope.$apply(); }; - ctrl.addAttr = function () { - if (ctrl.columns) { - var t = angular.copy(ctrl.defaultAttr); - ctrl.columns.push(t); - } + ctrl.checkLoginStatus = async function () { + var response = await userServices.getMyProfile(); + ctrl.user.connection.name = response.data.username; + ctrl.user.connection.id = response.data.id; + ctrl.user.connection.connectionId = ctrl.connection.connectionId; + ctrl.user.connection.avatar = response.data.avatar; + ctrl.user.loggedIn = true; + ctrl.join(); }; }, ], @@ -15860,239 +16028,71 @@ modules.component("templateEditor", { // var resp = await service.getSingle([ // "portal", // themeId, - // ctrl.folderType, - // ]); - // if (resp && resp.success) { - // resp.data.fileName = "new"; - // ctrl.templates.splice(0, 0, resp.data); - - // $rootScope.isBusy = false; - // $scope.$apply(); - // } else { - // if (resp) { - // $rootScope.showErrors(resp.errors); - // $rootScope.isBusy = false; - // $scope.$apply(); - // } - // } - // } - }; - ctrl.loadTemplates = async function () { - ctrl.request.folderType = ctrl.folderType; - ctrl.request.themeId = ctrl.theme.id; - ctrl.request.pageSize = 1000; - let getTemplates = await service.getList(ctrl.request); - ctrl.templates = getTemplates.data.items; - ctrl.templates.splice(0, 0, { id: null, fileName: "" }); - if (!ctrl.templateId && ctrl.templates.length > 1) { - if (ctrl.defaultTemplate) { - ctrl.template = ctrl.templates.find( - (m) => m.fileName == ctrl.defaultTemplate - ); - ctrl.templateId = ctrl.template.id; - ctrl.selectedTemplate = ctrl.template; - } - if (!ctrl.template) { - ctrl.template = ctrl.templates[1]; - ctrl.templateId = ctrl.templates[1].id; - ctrl.selectedTemplate = ctrl.template; - } - } - $scope.$apply(); - }; - ctrl.loadThemes = async () => { - let getThemes = await themeService.getList(ctrl.themeRequest); - ctrl.themes = getThemes.data.items; - ctrl.theme = !ctrl.templateId - ? ctrl.themes[0] - : ctrl.themes.filter((m) => m.id == ctrl.template.mixThemeId)[0]; - }; - ctrl.loadTemplate = async () => { - if (ctrl.templateId) { - var resp = await service.getSingle([ctrl.templateId], { - folderType: $scope.folderType, - }); - if (resp && resp.success) { - ctrl.selectedTemplate = resp.data; - ctrl.template = resp.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - }, - ], -}); - -modules.component("serviceHubPortal", { - templateUrl: - "/mix-app/views/app-portal/components/service-hub-portal/view.html", - bindings: { - mixDatabaseName: "=", - isSave: "=?", - }, - controller: [ - "$rootScope", - "$scope", - "RestMixDatabaseColumnPortalService", - "RestMixDatabaseDataClientService", - "UserServices", - function ($rootScope, $scope, columnService, service, userServices) { - var ctrl = this; - BaseHub.call(this, ctrl); - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.user = { - loggedIn: false, - connection: {}, - }; - ctrl.mixDatabaseData = null; - ctrl.isHide = true; - ctrl.hideContact = true; - ctrl.columns = []; - ctrl.members = []; - ctrl.errors = []; - ctrl.messages = { - items: [], - }; - ctrl.message = { connection: {}, content: "" }; - ctrl.request = { - uid: "", - specificulture: "", - action: "", - objectType: null, - data: {}, - room: "", - isMyself: true, - isSave: false, - }; - ctrl.init = function () { - ctrl.mixDatabaseId = ctrl.mixDatabaseId || 0; - ctrl.request.specificulture = service.lang; - ctrl.request.room = ctrl.mixDatabaseName; - ctrl.request.isSave = ctrl.isSave == "true" || false; - ctrl.startConnection("serviceHub", ctrl.checkLoginStatus); - }; - ctrl.loadData = async function () { - /* - If input is data id => load ctrl.mixDatabaseData from service and handle it independently - Else modify input ctrl.mixDatabaseData - */ - $rootScope.isBusy = true; - var getDefault = await service.initData(ctrl.mixDatabaseName); - if (getDefault.success) { - ctrl.defaultData = getDefault.data; - ctrl.defaultData.data.user_name = ctrl.user.connection.name; - ctrl.defaultData.data.user_id = ctrl.user.connection.id; - ctrl.defaultData.data.user_avatar = ctrl.user.connection.avatar; - ctrl.defaultData.data.data_type = 9; - ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); - $rootScope.isBusy = false; - } - var getFields = await columnService.initData(ctrl.mixDatabaseName); - if (getFields.success) { - ctrl.columns = getFields.data; - } - }; - ctrl.submit = async function () { - if (ctrl.validate()) { - ctrl.request.action = "send_group_message"; - ctrl.request.uid = ctrl.user.connection.id; - ctrl.request.data = ctrl.mixDatabaseData.data; - ctrl.request.connection = ctrl.user.connection; - ctrl.connection.invoke("HandleRequest", JSON.stringify(ctrl.request)); - ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); - } + // ctrl.folderType, + // ]); + // if (resp && resp.success) { + // resp.data.fileName = "new"; + // ctrl.templates.splice(0, 0, resp.data); + + // $rootScope.isBusy = false; + // $scope.$apply(); + // } else { + // if (resp) { + // $rootScope.showErrors(resp.errors); + // $rootScope.isBusy = false; + // $scope.$apply(); + // } + // } + // } }; - ctrl.validate = function () { - var isValid = true; - ctrl.errors = []; - angular.forEach(ctrl.columns, function (column) { - if (column.regex) { - var regex = RegExp(column.regex, "g"); - isValid = regex.test(ctrl.mixDatabaseData.data[column.name]); - if (!isValid) { - ctrl.errors.push(`${column.name} is not match Regex`); - } - } - if (isValid && column.isEncrypt) { - ctrl.mixDatabaseData.data[column.name] = $rootScope.encrypt( - ctrl.mixDatabaseData.data[column.name] + ctrl.loadTemplates = async function () { + ctrl.request.folderType = ctrl.folderType; + ctrl.request.themeId = ctrl.theme.id; + ctrl.request.pageSize = 1000; + let getTemplates = await service.getList(ctrl.request); + ctrl.templates = getTemplates.data.items; + ctrl.templates.splice(0, 0, { id: null, fileName: "" }); + if (!ctrl.templateId && ctrl.templates.length > 1) { + if (ctrl.defaultTemplate) { + ctrl.template = ctrl.templates.find( + (m) => m.fileName == ctrl.defaultTemplate ); + ctrl.templateId = ctrl.template.id; + ctrl.selectedTemplate = ctrl.template; + } + if (!ctrl.template) { + ctrl.template = ctrl.templates[1]; + ctrl.templateId = ctrl.templates[1].id; + ctrl.selectedTemplate = ctrl.template; } - }); - return isValid; - }; - ctrl.receiveMessage = function (msg) { - switch (msg.responseKey) { - case "NewMember": - ctrl.newMember(msg.data); - // $('.widget-conversation').scrollTop = $('.widget-conversation')[0].scrollHeight; - break; - case "NewMessage": - ctrl.newMessage(msg.data); - break; - case "ConnectSuccess": - ctrl.user.loggedIn = true; - ctrl.initListMember(msg.data); - $scope.$apply(); - break; - case "PreviousMessages": - ctrl.messages = msg.data; - $scope.$apply(); - break; - case "MemberOffline": - ctrl.removeMember(msg.data); - break; - case "Error": - console.error(msg.data); - break; - } - }; - ctrl.newMessage = function (msg) { - ctrl.messages.items.push(msg); - $scope.$apply(); - }; - ctrl.newMember = function (member) { - var m = $rootScope.findObjectByKey(ctrl.members, "id", member.id); - if (!m) { - ctrl.members.push(member); } $scope.$apply(); }; - ctrl.join = async function () { - ctrl.request.action = "join_group"; - ctrl.request.uid = ctrl.user.connection.id; - ctrl.request.data = ctrl.user.connection; - ctrl.message.connection = ctrl.user.connection; - ctrl.connection.invoke("HandleRequest", JSON.stringify(ctrl.request)); - await ctrl.loadData(); - $scope.$apply(); + ctrl.loadThemes = async () => { + let getThemes = await themeService.getList(ctrl.themeRequest); + ctrl.themes = getThemes.data.items; + ctrl.theme = !ctrl.templateId + ? ctrl.themes[0] + : ctrl.themes.filter((m) => m.id == ctrl.template.mixThemeId)[0]; }; - ctrl.initListMember = function (data) { - data.forEach((member) => { - var index = ctrl.members.findIndex((x) => x.id === member.id); - if (index < 0) { - ctrl.members.splice(0, 0, member); + ctrl.loadTemplate = async () => { + if (ctrl.templateId) { + var resp = await service.getSingle([ctrl.templateId], { + folderType: $scope.folderType, + }); + if (resp && resp.success) { + ctrl.selectedTemplate = resp.data; + ctrl.template = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); } - }); - - $scope.$apply(); - }; - - ctrl.checkLoginStatus = async function () { - var response = await userServices.getMyProfile(); - ctrl.user.connection.name = response.data.username; - ctrl.user.connection.id = response.data.id; - ctrl.user.connection.connectionId = ctrl.connection.connectionId; - ctrl.user.connection.avatar = response.data.avatar; - ctrl.user.loggedIn = true; - ctrl.join(); + } }; }, ], @@ -16114,6 +16114,67 @@ modules.component("toastHelper", { ], }); +modules.component("urlAlias", { + templateUrl: "/mix-app/views/app-portal/components/url-alias/url-alias.html", + controller: [ + "$rootScope", + "$scope", + "UrlAliasService", + function ($rootScope, $scope, service) { + var ctrl = this; + ctrl.$onInit = function () { + ctrl.updateUrl(); + }; + ctrl.updateUrl = function () { + ctrl.url = + $rootScope.globalSettings.domain + + "/" + + $rootScope.mixConfigurations.lang + + "/" + + ctrl.urlAlias.alias; + }; + ctrl.remove = function () { + if (ctrl.urlAlias.id > 0) { + $rootScope.showConfirm( + ctrl, + "removeConfirmed", + [ctrl.urlAlias.id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + } else { + if (ctrl.removeCallback) { + ctrl.removeCallback({ index: ctrl.index }); + } + } + }; + + ctrl.removeConfirmed = async function (id) { + $rootScope.isBusy = true; + var result = await service.delete(id); + if (result.success) { + if (ctrl.removeCallback) { + ctrl.removeCallback({ index: ctrl.index }); + } + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], + bindings: { + urlAlias: "=", + index: "=", + callback: "&", + removeCallback: "&", + }, +}); + app.factory("ConnectionManager", [ function () { var serviceFactory = {}; @@ -16966,67 +17027,6 @@ app.factory("ViewModel", [ }, ]); -modules.component("urlAlias", { - templateUrl: "/mix-app/views/app-portal/components/url-alias/url-alias.html", - controller: [ - "$rootScope", - "$scope", - "UrlAliasService", - function ($rootScope, $scope, service) { - var ctrl = this; - ctrl.$onInit = function () { - ctrl.updateUrl(); - }; - ctrl.updateUrl = function () { - ctrl.url = - $rootScope.globalSettings.domain + - "/" + - $rootScope.mixConfigurations.lang + - "/" + - ctrl.urlAlias.alias; - }; - ctrl.remove = function () { - if (ctrl.urlAlias.id > 0) { - $rootScope.showConfirm( - ctrl, - "removeConfirmed", - [ctrl.urlAlias.id], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - } else { - if (ctrl.removeCallback) { - ctrl.removeCallback({ index: ctrl.index }); - } - } - }; - - ctrl.removeConfirmed = async function (id) { - $rootScope.isBusy = true; - var result = await service.delete(id); - if (result.success) { - if (ctrl.removeCallback) { - ctrl.removeCallback({ index: ctrl.index }); - } - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, - ], - bindings: { - urlAlias: "=", - index: "=", - callback: "&", - removeCallback: "&", - }, -}); - !(function (t) { var e = {}; function i(n) {