From 579c110a6b6ce8dc23a7924dca69b174b045bb22 Mon Sep 17 00:00:00 2001 From: Eric Nguyen Date: Thu, 19 Oct 2023 18:53:57 +0700 Subject: [PATCH] fix bugs --- .github/workflows/develop_dev-mixcore.yml | 12 +- .../Domain/Services/MixSEORouteTransformer.cs | 2 +- .../wwwroot/mix-app/js/app-portal.min.js | 3830 ++++++++--------- .../app-portal/pages/application/details.html | 2 +- .../Domain/Services/MixApplicationService.cs | 21 +- src/modules/mix.portal/mix.portal.csproj | 4 + .../MixBackgroundTaskSubscriber.cs | 13 +- 7 files changed, 1943 insertions(+), 1941 deletions(-) diff --git a/.github/workflows/develop_dev-mixcore.yml b/.github/workflows/develop_dev-mixcore.yml index ed3737fdb..c13e32463 100644 --- a/.github/workflows/develop_dev-mixcore.yml +++ b/.github/workflows/develop_dev-mixcore.yml @@ -6,13 +6,13 @@ name: Build and deploy ASP.Net Core app to Azure Web App - dev-mixcore on: push: branches: - - develop + - features/move-install-app-to-queue workflow_dispatch: jobs: build: runs-on: windows-latest - + steps: - uses: actions/checkout@v2 with: @@ -20,7 +20,7 @@ jobs: - name: Set up .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: '7.x' + dotnet-version: "7.x" include-prerelease: true - name: Build with dotnet @@ -39,7 +39,7 @@ jobs: runs-on: windows-latest needs: build environment: - name: 'Production' + name: "Production" url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} steps: @@ -52,7 +52,7 @@ jobs: id: deploy-to-webapp uses: azure/webapps-deploy@v2 with: - app-name: 'dev-mixcore' - slot-name: 'Production' + app-name: "dev-mixcore" + slot-name: "Production" publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_401AAB0F55D04A1ABCF859E4A8B1463E }} package: . diff --git a/src/applications/Mixcore/Domain/Services/MixSEORouteTransformer.cs b/src/applications/Mixcore/Domain/Services/MixSEORouteTransformer.cs index 021b77c95..5c6766a86 100644 --- a/src/applications/Mixcore/Domain/Services/MixSEORouteTransformer.cs +++ b/src/applications/Mixcore/Domain/Services/MixSEORouteTransformer.cs @@ -26,7 +26,7 @@ public override ValueTask TransformAsync( var language = (string)values[keys[0]]; string seoName = string.Empty; - if (_tenantService.AllCultures.Any(m => m.Specificulture == language)) + if (_tenantService.AllCultures != null && _tenantService.AllCultures.Any(m => m.Specificulture == language)) { seoName = string.Join('/', values.Values.Skip(1)); } 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 402910c9c..f0b0df340 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 @@ -/* Wed Oct 18 2023 20:25:46 GMT+0700 (Indochina Time) */"use strict"; +/* Thu Oct 19 2023 18:51:13 GMT+0700 (Indochina Time) */"use strict"; var app = angular.module("MixPortal", [ "angularCroppie", "ui.bootstrap", @@ -342,6 +342,250 @@ app.factory("AppSettingsServices", [ }, ]); +"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(); + + setTimeout(() => { + $("body,html").animate( + { + scrollTop: $("#log-stream-container").height(), // Scroll to top of body + }, + 500 + ); + }, 200); + }; + $scope.getMessageType = function (type) { + switch (type) { + case "Success": + return "success"; + case "Error": + return "danger"; + case "Warning": + return "warning"; + case "Info": + return "info"; + default: + return "default"; + } + }; + $scope.view = function (item) { + item.objClass = item.success ? "text-success" : "text-danger"; + $rootScope.preview("object", item, null, "modal-lg"); + }; + }, +]); + +"use strict"; +app.factory("AuditLogRestService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.initService("/rest", "mix-log/audit-log", true); + var _search = async function (objData, queries = null) { + var data = serviceFactory.parseQuery(objData); + + var url = `${this.prefixUrl}/search`; + + if (data) { + url += "?"; + url = url.concat(data); + if (queries) { + url += "&"; + var extraQueries = serviceFactory.parseQuery(queries); + url = url.concat(extraQueries); + } + } + var req = { + serviceBase: this.serviceBase, + apiVersion: this.apiVersion, + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + serviceFactory.getList = _search; + return serviceFactory; + }, +]); + +"use strict"; +app.controller("ConfigurationController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "ConfigurationService", + "ApiService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + apiService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.init = function () { + $scope.request.category = $routeParams.category || ""; + $scope.getList(); + }; + $scope.getSingleSuccessCallback = function () { + $scope.cates = ngAppSettings.enums?.configuration_cates; + $scope.appSettings = $rootScope.globalSettings; + $scope.request.category = $routeParams.category || ""; + if (!$scope.viewmodel.id) { + $scope.viewmodel.dataType = "Text"; + } + if (!$scope.viewmodel.category) { + $scope.viewmodel.category = "Site"; + } + }; + $scope.saveSuccessCallback = function () { + apiService.getAllSettings().then(function () { + // $location.url($scope.referrerUrl); + $rootScope.isBusy = false; + $scope.$apply(); + }); + }; + $scope.removeCallback = function () { + apiService.getAllSettings().then(function () { + $location.url($scope.referrerUrl); + }); + }; + + $scope.generateName = function () { + $scope.viewmodel.keyword = $rootScope.generateKeyword( + $scope.viewmodel.keyword, + "_", + true + ); + }; + }, +]); + +"use strict"; +app.factory("ConfigurationService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("configuration"); + + var _uploadConfiguration = async function (configurationFile) { + //var container = $(this).parents('.model-configuration').first().find('.custom-file').first(); + if ( + configurationFile.file !== undefined && + configurationFile.file !== null + ) { + // Create FormData object + var files = new FormData(); + + // Looping over all files and add it to FormData object + files.append(configurationFile.file.name, configurationFile.file); + + // Adding one more key to FormData object + files.append("fileFolder", configurationFile.folder); + files.append("title", configurationFile.title); + files.append("description", configurationFile.description); + + var req = { + url: this.prefixUrl + "/upload", + type: "POST", + headers: {}, + contentType: false, // Not to set any content header + processData: false, // Not to process data + data: files, + }; + + return await apiService.sendRequest(req); + } + }; + serviceFactory.uploadConfiguration = _uploadConfiguration; + return serviceFactory; + }, +]); + "use strict"; app.controller("MixApplicationController", [ "$scope", @@ -419,9 +663,8 @@ app.controller("MixApplicationController", [ $scope.installStatus = "Downloading"; var resp = await service.install($scope.viewmodel); if (resp && resp.success) { - $scope.data = resp.data; $rootScope.isBusy = false; - $location.url("/admin/mix-application/list"); + $("html, body").animate({ scrollTop: "0px" }, 500); $scope.$apply(); } else { if (resp) { @@ -434,6 +677,7 @@ app.controller("MixApplicationController", [ $scope.restore = async function () { $rootScope.isBusy = true; $scope.installStatus = "Restoring"; + $("html, body").animate({ scrollTop: "0px" }, 500); var resp = await service.restore({ appId: $scope.viewmodel.id, packageFilePath: $scope.viewmodel.appSettings.activePackage, @@ -559,269 +803,25 @@ app.factory("MixApplicationRestService", [ ]); "use strict"; -app.controller("ConfigurationController", [ +app.controller("CultureController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", - "$location", - "ConfigurationService", + "CultureService", + "CommonService", "ApiService", function ( $scope, $rootScope, ngAppSettings, $routeParams, - $location, service, + commonService, apiService ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.init = function () { - $scope.request.category = $routeParams.category || ""; - $scope.getList(); - }; - $scope.getSingleSuccessCallback = function () { - $scope.cates = ngAppSettings.enums?.configuration_cates; - $scope.appSettings = $rootScope.globalSettings; - $scope.request.category = $routeParams.category || ""; - if (!$scope.viewmodel.id) { - $scope.viewmodel.dataType = "Text"; - } - if (!$scope.viewmodel.category) { - $scope.viewmodel.category = "Site"; - } - }; - $scope.saveSuccessCallback = function () { - apiService.getAllSettings().then(function () { - // $location.url($scope.referrerUrl); - $rootScope.isBusy = false; - $scope.$apply(); - }); - }; - $scope.removeCallback = function () { - apiService.getAllSettings().then(function () { - $location.url($scope.referrerUrl); - }); - }; - - $scope.generateName = function () { - $scope.viewmodel.keyword = $rootScope.generateKeyword( - $scope.viewmodel.keyword, - "_", - true - ); - }; - }, -]); - -"use strict"; -app.factory("ConfigurationService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("configuration"); - - var _uploadConfiguration = async function (configurationFile) { - //var container = $(this).parents('.model-configuration').first().find('.custom-file').first(); - if ( - configurationFile.file !== undefined && - configurationFile.file !== null - ) { - // Create FormData object - var files = new FormData(); - - // Looping over all files and add it to FormData object - files.append(configurationFile.file.name, configurationFile.file); - - // Adding one more key to FormData object - files.append("fileFolder", configurationFile.folder); - files.append("title", configurationFile.title); - files.append("description", configurationFile.description); - - var req = { - url: this.prefixUrl + "/upload", - type: "POST", - headers: {}, - contentType: false, // Not to set any content header - processData: false, // Not to process data - data: files, - }; - - return await apiService.sendRequest(req); - } - }; - serviceFactory.uploadConfiguration = _uploadConfiguration; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("AuditLogController", [ - "$scope", - "$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(); - - setTimeout(() => { - $("body,html").animate( - { - scrollTop: $("#log-stream-container").height(), // Scroll to top of body - }, - 500 - ); - }, 200); - }; - $scope.getMessageType = function (type) { - switch (type) { - case "Success": - return "success"; - case "Error": - return "danger"; - case "Warning": - return "warning"; - case "Info": - return "info"; - default: - return "default"; - } - }; - $scope.view = function (item) { - item.objClass = item.success ? "text-success" : "text-danger"; - $rootScope.preview("object", item, null, "modal-lg"); - }; - }, -]); - -"use strict"; -app.factory("AuditLogRestService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.initService("/rest", "mix-log/audit-log", true); - var _search = async function (objData, queries = null) { - var data = serviceFactory.parseQuery(objData); - - var url = `${this.prefixUrl}/search`; - - if (data) { - url += "?"; - url = url.concat(data); - if (queries) { - url += "&"; - var extraQueries = serviceFactory.parseQuery(queries); - url = url.concat(extraQueries); - } - } - var req = { - serviceBase: this.serviceBase, - apiVersion: this.apiVersion, - method: "GET", - url: url, - }; - return await this.getRestApiResult(req); - }; - serviceFactory.getList = _search; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("CultureController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "CultureService", - "CommonService", - "ApiService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - service, - commonService, - apiService - ) { - $scope.selected = null; - BaseCtrl.call( + $scope.selected = null; + BaseCtrl.call( this, $scope, $rootScope, @@ -885,6 +885,97 @@ app.factory("CultureService", [ }, ]); +"use strict"; +app.controller("DashboardController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$timeout", + "$location", + "DashboardServices", + function ( + $scope, + $rootScope, + ngAppSettings, + $timeout, + $location, + dashboardServices + ) { + $scope.pageClass = "page-dashboard"; + $(".side-nav li").removeClass("active"); + $(".side-nav .page-dashboard").addClass("active"); + $scope.data = { + totalPage: 0, + totalPost: 0, + totalProduct: 0, + totalUser: 0, + }; + $scope.users = []; + $scope.$on("$viewContentLoaded", function () { + $rootScope.isBusy = false; + }); + $scope.getDashboardInfo = async function () { + $rootScope.isBusy = true; + // var response = await dashboardServices.getDashboardInfo(); + // if (response.success) { + // // $('#mainSection').removeClass('card'); + // $scope.data = response.data; + // $rootScope.isBusy = false; + // $scope.$apply(); + // // $scope.getChart(); + // } else { + // $rootScope.showErrors(response.errors); + // $rootScope.isBusy = false; + // $scope.$apply(); + // } + }; + $scope.getChart = function () { + var ctx = document.getElementById("myChart"); + var myChart = new Chart(ctx, { + // type: 'pie', + // data: { + // labels: ["Africa", "Asia", "Europe", "Latin America", "North America"], + // datasets: [{ + // label: "Population (millions)", + // backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"], + // data: [2478,5267,734,784,433] + // }] + // }, + // options: { + // title: { + // display: true, + // text: 'Predicted world population (millions) in 2050' + // } + // } + }); + }; + }, +]); + +"use strict"; +app.factory("DashboardServices", [ + "$rootScope", + "$http", + "ApiService", + "CommonService", + function ($rootScope, $http, apiService, commonService) { + //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; + + var usersServiceFactory = {}; + var apiUrl = "/rest/portal/common/" + $rootScope.globalSettings.lang; + var _getDashboardInfo = async function () { + var req = { + method: "GET", + url: apiUrl + "/dashboard", + }; + return await apiService.sendRequest(req); + }; + + usersServiceFactory.getDashboardInfo = _getDashboardInfo; + return usersServiceFactory; + }, +]); + "use strict"; app.controller("CustomerController", [ "$scope", @@ -988,192 +1079,101 @@ app.controller("CustomerController", [ $scope.loadCustomers(); } else { $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.saveCustomer = async function (customer) { - customer.content = $(".editor-content").val(); - var resp = await customerServices.saveCustomer(customer); - if (resp && resp.success) { - $scope.activedCustomer = resp.data; - $rootScope.showMessage("Update successfully!", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - //$location.path('/admin/customer/details/' + resp.data.id); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.factory("CustomerServices", [ - "$http", - "$rootScope", - "ApiService", - "CommonService", - function ($http, $rootScope, apiService, commonService) { - //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; - - var customersServiceFactory = {}; - - var settings = $rootScope.globalSettings; - - var _getCustomer = async function (id, type) { - var apiUrl = "/queen-beauty/customer/"; - var url = apiUrl + "details/" + type; - if (id) { - url += "/" + id; - } - var req = { - method: "GET", - url: url, - }; - return await apiService.sendRequest(req); - }; - - var _initCustomer = async function (type) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "GET", - url: apiUrl + "init/" + type, - }; - return await apiService.sendRequest(req); - }; - - var _getCustomers = async function (request) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "POST", - url: apiUrl + "list", - data: JSON.stringify(request), - }; - - return await apiService.sendRequest(req); - }; - - var _removeCustomer = async function (id) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "GET", - url: apiUrl + "delete/" + id, - }; - return await apiService.sendRequest(req); - }; - - var _saveCustomer = async function (customer) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "POST", - url: apiUrl + "save", - data: JSON.stringify(customer), - }; - return await apiService.sendRequest(req); - }; - - customersServiceFactory.getCustomer = _getCustomer; - customersServiceFactory.initCustomer = _initCustomer; - customersServiceFactory.getCustomers = _getCustomers; - customersServiceFactory.removeCustomer = _removeCustomer; - customersServiceFactory.saveCustomer = _saveCustomer; - return customersServiceFactory; - }, -]); - -"use strict"; -app.controller("DashboardController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$timeout", - "$location", - "DashboardServices", - function ( - $scope, - $rootScope, - ngAppSettings, - $timeout, - $location, - dashboardServices - ) { - $scope.pageClass = "page-dashboard"; - $(".side-nav li").removeClass("active"); - $(".side-nav .page-dashboard").addClass("active"); - $scope.data = { - totalPage: 0, - totalPost: 0, - totalProduct: 0, - totalUser: 0, - }; - $scope.users = []; - $scope.$on("$viewContentLoaded", function () { - $rootScope.isBusy = false; - }); - $scope.getDashboardInfo = async function () { - $rootScope.isBusy = true; - // var response = await dashboardServices.getDashboardInfo(); - // if (response.success) { - // // $('#mainSection').removeClass('card'); - // $scope.data = response.data; - // $rootScope.isBusy = false; - // $scope.$apply(); - // // $scope.getChart(); - // } else { - // $rootScope.showErrors(response.errors); - // $rootScope.isBusy = false; - // $scope.$apply(); - // } - }; - $scope.getChart = function () { - var ctx = document.getElementById("myChart"); - var myChart = new Chart(ctx, { - // type: 'pie', - // data: { - // labels: ["Africa", "Asia", "Europe", "Latin America", "North America"], - // datasets: [{ - // label: "Population (millions)", - // backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"], - // data: [2478,5267,734,784,433] - // }] - // }, - // options: { - // title: { - // display: true, - // text: 'Predicted world population (millions) in 2050' - // } - // } - }); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.saveCustomer = async function (customer) { + customer.content = $(".editor-content").val(); + var resp = await customerServices.saveCustomer(customer); + if (resp && resp.success) { + $scope.activedCustomer = resp.data; + $rootScope.showMessage("Update successfully!", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + //$location.path('/admin/customer/details/' + resp.data.id); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $scope.$apply(); + } }; }, ]); "use strict"; -app.factory("DashboardServices", [ - "$rootScope", +app.factory("CustomerServices", [ "$http", + "$rootScope", "ApiService", "CommonService", - function ($rootScope, $http, apiService, commonService) { + function ($http, $rootScope, apiService, commonService) { //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; - var usersServiceFactory = {}; - var apiUrl = "/rest/portal/common/" + $rootScope.globalSettings.lang; - var _getDashboardInfo = async function () { + var customersServiceFactory = {}; + + var settings = $rootScope.globalSettings; + + var _getCustomer = async function (id, type) { + var apiUrl = "/queen-beauty/customer/"; + var url = apiUrl + "details/" + type; + if (id) { + url += "/" + id; + } var req = { method: "GET", - url: apiUrl + "/dashboard", + url: url, }; return await apiService.sendRequest(req); }; - usersServiceFactory.getDashboardInfo = _getDashboardInfo; - return usersServiceFactory; + var _initCustomer = async function (type) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "GET", + url: apiUrl + "init/" + type, + }; + return await apiService.sendRequest(req); + }; + + var _getCustomers = async function (request) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "POST", + url: apiUrl + "list", + data: JSON.stringify(request), + }; + + return await apiService.sendRequest(req); + }; + + var _removeCustomer = async function (id) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "GET", + url: apiUrl + "delete/" + id, + }; + return await apiService.sendRequest(req); + }; + + var _saveCustomer = async function (customer) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "POST", + url: apiUrl + "save", + data: JSON.stringify(customer), + }; + return await apiService.sendRequest(req); + }; + + customersServiceFactory.getCustomer = _getCustomer; + customersServiceFactory.initCustomer = _initCustomer; + customersServiceFactory.getCustomers = _getCustomers; + customersServiceFactory.removeCustomer = _removeCustomer; + customersServiceFactory.saveCustomer = _saveCustomer; + return customersServiceFactory; }, ]); @@ -1888,62 +1888,207 @@ app.controller("loginController", [ ) { window.top.location = document.referrer; } else { - window.top.location = "/"; + window.top.location = "/"; + } + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + + $scope.authExternalProvider = function (provider) { + var redirectUri = + location.protocol + "//" + location.host + "/authcomplete.html"; + + var externalProviderUrl = + ngAuthSettings.apiServiceBaseUri + + "api/Account/ExternalLogin?provider=" + + provider + + "&response_type=token&client_id=" + + ngAuthSettings.clientId + + "&redirect_uri=" + + redirectUri; + window.$windowScope = $scope; + + var oauthWindow = window.open( + externalProviderUrl, + "Authenticate Account", + "location=0,status=0,width=600,height=750" + ); + }; + + $scope.authCompletedCB = function (fragment) { + $scope.$apply(function () { + if (fragment.haslocalaccount === "False") { + authService.logOut(); + + authService.externalAuthData = { + provider: fragment.provider, + username: fragment.external_user_name, + externalAccessToken: fragment.external_access_token, + }; + + $location.path("/associate"); + } else { + //Obtain access token and redirect to orders + var externalData = { + provider: fragment.provider, + externalAccessToken: fragment.external_access_token, + }; + authService.obtainAccessToken(externalData).then( + function (response) { + $location.path("/orders"); + }, + function (err) { + $scope.message = err.error_description; + } + ); + } + }); + }; + }, +]); + +"use strict"; +app.controller("MixDatabaseController", [ + "$scope", + "$rootScope", + "$location", + "ngAppSettings", + "$routeParams", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + "RestMixDatabasePortalService", + "RestMixDatabaseContextService", + function ( + $scope, + $rootScope, + $location, + ngAppSettings, + $routeParams, + databaseDataService, + databaseColumnService, + databaseService, + dbContextService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + databaseService + ); + $scope.defaultAttr = null; + $scope.actions = ["Delete"]; + $scope.viewmodelType = "mix-database"; + // $scope.request.selects = 'id,title,name,createdDateTime'; + $scope.orders = [ + { title: "Id", value: "Id" }, + { title: "Name", value: "Name" }, + { title: "Created Date", value: "CreatedDateTime" }, + ]; + $scope.request.orderBy = "CreatedDateTime"; + $scope.request.columns = "id,displayName,systemName,type,createdDatetime"; + $scope.request.searchColumns = "displayName,systemName"; + $scope.saveDatabase = function () { + $scope.save($scope.viewmodel); + }; + + $scope.getSingleSuccessCallback = async function () { + $scope.viewmodel.mixDatabaseContextId = $routeParams.mixDatabaseContextId; + if ($scope.viewmodel.mixDatabaseContextId) { + var resp = await dbContextService.getSingle([ + $scope.viewmodel.mixDatabaseContextId, + ]); + if (resp.success) { + $scope.dbContext = resp.data; + } + } + if (!$scope.defaultAttr) { + var getDefaultAttr = await databaseColumnService.getDefault(); + if (getDefaultAttr.success) { + $scope.defaultAttr = getDefaultAttr.data; + $scope.defaultAttr.options = []; + } + $scope.$apply(); + } + }; + $scope.migrate = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.migrate($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + "Please restart pool to apply new db schema", + "warning" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot migrate database"]); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + $scope.backup = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.backup($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + `Backup ${$scope.viewmodel.systemName} is queued`, + "success" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot backup database"]); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + $scope.restore = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.restore($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + `Restore ${$scope.viewmodel.systemName} is queued`, + "success" + ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot restore database"]); + $rootScope.isBusy = false; + $scope.$apply(); } } - $rootScope.isBusy = false; - $scope.$apply(); - }; - - $scope.authExternalProvider = function (provider) { - var redirectUri = - location.protocol + "//" + location.host + "/authcomplete.html"; - - var externalProviderUrl = - ngAuthSettings.apiServiceBaseUri + - "api/Account/ExternalLogin?provider=" + - provider + - "&response_type=token&client_id=" + - ngAuthSettings.clientId + - "&redirect_uri=" + - redirectUri; - window.$windowScope = $scope; - - var oauthWindow = window.open( - externalProviderUrl, - "Authenticate Account", - "location=0,status=0,width=600,height=750" - ); }; - - $scope.authCompletedCB = function (fragment) { - $scope.$apply(function () { - if (fragment.haslocalaccount === "False") { - authService.logOut(); - - authService.externalAuthData = { - provider: fragment.provider, - username: fragment.external_user_name, - externalAccessToken: fragment.external_access_token, - }; - - $location.path("/associate"); - } else { - //Obtain access token and redirect to orders - var externalData = { - provider: fragment.provider, - externalAccessToken: fragment.external_access_token, - }; - authService.obtainAccessToken(externalData).then( - function (response) { - $location.path("/orders"); - }, - function (err) { - $scope.message = err.error_description; - } + $scope.updateSchema = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.updateSchema($scope.viewmodel); + if (result.success) { + $rootScope.showMessage( + "Please restart pool to apply new db schema", + "warning" ); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot update database"]); + $rootScope.isBusy = false; + $scope.$apply(); } - }); + } + }; + + $scope.back = function () { + window.history.back(); }; }, ]); @@ -2221,225 +2366,80 @@ app.controller("MixDatabaseDataController", [ $scope.queries = {}; } $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - if ($scope.getListFailCallback) { - $scope.getListFailCallback(); - } - $scope.queries = {}; - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.export = async function (pageIndex, exportAll) { - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } - if ($scope.request.fromDate !== null) { - var df = new Date($scope.request.fromDate); - $scope.request.fromDate = df.toISOString(); - } - if ($scope.request.toDate !== null) { - var dt = new Date($scope.request.toDate); - $scope.request.toDate = dt.toISOString(); - } - var query = {}; - if ($routeParams.mixDatabaseId) { - $scope.request.mixDatabaseId = $routeParams.mixDatabaseId; - } - $scope.request.mixDatabaseName = $routeParams.mixDatabaseName; - $scope.request.filterType = $routeParams.filterType || "contain"; - $scope.request.queries = []; - - Object.keys($scope.queries).forEach((e) => { - if ($scope.queries[e]) { - $scope.request.queries.push({ - fieldName: e, - value: $scope.queries[e], - }); - } - }); - var request = angular.copy($scope.request); - $scope.exportAll = $scope.exportAll; - if (exportAll) { - request.pageSize = 10000; - request.pageIndex = 0; - } - $rootScope.isBusy = true; - var resp = await mixDbService.export(request); - if (resp && resp.success) { - if (resp.data) { - window.top.location = resp.data.webPath; - } else { - $rootScope.showMessage("Nothing to export"); - } - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.migrate = async function () { - if ($routeParams.mixDatabaseId) { - $rootScope.isBusy = true; - var result = await service.migrate($routeParams.mixDatabaseId); - $scope.handleResult(result); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.controller("MixDatabaseController", [ - "$scope", - "$rootScope", - "$location", - "ngAppSettings", - "$routeParams", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "RestMixDatabasePortalService", - "RestMixDatabaseContextService", - function ( - $scope, - $rootScope, - $location, - ngAppSettings, - $routeParams, - databaseDataService, - databaseColumnService, - databaseService, - dbContextService - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - databaseService - ); - $scope.defaultAttr = null; - $scope.actions = ["Delete"]; - $scope.viewmodelType = "mix-database"; - // $scope.request.selects = 'id,title,name,createdDateTime'; - $scope.orders = [ - { title: "Id", value: "Id" }, - { title: "Name", value: "Name" }, - { title: "Created Date", value: "CreatedDateTime" }, - ]; - $scope.request.orderBy = "CreatedDateTime"; - $scope.request.columns = "id,displayName,systemName,type,createdDatetime"; - $scope.request.searchColumns = "displayName,systemName"; - $scope.saveDatabase = function () { - $scope.save($scope.viewmodel); - }; - - $scope.getSingleSuccessCallback = async function () { - $scope.viewmodel.mixDatabaseContextId = $routeParams.mixDatabaseContextId; - if ($scope.viewmodel.mixDatabaseContextId) { - var resp = await dbContextService.getSingle([ - $scope.viewmodel.mixDatabaseContextId, - ]); - if (resp.success) { - $scope.dbContext = resp.data; - } - } - if (!$scope.defaultAttr) { - var getDefaultAttr = await databaseColumnService.getDefault(); - if (getDefaultAttr.success) { - $scope.defaultAttr = getDefaultAttr.data; - $scope.defaultAttr.options = []; - } - $scope.$apply(); - } - }; - $scope.migrate = async function () { - if ($scope.viewmodel.id) { - $rootScope.isBusy = true; - var result = await databaseService.migrate($scope.viewmodel); - if (result.success) { - $rootScope.showMessage( - "Please restart pool to apply new db schema", - "warning" - ); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot migrate database"]); - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - $scope.backup = async function () { - if ($scope.viewmodel.id) { - $rootScope.isBusy = true; - var result = await databaseService.backup($scope.viewmodel); - if (result.success) { - $rootScope.showMessage( - `Backup ${$scope.viewmodel.systemName} is queued`, - "success" - ); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot backup database"]); - $rootScope.isBusy = false; - $scope.$apply(); + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); } + if ($scope.getListFailCallback) { + $scope.getListFailCallback(); + } + $scope.queries = {}; + $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.export = async function (pageIndex, exportAll) { + if (pageIndex !== undefined) { + $scope.request.pageIndex = pageIndex; + } + if ($scope.request.fromDate !== null) { + var df = new Date($scope.request.fromDate); + $scope.request.fromDate = df.toISOString(); + } + if ($scope.request.toDate !== null) { + var dt = new Date($scope.request.toDate); + $scope.request.toDate = dt.toISOString(); + } + var query = {}; + if ($routeParams.mixDatabaseId) { + $scope.request.mixDatabaseId = $routeParams.mixDatabaseId; + } + $scope.request.mixDatabaseName = $routeParams.mixDatabaseName; + $scope.request.filterType = $routeParams.filterType || "contain"; + $scope.request.queries = []; + + Object.keys($scope.queries).forEach((e) => { + if ($scope.queries[e]) { + $scope.request.queries.push({ + fieldName: e, + value: $scope.queries[e], + }); } + }); + var request = angular.copy($scope.request); + $scope.exportAll = $scope.exportAll; + if (exportAll) { + request.pageSize = 10000; + request.pageIndex = 0; } - }; - $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(); + $rootScope.isBusy = true; + var resp = await mixDbService.export(request); + if (resp && resp.success) { + if (resp.data) { + window.top.location = resp.data.webPath; } else { - $rootScope.showErrors(["Cannot update database"]); - $rootScope.isBusy = false; - $scope.$apply(); + $rootScope.showMessage("Nothing to export"); + } + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); } + $rootScope.isBusy = false; + $scope.$apply(); } }; - $scope.back = function () { - window.history.back(); + $scope.migrate = async function () { + if ($routeParams.mixDatabaseId) { + $rootScope.isBusy = true; + var result = await service.migrate($routeParams.mixDatabaseId); + $scope.handleResult(result); + $rootScope.isBusy = false; + $scope.$apply(); + } }; }, ]); @@ -3034,174 +3034,11 @@ app.controller("ModuleGalleryController", [ $rootScope.isBusy = true; var id = $routeParams.id; $scope.moduleContentId = $routeParams.id; - $scope.request.query = "&moduleContentId=" + id; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; - var response = await service.getList($scope.request); - if (response.success) { - $scope.data = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.remove = function (moduleContentId, postId) { - $rootScope.showConfirm( - $scope, - "removeConfirmed", - [moduleContentId, postId], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeConfirmed = async function (moduleContentId, postId) { - $rootScope.isBusy = true; - var result = await service.delete(moduleContentId, 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.removeCallback = function () {}; - - $scope.saveOthers = async function () { - var response = await service.saveList($scope.others); - if (response.success) { - $scope.getList(); - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.updateInfos = async function (index) { - $scope.data.items.splice(index, 1); - $rootScope.isBusy = true; - var startIndex = $scope.data.items[0].priority - 1; - for (var i = 0; i < $scope.data.items.length; i++) { - $scope.data.items[i].priority = startIndex + i + 1; - } - var resp = await service.updateInfos($scope.data.items); - if (resp && resp.success) { - $scope.activedPage = resp.data; - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.factory("ModuleGalleryService", [ - "$rootScope", - "ApiService", - "CommonService", - "BaseService", - function ($rootScope, apiService, commonService, baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("module-post"); - var _delete = async function (moduleContentId, postId) { - var url = this.prefixUrl + "/delete/" + moduleContentId + "/" + postId; - var req = { - method: "GET", - url: url, - }; - return await apiService.sendRequest(req); - }; - var _updateInfos = async function (modules) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(modules), - }; - return await apiService.sendRequest(req); - }; - serviceFactory.delete = _delete; - serviceFactory.updateInfos = _updateInfos; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("ModulePostController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "ModulePostRestService", - "ApiService", - "CommonService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service, - commonService - ) { - BaseCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - $scope.request.culture = $rootScope.globalSettings.defaultCulture; - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.mixConfigurations = $rootScope.globalSettings; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.translate = $rootScope.translate; - $scope.moduleIds = $routeParams.moduleIds || $routeParams.id; - $scope.pageIds = $routeParams.page_ids; - $scope.type = $routeParams.type; - $scope.template = $routeParams.template || ""; - - $scope.init = function () { - $scope.createUrl = `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; - $scope.getList(); - }; - $scope.getList = async function (pageIndex) { - $rootScope.isBusy = true; - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } - var id = $routeParams.id; - $scope.moduleContentId = $routeParams.id; - $scope.request.parentId = id; + $scope.request.query = "&moduleContentId=" + id; $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - var response = await service.search($scope.request); + var response = await service.getList($scope.request); if (response.success) { $scope.data = response.data; $rootScope.isBusy = false; @@ -3212,24 +3049,20 @@ app.controller("ModulePostController", [ $scope.$apply(); } }; - $scope.preview = function (item) { - item.editUrl = "/admin/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); - }; - $scope.remove = function (id) { + $scope.remove = function (moduleContentId, postId) { $rootScope.showConfirm( $scope, "removeConfirmed", - [id], + [moduleContentId, postId], null, "Remove", "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; - $scope.removeConfirmed = async function (id) { + $scope.removeConfirmed = async function (moduleContentId, postId) { $rootScope.isBusy = true; - var result = await service.delete(id); + var result = await service.delete(moduleContentId, postId); if (result.success) { if ($scope.removeCallback) { $rootScope.executeFunctionByName( @@ -3284,37 +3117,20 @@ app.controller("ModulePostController", [ ]); "use strict"; -app.factory("ModulePostRestService", [ +app.factory("ModuleGalleryService", [ "$rootScope", "ApiService", "CommonService", - "BaseRestService", + "BaseService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); serviceFactory.init("module-post"); - - var _search = async function (objData) { - var data = serviceFactory.parseQuery(objData); - var url = this.prefixUrl; - - if (data) { - url += "/search?"; - url = url.concat(data); - } + var _delete = async function (moduleContentId, postId) { + var url = this.prefixUrl + "/delete/" + moduleContentId + "/" + postId; var req = { - serviceBase: this.serviceBase, method: "GET", url: url, }; - return await this.getRestApiResult(req); - }; - - var _delete = async function (id) { - var url = this.prefixUrl + "/" + id; - var req = { - method: "DELETE", - url: url, - }; return await apiService.sendRequest(req); }; var _updateInfos = async function (modules) { @@ -3325,7 +3141,6 @@ app.factory("ModulePostRestService", [ }; return await apiService.sendRequest(req); }; - serviceFactory.search = _search; serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; return serviceFactory; @@ -3661,116 +3476,301 @@ app.controller("PageController", [ 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.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", [ + "$rootScope", + "ApiService", + "CommonService", + "BaseRestService", + function ($rootScope, apiService, commonService, baseService) { + var serviceFactory = Object.create(baseService); + 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.sendRequest(req); + }; + serviceFactory.updateInfos = _updateInfos; + return serviceFactory; + }, +]); + +"use strict"; +app.controller("ModulePostController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "ModulePostRestService", + "ApiService", + "CommonService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + commonService + ) { + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + $scope.request.culture = $rootScope.globalSettings.defaultCulture; + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.mixConfigurations = $rootScope.globalSettings; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.translate = $rootScope.translate; + $scope.moduleIds = $routeParams.moduleIds || $routeParams.id; + $scope.pageIds = $routeParams.page_ids; + $scope.type = $routeParams.type; + $scope.template = $routeParams.template || ""; + + $scope.init = function () { + $scope.createUrl = `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; + $scope.getList(); + }; + $scope.getList = async function (pageIndex) { + $rootScope.isBusy = true; + if (pageIndex !== undefined) { + $scope.request.pageIndex = pageIndex; + } + var id = $routeParams.id; + $scope.moduleContentId = $routeParams.id; + $scope.request.parentId = id; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; + var response = await service.search($scope.request); + if (response.success) { + $scope.data = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.preview = function (item) { + item.editUrl = "/admin/post/details/" + item.id; + $rootScope.preview("post", item, item.title, "modal-lg"); + }; + $scope.remove = function (id) { + $rootScope.showConfirm( + $scope, + "removeConfirmed", + [id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + + $scope.removeConfirmed = async function (id) { + $rootScope.isBusy = true; + var result = await service.delete(id); + if (result.success) { + if ($scope.removeCallback) { + $rootScope.executeFunctionByName( + "removeCallback", + $scope.removeCallbackArgs, + $scope + ); + } + $scope.getList(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; - // $scope.viewmodel.createdDateTime = Date.now(); - $scope.viewmodel.createdBy = $rootScope.authentication.username; + $scope.removeCallback = function () {}; - $rootScope.isBusy = false; + $scope.saveOthers = async function () { + var response = await service.saveList($scope.others); + if (response.success) { + $scope.getList(); $scope.$apply(); } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - if ($scope.getSingleFailCallback) { - $scope.getSingleFailCallback(); - } + $rootScope.showErrors(response.errors); $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); + $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; } - return result.success; - }; - $scope.saveColumns = async function () { - let result = await columnService.saveMany($scope.additionalData.columns); - if (result.success) { + 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 { - $rootScope.showErrors(getAlias.errors); + if (resp) { + $rootScope.showErrors(resp.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("ModulePostRestService", [ "$rootScope", "ApiService", "CommonService", "BaseRestService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-page-content"); - var _updateInfos = async function (pages) { + serviceFactory.init("module-post"); + + var _search = async function (objData) { + var data = serviceFactory.parseQuery(objData); + var url = this.prefixUrl; + + if (data) { + url += "/search?"; + url = url.concat(data); + } + var req = { + serviceBase: this.serviceBase, + method: "GET", + url: url, + }; + return await this.getRestApiResult(req); + }; + + var _delete = async function (id) { + var url = this.prefixUrl + "/" + id; + var req = { + method: "DELETE", + url: url, + }; + return await apiService.sendRequest(req); + }; + var _updateInfos = async function (modules) { var req = { method: "POST", url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), + data: JSON.stringify(modules), }; return await apiService.sendRequest(req); }; + serviceFactory.search = _search; + serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; return serviceFactory; }, @@ -7171,20 +7171,6 @@ app.component("appSettingsGeneral", { }, }); -app.component("appSettingsSmtp", { - templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/smtp/view.html", - controller: [ - "ngAppSettings", - function (ngAppSettings) { - var ctrl = this; - }, - ], - bindings: { - appSettings: "=", - }, -}); - modules.component("portalMenus", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/portal-menus/view.html", @@ -7217,6 +7203,20 @@ modules.component("portalMenus", { ], }); +app.component("appSettingsSmtp", { + templateUrl: + "/mix-app/views/app-portal/pages/app-settings/components/smtp/view.html", + controller: [ + "ngAppSettings", + function (ngAppSettings) { + var ctrl = this; + }, + ], + bindings: { + appSettings: "=", + }, +}); + app.component("customerMain", { templateUrl: "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", @@ -7351,25 +7351,6 @@ app.component("mixdbContextDatabases", { ], }); -app.component("moduleAdvanced", { - templateUrl: - "/mix-app/views/app-portal/pages/module/components/module-advanced/view.html", - bindings: { - model: "=", - additionalData: "=", - }, - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - }; - }, - ], -}); - app.component("moduleMain", { templateUrl: "/mix-app/views/app-portal/pages/module/components/main/main.html", @@ -7419,6 +7400,25 @@ app.component("moduleContent", { ], }); +app.component("moduleAdvanced", { + templateUrl: + "/mix-app/views/app-portal/pages/module/components/module-advanced/view.html", + bindings: { + model: "=", + additionalData: "=", + }, + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + }; + }, + ], +}); + app.component("moduleType", { templateUrl: "/mix-app/views/app-portal/pages/module/components/module-type/view.html", @@ -7584,27 +7584,6 @@ app.component("pageMain", { }, }); -app.component("pageAdvanced", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/page-advanced/view.html", - bindings: { - model: "=", - additionalData: "=", - }, - controller: [ - "$rootScope", - "$scope", - function ($rootScope, $scope) { - var ctrl = this; - - ctrl.translate = $rootScope.translate; - ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - }; - }, - ], -}); - app.component("pageModules", { templateUrl: "/mix-app/views/app-portal/pages/page/components/modules/modules.html", @@ -7650,6 +7629,27 @@ app.component("pageModules", { ], }); +app.component("pageAdvanced", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/page-advanced/view.html", + bindings: { + model: "=", + additionalData: "=", + }, + controller: [ + "$rootScope", + "$scope", + function ($rootScope, $scope) { + var ctrl = this; + + ctrl.translate = $rootScope.translate; + ctrl.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + }; + }, + ], +}); + app.component("pageContent", { templateUrl: "/mix-app/views/app-portal/pages/page/components/page-content/view.html", @@ -7695,6 +7695,16 @@ app.component("pageContent", { ], }); +app.component("pageParents", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/parents/parents.html", + bindings: { + page: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("pageType", { templateUrl: "/mix-app/views/app-portal/pages/page/components/page-type/view.html", @@ -7710,9 +7720,9 @@ app.component("pageType", { ], }); -app.component("pageParents", { +app.component("pagePlugPlay", { templateUrl: - "/mix-app/views/app-portal/pages/page/components/parents/parents.html", + "/mix-app/views/app-portal/pages/page/components/plug-play/plug-play.html", bindings: { page: "=", onDelete: "&", @@ -7720,9 +7730,17 @@ app.component("pageParents", { }, }); -app.component("pagePlugPlay", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/plug-play/plug-play.html", +app.component("pageSeo", { + templateUrl: "/mix-app/views/app-portal/pages/page/components/seo/seo.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.translate = function (keyword) { + return $rootScope.translate(keyword); + }; + }, + ], bindings: { page: "=", onDelete: "&", @@ -7766,24 +7784,6 @@ app.component("productRelated", { }, }); -app.component("pageSeo", { - templateUrl: "/mix-app/views/app-portal/pages/page/components/seo/seo.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.translate = function (keyword) { - return $rootScope.translate(keyword); - }; - }, - ], - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - app.component("permissionMain", { templateUrl: "/mix-app/views/app-portal/pages/permission/components/main/main.html", @@ -7832,105 +7832,6 @@ app.component("permissionParents", { }, }); -app.component("permissionPlugPlay", { - templateUrl: - "/mix-app/views/app-portal/pages/permission/components/plug-play/plug-play.html", - bindings: { - page: "=", - prefixParent: "=", - prefixChild: "=", - searchText: "=", - onDelete: "&", - onUpdate: "&", - }, - controller: [ - "$rootScope", - "$scope", - "$location", - "$element", - "PermissionService", - function ($rootScope, $scope, $location, $element, service) { - var ctrl = this; - ctrl.type = "Children"; - ctrl.goToPath = $rootScope.goToPath; - ctrl.request = { - pageSize: "5", - pageIndex: 0, - status: "Published", - orderBy: "CreatedDateTime", - direction: "Desc", - fromDate: null, - toDate: null, - }; - ctrl.pages = []; - ctrl.init = function () { - if (ctrl.page) { - ctrl.request.exceptIds = ctrl.page.parentNavs - .map((p) => p.pageId) - .concat(ctrl.page.childNavs.map((p) => p.pageId)); - if (ctrl.request.exceptIds.indexOf(ctrl.page.id) === -1) { - ctrl.request.exceptIds.push(ctrl.page.id); - } - ctrl.getList(); - } - }; - ctrl.selectPane = function (pane) { - if (ctrl.page) { - ctrl.type = pane.header; - ctrl.request.keyword = ""; - ctrl.init(); - } - }; - - ctrl.selectItem = (nav) => { - if (ctrl.type == "Parents") { - if ( - !$rootScope.findObjectByKey(ctrl.page.parentNavs, "pageId", nav.id) - ) { - ctrl.page.parentNavs.push({ - isActived: true, - pageId: ctrl.page.id, - parentId: nav.id, - description: nav.textDefault, - status: "Published", - parent: nav, - }); - } - } else { - if ( - !$rootScope.findObjectByKey(ctrl.page.childNavs, "pageId", nav.id) - ) { - ctrl.page.childNavs.push({ - isActived: true, - pageId: nav.id, - parentId: ctrl.page.id, - description: nav.textDefault, - status: "Published", - page: nav, - }); - } - } - }; - - ctrl.getList = async function () { - $rootScope.isBusy = true; - var resp = await service.getList(ctrl.request); - if (resp && resp.success) { - ctrl.pages = resp.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors || ["Failed"]); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, - ], -}); - modules.component("postFilterList", { templateUrl: "/mix-app/views/app-portal/pages/post/components/filter-list/filter-list.html", @@ -8127,14 +8028,103 @@ app.component("postMedias", { }, }); -app.component("postParents", { +app.component("permissionPlugPlay", { templateUrl: - "/mix-app/views/app-portal/pages/post/components/parents/view.html", + "/mix-app/views/app-portal/pages/permission/components/plug-play/plug-play.html", bindings: { - post: "=", + page: "=", + prefixParent: "=", + prefixChild: "=", + searchText: "=", onDelete: "&", onUpdate: "&", }, + controller: [ + "$rootScope", + "$scope", + "$location", + "$element", + "PermissionService", + function ($rootScope, $scope, $location, $element, service) { + var ctrl = this; + ctrl.type = "Children"; + ctrl.goToPath = $rootScope.goToPath; + ctrl.request = { + pageSize: "5", + pageIndex: 0, + status: "Published", + orderBy: "CreatedDateTime", + direction: "Desc", + fromDate: null, + toDate: null, + }; + ctrl.pages = []; + ctrl.init = function () { + if (ctrl.page) { + ctrl.request.exceptIds = ctrl.page.parentNavs + .map((p) => p.pageId) + .concat(ctrl.page.childNavs.map((p) => p.pageId)); + if (ctrl.request.exceptIds.indexOf(ctrl.page.id) === -1) { + ctrl.request.exceptIds.push(ctrl.page.id); + } + ctrl.getList(); + } + }; + ctrl.selectPane = function (pane) { + if (ctrl.page) { + ctrl.type = pane.header; + ctrl.request.keyword = ""; + ctrl.init(); + } + }; + + ctrl.selectItem = (nav) => { + if (ctrl.type == "Parents") { + if ( + !$rootScope.findObjectByKey(ctrl.page.parentNavs, "pageId", nav.id) + ) { + ctrl.page.parentNavs.push({ + isActived: true, + pageId: ctrl.page.id, + parentId: nav.id, + description: nav.textDefault, + status: "Published", + parent: nav, + }); + } + } else { + if ( + !$rootScope.findObjectByKey(ctrl.page.childNavs, "pageId", nav.id) + ) { + ctrl.page.childNavs.push({ + isActived: true, + pageId: nav.id, + parentId: ctrl.page.id, + description: nav.textDefault, + status: "Published", + page: nav, + }); + } + } + }; + + ctrl.getList = async function () { + $rootScope.isBusy = true; + var resp = await service.getList(ctrl.request); + if (resp && resp.success) { + ctrl.pages = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors || ["Failed"]); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], }); app.component("postModules", { @@ -8230,27 +8220,131 @@ app.component("postModules", { }, }); -app.component("postAdvanced", { +app.component("postParents", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/parents/view.html", + bindings: { + post: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + +app.component("postAdvanced", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/post-advanced/view.html", + bindings: { + model: "=", + additionalData: "=", + }, + controller: [ + "$rootScope", + "$scope", + "$routeParams", + function ($rootScope, $scope, $routeParams) { + var ctrl = this; + ctrl.translate = $rootScope.translate; + ctrl.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + if ($routeParams.template) { + ctrl.defaultTemplate = $routeParams.template; + } + if ($routeParams.layout) { + ctrl.defaultLayout = $routeParams.layout; + } + }; + }, + ], +}); + +app.component("postContent", { templateUrl: - "/mix-app/views/app-portal/pages/post/components/post-advanced/view.html", + "/mix-app/views/app-portal/pages/post/components/post-content/view.html", bindings: { model: "=", additionalData: "=", + loadingData: "=", }, controller: [ "$rootScope", "$scope", - "$routeParams", - function ($rootScope, $scope, $routeParams) { + "ngAppSettings", + "PostRestService", + function ($rootScope, $scope, ngAppSettings, service) { var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); ctrl.translate = $rootScope.translate; + ctrl.relatedData = {}; ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - if ($routeParams.template) { - ctrl.defaultTemplate = $routeParams.template; + ctrl.backUrl = `/admin/post/details`; + }; + ctrl.generateSeo = function () { + if (ctrl.model) { + if (ctrl.model.seoName === null || ctrl.model.seoName === "") { + ctrl.model.seoName = $rootScope.generateKeyword( + ctrl.model.title, + "-" + ); + } + if (ctrl.model.seoTitle === null || ctrl.model.seoTitle === "") { + ctrl.model.seoTitle = ctrl.model.title; + } + if ( + ctrl.model.seoDescription === null || + ctrl.model.seoDescription === "" + ) { + ctrl.model.seoDescription = ctrl.model.excerpt; + } + if ( + ctrl.model.seoKeywords === null || + ctrl.model.seoKeywords === "" + ) { + ctrl.model.seoKeywords = ctrl.model.title; + } } - if ($routeParams.layout) { - ctrl.defaultLayout = $routeParams.layout; + }; + ctrl.getListRelated = async function (pageIndex) { + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; + } + if (ctrl.request.fromDate !== null) { + var d = new Date(ctrl.request.fromDate); + ctrl.request.fromDate = d.toISOString(); + } + if (ctrl.request.toDate !== null) { + var d = new Date(ctrl.request.toDate); + ctrl.request.toDate = d.toISOString(); + } + var resp = await service.getList(ctrl.request); + if (resp && resp.success) { + ctrl.relatedData = angular.copy(resp.data); + ctrl.relatedData.items = []; + angular.forEach(resp.data.items, (element) => { + var existed = $rootScope.findObjectByKey( + ctrl.model.postNavs, + ["sourceId", "destinationId"], + [ctrl.model.id, element.id] + ); + + var obj = { + description: element.title, + destinationId: element.id, + image: element.image, + isActived: existed !== null, + sourceId: ctrl.model.id, + specificulture: ctrl.model.specificulture, + status: "Published", + }; + + ctrl.relatedData.items.push(obj); + }); + console.log(ctrl.relatedData); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(getData.errors); + $rootScope.isBusy = false; + $scope.$apply(); } }; }, @@ -8398,100 +8492,6 @@ modules.component("relatedPosts", { ], }); -app.component("postContent", { - templateUrl: - "/mix-app/views/app-portal/pages/post/components/post-content/view.html", - bindings: { - model: "=", - additionalData: "=", - loadingData: "=", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "PostRestService", - function ($rootScope, $scope, ngAppSettings, service) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.translate = $rootScope.translate; - ctrl.relatedData = {}; - ctrl.$onInit = function () { - ctrl.backUrl = `/admin/post/details`; - }; - ctrl.generateSeo = function () { - if (ctrl.model) { - if (ctrl.model.seoName === null || ctrl.model.seoName === "") { - ctrl.model.seoName = $rootScope.generateKeyword( - ctrl.model.title, - "-" - ); - } - if (ctrl.model.seoTitle === null || ctrl.model.seoTitle === "") { - ctrl.model.seoTitle = ctrl.model.title; - } - if ( - ctrl.model.seoDescription === null || - ctrl.model.seoDescription === "" - ) { - ctrl.model.seoDescription = ctrl.model.excerpt; - } - if ( - ctrl.model.seoKeywords === null || - ctrl.model.seoKeywords === "" - ) { - ctrl.model.seoKeywords = ctrl.model.title; - } - } - }; - ctrl.getListRelated = async function (pageIndex) { - if (pageIndex !== undefined) { - ctrl.request.pageIndex = pageIndex; - } - if (ctrl.request.fromDate !== null) { - var d = new Date(ctrl.request.fromDate); - ctrl.request.fromDate = d.toISOString(); - } - if (ctrl.request.toDate !== null) { - var d = new Date(ctrl.request.toDate); - ctrl.request.toDate = d.toISOString(); - } - var resp = await service.getList(ctrl.request); - if (resp && resp.success) { - ctrl.relatedData = angular.copy(resp.data); - ctrl.relatedData.items = []; - angular.forEach(resp.data.items, (element) => { - var existed = $rootScope.findObjectByKey( - ctrl.model.postNavs, - ["sourceId", "destinationId"], - [ctrl.model.id, element.id] - ); - - var obj = { - description: element.title, - destinationId: element.id, - image: element.image, - isActived: existed !== null, - sourceId: ctrl.model.id, - specificulture: ctrl.model.specificulture, - status: "Published", - }; - - ctrl.relatedData.items.push(obj); - }); - console.log(ctrl.relatedData); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(getData.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, - ], -}); - app.component("postSeo", { templateUrl: "/mix-app/views/app-portal/pages/post/components/seo/view.html", bindings: { @@ -8911,76 +8911,6 @@ app.component("themeExportPages", { }, }); -app.component("themeImportCultures", { - templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope, ngAppSettings) { - var ctrl = this; - var service = $rootScope.getRestService("culture"); - ctrl.selectAllContent = false; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = async () => { - ctrl.getList(); - }; - ctrl.getList = async (cultureIndex) => { - if (cultureIndex !== undefined) { - ctrl.request.cultureIndex = cultureIndex; - } - if (ctrl.request.fromDate !== null) { - var d = new Date(ctrl.request.fromDate); - ctrl.request.fromDate = d.toISOString(); - } - if (ctrl.request.toDate !== null) { - var d = new Date(ctrl.request.toDate); - ctrl.request.toDate = d.toISOString(); - } - let getData = await service.getList(ctrl.request); - if (getData.success) { - ctrl.data = getData.data; - } - }; - ctrl.selectContent = (culture, selected) => { - ctrl.selectAllContent = ctrl.selectAllContent && selected; - ctrl.selectAllData = ctrl.selectAllData && selected; - culture.isImportData = selected && culture.isImportData; - ctrl.updateContent([culture.id], selected); - }; - ctrl.updateContent = function (arr, selected) { - if (selected) { - ctrl.importThemeDto.cultureIds = ctrl.unionArray( - ctrl.importThemeDto.cultureIds, - arr - ); - } else { - ctrl.importThemeDto.cultureIds = - ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); - ctrl.updateData(arr, false); - } - }; - ctrl.selectAll = function (arr) { - // ctrl.selectedList.data = []; - var ids = arr.map(function (obj) { - return obj.id; - }); - ctrl.updateContent(ids, ctrl.selectAllContent); - angular.forEach(arr, function (e) { - e.isActived = ctrl.selectAllContent; - }); - }; - ctrl.unionArray = (a, b) => { - return [...new Set([...a, ...b])]; - }; - }, - ], - bindings: { - importThemeDto: "=", - }, -}); - app.component("themeExportPosts", { templateUrl: "/mix-app/views/app-portal/pages/theme/components/theme-export-posts/view.html", @@ -9150,7 +9080,77 @@ app.component("themeImportMixDatabases", { return [...new Set([...a, ...b])]; }; }, - ], + ], +}); + +app.component("themeImportCultures", { + templateUrl: + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope, ngAppSettings) { + var ctrl = this; + var service = $rootScope.getRestService("culture"); + ctrl.selectAllContent = false; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = async () => { + ctrl.getList(); + }; + ctrl.getList = async (cultureIndex) => { + if (cultureIndex !== undefined) { + ctrl.request.cultureIndex = cultureIndex; + } + if (ctrl.request.fromDate !== null) { + var d = new Date(ctrl.request.fromDate); + ctrl.request.fromDate = d.toISOString(); + } + if (ctrl.request.toDate !== null) { + var d = new Date(ctrl.request.toDate); + ctrl.request.toDate = d.toISOString(); + } + let getData = await service.getList(ctrl.request); + if (getData.success) { + ctrl.data = getData.data; + } + }; + ctrl.selectContent = (culture, selected) => { + ctrl.selectAllContent = ctrl.selectAllContent && selected; + ctrl.selectAllData = ctrl.selectAllData && selected; + culture.isImportData = selected && culture.isImportData; + ctrl.updateContent([culture.id], selected); + }; + ctrl.updateContent = function (arr, selected) { + if (selected) { + ctrl.importThemeDto.cultureIds = ctrl.unionArray( + ctrl.importThemeDto.cultureIds, + arr + ); + } else { + ctrl.importThemeDto.cultureIds = + ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); + ctrl.updateData(arr, false); + } + }; + ctrl.selectAll = function (arr) { + // ctrl.selectedList.data = []; + var ids = arr.map(function (obj) { + return obj.id; + }); + ctrl.updateContent(ids, ctrl.selectAllContent); + angular.forEach(arr, function (e) { + e.isActived = ctrl.selectAllContent; + }); + }; + ctrl.unionArray = (a, b) => { + return [...new Set([...a, ...b])]; + }; + }, + ], + bindings: { + importThemeDto: "=", + }, }); app.component("themeImportModules", { @@ -9249,25 +9249,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); @@ -9282,39 +9282,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 ); @@ -9345,25 +9345,25 @@ app.component("themeImportPages", { }, }); -app.component("themeImportPosts", { +app.component("themeImportPages", { 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-pages/view.html", controller: [ "$rootScope", "$scope", "ngAppSettings", function ($rootScope, $scope, ngAppSettings) { var ctrl = this; - var service = $rootScope.getRestService("mix-post"); + 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 (postIndex) => { - if (postIndex !== undefined) { - ctrl.request.postIndex = postIndex; + ctrl.getList = async (pageIndex) => { + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; } if (ctrl.request.fromDate !== null) { var d = new Date(ctrl.request.fromDate); @@ -9378,39 +9378,39 @@ app.component("themeImportPosts", { ctrl.data = getData.data; } }; - ctrl.selectContent = (post, selected) => { + ctrl.selectContent = (page, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - post.isImportData = selected && post.isImportData; - let contentIds = post.contents.map(function (obj) { + page.isImportData = selected && page.isImportData; + let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.content.postIds = ctrl.updateArray( - ctrl.importThemeDto.content.postIds, - [post.id], + ctrl.importThemeDto.content.pageIds = ctrl.updateArray( + ctrl.importThemeDto.content.pageIds, + [page.id], selected ); - ctrl.importThemeDto.content.postContentIds = ctrl.updateArray( - ctrl.importThemeDto.content.postContentIds, + ctrl.importThemeDto.content.pageContentIds = ctrl.updateArray( + ctrl.importThemeDto.content.pageContentIds, contentIds, selected ); if (!selected) { - ctrl.selectData(post, false); + ctrl.selectData(page, false); } }; - ctrl.selectData = (post, selected) => { + ctrl.selectData = (page, selected) => { ctrl.selectAllData = ctrl.selectAllData && selected; - let contentIds = post.contents.map(function (obj) { + let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.associations.postIds = ctrl.updateArray( - ctrl.importThemeDto.associations.postIds, - [post.id], + ctrl.importThemeDto.associations.pageIds = ctrl.updateArray( + ctrl.importThemeDto.associations.pageIds, + [page.id], selected ); - ctrl.importThemeDto.associations.postContentIds = ctrl.updateArray( - ctrl.importThemeDto.associations.postContentIds, + ctrl.importThemeDto.associations.pageContentIds = ctrl.updateArray( + ctrl.importThemeDto.associations.pageContentIds, contentIds, selected ); @@ -11321,6 +11321,30 @@ app.controller("HubMessagesController", [ }, ]); +modules.component("jumbotrons", { + templateUrl: + "/mix-app/views/app-portal/components/jumbotrons/jumbotrons.html", + controller: [ + "$rootScope", + "$scope", + "$location", + function ($rootScope, $scope, $location) { + var ctrl = this; + ctrl.translate = function (keyword) { + return $rootScope.translate(keyword); + }; + // ctrl.back = function () { + // ctrl.backUrl = ctrl.backUrl || '/admin'; + // $location.path(ctrl.backUrl); + // }; + }, + ], + bindings: { + tagName: "=", + tagType: "=", + }, +}); + // const { data } = require("jquery"); modules.component("listMixColumn", { @@ -11505,90 +11529,31 @@ modules.component("listMixColumn", { } else { ctrl.columns.splice(ctrl.dragStartIndex + 1, 1); } - angular.forEach(ctrl.columns, function (e, i) { - e.priority = i; - }); - $scope.$apply(); - }; - ctrl.dragStart = function (index) { - ctrl.dragStartIndex = index; - }; - ctrl.showReferences = function (col) { - ctrl.colRef = col; - $("#modal-navs").modal("show"); - }; - ctrl.showRelationships = function () { - $("#modal-relationships").modal("show"); - }; - - ctrl.referenceCallback = function (selected) { - if (selected && selected.length) { - ctrl.colRef.reference = selected; - ctrl.colRef.referenceId = selected[0].id; - } - $("#modal-navs").modal("hide"); - }; - }, - ], -}); - -modules.component("jumbotrons", { - templateUrl: - "/mix-app/views/app-portal/components/jumbotrons/jumbotrons.html", - controller: [ - "$rootScope", - "$scope", - "$location", - function ($rootScope, $scope, $location) { - var ctrl = this; - ctrl.translate = function (keyword) { - return $rootScope.translate(keyword); - }; - // ctrl.back = function () { - // ctrl.backUrl = ctrl.backUrl || '/admin'; - // $location.path(ctrl.backUrl); - // }; - }, - ], - bindings: { - tagName: "=", - tagType: "=", - }, -}); - -modules.component("mainSideBar", { - templateUrl: - "/mix-app/views/app-portal/components/main-side-bar/main-side-bar.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "TranslatorService", - "ApiService", - "CommonService", - function ( - $rootScope, - $scope, - ngAppSettings, - translatorService, - apiService, - commonService - ) { - var ctrl = this; - ctrl.items = []; - ctrl.init = async function () { - var resp = await apiService.getPortalMenus(); - if (resp.success && resp.data && resp.data.length) { - ctrl.items = resp.data; - } else { - ctrl.items = JSON.parse($("#portal-menus").val()).items; - } + angular.forEach(ctrl.columns, function (e, i) { + e.priority = i; + }); + $scope.$apply(); + }; + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + }; + ctrl.showReferences = function (col) { + ctrl.colRef = col; + $("#modal-navs").modal("show"); + }; + ctrl.showRelationships = function () { + $("#modal-relationships").modal("show"); + }; + + ctrl.referenceCallback = function (selected) { + if (selected && selected.length) { + ctrl.colRef.reference = selected; + ctrl.colRef.referenceId = selected[0].id; + } + $("#modal-navs").modal("hide"); }; }, ], - bindings: { - items: "=?", - }, }); modules.component("logStream", { @@ -11683,6 +11648,41 @@ app.controller("LogStreamController", [ }, ]); +modules.component("mainSideBar", { + templateUrl: + "/mix-app/views/app-portal/components/main-side-bar/main-side-bar.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "TranslatorService", + "ApiService", + "CommonService", + function ( + $rootScope, + $scope, + ngAppSettings, + translatorService, + apiService, + commonService + ) { + var ctrl = this; + ctrl.items = []; + ctrl.init = async function () { + var resp = await apiService.getPortalMenus(); + if (resp.success && resp.data && resp.data.length) { + ctrl.items = resp.data; + } else { + ctrl.items = JSON.parse($("#portal-menus").val()).items; + } + }; + }, + ], + bindings: { + items: "=?", + }, +}); + modules.component("mainSideBarDynamic", { templateUrl: "/mix-app/views/app-portal/components/main-side-bar-dynamic/main-side-bar-dynamic.html", @@ -13558,96 +13558,6 @@ modules.component("mixDatabaseNavValues", { ], }); -modules.component("mixFileExtract", { - templateUrl: - "/mix-app/views/app-portal/components/mix-file-extract/view.html", - bindings: { - folder: "=?", - accept: "=?", - onFail: "&?", - onSuccess: "&?", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "FileServices", - function ($rootScope, $scope, ngAppSettings, fileService) { - var ctrl = this; - ctrl.mediaFile = {}; - ctrl.isAdmin = $rootScope.isAdmin; - ctrl.mediaNavs = []; - ctrl.$onInit = function () { - ctrl.id = Math.floor(Math.random() * 100); - }; - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - const file = files[0]; - ctrl.file = file; - ctrl.mediaFile.folder = ctrl.folder ? ctrl.folder : "Media"; - ctrl.mediaFile.title = ctrl.title ? ctrl.title : ""; - ctrl.mediaFile.description = ctrl.description ? ctrl.description : ""; - ctrl.mediaFile.file = file; - if (ctrl.auto == "true") { - ctrl.uploadFile(file); - } else { - ctrl.getBase64(file); - } - } - }; - - ctrl.getBase64 = function (file) { - if (file !== null) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = function () { - if (ctrl.mediaFile) { - ctrl.mediaFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.fileStream = reader.result; - } - $rootScope.isBusy = false; - $scope.$apply(); - }; - reader.onerror = function (error) { - $rootScope.isBusy = false; - $rootScope.showErrors([error]); - }; - } else { - return null; - } - }; - - ctrl.uploadFile = async function () { - if (ctrl.file) { - $rootScope.isBusy = true; - var response = await fileService.extractFile(ctrl.file, ctrl.folder); - if (response) { - if (ctrl.onSuccess) { - ctrl.onSuccess(); - } - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot upload file"]); - $rootScope.isBusy = false; - $scope.$apply(); - } - } else { - $rootScope.showErrors(["Please choose file"]); - } - }; - }, - ], -}); - modules.component("mixDatabaseNavs", { templateUrl: "/mix-app/views/app-portal/components/mix-database-navs/view.html", @@ -13766,54 +13676,144 @@ modules.component("mixDatabaseNavs", { $rootScope.isBusy = false; $scope.$apply(); } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + ctrl.update = function (data) { + ctrl.onUpdate({ + data: data, + }); + }; + + ctrl.delete = function (data) { + ctrl.onDelete({ + data: data, + }); + }; + + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + ctrl.minPriority = ctrl.mixDatabaseNavs[0].priority; + }; + ctrl.updateOrders = function (index) { + if (index > ctrl.dragStartIndex) { + ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex, 1); + } else { + ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex + 1, 1); + } + var arrNavs = []; + angular.forEach(ctrl.mixDatabaseNavs, function (e, i) { + e.priority = ctrl.minPriority + i; + var keys = { + parentId: e.parentId, + parentType: e.parentType, + id: e.id, + }; + var properties = { + priority: e.priority, + }; + arrNavs.push({ + keys: keys, + properties: properties, + }); + }); + navService.saveProperties("portal", arrNavs).then((resp) => { + $rootScope.isBusy = false; + $scope.$apply(); + }); + }; + }, + ], +}); + +modules.component("mixFileExtract", { + templateUrl: + "/mix-app/views/app-portal/components/mix-file-extract/view.html", + bindings: { + folder: "=?", + accept: "=?", + onFail: "&?", + onSuccess: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "FileServices", + function ($rootScope, $scope, ngAppSettings, fileService) { + var ctrl = this; + ctrl.mediaFile = {}; + ctrl.isAdmin = $rootScope.isAdmin; + ctrl.mediaNavs = []; + ctrl.$onInit = function () { + ctrl.id = Math.floor(Math.random() * 100); + }; + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + const file = files[0]; + ctrl.file = file; + ctrl.mediaFile.folder = ctrl.folder ? ctrl.folder : "Media"; + ctrl.mediaFile.title = ctrl.title ? ctrl.title : ""; + ctrl.mediaFile.description = ctrl.description ? ctrl.description : ""; + ctrl.mediaFile.file = file; + if (ctrl.auto == "true") { + ctrl.uploadFile(file); + } else { + ctrl.getBase64(file); + } + } + }; + + ctrl.getBase64 = function (file) { + if (file !== null) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function () { + if (ctrl.mediaFile) { + ctrl.mediaFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.fileStream = reader.result; + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + reader.onerror = function (error) { + $rootScope.isBusy = false; + $rootScope.showErrors([error]); + }; + } else { + return null; } }; - ctrl.update = function (data) { - ctrl.onUpdate({ - data: data, - }); - }; - - ctrl.delete = function (data) { - ctrl.onDelete({ - data: data, - }); - }; - - ctrl.dragStart = function (index) { - ctrl.dragStartIndex = index; - ctrl.minPriority = ctrl.mixDatabaseNavs[0].priority; - }; - ctrl.updateOrders = function (index) { - if (index > ctrl.dragStartIndex) { - ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex, 1); + ctrl.uploadFile = async function () { + if (ctrl.file) { + $rootScope.isBusy = true; + var response = await fileService.extractFile(ctrl.file, ctrl.folder); + if (response) { + if (ctrl.onSuccess) { + ctrl.onSuccess(); + } + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot upload file"]); + $rootScope.isBusy = false; + $scope.$apply(); + } } else { - ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex + 1, 1); + $rootScope.showErrors(["Please choose file"]); } - var arrNavs = []; - angular.forEach(ctrl.mixDatabaseNavs, function (e, i) { - e.priority = ctrl.minPriority + i; - var keys = { - parentId: e.parentId, - parentType: e.parentType, - id: e.id, - }; - var properties = { - priority: e.priority, - }; - arrNavs.push({ - keys: keys, - properties: properties, - }); - }); - navService.saveProperties("portal", arrNavs).then((resp) => { - $rootScope.isBusy = false; - $scope.$apply(); - }); }; }, ], @@ -14729,232 +14729,74 @@ modules.component("modalNavDatas", { $scope.$apply(); } } - if (!ctrl.data) { - await ctrl.loadData(); - } - }; - ctrl.select = async (item) => { - $rootScope.isBusy = true; - if (item.isSelected && (ctrl.parentId || ctrl.guidParentId)) { - ctrl.association.childId = item.id; - let result = await associationService.save(ctrl.association); - if (result.success) { - item.associationId = result.data.id; - } - $rootScope.handleResponse(result); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - let result = await associationService.deleteAssociation( - ctrl.parentDatabaseName, - ctrl.mixDatabaseName, - ctrl.parentId, - ctrl.guidParentId, - item.id - ); - $rootScope.handleResponse(result); - $rootScope.isBusy = false; - $scope.$apply(); - } - if (ctrl.selectCallback) { - ctrl.selectCallback(); - } - }; - - ctrl.filter = function () { - ctrl.data = []; - ctrl.loadData(); - }; - ctrl.loadData = async function () { - dataService.initDbName(ctrl.mixDatabaseName); - ctrl.request.queries = []; - if (ctrl.queries) { - Object.keys(ctrl.queries).forEach((e) => { - if (ctrl.queries[e]) { - ctrl.request.queries.push({ - fieldName: e, - value: ctrl.queries[e], - compareOperator: 'Like', - }); - } - }); - } - var getData = await dataService.filter(ctrl.request); - ctrl.data = getData.data; - angular.forEach(ctrl.data.items, (e) => { - if (ctrl.selectedIds.includes(e.id)) { - e.isSelected = true; - } - }); - $scope.$apply(); - }; - ctrl.update = function (data) { - let url = `/admin/mix-database-data/details?dataContentId=${ - data.id - }&mixDatabaseName=${ctrl.mixDatabaseName}&mixDatabaseTitle=${ - ctrl.mixDatabaseTitle - }&parentId=${ctrl.parentId || ""}&parentName=${ - ctrl.parentName || "" - }&guidParentId=${ctrl.guidParentId || ""}`; - $location.url(url); - }; - }, - ], -}); - -modules.component("modalNavPosts", { - templateUrl: - "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", - bindings: { - srcColumn: "=", - srcId: "=", - query: "=", - selected: "=", - save: "&", - }, - controller: [ - "$rootScope", - "$scope", - "$routeParams", - "ngAppSettings", - "PostRestService", - function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.navs = []; - ctrl.associations = []; - ctrl.data = { items: [] }; - ctrl.loadPosts = async function (pageIndex) { - // ctrl.request.query = ctrl.query + ctrl.srcId; - if (pageIndex !== undefined) { - ctrl.request.pageIndex = pageIndex; - } - if (ctrl.request.fromDate !== null) { - var d = new Date(ctrl.request.fromDate); - ctrl.request.fromDate = d.toISOString(); - } - if (ctrl.request.toDate !== null) { - var d = new Date(ctrl.request.toDate); - ctrl.request.toDate = d.toISOString(); - } - if ($routeParams.type) { - ctrl.request.postType = $routeParams.type; - } else { - ctrl.request.postType = ""; - } - var response = await postService.getList(ctrl.request); - if (response.success) { - ctrl.data = response.data; - // ctrl.navs = []; - // angular.forEach(response.data.items, function (e) { - // var item = { - // priority: e.priority, - // description: e.title, - // postId: e.id, - // image: e.thumbnailUrl, - // specificulture: e.specificulture, - // post: e, - // status: "Published", - // isActived: false, - // }; - // item[ctrl.srcColumn] = ctrl.srcId; - // ctrl.navs.push(item); - // }); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - ctrl.select = async (associations) => { - ctrl.associations = associations; - }; - ctrl.saveSelected = function () { - ctrl.selected = $rootScope.filterArray( - ctrl.navs, - ["isActived"], - [true] - ); - setTimeout(() => { - ctrl.save().then(() => { - ctrl.loadPosts(); - }); - }, 500); - }; - }, - ], -}); - -modules.component("modalNavPages", { - templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", - bindings: { - srcField: "=", - srcId: "=", - query: "=", - selected: "=", - save: "&", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "PageRestService", - function ($rootScope, $scope, ngAppSettings, pageService) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.navs = []; - ctrl.data = { items: [] }; - ctrl.loadData = async function (pageIndex) { - ctrl.request.query = ctrl.query + ctrl.srcId; - if (pageIndex !== undefined) { - ctrl.request.pageIndex = pageIndex; - } - if (ctrl.request.fromDate !== null) { - var d = new Date(ctrl.request.fromDate); - ctrl.request.fromDate = d.toISOString(); - } - if (ctrl.request.toDate !== null) { - var d = new Date(ctrl.request.toDate); - ctrl.request.toDate = d.toISOString(); + if (!ctrl.data) { + await ctrl.loadData(); } - var response = await pageService.getList(ctrl.request); - if (response.success) { - ctrl.data = response.data; - ctrl.navs = []; - angular.forEach(response.data.items, function (e) { - var item = { - priority: e.priority, - description: e.title, - pageId: e.id, - image: e.thumbnailUrl, - specificulture: e.specificulture, - status: "Published", - isActived: false, - }; - item[ctrl.srcField] = ctrl.srcId; - ctrl.navs.push(item); - }); + }; + ctrl.select = async (item) => { + $rootScope.isBusy = true; + if (item.isSelected && (ctrl.parentId || ctrl.guidParentId)) { + ctrl.association.childId = item.id; + let result = await associationService.save(ctrl.association); + if (result.success) { + item.associationId = result.data.id; + } + $rootScope.handleResponse(result); $rootScope.isBusy = false; $scope.$apply(); } else { - $rootScope.showErrors(response.errors); + let result = await associationService.deleteAssociation( + ctrl.parentDatabaseName, + ctrl.mixDatabaseName, + ctrl.parentId, + ctrl.guidParentId, + item.id + ); + $rootScope.handleResponse(result); $rootScope.isBusy = false; $scope.$apply(); } + if (ctrl.selectCallback) { + ctrl.selectCallback(); + } }; - ctrl.saveSelected = function () { - ctrl.selected = $rootScope.filterArray( - ctrl.navs, - ["isActived"], - [true] - ); - setTimeout(() => { - ctrl.save().then(() => { - ctrl.loadPages(); + + ctrl.filter = function () { + ctrl.data = []; + ctrl.loadData(); + }; + ctrl.loadData = async function () { + dataService.initDbName(ctrl.mixDatabaseName); + ctrl.request.queries = []; + if (ctrl.queries) { + Object.keys(ctrl.queries).forEach((e) => { + if (ctrl.queries[e]) { + ctrl.request.queries.push({ + fieldName: e, + value: ctrl.queries[e], + compareOperator: 'Like', + }); + } }); - }, 500); + } + var getData = await dataService.filter(ctrl.request); + ctrl.data = getData.data; + angular.forEach(ctrl.data.items, (e) => { + if (ctrl.selectedIds.includes(e.id)) { + e.isSelected = true; + } + }); + $scope.$apply(); + }; + ctrl.update = function (data) { + let url = `/admin/mix-database-data/details?dataContentId=${ + data.id + }&mixDatabaseName=${ctrl.mixDatabaseName}&mixDatabaseTitle=${ + ctrl.mixDatabaseTitle + }&parentId=${ctrl.parentId || ""}&parentName=${ + ctrl.parentName || "" + }&guidParentId=${ctrl.guidParentId || ""}`; + $location.url(url); }; }, ], @@ -15189,66 +15031,224 @@ modules.component("modalNavMetas", { $scope.$apply(); } } - - if (!isSelected) { - await ctrl.removeNav(idx); - if (ctrl.selectCallback) { - ctrl.selectCallback({ data: nav }); - } - return; + + if (!isSelected) { + await ctrl.removeNav(idx); + if (ctrl.selectCallback) { + ctrl.selectCallback({ data: nav }); + } + return; + } + }; + ctrl.removeNav = async function (idx) { + var nav = ctrl.selectedList.items[idx]; + ctrl.selectedValues.splice(idx, 1); + ctrl.selectedList.items.splice(idx, 1); + ctrl.filterData(); + if (nav && nav.id) { + await navService.delete([nav.id]); + $rootScope.showMessage("success", "success"); + $scope.$apply(); + } + }; + ctrl.disableNavitem = function (nav, isDisable) { + nav.disabled = isDisable; + }; + ctrl.createData = function () { + if (ctrl.newTitle) { + var tmp = $rootScope.findObjectByKey( + ctrl.data.items, + "title", + ctrl.newTitle + ); + if (!tmp) { + ctrl.isBusy = true; + ctrl.mixDatabaseData.intParentId = 0; + ctrl.mixDatabaseData.parentType = "Set"; + ctrl.mixDatabaseData.data.title = ctrl.newTitle; + ctrl.mixDatabaseData.data.slug = $rootScope.generateKeyword( + ctrl.newTitle, + "-" + ); + ctrl.mixDatabaseData.data.type = ctrl.type; + dataService.save(ctrl.mixDatabaseData).then((resp) => { + if (resp.success) { + ctrl.mixDatabaseData.id = resp.data; + ctrl.data.items.push(ctrl.mixDatabaseData); + ctrl.reload(); + ctrl.select(resp.data.id, true); + ctrl.filterData(); + ctrl.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(resp.errors); + ctrl.isBusy = false; + $scope.$apply(); + } + }); + } else { + tmp.isActived = true; + ctrl.select(tmp); + } + } + }; + }, + ], +}); + +modules.component("modalNavPages", { + templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", + bindings: { + srcField: "=", + srcId: "=", + query: "=", + selected: "=", + save: "&", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "PageRestService", + function ($rootScope, $scope, ngAppSettings, pageService) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.navs = []; + ctrl.data = { items: [] }; + ctrl.loadData = async function (pageIndex) { + ctrl.request.query = ctrl.query + ctrl.srcId; + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; + } + if (ctrl.request.fromDate !== null) { + var d = new Date(ctrl.request.fromDate); + ctrl.request.fromDate = d.toISOString(); + } + if (ctrl.request.toDate !== null) { + var d = new Date(ctrl.request.toDate); + ctrl.request.toDate = d.toISOString(); + } + var response = await pageService.getList(ctrl.request); + if (response.success) { + ctrl.data = response.data; + ctrl.navs = []; + angular.forEach(response.data.items, function (e) { + var item = { + priority: e.priority, + description: e.title, + pageId: e.id, + image: e.thumbnailUrl, + specificulture: e.specificulture, + status: "Published", + isActived: false, + }; + item[ctrl.srcField] = ctrl.srcId; + ctrl.navs.push(item); + }); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + ctrl.saveSelected = function () { + ctrl.selected = $rootScope.filterArray( + ctrl.navs, + ["isActived"], + [true] + ); + setTimeout(() => { + ctrl.save().then(() => { + ctrl.loadPages(); + }); + }, 500); + }; + }, + ], +}); + +modules.component("modalNavPosts", { + templateUrl: + "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", + bindings: { + srcColumn: "=", + srcId: "=", + query: "=", + selected: "=", + save: "&", + }, + controller: [ + "$rootScope", + "$scope", + "$routeParams", + "ngAppSettings", + "PostRestService", + function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.navs = []; + ctrl.associations = []; + ctrl.data = { items: [] }; + ctrl.loadPosts = async function (pageIndex) { + // ctrl.request.query = ctrl.query + ctrl.srcId; + if (pageIndex !== undefined) { + ctrl.request.pageIndex = pageIndex; + } + if (ctrl.request.fromDate !== null) { + var d = new Date(ctrl.request.fromDate); + ctrl.request.fromDate = d.toISOString(); + } + if (ctrl.request.toDate !== null) { + var d = new Date(ctrl.request.toDate); + ctrl.request.toDate = d.toISOString(); } - }; - ctrl.removeNav = async function (idx) { - var nav = ctrl.selectedList.items[idx]; - ctrl.selectedValues.splice(idx, 1); - ctrl.selectedList.items.splice(idx, 1); - ctrl.filterData(); - if (nav && nav.id) { - await navService.delete([nav.id]); - $rootScope.showMessage("success", "success"); + if ($routeParams.type) { + ctrl.request.postType = $routeParams.type; + } else { + ctrl.request.postType = ""; + } + var response = await postService.getList(ctrl.request); + if (response.success) { + ctrl.data = response.data; + // ctrl.navs = []; + // angular.forEach(response.data.items, function (e) { + // var item = { + // priority: e.priority, + // description: e.title, + // postId: e.id, + // image: e.thumbnailUrl, + // specificulture: e.specificulture, + // post: e, + // status: "Published", + // isActived: false, + // }; + // item[ctrl.srcColumn] = ctrl.srcId; + // ctrl.navs.push(item); + // }); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; $scope.$apply(); } }; - ctrl.disableNavitem = function (nav, isDisable) { - nav.disabled = isDisable; + ctrl.select = async (associations) => { + ctrl.associations = associations; }; - ctrl.createData = function () { - if (ctrl.newTitle) { - var tmp = $rootScope.findObjectByKey( - ctrl.data.items, - "title", - ctrl.newTitle - ); - if (!tmp) { - ctrl.isBusy = true; - ctrl.mixDatabaseData.intParentId = 0; - ctrl.mixDatabaseData.parentType = "Set"; - ctrl.mixDatabaseData.data.title = ctrl.newTitle; - ctrl.mixDatabaseData.data.slug = $rootScope.generateKeyword( - ctrl.newTitle, - "-" - ); - ctrl.mixDatabaseData.data.type = ctrl.type; - dataService.save(ctrl.mixDatabaseData).then((resp) => { - if (resp.success) { - ctrl.mixDatabaseData.id = resp.data; - ctrl.data.items.push(ctrl.mixDatabaseData); - ctrl.reload(); - ctrl.select(resp.data.id, true); - ctrl.filterData(); - ctrl.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(resp.errors); - ctrl.isBusy = false; - $scope.$apply(); - } - }); - } else { - tmp.isActived = true; - ctrl.select(tmp); - } - } + ctrl.saveSelected = function () { + ctrl.selected = $rootScope.filterArray( + ctrl.navs, + ["isActived"], + [true] + ); + setTimeout(() => { + ctrl.save().then(() => { + ctrl.loadPosts(); + }); + }, 500); }; }, ], @@ -16330,6 +16330,83 @@ modules.component("templateEditor", { ], }); +modules.component("toastHelper", { + templateUrl: + "/mix-app/views/app-portal/components/toast-helper/toast-helper.html", + bindings: { + url: "=?", + title: "=?", + }, + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.visible = $rootScope.visible; + }, + ], +}); + +modules.component("urlAlias", { + templateUrl: "/mix-app/views/app-portal/components/url-alias/url-alias.html", + controller: [ + "$rootScope", + "$scope", + "UrlAliasService", + function ($rootScope, $scope, service) { + var ctrl = this; + ctrl.$onInit = function () { + ctrl.updateUrl(); + }; + ctrl.updateUrl = function () { + ctrl.url = + $rootScope.globalSettings.domain + + "/" + + $rootScope.mixConfigurations.lang + + "/" + + ctrl.urlAlias.alias; + }; + ctrl.remove = function () { + if (ctrl.urlAlias.id > 0) { + $rootScope.showConfirm( + ctrl, + "removeConfirmed", + [ctrl.urlAlias.id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + } else { + if (ctrl.removeCallback) { + ctrl.removeCallback({ index: ctrl.index }); + } + } + }; + + ctrl.removeConfirmed = async function (id) { + $rootScope.isBusy = true; + var result = await service.delete(id); + if (result.success) { + if (ctrl.removeCallback) { + ctrl.removeCallback({ index: ctrl.index }); + } + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], + bindings: { + urlAlias: "=", + index: "=", + callback: "&", + removeCallback: "&", + }, +}); + app.factory("ConnectionManager", [ function () { var serviceFactory = {}; @@ -17182,83 +17259,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: "&", - }, -}); - -modules.component("toastHelper", { - templateUrl: - "/mix-app/views/app-portal/components/toast-helper/toast-helper.html", - bindings: { - url: "=?", - title: "=?", - }, - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.visible = $rootScope.visible; - }, - ], -}); - !(function (t) { var e = {}; function i(n) { diff --git a/src/applications/Mixcore/wwwroot/mix-app/views/app-portal/pages/application/details.html b/src/applications/Mixcore/wwwroot/mix-app/views/app-portal/pages/application/details.html index 297c3a6c0..735fd443e 100644 --- a/src/applications/Mixcore/wwwroot/mix-app/views/app-portal/pages/application/details.html +++ b/src/applications/Mixcore/wwwroot/mix-app/views/app-portal/pages/application/details.html @@ -1 +1 @@ -
(Must start with "/app/", ex: '/app/my-app')
{{post.title}}
by {{post.properties.authorName}} in {{post.additionalData.category}}

\ No newline at end of file +
(Must start with "/app/", ex: '/app/my-app')

{{post.title}}
by {{post.properties.authorName}} in {{post.additionalData.category}}
\ No newline at end of file diff --git a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs index f0605dcc8..60e29438f 100644 --- a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs +++ b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs @@ -5,9 +5,11 @@ using Mix.Lib.Interfaces; using Mix.Portal.Domain.Interfaces; using Mix.Shared.Helpers; +using Mix.Shared.Models.Configurations; using Mix.Shared.Services; using Mix.SignalR.Constants; using Mix.SignalR.Hubs; +using System.Configuration; using System.IO.Packaging; using System.Text.RegularExpressions; using static NuGet.Packaging.PackagingConstants; @@ -17,7 +19,7 @@ namespace Mix.Portal.Domain.Services public sealed class MixApplicationService : TenantServiceBase, IMixApplicationService { static string[] excludeFileNames = { "jquery", "index" }; - static string allowExtensionsPattern = "js|css|png|jpg|jpeg|gif|svg|webm|mp3|mp4|wmv"; + static string allowExtensionsPattern = "js|css|webmanifest|ico|png|jpg|jpeg|gif|svg|webm|mp3|mp4|wmv"; private readonly IQueueService _queueService; private readonly IThemeService _themeService; private readonly MixIdentityService _mixIdentityService; @@ -121,14 +123,11 @@ private async Task ModifyFilesAndFolders(string deployUrl, string topFolder, str Regex regex = new($"((\\\"|\\'|\\(\\/|\\`)(\\.)?(\\/)?(([0-9a-zA-Z\\/\\._-])+)\\.({allowExtensionsPattern})(\"|\\'|\\)|\\`))"); - Regex baseHrefRegex = new("(base href=\"(.+?)\")"); - indexFile.Content = indexFile.Content.Replace("[basePath]/", string.Empty); + Regex baseHrefRegex = new("(base href=\"(.{0,})\")"); + Regex basePathRegex = new("(\\[\\[?basePath\\]\\]?\\/?)"); indexFile.Content = regex.Replace(indexFile.Content, $"$2/{deployUrl}/$5.$7$2"); - indexFile.Content = baseHrefRegex.Replace(indexFile.Content, $"base href=\"{baseHref}\"") - .Replace("[baseRoute]", deployUrl) - - .Replace("options['baseRoute']", $"'{deployUrl}'") - .Replace("options['baseHref']", $"'/{baseHref}'"); + indexFile.Content = baseHrefRegex.Replace(indexFile.Content, $"base href=\"{baseHref}\""); + indexFile.Content = basePathRegex.Replace(indexFile.Content, $"/{deployUrl}/"); var activeTheme = await _themeService.GetActiveTheme(); MixTemplateViewModel template = await MixTemplateViewModel.GetRepository(_cmsUow, CacheService).GetSingleAsync(m => m.Id == templateId); @@ -153,7 +152,6 @@ private async Task ModifyFilesAndFolders(string deployUrl, string topFolder, str } catch (Exception) { - throw; } } @@ -166,6 +164,8 @@ private Task ReplaceContent(FileModel file, string folders, string deployUrl) { _ = AlertAsync(_hubContext.Clients.Group("Theme"), "Status", 200, $"Modifying {file.Filename}{file.Extension}"); Regex rg = new($"((\\\"|\\'|\\(\\/|\\`)(\\.)?(\\/)?(([0-9a-zA-Z\\/\\._-])+)\\.({allowExtensionsPattern})(\"|\\'|\\)|\\`))"); + Regex basePathRegex = new("(\\[\\[?basePath\\]\\]?\\/?)"); + Regex apiEndpointRegex = new("(\\[\\[?apiEndpoint\\]\\]?\\/?)"); if (rg.IsMatch(file.Content)) { file.Content = rg.Replace(file.Content, $"$2/{deployUrl}/$5.$7$2"); @@ -179,7 +179,8 @@ private Task ReplaceContent(FileModel file, string folders, string deployUrl) } } - file.Content = file.Content.Replace("[basePath]", $"/{deployUrl}"); + file.Content = basePathRegex.Replace(file.Content, $"/{deployUrl}/"); + file.Content = apiEndpointRegex.Replace(file.Content, $"/{CurrentTenant.Configurations.Domain.TrimEnd('/')}/"); MixFileHelper.SaveFile(file); } diff --git a/src/modules/mix.portal/mix.portal.csproj b/src/modules/mix.portal/mix.portal.csproj index 29bcaf98e..40cddd0b2 100644 --- a/src/modules/mix.portal/mix.portal.csproj +++ b/src/modules/mix.portal/mix.portal.csproj @@ -496,4 +496,8 @@ + + + + diff --git a/src/platform/mix.library/Subscribers/MixBackgroundTaskSubscriber.cs b/src/platform/mix.library/Subscribers/MixBackgroundTaskSubscriber.cs index 89109248b..e93e28f52 100644 --- a/src/platform/mix.library/Subscribers/MixBackgroundTaskSubscriber.cs +++ b/src/platform/mix.library/Subscribers/MixBackgroundTaskSubscriber.cs @@ -81,14 +81,11 @@ public override async Task Handler(MessageQueueModel model) private async Task InstallMixApplication(MessageQueueModel model) { - using (ServiceScope = ServicesProvider.CreateScope()) - { - var cmsUow = GetRequiredService>(); - IMixApplicationService _applicationService = GetRequiredService(); - var app = model.ParseData(); - await _applicationService.Install(app); - await cmsUow.CompleteAsync(); - } + var cmsUow = GetRequiredService>(); + IMixApplicationService _applicationService = GetRequiredService(); + var app = model.ParseData(); + await _applicationService.Install(app); + await cmsUow.CompleteAsync(); } public override Task HandleException(MessageQueueModel model, Exception ex)