diff --git a/src/applications/Mixcore/Controllers/ModuleDataController.cs b/src/applications/Mixcore/Controllers/ModuleDataController.cs index 70f880366..a3c0115b0 100644 --- a/src/applications/Mixcore/Controllers/ModuleDataController.cs +++ b/src/applications/Mixcore/Controllers/ModuleDataController.cs @@ -17,8 +17,10 @@ public ModuleDataController(IHttpContextAccessor httpContextAccessor, MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/applications/Mixcore/Controllers/PageContentApiController.cs b/src/applications/Mixcore/Controllers/PageContentApiController.cs index 488874163..8cd28194e 100644 --- a/src/applications/Mixcore/Controllers/PageContentApiController.cs +++ b/src/applications/Mixcore/Controllers/PageContentApiController.cs @@ -25,8 +25,10 @@ public PageContentApiController( IQueueService queueService, MixRepoDbRepository mixRepoDbRepository, IMixMetadataService metadataService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _mixRepoDbRepository = mixRepoDbRepository; _metadataService = metadataService; diff --git a/src/applications/Mixcore/Controllers/PostContentApiController.cs b/src/applications/Mixcore/Controllers/PostContentApiController.cs index 7a2261d97..04ffadcf0 100644 --- a/src/applications/Mixcore/Controllers/PostContentApiController.cs +++ b/src/applications/Mixcore/Controllers/PostContentApiController.cs @@ -28,8 +28,10 @@ public PostContentApiController( MixRepoDbRepository mixRepoDbRepository, IMixMetadataService metadataService, MixRepoDbRepository repoDbRepository, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _postService = postService; _mixRepoDbRepository = mixRepoDbRepository; diff --git a/src/applications/Mixcore/Domain/Extensions/ServiceExtension.cs b/src/applications/Mixcore/Domain/Extensions/ServiceExtension.cs index 70a262d76..bfd0c55ad 100644 --- a/src/applications/Mixcore/Domain/Extensions/ServiceExtension.cs +++ b/src/applications/Mixcore/Domain/Extensions/ServiceExtension.cs @@ -59,15 +59,6 @@ public static IApplicationBuilder UseMixRoutes(this IApplicationBuilder app) // pattern: "portal-apps/{appFolder:" + urlPathPattern + "}/{param1?}/{param2?}/{param3?}/{param4?}"); routes.MapFallbackToFile("/index.html"); }); - //app.MapWhen( - // context => - // { - // var path = context.Request.Path.Value.ToLower(); - // return - // path.StartsWith("/mix-app") || - // path.StartsWith("/mix-content"); - // }, - // config => config.UseStaticFiles()); return app; } diff --git a/src/applications/Mixcore/Domain/Services/PostService.cs b/src/applications/Mixcore/Domain/Services/PostService.cs index a9b050154..0cce5b0fe 100644 --- a/src/applications/Mixcore/Domain/Services/PostService.cs +++ b/src/applications/Mixcore/Domain/Services/PostService.cs @@ -9,8 +9,9 @@ public MixcorePostService( UnitOfWorkInfo uow, IMixMetadataService metadataService, IHttpContextAccessor httpContextAccessor, - MixCacheService cacheService) - : base(uow, metadataService, httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(uow, metadataService, httpContextAccessor, cacheService, mixTenantService) { } } 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 d58764902..b6c33a3bf 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 @@ -342,6 +342,119 @@ 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.init("audit-log"); + return serviceFactory; + }, +]); + "use strict"; app.controller("MixApplicationController", [ "$scope", @@ -497,119 +610,6 @@ app.factory("MixApplicationRestService", [ }, ]); -"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.init("audit-log"); - return serviceFactory; - }, -]); - "use strict"; app.controller("ConfigurationController", [ "$scope", @@ -1381,79 +1381,24 @@ app.factory("FileServices", [ ]); "use strict"; -app.controller("ImportFileController", [ +app.controller("JsonDataController", [ "$scope", "$rootScope", - "ImportFileServices", - "TranslatorService", - "AppSettingsService", + "ngAppSettings", + "$routeParams", + "$timeout", + "$location", + "AuthService", + "JsonDataService", function ( $scope, $rootScope, - service, - translatorService, - AppSettingsService - ) { - $scope.saveImportFile = async function () { - $rootScope.isBusy = true; - var form = document.getElementById("frm-import"); - var frm = new FormData(); - frm.append("assets", form["assets"].files[0]); - var response = await service.saveImportFile(frm); - if (response.success) { - $scope.viewmodel = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.factory("ImportFileServices", [ - "$rootScope", - "BaseService", - function ($rootScope, baseService) { - //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; - - var serviceFactory = {}; - - var settings = $rootScope.globalSettings; - var serviceFactory = Object.create(baseService); - serviceFactory.init("portal", true); - var _saveImportFile = async function (frm) { - var apiUrl = this.prefixUrl + "/" + settings.lang + "/import"; - return await this.ajaxSubmitForm(frm, apiUrl); - }; - - serviceFactory.saveImportFile = _saveImportFile; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("JsonDataController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$timeout", - "$location", - "AuthService", - "JsonDataService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $timeout, - $location, - authService, - service + ngAppSettings, + $routeParams, + $timeout, + $location, + authService, + service ) { $scope.request = { pageSize: "10", @@ -1649,6 +1594,61 @@ app.factory("JsonDataService", [ }, ]); +"use strict"; +app.controller("ImportFileController", [ + "$scope", + "$rootScope", + "ImportFileServices", + "TranslatorService", + "AppSettingsService", + function ( + $scope, + $rootScope, + service, + translatorService, + AppSettingsService + ) { + $scope.saveImportFile = async function () { + $rootScope.isBusy = true; + var form = document.getElementById("frm-import"); + var frm = new FormData(); + frm.append("assets", form["assets"].files[0]); + var response = await service.saveImportFile(frm); + if (response.success) { + $scope.viewmodel = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.factory("ImportFileServices", [ + "$rootScope", + "BaseService", + function ($rootScope, baseService) { + //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; + + var serviceFactory = {}; + + var settings = $rootScope.globalSettings; + var serviceFactory = Object.create(baseService); + serviceFactory.init("portal", true); + var _saveImportFile = async function (frm) { + var apiUrl = this.prefixUrl + "/" + settings.lang + "/import"; + return await this.ajaxSubmitForm(frm, apiUrl); + }; + + serviceFactory.saveImportFile = _saveImportFile; + return serviceFactory; + }, +]); + "use strict"; app.controller("LocalizeController", [ "$scope", @@ -3605,13 +3605,13 @@ app.factory("PageRestService", [ ]); "use strict"; -app.controller("PageGalleryController", [ +app.controller("PagePostController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "PageGalleryService", + "PagePostRestService", "PostRestService", "ApiService", "CommonService", @@ -3623,7 +3623,6 @@ app.controller("PageGalleryController", [ $location, service, postService, - apiService, commonService ) { BaseCtrl.call( @@ -3634,20 +3633,39 @@ app.controller("PageGalleryController", [ ngAppSettings, service ); + $scope.request.culture = $rootScope.globalSettings.defaultCulture; $scope.cates = ["Site", "System"]; $scope.others = []; $scope.mixConfigurations = $rootScope.globalSettings; - $scope.pageId = $routeParams.id; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.getList = async function () { + $scope.init = function () { + $scope.pageId = $routeParams.id; + $scope.type = $routeParams.type || ""; + $scope.template = $routeParams.template || ""; + $scope.pageIds = $routeParams.page_ids || $routeParams.id || ""; + $scope.moduleIds = $routeParams.module_ids || ""; + $scope.canDrag = + $scope.request.orderBy === "Priority" && + $scope.request.direction === "Asc"; + $scope.createUrl = + $routeParams.post_type === "gallery" + ? "/admin/post/create-gallery" + : `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; + $scope.updateUrl = + $routeParams.post_type === "gallery" + ? "/admin/post/gallery-details" + : "/admin/post/details"; + }; + $scope.getList = async function (pageIndex) { + if (pageIndex !== undefined) { + $scope.request.pageIndex = pageIndex; + } $rootScope.isBusy = true; var id = $routeParams.id; $scope.request.query = "&page_id=" + id; var response = await service.getList($scope.request); $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; + $scope.request.orderBy === "Priority" && + $scope.request.direction === "Asc"; if (response.success) { $scope.data = response.data; $rootScope.isBusy = false; @@ -3658,6 +3676,10 @@ app.controller("PageGalleryController", [ $scope.$apply(); } }; + $scope.preview = function (item) { + item.editUrl = "/admin/post/details/" + item.id; + $rootScope.preview("post", item, item.title, "modal-lg"); + }; $scope.remove = function (pageId, postId) { $rootScope.showConfirm( $scope, @@ -3668,10 +3690,13 @@ app.controller("PageGalleryController", [ "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; + $scope.back = function () { + window.history.back(); + }; - $scope.removeConfirmed = async function (pageId, postId) { + $scope.removeConfirmed = async function (id) { $rootScope.isBusy = true; - var result = await service.delete(pageId, postId); + var result = await service.delete(id); if (result.success) { if ($scope.removeCallback) { $rootScope.executeFunctionByName( @@ -3682,7 +3707,7 @@ app.controller("PageGalleryController", [ } $scope.getList(); } else { - $rootScope.showMessage("failed"); + $rootScope.showErrors(result.errors); $rootScope.isBusy = false; $scope.$apply(); } @@ -3724,21 +3749,21 @@ app.controller("PageGalleryController", [ ]); "use strict"; -app.factory("PageGalleryService", [ +app.factory("PagePostRestService", [ "$rootScope", "ApiService", "CommonService", - "BaseService", + "BaseRestService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("page-post"); - var _delete = async function (pageId, postId) { - var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; + serviceFactory.init("mix-page-post"); + var _delete = async function (id) { + var url = this.prefixUrl + "/delete/" + id; var req = { method: "GET", url: url, }; - return await apiService.sendRequest(req); + return await apiService.getApiResult(req); }; var _updateInfos = async function (pages) { var req = { @@ -3746,7 +3771,7 @@ app.factory("PageGalleryService", [ url: this.prefixUrl + "/update-infos", data: JSON.stringify(pages), }; - return await apiService.sendRequest(req); + return await apiService.getApiResult(req); }; serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; @@ -3908,7 +3933,7 @@ app.controller("PagePostController", [ "ngAppSettings", "$routeParams", "$location", - "PagePostRestService", + "PageGalleryService", "PostRestService", "ApiService", "CommonService", @@ -3920,6 +3945,7 @@ app.controller("PagePostController", [ $location, service, postService, + apiService, commonService ) { BaseCtrl.call( @@ -3930,39 +3956,20 @@ app.controller("PagePostController", [ ngAppSettings, service ); - $scope.request.culture = $rootScope.globalSettings.defaultCulture; $scope.cates = ["Site", "System"]; $scope.others = []; $scope.mixConfigurations = $rootScope.globalSettings; - $scope.init = function () { - $scope.pageId = $routeParams.id; - $scope.type = $routeParams.type || ""; - $scope.template = $routeParams.template || ""; - $scope.pageIds = $routeParams.page_ids || $routeParams.id || ""; - $scope.moduleIds = $routeParams.module_ids || ""; - $scope.canDrag = - $scope.request.orderBy === "Priority" && - $scope.request.direction === "Asc"; - $scope.createUrl = - $routeParams.post_type === "gallery" - ? "/admin/post/create-gallery" - : `/admin/post/create?page_ids=${$scope.pageIds}&moduleIds=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; - $scope.updateUrl = - $routeParams.post_type === "gallery" - ? "/admin/post/gallery-details" - : "/admin/post/details"; - }; - $scope.getList = async function (pageIndex) { - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } + $scope.pageId = $routeParams.id; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.getList = async function () { $rootScope.isBusy = true; var id = $routeParams.id; $scope.request.query = "&page_id=" + id; var response = await service.getList($scope.request); $scope.canDrag = - $scope.request.orderBy === "Priority" && - $scope.request.direction === "Asc"; + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; if (response.success) { $scope.data = response.data; $rootScope.isBusy = false; @@ -3973,10 +3980,6 @@ app.controller("PagePostController", [ $scope.$apply(); } }; - $scope.preview = function (item) { - item.editUrl = "/admin/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); - }; $scope.remove = function (pageId, postId) { $rootScope.showConfirm( $scope, @@ -3987,13 +3990,10 @@ app.controller("PagePostController", [ "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; - $scope.back = function () { - window.history.back(); - }; - $scope.removeConfirmed = async function (id) { + $scope.removeConfirmed = async function (pageId, postId) { $rootScope.isBusy = true; - var result = await service.delete(id); + var result = await service.delete(pageId, postId); if (result.success) { if ($scope.removeCallback) { $rootScope.executeFunctionByName( @@ -4004,7 +4004,7 @@ app.controller("PagePostController", [ } $scope.getList(); } else { - $rootScope.showErrors(result.errors); + $rootScope.showMessage("failed"); $rootScope.isBusy = false; $scope.$apply(); } @@ -4046,21 +4046,21 @@ app.controller("PagePostController", [ ]); "use strict"; -app.factory("PagePostRestService", [ +app.factory("PageGalleryService", [ "$rootScope", "ApiService", "CommonService", - "BaseRestService", + "BaseService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-page-post"); - var _delete = async function (id) { - var url = this.prefixUrl + "/delete/" + id; + serviceFactory.init("page-post"); + var _delete = async function (pageId, postId) { + var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; var req = { method: "GET", url: url, }; - return await apiService.getApiResult(req); + return await apiService.sendRequest(req); }; var _updateInfos = async function (pages) { var req = { @@ -4068,7 +4068,7 @@ app.factory("PagePostRestService", [ url: this.prefixUrl + "/update-infos", data: JSON.stringify(pages), }; - return await apiService.getApiResult(req); + return await apiService.sendRequest(req); }; serviceFactory.delete = _delete; serviceFactory.updateInfos = _updateInfos; @@ -4577,24 +4577,26 @@ app.factory("PostRestService", [ ]); "use strict"; -app.controller("RoleController", [ +app.controller("PermissionController", [ "$scope", "$rootScope", - "$location", - "$routeParams", "ngAppSettings", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "RoleService", + "$routeParams", + "$location", + "ApiService", + "CommonService", + "PermissionService", + "RestPortalPageNavigationService", function ( $scope, $rootScope, - $location, - $routeParams, ngAppSettings, - dataService, - columnService, - service + $routeParams, + $location, + apiService, + commonService, + service, + navService ) { BaseRestCtrl.call( this, @@ -4605,9 +4607,154 @@ app.controller("RoleController", [ ngAppSettings, service ); - $scope.role = { name: "" }; - $scope.initPermissions = async function () { - let backUrl = "/admin/role/list"; + $scope.request.level = 0; + $scope.miOptions = ngAppSettings.miIcons; + $scope.initDialog = function () { + $("#dlg-permission").on("shown.bs.modal", function () { + $scope.initCurrentPath(); + }); + }; + + $scope.initCurrentPath = async function () { + var resp = await service.getDefault(); + if (resp && resp.success) { + $scope.viewmodel = resp.data; + $scope.viewmodel.url = $location.url(); + $rootScope.isBusy = false; + $scope.$applyAsync(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + if ($scope.getSingleFailCallback) { + $scope.getSingleFailCallback(); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.saveSuccessCallback = function () { + $scope.getSingle(); + }; + + $scope.dragStart = function (index) { + $scope.minPriority = $scope.data.items[0].priority; + $scope.dragStartIndex = index; + }; + $scope.updateOrders = function (index) { + if (index > $scope.dragStartIndex) { + $scope.data.items.splice($scope.dragStartIndex, 1); + } else { + $scope.data.items.splice($scope.dragStartIndex + 1, 1); + } + angular.forEach($scope.data.items, function (e, i) { + e.priority = $scope.minPriority + i; + service.saveFields(e.id, { priority: e.priority }).then((resp) => { + $rootScope.isBusy = false; + $scope.$apply(); + }); + }); + }; + + $scope.updateChildInfos = async function (items) { + $rootScope.isBusy = true; + var resp = await service.updateChildInfos(items); + if (resp && resp.success) { + $scope.activedPage = resp.data; + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $("#dlg-favorite").on("show.bs.modal", function (event) { + $scope.initCurrentPath(); + }); + }, +]); + +"use strict"; +app.factory("PermissionService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.initService("/rest/mix-services", "permission", true); + var _updateInfos = async function (pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), + }; + return await apiService.sendRequest(req); + }; + + var _updateChildInfos = async function (pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-child-infos", + data: JSON.stringify(pages), + }; + return await apiService.sendRequest(req); + }; + + serviceFactory.updateInfos = _updateInfos; + serviceFactory.updateChildInfos = _updateChildInfos; + return serviceFactory; + }, +]); + +"use strict"; +app.factory("RestPortalPageNavigationService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("portal-page-navigation", true); + + return serviceFactory; + }, +]); + +"use strict"; +app.controller("RoleController", [ + "$scope", + "$rootScope", + "$location", + "$routeParams", + "ngAppSettings", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + "RoleService", + function ( + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + dataService, + columnService, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.role = { name: "" }; + $scope.initPermissions = async function () { + let backUrl = "/admin/role/list"; $scope.createUrl = `/admin/mix-database-data/create?mixDatabaseName=sysPermission&dataContentId=default&guidParentId=${$scope.viewmodel.id}&parentType=Role&backUrl=${backUrl}`; $scope.updateUrl = "/admin/mix-database-data/details"; }; @@ -5450,6 +5597,54 @@ app.controller("StoreController", [ }, ]); +"use strict"; +app.controller("TenantController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$location", + "$routeParams", + "TenantRestService", + function ( + $scope, + $rootScope, + ngAppSettings, + $location, + $routeParams, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.request.columns = [ + "id", + "displayName", + "systemName", + "primaryDomain", + "createdDateTime", + "createdBy", + ]; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + }, +]); + +"use strict"; +app.factory("TenantRestService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-tenant"); + return serviceFactory; + }, +]); + "use strict"; app.controller("TemplateController", [ "$scope", @@ -5682,75 +5877,112 @@ app.controller("TemplateController", [ ]); "use strict"; -app.controller("TenantController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$location", - "$routeParams", - "TenantRestService", - function ( - $scope, - $rootScope, - ngAppSettings, - $location, - $routeParams, - service - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.request.columns = [ - "id", - "displayName", - "systemName", - "primaryDomain", - "createdDateTime", - "createdBy", - ]; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - }, -]); - -"use strict"; -app.factory("TenantRestService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-tenant"); - return serviceFactory; - }, -]); - -"use strict"; -app.controller("ThemeController", [ +app.controller("ThemeImportController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "ThemeService", "ApiService", - "CommonService", + "TenancyService", function ( $scope, $rootScope, ngAppSettings, $routeParams, $location, - service, - commonService + apiService, + tenancyService ) { - BaseRestCtrl.call( - this, - $scope, + $scope.importData = null; + $scope.init = function () {}; + $scope.getSingleSuccessCallback = function () { + $scope.assets = null; + $scope.theme = null; + }; + $scope.submit = async function () { + $scope.form = document.getElementById("form-portal"); + let theme = $scope.form["theme"].files[0]; + if (theme) { + await $scope.extract(theme); + document.getElementById("form-portal")["theme"].value = ""; + } else { + $scope.import(); + } + }; + $scope.extract = async function (theme) { + $rootScope.isBusy = true; + var frm = new FormData(); + var url = "/rest/mix-tenancy/setup/extract-theme"; + $rootScope.isBusy = true; + // Looping over all files and add it to FormData object + frm.append("theme", theme); + // Adding one more key to FormData object + frm.append("model", angular.toJson($scope.data)); + var response = await apiService.ajaxSubmitForm(frm, url); + $rootScope.isBusy = false; + if (response.success) { + var getData = await $scope.loadTheme(); + if (getData.success) { + $scope.importThemeDto = getData.data; + $rootScope.isBusy = false; + $scope.$apply(); + } + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.loadTheme = async function () { + var req = { + method: "GET", + url: "/rest/mix-tenancy/setup/load-theme", + }; + return await apiService.sendRequest(req); + }; + + $scope.import = async function () { + $scope.importThemeDto.themeId = $routeParams.id; + $rootScope.isBusy = true; + var response = await tenancyService.import($scope.importThemeDto); + + if (response.success) { + $rootScope.isBusy = false; + window.open("/", "_blank"); + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.controller("ThemeController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "ThemeService", + "ApiService", + "CommonService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + commonService + ) { + BaseRestCtrl.call( + this, + $scope, $rootScope, $location, $routeParams, @@ -5876,91 +6108,6 @@ app.controller("ThemeController", [ }, ]); -"use strict"; -app.controller("ThemeImportController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "ApiService", - "TenancyService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - apiService, - tenancyService - ) { - $scope.importData = null; - $scope.init = function () {}; - $scope.getSingleSuccessCallback = function () { - $scope.assets = null; - $scope.theme = null; - }; - $scope.submit = async function () { - $scope.form = document.getElementById("form-portal"); - let theme = $scope.form["theme"].files[0]; - if (theme) { - await $scope.extract(theme); - document.getElementById("form-portal")["theme"].value = ""; - } else { - $scope.import(); - } - }; - $scope.extract = async function (theme) { - $rootScope.isBusy = true; - var frm = new FormData(); - var url = "/rest/mix-tenancy/setup/extract-theme"; - $rootScope.isBusy = true; - // Looping over all files and add it to FormData object - frm.append("theme", theme); - // Adding one more key to FormData object - frm.append("model", angular.toJson($scope.data)); - var response = await apiService.ajaxSubmitForm(frm, url); - $rootScope.isBusy = false; - if (response.success) { - var getData = await $scope.loadTheme(); - if (getData.success) { - $scope.importThemeDto = getData.data; - $rootScope.isBusy = false; - $scope.$apply(); - } - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.loadTheme = async function () { - var req = { - method: "GET", - url: "/rest/mix-tenancy/setup/load-theme", - }; - return await apiService.sendRequest(req); - }; - - $scope.import = async function () { - $scope.importThemeDto.themeId = $routeParams.id; - $rootScope.isBusy = true; - var response = await tenancyService.import($scope.importThemeDto); - - if (response.success) { - $rootScope.isBusy = false; - window.open("/", "_blank"); - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - "use strict"; app.controller("UrlAliasController", [ "$scope", @@ -6803,6 +6950,43 @@ app.component("appSettingsDefault", { }, }); +app.component("appSettingsHeart", { + templateUrl: + "/mix-app/views/app-portal/pages/app-settings/components/heart/view.html", + bindings: {}, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "AppSettingsServices", + "CommonService", + function ( + $rootScope, + $scope, + ngAppSettings, + settingService, + commonService + ) { + var ctrl = this; + ctrl.$onInit = function () { + ctrl.databaseProviders = ngAppSettings.enums.database_providers; + ctrl.cacheModes = ngAppSettings.enums.cache_modes; + settingService.getAppSettings("mix_heart").then((resp) => { + ctrl.appSettings = resp.data; + $scope.$apply; + }); + }; + ctrl.clearCache = async function () { + $rootScope.isBusy = true; + await commonService.clearCache(); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + }; + }, + ], +}); + app.component("appSettingsGeneral", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/general/view.html", @@ -6834,41 +7018,18 @@ app.component("appSettingsGeneral", { }, }); -app.component("appSettingsHeart", { +app.component("appSettingsSmtp", { templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/heart/view.html", - bindings: {}, + "/mix-app/views/app-portal/pages/app-settings/components/smtp/view.html", controller: [ - "$rootScope", - "$scope", "ngAppSettings", - "AppSettingsServices", - "CommonService", - function ( - $rootScope, - $scope, - ngAppSettings, - settingService, - commonService - ) { + function (ngAppSettings) { var ctrl = this; - ctrl.$onInit = function () { - ctrl.databaseProviders = ngAppSettings.enums.database_providers; - ctrl.cacheModes = ngAppSettings.enums.cache_modes; - settingService.getAppSettings("mix_heart").then((resp) => { - ctrl.appSettings = resp.data; - $scope.$apply; - }); - }; - ctrl.clearCache = async function () { - $rootScope.isBusy = true; - await commonService.clearCache(); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - }; }, ], + bindings: { + appSettings: "=", + }, }); modules.component("portalMenus", { @@ -6903,23 +7064,9 @@ modules.component("portalMenus", { ], }); -app.component("appSettingsSmtp", { +app.component("customerMain", { 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", + "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", bindings: { customer: "=", onDelete: "&", @@ -7448,153 +7595,6 @@ app.component("pageSeo", { }, }); -app.component("permissionMain", { - templateUrl: - "/mix-app/views/app-portal/pages/permission/components/main/main.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "$routeParams", - function ($rootScope, $scope, ngAppSettings, $routeParams) { - var ctrl = this; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.icons = ngAppSettings.icons; - ctrl.setPageType = function (type) { - ctrl.page.type = $index; - }; - ctrl.generateKeyword = function (text) { - if (!$routeParams.id && text) { - ctrl.page.textKeyword = - "portal_" + - text - .replace(/[^a-zA-Z0-9]+/g, "_") - .replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2") - .replace(/([a-z])([A-Z])/g, "$1-$2") - .replace(/([0-9])([^0-9])/g, "$1-$2") - .replace(/([^0-9])([0-9])/g, "$1-$2") - .replace(/-+/g, "_") - .toLowerCase(); - } - }; - }, - ], - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("permissionParents", { - templateUrl: - "/mix-app/views/app-portal/pages/permission/components/parents/parents.html", - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -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", @@ -8165,84 +8165,231 @@ app.component("postSeo", { }, }); -modules.component("rolePageNav", { +app.component("permissionMain", { templateUrl: - "/mix-app/views/app-portal/pages/role/components/role-page-navigation/role-page-navigations.html", - bindings: { - prefix: "=", - page: "=", - callback: "&", - }, + "/mix-app/views/app-portal/pages/permission/components/main/main.html", controller: [ "$rootScope", "$scope", "ngAppSettings", - "RoleService", - function ($rootScope, $scope, ngAppSettings, roleServices) { + "$routeParams", + function ($rootScope, $scope, ngAppSettings, $routeParams) { var ctrl = this; - ctrl.selected = null; - ctrl.updateOrders = function (index) { - ctrl.data.splice(index, 1); - for (var i = 0; i < ctrl.data.length; i++) { - ctrl.data[i].priority = i + 1; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.icons = ngAppSettings.icons; + ctrl.setPageType = function (type) { + ctrl.page.type = $index; + }; + ctrl.generateKeyword = function (text) { + if (!$routeParams.id && text) { + ctrl.page.textKeyword = + "portal_" + + text + .replace(/[^a-zA-Z0-9]+/g, "_") + .replace(/([A-Z]+)([A-Z][a-z])/g, "$1-$2") + .replace(/([a-z])([A-Z])/g, "$1-$2") + .replace(/([0-9])([^0-9])/g, "$1-$2") + .replace(/([^0-9])([0-9])/g, "$1-$2") + .replace(/-+/g, "_") + .toLowerCase(); } }; - //ctrl.change = async function () { - // //var permission = ctrl.page.navPermission; - // //$rootScope.isBusy = true; - // //var resp = await roleServices.updatePermission(permission); - // //if (resp && resp.success) { - // // $rootScope.showMessage('Update successfully!', 'success'); - // // $rootScope.isBusy = false; - // // $scope.$apply(); - // //} - // //else { - // // if (resp) { $rootScope.showErrors(resp.errors); } - // // $rootScope.isBusy = false; - // // $scope.$apply(); - // //} - //}; }, ], + bindings: { + page: "=", + onDelete: "&", + onUpdate: "&", + }, }); -app.component("serviceMain", { +app.component("permissionParents", { templateUrl: - "/mix-app/views/app-portal/pages/service/components/main/view.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.gennerateName = function () { - if ( - !ctrl.model.id || - ctrl.model.name === null || - ctrl.model.name === "" - ) { - ctrl.model.name = $rootScope.generateKeyword(ctrl.model.title, "_"); - } - }; - }, - ], + "/mix-app/views/app-portal/pages/permission/components/parents/parents.html", bindings: { - model: "=", + page: "=", + onDelete: "&", + onUpdate: "&", }, }); -app.component("themeExportCultures", { +app.component("permissionPlugPlay", { templateUrl: - "/mix-app/views/app-portal/pages/theme/components/theme-export-cultures/view.html", + "/mix-app/views/app-portal/pages/permission/components/plug-play/plug-play.html", + bindings: { + page: "=", + prefixParent: "=", + prefixChild: "=", + searchText: "=", + onDelete: "&", + onUpdate: "&", + }, controller: [ "$rootScope", "$scope", - "ngAppSettings", - function ($rootScope, $scope, ngAppSettings) { + "$location", + "$element", + "PermissionService", + function ($rootScope, $scope, $location, $element, service) { var ctrl = this; - var service = $rootScope.getRestService("mix-culture"); - ctrl.selectAllContent = false; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = async () => { + ctrl.type = "Children"; + ctrl.goToPath = $rootScope.goToPath; + ctrl.request = { + pageSize: "5", + pageIndex: 0, + status: "Published", + orderBy: "CreatedDateTime", + direction: "Desc", + fromDate: null, + toDate: null, + }; + ctrl.pages = []; + ctrl.init = function () { + if (ctrl.page) { + ctrl.request.exceptIds = ctrl.page.parentNavs + .map((p) => p.pageId) + .concat(ctrl.page.childNavs.map((p) => p.pageId)); + if (ctrl.request.exceptIds.indexOf(ctrl.page.id) === -1) { + ctrl.request.exceptIds.push(ctrl.page.id); + } + ctrl.getList(); + } + }; + ctrl.selectPane = function (pane) { + if (ctrl.page) { + ctrl.type = pane.header; + ctrl.request.keyword = ""; + ctrl.init(); + } + }; + + ctrl.selectItem = (nav) => { + if (ctrl.type == "Parents") { + if ( + !$rootScope.findObjectByKey(ctrl.page.parentNavs, "pageId", nav.id) + ) { + ctrl.page.parentNavs.push({ + isActived: true, + pageId: ctrl.page.id, + parentId: nav.id, + description: nav.textDefault, + status: "Published", + parent: nav, + }); + } + } else { + if ( + !$rootScope.findObjectByKey(ctrl.page.childNavs, "pageId", nav.id) + ) { + ctrl.page.childNavs.push({ + isActived: true, + pageId: nav.id, + parentId: ctrl.page.id, + description: nav.textDefault, + status: "Published", + page: nav, + }); + } + } + }; + + ctrl.getList = async function () { + $rootScope.isBusy = true; + var resp = await service.getList(ctrl.request); + if (resp && resp.success) { + ctrl.pages = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors || ["Failed"]); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, + ], +}); + +modules.component("rolePageNav", { + templateUrl: + "/mix-app/views/app-portal/pages/role/components/role-page-navigation/role-page-navigations.html", + bindings: { + prefix: "=", + page: "=", + callback: "&", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "RoleService", + function ($rootScope, $scope, ngAppSettings, roleServices) { + var ctrl = this; + ctrl.selected = null; + ctrl.updateOrders = function (index) { + ctrl.data.splice(index, 1); + for (var i = 0; i < ctrl.data.length; i++) { + ctrl.data[i].priority = i + 1; + } + }; + //ctrl.change = async function () { + // //var permission = ctrl.page.navPermission; + // //$rootScope.isBusy = true; + // //var resp = await roleServices.updatePermission(permission); + // //if (resp && resp.success) { + // // $rootScope.showMessage('Update successfully!', 'success'); + // // $rootScope.isBusy = false; + // // $scope.$apply(); + // //} + // //else { + // // if (resp) { $rootScope.showErrors(resp.errors); } + // // $rootScope.isBusy = false; + // // $scope.$apply(); + // //} + //}; + }, + ], +}); + +app.component("serviceMain", { + templateUrl: + "/mix-app/views/app-portal/pages/service/components/main/view.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.gennerateName = function () { + if ( + !ctrl.model.id || + ctrl.model.name === null || + ctrl.model.name === "" + ) { + ctrl.model.name = $rootScope.generateKeyword(ctrl.model.title, "_"); + } + }; + }, + ], + bindings: { + model: "=", + }, +}); + +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("mix-culture"); + ctrl.selectAllContent = false; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = async () => { ctrl.getList(); }; ctrl.getList = async (cultureIndex) => { @@ -8265,18 +8412,18 @@ app.component("themeExportCultures", { ctrl.selectContent = (culture, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - culture.isExportData = selected && culture.isExportData; + culture.isImportData = selected && culture.isImportData; ctrl.updateContent([culture.id], selected); }; ctrl.updateContent = function (arr, selected) { if (selected) { - ctrl.exportThemeDto.cultureIds = ctrl.unionArray( - ctrl.exportThemeDto.cultureIds, + ctrl.importThemeDto.cultureIds = ctrl.unionArray( + ctrl.importThemeDto.cultureIds, arr ); } else { - ctrl.exportThemeDto.cultureIds = - ctrl.exportThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); + ctrl.importThemeDto.cultureIds = + ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); ctrl.updateData(arr, false); } }; @@ -8296,7 +8443,7 @@ app.component("themeExportCultures", { }, ], bindings: { - exportThemeDto: "=", + importThemeDto: "=", }, }); @@ -8314,8 +8461,7 @@ app.component("themeExportMixDatabases", { ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { - ctrl.request.pageSize = null; - ctrl.getList(); + ctrl.data = ctrl.importThemeDto.mixDatabases; }; ctrl.getList = async (mixDatabaseIndex) => { if (mixDatabaseIndex !== undefined) { @@ -8368,17 +8514,23 @@ app.component("themeExportMixDatabases", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isExportData = ctrl.selectAllData; + e.isImportData = ctrl.selectAllData; }); }; + ctrl.validate = (mixDatabase) => { + if ( + ctrl.importThemeDto.invalidDatabaseNames.indexOf( + mixDatabase.systemName + ) >= 0 + ) { + return `${mixDatabase.systemName} is invalid`; + } + }; ctrl.unionArray = (a, b) => { return [...new Set([...a, ...b])]; }; }, ], - bindings: { - exportThemeDto: "=", - }, }); app.component("themeExportModules", { @@ -8395,7 +8547,6 @@ app.component("themeExportModules", { ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { - ctrl.request.pageSize = null; ctrl.getList(); }; ctrl.getList = async (moduleIndex) => { @@ -8465,7 +8616,7 @@ app.component("themeExportModules", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isExportData = ctrl.selectAllData; + e.isImportData = ctrl.selectAllData; }); }; ctrl.unionArray = (a, b) => { @@ -8474,13 +8625,13 @@ app.component("themeExportModules", { }, ], bindings: { - exportThemeDto: "=", + importThemeDto: "=", }, }); -app.component("themeExportPages", { +app.component("themeImportPages", { templateUrl: - "/mix-app/views/app-portal/pages/theme/components/theme-export-pages/view.html", + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-pages/view.html", controller: [ "$rootScope", "$scope", @@ -8492,7 +8643,6 @@ app.component("themeExportPages", { ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { - ctrl.request.pageSize = null; ctrl.getList(); }; ctrl.getList = async (pageIndex) => { @@ -8515,17 +8665,17 @@ app.component("themeExportPages", { ctrl.selectContent = (page, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - page.isExportData = selected && page.isExportData; + page.isImportData = selected && page.isImportData; let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.exportThemeDto.content.pageIds = ctrl.updateArray( - ctrl.exportThemeDto.content.pageIds, + ctrl.importThemeDto.content.pageIds = ctrl.updateArray( + ctrl.importThemeDto.content.pageIds, [page.id], selected ); - ctrl.exportThemeDto.content.pageContentIds = ctrl.updateArray( - ctrl.exportThemeDto.content.pageContentIds, + ctrl.importThemeDto.content.pageContentIds = ctrl.updateArray( + ctrl.importThemeDto.content.pageContentIds, contentIds, selected ); @@ -8538,13 +8688,13 @@ app.component("themeExportPages", { let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.exportThemeDto.associations.pageIds = ctrl.updateArray( - ctrl.exportThemeDto.associations.pageIds, + ctrl.importThemeDto.associations.pageIds = ctrl.updateArray( + ctrl.importThemeDto.associations.pageIds, [page.id], selected ); - ctrl.exportThemeDto.associations.pageContentIds = ctrl.updateArray( - ctrl.exportThemeDto.associations.pageContentIds, + ctrl.importThemeDto.associations.pageContentIds = ctrl.updateArray( + ctrl.importThemeDto.associations.pageContentIds, contentIds, selected ); @@ -8562,7 +8712,7 @@ app.component("themeExportPages", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isExportData = ctrl.selectAllData; + e.isImportData = ctrl.selectAllData; }); }; ctrl.unionArray = (a, b) => { @@ -8571,27 +8721,24 @@ app.component("themeExportPages", { }, ], bindings: { - exportThemeDto: "=", + importThemeDto: "=", }, }); -app.component("themeExportPosts", { +app.component("themeImportPosts", { templateUrl: - "/mix-app/views/app-portal/pages/theme/components/theme-export-posts/view.html", + "/mix-app/views/app-portal/pages/theme-import/components/theme-import-posts/view.html", controller: [ "$rootScope", "$scope", "ngAppSettings", - "BaseRestService", - function ($rootScope, $scope, ngAppSettings, baseRestService) { + function ($rootScope, $scope, ngAppSettings) { var ctrl = this; - var service = angular.copy(baseRestService); - service.initService("/rest/mix-library", "mix-post"); + var service = $rootScope.getRestService("mix-post"); ctrl.selectAllContent = false; ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { - ctrl.request.pageSize = null; ctrl.getList(); }; ctrl.getList = async (postIndex) => { @@ -8614,17 +8761,17 @@ app.component("themeExportPosts", { ctrl.selectContent = (post, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - post.isExportData = selected && post.isExportData; + post.isImportData = selected && post.isImportData; let contentIds = post.contents.map(function (obj) { return obj.id; }); - ctrl.exportThemeDto.content.postIds = ctrl.updateArray( - ctrl.exportThemeDto.content.postIds, + ctrl.importThemeDto.content.postIds = ctrl.updateArray( + ctrl.importThemeDto.content.postIds, [post.id], selected ); - ctrl.exportThemeDto.content.postContentIds = ctrl.updateArray( - ctrl.exportThemeDto.content.postContentIds, + ctrl.importThemeDto.content.postContentIds = ctrl.updateArray( + ctrl.importThemeDto.content.postContentIds, contentIds, selected ); @@ -8637,13 +8784,13 @@ app.component("themeExportPosts", { let contentIds = post.contents.map(function (obj) { return obj.id; }); - ctrl.exportThemeDto.associations.postIds = ctrl.updateArray( - ctrl.exportThemeDto.associations.postIds, + ctrl.importThemeDto.associations.postIds = ctrl.updateArray( + ctrl.importThemeDto.associations.postIds, [post.id], selected ); - ctrl.exportThemeDto.associations.postContentIds = ctrl.updateArray( - ctrl.exportThemeDto.associations.postContentIds, + ctrl.importThemeDto.associations.postContentIds = ctrl.updateArray( + ctrl.importThemeDto.associations.postContentIds, contentIds, selected ); @@ -8661,7 +8808,7 @@ app.component("themeExportPosts", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isExportData = ctrl.selectAllData; + e.isImportData = ctrl.selectAllData; }); }; ctrl.unionArray = (a, b) => { @@ -8670,13 +8817,13 @@ app.component("themeExportPosts", { }, ], bindings: { - exportThemeDto: "=", + importThemeDto: "=", }, }); -app.component("themeImportCultures", { +app.component("themeExportCultures", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-cultures/view.html", + "/mix-app/views/app-portal/pages/theme/components/theme-export-cultures/view.html", controller: [ "$rootScope", "$scope", @@ -8709,18 +8856,18 @@ app.component("themeImportCultures", { ctrl.selectContent = (culture, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - culture.isImportData = selected && culture.isImportData; + culture.isExportData = selected && culture.isExportData; ctrl.updateContent([culture.id], selected); }; ctrl.updateContent = function (arr, selected) { if (selected) { - ctrl.importThemeDto.cultureIds = ctrl.unionArray( - ctrl.importThemeDto.cultureIds, + ctrl.exportThemeDto.cultureIds = ctrl.unionArray( + ctrl.exportThemeDto.cultureIds, arr ); } else { - ctrl.importThemeDto.cultureIds = - ctrl.importThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); + ctrl.exportThemeDto.cultureIds = + ctrl.exportThemeDto.cultureIds.filter((m) => arr.indexOf(m) < 0); ctrl.updateData(arr, false); } }; @@ -8740,16 +8887,13 @@ app.component("themeImportCultures", { }, ], bindings: { - importThemeDto: "=", + exportThemeDto: "=", }, }); -app.component("themeImportMixDatabases", { +app.component("themeExportMixDatabases", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-mix-databases/view.html", - bindings: { - importThemeDto: "=", - }, + "/mix-app/views/app-portal/pages/theme/components/theme-export-mix-databases/view.html", controller: [ "$rootScope", "$scope", @@ -8761,15 +8905,32 @@ app.component("themeImportMixDatabases", { ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { - ctrl.data = ctrl.importThemeDto.mixDatabases; + ctrl.request.pageSize = null; + ctrl.getList(); + }; + ctrl.getList = async (mixDatabaseIndex) => { + if (mixDatabaseIndex !== undefined) { + ctrl.request.mixDatabaseIndex = mixDatabaseIndex; + } + 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 = (mixDatabase, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - mixDatabase.isImportData = selected && mixDatabase.isImportData; - ctrl.importThemeDto.content.mixDatabaseIds = ctrl.updateArray( - ctrl.importThemeDto.content.mixDatabaseIds, + mixDatabase.isExportData = selected && mixDatabase.isExportData; + ctrl.exportThemeDto.content.mixDatabaseIds = ctrl.updateArray( + ctrl.exportThemeDto.content.mixDatabaseIds, [mixDatabase.id], selected ); @@ -8779,8 +8940,8 @@ app.component("themeImportMixDatabases", { }; ctrl.selectData = (mixDatabase, selected) => { ctrl.selectAllData = ctrl.selectAllData && selected; - ctrl.importThemeDto.associations.mixDatabaseIds = ctrl.updateArray( - ctrl.importThemeDto.associations.mixDatabaseIds, + ctrl.exportThemeDto.associations.mixDatabaseIds = ctrl.updateArray( + ctrl.exportThemeDto.associations.mixDatabaseIds, [mixDatabase.id], selected ); @@ -8798,28 +8959,22 @@ app.component("themeImportMixDatabases", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isImportData = ctrl.selectAllData; + e.isExportData = ctrl.selectAllData; }); }; - ctrl.validate = (mixDatabase) => { - if ( - ctrl.importThemeDto.invalidDatabaseNames.indexOf( - mixDatabase.systemName - ) >= 0 - ) { - return `${mixDatabase.systemName} is invalid`; - } - }; ctrl.unionArray = (a, b) => { return [...new Set([...a, ...b])]; }; }, ], + bindings: { + exportThemeDto: "=", + }, }); -app.component("themeImportModules", { +app.component("themeExportModules", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-modules/view.html", + "/mix-app/views/app-portal/pages/theme/components/theme-export-modules/view.html", controller: [ "$rootScope", "$scope", @@ -8831,6 +8986,7 @@ app.component("themeImportModules", { ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { + ctrl.request.pageSize = null; ctrl.getList(); }; ctrl.getList = async (moduleIndex) => { @@ -8853,17 +9009,17 @@ app.component("themeImportModules", { ctrl.selectContent = (module, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - module.isImportData = selected && module.isImportData; + module.isExportData = selected && module.isExportData; let contentIds = module.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.content.moduleIds = ctrl.updateArray( - ctrl.importThemeDto.content.moduleIds, + ctrl.exportThemeDto.content.moduleIds = ctrl.updateArray( + ctrl.exportThemeDto.content.moduleIds, [module.id], selected ); - ctrl.importThemeDto.content.moduleContentIds = ctrl.updateArray( - ctrl.importThemeDto.content.moduleContentIds, + ctrl.exportThemeDto.content.moduleContentIds = ctrl.updateArray( + ctrl.exportThemeDto.content.moduleContentIds, contentIds, selected ); @@ -8876,13 +9032,13 @@ app.component("themeImportModules", { let contentIds = module.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.associations.moduleIds = ctrl.updateArray( - ctrl.importThemeDto.associations.moduleIds, + ctrl.exportThemeDto.associations.moduleIds = ctrl.updateArray( + ctrl.exportThemeDto.associations.moduleIds, [module.id], selected ); - ctrl.importThemeDto.associations.moduleContentIds = ctrl.updateArray( - ctrl.importThemeDto.associations.moduleContentIds, + ctrl.exportThemeDto.associations.moduleContentIds = ctrl.updateArray( + ctrl.exportThemeDto.associations.moduleContentIds, contentIds, selected ); @@ -8900,7 +9056,7 @@ app.component("themeImportModules", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isImportData = ctrl.selectAllData; + e.isExportData = ctrl.selectAllData; }); }; ctrl.unionArray = (a, b) => { @@ -8909,13 +9065,13 @@ app.component("themeImportModules", { }, ], bindings: { - importThemeDto: "=", + exportThemeDto: "=", }, }); -app.component("themeImportPages", { +app.component("themeExportPages", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-pages/view.html", + "/mix-app/views/app-portal/pages/theme/components/theme-export-pages/view.html", controller: [ "$rootScope", "$scope", @@ -8927,6 +9083,7 @@ app.component("themeImportPages", { ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { + ctrl.request.pageSize = null; ctrl.getList(); }; ctrl.getList = async (pageIndex) => { @@ -8949,17 +9106,17 @@ app.component("themeImportPages", { ctrl.selectContent = (page, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - page.isImportData = selected && page.isImportData; + page.isExportData = selected && page.isExportData; let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.content.pageIds = ctrl.updateArray( - ctrl.importThemeDto.content.pageIds, + ctrl.exportThemeDto.content.pageIds = ctrl.updateArray( + ctrl.exportThemeDto.content.pageIds, [page.id], selected ); - ctrl.importThemeDto.content.pageContentIds = ctrl.updateArray( - ctrl.importThemeDto.content.pageContentIds, + ctrl.exportThemeDto.content.pageContentIds = ctrl.updateArray( + ctrl.exportThemeDto.content.pageContentIds, contentIds, selected ); @@ -8972,13 +9129,13 @@ app.component("themeImportPages", { let contentIds = page.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.associations.pageIds = ctrl.updateArray( - ctrl.importThemeDto.associations.pageIds, + ctrl.exportThemeDto.associations.pageIds = ctrl.updateArray( + ctrl.exportThemeDto.associations.pageIds, [page.id], selected ); - ctrl.importThemeDto.associations.pageContentIds = ctrl.updateArray( - ctrl.importThemeDto.associations.pageContentIds, + ctrl.exportThemeDto.associations.pageContentIds = ctrl.updateArray( + ctrl.exportThemeDto.associations.pageContentIds, contentIds, selected ); @@ -8996,7 +9153,7 @@ app.component("themeImportPages", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isImportData = ctrl.selectAllData; + e.isExportData = ctrl.selectAllData; }); }; ctrl.unionArray = (a, b) => { @@ -9005,24 +9162,27 @@ app.component("themeImportPages", { }, ], bindings: { - importThemeDto: "=", + exportThemeDto: "=", }, }); -app.component("themeImportPosts", { +app.component("themeExportPosts", { templateUrl: - "/mix-app/views/app-portal/pages/theme-import/components/theme-import-posts/view.html", + "/mix-app/views/app-portal/pages/theme/components/theme-export-posts/view.html", controller: [ "$rootScope", "$scope", "ngAppSettings", - function ($rootScope, $scope, ngAppSettings) { + "BaseRestService", + function ($rootScope, $scope, ngAppSettings, baseRestService) { var ctrl = this; - var service = $rootScope.getRestService("mix-post"); + var service = angular.copy(baseRestService); + service.initService("/rest/mix-library", "mix-post"); ctrl.selectAllContent = false; ctrl.selectAllData = false; ctrl.request = angular.copy(ngAppSettings.request); ctrl.$onInit = async () => { + ctrl.request.pageSize = null; ctrl.getList(); }; ctrl.getList = async (postIndex) => { @@ -9045,17 +9205,17 @@ app.component("themeImportPosts", { ctrl.selectContent = (post, selected) => { ctrl.selectAllContent = ctrl.selectAllContent && selected; ctrl.selectAllData = ctrl.selectAllData && selected; - post.isImportData = selected && post.isImportData; + post.isExportData = selected && post.isExportData; let contentIds = post.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.content.postIds = ctrl.updateArray( - ctrl.importThemeDto.content.postIds, + ctrl.exportThemeDto.content.postIds = ctrl.updateArray( + ctrl.exportThemeDto.content.postIds, [post.id], selected ); - ctrl.importThemeDto.content.postContentIds = ctrl.updateArray( - ctrl.importThemeDto.content.postContentIds, + ctrl.exportThemeDto.content.postContentIds = ctrl.updateArray( + ctrl.exportThemeDto.content.postContentIds, contentIds, selected ); @@ -9068,13 +9228,13 @@ app.component("themeImportPosts", { let contentIds = post.contents.map(function (obj) { return obj.id; }); - ctrl.importThemeDto.associations.postIds = ctrl.updateArray( - ctrl.importThemeDto.associations.postIds, + ctrl.exportThemeDto.associations.postIds = ctrl.updateArray( + ctrl.exportThemeDto.associations.postIds, [post.id], selected ); - ctrl.importThemeDto.associations.postContentIds = ctrl.updateArray( - ctrl.importThemeDto.associations.postContentIds, + ctrl.exportThemeDto.associations.postContentIds = ctrl.updateArray( + ctrl.exportThemeDto.associations.postContentIds, contentIds, selected ); @@ -9092,7 +9252,7 @@ app.component("themeImportPosts", { ctrl.selectContent(e, ctrl.selectAllContent); ctrl.selectData(e, ctrl.selectAllData); e.isActived = ctrl.selectAllContent; - e.isImportData = ctrl.selectAllData; + e.isExportData = ctrl.selectAllData; }); }; ctrl.unionArray = (a, b) => { @@ -9101,7 +9261,7 @@ app.component("themeImportPosts", { }, ], bindings: { - importThemeDto: "=", + exportThemeDto: "=", }, }); @@ -9728,6 +9888,49 @@ modules.component("confirm", { }, }); +modules.component("funding", { + templateUrl: "/mix-app/views/app-portal/components/funding/view.html", + controller: [ + "$rootScope", + "$http", + function ($rootScope, $http) { + var ctrl = this; + ctrl.items = [ + { + title: "opencollective.com/mixcore", + href: "https://opencollective.com/mixcore", + logo: + "https://github.githubassets.com/images/modules/site/icons/funding_platforms/open_collective.svg", + }, + { + title: "funding.communitybridge.org/projects/mixcore", + href: "https://crowdfunding.lfx.linuxfoundation.org/projects/mixcore", + logo: + "https://github.githubassets.com/images/modules/site/icons/funding_platforms/community_bridge.svg", + }, + { + title: "patreon.com/mixcore", + href: "https://www.patreon.com/mixcore/creators", + logo: + "https://github.githubassets.com/images/modules/site/icons/funding_platforms/patreon.svg", + }, + { + title: "paypalme/mixcore", + href: "https://www.paypal.me/mixcore", + logo: "/mix-app/assets/img/svg/heart.svg", + }, + { + title: "buymeacoffee.com/mixcore", + href: "https://www.buymeacoffee.com/mixcore", + logo: "/mix-app/assets/img/svg/heart.svg", + }, + ]; + ctrl.init = function () {}; + }, + ], + bindings: {}, +}); + modules.component("customImage", { templateUrl: "/mix-app/views/app-portal/components/custom-image/custom-image.html", @@ -10292,6 +10495,79 @@ modules.component("googleAnalytic", { ], }); +modules.component("filterList", { + templateUrl: + "/mix-app/views/app-portal/components/filter-list/filter-list.html", + controller: [ + "$scope", + "$rootScope", + "ngAppSettings", + "CultureService", + function ($scope, $rootScope, ngAppSettings, cultureService) { + var ctrl = this; + ctrl.dateRange = { + fromDate: null, + toDate: null, + }; + ctrl.searchMethods = ["Equal", "Like"]; + ctrl.init = async function () { + if (!ctrl.arrOrderby) { + ctrl.arrOrderby = [ + "Title", + "Priority", + "CreatedDateTime", + "LastModified", + "Status", + ]; + } + ctrl.request.orderBy = ctrl.request.orderBy || ctrl.arrOrderby[0]; + ctrl.directions = ["Asc", "Desc"]; + ctrl.pageSizes = [5, 10, 15, 20]; + ctrl.statuses = $rootScope.globalSettings.statuses; + }; + ctrl.changeLang = function (culture) { + if (culture) { + ctrl.selectedCulture = culture; + ctrl.request.culture = culture.specificulture; + } else { + ctrl.selectedCulture = null; + ctrl.request.culture = null; + } + ctrl.apply(0); + }; + ctrl.apply = function (pageIndex) { + $rootScope.setRequest(ctrl.request, ctrl.key); + ctrl.callback({ pageIndex: pageIndex }); + }; + ctrl.updateDate = function () { + ctrl.request.pageIndex = 0; + if (Date.parse(ctrl.dateRange.fromDate)) { + ctrl.request.fromDate = new Date( + ctrl.dateRange.fromDate + ).toISOString(); + } else { + $scope.request.fromDate = null; + } + if (Date.parse(ctrl.dateRange.toDate)) { + ctrl.request.toDate = new Date(ctrl.dateRange.toDate).toISOString(); + } else { + ctrl.request.toDate = null; + } + $rootScope.setRequest(ctrl.request, ctrl.key); + ctrl.callback({ pageIndex: 0 }); + }; + }, + ], + bindings: { + request: "=", + key: "=?", + arrOrderby: "=?", + createUrl: "=", + createText: "=", + callback: "&", + }, +}); + (function (angular) { app.component("headerNav", { templateUrl: @@ -10396,28 +10672,65 @@ modules.component("googleAnalytic", { }); })(window.angular); -modules.component("highFrequencyMessages", { +modules.component("githubContributers", { templateUrl: - "/mix-app/views/app-portal/components/high-frequency-messages/view.html", - controller: "HighFrequencyMessagesController", - bindings: {}, -}); -app.controller("HighFrequencyMessagesController", [ - "$scope", - "$rootScope", - "AuthService", - function ($scope, $rootScope, authService) { + "/mix-app/views/app-portal/components/github-contributers/view.html", + controller: [ + "$rootScope", + "$http", + function ($rootScope, $http) { + var ctrl = this; + ctrl.items = []; + ctrl.init = function () { + var req = { + method: "GET", + url: "https://api.github.com/repos/mixcore/mix.core/contributors", + }; + ctrl.getGithubApiResult(req); + }; + + ctrl.getGithubApiResult = async function (req) { + return $http(req).then( + function (resp) { + if (resp.status == "200") { + ctrl.items = resp.data; + } else { + } + }, + function (error) { + return { + success: false, + errors: [error.statusText || error.status], + }; + } + ); + }; + }, + ], + bindings: {}, +}); + +modules.component("hubMessages", { + templateUrl: + "/mix-app/views/app-portal/components/hub-messages/hub-messages.html", + controller: "HubMessagesController", + bindings: {}, +}); +app.controller("HubMessagesController", [ + "$scope", + "$rootScope", + "AuthService", + function ($scope, $rootScope, authService) { BaseHub.call(this, $scope); authService.fillAuthData(); $scope.newMsgCount = 0; $scope.messages = []; - $scope.mouses = []; - $scope.init = function () { - // $scope.connectHightFrequencyHub(); + $scope.onConnected = () => { + // $scope.joinRoom("portal"); }; - $scope.connectHightFrequencyHub = () => { + $scope.init = function () { $scope.startConnection( - "highFrequencyHub", + "portalHub", authService.authentication.accessToken, (err) => { if ( @@ -10426,7 +10739,7 @@ app.controller("HighFrequencyMessagesController", [ ) { authService.refreshToken().then(async () => { $scope.startConnection( - "highFrequencyHub", + "portalHub", authService.authentication.accessToken ); }); @@ -10434,99 +10747,44 @@ app.controller("HighFrequencyMessagesController", [ } ); }; - $scope.onConnected = () => { - $scope.joinRoom("mouseMove_portal"); - $scope.streamMouseMove(); - }; - $scope.onLeave = () => { - clearInterval($scope.intervalHandle); - $scope.subject.complete(); - }; - $scope.streamMouseMove = () => { - document.onmousemove = $scope.handleMouseMove; - $scope.subject = new signalR.Subject(); - // Send a maximum of 10 messages per second - // (mouse movements trigger a lot of messages) - var messageFrequency = 60, - // Determine how often to send messages in - // time to abide by the messageFrequency - updateRate = 1000 / messageFrequency; - // Start the client side server update interval - $scope.hubRequest.title = "MouseMove"; - $scope.connection.invoke("UploadStream", $scope.subject, $scope.room); - $scope.intervalHandle = setInterval($scope.updateMouse, updateRate); - }; - $scope.receiveMessage = function (data) { - var msg = JSON.parse(data); - switch (msg.title) { - case "MouseMove": - let mouse = $scope.mouses.find( - (m) => m.from.username == msg.from.username + $scope.readMessages = function () { + $scope.newMsgCount = 0; + $("#modal-hub-messages").modal("show"); + }; + $scope.receiveMessage = function (msg) { + switch (msg.action) { + case "MyConnection": + $scope.hubRequest.from = msg.data; + $scope.$apply(); + break; + case "MemberList": + // filter unique member by username + $scope.members = msg.data.filter( + (value, index, array) => + array.indexOf(array.find((u) => u.username == value.username)) === + index ); - if (!mouse) { - $scope.mouses.push(msg); - } else { - mouse.data.x = msg.data.x; - mouse.data.y = msg.data.y; - } $scope.$apply(); break; - default: + case "NewMember": + $scope.newMember(msg.data); + break; + case "MemberOffline": + $scope.removeMember(msg.data); + case "NewMessage": + $scope.newMessage(msg); break; } }; - $scope.updateMouse = () => { - if ($scope.room && $scope.mousePos && $scope.moved) { - let msg = angular.copy($scope.hubRequest); - msg.data = $scope.mousePos; - $scope.subject.next(JSON.stringify(msg)); - $scope.moved = false; - } else { - // Use pos.x and pos.y - } - // if (iteration === 10) { - // clearInterval(intervalHandle); - // subject.complete(); - // } - }; - $scope.handleMouseMove = (event) => { - var dot, eventDoc, doc, body, pageX, pageY; - - event = event || window.event; // IE-ism - - // If pageX/Y aren't available and clientX/Y are, - // calculate pageX/Y - logic taken from jQuery. - // (This is to support old IE) - if (event.pageX == null && event.clientX != null) { - eventDoc = (event.target && event.target.ownerDocument) || document; - doc = eventDoc.documentElement; - body = eventDoc.body; - - event.pageX = - event.clientX + - ((doc && doc.scrollLeft) || (body && body.scrollLeft) || 0) - - ((doc && doc.clientLeft) || (body && body.clientLeft) || 0); - event.pageY = - event.clientY + - ((doc && doc.scrollTop) || (body && body.scrollTop) || 0) - - ((doc && doc.clientTop) || (body && body.clientTop) || 0); - } - let x = (event.pageX / screen.width) * 100; - let y = (event.pageY / screen.height) * 100; + $scope.newMessage = function (msg) { + msg.style = $scope.getMessageType(msg.type); if ( - !$scope.mousePos || - ($scope.mousePos.x != x && $scope.mousePos.y != y) + msg.data && + !angular.isObject(msg.data) && + msg.data.indexOf("{") == 0 ) { - $scope.moved = true; - $scope.mousePos = { - x: x, - y: y, - }; + msg.data = JSON.parse(msg.data); } - }; - - $scope.newMessage = function (msg) { - msg.style = $scope.getMessageType(msg.type); $scope.messages.push(msg); if ( !msg.from || @@ -11347,6 +11605,29 @@ modules.component("mainSideBar", { }, }); +modules.component("mainSideBarItem", { + templateUrl: + "/mix-app/views/app-portal/components/main-side-bar-item/main-side-bar-item.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.translate = $rootScope.translate; + ctrl.addClass = function (obj) { + obj.currentTarget.classList.add("btn-group-lg"); + //alert(obj); + }; + ctrl.removeClass = function (obj) { + obj.currentTarget.classList.remove("btn-group-lg"); + //alert(obj); + }; + }, + ], + bindings: { + item: "=", + }, +}); + modules.component("mainSideBarDynamic", { templateUrl: "/mix-app/views/app-portal/components/main-side-bar-dynamic/main-side-bar-dynamic.html", @@ -11388,29 +11669,6 @@ modules.component("mainSideBarDynamic", { }, }); -modules.component("mainSideBarItem", { - templateUrl: - "/mix-app/views/app-portal/components/main-side-bar-item/main-side-bar-item.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.translate = $rootScope.translate; - ctrl.addClass = function (obj) { - obj.currentTarget.classList.add("btn-group-lg"); - //alert(obj); - }; - ctrl.removeClass = function (obj) { - obj.currentTarget.classList.remove("btn-group-lg"); - //alert(obj); - }; - }, - ], - bindings: { - item: "=", - }, -}); - modules.component("mainSideBarItemDynamic", { templateUrl: "/mix-app/views/app-portal/components/main-side-bar-item-dynamic/main-side-bar-item-dynamic.html", @@ -11592,6 +11850,44 @@ modules.component("mediaFileUpload", { ], }); +modules.component("mediumNews", { + templateUrl: "/mix-app/views/app-portal/components/medium-news/view.html", + controller: [ + "$rootScope", + "$http", + function ($rootScope, $http) { + var ctrl = this; + ctrl.items = []; + ctrl.init = function () { + var req = { + method: "GET", + url: + "https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/mixcore&api_key=qww481wpgat3g4iqvqss7spzrilkbekpxpjgrbof&t=" + + Math.floor(Date.now() / 1000), + }; + ctrl.getMediumApiResult(req); + }; + + ctrl.getMediumApiResult = async function (req) { + return $http(req).then( + function (resp) { + if (resp.status == "200") { + ctrl.items = resp.data.items; + } + }, + function (error) { + return { + success: false, + errors: [error.statusText || error.status], + }; + } + ); + }; + }, + ], + bindings: {}, +}); + modules.component("mediaUpload", { templateUrl: "/mix-app/views/app-portal/components/media-upload/media-upload.html", @@ -11653,44 +11949,6 @@ modules.component("mediaUpload", { }, }); -modules.component("mediumNews", { - templateUrl: "/mix-app/views/app-portal/components/medium-news/view.html", - controller: [ - "$rootScope", - "$http", - function ($rootScope, $http) { - var ctrl = this; - ctrl.items = []; - ctrl.init = function () { - var req = { - method: "GET", - url: - "https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/mixcore&api_key=qww481wpgat3g4iqvqss7spzrilkbekpxpjgrbof&t=" + - Math.floor(Date.now() / 1000), - }; - ctrl.getMediumApiResult(req); - }; - - ctrl.getMediumApiResult = async function (req) { - return $http(req).then( - function (resp) { - if (resp.status == "200") { - ctrl.items = resp.data.items; - } - }, - function (error) { - return { - success: false, - errors: [error.statusText || error.status], - }; - } - ); - }; - }, - ], - bindings: {}, -}); - app.component("mixMetadata", { templateUrl: "/mix-app/views/app-portal/components/metadata/view.html", bindings: { @@ -12567,42 +12825,403 @@ modules.component("mixDatabaseDataValues", { ], }); -modules.component("mixDatabaseForm", { +modules.component("mixDatabaseNavs", { templateUrl: - "/mix-app/views/app-portal/components/mix-database-form/view.html", + "/mix-app/views/app-portal/components/mix-database-navs/view.html", bindings: { - mixDatabaseId: "=?", - mixDatabaseName: "=?", - mixDatabaseTitle: "=?", - mixDatabaseType: "=?", - parentId: "=?", - parentType: "=?", // MixContentType - parentName: "=?", - postId: "=?", - pageId: "=?", - moduleId: "=?", - columns: "=?", - references: "=?", - mixDataContentId: "=?", - mixDataContent: "=?", - intParentId: "=?", - guidParentId: "=?", - defaultId: "=", - backUrl: "=?", - level: "=?", - hideAction: "=?", - onSave: "&?", - onSaveSuccess: "&?", + parentId: "=", + parentType: "=", + mixDatabaseNavs: "=?", + onUpdate: "&?", + onDelete: "&?", }, controller: [ "$rootScope", "$scope", - "$routeParams", - "RestMixAssociationPortalService", + "ngAppSettings", + "RestRelatedMixDatabasePortalService", "RestMixDatabasePortalService", - "MixDbService", - "AuthService", - function ( + function ($rootScope, $scope, ngAppSettings, navService, setService) { + var ctrl = this; + ctrl.mixDatabaseNavs = ctrl.mixDatabaseNavs || []; + ctrl.selected = {}; + ctrl.defaultData = null; + ctrl.navRequest = angular.copy(ngAppSettings.request); + ctrl.setRequest = angular.copy(ngAppSettings.request); + + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = function () { + // ctrl.setRequest.type = ctrl.parentType; + navService.getDefault().then((resp) => { + resp.parentId = ctrl.parentId; + resp.parentType = ctrl.parentType; + ctrl.defaultData = resp; + ctrl.loadData(); + }); + }; + ctrl.goToPath = $rootScope.goToPath; + ctrl.selectPane = function (pane) {}; + ctrl.loadData = async function () { + // Load attr set navs if not in input + if (!ctrl.mixDatabaseNavs) { + ctrl.navRequest.parentType = ctrl.parentType; + ctrl.navRequest.parentId = ctrl.parentId; + var resp = await navService.getList(ctrl.navRequest); + if (resp) { + angular.forEach(resp.data.items, (e) => { + e.isActived = true; + ctrl.mixDatabaseNavs.push(e); + }); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + } + } else { + angular.forEach(ctrl.mixDatabaseNavs, (e) => { + e.isActived = true; + }); + } + + var setResult = await setService.getList(ctrl.setRequest); + if (setResult) { + angular.forEach(setResult.data.items, (element) => { + var e = $rootScope.findObjectByKey( + ctrl.mixDatabaseNavs, + "mixDatabaseId", + element.id + ); + if (!e) { + e = angular.copy(ctrl.defaultData); + e.status = "Published"; + e.mixDatabaseId = element.id; + e.specificulture = navService.lang; + e.data = element; + e.isActived = false; + ctrl.mixDatabaseNavs.push(e); + } + }); + } else { + if (setResult) { + $rootScope.showErrors("Others Failed"); + } + } + $scope.$apply(); + }; + ctrl.change = async function (nav) { + $rootScope.isBusy = true; + var result; + if (nav.isActived) { + ctrl.active(nav); + } else { + ctrl.deactive(nav); + } + }; + + ctrl.deactive = async function (nav) { + let result = null; + if (nav.id) { + result = await navService.delete([nav.id]); + $(".pane-container-" + nav.data.id) + .parent() + .remove(); + } + if (result && result.success) { + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + } + }; + + ctrl.active = async function (nav) { + $rootScope.isBusy = true; + var result; + result = await navService.save(nav); + if (result && result.success) { + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + ctrl.update = function (data) { + ctrl.onUpdate({ + data: data, + }); + }; + + ctrl.delete = function (data) { + ctrl.onDelete({ + data: data, + }); + }; + + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + ctrl.minPriority = ctrl.mixDatabaseNavs[0].priority; + }; + ctrl.updateOrders = function (index) { + if (index > ctrl.dragStartIndex) { + ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex, 1); + } else { + ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex + 1, 1); + } + var arrNavs = []; + angular.forEach(ctrl.mixDatabaseNavs, function (e, i) { + e.priority = ctrl.minPriority + i; + var keys = { + parentId: e.parentId, + parentType: e.parentType, + id: e.id, + }; + var properties = { + priority: e.priority, + }; + arrNavs.push({ + keys: keys, + properties: properties, + }); + }); + navService.saveProperties("portal", arrNavs).then((resp) => { + $rootScope.isBusy = false; + $scope.$apply(); + }); + }; + }, + ], +}); + +modules.component("mixDatabaseNavValues", { + templateUrl: + "/mix-app/views/app-portal/components/mix-database-nav-values/view.html", + bindings: { + mixDatabaseId: "=", + mixDatabaseName: "=", + guidParentId: "=", + parentType: "=", + columns: "=?", + header: "=", + data: "=?", + maxCol: "=?", + createUrl: "=?", + updateUrl: "=?", + onUpdate: "&?", + onDelete: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "RestRelatedAttributeDataPortalService", + "RestMixDatabaseColumnPortalService", + function ($rootScope, $scope, ngAppSettings, navService, columnService) { + var ctrl = this; + ctrl.selectedProp = null; + ctrl.request = angular.copy(ngAppSettings.restRequest); + ctrl.request.orderBy = "Priority"; + ctrl.request.query = "{}"; + + ctrl.request.direction = 0; + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = async function () { + ctrl.maxCol = ctrl.maxCol || 3; + if (!ctrl.createUrl) { + ctrl.createUrl = "/admin/mix-database-data/create"; + } + if (!ctrl.updateUrl) { + ctrl.updateUrl = "/admin/mix-database-data/details"; + } + if (!ctrl.columns) { + var getFields = await columnService.initData( + ctrl.mixDatabaseName || ctrl.mixDatabaseId + ); + if (getFields.success) { + ctrl.columns = getFields.data; + $scope.$apply(); + } + } + if (!ctrl.data) { + ctrl.loadData(); + } + }; + + ctrl.update = function (data) { + ctrl.onUpdate({ data: data }); + }; + + ctrl.delete = function (data) { + ctrl.onDelete({ data: data }); + }; + + ctrl.filterData = function (item, attributeName) { + return $rootScope.findObjectByKey( + item.data, + "attributeName", + attributeName + ); + }; + + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + ctrl.minPriority = ctrl.data.items[0].priority; + }; + ctrl.updateOrders = function (index) { + if (index > ctrl.dragStartIndex) { + ctrl.data.items.splice(ctrl.dragStartIndex, 1); + } else { + ctrl.data.items.splice(ctrl.dragStartIndex + 1, 1); + } + angular.forEach(ctrl.data.items, function (e, i) { + e.priority = ctrl.minPriority + i; + navService.saveFields(e.id, { priority: e.priority }).then((resp) => { + $rootScope.isBusy = false; + $scope.$apply(); + }); + }); + }; + + ctrl.loadData = function () { + ctrl.request.mixDatabaseId = ctrl.mixDatabaseId || 0; + ctrl.request.mixDatabaseName = ctrl.mixDatabaseName || null; + ctrl.request.guidParentId = ctrl.guidParentId; + ctrl.request.intParentId = ctrl.intParentId; + ctrl.request.parentType = ctrl.parentType; + navService.getList(ctrl.request).then((resp) => { + if (resp) { + ctrl.data = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors("Failed"); + } + ctrl.refData = []; + $rootScope.isBusy = false; + $scope.$apply(); + } + }); + }; + ctrl.updateData = function (nav) { + $rootScope.goToPath( + `${ctrl.updateUrl}?dataContentId=${nav.childDataContent.id}&mixDatabaseId=${nav.mixDatabaseId}&guidParentId=${ctrl.guidParentId}&parentType=${ctrl.parentType}` + ); + // ctrl.refDataModel = nav; + // var e = $(".pane-form-" + ctrl.mixDatabaseDataValue.column.referenceId)[0]; + // angular.element(e).triggerHandler('click'); + // $location.url('/admin/mix-database-data/details?dataContentId='+ item.id +'&mixDatabaseId=' + item.mixDatabaseId+'&parentType=' + item.parentType+'&parentId=' + item.parentId); + }; + ctrl.saveData = function (data) { + $rootScope.isBusy = true; + ctrl.refDataModel.data = data; + dataService.save("portal", data).then((resp) => { + if (resp.success) { + ctrl.refDataModel.id = resp.data.id; + ctrl.refDataModel.data = resp.data; + navService.save("portal", ctrl.refDataModel).then((resp) => { + if (resp.success) { + var tmp = $rootScope.findObjectByKey( + ctrl.refData, + ["parentId", "parentType", "id"], + [resp.data.parentId, resp.data.parentType, resp.data.id] + ); + if (!tmp) { + ctrl.refData.push(resp.data); + } + ctrl.refDataModel = angular.copy(ctrl.defaultDataModel); + var e = $( + ".pane-data-" + ctrl.mixDatabaseDataValue.column.referenceId + )[0]; + angular.element(e).triggerHandler("click"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }); + }; + ctrl.removeData = async function (nav) { + $rootScope.showConfirm( + ctrl, + "removeDataConfirmed", + [nav], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + ctrl.removeDataConfirmed = async function (nav) { + $rootScope.isBusy = true; + var result = await navService.delete([nav.id]); + if (result.success) { + $rootScope.removeObjectByKey(ctrl.data.items, "id", nav.id); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + ctrl.view = function (item) { + var obj = { + columns: ctrl.columns, + item: item, + }; + $rootScope.preview("mix-database-data", obj, null, "modal-lg"); + }; + }, + ], +}); + +modules.component("mixDatabaseForm", { + templateUrl: + "/mix-app/views/app-portal/components/mix-database-form/view.html", + bindings: { + mixDatabaseId: "=?", + mixDatabaseName: "=?", + mixDatabaseTitle: "=?", + mixDatabaseType: "=?", + parentId: "=?", + parentType: "=?", // MixContentType + parentName: "=?", + postId: "=?", + pageId: "=?", + moduleId: "=?", + columns: "=?", + references: "=?", + mixDataContentId: "=?", + mixDataContent: "=?", + intParentId: "=?", + guidParentId: "=?", + defaultId: "=", + backUrl: "=?", + level: "=?", + hideAction: "=?", + onSave: "&?", + onSaveSuccess: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "$routeParams", + "RestMixAssociationPortalService", + "RestMixDatabasePortalService", + "MixDbService", + "AuthService", + function ( $rootScope, $scope, $routeParams, @@ -12846,315 +13465,101 @@ modules.component("mixDatabaseForm", { mixDatabaseColumn; ctrl.mixDataContent.data.push(attr); } - return attr; - } - }; - }, - ], -}); - -modules.component("mixDatabaseNavData", { - templateUrl: - "/mix-app/views/app-portal/components/mix-database-nav-data/view.html", - bindings: { - nav: "=", - parentId: "=", - parentType: "=", - onUpdate: "&?", - onDelete: "&?", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "RestRelatedAttributeDataPortalService", - "RestMixDatabaseDataPortalService", - function ($rootScope, $scope, ngAppSettings, navService, dataService) { - var ctrl = this; - ctrl.data = null; - ctrl.selected = null; - ctrl.navRequest = angular.copy(ngAppSettings.request); - ctrl.setRequest = angular.copy(ngAppSettings.request); - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = function () { - navService - .getDefault([ctrl.parentId, ctrl.parentType, "default"]) - .then((resp) => { - ctrl.defaultData = resp.data; - ctrl.defaultData.parentId = ctrl.parentId; - ctrl.defaultData.parentType = ctrl.parentType; - ctrl.selected = angular.copy(ctrl.defaultData); - ctrl.loadData(); - }); - ctrl.navRequest.parentType = ctrl.parentType; - ctrl.navRequest.parentId = ctrl.parentId; - }; - ctrl.selectPane = function (pane) {}; - ctrl.loadData = function () { - navService.getList(ctrl.navRequest).then((resp) => { - if (resp) { - ctrl.data = resp.data; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $scope.$apply(); - } - }); - }; - ctrl.updateData = function (nav) { - ctrl.selected = nav; - var e = $(".pane-form-" + ctrl.nav.data.id)[0]; - angular.element(e).triggerHandler("click"); - // $location.url('/admin/mix-database-data/details?dataContentId='+ item.id +'&mixDatabaseId=' + item.mixDatabaseId+'&parentType=' + item.parentType+'&parentId=' + item.parentId); - }; - ctrl.saveData = function (data) { - $rootScope.isBusy = true; - ctrl.selected.data = data; - dataService.save(data).then((resp) => { - if (resp.success) { - ctrl.selected.dataContentId = resp.data.id; - ctrl.selected.mixDatabaseId = resp.data.mixDatabaseId; - ctrl.selected.mixDatabaseName = resp.data.mixDatabaseName; - ctrl.selected.attributeData = resp.data; - navService.save(ctrl.selected).then((resp) => { - if (resp.success) { - var tmp = $rootScope.findObjectByKey( - ctrl.data, - ["parentId", "parentType", "id"], - [resp.data.parentId, resp.data.parentType, resp.data.id] - ); - if (!tmp) { - ctrl.data.items.push(resp.data); - var e = $(".pane-data-" + ctrl.nav.data.id)[0]; - angular.element(e).triggerHandler("click"); - } - ctrl.selected = angular.copy(ctrl.defautData); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage(resp.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }); - } else { - $rootScope.showErrors(resp.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }); - }; - ctrl.removeData = async function (nav) { - $rootScope.showConfirm( - ctrl, - "removeDataConfirmed", - [nav], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - ctrl.removeDataConfirmed = async function (nav) { - $rootScope.isBusy = true; - var result = await navService.delete([nav.id]); - if (result.success) { - $rootScope.removeObjectByKey(ctrl.data, "id", nav.id); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - ctrl.dragStart = function (index) { - ctrl.dragStartIndex = index; - ctrl.minPriority = ctrl.data[0].priority; - }; - ctrl.updateOrders = function (index) { - if (index > ctrl.dragStartIndex) { - ctrl.data.splice(ctrl.dragStartIndex, 1); - } else { - ctrl.data.splice(ctrl.dragStartIndex + 1, 1); - } - var arrNavs = []; - angular.forEach(ctrl.data, 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("mixDatabaseNavValues", { - templateUrl: - "/mix-app/views/app-portal/components/mix-database-nav-values/view.html", - bindings: { - mixDatabaseId: "=", - mixDatabaseName: "=", - guidParentId: "=", - parentType: "=", - columns: "=?", - header: "=", - data: "=?", - maxCol: "=?", - createUrl: "=?", - updateUrl: "=?", - onUpdate: "&?", - onDelete: "&?", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "RestRelatedAttributeDataPortalService", - "RestMixDatabaseColumnPortalService", - function ($rootScope, $scope, ngAppSettings, navService, columnService) { - var ctrl = this; - ctrl.selectedProp = null; - ctrl.request = angular.copy(ngAppSettings.restRequest); - ctrl.request.orderBy = "Priority"; - ctrl.request.query = "{}"; - - ctrl.request.direction = 0; - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = async function () { - ctrl.maxCol = ctrl.maxCol || 3; - if (!ctrl.createUrl) { - ctrl.createUrl = "/admin/mix-database-data/create"; - } - if (!ctrl.updateUrl) { - ctrl.updateUrl = "/admin/mix-database-data/details"; - } - if (!ctrl.columns) { - var getFields = await columnService.initData( - ctrl.mixDatabaseName || ctrl.mixDatabaseId - ); - if (getFields.success) { - ctrl.columns = getFields.data; - $scope.$apply(); - } - } - if (!ctrl.data) { - ctrl.loadData(); + return attr; } }; + }, + ], +}); - ctrl.update = function (data) { - ctrl.onUpdate({ data: data }); - }; - - ctrl.delete = function (data) { - ctrl.onDelete({ data: data }); - }; - - ctrl.filterData = function (item, attributeName) { - return $rootScope.findObjectByKey( - item.data, - "attributeName", - attributeName - ); - }; - - ctrl.dragStart = function (index) { - ctrl.dragStartIndex = index; - ctrl.minPriority = ctrl.data.items[0].priority; - }; - ctrl.updateOrders = function (index) { - if (index > ctrl.dragStartIndex) { - ctrl.data.items.splice(ctrl.dragStartIndex, 1); - } else { - ctrl.data.items.splice(ctrl.dragStartIndex + 1, 1); - } - angular.forEach(ctrl.data.items, function (e, i) { - e.priority = ctrl.minPriority + i; - navService.saveFields(e.id, { priority: e.priority }).then((resp) => { - $rootScope.isBusy = false; - $scope.$apply(); +modules.component("mixDatabaseNavData", { + templateUrl: + "/mix-app/views/app-portal/components/mix-database-nav-data/view.html", + bindings: { + nav: "=", + parentId: "=", + parentType: "=", + onUpdate: "&?", + onDelete: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "RestRelatedAttributeDataPortalService", + "RestMixDatabaseDataPortalService", + function ($rootScope, $scope, ngAppSettings, navService, dataService) { + var ctrl = this; + ctrl.data = null; + ctrl.selected = null; + ctrl.navRequest = angular.copy(ngAppSettings.request); + ctrl.setRequest = angular.copy(ngAppSettings.request); + ctrl.mixConfigurations = $rootScope.globalSettings; + ctrl.$onInit = function () { + navService + .getDefault([ctrl.parentId, ctrl.parentType, "default"]) + .then((resp) => { + ctrl.defaultData = resp.data; + ctrl.defaultData.parentId = ctrl.parentId; + ctrl.defaultData.parentType = ctrl.parentType; + ctrl.selected = angular.copy(ctrl.defaultData); + ctrl.loadData(); }); - }); + ctrl.navRequest.parentType = ctrl.parentType; + ctrl.navRequest.parentId = ctrl.parentId; }; - + ctrl.selectPane = function (pane) {}; ctrl.loadData = function () { - ctrl.request.mixDatabaseId = ctrl.mixDatabaseId || 0; - ctrl.request.mixDatabaseName = ctrl.mixDatabaseName || null; - ctrl.request.guidParentId = ctrl.guidParentId; - ctrl.request.intParentId = ctrl.intParentId; - ctrl.request.parentType = ctrl.parentType; - navService.getList(ctrl.request).then((resp) => { + navService.getList(ctrl.navRequest).then((resp) => { if (resp) { ctrl.data = resp.data; - $rootScope.isBusy = false; $scope.$apply(); } else { if (resp) { - $rootScope.showErrors("Failed"); + $rootScope.showErrors(resp.errors); } - ctrl.refData = []; - $rootScope.isBusy = false; $scope.$apply(); } }); }; ctrl.updateData = function (nav) { - $rootScope.goToPath( - `${ctrl.updateUrl}?dataContentId=${nav.childDataContent.id}&mixDatabaseId=${nav.mixDatabaseId}&guidParentId=${ctrl.guidParentId}&parentType=${ctrl.parentType}` - ); - // ctrl.refDataModel = nav; - // var e = $(".pane-form-" + ctrl.mixDatabaseDataValue.column.referenceId)[0]; - // angular.element(e).triggerHandler('click'); + ctrl.selected = nav; + var e = $(".pane-form-" + ctrl.nav.data.id)[0]; + angular.element(e).triggerHandler("click"); // $location.url('/admin/mix-database-data/details?dataContentId='+ item.id +'&mixDatabaseId=' + item.mixDatabaseId+'&parentType=' + item.parentType+'&parentId=' + item.parentId); }; ctrl.saveData = function (data) { $rootScope.isBusy = true; - ctrl.refDataModel.data = data; - dataService.save("portal", data).then((resp) => { + ctrl.selected.data = data; + dataService.save(data).then((resp) => { if (resp.success) { - ctrl.refDataModel.id = resp.data.id; - ctrl.refDataModel.data = resp.data; - navService.save("portal", ctrl.refDataModel).then((resp) => { + ctrl.selected.dataContentId = resp.data.id; + ctrl.selected.mixDatabaseId = resp.data.mixDatabaseId; + ctrl.selected.mixDatabaseName = resp.data.mixDatabaseName; + ctrl.selected.attributeData = resp.data; + navService.save(ctrl.selected).then((resp) => { if (resp.success) { var tmp = $rootScope.findObjectByKey( - ctrl.refData, + ctrl.data, ["parentId", "parentType", "id"], [resp.data.parentId, resp.data.parentType, resp.data.id] ); if (!tmp) { - ctrl.refData.push(resp.data); + ctrl.data.items.push(resp.data); + var e = $(".pane-data-" + ctrl.nav.data.id)[0]; + angular.element(e).triggerHandler("click"); } - ctrl.refDataModel = angular.copy(ctrl.defaultDataModel); - var e = $( - ".pane-data-" + ctrl.mixDatabaseDataValue.column.referenceId - )[0]; - angular.element(e).triggerHandler("click"); + ctrl.selected = angular.copy(ctrl.defautData); $rootScope.isBusy = false; $scope.$apply(); } else { - $rootScope.showMessage("failed"); + $rootScope.showMessage(resp.errors); $rootScope.isBusy = false; $scope.$apply(); } }); } else { - $rootScope.showMessage("failed"); + $rootScope.showErrors(resp.errors); $rootScope.isBusy = false; $scope.$apply(); } @@ -13170,178 +13575,31 @@ modules.component("mixDatabaseNavValues", { "Deleted data will not able to recover, are you sure you want to delete this item?" ); }; - ctrl.removeDataConfirmed = async function (nav) { - $rootScope.isBusy = true; - var result = await navService.delete([nav.id]); - if (result.success) { - $rootScope.removeObjectByKey(ctrl.data.items, "id", nav.id); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - ctrl.view = function (item) { - var obj = { - columns: ctrl.columns, - item: item, - }; - $rootScope.preview("mix-database-data", obj, null, "modal-lg"); - }; - }, - ], -}); - -modules.component("mixDatabaseNavs", { - templateUrl: - "/mix-app/views/app-portal/components/mix-database-navs/view.html", - bindings: { - parentId: "=", - parentType: "=", - mixDatabaseNavs: "=?", - onUpdate: "&?", - onDelete: "&?", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "RestRelatedMixDatabasePortalService", - "RestMixDatabasePortalService", - function ($rootScope, $scope, ngAppSettings, navService, setService) { - var ctrl = this; - ctrl.mixDatabaseNavs = ctrl.mixDatabaseNavs || []; - ctrl.selected = {}; - ctrl.defaultData = null; - ctrl.navRequest = angular.copy(ngAppSettings.request); - ctrl.setRequest = angular.copy(ngAppSettings.request); - - ctrl.mixConfigurations = $rootScope.globalSettings; - ctrl.$onInit = function () { - // ctrl.setRequest.type = ctrl.parentType; - navService.getDefault().then((resp) => { - resp.parentId = ctrl.parentId; - resp.parentType = ctrl.parentType; - ctrl.defaultData = resp; - ctrl.loadData(); - }); - }; - ctrl.goToPath = $rootScope.goToPath; - ctrl.selectPane = function (pane) {}; - ctrl.loadData = async function () { - // Load attr set navs if not in input - if (!ctrl.mixDatabaseNavs) { - ctrl.navRequest.parentType = ctrl.parentType; - ctrl.navRequest.parentId = ctrl.parentId; - var resp = await navService.getList(ctrl.navRequest); - if (resp) { - angular.forEach(resp.data.items, (e) => { - e.isActived = true; - ctrl.mixDatabaseNavs.push(e); - }); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - } - } else { - angular.forEach(ctrl.mixDatabaseNavs, (e) => { - e.isActived = true; - }); - } - - var setResult = await setService.getList(ctrl.setRequest); - if (setResult) { - angular.forEach(setResult.data.items, (element) => { - var e = $rootScope.findObjectByKey( - ctrl.mixDatabaseNavs, - "mixDatabaseId", - element.id - ); - if (!e) { - e = angular.copy(ctrl.defaultData); - e.status = "Published"; - e.mixDatabaseId = element.id; - e.specificulture = navService.lang; - e.data = element; - e.isActived = false; - ctrl.mixDatabaseNavs.push(e); - } - }); - } else { - if (setResult) { - $rootScope.showErrors("Others Failed"); - } - } - $scope.$apply(); - }; - ctrl.change = async function (nav) { - $rootScope.isBusy = true; - var result; - if (nav.isActived) { - ctrl.active(nav); - } else { - ctrl.deactive(nav); - } - }; - - ctrl.deactive = async function (nav) { - let result = null; - if (nav.id) { - result = await navService.delete([nav.id]); - $(".pane-container-" + nav.data.id) - .parent() - .remove(); - } - if (result && result.success) { - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - } - }; - - ctrl.active = async function (nav) { + ctrl.removeDataConfirmed = async function (nav) { $rootScope.isBusy = true; - var result; - result = await navService.save(nav); - if (result && result.success) { + var result = await navService.delete([nav.id]); + if (result.success) { + $rootScope.removeObjectByKey(ctrl.data, "id", nav.id); $rootScope.isBusy = false; $scope.$apply(); } else { - $rootScope.showMessage("failed"); + $rootScope.showErrors(result.errors); $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.minPriority = ctrl.data[0].priority; }; ctrl.updateOrders = function (index) { if (index > ctrl.dragStartIndex) { - ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex, 1); + ctrl.data.splice(ctrl.dragStartIndex, 1); } else { - ctrl.mixDatabaseNavs.splice(ctrl.dragStartIndex + 1, 1); + ctrl.data.splice(ctrl.dragStartIndex + 1, 1); } var arrNavs = []; - angular.forEach(ctrl.mixDatabaseNavs, function (e, i) { + angular.forEach(ctrl.data, function (e, i) { e.priority = ctrl.minPriority + i; var keys = { parentId: e.parentId, @@ -13455,91 +13713,119 @@ modules.component("mixFileExtract", { ], }); -modules.component("mixFileUpload", { - templateUrl: "/mix-app/views/app-portal/components/mix-file-upload/view.html", - bindings: { - folder: "=?", - accept: "=?", - onFail: "&?", - onSuccess: "&?", - }, +modules.component("mixSelectIcons", { + templateUrl: + "/mix-app/views/app-portal/components/mix-select-icons/mix-select-icons.html", controller: [ "$rootScope", "$scope", - "ngAppSettings", - "FileServices", - function ($rootScope, $scope, ngAppSettings, fileService) { + "$location", + "$element", + function ($rootScope, $scope, $location, $element) { var ctrl = this; - ctrl.mediaFile = {}; - ctrl.isAdmin = $rootScope.isAdmin; - ctrl.mediaNavs = []; - ctrl.$onInit = function () { - ctrl.id = Math.floor(Math.random() * 100); + ctrl.limitTo = 20; + ctrl.container = $element[0].querySelector(".list-icon"); + ctrl.translate = function (keyword) { + return $rootScope.translate(keyword); }; - 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.showMore = () => { + if ( + ctrl.container.scrollTop >= ctrl.container.scrollHeight - 200 && + ctrl.limitTo < ctrl.options.length + ) { + ctrl.limitTo *= 2; } }; + ctrl.select = function (ico) { + ctrl.data = ico.class; + }; + }, + ], + bindings: { + data: "=", + prefix: "=", + options: "=", + }, +}); - 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; - } +modules.component("mixTemplateEditor", { + templateUrl: + "/mix-app/views/app-portal/components/mix-template-editor/view.html", + bindings: { + template: "=", + folderType: "=", + isReadonly: "=?", + lineCount: "=?", + hideJs: "=?", + hideCss: "=?", + }, + controller: [ + "$scope", + "$rootScope", + "$routeParams", + "ngAppSettings", + "AppSettingsService", + "TemplateService", + function ( + $scope, + $rootScope, + $routeParams, + ngAppSettings, + appSettingsService, + service + ) { + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + var ctrl = this; + ctrl.isNull = false; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.selectPane = function (pane) { + ctrl.activedPane = pane; + }; + ctrl.selectTemplate = function (template) { + ctrl.template = template; + $scope.$broadcast("updateContentCodeEditors", []); + }; + ctrl.new = function () { + ctrl.template.id = 0; }; + ctrl.init = async function () { + if (ctrl.folderType) { + var themeId = $rootScope.mixConfigurations.data.ThemeId; + ctrl.request.key = ctrl.folderType; + var resp = await service.getList(ctrl.request, [themeId]); - ctrl.uploadFile = async function () { - if (ctrl.file) { - $rootScope.isBusy = true; - var response = await fileService.uploadFile(ctrl.file, ctrl.folder); - if (response) { - if (ctrl.onSuccess) { - ctrl.onSuccess(); + if (resp && resp.success) { + ctrl.templates = resp.data.items; + if (!ctrl.template) { + ctrl.template = ctrl.templates[0]; } - $rootScope.showMessage("success", "success"); $rootScope.isBusy = false; $scope.$apply(); } else { - $rootScope.showErrors(['Cannot upload file']); - $rootScope.isBusy = false; - $scope.$apply(); + if (resp) { + $rootScope.showErrors(resp.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } } - } else { - $rootScope.showErrors(["Please choose file"]); } }; + ctrl.updateTemplateContent = function (content) { + ctrl.template.content = content; + }; + ctrl.updateStyleContent = function (content) { + ctrl.template.scripts = content; + }; + ctrl.updateScriptContent = function (content) { + ctrl.template.styles = content; + }; }, ], }); @@ -13665,39 +13951,93 @@ app.controller("MixNavigationController", [ }, ]); -modules.component("mixSelectIcons", { - templateUrl: - "/mix-app/views/app-portal/components/mix-select-icons/mix-select-icons.html", +modules.component("mixFileUpload", { + templateUrl: "/mix-app/views/app-portal/components/mix-file-upload/view.html", + bindings: { + folder: "=?", + accept: "=?", + onFail: "&?", + onSuccess: "&?", + }, controller: [ "$rootScope", "$scope", - "$location", - "$element", - function ($rootScope, $scope, $location, $element) { + "ngAppSettings", + "FileServices", + function ($rootScope, $scope, ngAppSettings, fileService) { var ctrl = this; - ctrl.limitTo = 20; - ctrl.container = $element[0].querySelector(".list-icon"); - ctrl.translate = function (keyword) { - return $rootScope.translate(keyword); + ctrl.mediaFile = {}; + ctrl.isAdmin = $rootScope.isAdmin; + ctrl.mediaNavs = []; + ctrl.$onInit = function () { + ctrl.id = Math.floor(Math.random() * 100); }; - ctrl.showMore = () => { - if ( - ctrl.container.scrollTop >= ctrl.container.scrollHeight - 200 && - ctrl.limitTo < ctrl.options.length - ) { - ctrl.limitTo *= 2; + 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.select = function (ico) { - ctrl.data = ico.class; + + ctrl.uploadFile = async function () { + if (ctrl.file) { + $rootScope.isBusy = true; + var response = await fileService.uploadFile(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"]); + } }; }, ], - bindings: { - data: "=", - prefix: "=", - options: "=", - }, }); modules.component("mixValueEditor", { @@ -14145,30 +14485,6 @@ modules.component("modalContentFilter", { ], }); -app.component("modalCroppie", { - templateUrl: "/mix-app/views/app-portal/components/modal-croppie/view.html", - bidings: { - resolve: "<", - close: "&", - dismiss: "&", - }, - controller: function () { - var $ctrl = this; - $ctrl.fileUrl = "test"; - $ctrl.$onInit = function () { - $ctrl.file = $ctrl.resolve.file; - }; - - $ctrl.ok = function () { - $ctrl.close({ $value: $ctrl.fileUrl }); - }; - - $ctrl.cancel = function () { - $ctrl.dismiss({ $value: "cancel" }); - }; - }, -}); - modules.component("modalHelper", { templateUrl: "/mix-app/views/app-portal/components/modal-helper/modal-helper.html", @@ -14346,392 +14662,122 @@ modules.component("modalNavDatas", { ctrl.queries = {}; ctrl.data = { items: [] }; ctrl.$onInit = async function () { - ctrl.association = { - parentId: ctrl.parentId, - guidParentId: ctrl.guidParentId, - parentDatabaseName: ctrl.parentDatabaseName, - childDatabaseName: ctrl.mixDatabaseName, - }; - dataService.initDbName(ctrl.mixDatabaseName); - ctrl.request.name = ctrl.mixDatabaseName; - ctrl.request.parentName = ctrl.parentName; - // ctrl.request.parentId = ctrl.parentId; - if (!ctrl.database) { - var getDatabase = await databaseService.getByName( - ctrl.mixDatabaseName - ); - if (getDatabase.success) { - ctrl.database = getDatabase.data; - $scope.$apply(); - } - } - if (!ctrl.data) { - await ctrl.loadData(); - } - }; - ctrl.select = async (item) => { - $rootScope.isBusy = true; - if (item.isSelected && (ctrl.parentId || ctrl.guidParentId)) { - ctrl.association.childId = item.id; - let result = await associationService.save(ctrl.association); - if (result.success) { - item.associationId = result.data.id; - } - $rootScope.handleResponse(result); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - let result = await associationService.deleteAssociation( - ctrl.parentDatabaseName, - ctrl.mixDatabaseName, - ctrl.parentId, - ctrl.guidParentId, - item.id - ); - $rootScope.handleResponse(result); - $rootScope.isBusy = false; - $scope.$apply(); - } - if (ctrl.selectCallback) { - ctrl.selectCallback(); - } - }; - - ctrl.filter = function () { - ctrl.data = []; - ctrl.loadData(); - }; - ctrl.loadData = async function () { - dataService.initDbName(ctrl.mixDatabaseName); - ctrl.request.queries = []; - if (ctrl.queries) { - Object.keys(ctrl.queries).forEach((e) => { - if (ctrl.queries[e]) { - ctrl.request.queries.push({ - fieldName: e, - value: ctrl.queries[e], - compareOperator: 'Like', - }); - } - }); - } - var getData = await dataService.filter(ctrl.request); - ctrl.data = getData.data; - angular.forEach(ctrl.data.items, (e) => { - if (ctrl.selectedIds.includes(e.id)) { - e.isSelected = true; - } - }); - $scope.$apply(); - }; - ctrl.update = function (data) { - let url = `/admin/mix-database-data/details?dataContentId=${ - data.id - }&mixDatabaseName=${ctrl.mixDatabaseName}&mixDatabaseTitle=${ - ctrl.mixDatabaseTitle - }&parentId=${ctrl.parentId || ""}&parentName=${ - ctrl.parentName || "" - }&guidParentId=${ctrl.guidParentId || ""}`; - $location.url(url); - }; - }, - ], -}); - -modules.component("modalNavMetas", { - templateUrl: "/mix-app/views/app-portal/components/modal-nav-metas/view.html", - bindings: { - header: "=", - mixDatabaseId: "=?", - mixDatabaseName: "=?", - intParentId: "=?", - guidParentId: "=?", - parentType: "=?", - type: "=?", - columnDisplay: "=?", - isOpen: "=?", - selectedList: "=?", - selectCallback: "&?", - save: "&", - }, - controller: [ - "$rootScope", - "$scope", - "$routeParams", - "ngAppSettings", - "RestMixDatabaseDataPortalService", - "RestRelatedAttributeDataPortalService", - "RestMixDatabasePortalService", - function ( - $rootScope, - $scope, - $routeParams, - ngAppSettings, - dataService, - navService, - databaseService - ) { - var ctrl = this; - - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.request.key = "readData"; - ctrl.navs = []; - - ctrl.queries = {}; - ctrl.data = { items: [] }; - ctrl.selectedValues = []; - - ctrl.$onInit = async function () { - await ctrl.loadDefaultModel(); - await ctrl.loadDefaultData(); - await ctrl.loadSelected(); - ctrl.loadData(); - ctrl.filterData(); - }; - - ctrl.loadSelected = async function () { - ctrl.navRequest = angular.copy(ngAppSettings.request); - ctrl.navRequest.mixDatabaseId = ctrl.mixDatabaseId; - ctrl.navRequest.mixDatabaseName = ctrl.mixDatabaseName; - ctrl.navRequest.intParentId = ctrl.intParentId; - ctrl.navRequest.guidParentId = ctrl.guidParentId; - var getSelected = await navService.getList(ctrl.navRequest); - if (getSelected.success) { - ctrl.selectedList = getSelected.data; - ctrl.selectedValues = ctrl.selectedList.items.map( - (m) => m.dataContentId - ); - $scope.$apply(); - } - }; - ctrl.loadDefaultModel = async function () { - ctrl.request.isGroup = true; - - if (ctrl.mixDatabaseId) { - ctrl.request.mixDatabaseId = ctrl.mixDatabaseId; - } - if (ctrl.mixDatabaseName) { - ctrl.request.mixDatabaseName = ctrl.mixDatabaseName; - } - if ($routeParams.intParentId) { - ctrl.intParentId = $routeParams.intParentId; - } - if ($routeParams.parentType) { - ctrl.parentType = $routeParams.parentType; - } - ctrl.defaultNav = { - id: null, - specificulture: navService.lang, - dataContentId: null, - intParentId: ctrl.intParentId, - parentType: ctrl.parentType, - mixDatabaseId: ctrl.mixDatabaseId, - mixDatabaseName: ctrl.mixDatabaseName, - status: "Published", - childDataContent: null, - }; - if (!ctrl.columns) { - var getMixDatbase = ctrl.mixDatabaseId - ? await databaseService.getSingle([ctrl.mixDatabaseId]) - : await databaseService.getByName([ctrl.mixDatabaseName]); - if (getMixDatbase.success) { - ctrl.columns = getMixDatbase.data.columns; - ctrl.mixDatabaseId = getMixDatbase.data.id; - ctrl.mixDatabaseName = getMixDatbase.data.systemName; - ctrl.defaultNav.mixDatabaseId = getMixDatbase.data.id; - ctrl.defaultNav.mixDatabaseName = getMixDatbase.data.systemName; + ctrl.association = { + parentId: ctrl.parentId, + guidParentId: ctrl.guidParentId, + parentDatabaseName: ctrl.parentDatabaseName, + childDatabaseName: ctrl.mixDatabaseName, + }; + dataService.initDbName(ctrl.mixDatabaseName); + ctrl.request.name = ctrl.mixDatabaseName; + ctrl.request.parentName = ctrl.parentName; + // ctrl.request.parentId = ctrl.parentId; + if (!ctrl.database) { + var getDatabase = await databaseService.getByName( + ctrl.mixDatabaseName + ); + if (getDatabase.success) { + ctrl.database = getDatabase.data; $scope.$apply(); } } - }; - ctrl.loadDefaultData = async function () { - var getDefault = await dataService.initData( - ctrl.mixDatabaseName || ctrl.mixDatabaseId - ); - ctrl.defaultData = getDefault.data; - if (ctrl.defaultData) { - ctrl.defaultData.mixDatabaseId = ctrl.mixDatabaseId || 0; - ctrl.defaultData.mixDatabaseName = ctrl.mixDatabaseName; - } - if (!ctrl.mixDatabaseData) { - ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); - } - if (!ctrl.mixDatabaseId) { - ctrl.mixDatabaseId = ctrl.defaultData.mixDatabaseId; - } - if (!ctrl.mixDatabaseName) { - ctrl.mixDatabaseName = ctrl.defaultData.mixDatabaseName; - } - }; - ctrl.isSelected = function (value, level) { - let item = $rootScope.findObjectByKey( - ctrl.selectedList.items, - "dataContentId", - value - ); - if (item) { - item.level = level; + if (!ctrl.data) { + await ctrl.loadData(); } - return ctrl.selectedValues.indexOf(value) >= 0; - }; - ctrl.reload = async function () { - ctrl.newTitle = ""; - ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); }; - ctrl.loadData = async function (pageIndex) { - ctrl.request.query = "{}"; - 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.mixDatabaseId) { - ctrl.request.mixDatabaseId = ctrl.mixDatabaseId; - } - if (ctrl.mixDatabaseName) { - ctrl.request.mixDatabaseName = ctrl.mixDatabaseName; - } - if (ctrl.type) { - ctrl.request.type = ctrl.type; - } - Object.keys(ctrl.queries).forEach((e) => { - if (ctrl.queries[e]) { - ctrl.request[e] = ctrl.queries[e]; + 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; } - }); - ctrl.request.key = "data"; - var response = await dataService.getList(ctrl.request); - if (response.success) { - ctrl.data = response.data; - ctrl.filterData(); - ctrl.isBusy = false; + $rootScope.handleResponse(result); + $rootScope.isBusy = false; $scope.$apply(); } else { - $rootScope.showErrors(response.errors); - ctrl.isBusy = false; - $scope.$apply(); - } - }; - ctrl.filterData = function () { - angular.forEach(ctrl.data.items, function (e) { - // Not show data if there's in selected list - e.disabled = ctrl.selectedValues.indexOf(e.id) >= 0; - }); - angular.forEach(ctrl.selectedList.items, function (e) { - var subIds = []; - e.isActived = e.isActived === undefined ? true : e.isActived; - if (e.childDataContent && e.childDataContent.data.childItems) { - angular.forEach(e.childDataContent.data.childItems, function (sub) { - sub.isActived = ctrl.selectedValues.indexOf(e.id) >= 0; - }); - subIds = e.childDataContent.data.childItems.map((m) => m.id); - } else if (e.childItems) { - subIds = e.childItems.map((m) => m.id); - } - var subData = ctrl.selectedList.items.filter( - (m) => subIds.indexOf(m.dataContentId) >= 0 - ); - angular.forEach(subData, function (s) { - s.disabled = true; - }); - }); - }; - ctrl.select = async function (dataContentId, isSelected, level) { - let idx = ctrl.selectedValues.indexOf(dataContentId); - var nav = ctrl.selectedList.items[idx]; - if (!nav) { - ctrl.selectedValues.push(dataContentId); - nav = angular.copy(ctrl.defaultNav); - nav.dataContentId = dataContentId; - nav.childDataContent = $rootScope.findObjectByKey( - ctrl.data.items, - "id", - dataContentId + let result = await associationService.deleteAssociation( + ctrl.parentDatabaseName, + ctrl.mixDatabaseName, + ctrl.parentId, + ctrl.guidParentId, + item.id ); - ctrl.selectedList.items.push(nav); + $rootScope.handleResponse(result); + $rootScope.isBusy = false; + $scope.$apply(); } - nav.level = level; - if (isSelected) { - nav.isActived = true; - if (nav.intParentId) { - var saveResult = await navService.save(nav); - nav.id = saveResult.data.id; - $rootScope.showMessage("success", "success"); - ctrl.filterData(); - $scope.$apply(); - } + if (ctrl.selectCallback) { + ctrl.selectCallback(); } + }; - if (!isSelected) { - await ctrl.removeNav(idx); - if (ctrl.selectCallback) { - ctrl.selectCallback({ data: nav }); - } - return; - } + ctrl.filter = function () { + ctrl.data = []; + ctrl.loadData(); }; - 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.loadData = async function () { + dataService.initDbName(ctrl.mixDatabaseName); + ctrl.request.queries = []; + if (ctrl.queries) { + Object.keys(ctrl.queries).forEach((e) => { + if (ctrl.queries[e]) { + ctrl.request.queries.push({ + fieldName: e, + value: ctrl.queries[e], + compareOperator: 'Like', + }); + } + }); } - }; - ctrl.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); + 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); }; }, ], }); +app.component("modalCroppie", { + templateUrl: "/mix-app/views/app-portal/components/modal-croppie/view.html", + bidings: { + resolve: "<", + close: "&", + dismiss: "&", + }, + controller: function () { + var $ctrl = this; + $ctrl.fileUrl = "test"; + $ctrl.$onInit = function () { + $ctrl.file = $ctrl.resolve.file; + }; + + $ctrl.ok = function () { + $ctrl.close({ $value: $ctrl.fileUrl }); + }; + + $ctrl.cancel = function () { + $ctrl.dismiss({ $value: "cancel" }); + }; + }, +}); + modules.component("modalNavPages", { templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", bindings: { @@ -14948,74 +14994,368 @@ modules.component("modalNavs", { $rootScope.isBusy = false; $scope.$apply(); } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + // 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.selectAll = function (isSelectAll) { + angular.forEach(ctrl.data.items, (element) => { + element.isActived = isSelectAll; + }); + }; + ctrl.selectChange = function (item) { + if (ctrl.isSingle == "true" && item.isActived) { + angular.forEach(ctrl.data.items, (element) => { + element.isActived = false; + }); + item.isActived = true; + } + }; + ctrl.saveSelected = function () { + ctrl.selected = $rootScope.filterArray( + ctrl.data.items, + ["isActived"], + [true] + ); + if (ctrl.save) { + ctrl.save({ selected: ctrl.selected }); + } + }; + }, + ], +}); + +modules.component("modalNavMetas", { + templateUrl: "/mix-app/views/app-portal/components/modal-nav-metas/view.html", + bindings: { + header: "=", + mixDatabaseId: "=?", + mixDatabaseName: "=?", + intParentId: "=?", + guidParentId: "=?", + parentType: "=?", + type: "=?", + columnDisplay: "=?", + isOpen: "=?", + selectedList: "=?", + selectCallback: "&?", + save: "&", + }, + controller: [ + "$rootScope", + "$scope", + "$routeParams", + "ngAppSettings", + "RestMixDatabaseDataPortalService", + "RestRelatedAttributeDataPortalService", + "RestMixDatabasePortalService", + function ( + $rootScope, + $scope, + $routeParams, + ngAppSettings, + dataService, + navService, + databaseService + ) { + var ctrl = this; + + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.request.key = "readData"; + ctrl.navs = []; + + ctrl.queries = {}; + ctrl.data = { items: [] }; + ctrl.selectedValues = []; + + ctrl.$onInit = async function () { + await ctrl.loadDefaultModel(); + await ctrl.loadDefaultData(); + await ctrl.loadSelected(); + ctrl.loadData(); + ctrl.filterData(); + }; + + ctrl.loadSelected = async function () { + ctrl.navRequest = angular.copy(ngAppSettings.request); + ctrl.navRequest.mixDatabaseId = ctrl.mixDatabaseId; + ctrl.navRequest.mixDatabaseName = ctrl.mixDatabaseName; + ctrl.navRequest.intParentId = ctrl.intParentId; + ctrl.navRequest.guidParentId = ctrl.guidParentId; + var getSelected = await navService.getList(ctrl.navRequest); + if (getSelected.success) { + ctrl.selectedList = getSelected.data; + ctrl.selectedValues = ctrl.selectedList.items.map( + (m) => m.dataContentId + ); + $scope.$apply(); + } + }; + ctrl.loadDefaultModel = async function () { + ctrl.request.isGroup = true; + + if (ctrl.mixDatabaseId) { + ctrl.request.mixDatabaseId = ctrl.mixDatabaseId; + } + if (ctrl.mixDatabaseName) { + ctrl.request.mixDatabaseName = ctrl.mixDatabaseName; + } + if ($routeParams.intParentId) { + ctrl.intParentId = $routeParams.intParentId; + } + if ($routeParams.parentType) { + ctrl.parentType = $routeParams.parentType; + } + ctrl.defaultNav = { + id: null, + specificulture: navService.lang, + dataContentId: null, + intParentId: ctrl.intParentId, + parentType: ctrl.parentType, + mixDatabaseId: ctrl.mixDatabaseId, + mixDatabaseName: ctrl.mixDatabaseName, + status: "Published", + childDataContent: null, + }; + if (!ctrl.columns) { + var getMixDatbase = ctrl.mixDatabaseId + ? await databaseService.getSingle([ctrl.mixDatabaseId]) + : await databaseService.getByName([ctrl.mixDatabaseName]); + if (getMixDatbase.success) { + ctrl.columns = getMixDatbase.data.columns; + ctrl.mixDatabaseId = getMixDatbase.data.id; + ctrl.mixDatabaseName = getMixDatbase.data.systemName; + ctrl.defaultNav.mixDatabaseId = getMixDatbase.data.id; + ctrl.defaultNav.mixDatabaseName = getMixDatbase.data.systemName; + $scope.$apply(); + } + } + }; + ctrl.loadDefaultData = async function () { + var getDefault = await dataService.initData( + ctrl.mixDatabaseName || ctrl.mixDatabaseId + ); + ctrl.defaultData = getDefault.data; + if (ctrl.defaultData) { + ctrl.defaultData.mixDatabaseId = ctrl.mixDatabaseId || 0; + ctrl.defaultData.mixDatabaseName = ctrl.mixDatabaseName; + } + if (!ctrl.mixDatabaseData) { + ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); + } + if (!ctrl.mixDatabaseId) { + ctrl.mixDatabaseId = ctrl.defaultData.mixDatabaseId; + } + if (!ctrl.mixDatabaseName) { + ctrl.mixDatabaseName = ctrl.defaultData.mixDatabaseName; + } + }; + ctrl.isSelected = function (value, level) { + let item = $rootScope.findObjectByKey( + ctrl.selectedList.items, + "dataContentId", + value + ); + if (item) { + item.level = level; + } + return ctrl.selectedValues.indexOf(value) >= 0; + }; + ctrl.reload = async function () { + ctrl.newTitle = ""; + ctrl.mixDatabaseData = angular.copy(ctrl.defaultData); + }; + ctrl.loadData = async function (pageIndex) { + ctrl.request.query = "{}"; + 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.mixDatabaseId) { + ctrl.request.mixDatabaseId = ctrl.mixDatabaseId; + } + if (ctrl.mixDatabaseName) { + ctrl.request.mixDatabaseName = ctrl.mixDatabaseName; + } + if (ctrl.type) { + ctrl.request.type = ctrl.type; + } + Object.keys(ctrl.queries).forEach((e) => { + if (ctrl.queries[e]) { + ctrl.request[e] = ctrl.queries[e]; + } + }); + ctrl.request.key = "data"; + var response = await dataService.getList(ctrl.request); + if (response.success) { + ctrl.data = response.data; + ctrl.filterData(); + ctrl.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + ctrl.isBusy = false; $scope.$apply(); } }; - - // 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.selectAll = function (isSelectAll) { - angular.forEach(ctrl.data.items, (element) => { - element.isActived = isSelectAll; + ctrl.filterData = function () { + angular.forEach(ctrl.data.items, function (e) { + // Not show data if there's in selected list + e.disabled = ctrl.selectedValues.indexOf(e.id) >= 0; }); - }; - ctrl.selectChange = function (item) { - if (ctrl.isSingle == "true" && item.isActived) { - angular.forEach(ctrl.data.items, (element) => { - element.isActived = false; + angular.forEach(ctrl.selectedList.items, function (e) { + var subIds = []; + e.isActived = e.isActived === undefined ? true : e.isActived; + if (e.childDataContent && e.childDataContent.data.childItems) { + angular.forEach(e.childDataContent.data.childItems, function (sub) { + sub.isActived = ctrl.selectedValues.indexOf(e.id) >= 0; + }); + subIds = e.childDataContent.data.childItems.map((m) => m.id); + } else if (e.childItems) { + subIds = e.childItems.map((m) => m.id); + } + var subData = ctrl.selectedList.items.filter( + (m) => subIds.indexOf(m.dataContentId) >= 0 + ); + angular.forEach(subData, function (s) { + s.disabled = true; }); - item.isActived = true; + }); + }; + ctrl.select = async function (dataContentId, isSelected, level) { + let idx = ctrl.selectedValues.indexOf(dataContentId); + var nav = ctrl.selectedList.items[idx]; + if (!nav) { + ctrl.selectedValues.push(dataContentId); + nav = angular.copy(ctrl.defaultNav); + nav.dataContentId = dataContentId; + nav.childDataContent = $rootScope.findObjectByKey( + ctrl.data.items, + "id", + dataContentId + ); + ctrl.selectedList.items.push(nav); + } + nav.level = level; + if (isSelected) { + nav.isActived = true; + if (nav.intParentId) { + var saveResult = await navService.save(nav); + nav.id = saveResult.data.id; + $rootScope.showMessage("success", "success"); + ctrl.filterData(); + $scope.$apply(); + } + } + + if (!isSelected) { + await ctrl.removeNav(idx); + if (ctrl.selectCallback) { + ctrl.selectCallback({ data: nav }); + } + return; } }; - ctrl.saveSelected = function () { - ctrl.selected = $rootScope.filterArray( - ctrl.data.items, - ["isActived"], - [true] - ); - if (ctrl.save) { - ctrl.save({ selected: ctrl.selected }); + 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); + } } }; }, @@ -15031,48 +15371,6 @@ modules.component("modalPermission", { }, }); -modules.component("modalTemplate", { - templateUrl: "/mix-app/views/app-portal/components/modal-template/view.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "TemplateService", - function ($rootScope, $scope, ngAppSettings, service) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = function () { - ctrl.modal = $("#modal-template"); - ctrl.request.status = null; - ctrl.request.pageSize = 10; - ctrl.modal.on("shown.bs.modal", function () { - ctrl.search(); - }); - }; - ctrl.search = async function (pageIndex) { - if (ctrl.request.keyword.indexOf("/") > 0) { - let params = ctrl.request.keyword.split("/"); - ctrl.request.folderType = params[0]; - ctrl.request.keyword = params[1]; - } - ctrl.request.pageIndex = pageIndex || ctrl.request.pageIndex; - $rootScope.isBusy = true; - var resp = await service.getList(ctrl.request); - if (resp && resp.success) { - ctrl.data = resp.data; - } - $rootScope.isBusy = false; - $scope.$apply(); - }; - ctrl.edit = function (item) { - let path = `/admin/template/details/${item.folderType}/${item.id}`; - ctrl.modal.modal("hide"); - $rootScope.goToPath(path); - }; - }, - ], -}); - modules.component("monacoEditor", { templateUrl: "/mix-app/views/app-portal/components/monaco-editor/view.html", bindings: { @@ -15271,6 +15569,48 @@ modules.component("monacoEditor", { ], }); +modules.component("modalTemplate", { + templateUrl: "/mix-app/views/app-portal/components/modal-template/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "TemplateService", + function ($rootScope, $scope, ngAppSettings, service) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = function () { + ctrl.modal = $("#modal-template"); + ctrl.request.status = null; + ctrl.request.pageSize = 10; + ctrl.modal.on("shown.bs.modal", function () { + ctrl.search(); + }); + }; + ctrl.search = async function (pageIndex) { + if (ctrl.request.keyword.indexOf("/") > 0) { + let params = ctrl.request.keyword.split("/"); + ctrl.request.folderType = params[0]; + ctrl.request.keyword = params[1]; + } + ctrl.request.pageIndex = pageIndex || ctrl.request.pageIndex; + $rootScope.isBusy = true; + var resp = await service.getList(ctrl.request); + if (resp && resp.success) { + ctrl.data = resp.data; + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + ctrl.edit = function (item) { + let path = `/admin/template/details/${item.folderType}/${item.id}`; + ctrl.modal.modal("hide"); + $rootScope.goToPath(path); + }; + }, + ], +}); + modules.component("navigators", { templateUrl: "/mix-app/views/app-portal/components/navigations/navigations.html", diff --git a/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js b/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js index 86f3a8552..4769f0bd4 100644 --- a/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js +++ b/src/applications/Mixcore/wwwroot/mix-app/js/app-shared.min.js @@ -2921,6 +2921,71 @@ appShared.factory("TranslatorService", [ }, ]); +"use strict"; +appShared.factory("RestMixAssociationPortalService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-db-association"); + + serviceFactory.getAssociation = async ( + parentDbName, + childDbName, + parentId, + childId + ) => { + var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${ + parentId || guidParentId + }/${childId}`; + var req = { + serviceBase: serviceFactory.serviceBase, + apiVersion: serviceFactory.apiVersion, + method: "GET", + url: url, + }; + return await serviceFactory.getRestApiResult(req); + }; + serviceFactory.deleteAssociation = async ( + parentDbName, + childDbName, + parentId, + guidParentId, + childId + ) => { + var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${parentId}/${childId}`; + var req = { + serviceBase: serviceFactory.serviceBase, + apiVersion: serviceFactory.apiVersion, + method: "DELETE", + url: url, + }; + return await serviceFactory.getRestApiResult(req); + }; + return serviceFactory; + }, +]); + +"use strict"; +appShared.factory("RestMixDatabaseColumnPortalService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-database-column", true); + var _initData = async function (mixDatabaseName) { + var url = this.prefixUrl + "/init/" + mixDatabaseName; + var req = { + method: "GET", + url: url, + }; + return await apiService.sendRequest(req); + }; + serviceFactory.initData = _initData; + return serviceFactory; + }, +]); + "use strict"; appShared.factory("MixDbService", [ "BaseRestService", @@ -3029,66 +3094,11 @@ appShared.factory("RestMixDatabasePortalService", [ ]); "use strict"; -appShared.factory("RestMixAssociationPortalService", [ +appShared.factory("RestMixDatabaseDataValuePortalService", [ "BaseRestService", function (baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-db-association"); - - serviceFactory.getAssociation = async ( - parentDbName, - childDbName, - parentId, - childId - ) => { - var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${ - parentId || guidParentId - }/${childId}`; - var req = { - serviceBase: serviceFactory.serviceBase, - apiVersion: serviceFactory.apiVersion, - method: "GET", - url: url, - }; - return await serviceFactory.getRestApiResult(req); - }; - serviceFactory.deleteAssociation = async ( - parentDbName, - childDbName, - parentId, - guidParentId, - childId - ) => { - var url = `${serviceFactory.prefixUrl}/${parentDbName}/${childDbName}/${parentId}/${childId}`; - var req = { - serviceBase: serviceFactory.serviceBase, - apiVersion: serviceFactory.apiVersion, - method: "DELETE", - url: url, - }; - return await serviceFactory.getRestApiResult(req); - }; - return serviceFactory; - }, -]); - -"use strict"; -appShared.factory("RestMixDatabaseColumnPortalService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-database-column", true); - var _initData = async function (mixDatabaseName) { - var url = this.prefixUrl + "/init/" + mixDatabaseName; - var req = { - method: "GET", - url: url, - }; - return await apiService.sendRequest(req); - }; - serviceFactory.initData = _initData; + serviceFactory.init("mix-database-data-value"); return serviceFactory; }, ]); @@ -3226,11 +3236,11 @@ appShared.factory("RestMixDatabaseDataPortalService", [ ]); "use strict"; -appShared.factory("RestMixDatabaseDataValuePortalService", [ +appShared.factory("RestMvcModuleDataService", [ "BaseRestService", function (baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-database-data-value"); + serviceFactory.init("mix-database-relationship"); return serviceFactory; }, ]); @@ -3289,25 +3299,6 @@ appShared.factory("RestRelatedAttributeDataPortalService", [ }, ]); -"use strict"; -appShared.factory("RestMvcModuleDataService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("module-data/mvc"); - var _initForm = async function (moduleContentId) { - var url = `${this.prefixUrl}/init-form/${moduleContentId}`; - var req = { - method: "GET", - url: url, - }; - return await apiService.sendRequest(req); - }; - serviceFactory.initForm = _initForm; - return serviceFactory; - }, -]); - "use strict"; function BaseCtrl($scope, $rootScope, $routeParams, ngAppSettings, service) { @@ -3867,6 +3858,7 @@ function BaseRestCtrl( service ) { $scope.request = $rootScope.getRequest(); + $scope.request.culture = $rootScope.globalSettings.defaultCulture; $scope.contentStatuses = angular.copy(ngAppSettings.contentStatuses); $scope.viewmodel = null; @@ -4253,6 +4245,9 @@ function BaseHub(scope) { // Create a function that the hub can call to broadcast messages. scope.connection.on("receive_message", (msg) => { + if (typeof msg !== "object") { + msg = JSON.parse(msg); + } scope.receiveMessage(msg); }); scope.connection.onreconnected((connectionId) => { @@ -4394,187 +4389,68 @@ appShared.controller("ModuleFormController", [ }, ]); -appShared.controller("MixDataController", [ - "$rootScope", +"use strict"; +appShared.controller("MvcModuleDataController", [ "$scope", + "$rootScope", "ngAppSettings", - "RestRelatedAttributeDataFormService", - "RestMixDatabaseDataClientService", - function ($rootScope, $scope, ngAppSettings, navService, dataService) { - $scope.defaultData = null; - $scope.formData = null; - $scope.formRecords = null; - $scope.formName = null; - $scope.navRequest = angular.copy(ngAppSettings.request); - $scope.successMsg = "Thành công"; - $scope.init = async function ( - formName, - parentId, - parentType, - validateHandler, - loadingHandler, - successHandler, - failHandler - ) { - $scope.successMsg = "Success"; - $scope.validateHandler = validateHandler; - $scope.loadingHandler = loadingHandler; - $scope.successHandler = successHandler; - $scope.failHandler = failHandler; - $scope.formName = formName; - $scope.navRequest.mixDatabaseName = formName; - $scope.navRequest.parentType = parentType; - $scope.navRequest.parentId = parentId; - var getDefault = await dataService.initData($scope.formName); - $scope.defaultData = getDefault.data; - if ($scope.defaultData) { - $scope.defaultData.mixDatabaseName = $scope.formName; - $scope.defaultData.parentType = parentType || "Set"; - $scope.defaultData.parentId = parentId; - $scope.formData = angular.copy($scope.defaultData); - } - $scope.$apply(); + "$routeParams", + "$location", + "RestMvcModuleDataService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.request.orderBy = "Priority"; + $scope.request.direction = "Asc"; + $scope.mixConfigurations = $rootScope.globalSettings; + $scope.moduleContentId = null; + $scope.module = null; + $scope.allData = []; + $scope.editDataUrl = null; + $scope.canLoadMore = false; + $scope.init = async function (moduleContentId, pageSize) { + $scope.moduleContentId = moduleContentId; + $scope.request.moduleContentId = $scope.moduleContentId; + $scope.request.pageSize = pageSize || $scope.request.pageSize; + $scope.loadMore(0); }; - $scope.loadData = function () { - navService.getList($scope.navRequest).then((resp) => { + + $scope.getSingle = async function () { + $rootScope.isBusy = true; + var resp = await service.getSingle($scope.id, "mvc"); + if (resp && resp.success) { + $scope.activedModuleData = resp.data; + $rootScope.initEditor(); + $rootScope.isBusy = false; + $scope.$apply(); + } else { if (resp) { - $scope.formRecords = resp.data; - $scope.$apply(); + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.activeItem = function (arr, item) { + angular.forEach(arr, function (e) { + if (e.id != item.id) { + e.expanded = false; } else { - if (resp) { - $rootScope.showErrors("Failed"); - } - $scope.$apply(); - } - }); - }; - $scope.submit = async (data) => { - $scope.form.$$element.addClass("was-validated"); - if ($scope.form.$valid) { - $rootScope.isBusy = true; - if ($scope.loadingHandler) { - $rootScope.executeFunctionByName($scope.loadingHandler, [true]); - } - if ( - !$scope.validateHandler || - $rootScope.executeFunctionByName($scope.validateHandler, [data]) - ) { - var saveResult = await dataService.save(data); - if (saveResult.success) { - $scope.loadData(); - if ($scope.successHandler) { - $rootScope.executeFunctionByName($scope.successHandler, [ - saveResult, - ]); - } else { - $scope.form.$$element.removeClass("was-validated"); - $scope.form.$setPristine(); - $scope.form.$setUntouched(); - console.log($scope.successMsg); - } - $scope.formData = angular.copy($scope.defaultData); - $rootScope.isBusy = false; - // $scope.loadData(); - if ($scope.loadingHandler) { - $rootScope.executeFunctionByName($scope.loadingHandler, [false]); - } - $scope.$apply(); - } else { - if (saveResult.errors && saveResult.errors.length) { - if ($scope.failHandler) { - $rootScope.executeFunctionByName($scope.failHandler, [ - data, - saveResult, - ]); - } else { - console.error(saveResult.errors); - } - } - if ($scope.loadingHandler) { - $rootScope.executeFunctionByName($scope.loadingHandler, [false]); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - } - } - }; - - $scope.saveValue = async (id, name, value) => { - if ($scope.form.$valid) { - $rootScope.isBusy = true; - var obj = new {}(); - obj[name] = value; - await dataService.saveValues(id, obj); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -appShared.controller("MvcModuleDataController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "RestMvcModuleDataService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service - ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); - $scope.request.orderBy = "Priority"; - $scope.request.direction = "Asc"; - $scope.mixConfigurations = $rootScope.globalSettings; - $scope.moduleContentId = null; - $scope.module = null; - $scope.allData = []; - $scope.editDataUrl = null; - $scope.canLoadMore = false; - $scope.init = async function (moduleContentId, pageSize) { - $scope.moduleContentId = moduleContentId; - $scope.request.moduleContentId = $scope.moduleContentId; - $scope.request.pageSize = pageSize || $scope.request.pageSize; - $scope.loadMore(0); - }; - - $scope.getSingle = async function () { - $rootScope.isBusy = true; - var resp = await service.getSingle($scope.id, "mvc"); - if (resp && resp.success) { - $scope.activedModuleData = resp.data; - $rootScope.initEditor(); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.activeItem = function (arr, item) { - angular.forEach(arr, function (e) { - if (e.id != item.id) { - e.expanded = false; - } else { - e.expanded = !e.expanded; + e.expanded = !e.expanded; } }); }; @@ -4664,99 +4540,137 @@ appShared.controller("MvcPostController", [ }, ]); -sharedComponents.component("addressEditor", { - templateUrl: "/mix-app/views/app-shared/components/address-editor/view.html", - bindings: { - province: "=", - provinceClass: "=?", - district: "=", - districtClass: "=?", - ward: "=", - wardClass: "=?", - }, - controller: "AddressEditorController", -}); - -sharedComponents.controller("AddressEditorController", [ +appShared.controller("MixDataController", [ "$rootScope", "$scope", - "ApiService", - function PortalTemplateController($rootScope, $scope, apiService) { - var ctrl = this; - ctrl.provinceEndpoint = "/rest/shared/json-data/provinces.json/true"; - ctrl.districtEndpoint = "/rest/shared/json-data/districts.json/true"; - ctrl.wardEndpoint = "/rest/shared/json-data/wards.json/true"; - ctrl.$onInit = async function () { - ctrl.provinceClass = - ctrl.provinceClass || "form-select form-control mb-3"; - ctrl.districtClass = - ctrl.districtClass || "form-select form-control mb-3"; - ctrl.wardClass = ctrl.wardClass || "form-select form-control mb-3"; - - ctrl.provinceOptions = await apiService.getApiResult({ - url: ctrl.provinceEndpoint, - }); + "ngAppSettings", + "RestRelatedAttributeDataFormService", + "RestMixDatabaseDataClientService", + function ($rootScope, $scope, ngAppSettings, navService, dataService) { + $scope.defaultData = null; + $scope.formData = null; + $scope.formRecords = null; + $scope.formName = null; + $scope.navRequest = angular.copy(ngAppSettings.request); + $scope.successMsg = "Thành công"; + $scope.init = async function ( + formName, + parentId, + parentType, + validateHandler, + loadingHandler, + successHandler, + failHandler + ) { + $scope.successMsg = "Success"; + $scope.validateHandler = validateHandler; + $scope.loadingHandler = loadingHandler; + $scope.successHandler = successHandler; + $scope.failHandler = failHandler; + $scope.formName = formName; + $scope.navRequest.mixDatabaseName = formName; + $scope.navRequest.parentType = parentType; + $scope.navRequest.parentId = parentId; + var getDefault = await dataService.initData($scope.formName); + $scope.defaultData = getDefault.data; + if ($scope.defaultData) { + $scope.defaultData.mixDatabaseName = $scope.formName; + $scope.defaultData.parentType = parentType || "Set"; + $scope.defaultData.parentId = parentId; + $scope.formData = angular.copy($scope.defaultData); + } $scope.$apply(); - $rootScope.$watch( - () => { - return ctrl.province; - }, - async function (newVal, oldVal) { - if (newVal != oldVal || !ctrl.district) { - if (!ctrl.allDistrictOptions) { - ctrl.allDistrictOptions = await apiService.getApiResult({ - url: ctrl.districtEndpoint, - }); - ctrl.districtOptions = ctrl.allDistrictOptions.filter( - (m) => m["province"] == ctrl.province - ); - $scope.$apply(); - } else { - ctrl.districtOptions = ctrl.allDistrictOptions.filter( - (m) => m["province"] == ctrl.province - ); - } - } - } - ); - $rootScope.$watch( - () => { - return ctrl.district; - }, - async function (newVal, oldVal) { - if (newVal != oldVal) { - if (!ctrl.allWardOptions) { - ctrl.allWardOptions = await apiService.getApiResult({ - url: ctrl.wardEndpoint, - }); - ctrl.wardOptions = ctrl.allWardOptions.filter( - (m) => m["district"] == ctrl.district - ); - $scope.$apply(); - } else { - ctrl.wardOptions = ctrl.allWardOptions.filter( - (m) => m["district"] == ctrl.district - ); - } + }; + $scope.loadData = function () { + navService.getList($scope.navRequest).then((resp) => { + if (resp) { + $scope.formRecords = resp.data; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors("Failed"); } + $scope.$apply(); } - ); + }); }; - }, -]); - -sharedComponents.component("apiFile", { - templateUrl: "/mix-app/views/app-shared/components/api-file/api-file.html", - controller: [ - "$rootScope", - "$scope", - "Upload", - function PortalTemplateController($rootScope, $scope, uploader) { - var ctrl = this; - ctrl.accept = ctrl.accept || "application/zip"; - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - const file = files[0]; + $scope.submit = async (data) => { + $scope.form.$$element.addClass("was-validated"); + if ($scope.form.$valid) { + $rootScope.isBusy = true; + if ($scope.loadingHandler) { + $rootScope.executeFunctionByName($scope.loadingHandler, [true]); + } + if ( + !$scope.validateHandler || + $rootScope.executeFunctionByName($scope.validateHandler, [data]) + ) { + var saveResult = await dataService.save(data); + if (saveResult.success) { + $scope.loadData(); + if ($scope.successHandler) { + $rootScope.executeFunctionByName($scope.successHandler, [ + saveResult, + ]); + } else { + $scope.form.$$element.removeClass("was-validated"); + $scope.form.$setPristine(); + $scope.form.$setUntouched(); + console.log($scope.successMsg); + } + $scope.formData = angular.copy($scope.defaultData); + $rootScope.isBusy = false; + // $scope.loadData(); + if ($scope.loadingHandler) { + $rootScope.executeFunctionByName($scope.loadingHandler, [false]); + } + $scope.$apply(); + } else { + if (saveResult.errors && saveResult.errors.length) { + if ($scope.failHandler) { + $rootScope.executeFunctionByName($scope.failHandler, [ + data, + saveResult, + ]); + } else { + console.error(saveResult.errors); + } + } + if ($scope.loadingHandler) { + $rootScope.executeFunctionByName($scope.loadingHandler, [false]); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + } + } + }; + + $scope.saveValue = async (id, name, value) => { + if ($scope.form.$valid) { + $rootScope.isBusy = true; + var obj = new {}(); + obj[name] = value; + await dataService.saveValues(id, obj); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +sharedComponents.component("apiFile", { + templateUrl: "/mix-app/views/app-shared/components/api-file/api-file.html", + controller: [ + "$rootScope", + "$scope", + "Upload", + function PortalTemplateController($rootScope, $scope, uploader) { + var ctrl = this; + ctrl.accept = ctrl.accept || "application/zip"; + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + const file = files[0]; ctrl.postedFile = file; } }; @@ -4825,113 +4739,86 @@ sharedComponents.component("apiFile", { }, }); -sharedComponents.component("azureStorage", { - templateUrl: "/mix-app/views/app-shared/components/azure-storage/view.html", +sharedComponents.component("addressEditor", { + templateUrl: "/mix-app/views/app-shared/components/address-editor/view.html", bindings: { - data: "=", - width: "=", + province: "=", + provinceClass: "=?", + district: "=", + districtClass: "=?", + ward: "=", + wardClass: "=?", }, - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.blobSasUrl = ""; - ctrl.blobServiceClient = new BlobServiceClient(blobSasUrl); - ctrl.containerName = "container" + new Date().getTime(); - ctrl.containerClient = blobServiceClient.getContainerClient( - containerName - ); - - const fileInput = document.getElementById("azure-file-input"); - const status = document.getElementById("status"); - const fileList = document.getElementById("file-list"); - - const reportStatus = (message) => { - status.innerHTML += `${message}
`; - status.scrollTop = status.scrollHeight; - }; - - ctrl.$onInit = function () {}; - - ctrl.createContainer = async () => { - try { - reportStatus(`Creating container "${containerName}"...`); - await containerClient.create(); - reportStatus(`Done.`); - } catch (error) { - reportStatus(error.message); - } - }; - - ctrl.deleteContainer = async () => { - try { - reportStatus(`Deleting container "${containerName}"...`); - await containerClient.delete(); - reportStatus(`Done.`); - } catch (error) { - reportStatus(error.message); - } - }; + controller: "AddressEditorController", +}); - ctrl.listFiles = async () => { - fileList.size = 0; - fileList.innerHTML = ""; - try { - reportStatus("Retrieving file list..."); - let iter = containerClient.listBlobsFlat(); - let blobItem = await iter.next(); - while (!blobItem.done) { - fileList.size += 1; - fileList.innerHTML += ``; - blobItem = await iter.next(); - } - if (fileList.size > 0) { - reportStatus("Done."); - } else { - reportStatus("The container does not contain any files."); - } - } catch (error) { - reportStatus(error.message); - } - }; +sharedComponents.controller("AddressEditorController", [ + "$rootScope", + "$scope", + "ApiService", + function PortalTemplateController($rootScope, $scope, apiService) { + var ctrl = this; + ctrl.provinceEndpoint = "/rest/shared/json-data/provinces.json/true"; + ctrl.districtEndpoint = "/rest/shared/json-data/districts.json/true"; + ctrl.wardEndpoint = "/rest/shared/json-data/wards.json/true"; + ctrl.$onInit = async function () { + ctrl.provinceClass = + ctrl.provinceClass || "form-select form-control mb-3"; + ctrl.districtClass = + ctrl.districtClass || "form-select form-control mb-3"; + ctrl.wardClass = ctrl.wardClass || "form-select form-control mb-3"; - ctrl.uploadFiles = async () => { - try { - reportStatus("Uploading files..."); - const promises = []; - for (const file of fileInput.files) { - const blockBlobClient = containerClient.getBlockBlobClient( - file.name - ); - promises.push(blockBlobClient.uploadBrowserData(file)); + ctrl.provinceOptions = await apiService.getApiResult({ + url: ctrl.provinceEndpoint, + }); + $scope.$apply(); + $rootScope.$watch( + () => { + return ctrl.province; + }, + async function (newVal, oldVal) { + if (newVal != oldVal || !ctrl.district) { + if (!ctrl.allDistrictOptions) { + ctrl.allDistrictOptions = await apiService.getApiResult({ + url: ctrl.districtEndpoint, + }); + ctrl.districtOptions = ctrl.allDistrictOptions.filter( + (m) => m["province"] == ctrl.province + ); + $scope.$apply(); + } else { + ctrl.districtOptions = ctrl.allDistrictOptions.filter( + (m) => m["province"] == ctrl.province + ); + } } - await Promise.all(promises); - reportStatus("Done."); - listFiles(); - } catch (error) { - reportStatus(error.message); } - }; - - ctrl.deleteFiles = async () => { - try { - if (fileList.selectedOptions.length > 0) { - reportStatus("Deleting files..."); - for (const option of fileList.selectedOptions) { - await containerClient.deleteBlob(option.text); + ); + $rootScope.$watch( + () => { + return ctrl.district; + }, + async function (newVal, oldVal) { + if (newVal != oldVal) { + if (!ctrl.allWardOptions) { + ctrl.allWardOptions = await apiService.getApiResult({ + url: ctrl.wardEndpoint, + }); + ctrl.wardOptions = ctrl.allWardOptions.filter( + (m) => m["district"] == ctrl.district + ); + $scope.$apply(); + } else { + ctrl.wardOptions = ctrl.allWardOptions.filter( + (m) => m["district"] == ctrl.district + ); } - reportStatus("Done."); - listFiles(); - } else { - reportStatus("No files selected."); } - } catch (error) { - reportStatus(error.message); } - }; - }, - ], -}); + ); + }; + }, +]); sharedComponents.component("barCode", { templateUrl: "/mix-app/views/app-shared/components/bar-code/view.html", @@ -5059,130 +4946,108 @@ sharedComponents.component("cultures", { }, }); -//sharedComponents.controller('ImageController', ); -sharedComponents.component("customFile", { - templateUrl: - "/mix-app/views/app-shared/components/custom-file/custom-file.html", +sharedComponents.component("azureStorage", { + templateUrl: "/mix-app/views/app-shared/components/azure-storage/view.html", bindings: { - header: "=", - title: "=", - description: "=", - src: "=", - srcUrl: "=?", - data: "=?", - type: "=?", - folder: "=", - auto: "=", - onInsert: "&?", - onDelete: "&", - save: "&", + data: "=", + width: "=", }, controller: [ "$rootScope", - "$scope", - "MediaService", - function PortalTemplateController($rootScope, $scope, mediaService) { + function ($rootScope) { var ctrl = this; - ctrl.media = null; - ctrl.$onInit = function () { - ctrl.id = Math.random(); - ctrl.mediaFile = { - file: null, - fullPath: "", - fileFolder: "content/site", - title: "", - description: "", - }; + ctrl.blobSasUrl = ""; + ctrl.blobServiceClient = new BlobServiceClient(blobSasUrl); + ctrl.containerName = "container" + new Date().getTime(); + ctrl.containerClient = blobServiceClient.getContainerClient( + containerName + ); + + const fileInput = document.getElementById("azure-file-input"); + const status = document.getElementById("status"); + const fileList = document.getElementById("file-list"); + + const reportStatus = (message) => { + status.innerHTML += `${message}
`; + status.scrollTop = status.scrollHeight; }; - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - ctrl.file = files[0]; - if ($rootScope.isImage(ctrl.file)) { - ctrl.canUpload = false; - mediaService.openCroppie(ctrl.file, ctrl, true); - } else { - ctrl.canUpload = true; - ctrl.uploadFile(ctrl.file); - } + + ctrl.$onInit = function () {}; + + ctrl.createContainer = async () => { + try { + reportStatus(`Creating container "${containerName}"...`); + await containerClient.create(); + reportStatus(`Done.`); + } catch (error) { + reportStatus(error.message); } }; - ctrl.croppieCallback = function (result) { - if (result) { - ctrl.srcUrl = result.filePath; - if (ctrl.onInsert) { - ctrl.onInsert({ data: ctrl.srcUrl }); - } - } else if (ctrl.file) { - ctrl.uploadFile(ctrl.file); + ctrl.deleteContainer = async () => { + try { + reportStatus(`Deleting container "${containerName}"...`); + await containerClient.delete(); + reportStatus(`Done.`); + } catch (error) { + reportStatus(error.message); } }; - ctrl.uploadFile = async function (file) { - if (file !== null) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = async function () { - var getMedia = await mediaService.getSingle(["portal"]); - if (getMedia.success) { - ctrl.mediaFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.fileStream = reader.result; - var media = getMedia.data; - media.mediaFile = ctrl.mediaFile; - var resp = await mediaService.save(media); - if (resp && resp.success) { - ctrl.src = resp.data.targetUrl; - ctrl.srcUrl = resp.data.targetUrl; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - } - }; - reader.onerror = function (error) {}; - } else { - return null; + ctrl.listFiles = async () => { + fileList.size = 0; + fileList.innerHTML = ""; + try { + reportStatus("Retrieving file list..."); + let iter = containerClient.listBlobsFlat(); + let blobItem = await iter.next(); + while (!blobItem.done) { + fileList.size += 1; + fileList.innerHTML += ``; + blobItem = await iter.next(); + } + if (fileList.size > 0) { + reportStatus("Done."); + } else { + reportStatus("The container does not contain any files."); + } + } catch (error) { + reportStatus(error.message); } }; - ctrl.getBase64 = function (file) { - if (file !== null && ctrl.mediaFile) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = function () { - var index = reader.result.indexOf(",") + 1; - var base64 = reader.result.substring(index); - ctrl.mediaFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.extension = file.name.substring( - file.name.lastIndexOf(".") + + ctrl.uploadFiles = async () => { + try { + reportStatus("Uploading files..."); + const promises = []; + for (const file of fileInput.files) { + const blockBlobClient = containerClient.getBlockBlobClient( + file.name ); - ctrl.mediaFile.fileStream = reader.result; - ctrl.srcUrl = reader.result; - $rootScope.isBusy = false; + promises.push(blockBlobClient.uploadBrowserData(file)); + } + await Promise.all(promises); + reportStatus("Done."); + listFiles(); + } catch (error) { + reportStatus(error.message); + } + }; - $scope.$apply(); - }; - reader.onerror = function (error) { - $rootScope.isBusy = false; - $rootScope.showErrors([error]); - }; - } else { - return null; + ctrl.deleteFiles = async () => { + try { + if (fileList.selectedOptions.length > 0) { + reportStatus("Deleting files..."); + for (const option of fileList.selectedOptions) { + await containerClient.deleteBlob(option.text); + } + reportStatus("Done."); + listFiles(); + } else { + reportStatus("No files selected."); + } + } catch (error) { + reportStatus(error.message); } }; }, @@ -5272,46 +5137,19 @@ sharedComponents.component("mixDataTypeEditor", { ], }); -"use trick"; -sharedComponents.directive("pane", function () { - return { - require: "^tabs", - restrict: "E", - transclude: true, - scope: { title: "@" }, - link: function (scope, element, attrs, tabsController) { - tabsController.addPane(scope); - }, - template: - '
' + - "
", - replace: true, - }; -}); - -sharedComponents.directive("tabs", function () { - return { - restrict: "E", - transclude: true, - scope: {}, - controller: function ($scope, $element) { - var panes = ($scope.panes = []); - - $scope.select = function (pane) { - angular.forEach(panes, function (pane) { - pane.selected = false; - }); - pane.selected = true; - }; - - this.addPane = function (pane) { - if (panes.length === 0) $scope.select(pane); - panes.push(pane); - }; +sharedComponents.component("swDataPreview", { + templateUrl: + "/mix-app/views/app-shared/components/data-preview/data-preview.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; }, - templateUrl: "/mix-app/views/app-shared/components/templates/tabs.html", - replace: true, - }; + ], + bindings: { + type: "=", + value: "=", + }, }); sharedComponents.component("fbLogin", { @@ -5392,12 +5230,142 @@ sharedComponents.component("fbLogin", { ], }); -sharedComponents.component("goToTop", { - templateUrl: "/mix-app/views/app-shared/components/go-to-top/view.html", +//sharedComponents.controller('ImageController', ); +sharedComponents.component("customFile", { + templateUrl: + "/mix-app/views/app-shared/components/custom-file/custom-file.html", + bindings: { + header: "=", + title: "=", + description: "=", + src: "=", + srcUrl: "=?", + data: "=?", + type: "=?", + folder: "=", + auto: "=", + onInsert: "&?", + onDelete: "&", + save: "&", + }, controller: [ "$rootScope", "$scope", - function ($rootScope, $scope) { + "MediaService", + function PortalTemplateController($rootScope, $scope, mediaService) { + var ctrl = this; + ctrl.media = null; + ctrl.$onInit = function () { + ctrl.id = Math.random(); + ctrl.mediaFile = { + file: null, + fullPath: "", + fileFolder: "content/site", + title: "", + description: "", + }; + }; + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + ctrl.file = files[0]; + if ($rootScope.isImage(ctrl.file)) { + ctrl.canUpload = false; + mediaService.openCroppie(ctrl.file, ctrl, true); + } else { + ctrl.canUpload = true; + ctrl.uploadFile(ctrl.file); + } + } + }; + + ctrl.croppieCallback = function (result) { + if (result) { + ctrl.srcUrl = result.filePath; + if (ctrl.onInsert) { + ctrl.onInsert({ data: ctrl.srcUrl }); + } + } else if (ctrl.file) { + ctrl.uploadFile(ctrl.file); + } + }; + + ctrl.uploadFile = async function (file) { + if (file !== null) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = async function () { + var getMedia = await mediaService.getSingle(["portal"]); + if (getMedia.success) { + ctrl.mediaFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.fileStream = reader.result; + var media = getMedia.data; + media.mediaFile = ctrl.mediaFile; + var resp = await mediaService.save(media); + if (resp && resp.success) { + ctrl.src = resp.data.targetUrl; + ctrl.srcUrl = resp.data.targetUrl; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + reader.onerror = function (error) {}; + } else { + return null; + } + }; + ctrl.getBase64 = function (file) { + if (file !== null && ctrl.mediaFile) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function () { + var index = reader.result.indexOf(",") + 1; + var base64 = reader.result.substring(index); + ctrl.mediaFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.fileStream = reader.result; + ctrl.srcUrl = reader.result; + $rootScope.isBusy = false; + + $scope.$apply(); + }; + reader.onerror = function (error) { + $rootScope.isBusy = false; + $rootScope.showErrors([error]); + }; + } else { + return null; + } + }; + }, + ], +}); + +sharedComponents.component("goToTop", { + templateUrl: "/mix-app/views/app-shared/components/go-to-top/view.html", + controller: [ + "$rootScope", + "$scope", + function ($rootScope, $scope) { var ctrl = this; ctrl.$onInit = function () { $(window).scroll(function () { @@ -5423,6 +5391,48 @@ sharedComponents.component("goToTop", { bindings: {}, }); +"use trick"; +sharedComponents.directive("pane", function () { + return { + require: "^tabs", + restrict: "E", + transclude: true, + scope: { title: "@" }, + link: function (scope, element, attrs, tabsController) { + tabsController.addPane(scope); + }, + template: + '
' + + "
", + replace: true, + }; +}); + +sharedComponents.directive("tabs", function () { + return { + restrict: "E", + transclude: true, + scope: {}, + controller: function ($scope, $element) { + var panes = ($scope.panes = []); + + $scope.select = function (pane) { + angular.forEach(panes, function (pane) { + pane.selected = false; + }); + pane.selected = true; + }; + + this.addPane = function (pane) { + if (panes.length === 0) $scope.select(pane); + panes.push(pane); + }; + }, + templateUrl: "/mix-app/views/app-shared/components/templates/tabs.html", + replace: true, + }; +}); + sharedComponents.component("googlePay", { templateUrl: "/mix-app/views/app-shared/components/google-pay/view.html", bindings: { @@ -5724,116 +5734,6 @@ appShared.controller("LoginPopupController", [ }, ]); -appShared.component("mediaNavs", { - templateUrl: - "/mix-app/views/app-shared/components/media-navs/media-navs.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "MediaService", - function ($rootScope, $scope, ngAppSettings, mediaService) { - var ctrl = this; - mediaService.init("media"); - ctrl.request = { - pageSize: "10", - pageIndex: 0, - status: "Published", - orderBy: "CreatedDateTime", - direction: "Desc", - fromDate: null, - toDate: null, - keyword: "", - }; - ctrl.medias = []; - ctrl.activeMedia = function (media) { - var currentItem = null; - if (ctrl.data === null || ctrl.isSingle) { - ctrl.data = []; - } - $.each(ctrl.data, function (i, e) { - if (e.mediaId === media.id) { - e.isActived = media.isActived; - currentItem = e; - return false; - } - }); - if (currentItem === null) { - currentItem = { - description: - media.description !== "undefined" ? media.description : "", - image: media.filePath, - mediaId: media.id, - product: ctrl.id, - specificulture: media.specificulture, - position: 0, - priority: ctrl.data.length + 1, - isActived: true, - }; - ctrl.data.push(currentItem); - } - if (ctrl.isSingle) { - if (!media.isActived) { - ctrl.output = ""; - ctrl.data = []; - } else { - ctrl.output = ctrl.data[0].image; - //ctrl.loadMedias(ctrl.request.pageIndex); - } - } - }; - ctrl.loadMedias = async function (pageIndex) { - if (!ctrl.prefix) { - ctrl.prefix = "media_navs"; - } - 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) { - ctrl.request.toDate = ctrl.request.toDate.toISOString(); - } - if ($rootScope.globalSettings) { - ctrl.isBusy = true; - var resp = await mediaService.getList(ctrl.request); - if (resp && resp.success) { - ctrl.medias = resp.data; - if (ctrl.data) { - angular.forEach(ctrl.medias.items, function (value, key) { - var temp = ctrl.data.filter(function (item) { - return item.mediaId === value.id; - })[0]; - value.isActived = temp !== undefined; - }); - } - ctrl.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - ctrl.isBusy = false; - $scope.$apply(); - } - } - }; - }, - ], - bindings: { - data: "=", - prefix: "=", - sourceFieldName: "=", - isSingle: "=", - output: "=", - loadMedia: "&", - onDelete: "&", - onUpdate: "&", - }, -}); - "use strict"; appShared.controller("MediaController", [ "$scope", @@ -6130,6 +6030,116 @@ sharedComponents.component("medias", { bindings: {}, }); +appShared.component("mediaNavs", { + templateUrl: + "/mix-app/views/app-shared/components/media-navs/media-navs.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "MediaService", + function ($rootScope, $scope, ngAppSettings, mediaService) { + var ctrl = this; + mediaService.init("media"); + ctrl.request = { + pageSize: "10", + pageIndex: 0, + status: "Published", + orderBy: "CreatedDateTime", + direction: "Desc", + fromDate: null, + toDate: null, + keyword: "", + }; + ctrl.medias = []; + ctrl.activeMedia = function (media) { + var currentItem = null; + if (ctrl.data === null || ctrl.isSingle) { + ctrl.data = []; + } + $.each(ctrl.data, function (i, e) { + if (e.mediaId === media.id) { + e.isActived = media.isActived; + currentItem = e; + return false; + } + }); + if (currentItem === null) { + currentItem = { + description: + media.description !== "undefined" ? media.description : "", + image: media.filePath, + mediaId: media.id, + product: ctrl.id, + specificulture: media.specificulture, + position: 0, + priority: ctrl.data.length + 1, + isActived: true, + }; + ctrl.data.push(currentItem); + } + if (ctrl.isSingle) { + if (!media.isActived) { + ctrl.output = ""; + ctrl.data = []; + } else { + ctrl.output = ctrl.data[0].image; + //ctrl.loadMedias(ctrl.request.pageIndex); + } + } + }; + ctrl.loadMedias = async function (pageIndex) { + if (!ctrl.prefix) { + ctrl.prefix = "media_navs"; + } + 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) { + ctrl.request.toDate = ctrl.request.toDate.toISOString(); + } + if ($rootScope.globalSettings) { + ctrl.isBusy = true; + var resp = await mediaService.getList(ctrl.request); + if (resp && resp.success) { + ctrl.medias = resp.data; + if (ctrl.data) { + angular.forEach(ctrl.medias.items, function (value, key) { + var temp = ctrl.data.filter(function (item) { + return item.mediaId === value.id; + })[0]; + value.isActived = temp !== undefined; + }); + } + ctrl.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + ctrl.isBusy = false; + $scope.$apply(); + } + } + }; + }, + ], + bindings: { + data: "=", + prefix: "=", + sourceFieldName: "=", + isSingle: "=", + output: "=", + loadMedia: "&", + onDelete: "&", + onUpdate: "&", + }, +}); + sharedComponents.component("message", { templateUrl: "/mix-app/views/app-shared/components/message/message.html", bindings: { @@ -6309,13 +6319,87 @@ sharedComponents.component("messenger", { }, }); -sharedComponents.component("messengerPrivate", { +sharedComponents.component("mixColumnPreview", { templateUrl: - "/mix-app/views/app-shared/components/messenger-private/index.html", - controller: "MessengerController", + "/mix-app/views/app-shared/components/mix-column-preview/view.html", bindings: { - message: "=", - connectionId: "=", + model: "=", + column: "=", + datatype: "=?", + maxLength: "=?", + isShowTitle: "=?", + inputClass: "=?", + }, + controller: [ + "$rootScope", + "$sce", + "$filter", + function ($rootScope, $sce, $filter) { + var ctrl = this; + ctrl.previousId = null; + + ctrl.$onInit = function () { + ctrl.parseView(); + }; + ctrl.parseView = function () { + ctrl.uuid = $rootScope.generateUUID(); + var obj = $rootScope.testJSON(ctrl.model); + ctrl.view = ctrl.model; + if (ctrl.column) { + if (!ctrl.datatype) { + ctrl.datatype = ctrl.column.dataType; + } + if (ctrl.column.isEncrypt) { + if (obj) { + ctrl.encryptedData = obj; + ctrl.model = ctrl.encryptedData.data; + ctrl.decrypted = $rootScope.decrypt(ctrl.encryptedData); + } + } else { + if (obj && ctrl.maxLength) { + ctrl.view = JSON.stringify(ctrl.model); + } + } + if (ctrl.maxLength && ctrl.view) { + ctrl.view = $filter("trim")(ctrl.view, ctrl.maxLength); + } + if (ctrl.column.dataType == 20 && ctrl.model) { + // youtube video + ctrl.model = $sce.trustAsResourceUrl( + "https://www.youtube.com/embed/" + + ctrl.model + + "?rel=0&showinfo=0&autoplay=0" + ); + } + } + // if(ctrl.column.dataType == 24 && ctrl.model) // youtube video + // { + // ctrl.generateQRCode(); + // } + }; + ctrl.generateQRCode = function () { + setTimeout(() => { + $("#" + ctrl.uuid).empty(); + $("#" + ctrl.uuid).qrcode(ctrl.model); + }, 200); + }; + }, + ], +}); + +sharedComponents.component("mixDataPreview", { + templateUrl: + "/mix-app/views/app-shared/components/mix-data-preview/mix-data-preview.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + }, + ], + bindings: { + type: "=", + value: "=", + width: "=", }, }); @@ -6620,89 +6704,15 @@ sharedComponents.component("mixColumnEditor", { ], }); -sharedComponents.component("mixColumnPreview", { +sharedComponents.component("messengerPrivate", { templateUrl: - "/mix-app/views/app-shared/components/mix-column-preview/view.html", + "/mix-app/views/app-shared/components/messenger-private/index.html", + controller: "MessengerController", bindings: { - model: "=", - column: "=", - datatype: "=?", - maxLength: "=?", - isShowTitle: "=?", - inputClass: "=?", + message: "=", + connectionId: "=", }, - controller: [ - "$rootScope", - "$sce", - "$filter", - function ($rootScope, $sce, $filter) { - var ctrl = this; - ctrl.previousId = null; - - ctrl.$onInit = function () { - ctrl.parseView(); - }; - ctrl.parseView = function () { - ctrl.uuid = $rootScope.generateUUID(); - var obj = $rootScope.testJSON(ctrl.model); - ctrl.view = ctrl.model; - if (ctrl.column) { - if (!ctrl.datatype) { - ctrl.datatype = ctrl.column.dataType; - } - if (ctrl.column.isEncrypt) { - if (obj) { - ctrl.encryptedData = obj; - ctrl.model = ctrl.encryptedData.data; - ctrl.decrypted = $rootScope.decrypt(ctrl.encryptedData); - } - } else { - if (obj && ctrl.maxLength) { - ctrl.view = JSON.stringify(ctrl.model); - } - } - if (ctrl.maxLength && ctrl.view) { - ctrl.view = $filter("trim")(ctrl.view, ctrl.maxLength); - } - if (ctrl.column.dataType == 20 && ctrl.model) { - // youtube video - ctrl.model = $sce.trustAsResourceUrl( - "https://www.youtube.com/embed/" + - ctrl.model + - "?rel=0&showinfo=0&autoplay=0" - ); - } - } - // if(ctrl.column.dataType == 24 && ctrl.model) // youtube video - // { - // ctrl.generateQRCode(); - // } - }; - ctrl.generateQRCode = function () { - setTimeout(() => { - $("#" + ctrl.uuid).empty(); - $("#" + ctrl.uuid).qrcode(ctrl.model); - }, 200); - }; - }, - ], -}); - -sharedComponents.component("mixDataPreview", { - templateUrl: - "/mix-app/views/app-shared/components/mix-data-preview/mix-data-preview.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - }, - ], - bindings: { - type: "=", - value: "=", - width: "=", - }, -}); +}); "use strict"; appShared.controller("MixDatabaseDataClientController", [ @@ -6992,6 +7002,94 @@ sharedComponents.component("mixDataTable", { }, }); +sharedComponents.component("mixDatabaseDataValuePreview", { + templateUrl: + "/mix-app/views/app-shared/components/mix-data-table/mix-data-table.html", + controller: [ + "$rootScope", + "$scope", + "$location", + "ngAppSettings", + function ($rootScope, $scope, $location, ngAppSettings) { + var ctrl = this; + ctrl.colWidth = 3; + ctrl.init = function () { + if (ctrl.data.items.length) { + ctrl.min = ctrl.data.items[0].priority; + } + ctrl.colWidth = parseInt(9 / ctrl.columns.length); + ctrl.lastColWidth = 9 % ctrl.columns.length > 0 ? 2 : 1; + }; + ctrl.translate = $rootScope.translate; + ctrl.selected = null; + ctrl.updateOrders = function (index, items) { + items.splice(index, 1); + for (var i = 0; i < items.length; i++) { + items[i].priority = ctrl.min + i; + } + ctrl.onUpdateInfos({ items: items }); + }; + + ctrl.updateChildOrders = function (index, items) { + items.splice(index, 1); + for (var i = 0; i < items.length; i++) { + items[i].priority = ctrl.min + i; + } + ctrl.onUpdateChildInfos({ items: items }); + }; + ctrl.dragoverCallback = function (index, item, external, type) { + //console.log('drop ', index, item, external, type); + }; + ctrl.insertCallback = function (index, item, external, type) { + //console.log('insert ', index, item, external, type); + }; + ctrl.delete = function (id) { + ctrl.onDelete({ id: id }); + }; + ctrl.goTo = function (id) { + $location.path(ctrl.editUrl + "/" + id); + }; + ctrl.toggleChildNavs = function (nav) { + nav.showChildNavs = nav.childNavs.length > 0 && !nav.showChildNavs; + }; + }, + ], + bindings: { + data: "=", + childName: "=", + canDrag: "=", + editUrl: "=", + columns: "=", + onDelete: "&", + onUpdateInfos: "&", + onUpdateChildInfos: "&", + }, +}); + +sharedComponents.component("mixDateEditor", { + templateUrl: "/mix-app/views/app-shared/components/mix-date-editor/view.html", + bindings: { + utcDate: "=", + isReadonly: "=?", + }, + controller: [ + "$filter", + function ($filter) { + var ctrl = this; + ctrl.$onInit = async function () { + ctrl.readonly = ctrl.isReadonly === "true"; + if (ctrl.utcDate) { + let local = $filter("utcToLocal")(ctrl.utcDate, "yyyy-MM-ddTHH:mm"); + ctrl.local = new Date(local); + } + }; + ctrl.update = function () { + ctrl.utcDate = ctrl.local.toISOString(); + }; + }, + ], +}); + sharedComponents.component("mixDatabaseFormWeb", { templateUrl: "/mix-app/views/app-shared/components/mix-database-form-web/view.html", @@ -7121,54 +7219,6 @@ sharedComponents.component("mixDatabaseFormWeb", { ], }); -sharedComponents.component("mixDatabaseDataValuePreview", { - templateUrl: - "/mix-app/views/app-shared/components/mix-database-data-value-preview/view.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.$onInit = function () { - if (ctrl.data.column && ctrl.data.column.isEncrypt) { - var encryptedData = { - key: ctrl.data.encryptKey, - data: ctrl.data.encryptValue, - }; - ctrl.data.stringValue = $rootScope.decrypt(encryptedData); - } - }; - }, - ], - bindings: { - data: "=", - width: "=", - }, -}); - -sharedComponents.component("mixDateEditor", { - templateUrl: "/mix-app/views/app-shared/components/mix-date-editor/view.html", - bindings: { - utcDate: "=", - isReadonly: "=?", - }, - controller: [ - "$filter", - function ($filter) { - var ctrl = this; - ctrl.$onInit = async function () { - ctrl.readonly = ctrl.isReadonly === "true"; - if (ctrl.utcDate) { - let local = $filter("utcToLocal")(ctrl.utcDate, "yyyy-MM-ddTHH:mm"); - ctrl.local = new Date(local); - } - }; - ctrl.update = function () { - ctrl.utcDate = ctrl.local.toISOString(); - }; - }, - ], -}); - sharedComponents.component("mixLoader", { templateUrl: "/mix-app/views/app-shared/components/mix-loader/view.html", controller: [ @@ -7410,28 +7460,6 @@ sharedComponents.component("mixModuleDataTable", { }, }); -sharedComponents.component("mixSelect", { - templateUrl: "/mix-app/views/app-shared/components/mix-select/view.html", - bindings: { - options: "=", - model: "=", - allowNull: "=?", - callback: "&?", - }, - controller: [ - "$rootScope", - "$scope", - function PortalTemplateController($rootScope, $scope) { - var ctrl = this; - ctrl.onSelect = function () { - if (ctrl.callback) { - ctrl.callback({ type: ctrl.model }); - } - }; - }, - ], -}); - "use strict"; appShared.controller("ModalPostController", [ "$scope", @@ -7502,309 +7530,53 @@ sharedComponents.component("modalPosts", { }, }); -// sharedComponents.component('modalConfirm', { -// templateUrl: '/mix-app/views/app-shared/components/modal-confirm/modal-confirm.html', -// controller: ModalConfirmController, -// bindings: { -// message: '=' -// } -// }); -function ModalConfirmController($rootScope, $scope, $mdDialog, message) { - $scope.message = message; - $scope.executeFunctionByName = async function (functionName, args, context) { - var result = await $rootScope.executeFunctionByName( - functionName, - args, - context - ); - if (result) { - $scope.$apply(); - } - $mdDialog.hide(); - }; - $scope.closeDialog = function () { - $mdDialog.hide(); - }; -} - -sharedComponents.controller( - "ModalCroppieController", - function ( - $rootScope, - $scope, - $http, - $uibModalInstance, - mediaService, - file, - w, - h, - rto, - autoSave - ) { - var ctrl = this; - ctrl.autoSave = autoSave; - ctrl.maxW = 400; - ctrl.file = file; - ctrl.w = w; - ctrl.h = h; - ctrl.rto = rto; - ctrl.isAdmin = $rootScope.isAdmin; - ctrl.postedFile = {}; - ctrl.isImage = false; - ctrl.mediaNavs = []; - ctrl.media = { - title: "", - mediaFile: {}, - }; - ctrl.image_placeholder = "/mix-app/assets/img/image_placeholder.jpg"; - ctrl.options = null; - ctrl.init = function () { - ctrl.srcUrl = ctrl.srcUrl || ctrl.image_placeholder; - ctrl.maxHeight = ctrl.maxHeight || "2000px"; - ctrl.id = Math.floor(Math.random() * 100); - ctrl.canvas = document.getElementById(`canvas-${ctrl.id}`); - ctrl.cropped = { - source: null, - }; - if (ctrl.frameUrl) { - ctrl.frame = ctrl.loadImage(frameUrl); - } - - if (ctrl.srcUrl) { - ctrl.loadBase64(ctrl.srcUrl); - } - - if (ctrl.file) { - setTimeout(() => { - ctrl.selectFile([ctrl.file]); - }, 500); - } - - // Assign blob to component when selecting a image - }; - - ctrl.loadFromUrl = function () { - if (ctrl.src !== ctrl.srcUrl && ctrl.srcUrl != ctrl.image_placeholder) { - ctrl.src = ctrl.srcUrl; - ctrl.isImage = ctrl.srcUrl - .toLowerCase() - .match(/([/|.|\w|\s|-])*\.(?:jpg|jpeg|gif|png|svg)/g); - if (ctrl.isImage) { - ctrl.loadBase64(ctrl.srcUrl); - } - } - }; - - ctrl.origin = function () { - $uibModalInstance.close(); - }; - - ctrl.ok = async function () { - if (!ctrl.autoSave) { - $uibModalInstance.close(ctrl.cropped.image); - } else { - // ctrl.media.fileFolder = ctrl.folder || "Media"; - // ctrl.media.fileName = ctrl.media.mediaFile.fileName; - // ctrl.media.extension = ctrl.media.mediaFile.extension; - ctrl.media.mediaFile.fileStream = ctrl.cropped.image; - ctrl.media.mediaFile.folderName = ctrl.folder || "Media"; - var result = await mediaService.saveFileStream(ctrl.media.mediaFile); - if (result.success) { - $uibModalInstance.close(result.data); - } - } - }; - - ctrl.cancel = function () { - $uibModalInstance.dismiss("cancel"); - }; - ctrl.combineImage = function () { - ctrl.canvas = document.getElementById(`canvas-${ctrl.id}`); - if (ctrl.canvas) { - var img = document.getElementById("croppie-src"); - var w = ctrl.options.boundary.width; - var h = ctrl.options.boundary.height; - // var rto = w / h; - var newW = ctrl.options.output.width; - var newH = ctrl.options.output.height; - var ctx = ctrl.canvas.getContext("2d"); - ctx.imageSmoothingEnabled = true; - ctx.drawImage(img, 0, 0, newW, newH); - if (ctrl.frame) { - // combine with frame - ctx.drawImage(ctrl.frame, 0, 0, w, h); - } - - $scope.$apply(function () { - ctrl.postedFile.fileStream = ctrl.canvas.toDataURL(); //ctx.getImageData(0, 0, 300, 350); - ctrl.imgUrl = ctrl.postedFile.fileStream.replace( - "image/png", - "image/octet-stream" - ); - }); - } - }; - ctrl.saveCanvas = function () { - var link = document.createElement("a"); - link.download = ctrl.postedFile.fileName + ctrl.postedFile.extension; - $rootScope.isBusy = true; - ctrl.canvas.toBlob(function (blob) { - link.href = URL.createObjectURL(blob); - link.click(); - $rootScope.isBusy = false; - $scope.$apply(); - }, "image/png"); - }; - ctrl._arrayBufferToBase64 = function (buffer) { - var binary = ""; - var bytes = new Uint8Array(buffer); - var len = bytes.byteLength; - for (var i = 0; i < len; i++) { - binary += String.fromCharCode(bytes[i]); - } - return window.btoa(binary); - }; - - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - const file = files[0]; - ctrl.media.folder = ctrl.folder ? ctrl.folder : "Media"; - ctrl.media.title = ctrl.title ? ctrl.title : file.name; - ctrl.media.description = ctrl.description ? ctrl.description : ""; - ctrl.media.mediaFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.media.mediaFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - ctrl.getBase64(file); - // if (file.size < 100000) { - // var msg = "Please choose a better photo (larger than 100kb)!"; - // $rootScope.showConfirm(ctrl, null, [], null, null, msg); - // } else { - // } - } - }; - ctrl.loadBase64 = function (url) { - var ext = url.substring(url.lastIndexOf(".") + 1); - $http({ - method: "GET", - url: url, - responseType: "arraybuffer", - }).then(function (resp) { - var base64 = `data:image/${ext};base64,${ctrl._arrayBufferToBase64( - resp.data - )}`; - var image = new Image(); - image.src = base64; - image.onload = function () { - // access image size here - ctrl.originW = this.width; - ctrl.originH = this.height; - - ctrl.loadImageSize(this.width, this.height); - ctrl.cropped.source = base64; - $scope.$apply(); - }; - return base64; - }); - }; - ctrl.getBase64 = function (file) { - if (file !== null) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - // ctrl.cropped.source = null; - reader.onload = function () { - if (ctrl.media.mediaFile) { - ctrl.media.mediaFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.media.mediaFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - // ctrl.postedFile.fileStream = reader.result; - } - var image = new Image(); - image.src = reader.result; - - image.onload = function () { - // access image size here - ctrl.originW = this.width; - ctrl.originH = this.height; - ctrl.loadImageSize(this.width, this.height); - ctrl.cropped.source = reader.result; - $rootScope.isBusy = false; - $scope.$apply(); - }; - }; - reader.onerror = function (error) { - $rootScope.isBusy = false; - $rootScope.showErrors([error]); - }; - } else { - return null; - } - }; - ctrl.loadImageSize = function (w, h) { - // const maxW = ctrl.w + 100; - w = w || ctrl.originW; - h = h || ctrl.originH; - var rto = w / h; - ctrl.rto = ctrl.rto || rto; - ctrl.w = ctrl.w || w; - ctrl.h = ctrl.w / ctrl.rto; - ctrl.options = { - boundary: { height: ctrl.maxW / rto, width: ctrl.maxW }, - render: { height: ctrl.maxW / rto, width: ctrl.maxW }, - output: { height: ctrl.h, width: ctrl.h * ctrl.rto }, - }; - ctrl.loadViewport(); - }; - ctrl.loadViewport = function () { - if (ctrl.w && ctrl.h) { - ctrl.rto = ctrl.w / ctrl.h; - let w = ctrl.w > ctrl.maxW ? ctrl.maxW * 0.6 : ctrl.w * 0.6; - let h = w / ctrl.rto; - if (w > ctrl.options.boundary.width) { - w = ctrl.options.boundary.width; - h = w / ctrl.rto; - } - ctrl.options.viewport = { - height: h, - width: w, - }; - } - }; - } -); - -sharedComponents.component("moduleDataPreview", { - templateUrl: - "/mix-app/views/app-shared/components/module-data-preview/module-data-preview.html", +sharedComponents.component("mixSelect", { + templateUrl: "/mix-app/views/app-shared/components/mix-select/view.html", + bindings: { + options: "=", + model: "=", + allowNull: "=?", + callback: "&?", + }, controller: [ "$rootScope", - function ($rootScope) { + "$scope", + function PortalTemplateController($rootScope, $scope) { var ctrl = this; - - ctrl.translate = $rootScope.translate; - ctrl.$onInit = () => { - if (!ctrl.datatype) { - ctrl.datatype = ctrl.data.dataType; - } - }; - }, - ], - bindings: { - data: "=", - datatype: "=?", - width: "=", - header: "=", - }, + ctrl.onSelect = function () { + if (ctrl.callback) { + ctrl.callback({ type: ctrl.model }); + } + }; + }, + ], }); +// sharedComponents.component('modalConfirm', { +// templateUrl: '/mix-app/views/app-shared/components/modal-confirm/modal-confirm.html', +// controller: ModalConfirmController, +// bindings: { +// message: '=' +// } +// }); +function ModalConfirmController($rootScope, $scope, $mdDialog, message) { + $scope.message = message; + $scope.executeFunctionByName = async function (functionName, args, context) { + var result = await $rootScope.executeFunctionByName( + functionName, + args, + context + ); + if (result) { + $scope.$apply(); + } + $mdDialog.hide(); + }; + $scope.closeDialog = function () { + $mdDialog.hide(); + }; +} + "use strict"; appShared.controller("SharedModuleDataController", [ "$scope", @@ -8010,97 +7782,375 @@ appShared.factory("SharedModuleDataService", [ return await apiService.sendRequest(req); }; - var _getModuleData = async function (moduleContentId, id, type) { - var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; - var url = apiUrl + "details/" + type; - if (id) { - url += "/" + moduleContentId + "/" + id; - } else { - url += "/" + moduleContentId; + var _getModuleData = async function (moduleContentId, id, type) { + var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; + var url = apiUrl + "details/" + type; + if (id) { + url += "/" + moduleContentId + "/" + id; + } else { + url += "/" + moduleContentId; + } + var req = { + method: "GET", + url: url, + }; + return await apiService.sendRequest(req); + }; + + var _getModuleDatas = async function (request) { + var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; + var req = { + method: "POST", + url: apiUrl + "list", + data: JSON.stringify(request), + }; + + return await apiService.sendRequest(req); + }; + + var _exportModuleData = async function (request) { + var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; + var req = { + method: "POST", + url: apiUrl + "export", + data: JSON.stringify(request), + }; + + return await apiService.sendRequest(req); + }; + + var _initModuleForm = async function (name) { + var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; + var req = { + method: "GET", + url: apiUrl + "init-by-name/" + name, + }; + + return await apiService.sendRequest(req); + }; + + var _removeModuleData = async function (id) { + var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; + var req = { + method: "GET", + url: apiUrl + "delete/" + id, + }; + return await apiService.sendRequest(req); + }; + + var _saveModuleData = async function (moduleData) { + var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; + var req = { + method: "POST", + url: apiUrl + "save", + data: JSON.stringify(moduleData), + }; + return await apiService.sendRequest(req); + }; + var _saveFields = async function (id, propertyName, propertyValue) { + var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; + var column = [ + { + propertyName: propertyName, + propertyValue: propertyValue, + }, + ]; + var req = { + method: "POST", + url: apiUrl + "save/" + id, + data: JSON.stringify(column), + }; + return await apiService.sendRequest(req); + }; + moduleDatasServiceFactory.getModuleData = _getModuleData; + moduleDatasServiceFactory.getModuleDatas = _getModuleDatas; + moduleDatasServiceFactory.exportModuleData = _exportModuleData; + moduleDatasServiceFactory.removeModuleData = _removeModuleData; + moduleDatasServiceFactory.saveModuleData = _saveModuleData; + moduleDatasServiceFactory.initModuleForm = _initModuleForm; + moduleDatasServiceFactory.saveFields = _saveFields; + moduleDatasServiceFactory.updateInfos = _updateInfos; + return moduleDatasServiceFactory; + }, +]); + +sharedComponents.controller( + "ModalCroppieController", + function ( + $rootScope, + $scope, + $http, + $uibModalInstance, + mediaService, + file, + w, + h, + rto, + autoSave + ) { + var ctrl = this; + ctrl.autoSave = autoSave; + ctrl.maxW = 400; + ctrl.file = file; + ctrl.w = w; + ctrl.h = h; + ctrl.rto = rto; + ctrl.isAdmin = $rootScope.isAdmin; + ctrl.postedFile = {}; + ctrl.isImage = false; + ctrl.mediaNavs = []; + ctrl.media = { + title: "", + mediaFile: {}, + }; + ctrl.image_placeholder = "/mix-app/assets/img/image_placeholder.jpg"; + ctrl.options = null; + ctrl.init = function () { + ctrl.srcUrl = ctrl.srcUrl || ctrl.image_placeholder; + ctrl.maxHeight = ctrl.maxHeight || "2000px"; + ctrl.id = Math.floor(Math.random() * 100); + ctrl.canvas = document.getElementById(`canvas-${ctrl.id}`); + ctrl.cropped = { + source: null, + }; + if (ctrl.frameUrl) { + ctrl.frame = ctrl.loadImage(frameUrl); + } + + if (ctrl.srcUrl) { + ctrl.loadBase64(ctrl.srcUrl); + } + + if (ctrl.file) { + setTimeout(() => { + ctrl.selectFile([ctrl.file]); + }, 500); + } + + // Assign blob to component when selecting a image + }; + + ctrl.loadFromUrl = function () { + if (ctrl.src !== ctrl.srcUrl && ctrl.srcUrl != ctrl.image_placeholder) { + ctrl.src = ctrl.srcUrl; + ctrl.isImage = ctrl.srcUrl + .toLowerCase() + .match(/([/|.|\w|\s|-])*\.(?:jpg|jpeg|gif|png|svg)/g); + if (ctrl.isImage) { + ctrl.loadBase64(ctrl.srcUrl); + } + } + }; + + ctrl.origin = function () { + $uibModalInstance.close(); + }; + + ctrl.ok = async function () { + if (!ctrl.autoSave) { + $uibModalInstance.close(ctrl.cropped.image); + } else { + // ctrl.media.fileFolder = ctrl.folder || "Media"; + // ctrl.media.fileName = ctrl.media.mediaFile.fileName; + // ctrl.media.extension = ctrl.media.mediaFile.extension; + ctrl.media.mediaFile.fileStream = ctrl.cropped.image; + ctrl.media.mediaFile.folderName = ctrl.folder || "Media"; + var result = await mediaService.saveFileStream(ctrl.media.mediaFile); + if (result.success) { + $uibModalInstance.close(result.data); + } + } + }; + + ctrl.cancel = function () { + $uibModalInstance.dismiss("cancel"); + }; + ctrl.combineImage = function () { + ctrl.canvas = document.getElementById(`canvas-${ctrl.id}`); + if (ctrl.canvas) { + var img = document.getElementById("croppie-src"); + var w = ctrl.options.boundary.width; + var h = ctrl.options.boundary.height; + // var rto = w / h; + var newW = ctrl.options.output.width; + var newH = ctrl.options.output.height; + var ctx = ctrl.canvas.getContext("2d"); + ctx.imageSmoothingEnabled = true; + ctx.drawImage(img, 0, 0, newW, newH); + if (ctrl.frame) { + // combine with frame + ctx.drawImage(ctrl.frame, 0, 0, w, h); + } + + $scope.$apply(function () { + ctrl.postedFile.fileStream = ctrl.canvas.toDataURL(); //ctx.getImageData(0, 0, 300, 350); + ctrl.imgUrl = ctrl.postedFile.fileStream.replace( + "image/png", + "image/octet-stream" + ); + }); + } + }; + ctrl.saveCanvas = function () { + var link = document.createElement("a"); + link.download = ctrl.postedFile.fileName + ctrl.postedFile.extension; + $rootScope.isBusy = true; + ctrl.canvas.toBlob(function (blob) { + link.href = URL.createObjectURL(blob); + link.click(); + $rootScope.isBusy = false; + $scope.$apply(); + }, "image/png"); + }; + ctrl._arrayBufferToBase64 = function (buffer) { + var binary = ""; + var bytes = new Uint8Array(buffer); + var len = bytes.byteLength; + for (var i = 0; i < len; i++) { + binary += String.fromCharCode(bytes[i]); + } + return window.btoa(binary); + }; + + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + const file = files[0]; + ctrl.media.folder = ctrl.folder ? ctrl.folder : "Media"; + ctrl.media.title = ctrl.title ? ctrl.title : file.name; + ctrl.media.description = ctrl.description ? ctrl.description : ""; + ctrl.media.mediaFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.media.mediaFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.getBase64(file); + // if (file.size < 100000) { + // var msg = "Please choose a better photo (larger than 100kb)!"; + // $rootScope.showConfirm(ctrl, null, [], null, null, msg); + // } else { + // } } - var req = { + }; + ctrl.loadBase64 = function (url) { + var ext = url.substring(url.lastIndexOf(".") + 1); + $http({ method: "GET", url: url, - }; - return await apiService.sendRequest(req); - }; - - var _getModuleDatas = async function (request) { - var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; - var req = { - method: "POST", - url: apiUrl + "list", - data: JSON.stringify(request), - }; + responseType: "arraybuffer", + }).then(function (resp) { + var base64 = `data:image/${ext};base64,${ctrl._arrayBufferToBase64( + resp.data + )}`; + var image = new Image(); + image.src = base64; + image.onload = function () { + // access image size here + ctrl.originW = this.width; + ctrl.originH = this.height; - return await apiService.sendRequest(req); + ctrl.loadImageSize(this.width, this.height); + ctrl.cropped.source = base64; + $scope.$apply(); + }; + return base64; + }); }; + ctrl.getBase64 = function (file) { + if (file !== null) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + // ctrl.cropped.source = null; + reader.onload = function () { + if (ctrl.media.mediaFile) { + ctrl.media.mediaFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.media.mediaFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + // ctrl.postedFile.fileStream = reader.result; + } + var image = new Image(); + image.src = reader.result; - var _exportModuleData = async function (request) { - var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; - var req = { - method: "POST", - url: apiUrl + "export", - data: JSON.stringify(request), - }; - - return await apiService.sendRequest(req); + image.onload = function () { + // access image size here + ctrl.originW = this.width; + ctrl.originH = this.height; + ctrl.loadImageSize(this.width, this.height); + ctrl.cropped.source = reader.result; + $rootScope.isBusy = false; + $scope.$apply(); + }; + }; + reader.onerror = function (error) { + $rootScope.isBusy = false; + $rootScope.showErrors([error]); + }; + } else { + return null; + } }; - - var _initModuleForm = async function (name) { - var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; - var req = { - method: "GET", - url: apiUrl + "init-by-name/" + name, + ctrl.loadImageSize = function (w, h) { + // const maxW = ctrl.w + 100; + w = w || ctrl.originW; + h = h || ctrl.originH; + var rto = w / h; + ctrl.rto = ctrl.rto || rto; + ctrl.w = ctrl.w || w; + ctrl.h = ctrl.w / ctrl.rto; + ctrl.options = { + boundary: { height: ctrl.maxW / rto, width: ctrl.maxW }, + render: { height: ctrl.maxW / rto, width: ctrl.maxW }, + output: { height: ctrl.h, width: ctrl.h * ctrl.rto }, }; - - return await apiService.sendRequest(req); + ctrl.loadViewport(); }; - - var _removeModuleData = async function (id) { - var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; - var req = { - method: "GET", - url: apiUrl + "delete/" + id, - }; - return await apiService.sendRequest(req); + ctrl.loadViewport = function () { + if (ctrl.w && ctrl.h) { + ctrl.rto = ctrl.w / ctrl.h; + let w = ctrl.w > ctrl.maxW ? ctrl.maxW * 0.6 : ctrl.w * 0.6; + let h = w / ctrl.rto; + if (w > ctrl.options.boundary.width) { + w = ctrl.options.boundary.width; + h = w / ctrl.rto; + } + ctrl.options.viewport = { + height: h, + width: w, + }; + } }; + } +); - var _saveModuleData = async function (moduleData) { - var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; - var req = { - method: "POST", - url: apiUrl + "save", - data: JSON.stringify(moduleData), - }; - return await apiService.sendRequest(req); - }; - var _saveFields = async function (id, propertyName, propertyValue) { - var apiUrl = "/" + $rootScope.mixConfigurations.lang + "/module-data/"; - var column = [ - { - propertyName: propertyName, - propertyValue: propertyValue, - }, - ]; - var req = { - method: "POST", - url: apiUrl + "save/" + id, - data: JSON.stringify(column), +sharedComponents.component("moduleDataPreview", { + templateUrl: + "/mix-app/views/app-shared/components/module-data-preview/module-data-preview.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + + ctrl.translate = $rootScope.translate; + ctrl.$onInit = () => { + if (!ctrl.datatype) { + ctrl.datatype = ctrl.data.dataType; + } }; - return await apiService.sendRequest(req); - }; - moduleDatasServiceFactory.getModuleData = _getModuleData; - moduleDatasServiceFactory.getModuleDatas = _getModuleDatas; - moduleDatasServiceFactory.exportModuleData = _exportModuleData; - moduleDatasServiceFactory.removeModuleData = _removeModuleData; - moduleDatasServiceFactory.saveModuleData = _saveModuleData; - moduleDatasServiceFactory.initModuleForm = _initModuleForm; - moduleDatasServiceFactory.saveFields = _saveFields; - moduleDatasServiceFactory.updateInfos = _updateInfos; - return moduleDatasServiceFactory; + }, + ], + bindings: { + data: "=", + datatype: "=?", + width: "=", + header: "=", }, -]); +}); sharedComponents.component("moduleForm", { templateUrl: "/mix-app/views/app-shared/components/module-form/view.html", @@ -8453,30 +8503,6 @@ sharedComponents.controller("OnePayShoppingCartController", [ }, ]); -sharedComponents.component("mixPaging", { - templateUrl: "/mix-app/views/app-shared/components/paging/paging.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.loadData = function (index) { - ctrl.pagingAction({ pageIndex: index }); - }; - ctrl.range = $rootScope.range; - }, - ], - bindings: { - data: "=", - activeClass: "=", - ulClass: "=", - page: "=", - pageSize: "=", - total: "=", - totalPage: "=", - pagingAction: "&", - }, -}); - sharedComponents.component("payPal", { templateUrl: "/mix-app/views/app-shared/components/pay-pal/view.html", bindings: { @@ -8549,15 +8575,78 @@ sharedComponents.component("payPal", { } } - // dataService.saveData("paypal", obj); - }); - }, - }) - .render("#paypal-button-container"); - //This function displays Smart Payment Buttons on your web page. + // dataService.saveData("paypal", obj); + }); + }, + }) + .render("#paypal-button-container"); + //This function displays Smart Payment Buttons on your web page. + }; + }, + ], +}); + +sharedComponents.component("mixPaging", { + templateUrl: "/mix-app/views/app-shared/components/paging/paging.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.loadData = function (index) { + ctrl.pagingAction({ pageIndex: index }); + }; + ctrl.range = $rootScope.range; + }, + ], + bindings: { + data: "=", + activeClass: "=", + ulClass: "=", + page: "=", + pageSize: "=", + total: "=", + totalPage: "=", + pagingAction: "&", + }, +}); + +sharedComponents.component("previewImage", { + templateUrl: + "/mix-app/views/app-shared/components/preview-image/preview-image.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope) { + var ctrl = this; + ctrl.isImage = false; + ctrl.init = function () { + if (ctrl.imgSrc) { + ctrl.imgClass = ctrl.imgClass || "rounded"; + ctrl.isImage = ctrl.imgSrc + .toLowerCase() + .match(/([/|.|\w|\s|-])*\.(?:jpg|jpeg|gif|png|svg|webp|jfif)/g); + // check if facebook avatar Url + ctrl.isImage = + ctrl.isImage || + ctrl.imgSrc + .toLowerCase() + .match( + /(?:(?:http|https):\/\/)?(?:www.)?(graph.facebook.com)\/([A-Za-z0-9.]{0,})\/(picture)(\?)?([A-Za-z0-9.=&]{0,})?/g + ); + } + }; + ctrl.showImage = async function (functionName, args, context) { + $rootScope.preview("img", ctrl.imgSrc); }; }, ], + bindings: { + imgWidth: "=", + imgHeight: "=", + imgSrc: "=", + imgClass: "=?", + }, }); "use trick"; @@ -8605,6 +8694,31 @@ sharedComponents.directive("pills", function () { }; }); +sharedComponents.component("previewPopup", { + templateUrl: + "/mix-app/views/app-shared/components/preview-popup/preview-popup.html", + controller: [ + "$scope", + "$location", + function ($scope, $location) { + var ctrl = this; + ctrl.$onInit = function () { + $("#dlg-preview-popup").on("hidden.bs.modal", function (e) { + ctrl.previewObject.data = null; + $scope.$apply(); + }); + }; + ctrl.goToLink = async function (link) { + $("#dlg-preview-popup").modal("hide"); + $location.path(link); + }; + }, + ], + bindings: { + previewObject: "=", + }, +}); + sharedComponents.component("portalSearch", { templateUrl: "portal-search.html", bindings: { @@ -8613,42 +8727,55 @@ sharedComponents.component("portalSearch", { }, }); -sharedComponents.component("previewImage", { - templateUrl: - "/mix-app/views/app-shared/components/preview-image/preview-image.html", +sharedComponents.component("recaptcha", { + templateUrl: "/mix-app/views/app-shared/components/recaptcha/recaptcha.html", controller: [ "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope) { + "ApiService", + "CommonService", + function ($rootScope, apiService, commonService) { var ctrl = this; - ctrl.isImage = false; - ctrl.init = function () { - if (ctrl.imgSrc) { - ctrl.imgClass = ctrl.imgClass || "rounded"; - ctrl.isImage = ctrl.imgSrc - .toLowerCase() - .match(/([/|.|\w|\s|-])*\.(?:jpg|jpeg|gif|png|svg|webp|jfif)/g); - // check if facebook avatar Url - ctrl.isImage = - ctrl.isImage || - ctrl.imgSrc - .toLowerCase() - .match( - /(?:(?:http|https):\/\/)?(?:www.)?(graph.facebook.com)\/([A-Za-z0-9.]{0,})\/(picture)(\?)?([A-Za-z0-9.=&]{0,})?/g - ); - } + ctrl.shortenString = ""; + ctrl.previousContentId = undefined; + ctrl.recaptcha_key = null; + ctrl.token = null; + this.$onInit = () => { + ctrl.recaptcha_key = $rootScope.globalSettings.data.Recaptcha_Key; + ctrl.recaptcha_secret = $rootScope.globalSettings.data.Recaptcha_Secret; + grecaptcha.ready(function () { + grecaptcha + .execute(ctrl.recaptcha_key, { action: ctrl.action }) + .then(function (token) { + ctrl.token = token; + }); + }); }; - ctrl.showImage = async function (functionName, args, context) { - $rootScope.preview("img", ctrl.imgSrc); + ctrl.verify = function () { + var url = "https://www.google.com/recaptcha/api/siteverify"; + var data = { + secret: ctrl.recaptcha_secret, + response: ctrl.token, + }; + var req = { + method: "POST", + url: url, + data: data, + }; + return apiService.sendRequest(req).then(function (response) { + if (response.success) { + ctrl.callback(); + } else { + angular.forEach(response.error - codes, function (err) { + commonService.showAlertMsg("Recaptcha Error", err); + }); + } + }); }; }, ], bindings: { - imgWidth: "=", - imgHeight: "=", - imgSrc: "=", - imgClass: "=?", + action: "=", + callback: "&", }, }); @@ -8809,55 +8936,134 @@ sharedComponents.component("quillEditor", { }, }); -sharedComponents.component("recaptcha", { - templateUrl: "/mix-app/views/app-shared/components/recaptcha/recaptcha.html", +sharedComponents.component("snowy", { + templateUrl: "/mix-app/views/app-shared/components/snowy/index.html", controller: [ - "$rootScope", - "ApiService", - "CommonService", - function ($rootScope, apiService, commonService) { + "$scope", + function ($scope) { var ctrl = this; - ctrl.shortenString = ""; - ctrl.previousContentId = undefined; - ctrl.recaptcha_key = null; - ctrl.token = null; - this.$onInit = () => { - ctrl.recaptcha_key = $rootScope.globalSettings.data.Recaptcha_Key; - ctrl.recaptcha_secret = $rootScope.globalSettings.data.Recaptcha_Secret; - grecaptcha.ready(function () { - grecaptcha - .execute(ctrl.recaptcha_key, { action: ctrl.action }) - .then(function (token) { - ctrl.token = token; - }); - }); - }; - ctrl.verify = function () { - var url = "https://www.google.com/recaptcha/api/siteverify"; - var data = { - secret: ctrl.recaptcha_secret, - response: ctrl.token, - }; - var req = { - method: "POST", - url: url, - data: data, + this.init = function () { + var Snowflake = (function () { + var flakes; + var flakesTotal = 250; + var wind = 0; + var mouseX; + var mouseY; + + function Snowflake(size, x, y, vx, vy) { + this.size = size; + this.x = x; + this.y = y; + this.vx = vx; + this.vy = vy; + this.hit = false; + this.melt = false; + this.div = document.createElement("div"); + this.div.classList.add("snowflake"); + this.div.style.width = this.size + "px"; + this.div.style.height = this.size + "px"; + } + + Snowflake.prototype.move = function () { + if (this.hit) { + if (Math.random() > 0.995) this.melt = true; + } else { + this.x += this.vx + Math.min(Math.max(wind, -10), 10); + this.y += this.vy; + } + + // Wrap the snowflake to within the bounds of the page + if (this.x > window.innerWidth + this.size) { + this.x -= window.innerWidth + this.size; + } + + if (this.x < -this.size) { + this.x += window.innerWidth + this.size; + } + + if (this.y > window.innerHeight + this.size) { + this.x = Math.random() * window.innerWidth; + this.y -= window.innerHeight + this.size * 2; + this.melt = false; + } + + var dx = mouseX - this.x; + var dy = mouseY - this.y; + this.hit = + !this.melt && this.y < mouseY && dx * dx + dy * dy < 2400; + }; + + Snowflake.prototype.draw = function () { + this.div.style.transform = this.div.style.MozTransform = this.div.style.webkitTransform = + "translate3d(" + this.x + "px" + "," + this.y + "px,0)"; + }; + + function update() { + for (var i = flakes.length; i--; ) { + var flake = flakes[i]; + flake.move(); + flake.draw(); + } + requestAnimationFrame(update); + } + + Snowflake.init = function (container) { + flakes = []; + + for (var i = flakesTotal; i--; ) { + var size = (Math.random() + 0.2) * 2 + 1; + var flake = new Snowflake( + size, + Math.random() * window.innerWidth, + Math.random() * window.innerHeight, + Math.random() - 0.5, + size * 0.3 + ); + container.appendChild(flake.div); + flakes.push(flake); + } + + container.onmousemove = function (event) { + mouseX = event.clientX; + mouseY = event.clientY; + wind = ((mouseX - window.innerWidth / 2) / window.innerWidth) * 6; + }; + + container.ontouchstart = function (event) { + mouseX = event.targetTouches[0].clientX; + mouseY = event.targetTouches[0].clientY; + event.preventDefault(); + }; + + window.ondeviceorientation = function (event) { + if (event) { + wind = event.gamma / 10; + } + }; + + update(); + }; + + return Snowflake; + })(); + + window.onload = function () { + setTimeout(function () { + Snowflake.init(document.getElementById("snow")); + }, 500); }; - return apiService.sendRequest(req).then(function (response) { - if (response.success) { - ctrl.callback(); - } else { - angular.forEach(response.error - codes, function (err) { - commonService.showAlertMsg("Recaptcha Error", err); - }); - } - }); }; }, ], + bindings: {}, +}); + +sharedComponents.component("codeEditor", { + templateUrl: "codeEditor.html", bindings: { - action: "=", - callback: "&", + product: "=", + onDelete: "&", + onUpdate: "&", }, }); @@ -9044,6 +9250,20 @@ sharedComponents.component("serviceHub", { ], }); +sharedComponents.component("statuses", { + templateUrl: "/mix-app/views/app-shared/components/statuses/statuses.html", + controller: [ + "$rootScope", + "ngAppSettings", + function ($rootScope, ngAppSettings) { + this.contentStatuses = ngAppSettings.contentStatuses; + }, + ], + bindings: { + status: "=", + }, +}); + sharedComponents.component("shoppingCart", { templateUrl: "/mix-app/views/app-shared/components/shopping-cart/view.html", bindings: { @@ -9079,226 +9299,95 @@ sharedComponents.controller("ShoppingCartController", [ localStorageService.set("shoppingCart", $scope.cartData); }; $scope.removeItem = function (index) { - $scope.cartData.items.splice(index, 1); - $scope.calculate(); - }; - - $scope.submit = async function () { - $scope.onValidate(); - if ($scope.frmCheckOut.$valid) { - $scope.isBusy = true; - $rootScope.submitting = true; - var result = await dataService.saveData( - "shoppingCart", - $scope.cartData - ); - if (result.success) { - $scope.isBusy = false; - $scope.cartData = result.data.obj; - $scope.$apply(); - $scope.onSuccess(result.data); - } else { - $scope.isBusy = false; - $scope.$apply(); - $scope.onFail(result.errors); - } - } - }; - - $scope.onValidate = async function () { - $scope.frmCheckOut.$$element.addClass("was-validated"); - if ($scope.validateCallback) { - let isValid = await $rootScope.executeFunctionByName( - $scope.validateCallback, - [$scope.frmCheckOut, $scope.cartData], - window - ); - $scope.frmCheckOut.$valid = $scope.frmCheckOut.$valid && isValid; - } - }; - $scope.onSuccess = function (resp) { - localStorageService.set("shoppingCart", resp.obj); - - if ($scope.successCallback) { - $rootScope.executeFunctionByName( - $scope.successCallback, - [resp], - window - ); - } else { - setTimeout(() => { - $scope.submitting = false; - }, 1000); - $scope.cartData = { - items: [], - totalItem: 0, - total: 0, - }; - localStorageService.set("shoppingCart", $scope.cartData); - window.location.href = "/"; - } - }; - $scope.onFail = function (errors) { - $scope.errors = errors; - if ($scope.failCallback) { - $rootScope.executeFunctionByName($scope.failCallback, [errors], window); - } - }; - $scope.sendmail = async function () { - let edm = - 'Url: View Tour
Name: [name]
' + - "Phone: [phone]
" + - "Email: [email]
" + - "Quantity: [quantity]
" + - "Message: [message]
" + - "property: [property]
Price: [price]
"; - - edm = edm.replace(/\[url\]/g, window.top.location.href); - edm = edm.replace(/\[name\]/g, $scope.order.name); - edm = edm.replace(/\[phone\]/g, $scope.order.phone); - edm = edm.replace(/\[email\]/g, $scope.order.email); - edm = edm.replace(/\[message\]/g, $scope.order.message); - edm = edm.replace(/\[property\]/g, $scope.order.propertyId); - edm = edm.replace(/\[price\]/g, $scope.order.price); - edm = edm.replace(/\[quantity\]/g, $scope.order.quantity); - - // TODO Handle cart submit - await commonService.sendMail("Booking - " + $scope.propertyName, edm); - $scope.submitted = true; - }; - }, -]); - -sharedComponents.component("codeEditor", { - templateUrl: "codeEditor.html", - bindings: { - product: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -sharedComponents.component("snowy", { - templateUrl: "/mix-app/views/app-shared/components/snowy/index.html", - controller: [ - "$scope", - function ($scope) { - var ctrl = this; - this.init = function () { - var Snowflake = (function () { - var flakes; - var flakesTotal = 250; - var wind = 0; - var mouseX; - var mouseY; - - function Snowflake(size, x, y, vx, vy) { - this.size = size; - this.x = x; - this.y = y; - this.vx = vx; - this.vy = vy; - this.hit = false; - this.melt = false; - this.div = document.createElement("div"); - this.div.classList.add("snowflake"); - this.div.style.width = this.size + "px"; - this.div.style.height = this.size + "px"; - } - - Snowflake.prototype.move = function () { - if (this.hit) { - if (Math.random() > 0.995) this.melt = true; - } else { - this.x += this.vx + Math.min(Math.max(wind, -10), 10); - this.y += this.vy; - } - - // Wrap the snowflake to within the bounds of the page - if (this.x > window.innerWidth + this.size) { - this.x -= window.innerWidth + this.size; - } - - if (this.x < -this.size) { - this.x += window.innerWidth + this.size; - } - - if (this.y > window.innerHeight + this.size) { - this.x = Math.random() * window.innerWidth; - this.y -= window.innerHeight + this.size * 2; - this.melt = false; - } - - var dx = mouseX - this.x; - var dy = mouseY - this.y; - this.hit = - !this.melt && this.y < mouseY && dx * dx + dy * dy < 2400; - }; - - Snowflake.prototype.draw = function () { - this.div.style.transform = this.div.style.MozTransform = this.div.style.webkitTransform = - "translate3d(" + this.x + "px" + "," + this.y + "px,0)"; - }; - - function update() { - for (var i = flakes.length; i--; ) { - var flake = flakes[i]; - flake.move(); - flake.draw(); - } - requestAnimationFrame(update); - } - - Snowflake.init = function (container) { - flakes = []; - - for (var i = flakesTotal; i--; ) { - var size = (Math.random() + 0.2) * 2 + 1; - var flake = new Snowflake( - size, - Math.random() * window.innerWidth, - Math.random() * window.innerHeight, - Math.random() - 0.5, - size * 0.3 - ); - container.appendChild(flake.div); - flakes.push(flake); - } - - container.onmousemove = function (event) { - mouseX = event.clientX; - mouseY = event.clientY; - wind = ((mouseX - window.innerWidth / 2) / window.innerWidth) * 6; - }; + $scope.cartData.items.splice(index, 1); + $scope.calculate(); + }; - container.ontouchstart = function (event) { - mouseX = event.targetTouches[0].clientX; - mouseY = event.targetTouches[0].clientY; - event.preventDefault(); - }; + $scope.submit = async function () { + $scope.onValidate(); + if ($scope.frmCheckOut.$valid) { + $scope.isBusy = true; + $rootScope.submitting = true; + var result = await dataService.saveData( + "shoppingCart", + $scope.cartData + ); + if (result.success) { + $scope.isBusy = false; + $scope.cartData = result.data.obj; + $scope.$apply(); + $scope.onSuccess(result.data); + } else { + $scope.isBusy = false; + $scope.$apply(); + $scope.onFail(result.errors); + } + } + }; - window.ondeviceorientation = function (event) { - if (event) { - wind = event.gamma / 10; - } - }; + $scope.onValidate = async function () { + $scope.frmCheckOut.$$element.addClass("was-validated"); + if ($scope.validateCallback) { + let isValid = await $rootScope.executeFunctionByName( + $scope.validateCallback, + [$scope.frmCheckOut, $scope.cartData], + window + ); + $scope.frmCheckOut.$valid = $scope.frmCheckOut.$valid && isValid; + } + }; + $scope.onSuccess = function (resp) { + localStorageService.set("shoppingCart", resp.obj); - update(); - }; + if ($scope.successCallback) { + $rootScope.executeFunctionByName( + $scope.successCallback, + [resp], + window + ); + } else { + setTimeout(() => { + $scope.submitting = false; + }, 1000); + $scope.cartData = { + items: [], + totalItem: 0, + total: 0, + }; + localStorageService.set("shoppingCart", $scope.cartData); + window.location.href = "/"; + } + }; + $scope.onFail = function (errors) { + $scope.errors = errors; + if ($scope.failCallback) { + $rootScope.executeFunctionByName($scope.failCallback, [errors], window); + } + }; + $scope.sendmail = async function () { + let edm = + 'Url: View Tour
Name: [name]
' + + "Phone: [phone]
" + + "Email: [email]
" + + "Quantity: [quantity]
" + + "Message: [message]
" + + "property: [property]
Price: [price]
"; - return Snowflake; - })(); + edm = edm.replace(/\[url\]/g, window.top.location.href); + edm = edm.replace(/\[name\]/g, $scope.order.name); + edm = edm.replace(/\[phone\]/g, $scope.order.phone); + edm = edm.replace(/\[email\]/g, $scope.order.email); + edm = edm.replace(/\[message\]/g, $scope.order.message); + edm = edm.replace(/\[property\]/g, $scope.order.propertyId); + edm = edm.replace(/\[price\]/g, $scope.order.price); + edm = edm.replace(/\[quantity\]/g, $scope.order.quantity); - window.onload = function () { - setTimeout(function () { - Snowflake.init(document.getElementById("snow")); - }, 500); - }; - }; - }, - ], - bindings: {}, -}); + // TODO Handle cart submit + await commonService.sendMail("Booking - " + $scope.propertyName, edm); + $scope.submitted = true; + }; + }, +]); sharedComponents.component("starRating", { templateUrl: @@ -9344,20 +9433,6 @@ appShared.controller("StarRatingController", [ }, ]); -sharedComponents.component("statuses", { - templateUrl: "/mix-app/views/app-shared/components/statuses/statuses.html", - controller: [ - "$rootScope", - "ngAppSettings", - function ($rootScope, ngAppSettings) { - this.contentStatuses = ngAppSettings.contentStatuses; - }, - ], - bindings: { - status: "=", - }, -}); - sharedComponents.component("mixStore", { templateUrl: "/mix-app/views/app-shared/components/store/view.html", bindings: { @@ -9543,9 +9618,9 @@ sharedComponents.component("mixStore", { }); "use trick"; -sharedComponents.directive("pane", function () { +sharedComponents.directive("paneH", function () { return { - require: "^tabs", + require: "^tabs-h", restrict: "E", transclude: true, scope: { header: "@", id: "@", icon: "@" }, @@ -9559,7 +9634,7 @@ sharedComponents.directive("pane", function () { }; }); -sharedComponents.directive("tabs", function () { +sharedComponents.directive("tabsH", function () { return { restrict: "E", transclude: true, @@ -9582,18 +9657,19 @@ sharedComponents.directive("tabs", function () { panes.push(pane); }; }, - templateUrl: "/mix-app/views/app-shared/components/tabs/tabs.html", + templateUrl: + "/mix-app/views/app-shared/components/tabs-horizontal/tabs.html", replace: true, }; }); "use trick"; -sharedComponents.directive("paneH", function () { +sharedComponents.directive("paneV", function () { return { - require: "^tabs-h", + require: "^tabs-v", restrict: "E", transclude: true, - scope: { header: "@", id: "@", icon: "@" }, + scope: { header: "@", id: "@", icon: "@", class: "@" }, link: function (scope, element, attrs, tabsController) { tabsController.addPane(scope); }, @@ -9604,7 +9680,7 @@ sharedComponents.directive("paneH", function () { }; }); -sharedComponents.directive("tabsH", function () { +sharedComponents.directive("tabsV", function () { return { restrict: "E", transclude: true, @@ -9627,19 +9703,18 @@ sharedComponents.directive("tabsH", function () { panes.push(pane); }; }, - templateUrl: - "/mix-app/views/app-shared/components/tabs-horizontal/tabs.html", + templateUrl: "/mix-app/views/app-shared/components/tabs-verticle/tabs.html", replace: true, }; }); "use trick"; -sharedComponents.directive("paneV", function () { +sharedComponents.directive("pane", function () { return { - require: "^tabs-v", + require: "^tabs", restrict: "E", transclude: true, - scope: { header: "@", id: "@", icon: "@", class: "@" }, + scope: { header: "@", id: "@", icon: "@" }, link: function (scope, element, attrs, tabsController) { tabsController.addPane(scope); }, @@ -9650,7 +9725,7 @@ sharedComponents.directive("paneV", function () { }; }); -sharedComponents.directive("tabsV", function () { +sharedComponents.directive("tabs", function () { return { restrict: "E", transclude: true, @@ -9673,7 +9748,7 @@ sharedComponents.directive("tabsV", function () { panes.push(pane); }; }, - templateUrl: "/mix-app/views/app-shared/components/tabs-verticle/tabs.html", + templateUrl: "/mix-app/views/app-shared/components/tabs/tabs.html", replace: true, }; }); @@ -9886,6 +9961,58 @@ sharedComponents.component("trumbowyg", { ], }); +sharedComponents.component("tuiEditor", { + templateUrl: "/mix-app/views/app-shared/components/tui-editor/view.html", + controller: [ + "$rootScope", + "$scope", + "$element", + "ngAppSettings", + function ($rootScope, $scope, $element, ngAppSettings) { + var ctrl = this; + ctrl.previousId = null; + ctrl.editor = null; + ctrl.init = function () { + ctrl.guid = $rootScope.generateUUID(); + setTimeout(() => { + ctrl.editor = new tui.Editor({ + el: document.querySelector("#tui-" + ctrl.guid), + initialEditType: "markdown", + previewStyle: "vertical", + height: "300px", + initialValue: ctrl.content, + events: { + // change: ctrl.updateContent, + // focus: () => onFocus(), + blur: () => ctrl.updateContent(), + }, + }); + ctrl.toolbar = ctrl.editor.getUI().getToolbar(); + ctrl.toolbar.addButton( + { + name: "fullscreen", + tooltip: "fullscreen", + $el: $( + '' + ), + }, + 1 + ); + }, 100); + }; + window.fsClick = function () { + $(".tui-editor-defaultUI").toggleClass("fs"); + }; + ctrl.updateContent = function () { + ctrl.content = ctrl.editor.getMarkdown(); + }; + }, + ], + bindings: { + content: "=", + }, +}); + sharedComponents.component("uploadCroppie", { templateUrl: "/mix-app/views/app-shared/components/upload-croppie/view.html?v=1", @@ -10118,58 +10245,6 @@ sharedComponents.component("uploadCroppie", { ], }); -sharedComponents.component("tuiEditor", { - templateUrl: "/mix-app/views/app-shared/components/tui-editor/view.html", - controller: [ - "$rootScope", - "$scope", - "$element", - "ngAppSettings", - function ($rootScope, $scope, $element, ngAppSettings) { - var ctrl = this; - ctrl.previousId = null; - ctrl.editor = null; - ctrl.init = function () { - ctrl.guid = $rootScope.generateUUID(); - setTimeout(() => { - ctrl.editor = new tui.Editor({ - el: document.querySelector("#tui-" + ctrl.guid), - initialEditType: "markdown", - previewStyle: "vertical", - height: "300px", - initialValue: ctrl.content, - events: { - // change: ctrl.updateContent, - // focus: () => onFocus(), - blur: () => ctrl.updateContent(), - }, - }); - ctrl.toolbar = ctrl.editor.getUI().getToolbar(); - ctrl.toolbar.addButton( - { - name: "fullscreen", - tooltip: "fullscreen", - $el: $( - '' - ), - }, - 1 - ); - }, 100); - }; - window.fsClick = function () { - $(".tui-editor-defaultUI").toggleClass("fs"); - }; - ctrl.updateContent = function () { - ctrl.content = ctrl.editor.getMarkdown(); - }; - }, - ], - bindings: { - content: "=", - }, -}); - "use strict"; appShared.controller("VideoCallController", [ "$scope", diff --git a/src/applications/Mixcore/wwwroot/mix-app/views/app-init/pages/step3/view.html b/src/applications/Mixcore/wwwroot/mix-app/views/app-init/pages/step3/view.html index 89e623c3a..b44cb353b 100644 --- a/src/applications/Mixcore/wwwroot/mix-app/views/app-init/pages/step3/view.html +++ b/src/applications/Mixcore/wwwroot/mix-app/views/app-init/pages/step3/view.html @@ -1 +1 @@ -
Mixcore CMS

You can start Mixcore with blank theme or with our default beautiful themes.

Blank Theme

Choose this theme only if you want to build your theme from scratch.

Mixcore Themes list.
25% Complete
\ No newline at end of file +
Mixcore CMS

You can start Mixcore with blank theme or with our default beautiful themes.

Blank Theme

Choose this theme only if you want to build your theme from scratch.

Mixcore Themes list.
25% Complete
\ No newline at end of file diff --git a/src/modules/mix.account/Controllers/MixRoleController.cs b/src/modules/mix.account/Controllers/MixRoleController.cs index 84f0cb704..b34d1d69b 100644 --- a/src/modules/mix.account/Controllers/MixRoleController.cs +++ b/src/modules/mix.account/Controllers/MixRoleController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using Mix.Database.Entities.Account; using Mix.Heart.Entities.Cache; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.Queue.Interfaces; using Mix.Queue.Models; @@ -22,8 +23,10 @@ public MixRoleController( MixIdentityService mixIdentityService, MixCacheDbContext cacheDbContext, MixCmsAccountContext context, - IQueueService queueService) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cacheDbContext, context, queueService) + IQueueService queueService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cacheDbContext, context, queueService, mixTenantService) { } diff --git a/src/modules/mix.account/Controllers/MixUserController.cs b/src/modules/mix.account/Controllers/MixUserController.cs index bbe203292..3259a2b2c 100644 --- a/src/modules/mix.account/Controllers/MixUserController.cs +++ b/src/modules/mix.account/Controllers/MixUserController.cs @@ -66,8 +66,10 @@ public MixUserController( IQueueService queueService, UnitOfWorkInfo mixDbUow, AuthConfigService authConfigService, - IMixEdmService edmService) - : base(httpContextAccessor, configuration, mixService, translator, mixIdentityService, queueService) + IMixEdmService edmService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, mixService, + translator, mixIdentityService, queueService, mixTenantService) { _userManager = userManager; _signInManager = signInManager; diff --git a/src/modules/mix.common/Controllers/PostContentApiController.cs b/src/modules/mix.common/Controllers/PostContentApiController.cs index 54f0d7618..43b9f2b4e 100644 --- a/src/modules/mix.common/Controllers/PostContentApiController.cs +++ b/src/modules/mix.common/Controllers/PostContentApiController.cs @@ -2,6 +2,7 @@ using Mix.Common.Domain.ViewModels; using Mix.Heart.Extensions; using Mix.Heart.Models; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.Lib.ViewModels; using Mix.Queue.Interfaces; @@ -25,8 +26,10 @@ public PostContentApiController( UnitOfWorkInfo cmsUow, IQueueService queueService, MixRepoDbRepository mixRepoDbRepository, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _mixRepoDbRepository = mixRepoDbRepository; } diff --git a/src/modules/mix.common/Controllers/SettingApiController.cs b/src/modules/mix.common/Controllers/SettingApiController.cs index 180face4d..50fe5ffc4 100644 --- a/src/modules/mix.common/Controllers/SettingApiController.cs +++ b/src/modules/mix.common/Controllers/SettingApiController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Mvc; using Mix.Heart.Exceptions; using Mix.Identity.Constants; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.Queue.Interfaces; using Mix.Queue.Models; @@ -22,8 +23,10 @@ public SettingApiController( MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, - IQueueService queueService) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + IQueueService queueService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { } diff --git a/src/modules/mix.common/Controllers/SharedApiController.cs b/src/modules/mix.common/Controllers/SharedApiController.cs index 70180941e..7f89c6776 100644 --- a/src/modules/mix.common/Controllers/SharedApiController.cs +++ b/src/modules/mix.common/Controllers/SharedApiController.cs @@ -43,8 +43,10 @@ public SharedApiController( ApplicationLifetime applicationLifetime, MixCacheService cacheService, IHttpContextAccessor httpContextAccessor, - MixQueueMessages mixMemoryMessageQueue) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + MixQueueMessages mixMemoryMessageQueue, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { _uow = uow; _cacheService = cacheService; diff --git a/src/modules/mix.common/Controllers/SharedTenantApiController.cs b/src/modules/mix.common/Controllers/SharedTenantApiController.cs index 528ac893e..fffe7278b 100644 --- a/src/modules/mix.common/Controllers/SharedTenantApiController.cs +++ b/src/modules/mix.common/Controllers/SharedTenantApiController.cs @@ -2,6 +2,7 @@ using Mix.Common.Domain.Helpers; using Mix.Common.Domain.ViewModels; using Mix.Common.Models; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.Queue.Interfaces; using Mix.Queue.Models; @@ -27,8 +28,10 @@ public SharedTenantApiController( MixIdentityService mixIdentityService, AuthConfigService authConfigService, MixCmsContext context, - IQueueService queueService) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + IQueueService queueService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { _authConfigurations = authConfigService.AppSettings; Context = context; diff --git a/src/modules/mix.portal/Controllers/CommonController.cs b/src/modules/mix.portal/Controllers/CommonController.cs index b468d057c..9365bf61b 100644 --- a/src/modules/mix.portal/Controllers/CommonController.cs +++ b/src/modules/mix.portal/Controllers/CommonController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Mix.Heart.Helpers; +using Mix.Lib.Interfaces; using Mix.RepoDb.Repositories; using RepoDb; using RepoDb.Enumerations; @@ -22,8 +23,10 @@ public CommonController( MixIdentityService mixIdentityService, IQueueService queueService, TenantUserManager userManager, - MixRepoDbRepository repoDbRepository) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + MixRepoDbRepository repoDbRepository, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { _context = context; UserManager = userManager; diff --git a/src/modules/mix.portal/Controllers/MixApplicationController.cs b/src/modules/mix.portal/Controllers/MixApplicationController.cs index 3fca951bf..fa8e53970 100644 --- a/src/modules/mix.portal/Controllers/MixApplicationController.cs +++ b/src/modules/mix.portal/Controllers/MixApplicationController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Mix.Database.Entities.AuditLog; +using Mix.Lib.Interfaces; using Mix.Portal.Domain.Interfaces; using Mix.SignalR.Interfaces; @@ -20,8 +21,10 @@ public MixApplicationController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _cmsContext = uow.DbContext; } diff --git a/src/modules/mix.portal/Controllers/MixAuditLogController.cs b/src/modules/mix.portal/Controllers/MixAuditLogController.cs index a00349146..719b93302 100644 --- a/src/modules/mix.portal/Controllers/MixAuditLogController.cs +++ b/src/modules/mix.portal/Controllers/MixAuditLogController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Mix.Database.Entities.AuditLog; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -18,8 +19,10 @@ public AuditLogController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixConfigurationController.cs b/src/modules/mix.portal/Controllers/MixConfigurationController.cs index eafc4d798..56dc1a6b6 100644 --- a/src/modules/mix.portal/Controllers/MixConfigurationController.cs +++ b/src/modules/mix.portal/Controllers/MixConfigurationController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -20,8 +21,10 @@ public MixConfigurationController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _cmsUow = uow; _configService = configService; diff --git a/src/modules/mix.portal/Controllers/MixCultureController.cs b/src/modules/mix.portal/Controllers/MixCultureController.cs index fda3a7b04..a25c43d11 100644 --- a/src/modules/mix.portal/Controllers/MixCultureController.cs +++ b/src/modules/mix.portal/Controllers/MixCultureController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.Portal.Domain.Interfaces; using Mix.SignalR.Interfaces; @@ -20,8 +21,10 @@ public MixCultureController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _cloneCultureService = cloneCultureService; } diff --git a/src/modules/mix.portal/Controllers/MixDatabaseAssociationController.cs b/src/modules/mix.portal/Controllers/MixDatabaseAssociationController.cs index 7124cede3..6d6925545 100644 --- a/src/modules/mix.portal/Controllers/MixDatabaseAssociationController.cs +++ b/src/modules/mix.portal/Controllers/MixDatabaseAssociationController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -17,8 +18,10 @@ public MixDatabaseAssociationController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixDatabaseColumnPortalController.cs b/src/modules/mix.portal/Controllers/MixDatabaseColumnPortalController.cs index 403b0045d..9adb299ff 100644 --- a/src/modules/mix.portal/Controllers/MixDatabaseColumnPortalController.cs +++ b/src/modules/mix.portal/Controllers/MixDatabaseColumnPortalController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; using System.Linq.Expressions; @@ -18,8 +19,10 @@ public MixDatabaseColumnPortalController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixDatabaseController.cs b/src/modules/mix.portal/Controllers/MixDatabaseController.cs index 8e3547fff..13cac83d2 100644 --- a/src/modules/mix.portal/Controllers/MixDatabaseController.cs +++ b/src/modules/mix.portal/Controllers/MixDatabaseController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.RepoDb.Interfaces; using Mix.SignalR.Interfaces; @@ -20,8 +21,10 @@ public MixDatabaseController( UnitOfWorkInfo cmsUow, IQueueService queueService, IMixDbService mixDbService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _mixDbService = mixDbService; } diff --git a/src/modules/mix.portal/Controllers/MixDatabaseRelationshipController.cs b/src/modules/mix.portal/Controllers/MixDatabaseRelationshipController.cs index 5ddb772b9..92bb5c9b6 100644 --- a/src/modules/mix.portal/Controllers/MixDatabaseRelationshipController.cs +++ b/src/modules/mix.portal/Controllers/MixDatabaseRelationshipController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -15,10 +16,12 @@ public MixDatabaseRelationshipController( MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, - UnitOfWorkInfo uow, + UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixDbController.cs b/src/modules/mix.portal/Controllers/MixDbController.cs index 550add1b2..00920abe8 100644 --- a/src/modules/mix.portal/Controllers/MixDbController.cs +++ b/src/modules/mix.portal/Controllers/MixDbController.cs @@ -4,6 +4,7 @@ using Mix.Database.Services; using Mix.Heart.Helpers; using Mix.Heart.Model; +using Mix.Lib.Interfaces; using Mix.RepoDb.Interfaces; using Mix.RepoDb.Repositories; using Mix.Service.Commands; @@ -64,8 +65,10 @@ public MixDbController( MixIdentityService idService, IMixDbService mixDbService, IMixDbCommandHubClientService mixDbCommandHubClientService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { _repository = repository; _associationRepository = new(cache, databaseService, cmsUow); diff --git a/src/modules/mix.portal/Controllers/MixDomainController.cs b/src/modules/mix.portal/Controllers/MixDomainController.cs index 6d13381a6..e27597605 100644 --- a/src/modules/mix.portal/Controllers/MixDomainController.cs +++ b/src/modules/mix.portal/Controllers/MixDomainController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -14,7 +15,10 @@ public MixDomainController( IConfiguration configuration, MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixLanguageController.cs b/src/modules/mix.portal/Controllers/MixLanguageController.cs index a38c96daf..defc4de80 100644 --- a/src/modules/mix.portal/Controllers/MixLanguageController.cs +++ b/src/modules/mix.portal/Controllers/MixLanguageController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -10,7 +11,10 @@ public class MixLanguageController : MixRestfulApiControllerBase { public MixLanguageController(IHttpContextAccessor httpContextAccessor, IConfiguration configuration, MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixModuleDataController.cs b/src/modules/mix.portal/Controllers/MixModuleDataController.cs index 3548dc125..3a7f17171 100644 --- a/src/modules/mix.portal/Controllers/MixModuleDataController.cs +++ b/src/modules/mix.portal/Controllers/MixModuleDataController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.RepoDb.Interfaces; using Mix.SignalR.Interfaces; @@ -18,8 +19,10 @@ public MixModuleDataController( UnitOfWorkInfo cmsUow, IQueueService queueService, IMixDbService mixDbService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixModulePostPortalController.cs b/src/modules/mix.portal/Controllers/MixModulePostPortalController.cs index a218ff7a2..806840e1c 100644 --- a/src/modules/mix.portal/Controllers/MixModulePostPortalController.cs +++ b/src/modules/mix.portal/Controllers/MixModulePostPortalController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -18,8 +19,10 @@ public MixModulePostController( MixIdentityService mixIdentityService, UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _cmsUow = cmsUow; } diff --git a/src/modules/mix.portal/Controllers/MixPageContentController.cs b/src/modules/mix.portal/Controllers/MixPageContentController.cs index a0d3ed641..dc9b240f9 100644 --- a/src/modules/mix.portal/Controllers/MixPageContentController.cs +++ b/src/modules/mix.portal/Controllers/MixPageContentController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -19,8 +20,11 @@ public MixPageContentController( MixIdentityService mixIdentityService, UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(MixContentType.Page, identityService, userManager, httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(MixContentType.Page, identityService, userManager, + httpContextAccessor, configuration, cacheService, translator, + mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixPageModuleController.cs b/src/modules/mix.portal/Controllers/MixPageModuleController.cs index ad0af7b09..b184dc3ff 100644 --- a/src/modules/mix.portal/Controllers/MixPageModuleController.cs +++ b/src/modules/mix.portal/Controllers/MixPageModuleController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -18,8 +19,10 @@ public MixPageModuleController( MixIdentityService mixIdentityService, UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _cmsUow = cmsUow; } diff --git a/src/modules/mix.portal/Controllers/MixPagePostPortalController.cs b/src/modules/mix.portal/Controllers/MixPagePostPortalController.cs index d43fae98e..7d3b418eb 100644 --- a/src/modules/mix.portal/Controllers/MixPagePostPortalController.cs +++ b/src/modules/mix.portal/Controllers/MixPagePostPortalController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -11,7 +12,10 @@ public class MixPagePostController private readonly UnitOfWorkInfo _cmsUow; public MixPagePostController(IHttpContextAccessor httpContextAccessor, IConfiguration configuration, MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _cmsUow = cmsUow; } diff --git a/src/modules/mix.portal/Controllers/MixPostContentController.cs b/src/modules/mix.portal/Controllers/MixPostContentController.cs index 747969883..468c32e80 100644 --- a/src/modules/mix.portal/Controllers/MixPostContentController.cs +++ b/src/modules/mix.portal/Controllers/MixPostContentController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.Portal.Domain.Services; using Mix.RepoDb.Repositories; using Mix.SignalR.Interfaces; @@ -25,9 +26,10 @@ public MixPostContentController( IQueueService queueService, MixRepoDbRepository mixRepoDbRepository, PortalPostService postService, - IPortalHubClientService portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) : base(MixContentType.Post, identityService, userManager, httpContextAccessor, configuration, cacheService, translator, - mixIdentityService, cmsUow, queueService, portalHub) + mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _mixRepoDbRepository = mixRepoDbRepository; _postService = postService; diff --git a/src/modules/mix.portal/Controllers/MixPostPostController.cs b/src/modules/mix.portal/Controllers/MixPostPostController.cs index 1fe12135c..270255a86 100644 --- a/src/modules/mix.portal/Controllers/MixPostPostController.cs +++ b/src/modules/mix.portal/Controllers/MixPostPostController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -11,7 +12,10 @@ public class MixPostPostController private readonly UnitOfWorkInfo _cmsUow; public MixPostPostController(IHttpContextAccessor httpContextAccessor, IConfiguration configuration, MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _cmsUow = cmsUow; } diff --git a/src/modules/mix.portal/Controllers/MixTemplateController.cs b/src/modules/mix.portal/Controllers/MixTemplateController.cs index db9a64927..f0f97c485 100644 --- a/src/modules/mix.portal/Controllers/MixTemplateController.cs +++ b/src/modules/mix.portal/Controllers/MixTemplateController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; namespace Mix.Portal.Controllers @@ -17,8 +18,10 @@ public MixTemplateController( MixIdentityService mixIdentityService, UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { } diff --git a/src/modules/mix.portal/Controllers/MixTenantController.cs b/src/modules/mix.portal/Controllers/MixTenantController.cs index 0c1f91ebe..0b0abdb42 100644 --- a/src/modules/mix.portal/Controllers/MixTenantController.cs +++ b/src/modules/mix.portal/Controllers/MixTenantController.cs @@ -30,7 +30,8 @@ public MixTenantController( UnitOfWorkInfo uow, IQueueService queueService, IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _userManager = userManager; _accContext = accContext; diff --git a/src/modules/mix.portal/Controllers/MixThemeController.cs b/src/modules/mix.portal/Controllers/MixThemeController.cs index c5b28348a..93ffad928 100644 --- a/src/modules/mix.portal/Controllers/MixThemeController.cs +++ b/src/modules/mix.portal/Controllers/MixThemeController.cs @@ -37,8 +37,10 @@ public MixThemeController( HttpService httpService, IHubContext hubContext, MixConfigurationService configService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { _exportService = exportService; diff --git a/src/modules/mix.portal/Domain/Services/CloneCultureService.cs b/src/modules/mix.portal/Domain/Services/CloneCultureService.cs index b39888176..04b0adf00 100644 --- a/src/modules/mix.portal/Domain/Services/CloneCultureService.cs +++ b/src/modules/mix.portal/Domain/Services/CloneCultureService.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using Mix.Database.Entities.Base; +using Mix.Lib.Interfaces; using Mix.Portal.Domain.Interfaces; using System.Linq.Expressions; @@ -20,8 +21,9 @@ public sealed class CloneCultureService : TenantServiceBase, ICloneCultureServic public CloneCultureService( IHttpContextAccessor httpContextAccessor, UnitOfWorkInfo cmsUow, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _cmsUow = cmsUow; } diff --git a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs index d5d6e46d9..a35c43e45 100644 --- a/src/modules/mix.portal/Domain/Services/MixApplicationService.cs +++ b/src/modules/mix.portal/Domain/Services/MixApplicationService.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.SignalR; using Mix.Heart.Constants; +using Mix.Lib.Interfaces; using Mix.Portal.Domain.Interfaces; using Mix.Shared.Helpers; using Mix.Shared.Services; @@ -25,8 +26,9 @@ public MixApplicationService( MixIdentityService mixIdentityService, IThemeService themeService, IQueueService queueService, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _cmsUow = cmsUow; _hubContext = hubContext; diff --git a/src/modules/mix.portal/Domain/Services/PortalPostService.cs b/src/modules/mix.portal/Domain/Services/PortalPostService.cs index 8380257c3..940509064 100644 --- a/src/modules/mix.portal/Domain/Services/PortalPostService.cs +++ b/src/modules/mix.portal/Domain/Services/PortalPostService.cs @@ -1,4 +1,5 @@ -using Mix.Services.Databases.Lib.Abstracts; +using Mix.Lib.Interfaces; +using Mix.Services.Databases.Lib.Abstracts; using Mix.Services.Databases.Lib.Interfaces; namespace Mix.Portal.Domain.Services @@ -9,8 +10,9 @@ public PortalPostService( UnitOfWorkInfo uow, IMixMetadataService metadataService, IHttpContextAccessor httpContextAccessor, - MixCacheService cacheService) - : base(uow, metadataService, httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(uow, metadataService, httpContextAccessor, cacheService, mixTenantService) { } } diff --git a/src/modules/mix.portal/Domain/Services/ThemeService.cs b/src/modules/mix.portal/Domain/Services/ThemeService.cs index 58a736544..6aeb63d91 100644 --- a/src/modules/mix.portal/Domain/Services/ThemeService.cs +++ b/src/modules/mix.portal/Domain/Services/ThemeService.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore; +using Mix.Lib.Interfaces; using Mix.Portal.Domain.Interfaces; namespace Mix.Portal.Domain.Services @@ -6,7 +7,8 @@ namespace Mix.Portal.Domain.Services public sealed class ThemeService : TenantServiceBase, IThemeService { private readonly UnitOfWorkInfo _cmsUow; - public ThemeService(IHttpContextAccessor httpContextAccessor, UnitOfWorkInfo cmsUow, MixCacheService cacheService) : base(httpContextAccessor, cacheService) + public ThemeService(IHttpContextAccessor httpContextAccessor, UnitOfWorkInfo cmsUow, MixCacheService cacheService, + IMixTenantService mixTenantService) : base(httpContextAccessor, cacheService, mixTenantService) { _cmsUow = cmsUow; } diff --git a/src/modules/mix.storage/Controllers/FileSystemController.cs b/src/modules/mix.storage/Controllers/FileSystemController.cs index 7708b79bf..98cb28465 100644 --- a/src/modules/mix.storage/Controllers/FileSystemController.cs +++ b/src/modules/mix.storage/Controllers/FileSystemController.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Mvc; using Mix.Heart.Constants; +using Mix.Lib.Interfaces; using Mix.Storage.Lib.Models; namespace Mix.Storage.Controllers @@ -16,8 +17,10 @@ public FileSystemController( TranslatorService translator, MixIdentityService mixIdentityService, IQueueService queueService, - MixStorageService storageService) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + MixStorageService storageService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { } diff --git a/src/modules/mix.storage/Controllers/StorageController.cs b/src/modules/mix.storage/Controllers/StorageController.cs index fbd806fcb..1b412b68f 100644 --- a/src/modules/mix.storage/Controllers/StorageController.cs +++ b/src/modules/mix.storage/Controllers/StorageController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Mix.Lib.Interfaces; using Mix.SignalR.Interfaces; using Mix.Storage.Lib.ViewModels; @@ -11,7 +12,10 @@ public class StorageController : MixRestfulApiControllerBase uow, IQueueService queueService, - IPortalHubClientService portalHub) : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _storageService = storageService; } diff --git a/src/modules/mix.tenancy/Controllers/InitController.cs b/src/modules/mix.tenancy/Controllers/InitController.cs index d782f35aa..ce38ad95c 100644 --- a/src/modules/mix.tenancy/Controllers/InitController.cs +++ b/src/modules/mix.tenancy/Controllers/InitController.cs @@ -49,7 +49,8 @@ public InitController( MixEndpointService mixEndpointService = null, MixConfigurationService configService = null, UnitOfWorkInfo uow = null) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { _initCmsService = initCmsService; diff --git a/src/platform/mix.library/Base/MixApiTenantControllerBase.cs b/src/platform/mix.library/Base/MixApiTenantControllerBase.cs index 4a0645d87..fc2231c05 100644 --- a/src/platform/mix.library/Base/MixApiTenantControllerBase.cs +++ b/src/platform/mix.library/Base/MixApiTenantControllerBase.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; namespace Mix.Lib.Base @@ -18,14 +19,16 @@ public abstract class MixTenantApiControllerBase : Controller protected readonly IConfiguration Configuration; protected readonly MixIdentityService MixIdentityService; protected readonly TranslatorService Translator; - protected MixTenantSystemModel CurrentTenant => Session.Get(MixRequestQueryKeywords.Tenant); + protected IMixTenantService MixTenantService; + protected MixTenantSystemModel CurrentTenant { get; set; } protected MixTenantApiControllerBase( IHttpContextAccessor httpContextAccessor, IConfiguration configuration, MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, - IQueueService queueService) + IQueueService queueService, + IMixTenantService mixTenantService) { HttpContextAccessor = httpContextAccessor; Session = httpContextAccessor.HttpContext?.Session; @@ -34,6 +37,9 @@ protected MixTenantApiControllerBase( Translator = translator; MixIdentityService = mixIdentityService; QueueService = queueService; + MixTenantService = mixTenantService; + + } public override void OnActionExecuting(ActionExecutingContext context) @@ -44,14 +50,19 @@ public override void OnActionExecuting(ActionExecutingContext context) { return; } - if (CurrentTenant != null) - { - Lang = RouteData.Values[MixRequestQueryKeywords.Specificulture] != null - ? RouteData.Values[MixRequestQueryKeywords.Specificulture].ToString() - : CurrentTenant.Configurations.DefaultCulture; + CurrentTenant = Session.Get(MixRequestQueryKeywords.Tenant); + CurrentTenant ??= MixTenantService.GetDefaultTenant().GetAwaiter().GetResult(); + Lang = RouteData.Values[MixRequestQueryKeywords.Specificulture] != null + ? RouteData.Values[MixRequestQueryKeywords.Specificulture].ToString() + : CurrentTenant.Configurations.DefaultCulture; - Culture = CurrentTenant.Cultures.FirstOrDefault(c => c.Specificulture == Lang) ?? CurrentTenant.Cultures.FirstOrDefault(); - } + Culture = CurrentTenant.Cultures.FirstOrDefault(c => c.Specificulture == Lang) ?? CurrentTenant.Cultures.FirstOrDefault(); + } + + protected bool IsValidCulture(string culture) + { + return CurrentTenant != null && !string.IsNullOrEmpty(culture) + && CurrentTenant.Cultures.Any(m => m.Specificulture == culture); } } } diff --git a/src/platform/mix.library/Base/MixAssociationApiControllerBase.cs b/src/platform/mix.library/Base/MixAssociationApiControllerBase.cs index 61564d470..0da492161 100644 --- a/src/platform/mix.library/Base/MixAssociationApiControllerBase.cs +++ b/src/platform/mix.library/Base/MixAssociationApiControllerBase.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Mix.Lib.Dtos; +using Mix.Lib.Interfaces; using Mix.Lib.Models.Common; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -16,7 +17,10 @@ public class MixAssociationApiControllerBase where TView : AssociationViewModelBase { public MixAssociationApiControllerBase(IHttpContextAccessor httpContextAccessor, IConfiguration configuration, MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/platform/mix.library/Base/MixBaseContentController.cs b/src/platform/mix.library/Base/MixBaseContentController.cs index aa0943001..252160b0d 100644 --- a/src/platform/mix.library/Base/MixBaseContentController.cs +++ b/src/platform/mix.library/Base/MixBaseContentController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.SignalR.Interfaces; using System.Linq.Expressions; @@ -30,8 +31,10 @@ protected MixBaseContentController( MixIdentityService mixIdentityService, UnitOfWorkInfo cmsUow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, cmsUow, queueService, portalHub, mixTenantService) { ContentType = contentType; CmsUow = cmsUow; diff --git a/src/platform/mix.library/Base/MixQueryApiControllerBase.cs b/src/platform/mix.library/Base/MixQueryApiControllerBase.cs index 7abb042c6..7822c6408 100644 --- a/src/platform/mix.library/Base/MixQueryApiControllerBase.cs +++ b/src/platform/mix.library/Base/MixQueryApiControllerBase.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -22,8 +23,10 @@ public MixQueryApiControllerBase( TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/platform/mix.library/Base/MixQueryEntityApiControllerBase.cs b/src/platform/mix.library/Base/MixQueryEntityApiControllerBase.cs index c549da5f5..8fd6553f7 100644 --- a/src/platform/mix.library/Base/MixQueryEntityApiControllerBase.cs +++ b/src/platform/mix.library/Base/MixQueryEntityApiControllerBase.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Models.Common; using Mix.Lib.Services; using System.Linq.Expressions; @@ -28,8 +29,10 @@ public MixQueryEntityApiControllerBase( TranslatorService translator, MixIdentityService mixIdentityService, TDbContext context, - IQueueService queueService, MixCacheDbContext cacheDbContext) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + IQueueService queueService, MixCacheDbContext cacheDbContext, + IMixTenantService mixTenantService) + : base(httpContextAccessor, + configuration, cacheService, translator, mixIdentityService, queueService, mixTenantService) { Context = context; Uow = new(Context); diff --git a/src/platform/mix.library/Base/MixRestApiControllerBase.cs b/src/platform/mix.library/Base/MixRestApiControllerBase.cs index 8e8921bd2..b0df4268b 100644 --- a/src/platform/mix.library/Base/MixRestApiControllerBase.cs +++ b/src/platform/mix.library/Base/MixRestApiControllerBase.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Models.Common; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -27,13 +28,15 @@ public MixRestHandlerApiControllerBase( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { Context = (TDbContext)uow.ActiveDbContext; Uow = uow; Repository = ViewModelBase.GetRepository(Uow, CacheService); - RestApiService = new(httpContextAccessor, mixIdentityService, uow, queueService, CacheService, portalHub); + RestApiService = new(httpContextAccessor, mixIdentityService, uow, queueService, CacheService, portalHub, mixTenantService); RestApiService.Repository = Repository; Repository.CacheService = CacheService; } diff --git a/src/platform/mix.library/Base/MixRestEntityApiControllerBase.cs b/src/platform/mix.library/Base/MixRestEntityApiControllerBase.cs index ecf0ce868..7fa5238c6 100644 --- a/src/platform/mix.library/Base/MixRestEntityApiControllerBase.cs +++ b/src/platform/mix.library/Base/MixRestEntityApiControllerBase.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; namespace Mix.Lib.Base @@ -21,8 +22,10 @@ public MixRestEntityApiControllerBase( MixIdentityService mixIdentityService, MixCacheDbContext cacheDbContext, TDbContext context, - IQueueService queueService) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, context, queueService, cacheDbContext) + IQueueService queueService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, context, queueService, cacheDbContext, mixTenantService) { } diff --git a/src/platform/mix.library/Base/MixRestfulApiControllerBase.cs b/src/platform/mix.library/Base/MixRestfulApiControllerBase.cs index ecc627ee1..68aa77387 100644 --- a/src/platform/mix.library/Base/MixRestfulApiControllerBase.cs +++ b/src/platform/mix.library/Base/MixRestfulApiControllerBase.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Mix.Lib.Dtos; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -22,8 +23,10 @@ public MixRestfulApiControllerBase( TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } diff --git a/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedQueryApiController.cs b/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedQueryApiController.cs index 2606bc501..15ca3f770 100644 --- a/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedQueryApiController.cs +++ b/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedQueryApiController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -22,8 +23,10 @@ public MixAutoGenerateAuthorizedQueryApiController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } } diff --git a/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedRestApiController.cs b/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedRestApiController.cs index 57001d0b5..b7416dfbd 100644 --- a/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedRestApiController.cs +++ b/src/platform/mix.library/Controllers/MixAutoGenerateAuthorizedRestApiController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -24,8 +25,10 @@ public MixAutoGenerateAuthorizedRestApiController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } } diff --git a/src/platform/mix.library/Controllers/MixAutoGenerateQueryApiController.cs b/src/platform/mix.library/Controllers/MixAutoGenerateQueryApiController.cs index 38f5aa5af..e6923ffc5 100644 --- a/src/platform/mix.library/Controllers/MixAutoGenerateQueryApiController.cs +++ b/src/platform/mix.library/Controllers/MixAutoGenerateQueryApiController.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -21,8 +22,10 @@ public MixAutoGenerateQueryApiController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } } diff --git a/src/platform/mix.library/Controllers/MixAutoGenerateRestApiController.cs b/src/platform/mix.library/Controllers/MixAutoGenerateRestApiController.cs index b71bcb772..96f96ef3c 100644 --- a/src/platform/mix.library/Controllers/MixAutoGenerateRestApiController.cs +++ b/src/platform/mix.library/Controllers/MixAutoGenerateRestApiController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.SignalR.Interfaces; @@ -16,7 +17,10 @@ public class MixAutoGenerateRestApiController { public MixAutoGenerateRestApiController(IHttpContextAccessor httpContextAccessor, IConfiguration configuration, MixCacheService cacheService, TranslatorService translator, MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { } } diff --git a/src/platform/mix.library/Services/MixCmsService.cs b/src/platform/mix.library/Services/MixCmsService.cs index 03eb38525..e042741e1 100644 --- a/src/platform/mix.library/Services/MixCmsService.cs +++ b/src/platform/mix.library/Services/MixCmsService.cs @@ -19,8 +19,9 @@ public MixCmsService( MixConfigurationService configService, MixCacheService cacheService, UnitOfWorkInfo mixdbUow, - UnitOfWorkInfo cmsUow) - : base(httpContextAccessor, cacheService) + UnitOfWorkInfo cmsUow, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _configService = configService; _mixdbUow = mixdbUow; diff --git a/src/platform/mix.library/Services/MixConfigurationService.cs b/src/platform/mix.library/Services/MixConfigurationService.cs index 18a1ce6d1..f850a6492 100644 --- a/src/platform/mix.library/Services/MixConfigurationService.cs +++ b/src/platform/mix.library/Services/MixConfigurationService.cs @@ -11,8 +11,11 @@ public sealed class MixConfigurationService : TenantServiceBase, IMixConfigurati public List Configs { get; set; } - public MixConfigurationService(IHttpContextAccessor httpContextAccessor, DatabaseService databaseService, MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + public MixConfigurationService( + IHttpContextAccessor httpContextAccessor, + DatabaseService databaseService, MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _databaseService = databaseService; } diff --git a/src/platform/mix.library/Services/MixEdmService.cs b/src/platform/mix.library/Services/MixEdmService.cs index 16f785533..1a520e6f7 100644 --- a/src/platform/mix.library/Services/MixEdmService.cs +++ b/src/platform/mix.library/Services/MixEdmService.cs @@ -13,7 +13,8 @@ public MixEdmService( IHttpContextAccessor httpContextAccessor, UnitOfWorkInfo uow, IQueueService queueService, - MixCacheService cacheService) : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) : base(httpContextAccessor, cacheService, mixTenantService) { _uow = uow; _queueService = queueService; diff --git a/src/platform/mix.library/Services/MixTenantService.cs b/src/platform/mix.library/Services/MixTenantService.cs index 8863d2cc2..f28e46eed 100644 --- a/src/platform/mix.library/Services/MixTenantService.cs +++ b/src/platform/mix.library/Services/MixTenantService.cs @@ -53,5 +53,14 @@ public MixTenantSystemModel GetTenant(string host) { return AllTenants.FirstOrDefault(m => m.Domains.Any(d => d.Host == host)) ?? AllTenants.First(); } + + public async Task GetDefaultTenant() + { + if (AllTenants == null) + { + await Reload(); + } + return AllTenants.FirstOrDefault(); + } } } diff --git a/src/platform/mix.library/Services/RestApiService.cs b/src/platform/mix.library/Services/RestApiService.cs index 10758e567..ee7256913 100644 --- a/src/platform/mix.library/Services/RestApiService.cs +++ b/src/platform/mix.library/Services/RestApiService.cs @@ -30,8 +30,9 @@ public RestApiService( UnitOfWorkInfo uow, IQueueService queueService, MixCacheService cacheService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, cacheService) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { MixIdentityService = identityService; Uow = uow; diff --git a/src/platform/mix.library/Startup/Swagger.cs b/src/platform/mix.library/Startup/Swagger.cs index 7481bc210..2e56b63f3 100644 --- a/src/platform/mix.library/Startup/Swagger.cs +++ b/src/platform/mix.library/Startup/Swagger.cs @@ -80,10 +80,6 @@ public static IApplicationBuilder UseMixSwaggerApps(this IApplicationBuilder app //c.IncludeXmlComments(xmlFilename); }); //} - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); return app; } diff --git a/src/platform/mix.queue/Models/MessageQueueModel.cs b/src/platform/mix.queue/Models/MessageQueueModel.cs index 5ef04eac1..d7a2d7c38 100644 --- a/src/platform/mix.queue/Models/MessageQueueModel.cs +++ b/src/platform/mix.queue/Models/MessageQueueModel.cs @@ -18,6 +18,10 @@ public class MessageQueueModel public int TenantId { get; set; } public List Subscriptions { get; set; } = new(); + public MessageQueueModel() + { + TenantId = 1; + } public MessageQueueModel(int tenantId) { TenantId = tenantId; diff --git a/src/platform/mix.repodb/Services/MixDbDataService.cs b/src/platform/mix.repodb/Services/MixDbDataService.cs index cc932751d..19286b0c1 100644 --- a/src/platform/mix.repodb/Services/MixDbDataService.cs +++ b/src/platform/mix.repodb/Services/MixDbDataService.cs @@ -24,6 +24,7 @@ using Mix.Shared.Services; using Mix.Database.Entities.MixDb; using Newtonsoft.Json; +using Mix.Lib.Interfaces; namespace Mix.RepoDb.Services { @@ -56,8 +57,9 @@ public MixDbDataService( MixRepoDbRepository repository, ICache cache, IMixMemoryCacheService memoryCache, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _cmsUow = uow; _repository = repository; @@ -413,9 +415,9 @@ private async Task ParseDto(string tableName, JObject dto) } else { - if (col != null && - (col.DataType == MixDataType.Json - || col.DataType == MixDataType.Array + if (col != null && + (col.DataType == MixDataType.Json + || col.DataType == MixDataType.Array || col.DataType == MixDataType.ArrayMedia || col.DataType == MixDataType.ArrayRadio)) { diff --git a/src/platform/mix.repodb/Services/MixDbService.cs b/src/platform/mix.repodb/Services/MixDbService.cs index 43eb207dd..df176a40d 100644 --- a/src/platform/mix.repodb/Services/MixDbService.cs +++ b/src/platform/mix.repodb/Services/MixDbService.cs @@ -17,6 +17,7 @@ using Mix.Heart.Models; using Mix.Heart.Services; using Mix.Heart.UnitOfWork; +using Mix.Lib.Interfaces; using Mix.RepoDb.Entities; using Mix.RepoDb.Interfaces; using Mix.RepoDb.Repositories; @@ -80,8 +81,9 @@ public MixDbService( MixRepoDbRepository repository, ICache cache, IMixMemoryCacheService memoryCache, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _cmsUow = uow; _databaseService = databaseService; @@ -624,7 +626,14 @@ private string GetInsertQuery(ExpandoObject obj, List selectMembers) var val = obj.First(m => m.Key == col).Value; if (val != null) { - values.Add($"'{val}'"); + if (val is string) + { + values.Add($"'{val.ToString()!.Replace("'", "\\'")}'"); + } + else + { + values.Add($"'{val}'"); + } continue; } } diff --git a/src/platform/mix.service/Interfaces/IMixTenantService.cs b/src/platform/mix.service/Interfaces/IMixTenantService.cs index dead923e9..d43c2a44e 100644 --- a/src/platform/mix.service/Interfaces/IMixTenantService.cs +++ b/src/platform/mix.service/Interfaces/IMixTenantService.cs @@ -12,5 +12,6 @@ public interface IMixTenantService public Task Reload(CancellationToken cancellationToken = default); public MixTenantSystemModel GetTenant(string host); + public Task GetDefaultTenant(); } } diff --git a/src/platform/mix.service/Services/PortalHubClientService.cs b/src/platform/mix.service/Services/PortalHubClientService.cs index 9e38389b3..1228086be 100644 --- a/src/platform/mix.service/Services/PortalHubClientService.cs +++ b/src/platform/mix.service/Services/PortalHubClientService.cs @@ -63,7 +63,7 @@ private async Task HandleQueueMessage(SignalRMessageModel message) await cacheService.RemoveCachesAsync(modifiedEntities); if (modifiedEntities.Any(m => DomainTypes.Contains(m.EntityType))) { - Thread.Sleep(1000); + Thread.Sleep(10000); await _mixTenantService.Reload(); } } diff --git a/src/platform/mix.service/Services/TenantServiceBase.cs b/src/platform/mix.service/Services/TenantServiceBase.cs index 07209fe91..4fdc22ee9 100644 --- a/src/platform/mix.service/Services/TenantServiceBase.cs +++ b/src/platform/mix.service/Services/TenantServiceBase.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Http; using Mix.Constant.Constants; using Mix.Heart.Services; +using Mix.Lib.Interfaces; using Mix.Service.Models; using Mix.Shared.Extensions; namespace Mix.Service.Services @@ -8,16 +9,26 @@ namespace Mix.Service.Services public abstract class TenantServiceBase { protected IHttpContextAccessor HttpContextAccessor; + protected IMixTenantService MixTenantService; protected readonly MixCacheService CacheService; - protected TenantServiceBase(IHttpContextAccessor httpContextAccessor, MixCacheService cacheService) + private readonly MixDitributedCache _cache; + + protected TenantServiceBase(MixDitributedCache cache) + { + _cache = cache; + CacheService = new MixCacheService(cache); + } + + protected TenantServiceBase(IHttpContextAccessor httpContextAccessor, MixCacheService cacheService, IMixTenantService mixTenantService) { HttpContextAccessor = httpContextAccessor; CacheService = cacheService; + MixTenantService = mixTenantService; } protected MixTenantSystemModel? _currentTenant; - protected MixTenantSystemModel? CurrentTenant + protected MixTenantSystemModel CurrentTenant { get { @@ -31,13 +42,8 @@ protected MixTenantSystemModel? CurrentTenant { _currentTenant = httpContext.Session.Get(MixRequestQueryKeywords.Tenant); } - if (_currentTenant == null) - { - _currentTenant = new() - { - Id = 1 - }; - } + _currentTenant ??= MixTenantService.GetDefaultTenant().GetAwaiter().GetResult(); + return _currentTenant; } } @@ -54,6 +60,10 @@ public void SetTenantId(int tenantId) Id = tenantId }; } - + protected bool IsValidCulture(string culture) + { + return CurrentTenant != null && !string.IsNullOrEmpty(culture) + && CurrentTenant.Cultures.Any(m => m.Specificulture == culture); + } } } diff --git a/src/services/ecommerces/mix.services.ecommerce.lib/Services/EcommerceService.cs b/src/services/ecommerces/mix.services.ecommerce.lib/Services/EcommerceService.cs index 071b5fe09..0d2c480e8 100644 --- a/src/services/ecommerces/mix.services.ecommerce.lib/Services/EcommerceService.cs +++ b/src/services/ecommerces/mix.services.ecommerce.lib/Services/EcommerceService.cs @@ -41,7 +41,8 @@ public EcommerceService( IServiceProvider serviceProvider, IMixEdmService edmService, MixCacheService cacheService, - MixConfigurationService configService) : base(httpContextAccessor, cacheService) + MixConfigurationService configService, + IMixTenantService mixTenantService) : base(httpContextAccessor, cacheService, mixTenantService) { EcommerceUow = ecommerceUow; _userManager = userManager; diff --git a/src/services/ecommerces/mix.services.ecommerce.lib/Services/OnepayService.cs b/src/services/ecommerces/mix.services.ecommerce.lib/Services/OnepayService.cs index 8f658a482..dcbf1611b 100644 --- a/src/services/ecommerces/mix.services.ecommerce.lib/Services/OnepayService.cs +++ b/src/services/ecommerces/mix.services.ecommerce.lib/Services/OnepayService.cs @@ -6,6 +6,7 @@ using Mix.Heart.Helpers; using Mix.Heart.Services; using Mix.Heart.UnitOfWork; +using Mix.Lib.Interfaces; using Mix.Service.Services; using Mix.Services.Ecommerce.Lib.Entities.Onepay; using Mix.Services.Ecommerce.Lib.Enums; @@ -30,8 +31,9 @@ public OnepayService( HttpService httpService, IConfiguration configuration, UnitOfWorkInfo cmsUow, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _httpService = httpService; _cmsUow = cmsUow; diff --git a/src/services/ecommerces/mix.services.ecommerce.lib/Services/OrderService.cs b/src/services/ecommerces/mix.services.ecommerce.lib/Services/OrderService.cs index c360e1e84..ccbfaeeb6 100644 --- a/src/services/ecommerces/mix.services.ecommerce.lib/Services/OrderService.cs +++ b/src/services/ecommerces/mix.services.ecommerce.lib/Services/OrderService.cs @@ -14,6 +14,7 @@ using Mix.Service.Services; using Mix.Services.Ecommerce.Lib.Interfaces; using Mix.Heart.Services; +using Mix.Lib.Interfaces; namespace Mix.Services.Ecommerce.Lib.Services { @@ -28,7 +29,8 @@ public OrderService( UnitOfWorkInfo uow, TenantUserManager userManager, MixCacheService cacheService, - MixConfigurationService configService) : base(httpContextAccessor, cacheService) + MixConfigurationService configService, + IMixTenantService mixTenantService) : base(httpContextAccessor, cacheService, mixTenantService) { _uow = uow; _userManager = userManager; diff --git a/src/services/ecommerces/mix.services.ecommerce.lib/Services/PaypalService.cs b/src/services/ecommerces/mix.services.ecommerce.lib/Services/PaypalService.cs index b1f5affdd..ef66bcbc3 100644 --- a/src/services/ecommerces/mix.services.ecommerce.lib/Services/PaypalService.cs +++ b/src/services/ecommerces/mix.services.ecommerce.lib/Services/PaypalService.cs @@ -22,6 +22,7 @@ using DocumentFormat.OpenXml.Office2010.Excel; using System.Text.RegularExpressions; using Quartz.Util; +using Mix.Lib.Interfaces; namespace Mix.Services.Ecommerce.Lib.Services { @@ -37,8 +38,9 @@ public PaypalService( IHttpContextAccessor httpContextAccessor, IConfiguration configuration, UnitOfWorkInfo cmsUow, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { var session = configuration.GetSection(MixAppSettingsSection.Payments).GetSection("Paypal"); session.Bind(_settings); diff --git a/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiEcommerceController.cs b/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiEcommerceController.cs index cca58706c..6230b38c4 100644 --- a/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiEcommerceController.cs +++ b/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiEcommerceController.cs @@ -5,6 +5,7 @@ using Mix.Heart.UnitOfWork; using Mix.Lib.Attributes; using Mix.Lib.Base; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.Queue.Interfaces; using Mix.Queue.Models; @@ -42,8 +43,10 @@ public ApiEcommerceController( IEcommerceService ecommerceService, UnitOfWorkInfo cmsUow, IOrderService orderService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, queueService) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, queueService, mixTenantService) { _ecommerceService = ecommerceService; CmsUow = cmsUow; diff --git a/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiOrderDetailController.cs b/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiOrderDetailController.cs index 9d662c13e..1189373ab 100644 --- a/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiOrderDetailController.cs +++ b/src/services/ecommerces/mix.services.ecommerce/Controllers/ApiOrderDetailController.cs @@ -3,6 +3,7 @@ using Mix.Heart.UnitOfWork; using Mix.Lib.Attributes; using Mix.Lib.Base; +using Mix.Lib.Interfaces; using Mix.Lib.Services; using Mix.Queue.Interfaces; using Mix.Queue.Models; @@ -30,8 +31,10 @@ public OrderDetailController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { Repository.IsCache = false; _ecommerceService = ecommerceService; diff --git a/src/services/mix-databases/mix.services.databases.lib/Abstracts/MixPostService.cs b/src/services/mix-databases/mix.services.databases.lib/Abstracts/MixPostService.cs index 4ac3542fe..714c1775a 100644 --- a/src/services/mix-databases/mix.services.databases.lib/Abstracts/MixPostService.cs +++ b/src/services/mix-databases/mix.services.databases.lib/Abstracts/MixPostService.cs @@ -9,6 +9,7 @@ using Mix.Heart.Services; using Mix.Heart.UnitOfWork; using Mix.Heart.ViewModel; +using Mix.Lib.Interfaces; using Mix.Lib.Models.Common; using Mix.Service.Services; using Mix.Services.Databases.Lib.Interfaces; @@ -28,8 +29,9 @@ protected MixPostServiceBase( UnitOfWorkInfo uow, IMixMetadataService metadataService, IHttpContextAccessor httpContextAccessor, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { Uow = uow; MetadataService = metadataService; diff --git a/src/services/mix-databases/mix.services.databases.lib/Services/MixMetadataService.cs b/src/services/mix-databases/mix.services.databases.lib/Services/MixMetadataService.cs index 0b12dfaa8..14e21c250 100644 --- a/src/services/mix-databases/mix.services.databases.lib/Services/MixMetadataService.cs +++ b/src/services/mix-databases/mix.services.databases.lib/Services/MixMetadataService.cs @@ -30,8 +30,9 @@ public MixMetadataService( UnitOfWorkInfo uow, MixIdentityService identityService, UnitOfWorkInfo cmsUow, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _uow = uow; _identityService = identityService; diff --git a/src/services/mix-databases/mix.services.databases.lib/Services/MixUserDataService.cs b/src/services/mix-databases/mix.services.databases.lib/Services/MixUserDataService.cs index 9d01d7770..07c0fdfbf 100644 --- a/src/services/mix-databases/mix.services.databases.lib/Services/MixUserDataService.cs +++ b/src/services/mix-databases/mix.services.databases.lib/Services/MixUserDataService.cs @@ -11,6 +11,7 @@ using Mix.Services.Databases.Lib.Dtos; using Mix.Services.Databases.Lib.Interfaces; using Mix.Heart.Services; +using Mix.Lib.Interfaces; namespace Mix.Services.Databases.Lib.Services { @@ -23,8 +24,9 @@ public MixUserDataService( IHttpContextAccessor httpContextAccessor, UnitOfWorkInfo uow, TenantUserManager userManager, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _uow = uow; _userManager = userManager; diff --git a/src/services/mix-databases/mix.services.databases.lib/Services/MixUserPermissionService.cs b/src/services/mix-databases/mix.services.databases.lib/Services/MixUserPermissionService.cs index efd0fb45e..8981f03ed 100644 --- a/src/services/mix-databases/mix.services.databases.lib/Services/MixUserPermissionService.cs +++ b/src/services/mix-databases/mix.services.databases.lib/Services/MixUserPermissionService.cs @@ -10,6 +10,7 @@ using Mix.Service.Services; using Mix.Services.Databases.Lib.Interfaces; using Mix.Heart.Services; +using Mix.Lib.Interfaces; namespace Mix.Services.Databases.Lib.Services { @@ -23,8 +24,9 @@ public MixUserPermissionService( IHttpContextAccessor httpContextAccessor, UnitOfWorkInfo uow, MixIdentityService identityService, - MixCacheService cacheService) - : base(httpContextAccessor, cacheService) + MixCacheService cacheService, + IMixTenantService mixTenantService) + : base(httpContextAccessor, cacheService, mixTenantService) { _uow = uow; _permissionDbContext = _uow.DbContext; diff --git a/src/services/mix-databases/mix.servives.databases/Controllers/MixMetadataController.cs b/src/services/mix-databases/mix.servives.databases/Controllers/MixMetadataController.cs index f1e1be0a5..79f49ce7e 100644 --- a/src/services/mix-databases/mix.servives.databases/Controllers/MixMetadataController.cs +++ b/src/services/mix-databases/mix.servives.databases/Controllers/MixMetadataController.cs @@ -15,6 +15,7 @@ using Mix.Database.Entities.Cms; using Mix.Database.Entities.MixDb; using Mix.SignalR.Interfaces; +using Mix.Lib.Interfaces; namespace Mix.Services.Databases.Controllers { @@ -32,8 +33,10 @@ public MixMetadataController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _metadataService = metadataService; Repository.IsCache = false; diff --git a/src/services/mix-databases/mix.servives.databases/Controllers/MixPermissionController.cs b/src/services/mix-databases/mix.servives.databases/Controllers/MixPermissionController.cs index 92664f86d..a5dcf62f1 100644 --- a/src/services/mix-databases/mix.servives.databases/Controllers/MixPermissionController.cs +++ b/src/services/mix-databases/mix.servives.databases/Controllers/MixPermissionController.cs @@ -14,6 +14,7 @@ using Mix.Database.Entities.Cms; using Mix.Database.Entities.MixDb; using Mix.SignalR.Interfaces; +using Mix.Lib.Interfaces; namespace Mix.Services.Databases.Controllers { @@ -23,7 +24,7 @@ public sealed class MixPermissionController : { private readonly IMixPermissionService _permissionService; public MixPermissionController( - IMixPermissionService permissionService, + IMixPermissionService permissionService, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, MixCacheService cacheService, @@ -31,8 +32,10 @@ public MixPermissionController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _permissionService = permissionService; Repository.IsCache = false; diff --git a/src/services/mix-databases/mix.servives.databases/Controllers/MixUserDataController.cs b/src/services/mix-databases/mix.servives.databases/Controllers/MixUserDataController.cs index eb3dba987..b92a34328 100644 --- a/src/services/mix-databases/mix.servives.databases/Controllers/MixUserDataController.cs +++ b/src/services/mix-databases/mix.servives.databases/Controllers/MixUserDataController.cs @@ -13,6 +13,7 @@ using Mix.Database.Entities.Cms; using Mix.Database.Entities.MixDb; using Mix.SignalR.Interfaces; +using Mix.Lib.Interfaces; namespace Mix.Services.Databases.Controllers { @@ -32,8 +33,10 @@ public MixUserDataController( MixIdentityService mixIdentityService, UnitOfWorkInfo uow, IQueueService queueService, - IPortalHubClientService portalHub) - : base(httpContextAccessor, configuration, cacheService, translator, mixIdentityService, uow, queueService, portalHub) + IPortalHubClientService portalHub, + IMixTenantService mixTenantService) + : base(httpContextAccessor, configuration, + cacheService, translator, mixIdentityService, uow, queueService, portalHub, mixTenantService) { _userDataService = metadataService; _userManager = userManager;