diff --git a/src/Mix.Cms.Lib/Models/Common/SearchQueryModel.cs b/src/Mix.Cms.Lib/Models/Common/SearchQueryModel.cs index 02c03e334..0a62fdb9a 100644 --- a/src/Mix.Cms.Lib/Models/Common/SearchQueryModel.cs +++ b/src/Mix.Cms.Lib/Models/Common/SearchQueryModel.cs @@ -27,7 +27,7 @@ public SearchQueryModel(HttpRequest request, string culture = null) ToDate = DateTime.TryParse(request.Query[MixRequestQueryKeywords.ToDate], out DateTime toDate) ? toDate: null; Status = Enum.TryParse(request.Query[MixRequestQueryKeywords.Status], out MixContentStatus status) - ? status : null; + ? status : MixContentStatus.Published; Keyword = request.Query.TryGetValue(MixRequestQueryKeywords.Keyword, out var orderBy) ? orderBy : string.Empty; PagingData = new PagingRequest(request); diff --git a/src/Mix.Cms.Lib/ViewModels/MixDatabaseDataValues/UpdateViewModel.cs b/src/Mix.Cms.Lib/ViewModels/MixDatabaseDataValues/UpdateViewModel.cs index 600291d1a..6f4691af3 100644 --- a/src/Mix.Cms.Lib/ViewModels/MixDatabaseDataValues/UpdateViewModel.cs +++ b/src/Mix.Cms.Lib/ViewModels/MixDatabaseDataValues/UpdateViewModel.cs @@ -231,7 +231,7 @@ public override void Validate(MixCmsContext _context, IDbContextTransaction _tra if (exist) { IsValid = false; - Errors.Add($"{DataId}: {Column.Title} = {StringValue} is existed"); + Errors.Add($"{StringValue} is existed"); } } if (Column.IsRequire) diff --git a/src/Mix.Cms.Lib/ViewModels/MixPosts/DeleteViewModel.cs b/src/Mix.Cms.Lib/ViewModels/MixPosts/DeleteViewModel.cs index 3e8b7e297..46b1fb7d2 100644 --- a/src/Mix.Cms.Lib/ViewModels/MixPosts/DeleteViewModel.cs +++ b/src/Mix.Cms.Lib/ViewModels/MixPosts/DeleteViewModel.cs @@ -91,7 +91,7 @@ public override async Task> RemoveRelatedModelsAsync(De var navMedia = await _context.MixPostMedia.Where(n => n.PostId == Id && n.Specificulture == Specificulture).ToListAsync(); foreach (var item in navMedia) { - _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; + _context.Entry(item).State = EntityState.Deleted; } } if (result.IsSucceed) @@ -99,7 +99,7 @@ public override async Task> RemoveRelatedModelsAsync(De var navModule = await _context.MixPostModule.Where(n => n.PostId == Id && n.Specificulture == Specificulture).ToListAsync(); foreach (var item in navModule) { - _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; + _context.Entry(item).State = EntityState.Deleted; } } @@ -108,7 +108,7 @@ public override async Task> RemoveRelatedModelsAsync(De var navRelated = await _context.MixPostMedia.Where(n => n.PostId == Id && n.Specificulture == Specificulture).ToListAsync(); foreach (var item in navRelated) { - _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; + _context.Entry(item).State = EntityState.Deleted; } } @@ -117,16 +117,16 @@ public override async Task> RemoveRelatedModelsAsync(De var navs = await _context.MixUrlAlias.Where(n => n.SourceId == Id.ToString() && n.Type == (int)MixUrlAliasType.Post && n.Specificulture == Specificulture).ToListAsync(); foreach (var item in navs) { - _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; + _context.Entry(item).State = EntityState.Deleted; } } if (result.IsSucceed) { - var navs = await _context.MixRelatedPost.Where(n => (n.Id == Id || n.DestinationId == Id) && n.Specificulture == Specificulture).ToListAsync(); + var navs = await _context.MixRelatedPost.Where(n => (n.SourceId == Id || n.DestinationId == Id) && n.Specificulture == Specificulture).ToListAsync(); foreach (var item in navs) { - _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; + _context.Entry(item).State = EntityState.Deleted; } } @@ -135,7 +135,7 @@ public override async Task> RemoveRelatedModelsAsync(De var navs = await _context.MixDatabaseDataAssociation.Where(n => n.ParentId == Id.ToString() && n.ParentType == MixDatabaseParentType.Post && n.Specificulture == Specificulture).ToListAsync(); foreach (var item in navs) { - _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; + _context.Entry(item).State = EntityState.Deleted; } } diff --git a/src/Mix.Cms.Web/wwwroot/mix-app/js/app-portal.min.js b/src/Mix.Cms.Web/wwwroot/mix-app/js/app-portal.min.js index 84ed8ac68..a9fcdd630 100644 --- a/src/Mix.Cms.Web/wwwroot/mix-app/js/app-portal.min.js +++ b/src/Mix.Cms.Web/wwwroot/mix-app/js/app-portal.min.js @@ -1,4 +1,4 @@ -/* Fri Oct 08 2021 03:20:54 GMT+0700 (Indochina Time) */"use strict"; +/* Mon Oct 11 2021 22:47:33 GMT+0700 (Indochina Time) */"use strict"; var app = angular.module("MixPortal", [ "angularCroppie", "ui.bootstrap", @@ -451,207 +451,6 @@ app.factory("ConfigurationService", [ }, ]); -"use strict"; -app.controller("CustomerController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$timeout", - "$location", - "CustomerServices", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $timeout, - $location, - customerServices - ) { - $scope.request = angular.copy(ngAppSettings.request); - $scope.request.contentStatuses = ["Active"]; - $scope.request.status = "0"; - $scope.activedCustomer = null; - $scope.relatedCustomers = []; - $rootScope.isBusy = false; - $scope.data = { - pageIndex: 0, - pageSize: 1, - totalItems: 0, - }; - $scope.errors = []; - - $scope.range = function (max) { - var input = []; - for (var i = 1; i <= max; i += 1) input.push(i); - return input; - }; - - $scope.loadCustomer = async function () { - $rootScope.isBusy = true; - var id = $routeParams.id; - var response = await customerServices.getCustomer(id, "portal"); - if (response.isSucceed) { - $scope.activedCustomer = response.data; - $rootScope.initEditor(); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.loadCustomers = async function (pageIndex) { - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } - if ($scope.request.fromDate !== null) { - var d = new Date($scope.request.fromDate); - $scope.request.fromDate = d.toISOString(); - } - if ($scope.request.toDate !== null) { - var d = new Date($scope.request.toDate); - $scope.request.toDate = d.toISOString(); - } - var resp = await customerServices.getCustomers($scope.request); - if (resp && resp.isSucceed) { - $scope.data = resp.data; - //$("html, body").animate({ "scrollTop": "0px" }, 500); - $.each($scope.data.items, function (i, customer) { - $.each($scope.activedCustomers, function (i, e) { - if (e.customerId === customer.id) { - customer.isHidden = true; - } - }); - }); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $scope.$apply(); - } - }; - - $scope.removeCustomer = function (id) { - $rootScope.showConfirm( - $scope, - "removeCustomerConfirmed", - [id], - null, - "Remove Customer", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeCustomerConfirmed = async function (id) { - var result = await customerServices.removeCustomer(id); - if (result.isSucceed) { - $rootScope.showMessage("success", "success"); - $scope.loadCustomers(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.saveCustomer = async function (customer) { - customer.content = $(".editor-content").val(); - var resp = await customerServices.saveCustomer(customer); - if (resp && resp.isSucceed) { - $scope.activedCustomer = resp.data; - $rootScope.showMessage("Update successfully!", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - //$location.path('/portal/customer/details/' + resp.data.id); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.factory("CustomerServices", [ - "$http", - "$rootScope", - "ApiService", - "CommonService", - function ($http, $rootScope, apiService, commonService) { - //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; - - var customersServiceFactory = {}; - - var settings = $rootScope.globalSettings; - - var _getCustomer = async function (id, type) { - var apiUrl = "/queen-beauty/customer/"; - var url = apiUrl + "details/" + type; - if (id) { - url += "/" + id; - } - var req = { - method: "GET", - url: url, - }; - return await apiService.getApiResult(req); - }; - - var _initCustomer = async function (type) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "GET", - url: apiUrl + "init/" + type, - }; - return await apiService.getApiResult(req); - }; - - var _getCustomers = async function (request) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "POST", - url: apiUrl + "list", - data: JSON.stringify(request), - }; - - return await apiService.getApiResult(req); - }; - - var _removeCustomer = async function (id) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "GET", - url: apiUrl + "delete/" + id, - }; - return await apiService.getApiResult(req); - }; - - var _saveCustomer = async function (customer) { - var apiUrl = "/queen-beauty/customer/"; - var req = { - method: "POST", - url: apiUrl + "save", - data: JSON.stringify(customer), - }; - return await apiService.getApiResult(req); - }; - - customersServiceFactory.getCustomer = _getCustomer; - customersServiceFactory.initCustomer = _initCustomer; - customersServiceFactory.getCustomers = _getCustomers; - customersServiceFactory.removeCustomer = _removeCustomer; - customersServiceFactory.saveCustomer = _saveCustomer; - return customersServiceFactory; - }, -]); - "use strict"; app.controller("CultureController", [ "$scope", @@ -1227,58 +1026,259 @@ app.factory("CultureService", [ ]); "use strict"; -app.controller("DashboardController", [ +app.controller("CustomerController", [ "$scope", "$rootScope", "ngAppSettings", + "$routeParams", "$timeout", "$location", - "DashboardServices", + "CustomerServices", function ( $scope, $rootScope, ngAppSettings, + $routeParams, $timeout, $location, - dashboardServices + customerServices ) { - $scope.pageClass = "page-dashboard"; - $(".side-nav li").removeClass("active"); - $(".side-nav .page-dashboard").addClass("active"); + $scope.request = angular.copy(ngAppSettings.request); + $scope.request.contentStatuses = ["Active"]; + $scope.request.status = "0"; + $scope.activedCustomer = null; + $scope.relatedCustomers = []; + $rootScope.isBusy = false; $scope.data = { - totalPage: 0, - totalPost: 0, - totalProduct: 0, - totalUser: 0, + pageIndex: 0, + pageSize: 1, + totalItems: 0, }; - $scope.users = []; - $scope.$on("$viewContentLoaded", function () { - $rootScope.isBusy = false; - }); - $scope.getDashboardInfo = async function () { + $scope.errors = []; + + $scope.range = function (max) { + var input = []; + for (var i = 1; i <= max; i += 1) input.push(i); + return input; + }; + + $scope.loadCustomer = async function () { $rootScope.isBusy = true; - var response = await dashboardServices.getDashboardInfo(); + var id = $routeParams.id; + var response = await customerServices.getCustomer(id, "portal"); if (response.isSucceed) { - // $('#mainSection').removeClass('card'); - $scope.data = response.data; + $scope.activedCustomer = response.data; + $rootScope.initEditor(); $rootScope.isBusy = false; $scope.$apply(); - // $scope.getChart(); } else { $rootScope.showErrors(response.errors); $rootScope.isBusy = false; $scope.$apply(); } }; - $scope.getChart = function () { - var ctx = document.getElementById("myChart"); - var myChart = new Chart(ctx, { - // type: 'pie', - // data: { - // labels: ["Africa", "Asia", "Europe", "Latin America", "North America"], - // datasets: [{ - // label: "Population (millions)", - // backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"], + $scope.loadCustomers = async function (pageIndex) { + if (pageIndex !== undefined) { + $scope.request.pageIndex = pageIndex; + } + if ($scope.request.fromDate !== null) { + var d = new Date($scope.request.fromDate); + $scope.request.fromDate = d.toISOString(); + } + if ($scope.request.toDate !== null) { + var d = new Date($scope.request.toDate); + $scope.request.toDate = d.toISOString(); + } + var resp = await customerServices.getCustomers($scope.request); + if (resp && resp.isSucceed) { + $scope.data = resp.data; + //$("html, body").animate({ "scrollTop": "0px" }, 500); + $.each($scope.data.items, function (i, customer) { + $.each($scope.activedCustomers, function (i, e) { + if (e.customerId === customer.id) { + customer.isHidden = true; + } + }); + }); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $scope.$apply(); + } + }; + + $scope.removeCustomer = function (id) { + $rootScope.showConfirm( + $scope, + "removeCustomerConfirmed", + [id], + null, + "Remove Customer", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + + $scope.removeCustomerConfirmed = async function (id) { + var result = await customerServices.removeCustomer(id); + if (result.isSucceed) { + $rootScope.showMessage("success", "success"); + $scope.loadCustomers(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.saveCustomer = async function (customer) { + customer.content = $(".editor-content").val(); + var resp = await customerServices.saveCustomer(customer); + if (resp && resp.isSucceed) { + $scope.activedCustomer = resp.data; + $rootScope.showMessage("Update successfully!", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + //$location.path('/portal/customer/details/' + resp.data.id); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.factory("CustomerServices", [ + "$http", + "$rootScope", + "ApiService", + "CommonService", + function ($http, $rootScope, apiService, commonService) { + //var serviceBase = 'http://ngauthenticationapi.azurewebsites.net/'; + + var customersServiceFactory = {}; + + var settings = $rootScope.globalSettings; + + var _getCustomer = async function (id, type) { + var apiUrl = "/queen-beauty/customer/"; + var url = apiUrl + "details/" + type; + if (id) { + url += "/" + id; + } + var req = { + method: "GET", + url: url, + }; + return await apiService.getApiResult(req); + }; + + var _initCustomer = async function (type) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "GET", + url: apiUrl + "init/" + type, + }; + return await apiService.getApiResult(req); + }; + + var _getCustomers = async function (request) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "POST", + url: apiUrl + "list", + data: JSON.stringify(request), + }; + + return await apiService.getApiResult(req); + }; + + var _removeCustomer = async function (id) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "GET", + url: apiUrl + "delete/" + id, + }; + return await apiService.getApiResult(req); + }; + + var _saveCustomer = async function (customer) { + var apiUrl = "/queen-beauty/customer/"; + var req = { + method: "POST", + url: apiUrl + "save", + data: JSON.stringify(customer), + }; + return await apiService.getApiResult(req); + }; + + customersServiceFactory.getCustomer = _getCustomer; + customersServiceFactory.initCustomer = _initCustomer; + customersServiceFactory.getCustomers = _getCustomers; + customersServiceFactory.removeCustomer = _removeCustomer; + customersServiceFactory.saveCustomer = _saveCustomer; + return customersServiceFactory; + }, +]); + +"use strict"; +app.controller("DashboardController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$timeout", + "$location", + "DashboardServices", + function ( + $scope, + $rootScope, + ngAppSettings, + $timeout, + $location, + dashboardServices + ) { + $scope.pageClass = "page-dashboard"; + $(".side-nav li").removeClass("active"); + $(".side-nav .page-dashboard").addClass("active"); + $scope.data = { + totalPage: 0, + totalPost: 0, + totalProduct: 0, + totalUser: 0, + }; + $scope.users = []; + $scope.$on("$viewContentLoaded", function () { + $rootScope.isBusy = false; + }); + $scope.getDashboardInfo = async function () { + $rootScope.isBusy = true; + var response = await dashboardServices.getDashboardInfo(); + if (response.isSucceed) { + // $('#mainSection').removeClass('card'); + $scope.data = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + // $scope.getChart(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.getChart = function () { + var ctx = document.getElementById("myChart"); + var myChart = new Chart(ctx, { + // type: 'pie', + // data: { + // labels: ["Africa", "Asia", "Europe", "Latin America", "North America"], + // datasets: [{ + // label: "Population (millions)", + // backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"], // data: [2478,5267,734,784,433] // }] // }, @@ -1820,139 +1820,36 @@ app.factory("JsonDataService", [ ]); "use strict"; -app.controller("LocalizeController", [ - "$scope", +app.controller("loginController", [ "$rootScope", + "$scope", "ngAppSettings", - "$routeParams", "$location", - "LocalizeService", - "ApiService", - "CommonService", + "AuthService", + "ngAppSettings", function ( - $scope, $rootScope, + $scope, ngAppSettings, - $routeParams, $location, - service, - commonService + authService, + ngAuthSettings ) { - BaseRestCtrl.call( - this, - $scope, - $rootScope, - $location, - $routeParams, - ngAppSettings, - service - ); + if ( + authService.authentication && + authService.authentication.isAuth && + authService.authentication.isAdmin + ) { + authService.referredUrl = $location.path(); + $location.path("/portal"); + } - $scope.getSingleSuccessCallback = function () { - $scope.cates = ngAppSettings.enums.configuration_cates; - $scope.globalSettings = $rootScope.globalSettings; - $scope.request.category = $routeParams.category || ""; - if (!$scope.viewmodel.id) { - $scope.viewmodel.property.dataType = "Text"; - } - if (!$scope.viewmodel.category) { - $scope.viewmodel.category = "Site"; - } - }; - $scope.saveSuccessCallback = function () { - commonService.initAllSettings().then(function () { - // $location.url($scope.referrerUrl); - $rootScope.isBusy = false; - $scope.$apply(); - }); - }; - $scope.removeCallback = function () { - commonService.initAllSettings().then(function () { - $location.url($scope.referrerUrl); - }); - }; - - $scope.generateName = function () { - $scope.viewmodel.keyword = $rootScope.generateKeyword( - $scope.viewmodel.keyword, - "_", - true - ); - }; - }, -]); - -"use strict"; -app.factory("LocalizeService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("language"); - - var _uploadLanguage = async function (languageFile) { - //var container = $(this).parents('.model-language').first().find('.custom-file').first(); - if (languageFile.file !== undefined && languageFile.file !== null) { - // Create FormData object - var files = new FormData(); - - // Looping over all files and add it to FormData object - files.append(languageFile.file.name, languageFile.file); - - // Adding one more key to FormData object - files.append("fileFolder", languageFile.folder); - files.append("title", languageFile.title); - files.append("description", languageFile.description); - - var req = { - url: this.prefixUrl + "/upload", - type: "POST", - headers: {}, - contentType: false, // Not to set any content header - processData: false, // Not to process data - data: files, - }; - - return await apiService.getApiResult(req); - } - }; - serviceFactory.uploadLanguage = _uploadLanguage; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("loginController", [ - "$rootScope", - "$scope", - "ngAppSettings", - "$location", - "AuthService", - "ngAppSettings", - function ( - $rootScope, - $scope, - ngAppSettings, - $location, - authService, - ngAuthSettings - ) { - if ( - authService.authentication && - authService.authentication.isAuth && - authService.authentication.isAdmin - ) { - authService.referredUrl = $location.path(); - $location.path("/portal"); - } - - $scope.pageClass = "page-login"; - - $scope.loginData = { - username: "", - password: "", - rememberme: true, + $scope.pageClass = "page-login"; + + $scope.loginData = { + username: "", + password: "", + rememberme: true, }; $scope.message = ""; @@ -2035,24 +1932,23 @@ app.controller("loginController", [ ]); "use strict"; -app.controller("MixDatabaseController", [ +app.controller("LocalizeController", [ "$scope", "$rootScope", - "$location", "ngAppSettings", "$routeParams", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", - "RestMixDatabasePortalService", + "$location", + "LocalizeService", + "ApiService", + "CommonService", function ( $scope, $rootScope, - $location, ngAppSettings, $routeParams, - databaseDataService, - databaseColumnService, - databaseService + $location, + service, + commonService ) { BaseRestCtrl.call( this, @@ -2061,43 +1957,80 @@ app.controller("MixDatabaseController", [ $location, $routeParams, ngAppSettings, - databaseService + service ); - $scope.defaultAttr = null; - $scope.actions = ["Delete"]; - // $scope.request.selects = 'id,title,name,createdDateTime'; - $scope.orders = [ - { title: "Id", value: "id" }, - { title: "Name", value: "name" }, - { title: "Created Date", value: "createdDateTime" }, - ]; - $scope.request.orderBy = "createdDateTime"; - $scope.getSingleSuccessCallback = async function () { - var getDefaultAttr = await databaseColumnService.getDefault(); - if (getDefaultAttr.isSucceed) { - $scope.defaultAttr = getDefaultAttr.data; - $scope.defaultAttr.options = []; + + $scope.getSingleSuccessCallback = function () { + $scope.cates = ngAppSettings.enums.configuration_cates; + $scope.globalSettings = $rootScope.globalSettings; + $scope.request.category = $routeParams.category || ""; + if (!$scope.viewmodel.id) { + $scope.viewmodel.property.dataType = "Text"; + } + if (!$scope.viewmodel.category) { + $scope.viewmodel.category = "Site"; } - $scope.$apply(); }; - $scope.migrate = async function () { - if ($scope.viewmodel.id) { - $rootScope.isBusy = true; - var result = await databaseService.migrate($scope.viewmodel); - if (result.isSucceed) { - var migrateData = await databaseDataService.migrate( - $scope.viewmodel.id - ); - $scope.handleResult(migrateData); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(["Cannot migrate database"]); - $rootScope.isBusy = false; - $scope.$apply(); - } + $scope.saveSuccessCallback = function () { + commonService.initAllSettings().then(function () { + // $location.url($scope.referrerUrl); + $rootScope.isBusy = false; + $scope.$apply(); + }); + }; + $scope.removeCallback = function () { + commonService.initAllSettings().then(function () { + $location.url($scope.referrerUrl); + }); + }; + + $scope.generateName = function () { + $scope.viewmodel.keyword = $rootScope.generateKeyword( + $scope.viewmodel.keyword, + "_", + true + ); + }; + }, +]); + +"use strict"; +app.factory("LocalizeService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("language"); + + var _uploadLanguage = async function (languageFile) { + //var container = $(this).parents('.model-language').first().find('.custom-file').first(); + if (languageFile.file !== undefined && languageFile.file !== null) { + // Create FormData object + var files = new FormData(); + + // Looping over all files and add it to FormData object + files.append(languageFile.file.name, languageFile.file); + + // Adding one more key to FormData object + files.append("fileFolder", languageFile.folder); + files.append("title", languageFile.title); + files.append("description", languageFile.description); + + var req = { + url: this.prefixUrl + "/upload", + type: "POST", + headers: {}, + contentType: false, // Not to set any content header + processData: false, // Not to process data + data: files, + }; + + return await apiService.getApiResult(req); } }; + serviceFactory.uploadLanguage = _uploadLanguage; + return serviceFactory; }, ]); @@ -2456,25 +2389,24 @@ app.controller("MixDatabaseDataController", [ ]); "use strict"; -app.controller("ModuleDataController", [ +app.controller("MixDatabaseController", [ "$scope", "$rootScope", + "$location", "ngAppSettings", "$routeParams", - "$location", - "ModuleDataRestService", - "ModuleRestService", - "ApiService", - "CommonService", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + "RestMixDatabasePortalService", function ( $scope, $rootScope, + $location, ngAppSettings, $routeParams, - $location, - service, - moduleService, - commonService + databaseDataService, + databaseColumnService, + databaseService ) { BaseRestCtrl.call( this, @@ -2483,34 +2415,102 @@ app.controller("ModuleDataController", [ $location, $routeParams, ngAppSettings, - service + databaseService ); - // $scope.request.orderBy = "Priority"; - // $scope.request.direction = "Asc"; - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.localizeSettings = $rootScope.globalSettings; - $scope.moduleId = $routeParams.moduleId; - $scope.backUrl = `/portal/module-data/list/${$scope.moduleId}`; - $scope.module = null; - $scope.dataColumns = []; - $scope.editDataUrl = "/portal/module-data/details/" + $scope.moduleId; - $scope.init = async function () { - $scope.id = $routeParams.id; - if (!$scope.module) { - var getModule = await moduleService.getSingle([$scope.moduleId]); - if (getModule.isSucceed) { - $scope.module = getModule.data; - angular.forEach($scope.module.columns, function (e, i) { - if (e.isDisplay) { - $scope.dataColumns.push({ - title: e.title, - name: e.name, - datatype: e.dataType, - filter: true, - type: 0, // string - ngAppSettings.dataTypes[0] - }); - } + $scope.defaultAttr = null; + $scope.actions = ["Delete"]; + // $scope.request.selects = 'id,title,name,createdDateTime'; + $scope.orders = [ + { title: "Id", value: "id" }, + { title: "Name", value: "name" }, + { title: "Created Date", value: "createdDateTime" }, + ]; + $scope.request.orderBy = "createdDateTime"; + $scope.getSingleSuccessCallback = async function () { + var getDefaultAttr = await databaseColumnService.getDefault(); + if (getDefaultAttr.isSucceed) { + $scope.defaultAttr = getDefaultAttr.data; + $scope.defaultAttr.options = []; + } + $scope.$apply(); + }; + $scope.migrate = async function () { + if ($scope.viewmodel.id) { + $rootScope.isBusy = true; + var result = await databaseService.migrate($scope.viewmodel); + if (result.isSucceed) { + var migrateData = await databaseDataService.migrate( + $scope.viewmodel.id + ); + $scope.handleResult(migrateData); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(["Cannot migrate database"]); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + }; + }, +]); + +"use strict"; +app.controller("ModuleDataController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "ModuleDataRestService", + "ModuleRestService", + "ApiService", + "CommonService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + moduleService, + commonService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + // $scope.request.orderBy = "Priority"; + // $scope.request.direction = "Asc"; + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.localizeSettings = $rootScope.globalSettings; + $scope.moduleId = $routeParams.moduleId; + $scope.backUrl = `/portal/module-data/list/${$scope.moduleId}`; + $scope.module = null; + $scope.dataColumns = []; + $scope.editDataUrl = "/portal/module-data/details/" + $scope.moduleId; + $scope.init = async function () { + $scope.id = $routeParams.id; + if (!$scope.module) { + var getModule = await moduleService.getSingle([$scope.moduleId]); + if (getModule.isSucceed) { + $scope.module = getModule.data; + angular.forEach($scope.module.columns, function (e, i) { + if (e.isDisplay) { + $scope.dataColumns.push({ + title: e.title, + name: e.name, + datatype: e.dataType, + filter: true, + type: 0, // string - ngAppSettings.dataTypes[0] + }); + } }); $scope.$apply(); } @@ -2936,13 +2936,13 @@ app.factory("ModuleRestService", [ ]); "use strict"; -app.controller("ModulePostController", [ +app.controller("ModuleGalleryController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "ModulePostRestService", + "ModuleGalleryService", "ApiService", "CommonService", function ( @@ -2952,6 +2952,7 @@ app.controller("ModulePostController", [ $routeParams, $location, service, + apiService, commonService ) { BaseCtrl.call( @@ -2965,18 +2966,11 @@ app.controller("ModulePostController", [ $scope.cates = ["Site", "System"]; $scope.others = []; $scope.localizeSettings = $rootScope.globalSettings; + $scope.moduleId = $routeParams.id; $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; $scope.translate = $rootScope.translate; - $scope.moduleIds = $routeParams.moduleIds || $routeParams.id; - $scope.pageIds = $routeParams.page_ids; - $scope.type = $routeParams.type; - $scope.template = $routeParams.template || ""; - - $scope.init = function () { - $scope.createUrl = `/portal/post/create?page_ids=${$scope.pageIds}&module_ids=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; - $scope.getList(); - }; + $scope.moduleId = $routeParams.id; $scope.getList = async function () { $rootScope.isBusy = true; var id = $routeParams.id; @@ -2996,10 +2990,6 @@ app.controller("ModulePostController", [ $scope.$apply(); } }; - $scope.preview = function (item) { - item.editUrl = "/portal/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); - }; $scope.remove = function (moduleId, postId) { $rootScope.showConfirm( $scope, @@ -3068,7 +3058,7 @@ app.controller("ModulePostController", [ ]); "use strict"; -app.factory("ModulePostRestService", [ +app.factory("ModuleGalleryService", [ "$rootScope", "ApiService", "CommonService", @@ -3099,13 +3089,13 @@ app.factory("ModulePostRestService", [ ]); "use strict"; -app.controller("ModuleGalleryController", [ +app.controller("ModulePostController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "ModuleGalleryService", + "ModulePostRestService", "ApiService", "CommonService", function ( @@ -3115,7 +3105,6 @@ app.controller("ModuleGalleryController", [ $routeParams, $location, service, - apiService, commonService ) { BaseCtrl.call( @@ -3129,11 +3118,18 @@ app.controller("ModuleGalleryController", [ $scope.cates = ["Site", "System"]; $scope.others = []; $scope.localizeSettings = $rootScope.globalSettings; - $scope.moduleId = $routeParams.id; $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; $scope.translate = $rootScope.translate; - $scope.moduleId = $routeParams.id; + $scope.moduleIds = $routeParams.moduleIds || $routeParams.id; + $scope.pageIds = $routeParams.page_ids; + $scope.type = $routeParams.type; + $scope.template = $routeParams.template || ""; + + $scope.init = function () { + $scope.createUrl = `/portal/post/create?page_ids=${$scope.pageIds}&module_ids=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; + $scope.getList(); + }; $scope.getList = async function () { $rootScope.isBusy = true; var id = $routeParams.id; @@ -3153,6 +3149,10 @@ app.controller("ModuleGalleryController", [ $scope.$apply(); } }; + $scope.preview = function (item) { + item.editUrl = "/portal/post/details/" + item.id; + $rootScope.preview("post", item, item.title, "modal-lg"); + }; $scope.remove = function (moduleId, postId) { $rootScope.showConfirm( $scope, @@ -3221,7 +3221,7 @@ app.controller("ModuleGalleryController", [ ]); "use strict"; -app.factory("ModuleGalleryService", [ +app.factory("ModulePostRestService", [ "$rootScope", "ApiService", "CommonService", @@ -3731,13 +3731,13 @@ app.factory("PageRestService", [ ]); "use strict"; -app.controller("PageGalleryController", [ +app.controller("PagePageController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "PageGalleryService", + "PagePostRestService", "PostRestService", "ApiService", "CommonService", @@ -3850,14 +3850,14 @@ app.controller("PageGalleryController", [ ]); "use strict"; -app.factory("PageGalleryService", [ +app.factory("PagePageRestService", [ "$rootScope", "ApiService", "CommonService", "BaseService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("page-post"); + serviceFactory.init("page-page"); var _delete = async function (pageId, postId) { var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; var req = { @@ -3881,13 +3881,13 @@ app.factory("PageGalleryService", [ ]); "use strict"; -app.controller("PagePageController", [ +app.controller("PageGalleryController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "PagePostRestService", + "PageGalleryService", "PostRestService", "ApiService", "CommonService", @@ -4000,14 +4000,14 @@ app.controller("PagePageController", [ ]); "use strict"; -app.factory("PagePageRestService", [ +app.factory("PageGalleryService", [ "$rootScope", "ApiService", "CommonService", "BaseService", function ($rootScope, apiService, commonService, baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("page-page"); + serviceFactory.init("page-post"); var _delete = async function (pageId, postId) { var url = this.prefixUrl + "/delete/" + pageId + "/" + postId; var req = { @@ -4031,13 +4031,13 @@ app.factory("PagePageRestService", [ ]); "use strict"; -app.controller("PagePostController", [ +app.controller("PagePositionController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", - "PagePostRestService", + "PagePositionService", "PostRestService", "ApiService", "CommonService", @@ -4049,6 +4049,7 @@ app.controller("PagePostController", [ $location, service, postService, + apiService, commonService ) { BaseCtrl.call( @@ -4062,32 +4063,17 @@ app.controller("PagePostController", [ $scope.cates = ["Site", "System"]; $scope.others = []; $scope.localizeSettings = $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" - ? "/portal/post/create-gallery" - : `/portal/post/create?page_ids=${$scope.pageIds}&module_ids=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; - $scope.updateUrl = - $routeParams.post_type === "gallery" - ? "/portal/post/gallery-details" - : "/portal/post/details"; - }; + $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.isSucceed) { $scope.data = response.data; $rootScope.isBusy = false; @@ -4112,13 +4098,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.isSucceed) { if ($scope.removeCallback) { $rootScope.executeFunctionByName( @@ -4171,54 +4154,225 @@ app.controller("PagePostController", [ ]); "use strict"; -app.factory("PagePostRestService", [ - "$rootScope", - "ApiService", - "CommonService", - "BaseService", - function($rootScope, apiService, commonService, baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("page-post"); - var _delete = async function(id) { - var url = this.prefixUrl + "/delete/" + id; - var req = { - method: "GET", - url: url, - }; - return await apiService.getApiResult(req); - }; - var _updateInfos = async function(pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), - }; - return await apiService.getApiResult(req); - }; - serviceFactory.delete = _delete; - serviceFactory.updateInfos = _updateInfos; - return serviceFactory; - }, +app.factory("PagePositionService", [ + "$rootScope", + "ApiService", + "CommonService", + "BaseService", + function ($rootScope, apiService, commonService, baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("page-position"); + var _delete = async function (pageId, positionId) { + var url = this.prefixUrl + "/delete/" + pageId + "/" + positionId; + var req = { + method: "GET", + url: url, + }; + return await apiService.getApiResult(req); + }; + var _updateInfos = async function (pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), + }; + return await apiService.getApiResult(req); + }; + serviceFactory.delete = _delete; + serviceFactory.updateInfos = _updateInfos; + return serviceFactory; + }, ]); + "use strict"; -app.controller("PermissionController", [ +app.controller("PagePostController", [ "$scope", "$rootScope", "ngAppSettings", "$routeParams", "$location", + "PagePostRestService", + "PostRestService", "ApiService", "CommonService", - "PermissionService", - "RestPortalPageNavigationService", function ( $scope, $rootScope, ngAppSettings, $routeParams, $location, - apiService, - commonService, + service, + postService, + commonService + ) { + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.localizeSettings = $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" + ? "/portal/post/create-gallery" + : `/portal/post/create?page_ids=${$scope.pageIds}&module_ids=${$scope.moduleIds}&type=${$scope.type}&template=${$scope.template}`; + $scope.updateUrl = + $routeParams.post_type === "gallery" + ? "/portal/post/gallery-details" + : "/portal/post/details"; + }; + $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"; + if (response.isSucceed) { + $scope.data = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.preview = function (item) { + item.editUrl = "/portal/post/details/" + item.id; + $rootScope.preview("post", item, item.title, "modal-lg"); + }; + $scope.remove = function (pageId, postId) { + $rootScope.showConfirm( + $scope, + "removeConfirmed", + [pageId, postId], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + $scope.back = function () { + window.history.back(); + }; + + $scope.removeConfirmed = async function (id) { + $rootScope.isBusy = true; + var result = await service.delete(id); + if (result.isSucceed) { + if ($scope.removeCallback) { + $rootScope.executeFunctionByName( + "removeCallback", + $scope.removeCallbackArgs, + $scope + ); + } + $scope.getList(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.saveOthers = async function () { + var response = await service.saveList($scope.others); + if (response.isSucceed) { + $scope.getList(); + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.updateInfos = async function (index) { + $scope.data.items.splice(index, 1); + $rootScope.isBusy = true; + var startIndex = $scope.data.items[0].priority - 1; + for (var i = 0; i < $scope.data.items.length; i++) { + $scope.data.items[i].priority = startIndex + i + 1; + } + var resp = await service.updateInfos($scope.data.items); + if (resp && resp.isSucceed) { + $scope.activedPage = resp.data; + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.factory("PagePostRestService", [ + "$rootScope", + "ApiService", + "CommonService", + "BaseService", + function($rootScope, apiService, commonService, baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("page-post"); + var _delete = async function(id) { + var url = this.prefixUrl + "/delete/" + id; + var req = { + method: "GET", + url: url, + }; + return await apiService.getApiResult(req); + }; + var _updateInfos = async function(pages) { + var req = { + method: "POST", + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), + }; + return await apiService.getApiResult(req); + }; + serviceFactory.delete = _delete; + serviceFactory.updateInfos = _updateInfos; + return serviceFactory; + }, +]); +"use strict"; +app.controller("PermissionController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "ApiService", + "CommonService", + "PermissionService", + "RestPortalPageNavigationService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + apiService, + commonService, service, navService ) { @@ -4440,80 +4594,237 @@ app.factory("RoleService", [ ]); "use strict"; -app.controller("PostController", [ +app.controller("ServiceController", [ "$scope", "$rootScope", - "$location", - "$filter", "ngAppSettings", "$routeParams", - "PostRestService", - "UrlAliasService", - "RestMixDatabaseDataPortalService", - "RestMixDatabaseColumnPortalService", + "$location", + "RestMixDatabasePortalService", + "ApiService", + "CommonService", function ( $scope, $rootScope, - $location, - $filter, ngAppSettings, $routeParams, + $location, service, - urlAliasService, - dataService, - columnService + commonService ) { - BaseRestCtrl.call( + BaseODataCtrl.call( this, $scope, $rootScope, - $location, $routeParams, ngAppSettings, service ); - $scope.viewmodelType = "post"; - $scope.additionalData = null; - $scope.createUrl = "/portal/post/create?"; - $scope.selectedCategories = []; - $scope.selectedTags = []; - $scope.postType = { - databaseName: "", - title: "All", - }; - $scope.cateRequest = angular.copy(ngAppSettings.request); - $scope.postTypeRequest = angular.copy(ngAppSettings.request); - $scope.postTypeRequest.mixDatabaseName = "post_type"; - $scope.postTypeRequest.orderBy = "Priority"; - $scope.postTypeRequest.direction = "Asc"; - - $scope.initList = async function () { - if ($routeParams.template) { - $scope.createUrl = `${$scope.createUrl}&template=${$routeParams.template}`; - } - if ($routeParams.category) { - $scope.request.category = $routeParams.category; - } - if ($routeParams.type) { - $scope.createUrl = `${$scope.createUrl}&type=${$routeParams.type}`; - $scope.request.postType = $routeParams.type; - } - if ($routeParams.page_ids) { - $scope.createUrl = `${$scope.createUrl}&page_ids=${$routeParams.page_ids}`; - } - $scope.pageName = "postList"; - await $scope.loadPostTypes(); - await $scope.loadCategories(); - $scope.getList(); + $scope.defaultId = "default"; + $scope.parentId = null; + $scope.parentType = null; + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.localizeSettings = $rootScope.globalSettings; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.init = async function () { + $scope.mixDatabaseId = $routeParams.mixDatabaseId; + $scope.mixDatabaseName = $routeParams.mixDatabaseName; + $scope.dataId = $routeParams.dataId; }; - $scope.loadCategories = async function () { - $scope.cateRequest.mixDatabaseName = "sys_category"; - var response = await dataService.getList($scope.cateRequest); - if (response.isSucceed) { - $scope.categories = response.data; - $scope.isBusy = false; - $scope.$apply(); - } + $scope.saveSuccessCallback = function () { + $rootScope.isBusy = false; + $scope.$apply(); + // if($scope.parentId){ + // $location.url('/portal/mix-database-data/details?dataId='+ $scope.parentId); + // } + // else{ + // $location.url('/portal/mix-database-data/list?mixDatabaseId='+ $scope.viewmodel.mixDatabaseId); + // } + }; + $scope.getList = async function () { + $rootScope.isBusy = true; + $scope.mixDatabaseId = $routeParams.mixDatabaseId; + $scope.mixDatabaseName = $routeParams.mixDatabaseName; + var type = $routeParams.type; + var parentId = $routeParams.parentId; + var response = await service.getList( + "read", + $scope.request, + $scope.mixDatabaseId, + $scope.mixDatabaseName, + type, + parentId + ); + $scope.canDrag = + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; + if (response) { + $scope.data = response; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors("Failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.getSingle = async function () { + $rootScope.isBusy = true; + var id = $routeParams.id || $scope.defaultId; + $scope.mixDatabaseId = $routeParams.mixDatabaseId; + $scope.mixDatabaseName = $routeParams.mixDatabaseName; + var resp = await service.getSingle("portal", [ + id, + $scope.mixDatabaseId, + $scope.mixDatabaseName, + ]); + if (resp) { + $scope.viewmodel = resp; + $scope.viewmodel.parentType = $scope.parentType; + $scope.viewmodel.parentId = $scope.parentId; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors("Failed"); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.preview = function (item) { + item.editUrl = "/portal/post/details/" + item.id; + $rootScope.preview("post", item, item.title, "modal-lg"); + }; + $scope.edit = function (data) { + $scope.goToPath( + "/portal/mix-database-data/details?dataId=" + + data.id + + "&mixDatabaseId=" + + $scope.mixDatabaseId + ); + }; + $scope.remove = function (data) { + $rootScope.showConfirm( + $scope, + "removeConfirmed", + [data.id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + + $scope.removeConfirmed = async function (dataId) { + $rootScope.isBusy = true; + var result = await service.delete([dataId]); + if (result.isSucceed) { + if ($scope.removeCallback) { + $rootScope.executeFunctionByName( + "removeCallback", + $scope.removeCallbackArgs, + $scope + ); + } + $scope.getList(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + + $scope.saveOthers = async function () { + var response = await service.saveList($scope.others); + if (response.isSucceed) { + $scope.getList(); + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + }, +]); + +"use strict"; +app.controller("PostController", [ + "$scope", + "$rootScope", + "$location", + "$filter", + "ngAppSettings", + "$routeParams", + "PostRestService", + "UrlAliasService", + "RestMixDatabaseDataPortalService", + "RestMixDatabaseColumnPortalService", + function ( + $scope, + $rootScope, + $location, + $filter, + ngAppSettings, + $routeParams, + service, + urlAliasService, + dataService, + columnService + ) { + BaseRestCtrl.call( + this, + $scope, + $rootScope, + $location, + $routeParams, + ngAppSettings, + service + ); + $scope.viewmodelType = "post"; + $scope.additionalData = null; + $scope.createUrl = "/portal/post/create?"; + $scope.selectedCategories = []; + $scope.selectedTags = []; + $scope.postType = { + databaseName: "", + title: "All", + }; + $scope.cateRequest = angular.copy(ngAppSettings.request); + $scope.postTypeRequest = angular.copy(ngAppSettings.request); + $scope.postTypeRequest.mixDatabaseName = "post_type"; + $scope.postTypeRequest.orderBy = "Priority"; + $scope.postTypeRequest.direction = "Asc"; + + $scope.initList = async function () { + if ($routeParams.template) { + $scope.createUrl = `${$scope.createUrl}&template=${$routeParams.template}`; + } + if ($routeParams.category) { + $scope.request.category = $routeParams.category; + } + if ($routeParams.type) { + $scope.createUrl = `${$scope.createUrl}&type=${$routeParams.type}`; + $scope.request.postType = $routeParams.type; + } + if ($routeParams.page_ids) { + $scope.createUrl = `${$scope.createUrl}&page_ids=${$routeParams.page_ids}`; + } + $scope.pageName = "postList"; + await $scope.loadPostTypes(); + await $scope.loadCategories(); + $scope.getList(); + }; + $scope.loadCategories = async function () { + $scope.cateRequest.mixDatabaseName = "sys_category"; + var response = await dataService.getList($scope.cateRequest); + if (response.isSucceed) { + $scope.categories = response.data; + $scope.isBusy = false; + $scope.$apply(); + } }; $scope.loadPostTypes = async function () { let getTypes = await dataService.getList($scope.postTypeRequest); @@ -4862,330 +5173,19 @@ app.factory("PostRestService", [ ]); "use strict"; -app.controller("PagePositionController", [ - "$scope", +app.controller("SocialFeedController", [ "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "PagePositionService", + "$scope", + "$http", "PostRestService", - "ApiService", - "CommonService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service, - postService, - apiService, - commonService - ) { - BaseCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.localizeSettings = $rootScope.globalSettings; - $scope.pageId = $routeParams.id; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.getList = async function () { - $rootScope.isBusy = true; - var id = $routeParams.id; - $scope.request.query = "&page_id=" + id; - var response = await service.getList($scope.request); - $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; - if (response.isSucceed) { - $scope.data = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.preview = function (item) { - item.editUrl = "/portal/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); - }; - $scope.remove = function (pageId, postId) { - $rootScope.showConfirm( - $scope, - "removeConfirmed", - [pageId, postId], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeConfirmed = async function (pageId, postId) { - $rootScope.isBusy = true; - var result = await service.delete(pageId, postId); - if (result.isSucceed) { - if ($scope.removeCallback) { - $rootScope.executeFunctionByName( - "removeCallback", - $scope.removeCallbackArgs, - $scope - ); - } - $scope.getList(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.saveOthers = async function () { - var response = await service.saveList($scope.others); - if (response.isSucceed) { - $scope.getList(); - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.updateInfos = async function (index) { - $scope.data.items.splice(index, 1); - $rootScope.isBusy = true; - var startIndex = $scope.data.items[0].priority - 1; - for (var i = 0; i < $scope.data.items.length; i++) { - $scope.data.items[i].priority = startIndex + i + 1; - } - var resp = await service.updateInfos($scope.data.items); - if (resp && resp.isSucceed) { - $scope.activedPage = resp.data; - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.factory("PagePositionService", [ - "$rootScope", - "ApiService", - "CommonService", - "BaseService", - function ($rootScope, apiService, commonService, baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("page-position"); - var _delete = async function (pageId, positionId) { - var url = this.prefixUrl + "/delete/" + pageId + "/" + positionId; - var req = { - method: "GET", - url: url, - }; - return await apiService.getApiResult(req); - }; - var _updateInfos = async function (pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), - }; - return await apiService.getApiResult(req); - }; - serviceFactory.delete = _delete; - serviceFactory.updateInfos = _updateInfos; - return serviceFactory; - }, -]); - -"use strict"; -app.controller("ServiceController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "RestMixDatabasePortalService", - "ApiService", - "CommonService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service, - commonService - ) { - BaseODataCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - $scope.defaultId = "default"; - $scope.parentId = null; - $scope.parentType = null; - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.localizeSettings = $rootScope.globalSettings; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.init = async function () { - $scope.mixDatabaseId = $routeParams.mixDatabaseId; - $scope.mixDatabaseName = $routeParams.mixDatabaseName; - $scope.dataId = $routeParams.dataId; - }; - $scope.saveSuccessCallback = function () { - $rootScope.isBusy = false; - $scope.$apply(); - // if($scope.parentId){ - // $location.url('/portal/mix-database-data/details?dataId='+ $scope.parentId); - // } - // else{ - // $location.url('/portal/mix-database-data/list?mixDatabaseId='+ $scope.viewmodel.mixDatabaseId); - // } - }; - $scope.getList = async function () { - $rootScope.isBusy = true; - $scope.mixDatabaseId = $routeParams.mixDatabaseId; - $scope.mixDatabaseName = $routeParams.mixDatabaseName; - var type = $routeParams.type; - var parentId = $routeParams.parentId; - var response = await service.getList( - "read", - $scope.request, - $scope.mixDatabaseId, - $scope.mixDatabaseName, - type, - parentId - ); - $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; - if (response) { - $scope.data = response; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors("Failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.getSingle = async function () { - $rootScope.isBusy = true; - var id = $routeParams.id || $scope.defaultId; - $scope.mixDatabaseId = $routeParams.mixDatabaseId; - $scope.mixDatabaseName = $routeParams.mixDatabaseName; - var resp = await service.getSingle("portal", [ - id, - $scope.mixDatabaseId, - $scope.mixDatabaseName, - ]); - if (resp) { - $scope.viewmodel = resp; - $scope.viewmodel.parentType = $scope.parentType; - $scope.viewmodel.parentId = $scope.parentId; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors("Failed"); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.preview = function (item) { - item.editUrl = "/portal/post/details/" + item.id; - $rootScope.preview("post", item, item.title, "modal-lg"); - }; - $scope.edit = function (data) { - $scope.goToPath( - "/portal/mix-database-data/details?dataId=" + - data.id + - "&mixDatabaseId=" + - $scope.mixDatabaseId - ); - }; - $scope.remove = function (data) { - $rootScope.showConfirm( - $scope, - "removeConfirmed", - [data.id], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeConfirmed = async function (dataId) { - $rootScope.isBusy = true; - var result = await service.delete([dataId]); - if (result.isSucceed) { - if ($scope.removeCallback) { - $rootScope.executeFunctionByName( - "removeCallback", - $scope.removeCallbackArgs, - $scope - ); - } - $scope.getList(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.saveOthers = async function () { - var response = await service.saveList($scope.others); - if (response.isSucceed) { - $scope.getList(); - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, -]); - -"use strict"; -app.controller("SocialFeedController", [ - "$rootScope", - "$scope", - "$http", - "PostRestService", - function ($rootScope, $scope, $http, postService) { - $scope.types = ["Facebook", "Instagram"]; - $scope.isInit = false; - $scope.defaultPost = null; - $scope.defaultProperty = { - name: null, - dataType: 7, - value: "", + function ($rootScope, $scope, $http, postService) { + $scope.types = ["Facebook", "Instagram"]; + $scope.isInit = false; + $scope.defaultPost = null; + $scope.defaultProperty = { + name: null, + dataType: 7, + value: "", }; $scope.data = []; $scope.errors = []; @@ -5580,199 +5580,20 @@ app.controller("TemplateController", [ } } }; - $scope.copy = async function (id) { - $rootScope.isBusy = true; - $scope.folderType = $routeParams.folderType; // ? $routeParams.folderType : 'Masters'; - var themeId = $routeParams.themeId; - $scope.listUrl = - "/portal/template/list/" + - themeId + - "?folderType=" + - encodeURIComponent($scope.folderType); - var resp = await service.copy(id); - if (resp && resp.isSucceed) { - $location.url( - `/portal/template/details/${themeId}/${$scope.folderType}/${resp.data.id}` - ); - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.getList = async function (pageIndex, themeId) { - $scope.request.themeId = themeId || $routeParams.themeId; - $scope.request.folderType = $routeParams.folderType; - $scope.request.status = null; - $scope.folderType = $routeParams.folderType; - if ($scope.folderType) { - if (pageIndex !== undefined) { - $scope.request.pageIndex = pageIndex; - } - if ($scope.request.fromDate !== null) { - var df = new Date($scope.request.fromDate); - $scope.request.fromDate = df.toISOString(); - } - if ($scope.request.toDate !== null) { - var dt = new Date($scope.request.toDate); - $scope.request.toDate = dt.toISOString(); - } - var resp = await service.getList($scope.request, [$scope.themeId]); - if (resp && resp.isSucceed) { - $scope.data = resp.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - $rootScope.isBusy = false; - $scope.$apply(); - } - } else { - $rootScope.isBusy = false; - } - }; - $scope.updateTemplateContent = function (content) { - $scope.viewmodel.content = content; - }; - $scope.updateStyleContent = function (content) { - $scope.viewmodel.scripts = content; - }; - $scope.updateScriptContent = function (content) { - $scope.viewmodel.styles = content; - }; - $scope.joinRoom = function () { - $scope.connection.invoke("JoinRoom", $scope.room, $scope.user); - }; - $scope.receiveMessage = function (msg) { - switch (msg.type) { - case "MemberList": - $scope.members = msg.data; - $scope.initMembersData(); - $scope.canEdit = $scope.members.length == 1; - if (!$scope.canEdit) { - $scope.errors = [ - "Cannot modify if there is another user opening this template", - ]; - } else { - $scope.errors = []; - } - $scope.$apply(); - break; - - default: - break; - } - console.log(msg); - }; - $scope.initMembersData = function () { - angular.forEach($scope.members, function (e) { - if (!e.Avatar) { - e.Avatar = "/mix-app/assets/img/user.png"; - } - }); - }; - }, -]); - -"use strict"; -app.controller("UrlAliasController", [ - "$scope", - "$rootScope", - "ngAppSettings", - "$routeParams", - "$location", - "UrlAliasService", - "ApiService", - "CommonService", - function ( - $scope, - $rootScope, - ngAppSettings, - $routeParams, - $location, - service, - apiService, - commonService - ) { - BaseCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - $scope.cates = ["Site", "System"]; - $scope.others = []; - $scope.localizeSettings = $rootScope.globalSettings; - $scope.pageId = $routeParams.id; - $scope.canDrag = - $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.getList = async function () { - $rootScope.isBusy = true; - var id = $routeParams.id; - $scope.request.query = "&page_id=" + id; - var response = await service.getList($scope.request); - $scope.canDrag = - $scope.request.orderBy !== "Priority" || - $scope.request.direction !== "0"; - if (response.isSucceed) { - $scope.data = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - $scope.remove = function (id) { - $rootScope.showConfirm( - $scope, - "removeConfirmed", - [id], - null, - "Remove", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - - $scope.removeConfirmed = async function (id) { - $rootScope.isBusy = true; - var result = await service.delete(id); - if (result.isSucceed) { - if ($scope.removeCallback) { - $rootScope.executeFunctionByName( - "removeCallback", - $scope.removeCallbackArgs, - $scope - ); - } - $scope.getList(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - - $scope.updateInfos = async function (index) { - $scope.data.items.splice(index, 1); - $rootScope.isBusy = true; - var startIndex = $scope.data.items[0].priority - 1; - for (var i = 0; i < $scope.data.items.length; i++) { - $scope.data.items[i].priority = startIndex + i + 1; - } - var resp = await service.updateInfos($scope.data.items); + $scope.copy = async function (id) { + $rootScope.isBusy = true; + $scope.folderType = $routeParams.folderType; // ? $routeParams.folderType : 'Masters'; + var themeId = $routeParams.themeId; + $scope.listUrl = + "/portal/template/list/" + + themeId + + "?folderType=" + + encodeURIComponent($scope.folderType); + var resp = await service.copy(id); if (resp && resp.isSucceed) { - $scope.activedPage = resp.data; - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; + $location.url( + `/portal/template/details/${themeId}/${$scope.folderType}/${resp.data.id}` + ); $scope.$apply(); } else { if (resp) { @@ -5782,29 +5603,79 @@ app.controller("UrlAliasController", [ $scope.$apply(); } }; - }, -]); - -"use strict"; -app.factory("UrlAliasService", [ - "$rootScope", - "ApiService", - "CommonService", - "BaseService", - function ($rootScope, apiService, commonService, baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("url-alias"); + $scope.getList = async function (pageIndex, themeId) { + $scope.request.themeId = themeId || $routeParams.themeId; + $scope.request.folderType = $routeParams.folderType; + $scope.request.status = null; + $scope.folderType = $routeParams.folderType; + if ($scope.folderType) { + if (pageIndex !== undefined) { + $scope.request.pageIndex = pageIndex; + } + if ($scope.request.fromDate !== null) { + var df = new Date($scope.request.fromDate); + $scope.request.fromDate = df.toISOString(); + } + if ($scope.request.toDate !== null) { + var dt = new Date($scope.request.toDate); + $scope.request.toDate = dt.toISOString(); + } + var resp = await service.getList($scope.request, [$scope.themeId]); + if (resp && resp.isSucceed) { + $scope.data = resp.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + } else { + $rootScope.isBusy = false; + } + }; + $scope.updateTemplateContent = function (content) { + $scope.viewmodel.content = content; + }; + $scope.updateStyleContent = function (content) { + $scope.viewmodel.scripts = content; + }; + $scope.updateScriptContent = function (content) { + $scope.viewmodel.styles = content; + }; + $scope.joinRoom = function () { + $scope.connection.invoke("JoinRoom", $scope.room, $scope.user); + }; + $scope.receiveMessage = function (msg) { + switch (msg.type) { + case "MemberList": + $scope.members = msg.data; + $scope.initMembersData(); + $scope.canEdit = $scope.members.length == 1; + if (!$scope.canEdit) { + $scope.errors = [ + "Cannot modify if there is another user opening this template", + ]; + } else { + $scope.errors = []; + } + $scope.$apply(); + break; - var _updateInfos = async function (pages) { - var req = { - method: "POST", - url: this.prefixUrl + "/update-infos", - data: JSON.stringify(pages), - }; - return await apiService.getApiResult(req); + default: + break; + } + console.log(msg); + }; + $scope.initMembersData = function () { + angular.forEach($scope.members, function (e) { + if (!e.Avatar) { + e.Avatar = "/mix-app/assets/img/user.png"; + } + }); }; - serviceFactory.updateInfos = _updateInfos; - return serviceFactory; }, ]); @@ -6218,72 +6089,201 @@ app.factory("UserServices", [ if (id) { url += "/" + id; } - var req = { - method: "GET", - url: url, - }; - return await apiService.getApiResult(req); - }; - - var _getMyProfile = async function () { - var apiUrl = "/account/"; - var url = apiUrl + "my-profile"; - var req = { - method: "GET", - url: url, - }; - return await apiService.getApiResult(req); + var req = { + method: "GET", + url: url, + }; + return await apiService.getApiResult(req); + }; + + var _getMyProfile = async function () { + var apiUrl = "/account/"; + var url = apiUrl + "my-profile"; + var req = { + method: "GET", + url: url, + }; + return await apiService.getApiResult(req); + }; + + var _updateRoleStatus = function (userInRole) { + var req = { + method: "POST", + url: serviceBase + "/account/user-in-role", + data: JSON.stringify(userInRole), + }; + + return apiService.getApiResult(req); + }; + + var _saveUser = async function (user) { + var apiUrl = "/account/"; + var req = { + method: "POST", + url: apiUrl + "save", + data: JSON.stringify(user), + }; + return await apiService.getApiResult(req); + }; + + var _register = async function (user) { + var apiUrl = "/account/"; + var req = { + method: "POST", + url: apiUrl + "register", + data: JSON.stringify(user), + }; + return await apiService.getApiResult(req); + }; + + var _removeUser = function (userId) { + var req = { + method: "GET", + url: apiUrl + "remove-user/" + userId, + }; + + return apiService.getApiResult(req); + }; + + usersServiceFactory.importUsers = _importUsers; + usersServiceFactory.getUsers = _getUsers; + usersServiceFactory.getUser = _getUser; + usersServiceFactory.getMyProfile = _getMyProfile; + usersServiceFactory.saveUser = _saveUser; + usersServiceFactory.register = _register; + usersServiceFactory.removeUser = _removeUser; + usersServiceFactory.updateRoleStatus = _updateRoleStatus; + usersServiceFactory.getUserDemographicInfo = _getUserDemographicInfo; + return usersServiceFactory; + }, +]); + +"use strict"; +app.controller("UrlAliasController", [ + "$scope", + "$rootScope", + "ngAppSettings", + "$routeParams", + "$location", + "UrlAliasService", + "ApiService", + "CommonService", + function ( + $scope, + $rootScope, + ngAppSettings, + $routeParams, + $location, + service, + apiService, + commonService + ) { + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + $scope.cates = ["Site", "System"]; + $scope.others = []; + $scope.localizeSettings = $rootScope.globalSettings; + $scope.pageId = $routeParams.id; + $scope.canDrag = + $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; + $scope.getList = async function () { + $rootScope.isBusy = true; + var id = $routeParams.id; + $scope.request.query = "&page_id=" + id; + var response = await service.getList($scope.request); + $scope.canDrag = + $scope.request.orderBy !== "Priority" || + $scope.request.direction !== "0"; + if (response.isSucceed) { + $scope.data = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.remove = function (id) { + $rootScope.showConfirm( + $scope, + "removeConfirmed", + [id], + null, + "Remove", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + + $scope.removeConfirmed = async function (id) { + $rootScope.isBusy = true; + var result = await service.delete(id); + if (result.isSucceed) { + if ($scope.removeCallback) { + $rootScope.executeFunctionByName( + "removeCallback", + $scope.removeCallbackArgs, + $scope + ); + } + $scope.getList(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } }; - var _updateRoleStatus = function (userInRole) { - var req = { - method: "POST", - url: serviceBase + "/account/user-in-role", - data: JSON.stringify(userInRole), - }; - - return apiService.getApiResult(req); + $scope.updateInfos = async function (index) { + $scope.data.items.splice(index, 1); + $rootScope.isBusy = true; + var startIndex = $scope.data.items[0].priority - 1; + for (var i = 0; i < $scope.data.items.length; i++) { + $scope.data.items[i].priority = startIndex + i + 1; + } + var resp = await service.updateInfos($scope.data.items); + if (resp && resp.isSucceed) { + $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(); + } }; + }, +]); - var _saveUser = async function (user) { - var apiUrl = "/account/"; - var req = { - method: "POST", - url: apiUrl + "save", - data: JSON.stringify(user), - }; - return await apiService.getApiResult(req); - }; +"use strict"; +app.factory("UrlAliasService", [ + "$rootScope", + "ApiService", + "CommonService", + "BaseService", + function ($rootScope, apiService, commonService, baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("url-alias"); - var _register = async function (user) { - var apiUrl = "/account/"; + var _updateInfos = async function (pages) { var req = { method: "POST", - url: apiUrl + "register", - data: JSON.stringify(user), + url: this.prefixUrl + "/update-infos", + data: JSON.stringify(pages), }; return await apiService.getApiResult(req); }; - - var _removeUser = function (userId) { - var req = { - method: "GET", - url: apiUrl + "remove-user/" + userId, - }; - - return apiService.getApiResult(req); - }; - - usersServiceFactory.importUsers = _importUsers; - usersServiceFactory.getUsers = _getUsers; - usersServiceFactory.getUser = _getUser; - usersServiceFactory.getMyProfile = _getMyProfile; - usersServiceFactory.saveUser = _saveUser; - usersServiceFactory.register = _register; - usersServiceFactory.removeUser = _removeUser; - usersServiceFactory.updateRoleStatus = _updateRoleStatus; - usersServiceFactory.getUserDemographicInfo = _getUserDemographicInfo; - return usersServiceFactory; + serviceFactory.updateInfos = _updateInfos; + return serviceFactory; }, ]); @@ -6475,6 +6475,22 @@ function PageDetailsController($scope, $element, $attrs) { }); } +app.component("appSettingsAuth", { + templateUrl: + "/mix-app/views/app-portal/pages/app-settings/components/auth/view.html", + controller: [ + "ngAppSettings", + function (ngAppSettings) { + var ctrl = this; + }, + ], + bindings: { + appSettings: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("appSettingsDefault", { templateUrl: "/mix-app/views/app-portal/pages/app-settings/components/default/view.html", @@ -6519,45 +6535,32 @@ app.component("appSettingsDefault", { }, }); -app.component("appSettingsAuth", { +app.component("appSettingsHeart", { templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/auth/view.html", - controller: [ - "ngAppSettings", - function (ngAppSettings) { - var ctrl = this; - }, - ], + "/mix-app/views/app-portal/pages/app-settings/components/heart/view.html", bindings: { appSettings: "=", - onDelete: "&", - onUpdate: "&", }, -}); - -app.component("appSettingsGeneral", { - templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/general/view.html", controller: [ "$rootScope", "$scope", "CommonService", - function ($rootScope, $scope, commonService) { + "ngAppSettings", + function ($rootScope, $scope, commonService, ngAppSettings) { var ctrl = this; - ctrl.stopApplication = async function () { + ctrl.$onInit = function () { + ctrl.databaseProviders = ngAppSettings.enums.database_providers; + ctrl.cacheModes = ngAppSettings.enums.cache_modes; + }; + ctrl.clearCache = async function () { $rootScope.isBusy = true; - await commonService.stopApplication(); + await commonService.clearCache(); $rootScope.showMessage("success", "success"); $rootScope.isBusy = false; $scope.$apply(); }; }, ], - bindings: { - appSettings: "=", - onDelete: "&", - onUpdate: "&", - }, }); modules.component("portalMenus", { @@ -6592,32 +6595,29 @@ modules.component("portalMenus", { ], }); -app.component("appSettingsHeart", { +app.component("appSettingsGeneral", { templateUrl: - "/mix-app/views/app-portal/pages/app-settings/components/heart/view.html", - bindings: { - appSettings: "=", - }, + "/mix-app/views/app-portal/pages/app-settings/components/general/view.html", controller: [ "$rootScope", "$scope", "CommonService", - "ngAppSettings", - function ($rootScope, $scope, commonService, ngAppSettings) { + function ($rootScope, $scope, commonService) { var ctrl = this; - ctrl.$onInit = function () { - ctrl.databaseProviders = ngAppSettings.enums.database_providers; - ctrl.cacheModes = ngAppSettings.enums.cache_modes; - }; - ctrl.clearCache = async function () { + ctrl.stopApplication = async function () { $rootScope.isBusy = true; - await commonService.clearCache(); + await commonService.stopApplication(); $rootScope.showMessage("success", "success"); $rootScope.isBusy = false; $scope.$apply(); }; }, ], + bindings: { + appSettings: "=", + onDelete: "&", + onUpdate: "&", + }, }); app.component("appSettingsSmtp", { @@ -6634,6 +6634,16 @@ app.component("appSettingsSmtp", { }, }); +app.component("customerMain", { + templateUrl: + "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", + bindings: { + customer: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("customerOrders", { templateUrl: "/mix-app/views/app-portal/pages/customer/components/orders/customer-orders.html", @@ -6673,13 +6683,18 @@ app.component("customerOrders", { }, }); -app.component("customerMain", { +app.component("mixDatabaseEdm", { templateUrl: - "/mix-app/views/app-portal/pages/customer/components/main/customer-main.html", + "/mix-app/views/app-portal/pages/mix-database/components/edm/view.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + ctrl.localizeSettings = $rootScope.globalSettings; + }, + ], bindings: { - customer: "=", - onDelete: "&", - onUpdate: "&", + model: "=", }, }); @@ -6713,21 +6728,6 @@ app.component("mixDatabaseMain", { }, }); -app.component("mixDatabaseEdm", { - templateUrl: - "/mix-app/views/app-portal/pages/mix-database/components/edm/view.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.localizeSettings = $rootScope.globalSettings; - }, - ], - bindings: { - model: "=", - }, -}); - app.component("moduleMain", { templateUrl: "/mix-app/views/app-portal/pages/module/components/main/main.html", @@ -6799,7 +6799,60 @@ app.component("moduleType", { }, ], bindings: { - model: "=", + model: "=", + }, +}); + +app.component("pageMain", { + templateUrl: "/mix-app/views/app-portal/pages/page/components/main/main.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope) { + var ctrl = this; + ctrl.localizeSettings = $rootScope.globalSettings; + // ctrl.setPageType = function (type) { + // ctrl.page.type = $index; + // } + ctrl.generateSeo = function () { + if (ctrl.page) { + if (ctrl.page.seoName === null || ctrl.page.seoName === "") { + ctrl.page.seoName = $rootScope.generateKeyword( + ctrl.page.title, + "-" + ); + } + if (ctrl.page.seoTitle === null || ctrl.page.seoTitle === "") { + ctrl.page.seoTitle = ctrl.page.title; + } + if ( + ctrl.page.seoDescription === null || + ctrl.page.seoDescription === "" + ) { + ctrl.page.seoDescription = ctrl.page.excerpt; + } + if (ctrl.page.seoKeywords === null || ctrl.page.seoKeywords === "") { + ctrl.page.seoKeywords = ctrl.page.title; + } + } + }; + }, + ], + bindings: { + page: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + +app.component("pageModules", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/modules/modules.html", + bindings: { + page: "=", + onDelete: "&", + onUpdate: "&", }, }); @@ -6909,80 +6962,6 @@ app.component("pageGeneral", { }, }); -app.component("pageMain", { - templateUrl: "/mix-app/views/app-portal/pages/page/components/main/main.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope) { - var ctrl = this; - ctrl.localizeSettings = $rootScope.globalSettings; - // ctrl.setPageType = function (type) { - // ctrl.page.type = $index; - // } - ctrl.generateSeo = function () { - if (ctrl.page) { - if (ctrl.page.seoName === null || ctrl.page.seoName === "") { - ctrl.page.seoName = $rootScope.generateKeyword( - ctrl.page.title, - "-" - ); - } - if (ctrl.page.seoTitle === null || ctrl.page.seoTitle === "") { - ctrl.page.seoTitle = ctrl.page.title; - } - if ( - ctrl.page.seoDescription === null || - ctrl.page.seoDescription === "" - ) { - ctrl.page.seoDescription = ctrl.page.excerpt; - } - if (ctrl.page.seoKeywords === null || ctrl.page.seoKeywords === "") { - ctrl.page.seoKeywords = ctrl.page.title; - } - } - }; - }, - ], - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("pageModules", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/modules/modules.html", - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("pageAdvanced", { - templateUrl: - "/mix-app/views/app-portal/pages/page/components/page-advanced/view.html", - bindings: { - model: "=", - additionalData: "=", - }, - controller: [ - "$rootScope", - "$scope", - function ($rootScope, $scope) { - var ctrl = this; - - ctrl.translate = $rootScope.translate; - ctrl.$onInit = function () { - ctrl.isAdmin = $rootScope.isAdmin; - }; - }, - ], -}); - app.component("pageContent", { templateUrl: "/mix-app/views/app-portal/pages/page/components/page-content/view.html", @@ -7025,14 +7004,25 @@ app.component("pageContent", { ], }); -app.component("pageParents", { +app.component("pageAdvanced", { templateUrl: - "/mix-app/views/app-portal/pages/page/components/parents/parents.html", + "/mix-app/views/app-portal/pages/page/components/page-advanced/view.html", bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", + model: "=", + additionalData: "=", }, + controller: [ + "$rootScope", + "$scope", + function ($rootScope, $scope) { + var ctrl = this; + + ctrl.translate = $rootScope.translate; + ctrl.$onInit = function () { + ctrl.isAdmin = $rootScope.isAdmin; + }; + }, + ], }); app.component("pageType", { @@ -7050,6 +7040,16 @@ app.component("pageType", { ], }); +app.component("pageParents", { + templateUrl: + "/mix-app/views/app-portal/pages/page/components/parents/parents.html", + bindings: { + page: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("pagePlugPlay", { templateUrl: "/mix-app/views/app-portal/pages/page/components/plug-play/plug-play.html", @@ -7152,6 +7152,16 @@ app.component("permissionMain", { }, }); +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", @@ -7292,42 +7302,27 @@ modules.component("rolePageNav", { }, }); -app.component("permissionParents", { - templateUrl: - "/mix-app/views/app-portal/pages/permission/components/parents/parents.html", - bindings: { - page: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - -app.component("postGeneral", { +app.component("serviceMain", { templateUrl: - "/mix-app/views/app-portal/pages/post/components/general/view.html", + "/mix-app/views/app-portal/pages/service/components/main/view.html", controller: [ "$rootScope", - "ngAppSettings", - function ($rootScope, ngAppSettings) { + function ($rootScope) { var ctrl = this; - ctrl.dataTypes = $rootScope.globalSettings.dataTypes; - ctrl.$onInit = function () {}; - ctrl.addProperty = function (type) { - var i = $(".property").length; - ctrl.post.properties.push({ - title: "", - name: "", - value: null, - dataType: "text", - }); + ctrl.localizeSettings = $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: { - post: "=", - isAdmin: "=", - onDelete: "&", - onUpdate: "&", + model: "=", }, }); @@ -7477,6 +7472,35 @@ app.component("postMain", { ], }); +app.component("postGeneral", { + templateUrl: + "/mix-app/views/app-portal/pages/post/components/general/view.html", + controller: [ + "$rootScope", + "ngAppSettings", + function ($rootScope, ngAppSettings) { + var ctrl = this; + ctrl.dataTypes = $rootScope.globalSettings.dataTypes; + ctrl.$onInit = function () {}; + ctrl.addProperty = function (type) { + var i = $(".property").length; + ctrl.post.properties.push({ + title: "", + name: "", + value: null, + dataType: "text", + }); + }; + }, + ], + bindings: { + post: "=", + isAdmin: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("postParents", { templateUrl: "/mix-app/views/app-portal/pages/post/components/parents/view.html", @@ -7690,15 +7714,6 @@ app.component("postContent", { ], }); -app.component("postSeo", { - templateUrl: "/mix-app/views/app-portal/pages/post/components/seo/view.html", - bindings: { - post: "=", - onDelete: "&", - onUpdate: "&", - }, -}); - modules.component("relatedNavs", { templateUrl: "/mix-app/views/app-portal/pages/post/components/related-navigations/view.html", @@ -7756,30 +7771,6 @@ modules.component("relatedNavs", { ], }); -app.component("serviceMain", { - templateUrl: - "/mix-app/views/app-portal/pages/service/components/main/view.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - ctrl.localizeSettings = $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("themeExportMixDatabases", { templateUrl: "/mix-app/views/app-portal/pages/theme/components/theme-export-mix-databases/view.html", @@ -7798,40 +7789,7 @@ app.component("themeExportMixDatabases", { ) ); // angular.forEach(ctrl.selectedExport.mixDatabases,function(e){ - // e.data = angular.copy($rootScope.filterArray(e.data, ['isActived'], [true])); - // }); - }; - ctrl.selectAll = function (arr) { - ctrl.selectedList.data = []; - angular.forEach(arr, function (e) { - e.isActived = ctrl.selectedList.isSelectAll; - e.isExportData = ctrl.selectedList.isExportData; - }); - ctrl.updateMixDatabaseExport(); - }; - }, - ], - bindings: { - exportData: "=", - selectedExport: "=", - }, -}); - -app.component("themeExportModules", { - templateUrl: - "/mix-app/views/app-portal/pages/theme/components/theme-export-modules/view.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope) { - var ctrl = this; - ctrl.updateModuleExport = function () { - ctrl.selectedExport.modules = angular.copy( - $rootScope.filterArray(ctrl.exportData.modules, ["isActived"], [true]) - ); - // angular.forEach(ctrl.selectedExport.modules,function(e){ - // e.data.items = angular.copy($rootScope.filterArray(e.data.items, ['isActived'], [true])); + // e.data = angular.copy($rootScope.filterArray(e.data, ['isActived'], [true])); // }); }; ctrl.selectAll = function (arr) { @@ -7840,7 +7798,7 @@ app.component("themeExportModules", { e.isActived = ctrl.selectedList.isSelectAll; e.isExportData = ctrl.selectedList.isExportData; }); - ctrl.updateModuleExport(); + ctrl.updateMixDatabaseExport(); }; }, ], @@ -7850,6 +7808,15 @@ app.component("themeExportModules", { }, }); +app.component("postSeo", { + templateUrl: "/mix-app/views/app-portal/pages/post/components/seo/view.html", + bindings: { + post: "=", + onDelete: "&", + onUpdate: "&", + }, +}); + app.component("themeExportPages", { templateUrl: "/mix-app/views/app-portal/pages/theme/components/theme-export-pages/view.html", @@ -7898,6 +7865,39 @@ app.component("themeExportPages", { }, }); +app.component("themeExportModules", { + templateUrl: + "/mix-app/views/app-portal/pages/theme/components/theme-export-modules/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope) { + var ctrl = this; + ctrl.updateModuleExport = function () { + ctrl.selectedExport.modules = angular.copy( + $rootScope.filterArray(ctrl.exportData.modules, ["isActived"], [true]) + ); + // angular.forEach(ctrl.selectedExport.modules,function(e){ + // e.data.items = angular.copy($rootScope.filterArray(e.data.items, ['isActived'], [true])); + // }); + }; + ctrl.selectAll = function (arr) { + ctrl.selectedList.data = []; + angular.forEach(arr, function (e) { + e.isActived = ctrl.selectedList.isSelectAll; + e.isExportData = ctrl.selectedList.isExportData; + }); + ctrl.updateModuleExport(); + }; + }, + ], + bindings: { + exportData: "=", + selectedExport: "=", + }, +}); + app.component("themeExportPosts", { templateUrl: "/mix-app/views/app-portal/pages/theme/components/theme-export-posts/view.html", @@ -8280,6 +8280,46 @@ modules.component("aceEditor", { }, }); +modules.component("actions", { + templateUrl: "/mix-app/views/app-portal/components/actions/actions.html", + bindings: { + primaryUrl: "=", + primaryTitle: "=", + primaryIcon: "=", + previewUrl: "=", + backUrl: "=", + contentUrl: "=", + onClearCache: "&?", + onSubmit: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "$location", + function($rootScope, $scope, $location) { + var ctrl = this; + ctrl.visible = $rootScope.visible; + ctrl.back = function() { + // ctrl.backUrl = ctrl.backUrl || "/admin"; + // $location.url(ctrl.backUrl); + window.history.back(); + }; + ctrl.$onInit = function() { + ctrl.isAdmin = $rootScope.isAdmin; + }; + ctrl.submit = function($event) { + if (ctrl.onSubmit) { + $event.preventDefault(); + ctrl.onSubmit(); + return; + } + }; + ctrl.clearCache = function() { + ctrl.onClearCache(); + }; + }, + ], +}); modules.component("additionalColumn", { templateUrl: "/mix-app/views/app-portal/components/additional-column/view.html", @@ -8338,7 +8378,7 @@ modules.component("additionalColumn", { }; ctrl.generateName = function (col) { - col.name = $rootScope.generateKeyword(col.title, "_"); + col.name = $rootScope.generateKeyword(col.title, "_", true, true); }; ctrl.showReferences = function (col) { ctrl.colRef = col; @@ -8398,46 +8438,6 @@ modules.component("additionalColumn", { ], }); -modules.component("actions", { - templateUrl: "/mix-app/views/app-portal/components/actions/actions.html", - bindings: { - primaryUrl: "=", - primaryTitle: "=", - primaryIcon: "=", - previewUrl: "=", - backUrl: "=", - contentUrl: "=", - onClearCache: "&?", - onSubmit: "&?", - }, - controller: [ - "$rootScope", - "$scope", - "$location", - function($rootScope, $scope, $location) { - var ctrl = this; - ctrl.visible = $rootScope.visible; - ctrl.back = function() { - // ctrl.backUrl = ctrl.backUrl || "/admin"; - // $location.url(ctrl.backUrl); - window.history.back(); - }; - ctrl.$onInit = function() { - ctrl.isAdmin = $rootScope.isAdmin; - }; - ctrl.submit = function($event) { - if (ctrl.onSubmit) { - $event.preventDefault(); - ctrl.onSubmit(); - return; - } - }; - ctrl.clearCache = function() { - ctrl.onClearCache(); - }; - }, - ], -}); modules.component("additionalValue", { templateUrl: "/mix-app/views/app-portal/components/additional-value/view.html", @@ -8516,69 +8516,6 @@ modules.component("confirm", { }, }); -modules.component("filterList", { - templateUrl: - "/mix-app/views/app-portal/components/filter-list/filter-list.html", - controller: [ - "$scope", - "$rootScope", - "ngAppSettings", - function ($scope, $rootScope, ngAppSettings) { - var ctrl = this; - ctrl.dateRange = { - fromDate: null, - toDate: null, - }; - ctrl.init = function () { - if (!ctrl.orders) { - ctrl.orders = ngAppSettings.orders; - } - ctrl.directions = ngAppSettings.directions; - ctrl.pageSizes = ngAppSettings.pageSizes; - ctrl.statuses = []; - var statuses = ngAppSettings.contentStatuses; - if (ctrl.request && ctrl.request.contentStatuses) { - statuses = ctrl.request.contentStatuses; - } - angular.forEach(statuses, function (val, i) { - ctrl.statuses.push({ - value: val, - title: val, - }); - }); - }; - ctrl.apply = function (pageIndex) { - $rootScope.setRequest(ctrl.request, ctrl.key); - ctrl.callback({ pageIndex: pageIndex }); - }; - ctrl.updateDate = function () { - if (Date.parse(ctrl.dateRange.fromDate)) { - ctrl.request.fromDate = new Date( - ctrl.dateRange.fromDate - ).toISOString(); - } else { - $scope.request.fromDate = null; - } - if (Date.parse(ctrl.dateRange.toDate)) { - ctrl.request.toDate = new Date(ctrl.dateRange.toDate).toISOString(); - } else { - ctrl.request.toDate = null; - } - $rootScope.setRequest(ctrl.request, ctrl.key); - ctrl.callback({ pageIndex: 0 }); - }; - }, - ], - bindings: { - request: "=", - key: "=?", - orders: "=?", - createUrl: "=", - createText: "=", - callback: "&", - }, -}); - modules.component("customImage", { templateUrl: "/mix-app/views/app-portal/components/custom-image/custom-image.html", @@ -8754,11 +8691,113 @@ modules.component("customImage", { } }; - ctrl.onUploadFileProgress = function (progress) { - ctrl.progress = progress; + ctrl.onUploadFileProgress = function (progress) { + ctrl.progress = progress; + }; + }, + ], +}); + +modules.component("filterList", { + templateUrl: + "/mix-app/views/app-portal/components/filter-list/filter-list.html", + controller: [ + "$scope", + "$rootScope", + "ngAppSettings", + function ($scope, $rootScope, ngAppSettings) { + var ctrl = this; + ctrl.dateRange = { + fromDate: null, + toDate: null, + }; + ctrl.init = function () { + if (!ctrl.orders) { + ctrl.orders = ngAppSettings.orders; + } + ctrl.directions = ngAppSettings.directions; + ctrl.pageSizes = ngAppSettings.pageSizes; + ctrl.statuses = []; + var statuses = ngAppSettings.contentStatuses; + if (ctrl.request && ctrl.request.contentStatuses) { + statuses = ctrl.request.contentStatuses; + } + angular.forEach(statuses, function (val, i) { + ctrl.statuses.push({ + value: val, + title: val, + }); + }); + }; + ctrl.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: "=?", + orders: "=?", + createUrl: "=", + createText: "=", + callback: "&", + }, +}); + +modules.component("githubContributers", { + templateUrl: + "/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 { + isSucceed: false, + errors: [error.statusText || error.status], + }; + } + ); }; }, ], + bindings: {}, }); modules.component("funding", { @@ -8804,9 +8843,8 @@ modules.component("funding", { bindings: {}, }); -modules.component("githubContributers", { - templateUrl: - "/mix-app/views/app-portal/components/github-contributers/view.html", +modules.component("githubReleases", { + templateUrl: "/mix-app/views/app-portal/components/github-releases/view.html", controller: [ "$rootScope", "$http", @@ -8816,7 +8854,7 @@ modules.component("githubContributers", { ctrl.init = function () { var req = { method: "GET", - url: "https://api.github.com/repos/mixcore/mix.core/contributors", + url: "https://api.github.com/repos/mixcore/mix.core/releases", }; ctrl.getGithubApiResult(req); }; @@ -9044,43 +9082,6 @@ modules.component("googleAnalytic", { ], }); -modules.component("githubReleases", { - templateUrl: "/mix-app/views/app-portal/components/github-releases/view.html", - controller: [ - "$rootScope", - "$http", - function ($rootScope, $http) { - var ctrl = this; - ctrl.items = []; - ctrl.init = function () { - var req = { - method: "GET", - url: "https://api.github.com/repos/mixcore/mix.core/releases", - }; - ctrl.getGithubApiResult(req); - }; - - ctrl.getGithubApiResult = async function (req) { - return $http(req).then( - function (resp) { - if (resp.status == "200") { - ctrl.items = resp.data; - } else { - } - }, - function (error) { - return { - isSucceed: false, - errors: [error.statusText || error.status], - }; - } - ); - }; - }, - ], - bindings: {}, -}); - (function (angular) { app.component("headerNav", { templateUrl: @@ -9156,6 +9157,22 @@ modules.component("githubReleases", { }); })(window.angular); +modules.component("hubMessages", { + templateUrl: + "/mix-app/views/app-portal/components/hub-messages/hub-messages.html", + controller: "HubMessagesController", + bindings: {}, +}); +app.controller("HubMessagesController", [ + "$scope", + function ($scope) { + BaseHub.call(this, $scope); + $scope.init = function () { + $scope.startConnection("portalhub"); + }; + }, +]); + modules.component("jsonBuilder", { templateUrl: "/mix-app/views/app-portal/components/json-builder/view.html", bindings: { @@ -9370,22 +9387,6 @@ modules.component("jsonBuilder", { ], }); -modules.component("hubMessages", { - templateUrl: - "/mix-app/views/app-portal/components/hub-messages/hub-messages.html", - controller: "HubMessagesController", - bindings: {}, -}); -app.controller("HubMessagesController", [ - "$scope", - function ($scope) { - BaseHub.call(this, $scope); - $scope.init = function () { - $scope.startConnection("portalhub"); - }; - }, -]); - modules.component("jumbotrons", { templateUrl: "/mix-app/views/app-portal/components/jumbotrons/jumbotrons.html", @@ -9631,43 +9632,43 @@ modules.component("mainSideBarDynamic", { }, }); -modules.component("mainSideBarItem", { +modules.component("mainSideBarItemDynamic", { templateUrl: - "/mix-app/views/app-portal/components/main-side-bar-item/main-side-bar-item.html", + "/mix-app/views/app-portal/components/main-side-bar-item-dynamic/main-side-bar-item-dynamic.html", controller: [ "$rootScope", function ($rootScope) { var ctrl = this; ctrl.translate = $rootScope.translate; - ctrl.addClass = function (obj) { - obj.currentTarget.classList.add("btn-group-lg"); - //alert(obj); - }; - ctrl.removeClass = function (obj) { - obj.currentTarget.classList.remove("btn-group-lg"); - //alert(obj); - }; }, ], bindings: { + iconSize: "=", + linkStyle: "=", + itemStyle: "=", item: "=", }, }); -modules.component("mainSideBarItemDynamic", { +modules.component("mainSideBarItem", { templateUrl: - "/mix-app/views/app-portal/components/main-side-bar-item-dynamic/main-side-bar-item-dynamic.html", + "/mix-app/views/app-portal/components/main-side-bar-item/main-side-bar-item.html", controller: [ "$rootScope", function ($rootScope) { var ctrl = this; ctrl.translate = $rootScope.translate; + ctrl.addClass = function (obj) { + obj.currentTarget.classList.add("btn-group-lg"); + //alert(obj); + }; + ctrl.removeClass = function (obj) { + obj.currentTarget.classList.remove("btn-group-lg"); + //alert(obj); + }; }, ], bindings: { - iconSize: "=", - linkStyle: "=", - itemStyle: "=", item: "=", }, }); @@ -9923,125 +9924,15 @@ modules.component("mediumNews", { }, function (error) { return { - isSucceed: false, - errors: [error.statusText || error.status], - }; - } - ); - }; - }, - ], - bindings: {}, -}); - -modules.component("mixDatabaseColumn", { - templateUrl: - "/mix-app/views/app-portal/components/mix-database-column/view.html", - bindings: { - column: "=", - }, - controller: [ - "$rootScope", - "$scope", - "RestMixDatabaseColumnPortalService", - function ($rootScope, $scope, columnService) { - var ctrl = this; - ctrl.value = {}; - ctrl.column = { - dataType: "Text", - mixDatabaseName: "sys_additional_column", - mixDatabaseId: 6, - }; - ctrl.selectedCol = null; - ctrl.localizeSettings = $rootScope.globalSettings; - ctrl.$onInit = async function () {}; - ctrl.addAttr = async function () { - if (ctrl.column.name) { - var current = $rootScope.findObjectByKey( - ctrl.additionalData.columns, - "name", - ctrl.column.name - ); - if (current) { - $rootScope.showErrors(["Field " + ctrl.column.name + " existed!"]); - } else { - ctrl.column.priority = ctrl.additionalData.columns.length + 1; - $rootScope.isBusy = true; - var saveField = await columnService.create(ctrl.column); - $rootScope.isBusy = false; - if (saveField.isSucceed) { - ctrl.additionalData.columns.push(saveField.data); - - //reset column option - ctrl.column.title = ""; - ctrl.column.name = ""; - ctrl.column.dataType = "Text"; - $scope.$apply(); - } - } - } else { - $rootScope.showErrors(["Please add column Name"]); - } - }; - - ctrl.generateName = function (col) { - col.name = $rootScope.generateKeyword(col.title, "_"); - }; - ctrl.showReferences = function (col) { - ctrl.colRef = col; - $("#modal-navs").modal("show"); - }; - ctrl.referenceCallback = function (selected) { - if (selected && selected.length) { - ctrl.colRef.reference = selected; - ctrl.colRef.referenceId = selected[0].id; - } - $("#modal-navs").modal("hide"); - }; - ctrl.updateOrders = function (index) { - if (index > ctrl.dragStartIndex) { - ctrl.columns.splice(ctrl.dragStartIndex, 1); - } else { - ctrl.columns.splice(ctrl.dragStartIndex + 1, 1); - } - angular.forEach(ctrl.columns, function (e, i) { - e.priority = i; - }); - }; - - ctrl.dragStart = function (index) { - ctrl.dragStartIndex = index; - }; - - ctrl.removeAttribute = function (val, index) { - $rootScope.showConfirm( - ctrl, - "removeAttributeConfirmed", - [val, index], - null, - "Remove Field", - "Deleted data will not able to recover, are you sure you want to delete this item?" - ); - }; - ctrl.removeAttributeConfirmed = async function (val, index) { - if (val.id) { - $rootScope.isBusy = true; - var result = await columnService.delete([val.id]); - if (result.isSucceed) { - ctrl.additionalData.columns.splice(index, 1); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(result.errors); - $rootScope.isBusy = false; - $scope.$apply(); + isSucceed: false, + errors: [error.statusText || error.status], + }; } - } else { - ctrl.additionalData.columns.splice(index, 1); - } + ); }; }, ], + bindings: {}, }); modules.component("mixDatabaseDataFilter", { @@ -10168,6 +10059,116 @@ modules.component("mixDatabaseDataFilter", { ], }); +modules.component("mixDatabaseColumn", { + templateUrl: + "/mix-app/views/app-portal/components/mix-database-column/view.html", + bindings: { + column: "=", + }, + controller: [ + "$rootScope", + "$scope", + "RestMixDatabaseColumnPortalService", + function ($rootScope, $scope, columnService) { + var ctrl = this; + ctrl.value = {}; + ctrl.column = { + dataType: "Text", + mixDatabaseName: "sys_additional_column", + mixDatabaseId: 6, + }; + ctrl.selectedCol = null; + ctrl.localizeSettings = $rootScope.globalSettings; + ctrl.$onInit = async function () {}; + ctrl.addAttr = async function () { + if (ctrl.column.name) { + var current = $rootScope.findObjectByKey( + ctrl.additionalData.columns, + "name", + ctrl.column.name + ); + if (current) { + $rootScope.showErrors(["Field " + ctrl.column.name + " existed!"]); + } else { + ctrl.column.priority = ctrl.additionalData.columns.length + 1; + $rootScope.isBusy = true; + var saveField = await columnService.create(ctrl.column); + $rootScope.isBusy = false; + if (saveField.isSucceed) { + ctrl.additionalData.columns.push(saveField.data); + + //reset column option + ctrl.column.title = ""; + ctrl.column.name = ""; + ctrl.column.dataType = "Text"; + $scope.$apply(); + } + } + } else { + $rootScope.showErrors(["Please add column Name"]); + } + }; + + ctrl.generateName = function (col) { + col.name = $rootScope.generateKeyword(col.title, "_"); + }; + ctrl.showReferences = function (col) { + ctrl.colRef = col; + $("#modal-navs").modal("show"); + }; + ctrl.referenceCallback = function (selected) { + if (selected && selected.length) { + ctrl.colRef.reference = selected; + ctrl.colRef.referenceId = selected[0].id; + } + $("#modal-navs").modal("hide"); + }; + ctrl.updateOrders = function (index) { + if (index > ctrl.dragStartIndex) { + ctrl.columns.splice(ctrl.dragStartIndex, 1); + } else { + ctrl.columns.splice(ctrl.dragStartIndex + 1, 1); + } + angular.forEach(ctrl.columns, function (e, i) { + e.priority = i; + }); + }; + + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + }; + + ctrl.removeAttribute = function (val, index) { + $rootScope.showConfirm( + ctrl, + "removeAttributeConfirmed", + [val, index], + null, + "Remove Field", + "Deleted data will not able to recover, are you sure you want to delete this item?" + ); + }; + ctrl.removeAttributeConfirmed = async function (val, index) { + if (val.id) { + $rootScope.isBusy = true; + var result = await columnService.delete([val.id]); + if (result.isSucceed) { + ctrl.additionalData.columns.splice(index, 1); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(result.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + } else { + ctrl.additionalData.columns.splice(index, 1); + } + }; + }, + ], +}); + modules.component("mixDatabaseDataValueEditor", { templateUrl: "/mix-app/views/app-portal/components/mix-database-data-value-editor/view.html", @@ -10485,49 +10486,200 @@ modules.component("mixDatabaseDataValues", { ctrl.delete = function (data) { ctrl.onDelete({ data: data }); }; - - ctrl.filterData = function (item, attributeName) { - return $rootScope.findObjectByKey( - item.data, - "attributeName", - attributeName + + ctrl.filterData = function (item, attributeName) { + return $rootScope.findObjectByKey( + item.data, + "attributeName", + attributeName + ); + }; + + ctrl.dragStart = function (index) { + ctrl.dragStartIndex = index; + ctrl.minPriority = ctrl.data[0].priority; + }; + ctrl.updateOrders = function (index, items) { + if (index > ctrl.dragStartIndex) { + ctrl.data.splice(ctrl.dragStartIndex, 1); + } else { + ctrl.data.splice(ctrl.dragStartIndex + 1, 1); + } + ctrl.updateDataInfos(); + }; + ctrl.updateDataInfos = async function () { + angular.forEach(ctrl.data, async function (e, i) { + e.priority = ctrl.minPriority + i; + var resp = await dataService.saveFields(e.id, { + priority: e.priority, + }); + if (resp && resp.isSucceed) { + $scope.activedPage = resp.data; + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + } + } + }); + }; + + ctrl.view = function (item) { + var obj = { + columns: ctrl.columns, + item: item, + }; + $rootScope.preview("mix-database-data", obj, null, "modal-lg"); + }; + }, + ], +}); + +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.localizeSettings = $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("Failed"); + } + $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('/portal/mix-database-data/details?dataId='+ 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.isSucceed) { + ctrl.selected.dataId = 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.isSucceed) { + 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("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.isSucceed) { + $rootScope.removeObjectByKey(ctrl.data, "id", nav.id); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }; ctrl.dragStart = function (index) { ctrl.dragStartIndex = index; ctrl.minPriority = ctrl.data[0].priority; }; - ctrl.updateOrders = function (index, items) { + ctrl.updateOrders = function (index) { if (index > ctrl.dragStartIndex) { ctrl.data.splice(ctrl.dragStartIndex, 1); } else { ctrl.data.splice(ctrl.dragStartIndex + 1, 1); } - ctrl.updateDataInfos(); - }; - ctrl.updateDataInfos = async function () { - angular.forEach(ctrl.data, async function (e, i) { + var arrNavs = []; + angular.forEach(ctrl.data, function (e, i) { e.priority = ctrl.minPriority + i; - var resp = await dataService.saveFields(e.id, { + var keys = { + parentId: e.parentId, + parentType: e.parentType, + id: e.id, + }; + var properties = { priority: e.priority, + }; + arrNavs.push({ + keys: keys, + properties: properties, }); - if (resp && resp.isSucceed) { - $scope.activedPage = resp.data; - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - } - } }); - }; - - ctrl.view = function (item) { - var obj = { - columns: ctrl.columns, - item: item, - }; - $rootScope.preview("mix-database-data", obj, null, "modal-lg"); + navService.saveProperties("portal", arrNavs).then((resp) => { + $rootScope.isBusy = false; + $scope.$apply(); + }); }; }, ], @@ -10697,194 +10849,43 @@ modules.component("mixDatabaseForm", { } if (isValid && column.isEncrypt) { ctrl.mixDatabaseData.obj[column.name] = $rootScope.encrypt( - ctrl.mixDatabaseData.obj[column.name] - ); - } - }); - return isValid; - }; - ctrl.showContentFilter = function ($event) { - $rootScope.showContentFilter(ctrl.loadSelectedLink); - }; - ctrl.loadSelectedLink = function (data, type) { - if (data) { - ctrl.mixDatabaseData.obj.target_id = data.id; - ctrl.mixDatabaseData.obj.title = data.title; - ctrl.mixDatabaseData.obj.type = type; - ctrl.mixDatabaseData.obj.uri = data.detailsUrl; - } - }; - ctrl.filterData = function (attributeName) { - if (ctrl.mixDatabaseData) { - var attr = $rootScope.findObjectByKey( - ctrl.mixDatabaseData.obj, - "mixDatabaseColumnName", - attributeName - ); - if (!attr) { - attr = angular.copy( - $rootScope.findObjectByKey( - ctrl.defaultData.data, - "mixDatabaseColumnName", - attributeName - ) - ); - mixDatabaseColumn; - ctrl.mixDatabaseData.obj.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.localizeSettings = $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("Failed"); - } - $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('/portal/mix-database-data/details?dataId='+ 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.isSucceed) { - ctrl.selected.dataId = 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.isSucceed) { - 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("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.isSucceed) { - $rootScope.removeObjectByKey(ctrl.data, "id", nav.id); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $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(); + ctrl.mixDatabaseData.obj[column.name] + ); + } }); + return isValid; + }; + ctrl.showContentFilter = function ($event) { + $rootScope.showContentFilter(ctrl.loadSelectedLink); + }; + ctrl.loadSelectedLink = function (data, type) { + if (data) { + ctrl.mixDatabaseData.obj.target_id = data.id; + ctrl.mixDatabaseData.obj.title = data.title; + ctrl.mixDatabaseData.obj.type = type; + ctrl.mixDatabaseData.obj.uri = data.detailsUrl; + } + }; + ctrl.filterData = function (attributeName) { + if (ctrl.mixDatabaseData) { + var attr = $rootScope.findObjectByKey( + ctrl.mixDatabaseData.obj, + "mixDatabaseColumnName", + attributeName + ); + if (!attr) { + attr = angular.copy( + $rootScope.findObjectByKey( + ctrl.defaultData.data, + "mixDatabaseColumnName", + attributeName + ) + ); + mixDatabaseColumn; + ctrl.mixDatabaseData.obj.push(attr); + } + return attr; + } }; }, ], @@ -11250,95 +11251,6 @@ modules.component("mixDatabaseNavs", { ], }); -modules.component("mixFileUpload", { - templateUrl: "/mix-app/views/app-portal/components/mix-file-upload/view.html", - bindings: { - folder: "=?", - accept: "=?", - onFail: "&?", - onSuccess: "&?", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "FileServices", - function ($rootScope, $scope, ngAppSettings, fileService) { - var ctrl = this; - ctrl.mediaFile = {}; - ctrl.isAdmin = $rootScope.isAdmin; - ctrl.mediaNavs = []; - ctrl.$onInit = function () { - ctrl.id = Math.floor(Math.random() * 100); - }; - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - const file = files[0]; - ctrl.file = file; - ctrl.mediaFile.folder = ctrl.folder ? ctrl.folder : "Media"; - ctrl.mediaFile.title = ctrl.title ? ctrl.title : ""; - ctrl.mediaFile.description = ctrl.description ? ctrl.description : ""; - ctrl.mediaFile.file = file; - if (ctrl.auto == "true") { - ctrl.uploadFile(file); - } else { - ctrl.getBase64(file); - } - } - }; - - ctrl.getBase64 = function (file) { - if (file !== null) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = function () { - if (ctrl.mediaFile) { - ctrl.mediaFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - ctrl.mediaFile.fileStream = reader.result; - } - $rootScope.isBusy = false; - $scope.$apply(); - }; - reader.onerror = function (error) { - $rootScope.isBusy = false; - $rootScope.showErrors([error]); - }; - } else { - return null; - } - }; - - ctrl.uploadFile = async function () { - if (ctrl.file) { - $rootScope.isBusy = true; - var response = await fileService.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"]); - } - }; - }, - ], -}); - "use strict"; app.controller("MixNavigationController", [ "$scope", @@ -11460,6 +11372,95 @@ app.controller("MixNavigationController", [ }, ]); +modules.component("mixFileUpload", { + templateUrl: "/mix-app/views/app-portal/components/mix-file-upload/view.html", + bindings: { + folder: "=?", + accept: "=?", + onFail: "&?", + onSuccess: "&?", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "FileServices", + function ($rootScope, $scope, ngAppSettings, fileService) { + var ctrl = this; + ctrl.mediaFile = {}; + ctrl.isAdmin = $rootScope.isAdmin; + ctrl.mediaNavs = []; + ctrl.$onInit = function () { + ctrl.id = Math.floor(Math.random() * 100); + }; + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + const file = files[0]; + ctrl.file = file; + ctrl.mediaFile.folder = ctrl.folder ? ctrl.folder : "Media"; + ctrl.mediaFile.title = ctrl.title ? ctrl.title : ""; + ctrl.mediaFile.description = ctrl.description ? ctrl.description : ""; + ctrl.mediaFile.file = file; + if (ctrl.auto == "true") { + ctrl.uploadFile(file); + } else { + ctrl.getBase64(file); + } + } + }; + + ctrl.getBase64 = function (file) { + if (file !== null) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function () { + if (ctrl.mediaFile) { + ctrl.mediaFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.mediaFile.fileStream = reader.result; + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + reader.onerror = function (error) { + $rootScope.isBusy = false; + $rootScope.showErrors([error]); + }; + } else { + return null; + } + }; + + ctrl.uploadFile = async function () { + if (ctrl.file) { + $rootScope.isBusy = true; + var response = await fileService.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"]); + } + }; + }, + ], +}); + modules.component("mixSelectIcons", { templateUrl: "/mix-app/views/app-portal/components/mix-select-icons/mix-select-icons.html", @@ -11564,14 +11565,74 @@ modules.component("mixTemplateEditor", { } } }; - ctrl.updateTemplateContent = function (content) { - ctrl.template.content = content; + ctrl.updateTemplateContent = function (content) { + ctrl.template.content = content; + }; + ctrl.updateStyleContent = function (content) { + ctrl.template.scripts = content; + }; + ctrl.updateScriptContent = function (content) { + ctrl.template.styles = content; + }; + }, + ], +}); + +modules.component("modalBookmark", { + templateUrl: + "/mix-app/views/app-portal/components/modal-bookmark/modal-bookmark.html", + controller: [ + "$rootScope", + "$scope", + "localStorageService", + "$routeParams", + "$location", + function ( + $rootScope, + $scope, + localStorageService, + $routeParams, + $location + ) { + var ctrl = this; + ctrl.searchText = ""; + ctrl.defaultModel = { + url: "", + title: "", + }; + ctrl.bookmarks = []; + ctrl.model = null; + ctrl.$onInit = function () { + ctrl.model = angular.copy(ctrl.defaultModel); + ctrl.getCurrentUrl(); + ctrl.bookmarks = localStorageService.get("bookmarks") || []; + }; + ctrl.goToPath = function (url) { + $rootScope.goToPath(url); + $("#dlg-bookmark").modal("hide"); }; - ctrl.updateStyleContent = function (content) { - ctrl.template.scripts = content; + ctrl.getCurrentUrl = function (url) { + url = url || $location.url(); + ctrl.model.url = url; + ctrl.model.title = url; }; - ctrl.updateScriptContent = function (content) { - ctrl.template.styles = content; + ctrl.removeBookmark = function (url) { + $rootScope.removeObjectByKey(ctrl.bookmarks, "url", url); + localStorageService.set("bookmarks", ctrl.bookmarks); + }; + ctrl.addBookmark = function () { + var current = $rootScope.findObjectByKey( + ctrl.bookmarks, + "url", + ctrl.model.url + ); + if (current) { + current.title = ctrl.model.title; + } else { + ctrl.bookmarks.push(ctrl.model); + } + localStorageService.set("bookmarks", ctrl.bookmarks); + ctrl.model = angular.copy(ctrl.defaultModel); }; }, ], @@ -11692,252 +11753,54 @@ modules.component("modalContentFilter", { $scope.$apply(); } }; - ctrl.loadPages = async function () { - $rootScope.isBusy = true; - var response = await pageService.getList(ctrl.request); - if (response.isSucceed) { - ctrl.data = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - ctrl.select = function (nav) { - var current = $rootScope.findObjectByKey(ctrl.data.items, "id", nav.id); - if (!nav.isActive && ctrl.callback) { - ctrl.callback({ - nav: nav, - type: ctrl.type, - }); - } - if (ctrl.isMultiple) { - current.isActive = !current.isActive; - } else { - if (!nav.isActive) { - angular.forEach(ctrl.data.items, (element) => { - element.isActive = false; - }); - } - current.isActive = !nav.isActive; - } - }; - ctrl.saveSelected = function () { - ctrl.selected = $rootScope.filterArray( - ctrl.data, - ["isActived"], - [true] - ); - setTimeout(() => { - ctrl.save().then(() => { - ctrl.loadPosts(); - }); - }, 500); - }; - ctrl.limString = function (str, max) { - if (str) { - return str.length > max ? str.substring(0, max) + " ..." : str; - } - }; - }, - ], -}); - -modules.component("modalNavDatas", { - templateUrl: "/mix-app/views/app-portal/components/modal-nav-datas/view.html", - bindings: { - mixDatabaseId: "=?", - mixDatabaseName: "=?", - parentId: "=?", - parentType: "=?", - type: "=?", - columnDisplay: "=?", - selectedList: "=?", - selectCallback: "&", - save: "&", - }, - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "RestMixDatabaseDataPortalService", - "RestRelatedMixDatabasePortalService", - function ($rootScope, $scope, ngAppSettings, service, navService) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.request.key = "readData"; - ctrl.navs = []; - - ctrl.queries = {}; - ctrl.data = { items: [] }; - ctrl.$onInit = function () { - if (!ctrl.selectedList) { - ctrl.selectedList = []; - } - if (ctrl.mixDatabaseId) { - ctrl.request.query = "mixDatabaseId=" + ctrl.mixDatabaseId; - } - if (ctrl.mixDatabaseName) { - ctrl.request.query += "&mixDatabaseName=" + ctrl.mixDatabaseName; - } - }; - 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.query = "mixDatabaseId=" + ctrl.mixDatabaseId; - } - if (ctrl.mixDatabaseName) { - ctrl.request.query += "&mixDatabaseName=" + ctrl.mixDatabaseName; - } - Object.keys(ctrl.queries).forEach((e) => { - if (ctrl.queries[e]) { - ctrl.request.query += "&" + e + "=" + ctrl.queries[e]; - } - }); - var response = await service.getList(ctrl.request); - if (response.isSucceed) { - ctrl.data = response.data; - ctrl.navs = []; - angular.forEach(response.data.items, function (e) { - e.disabled = - $rootScope.findObjectByKey(ctrl.selectedList, "id", e.id) != null; - // var item = { - // priority: e.priority, - // description: e.data.title, - // postId: 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.select = function (value, isSelected) { - if (isSelected) { - if (ctrl.parentId) { - var nav = { - mixDatabaseName: ctrl.mixDatabaseName, - parentId: ctrl.parentId, - parentType: ctrl.parentType, - id: value, - }; - navService.save(nav).then((resp) => { - if (resp.isSucceed) { - var current = $rootScope.findObjectByKey( - ctrl.selectedList, - "id", - data.id - ); - if (!current) { - data.disabled = true; - ctrl.selectedList.push(data); - } - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }); - } else { - var current = $rootScope.findObjectByKey( - ctrl.selectedList, - "id", - data.id - ); - if (!current) { - data.disabled = true; - ctrl.selectedList.push(data); - } - } - } else { - if (ctrl.parentId) { - navService - .delete([ctrl.parentId, ctrl.parentType, data.id]) - .then((resp) => { - if (resp.isSucceed) { - data.disabled = false; - var tmp = $rootScope.findObjectByKey( - ctrl.data.items, - "id", - data.id - ); - if (tmp) { - tmp.disabled = false; - } - $rootScope.removeObjectByKey( - ctrl.selectedList, - "id", - data.id - ); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); - } - }); - } else { - data.disabled = false; - var tmp = $rootScope.findObjectByKey( - ctrl.data.items, - "id", - data.id - ); - if (tmp) { - tmp.disabled = false; - } - $rootScope.removeObjectByKey(ctrl.selectedList, "id", data.id); - } - } - if (ctrl.selectCallback) { - ctrl.selectCallback({ data: data }); + ctrl.loadPages = async function () { + $rootScope.isBusy = true; + var response = await pageService.getList(ctrl.request); + if (response.isSucceed) { + ctrl.data = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); } }; - ctrl.createData = function () { - var data = { - title: ctrl.newTitle, - slug: $rootScope.generateKeyword(ctrl.newTitle, "-"), - type: ctrl.type, - }; - service.saveByName(ctrl.mixDatabaseName, data).then((resp) => { - if (resp.isSucceed) { - ctrl.data.items.push(resp.data); - $rootScope.showMessage("success", "success"); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showMessage("failed"); - $rootScope.isBusy = false; - $scope.$apply(); + ctrl.select = function (nav) { + var current = $rootScope.findObjectByKey(ctrl.data.items, "id", nav.id); + if (!nav.isActive && ctrl.callback) { + ctrl.callback({ + nav: nav, + type: ctrl.type, + }); + } + if (ctrl.isMultiple) { + current.isActive = !current.isActive; + } else { + if (!nav.isActive) { + angular.forEach(ctrl.data.items, (element) => { + element.isActive = false; + }); } - }); + current.isActive = !nav.isActive; + } + }; + ctrl.saveSelected = function () { + ctrl.selected = $rootScope.filterArray( + ctrl.data, + ["isActived"], + [true] + ); + setTimeout(() => { + ctrl.save().then(() => { + ctrl.loadPosts(); + }); + }, 500); + }; + ctrl.limString = function (str, max) { + if (str) { + return str.length > max ? str.substring(0, max) + " ..." : str; + } }; }, ], @@ -12078,30 +11941,6 @@ modules.component("mixValueEditor", { ], }); -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", @@ -12220,81 +12059,243 @@ modules.component("modalHelper", { defaultUrl + "/basic-usage-configuration" ); } - if (portalUrl.startsWith("/portal/my-profile")) { - ctrl.trustedUrl = $sce.trustAsResourceUrl( - defaultUrl + "/basic-usage-users-profile" - ); + if (portalUrl.startsWith("/portal/my-profile")) { + ctrl.trustedUrl = $sce.trustAsResourceUrl( + defaultUrl + "/basic-usage-users-profile" + ); + } + + // switch (portalUrl) { + // case '/portal': + // default: + // ctrl.trustedUrl = $sce.trustAsResourceUrl(defaultUrl); + // break; + // } + }; + }, + ], +}); + +modules.component("modalNavDatas", { + templateUrl: "/mix-app/views/app-portal/components/modal-nav-datas/view.html", + bindings: { + mixDatabaseId: "=?", + mixDatabaseName: "=?", + parentId: "=?", + parentType: "=?", + type: "=?", + columnDisplay: "=?", + selectedList: "=?", + selectCallback: "&", + save: "&", + }, + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "RestMixDatabaseDataPortalService", + "RestRelatedMixDatabasePortalService", + function ($rootScope, $scope, ngAppSettings, service, navService) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.request.key = "readData"; + ctrl.navs = []; + + ctrl.queries = {}; + ctrl.data = { items: [] }; + ctrl.$onInit = function () { + if (!ctrl.selectedList) { + ctrl.selectedList = []; + } + if (ctrl.mixDatabaseId) { + ctrl.request.query = "mixDatabaseId=" + ctrl.mixDatabaseId; + } + if (ctrl.mixDatabaseName) { + ctrl.request.query += "&mixDatabaseName=" + ctrl.mixDatabaseName; + } + }; + 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.query = "mixDatabaseId=" + ctrl.mixDatabaseId; + } + if (ctrl.mixDatabaseName) { + ctrl.request.query += "&mixDatabaseName=" + ctrl.mixDatabaseName; + } + Object.keys(ctrl.queries).forEach((e) => { + if (ctrl.queries[e]) { + ctrl.request.query += "&" + e + "=" + ctrl.queries[e]; + } + }); + var response = await service.getList(ctrl.request); + if (response.isSucceed) { + ctrl.data = response.data; + ctrl.navs = []; + angular.forEach(response.data.items, function (e) { + e.disabled = + $rootScope.findObjectByKey(ctrl.selectedList, "id", e.id) != null; + // var item = { + // priority: e.priority, + // description: e.data.title, + // postId: 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.select = function (value, isSelected) { + if (isSelected) { + if (ctrl.parentId) { + var nav = { + mixDatabaseName: ctrl.mixDatabaseName, + parentId: ctrl.parentId, + parentType: ctrl.parentType, + id: value, + }; + navService.save(nav).then((resp) => { + if (resp.isSucceed) { + var current = $rootScope.findObjectByKey( + ctrl.selectedList, + "id", + data.id + ); + if (!current) { + data.disabled = true; + ctrl.selectedList.push(data); + } + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }); + } else { + var current = $rootScope.findObjectByKey( + ctrl.selectedList, + "id", + data.id + ); + if (!current) { + data.disabled = true; + ctrl.selectedList.push(data); + } + } + } else { + if (ctrl.parentId) { + navService + .delete([ctrl.parentId, ctrl.parentType, data.id]) + .then((resp) => { + if (resp.isSucceed) { + data.disabled = false; + var tmp = $rootScope.findObjectByKey( + ctrl.data.items, + "id", + data.id + ); + if (tmp) { + tmp.disabled = false; + } + $rootScope.removeObjectByKey( + ctrl.selectedList, + "id", + data.id + ); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }); + } else { + data.disabled = false; + var tmp = $rootScope.findObjectByKey( + ctrl.data.items, + "id", + data.id + ); + if (tmp) { + tmp.disabled = false; + } + $rootScope.removeObjectByKey(ctrl.selectedList, "id", data.id); + } + } + if (ctrl.selectCallback) { + ctrl.selectCallback({ data: data }); } - - // switch (portalUrl) { - // case '/portal': - // default: - // ctrl.trustedUrl = $sce.trustAsResourceUrl(defaultUrl); - // break; - // } + }; + ctrl.createData = function () { + var data = { + title: ctrl.newTitle, + slug: $rootScope.generateKeyword(ctrl.newTitle, "-"), + type: ctrl.type, + }; + service.saveByName(ctrl.mixDatabaseName, data).then((resp) => { + if (resp.isSucceed) { + ctrl.data.items.push(resp.data); + $rootScope.showMessage("success", "success"); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showMessage("failed"); + $rootScope.isBusy = false; + $scope.$apply(); + } + }); }; }, ], }); -modules.component("modalBookmark", { - templateUrl: - "/mix-app/views/app-portal/components/modal-bookmark/modal-bookmark.html", - controller: [ - "$rootScope", - "$scope", - "localStorageService", - "$routeParams", - "$location", - function ( - $rootScope, - $scope, - localStorageService, - $routeParams, - $location - ) { - var ctrl = this; - ctrl.searchText = ""; - ctrl.defaultModel = { - url: "", - title: "", - }; - ctrl.bookmarks = []; - ctrl.model = null; - ctrl.$onInit = function () { - ctrl.model = angular.copy(ctrl.defaultModel); - ctrl.getCurrentUrl(); - ctrl.bookmarks = localStorageService.get("bookmarks") || []; - }; - ctrl.goToPath = function (url) { - $rootScope.goToPath(url); - $("#dlg-bookmark").modal("hide"); - }; - ctrl.getCurrentUrl = function (url) { - url = url || $location.url(); - ctrl.model.url = url; - ctrl.model.title = url; - }; - ctrl.removeBookmark = function (url) { - $rootScope.removeObjectByKey(ctrl.bookmarks, "url", url); - localStorageService.set("bookmarks", ctrl.bookmarks); - }; - ctrl.addBookmark = function () { - var current = $rootScope.findObjectByKey( - ctrl.bookmarks, - "url", - ctrl.model.url - ); - if (current) { - current.title = ctrl.model.title; - } else { - ctrl.bookmarks.push(ctrl.model); - } - localStorageService.set("bookmarks", ctrl.bookmarks); - ctrl.model = angular.copy(ctrl.defaultModel); - }; - }, - ], +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("modalNavMetas", { @@ -12565,10 +12566,11 @@ modules.component("modalNavMetas", { ], }); -modules.component("modalNavPages", { - templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", +modules.component("modalNavPosts", { + templateUrl: + "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", bindings: { - srcField: "=", + srcColumn: "=", srcId: "=", query: "=", selected: "=", @@ -12577,15 +12579,16 @@ modules.component("modalNavPages", { controller: [ "$rootScope", "$scope", + "$routeParams", "ngAppSettings", - "PageRestService", - function ($rootScope, $scope, ngAppSettings, pageService) { + "PostRestService", + function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { var ctrl = this; ctrl.request = angular.copy(ngAppSettings.request); ctrl.navs = []; ctrl.data = { items: [] }; - ctrl.loadData = async function (pageIndex) { - ctrl.request.query = ctrl.query + ctrl.srcId; + ctrl.loadPosts = async function (pageIndex) { + // ctrl.request.query = ctrl.query + ctrl.srcId; if (pageIndex !== undefined) { ctrl.request.pageIndex = pageIndex; } @@ -12597,7 +12600,12 @@ modules.component("modalNavPages", { var d = new Date(ctrl.request.toDate); ctrl.request.toDate = d.toISOString(); } - var response = await pageService.getList(ctrl.request); + if ($routeParams.type) { + ctrl.request.postType = $routeParams.type; + } else { + ctrl.request.postType = ""; + } + var response = await postService.getList(ctrl.request); if (response.isSucceed) { ctrl.data = response.data; ctrl.navs = []; @@ -12605,13 +12613,14 @@ modules.component("modalNavPages", { var item = { priority: e.priority, description: e.title, - pageId: e.id, + postId: e.id, image: e.thumbnailUrl, specificulture: e.specificulture, + post: e, status: "Published", isActived: false, }; - item[ctrl.srcField] = ctrl.srcId; + item[ctrl.srcColumn] = ctrl.srcId; ctrl.navs.push(item); }); $rootScope.isBusy = false; @@ -12630,7 +12639,7 @@ modules.component("modalNavPages", { ); setTimeout(() => { ctrl.save().then(() => { - ctrl.loadPages(); + ctrl.loadPosts(); }); }, 500); }; @@ -12638,11 +12647,10 @@ modules.component("modalNavPages", { ], }); -modules.component("modalNavPosts", { - templateUrl: - "/mix-app/views/app-portal/components/modal-nav-posts/modal-nav-posts.html", +modules.component("modalNavPages", { + templateUrl: "/mix-app/views/app-portal/components/modal-nav-pages/view.html", bindings: { - srcColumn: "=", + srcField: "=", srcId: "=", query: "=", selected: "=", @@ -12651,16 +12659,15 @@ modules.component("modalNavPosts", { controller: [ "$rootScope", "$scope", - "$routeParams", "ngAppSettings", - "PostRestService", - function ($rootScope, $scope, $routeParams, ngAppSettings, postService) { + "PageRestService", + function ($rootScope, $scope, ngAppSettings, pageService) { var ctrl = this; ctrl.request = angular.copy(ngAppSettings.request); ctrl.navs = []; ctrl.data = { items: [] }; - ctrl.loadPosts = async function (pageIndex) { - // ctrl.request.query = ctrl.query + ctrl.srcId; + ctrl.loadData = async function (pageIndex) { + ctrl.request.query = ctrl.query + ctrl.srcId; if (pageIndex !== undefined) { ctrl.request.pageIndex = pageIndex; } @@ -12672,12 +12679,7 @@ modules.component("modalNavPosts", { var d = new Date(ctrl.request.toDate); ctrl.request.toDate = d.toISOString(); } - if ($routeParams.type) { - ctrl.request.postType = $routeParams.type; - } else { - ctrl.request.postType = ""; - } - var response = await postService.getList(ctrl.request); + var response = await pageService.getList(ctrl.request); if (response.isSucceed) { ctrl.data = response.data; ctrl.navs = []; @@ -12685,14 +12687,13 @@ modules.component("modalNavPosts", { var item = { priority: e.priority, description: e.title, - postId: e.id, + pageId: e.id, image: e.thumbnailUrl, specificulture: e.specificulture, - post: e, status: "Published", isActived: false, }; - item[ctrl.srcColumn] = ctrl.srcId; + item[ctrl.srcField] = ctrl.srcId; ctrl.navs.push(item); }); $rootScope.isBusy = false; @@ -12711,7 +12712,7 @@ modules.component("modalNavPosts", { ); setTimeout(() => { ctrl.save().then(() => { - ctrl.loadPosts(); + ctrl.loadPages(); }); }, 500); }; @@ -12813,93 +12814,42 @@ modules.component("modalNavs", { // 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("modalPermission", { - templateUrl: - "/mix-app/views/app-portal/components/modal-permission/modal-permission.html", - controller: "PermissionController", - bindings: { - message: "=", - }, -}); - -modules.component("modalTemplate", { - templateUrl: "/mix-app/views/app-portal/components/modal-template/view.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - "TemplateService", - function ($rootScope, $scope, ngAppSettings, service) { - var ctrl = this; - ctrl.request = angular.copy(ngAppSettings.request); - ctrl.$onInit = function () { - ctrl.modal = $("#modal-template"); - ctrl.request.status = null; - ctrl.request.pageSize = 10; - ctrl.modal.on("shown.bs.modal", function () { - ctrl.search(); + // 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.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.isSucceed) { - ctrl.data = resp.data; + ctrl.selectChange = function (item) { + if (ctrl.isSingle == "true" && item.isActived) { + angular.forEach(ctrl.data.items, (element) => { + element.isActived = false; + }); + item.isActived = true; } - $rootScope.isBusy = false; - $scope.$apply(); }; - ctrl.edit = function (item) { - let path = `/portal/template/details/${item.themeId}/${item.folderType}/${item.id}`; - ctrl.modal.modal("hide"); - $rootScope.goToPath(path); + ctrl.saveSelected = function () { + ctrl.selected = $rootScope.filterArray( + ctrl.data.items, + ["isActived"], + [true] + ); + if (ctrl.save) { + ctrl.save({ selected: ctrl.selected }); + } }; }, ], @@ -13096,6 +13046,57 @@ modules.component("monacoEditor", { ], }); +modules.component("modalPermission", { + templateUrl: + "/mix-app/views/app-portal/components/modal-permission/modal-permission.html", + controller: "PermissionController", + bindings: { + message: "=", + }, +}); + +modules.component("modalTemplate", { + templateUrl: "/mix-app/views/app-portal/components/modal-template/view.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + "TemplateService", + function ($rootScope, $scope, ngAppSettings, service) { + var ctrl = this; + ctrl.request = angular.copy(ngAppSettings.request); + ctrl.$onInit = function () { + ctrl.modal = $("#modal-template"); + ctrl.request.status = null; + ctrl.request.pageSize = 10; + ctrl.modal.on("shown.bs.modal", function () { + ctrl.search(); + }); + }; + ctrl.search = async function (pageIndex) { + if (ctrl.request.keyword.indexOf("/") > 0) { + let params = ctrl.request.keyword.split("/"); + ctrl.request.folderType = params[0]; + ctrl.request.keyword = params[1]; + } + ctrl.request.pageIndex = pageIndex || ctrl.request.pageIndex; + $rootScope.isBusy = true; + var resp = await service.getList(ctrl.request); + if (resp && resp.isSucceed) { + ctrl.data = resp.data; + } + $rootScope.isBusy = false; + $scope.$apply(); + }; + ctrl.edit = function (item) { + let path = `/portal/template/details/${item.themeId}/${item.folderType}/${item.id}`; + ctrl.modal.modal("hide"); + $rootScope.goToPath(path); + }; + }, + ], +}); + modules.component("navs", { templateUrl: "/mix-app/views/app-portal/components/navigations/navigations.html", @@ -13395,6 +13396,84 @@ modules.component("propertiesValue", { ], }); +modules.component("templateEditor", { + templateUrl: + "/mix-app/views/app-portal/components/template-editor/templateEditor.html", + bindings: { + template: "=", + templates: "=", + folderType: "=", + isReadonly: "=?", + lineCount: "=?", + hideJs: "=?", + hideCss: "=?", + enableRename: "=?", + }, + controller: [ + "$scope", + "$rootScope", + "$routeParams", + "ngAppSettings", + "GlobalSettingsService", + "TemplateService", + function ( + $scope, + $rootScope, + $routeParams, + ngAppSettings, + globalSettingsService, + service + ) { + BaseCtrl.call( + this, + $scope, + $rootScope, + $routeParams, + ngAppSettings, + service + ); + var ctrl = this; + BaseHub.call(this, ctrl); + ctrl.isNull = false; + 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.template && ctrl.templates) { + ctrl.template = ctrl.templates[0]; + } + if (ctrl.folderType && !ctrl.folderType) { + var themeId = globalSettingsService.get("themeId"); + var resp = await service.getSingle([ + "portal", + themeId, + ctrl.folderType, + ]); + if (resp && resp.isSucceed) { + resp.data.fileName = "new"; + ctrl.templates.splice(0, 0, resp.data); + $rootScope.isBusy = false; + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } + } + } + }; + }, + ], +}); + modules.component("serviceHubPortal", { templateUrl: "/mix-app/views/app-portal/components/service-hub-portal/view.html", @@ -13563,84 +13642,6 @@ modules.component("serviceHubPortal", { ], }); -modules.component("templateEditor", { - templateUrl: - "/mix-app/views/app-portal/components/template-editor/templateEditor.html", - bindings: { - template: "=", - templates: "=", - folderType: "=", - isReadonly: "=?", - lineCount: "=?", - hideJs: "=?", - hideCss: "=?", - enableRename: "=?", - }, - controller: [ - "$scope", - "$rootScope", - "$routeParams", - "ngAppSettings", - "GlobalSettingsService", - "TemplateService", - function ( - $scope, - $rootScope, - $routeParams, - ngAppSettings, - globalSettingsService, - service - ) { - BaseCtrl.call( - this, - $scope, - $rootScope, - $routeParams, - ngAppSettings, - service - ); - var ctrl = this; - BaseHub.call(this, ctrl); - ctrl.isNull = false; - 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.template && ctrl.templates) { - ctrl.template = ctrl.templates[0]; - } - if (ctrl.folderType && !ctrl.folderType) { - var themeId = globalSettingsService.get("themeId"); - var resp = await service.getSingle([ - "portal", - themeId, - ctrl.folderType, - ]); - if (resp && resp.isSucceed) { - resp.data.fileName = "new"; - ctrl.templates.splice(0, 0, resp.data); - $rootScope.isBusy = false; - $scope.$apply(); - } else { - if (resp) { - $rootScope.showErrors(resp.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - } - } - }; - }, - ], -}); - modules.component("toastHelper", { templateUrl: "/mix-app/views/app-portal/components/toast-helper/toast-helper.html", diff --git a/src/Mix.Cms.Web/wwwroot/mix-app/js/app-shared.min.js b/src/Mix.Cms.Web/wwwroot/mix-app/js/app-shared.min.js index 1500c44f9..b76664d63 100644 --- a/src/Mix.Cms.Web/wwwroot/mix-app/js/app-shared.min.js +++ b/src/Mix.Cms.Web/wwwroot/mix-app/js/app-shared.min.js @@ -2907,16 +2907,6 @@ appShared.factory("RestMixDatabaseColumnPortalService", [ }, ]); -"use strict"; -appShared.factory("RestMixDatabaseDataValuePortalService", [ - "BaseRestService", - function (baseService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-database-data-value/portal"); - return serviceFactory; - }, -]); - "use strict"; appShared.factory("RestMixDatabaseDataClientService", [ "BaseRestService", @@ -3050,24 +3040,11 @@ appShared.factory("RestMixDatabaseDataPortalService", [ ]); "use strict"; -appShared.factory("RestMvcPostService", [ +appShared.factory("RestMixDatabaseDataValuePortalService", [ "BaseRestService", function (baseService) { var serviceFactory = Object.create(baseService); - serviceFactory.init("mix-post/mvc"); - // Define more service methods here - return serviceFactory; - }, -]); - -"use strict"; -appShared.factory("RestRelatedMixDatabasePortalService", [ - "BaseRestService", - "ApiService", - "CommonService", - function (baseService, apiService, commonService) { - var serviceFactory = Object.create(baseService); - serviceFactory.init("related-mix-database/portal"); + serviceFactory.init("mix-database-data-value/portal"); return serviceFactory; }, ]); @@ -3091,6 +3068,17 @@ appShared.factory("RestMvcModuleDataService", [ }, ]); +"use strict"; +appShared.factory("RestMvcPostService", [ + "BaseRestService", + function (baseService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("mix-post/mvc"); + // Define more service methods here + return serviceFactory; + }, +]); + "use strict"; appShared.factory("RestRelatedAttributeDataFormService", [ "BaseRestService", @@ -3113,6 +3101,18 @@ appShared.factory("RestRelatedAttributeDataPortalService", [ }, ]); +"use strict"; +appShared.factory("RestRelatedMixDatabasePortalService", [ + "BaseRestService", + "ApiService", + "CommonService", + function (baseService, apiService, commonService) { + var serviceFactory = Object.create(baseService); + serviceFactory.init("related-mix-database/portal"); + return serviceFactory; + }, +]); + "use strict"; function BaseCtrl($scope, $rootScope, $routeParams, ngAppSettings, service) { @@ -4263,7 +4263,7 @@ appShared.controller("MixDataController", [ saveResult, ]); } else { - alert(errMsg); + console.error(saveResult.errors); } } if ($scope.loadingHandler) { @@ -4521,6 +4521,86 @@ sharedComponents.controller("AddressEditorController", [ }, ]); +sharedComponents.component("apiFile", { + templateUrl: "/mix-app/views/app-shared/components/api-file/api-file.html", + controller: [ + "$rootScope", + "$scope", + "Upload", + function PortalTemplateController($rootScope, $scope, uploader) { + var ctrl = this; + ctrl.accept = ctrl.accept || "application/zip"; + ctrl.selectFile = function (files) { + if (files !== undefined && files !== null && files.length > 0) { + const file = files[0]; + ctrl.postedFile = file; + } + }; + + ctrl.uploadFile = function (file) { + // Create FormData object + var files = new FormData(); + var folder = ctrl.folder; + var title = ctrl.title; + var description = ctrl.description; + // Looping over all files and add it to FormData object + files.append(file.name, file); + + // Adding one more key to FormData object + files.append("fileFolder", folder); + files.append("title", title); + files.append("description", description); + $.ajax({ + url: "/" + $rootScope.localizeSettings.lang + "/media/upload", //'/tts/UploadImage', + type: "POST", + contentType: false, // Not to set any content header + processData: false, // Not to process data + data: files, + success: function (result) { + ctrl.src = result.data.fullPath; + $scope.$apply(); + }, + error: function (err) { + return ""; + }, + }); + }; + ctrl.getBase64 = function (file) { + if (file !== null) { + $rootScope.isBusy = true; + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function () { + var index = reader.result.indexOf(",") + 1; + var base64 = reader.result.substring(index); + ctrl.postedFile.fileName = file.name.substring( + 0, + file.name.lastIndexOf(".") + ); + ctrl.postedFile.extension = file.name.substring( + file.name.lastIndexOf(".") + ); + ctrl.postedFile.fileStream = reader.result; + $rootScope.isBusy = false; + $scope.$apply(); + }; + reader.onerror = function (error) {}; + } else { + return null; + } + }; + }, + ], + bindings: { + header: "=", + accept: "=", + title: "=", + postedFile: "=", + formName: "=", + isBase64: "=", + }, +}); + sharedComponents.component("azureStorage", { templateUrl: "/mix-app/views/app-shared/components/azure-storage/view.html", bindings: { @@ -4629,83 +4709,17 @@ sharedComponents.component("azureStorage", { ], }); -sharedComponents.component("apiFile", { - templateUrl: "/mix-app/views/app-shared/components/api-file/api-file.html", +sharedComponents.component("breadcrumbs", { + templateUrl: + "/mix-app/views/app-shared/components/breadcrumbs/breadcrumbs.html", controller: [ "$rootScope", - "$scope", - "Upload", - function PortalTemplateController($rootScope, $scope, uploader) { + function ($rootScope) { var ctrl = this; - ctrl.accept = ctrl.accept || "application/zip"; - ctrl.selectFile = function (files) { - if (files !== undefined && files !== null && files.length > 0) { - const file = files[0]; - ctrl.postedFile = file; - } - }; - - ctrl.uploadFile = function (file) { - // Create FormData object - var files = new FormData(); - var folder = ctrl.folder; - var title = ctrl.title; - var description = ctrl.description; - // Looping over all files and add it to FormData object - files.append(file.name, file); - - // Adding one more key to FormData object - files.append("fileFolder", folder); - files.append("title", title); - files.append("description", description); - $.ajax({ - url: "/" + $rootScope.localizeSettings.lang + "/media/upload", //'/tts/UploadImage', - type: "POST", - contentType: false, // Not to set any content header - processData: false, // Not to process data - data: files, - success: function (result) { - ctrl.src = result.data.fullPath; - $scope.$apply(); - }, - error: function (err) { - return ""; - }, - }); - }; - ctrl.getBase64 = function (file) { - if (file !== null) { - $rootScope.isBusy = true; - var reader = new FileReader(); - reader.readAsDataURL(file); - reader.onload = function () { - var index = reader.result.indexOf(",") + 1; - var base64 = reader.result.substring(index); - ctrl.postedFile.fileName = file.name.substring( - 0, - file.name.lastIndexOf(".") - ); - ctrl.postedFile.extension = file.name.substring( - file.name.lastIndexOf(".") - ); - ctrl.postedFile.fileStream = reader.result; - $rootScope.isBusy = false; - $scope.$apply(); - }; - reader.onerror = function (error) {}; - } else { - return null; - } - }; }, ], bindings: { - header: "=", - accept: "=", - title: "=", - postedFile: "=", - formName: "=", - isBase64: "=", + breadCrumbs: "=", }, }); @@ -4737,20 +4751,6 @@ sharedComponents.component("checkboxSwitch", { }, }); -sharedComponents.component("breadcrumbs", { - templateUrl: - "/mix-app/views/app-shared/components/breadcrumbs/breadcrumbs.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - }, - ], - bindings: { - breadCrumbs: "=", - }, -}); - sharedComponents.component("cultures", { templateUrl: "/mix-app/views/app-shared/components/cultures/cultures.html", bindings: { @@ -4889,6 +4889,21 @@ sharedComponents.component("customFile", { ], }); +sharedComponents.component("swDataPreview", { + templateUrl: + "/mix-app/views/app-shared/components/data-preview/data-preview.html", + controller: [ + "$rootScope", + function ($rootScope) { + var ctrl = this; + }, + ], + bindings: { + type: "=", + value: "=", + }, +}); + "use trick"; sharedComponents.directive("pane", function () { return { @@ -4931,21 +4946,6 @@ sharedComponents.directive("tabs", function () { }; }); -sharedComponents.component("swDataPreview", { - templateUrl: - "/mix-app/views/app-shared/components/data-preview/data-preview.html", - controller: [ - "$rootScope", - function ($rootScope) { - var ctrl = this; - }, - ], - bindings: { - type: "=", - value: "=", - }, -}); - sharedComponents.component("fbLogin", { templateUrl: "/mix-app/views/app-shared/components/fb-login/view.html", bindings: { @@ -5055,66 +5055,6 @@ sharedComponents.component("goToTop", { bindings: {}, }); -(function (angular) { - appShared.component("languageSwitcher", { - templateUrl: - "/mix-app/views/app-shared/components/language-switcher/language-switcher.html", - controller: [ - "$rootScope", - "$scope", - "$location", - "ApiService", - "CommonService", - "TranslatorService", - "GlobalSettingsService", - function ( - $rootScope, - $scope, - $location, - apiService, - commonService, - translatorService, - globalSettingsService - ) { - var ctrl = this; - ctrl.localizeSettings = {}; - this.$onInit = function () { - ctrl.localizeSettings = $rootScope.localizeSettings; - if ($rootScope.globalSettings) { - ctrl.localizeSettings.cultures = $rootScope.globalSettings.cultures; - } - }; - - ctrl.changeLang = async function (lang, langIcon) { - ctrl.localizeSettings.lang = lang; - ctrl.localizeSettings.langIcon = langIcon; - // await commonService.removeSettings(); - // await commonService.removeTranslator(); - // commonService.fillSettings(lang).then(function () { - // translatorService.reset(lang).then(function () { - commonService.fillAllSettings(lang).then(function (response) { - translatorService.translateUrl(lang).then(function (url) { - window.top.location = url; - }); - }); - // }); - // }); - }; - ctrl.logOut = function () { - $rootScope.logOut(); - }; - }, - ], - bindings: { - //settings: '=', - ulStyle: "=", - liStyle: "=", - aStyle: "=", - activeClass: "=", - }, - }); -})(window.angular); - sharedComponents.component("googlePay", { templateUrl: "/mix-app/views/app-shared/components/google-pay/view.html", bindings: { @@ -5266,6 +5206,118 @@ sharedComponents.component("googlePay", { ], }); +(function (angular) { + appShared.component("languageSwitcher", { + templateUrl: + "/mix-app/views/app-shared/components/language-switcher/language-switcher.html", + controller: [ + "$rootScope", + "$scope", + "$location", + "ApiService", + "CommonService", + "TranslatorService", + "GlobalSettingsService", + function ( + $rootScope, + $scope, + $location, + apiService, + commonService, + translatorService, + globalSettingsService + ) { + var ctrl = this; + ctrl.localizeSettings = {}; + this.$onInit = function () { + ctrl.localizeSettings = $rootScope.localizeSettings; + if ($rootScope.globalSettings) { + ctrl.localizeSettings.cultures = $rootScope.globalSettings.cultures; + } + }; + + ctrl.changeLang = async function (lang, langIcon) { + ctrl.localizeSettings.lang = lang; + ctrl.localizeSettings.langIcon = langIcon; + // await commonService.removeSettings(); + // await commonService.removeTranslator(); + // commonService.fillSettings(lang).then(function () { + // translatorService.reset(lang).then(function () { + commonService.fillAllSettings(lang).then(function (response) { + translatorService.translateUrl(lang).then(function (url) { + window.top.location = url; + }); + }); + // }); + // }); + }; + ctrl.logOut = function () { + $rootScope.logOut(); + }; + }, + ], + bindings: { + //settings: '=', + ulStyle: "=", + liStyle: "=", + aStyle: "=", + activeClass: "=", + }, + }); +})(window.angular); + +sharedComponents.component("limitString", { + templateUrl: + "/mix-app/views/app-shared/components/limit-string/limit-string.html", + controller: [ + "$rootScope", + "$scope", + "ngAppSettings", + function ($rootScope, $scope, ngAppSettings) { + var ctrl = this; + ctrl.shortenString = ""; + ctrl.previousContentId = undefined; + + this.$onInit = () => { + ctrl.previousContentId = angular.copy(ctrl.contentId); + }; + + this.$doCheck = () => { + if (ctrl.contentId !== ctrl.previousContentId) { + ctrl.loadModuleData(); + ctrl.previousContentId = ctrl.contentId; + } + }; + ctrl.shortString = function () { + var data = decodeURIComponent(ctrl.content); + if (data) { + if (ctrl.max < data.length) { + ctrl.shortenString = + data.replace(/[+]/g, " ").substr(0, ctrl.max) + " ..."; + } else { + ctrl.shortenString = data.replace(/[+]/g, " "); + } + } + }; + ctrl.view = function () { + var obj = { + moduleId: ctrl.moduleId, + id: ctrl.contentId, + }; + $rootScope.preview("module-data", obj, null, "modal-lg"); + }; + ctrl.translate = $rootScope.translate; + }, + ], + bindings: { + content: "=", + showData: "=", + max: "=", + moduleId: "=", + contentId: "=", + }, +}); + appShared.component("loginPopup", { templateUrl: "/mix-app/views/app-shared/components/login-popup/view.html", controller: "LoginPopupController", @@ -5315,13 +5367,6 @@ appShared.controller("LoginPopupController", [ }, ]); -sharedComponents.component("message", { - templateUrl: "/mix-app/views/app-shared/components/message/message.html", - bindings: { - message: "=", - }, -}); - appShared.component("mediaNavs", { templateUrl: "/mix-app/views/app-shared/components/media-navs/media-navs.html", @@ -5709,6 +5754,13 @@ sharedComponents.component("medias", { bindings: {}, }); +sharedComponents.component("message", { + templateUrl: "/mix-app/views/app-shared/components/message/message.html", + bindings: { + message: "=", + }, +}); + "use strict"; appShared.controller("MessengerController", [ "$scope", @@ -5976,58 +6028,6 @@ sharedComponents.component("messenger", { }, }); -sharedComponents.component("limitString", { - templateUrl: - "/mix-app/views/app-shared/components/limit-string/limit-string.html", - controller: [ - "$rootScope", - "$scope", - "ngAppSettings", - function ($rootScope, $scope, ngAppSettings) { - var ctrl = this; - ctrl.shortenString = ""; - ctrl.previousContentId = undefined; - - this.$onInit = () => { - ctrl.previousContentId = angular.copy(ctrl.contentId); - }; - - this.$doCheck = () => { - if (ctrl.contentId !== ctrl.previousContentId) { - ctrl.loadModuleData(); - ctrl.previousContentId = ctrl.contentId; - } - }; - ctrl.shortString = function () { - var data = decodeURIComponent(ctrl.content); - if (data) { - if (ctrl.max < data.length) { - ctrl.shortenString = - data.replace(/[+]/g, " ").substr(0, ctrl.max) + " ..."; - } else { - ctrl.shortenString = data.replace(/[+]/g, " "); - } - } - }; - ctrl.view = function () { - var obj = { - moduleId: ctrl.moduleId, - id: ctrl.contentId, - }; - $rootScope.preview("module-data", obj, null, "modal-lg"); - }; - ctrl.translate = $rootScope.translate; - }, - ], - bindings: { - content: "=", - showData: "=", - max: "=", - moduleId: "=", - contentId: "=", - }, -}); - sharedComponents.component("messengerPrivate", { templateUrl: "/mix-app/views/app-shared/components/messenger-private/index.html", @@ -6038,96 +6038,34 @@ sharedComponents.component("messengerPrivate", { }, }); -sharedComponents.component("mixColumnPreview", { +sharedComponents.component("mixColumnEditor", { templateUrl: - "/mix-app/views/app-shared/components/mix-column-preview/view.html", + "/mix-app/views/app-shared/components/mix-column-editor/view.html", bindings: { model: "=", column: "=", - maxLength: "=?", isShowTitle: "=?", inputClass: "=?", + createUrl: "=?", + updateUrl: "=?", + backUrl: "=?", + level: "=?", }, controller: [ "$rootScope", - "$sce", + "$scope", + "$location", + "ngAppSettings", "$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.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("mixColumnEditor", { - templateUrl: - "/mix-app/views/app-shared/components/mix-column-editor/view.html", - bindings: { - model: "=", - column: "=", - isShowTitle: "=?", - inputClass: "=?", - createUrl: "=?", - updateUrl: "=?", - backUrl: "=?", - level: "=?", - }, - controller: [ - "$rootScope", - "$scope", - "$location", - "ngAppSettings", - "$filter", - "ApiService", - function ( - $rootScope, - $scope, - $location, - ngAppSettings, - $filter, - apiService - ) { + "ApiService", + function ( + $rootScope, + $scope, + $location, + ngAppSettings, + $filter, + apiService + ) { var ctrl = this; ctrl.mediaFile = {}; ctrl.icons = ngAppSettings.icons; @@ -6345,6 +6283,68 @@ sharedComponents.component("mixColumnEditor", { ], }); +sharedComponents.component("mixColumnPreview", { + templateUrl: + "/mix-app/views/app-shared/components/mix-column-preview/view.html", + bindings: { + model: "=", + column: "=", + 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.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", @@ -7088,31 +7088,6 @@ sharedComponents.component("mixSelect", { ], }); -// 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("ModalPostController", [ "$scope", @@ -7183,6 +7158,31 @@ 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 ( @@ -7438,6 +7438,30 @@ sharedComponents.controller( } ); +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; + } + }; + }, + ], + bindings: { + data: "=", + datatype: "=?", + width: "=", + header: "=", + }, +}); + "use strict"; appShared.controller("SharedModuleDataController", [ "$scope", @@ -7734,30 +7758,6 @@ appShared.factory("SharedModuleDataService", [ }, ]); -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; - } - }; - }, - ], - bindings: { - data: "=", - datatype: "=?", - width: "=", - header: "=", - }, -}); - sharedComponents.component("moduleForm", { templateUrl: "/mix-app/views/app-shared/components/module-form/view.html", bindings: { @@ -7914,70 +7914,23 @@ sharedComponents.component("moduleForm", { ], }); -sharedComponents.component("modulePreview", { - templateUrl: "/mix-app/views/app-shared/components/module-preview/view.html", +sharedComponents.component("moduleFormEditor", { + templateUrl: + "/mix-app/views/app-shared/components/module-form-editor/view.html", + bindings: { + data: "=", + datatype: "=?", + column: "=?", + inputClass: "=", + isShowTitle: "=", + columnTitle: "=", + }, controller: [ - "$scope", "$rootScope", - "SharedModuleDataService", - function ($scope, $rootScope, moduleDataService) { - var ctrl = this; - $rootScope.isBusy = false; - ctrl.previousContentId = undefined; - - this.$onInit = () => { - ctrl.previousContentId = angular.copy(ctrl.contentId); - }; - - this.$doCheck = () => { - if (ctrl.contentId !== ctrl.previousContentId) { - ctrl.loadModuleData(); - ctrl.previousContentId = ctrl.contentId; - } - }; - - ctrl.loadModuleData = async function () { - $rootScope.isBusy = true; - var response = await moduleDataService.getModuleData( - ctrl.moduleId, - ctrl.contentId, - "portal" - ); - if (response.isSucceed) { - ctrl.data = response.data; - $rootScope.isBusy = false; - $scope.$apply(); - } else { - $rootScope.showErrors(response.errors); - $rootScope.isBusy = false; - $scope.$apply(); - } - }; - }, - ], - bindings: { - moduleId: "=", - contentId: "=", - }, -}); - -sharedComponents.component("moduleFormEditor", { - templateUrl: - "/mix-app/views/app-shared/components/module-form-editor/view.html", - bindings: { - data: "=", - datatype: "=?", - column: "=?", - inputClass: "=", - isShowTitle: "=", - columnTitle: "=", - }, - controller: [ - "$rootScope", - "$scope", - "$filter", - "ngAppSettings", - function ($rootScope, $scope, $filter, ngAppSettings) { + "$scope", + "$filter", + "ngAppSettings", + function ($rootScope, $scope, $filter, ngAppSettings) { var ctrl = this; ctrl.icons = ngAppSettings.icons; this.dataTypes = ngAppSettings.dataTypes; @@ -8036,27 +7989,50 @@ sharedComponents.component("moduleFormEditor", { ], }); -sharedComponents.component("mixPaging", { - templateUrl: "/mix-app/views/app-shared/components/paging/paging.html", +sharedComponents.component("modulePreview", { + templateUrl: "/mix-app/views/app-shared/components/module-preview/view.html", controller: [ + "$scope", "$rootScope", - function ($rootScope) { + "SharedModuleDataService", + function ($scope, $rootScope, moduleDataService) { var ctrl = this; - ctrl.loadData = function (index) { - ctrl.pagingAction({ pageIndex: index }); + $rootScope.isBusy = false; + ctrl.previousContentId = undefined; + + this.$onInit = () => { + ctrl.previousContentId = angular.copy(ctrl.contentId); + }; + + this.$doCheck = () => { + if (ctrl.contentId !== ctrl.previousContentId) { + ctrl.loadModuleData(); + ctrl.previousContentId = ctrl.contentId; + } + }; + + ctrl.loadModuleData = async function () { + $rootScope.isBusy = true; + var response = await moduleDataService.getModuleData( + ctrl.moduleId, + ctrl.contentId, + "portal" + ); + if (response.isSucceed) { + ctrl.data = response.data; + $rootScope.isBusy = false; + $scope.$apply(); + } else { + $rootScope.showErrors(response.errors); + $rootScope.isBusy = false; + $scope.$apply(); + } }; - ctrl.range = $rootScope.range; }, ], bindings: { - data: "=", - activeClass: "=", - ulClass: "=", - page: "=", - pageSize: "=", - total: "=", - totalPage: "=", - pagingAction: "&", + moduleId: "=", + contentId: "=", }, }); @@ -8138,51 +8114,6 @@ sharedComponents.controller("OnePayShoppingCartController", [ }, ]); -"use trick"; -sharedComponents.directive("pill", function () { - return { - require: "^pills", - restrict: "E", - transclude: true, - scope: { header: "@", id: "@", icon: "@" }, - link: function (scope, element, attrs, tabsController) { - tabsController.addPane(scope); - }, - template: - '
' + - "
", - replace: true, - }; -}); - -sharedComponents.directive("pills", function () { - return { - restrict: "E", - transclude: true, - scope: { - selectCallback: "&", - }, - controller: function ($scope, $element) { - var panes = ($scope.panes = []); - - $scope.select = function (pane) { - angular.forEach(panes, function (pane) { - pane.selected = false; - }); - pane.selected = true; - this.selectCallback({ pane: pane }); - }; - - this.addPane = function (pane) { - if (panes.length === 0) $scope.select(pane); - panes.push(pane); - }; - }, - templateUrl: "/mix-app/views/app-shared/components/pills/pills.html", - replace: true, - }; -}); - sharedComponents.component("payPal", { templateUrl: "/mix-app/views/app-shared/components/pay-pal/view.html", bindings: { @@ -8266,6 +8197,75 @@ sharedComponents.component("payPal", { ], }); +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: "&", + }, +}); + +"use trick"; +sharedComponents.directive("pill", function () { + return { + require: "^pills", + restrict: "E", + transclude: true, + scope: { header: "@", id: "@", icon: "@" }, + link: function (scope, element, attrs, tabsController) { + tabsController.addPane(scope); + }, + template: + '
' + + "
", + replace: true, + }; +}); + +sharedComponents.directive("pills", function () { + return { + restrict: "E", + transclude: true, + scope: { + selectCallback: "&", + }, + controller: function ($scope, $element) { + var panes = ($scope.panes = []); + + $scope.select = function (pane) { + angular.forEach(panes, function (pane) { + pane.selected = false; + }); + pane.selected = true; + this.selectCallback({ pane: pane }); + }; + + this.addPane = function (pane) { + if (panes.length === 0) $scope.select(pane); + panes.push(pane); + }; + }, + templateUrl: "/mix-app/views/app-shared/components/pills/pills.html", + replace: true, + }; +}); + sharedComponents.component("portalSearch", { templateUrl: "portal-search.html", bindings: { @@ -8313,43 +8313,43 @@ sharedComponents.component("previewImage", { }, }); -sharedComponents.component("qrCode", { - templateUrl: "/mix-app/views/app-shared/components/qr-code/view.html", +sharedComponents.component("previewPopup", { + templateUrl: + "/mix-app/views/app-shared/components/preview-popup/preview-popup.html", controller: [ "$location", function ($location) { var ctrl = this; - ctrl.$onInit = function () { - if (ctrl.model) { - ctrl.generate(); - } - }; - ctrl.generate = function () { - $("#qr-output").empty(); - $("#qr-output").qrcode(ctrl.model); + ctrl.goToLink = async function (link) { + $("#dlg-preview-popup").modal("hide"); + $location.path(link); }; }, ], bindings: { - model: "=", + previewObject: "=", }, }); -sharedComponents.component("previewPopup", { - templateUrl: - "/mix-app/views/app-shared/components/preview-popup/preview-popup.html", +sharedComponents.component("qrCode", { + templateUrl: "/mix-app/views/app-shared/components/qr-code/view.html", controller: [ "$location", function ($location) { var ctrl = this; - ctrl.goToLink = async function (link) { - $("#dlg-preview-popup").modal("hide"); - $location.path(link); + ctrl.$onInit = function () { + if (ctrl.model) { + ctrl.generate(); + } + }; + ctrl.generate = function () { + $("#qr-output").empty(); + $("#qr-output").qrcode(ctrl.model); }; }, ], bindings: { - previewObject: "=", + model: "=", }, }); @@ -8503,131 +8503,6 @@ sharedComponents.component("recaptcha", { }, }); -sharedComponents.component("shoppingCart", { - templateUrl: "/mix-app/views/app-shared/components/shopping-cart/view.html", - bindings: { - cartData: "=?", - successCallback: "&?", - }, - controller: "ShoppingCartController", -}); -sharedComponents.controller("ShoppingCartController", [ - "$rootScope", - "$scope", - "localStorageService", - "RestMixDatabaseDataClientService", - function ($rootScope, $scope, localStorageService, dataService) { - $scope.submitted = false; - $scope.isShow = false; - $scope.init = function (validateCallback, successCallback, failCallback) { - $scope.validateCallback = validateCallback; - $scope.successCallback = successCallback; - $scope.failCallback = failCallback; - }; - $scope.translate = $rootScope.translate; - - $scope.showShoppingCart = function () { - $scope.cartModal.show(); - }; - $scope.calculate = function () { - $scope.cartData.total = 0; - $scope.cartData.totalItem = $scope.cartData.items.length; - angular.forEach($scope.cartData.items, function (e) { - $scope.cartData.total += parseInt(e.price) * e.quantity; - }); - 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.isSucceed) { - $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("serviceHub", { templateUrl: "/mix-app/views/app-shared/components/service-hub/view.html", bindings: { @@ -8790,26 +8665,151 @@ sharedComponents.component("serviceHub", { } }); - $scope.$apply(); - }; + $scope.$apply(); + }; + + ctrl.removeMember = function (memberId) { + var index = ctrl.members.findIndex((x) => x.id === memberId); + if (index >= 0) { + ctrl.members.splice(index, 1); + } + $scope.$apply(); + }; + + ctrl.newMessage = function (msg) { + ctrl.messages.push(msg); + $scope.$apply(); + // var objDiv = document.getElementsByClassName("widget-conversation")[0]; + // objDiv.scrollTop = objDiv.scrollHeight + 20; + }; + }, + ], +}); + +sharedComponents.component("shoppingCart", { + templateUrl: "/mix-app/views/app-shared/components/shopping-cart/view.html", + bindings: { + cartData: "=?", + successCallback: "&?", + }, + controller: "ShoppingCartController", +}); +sharedComponents.controller("ShoppingCartController", [ + "$rootScope", + "$scope", + "localStorageService", + "RestMixDatabaseDataClientService", + function ($rootScope, $scope, localStorageService, dataService) { + $scope.submitted = false; + $scope.isShow = false; + $scope.init = function (validateCallback, successCallback, failCallback) { + $scope.validateCallback = validateCallback; + $scope.successCallback = successCallback; + $scope.failCallback = failCallback; + }; + $scope.translate = $rootScope.translate; + + $scope.showShoppingCart = function () { + $scope.cartModal.show(); + }; + $scope.calculate = function () { + $scope.cartData.total = 0; + $scope.cartData.totalItem = $scope.cartData.items.length; + angular.forEach($scope.cartData.items, function (e) { + $scope.cartData.total += parseInt(e.price) * e.quantity; + }); + 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.isSucceed) { + $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]
"; - ctrl.removeMember = function (memberId) { - var index = ctrl.members.findIndex((x) => x.id === memberId); - if (index >= 0) { - ctrl.members.splice(index, 1); - } - $scope.$apply(); - }; + 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); - ctrl.newMessage = function (msg) { - ctrl.messages.push(msg); - $scope.$apply(); - // var objDiv = document.getElementsByClassName("widget-conversation")[0]; - // objDiv.scrollTop = objDiv.scrollHeight + 20; - }; - }, - ], -}); + // TODO Handle cart submit + await commonService.sendMail("Booking - " + $scope.propertyName, edm); + $scope.submitted = true; + }; + }, +]); sharedComponents.component("codeEditor", { templateUrl: "codeEditor.html", @@ -9000,51 +9000,6 @@ sharedComponents.component("statuses", { }, }); -"use trick"; -sharedComponents.directive("pane", function () { - return { - require: "^tabs", - restrict: "E", - transclude: true, - scope: { header: "@", id: "@", icon: "@" }, - link: function (scope, element, attrs, tabsController) { - tabsController.addPane(scope); - }, - template: - '
' + - "
", - replace: true, - }; -}); - -sharedComponents.directive("tabs", function () { - return { - restrict: "E", - transclude: true, - scope: { - selectCallback: "&", - }, - controller: function ($scope, $element) { - var panes = ($scope.panes = []); - - $scope.select = function (pane) { - angular.forEach(panes, function (pane) { - pane.selected = false; - }); - pane.selected = true; - this.selectCallback({ pane: pane }); - }; - - this.addPane = function (pane) { - if (panes.length === 0) $scope.select(pane); - panes.push(pane); - }; - }, - templateUrl: "/mix-app/views/app-shared/components/tabs/tabs.html", - replace: true, - }; -}); - sharedComponents.component("mixStore", { templateUrl: "/mix-app/views/app-shared/components/store/view.html", bindings: { @@ -9186,12 +9141,12 @@ sharedComponents.component("mixStore", { }); "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); }, @@ -9202,7 +9157,7 @@ sharedComponents.directive("paneV", function () { }; }); -sharedComponents.directive("tabsV", function () { +sharedComponents.directive("tabs", function () { return { restrict: "E", transclude: true, @@ -9225,7 +9180,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, }; }); @@ -9276,6 +9231,51 @@ sharedComponents.directive("tabsH", function () { }; }); +"use trick"; +sharedComponents.directive("paneV", function () { + return { + require: "^tabs-v", + restrict: "E", + transclude: true, + scope: { header: "@", id: "@", icon: "@", class: "@" }, + link: function (scope, element, attrs, tabsController) { + tabsController.addPane(scope); + }, + template: + '
' + + "
", + replace: true, + }; +}); + +sharedComponents.directive("tabsV", function () { + return { + restrict: "E", + transclude: true, + scope: { + selectCallback: "&", + }, + controller: function ($scope, $element) { + var panes = ($scope.panes = []); + + $scope.select = function (pane) { + angular.forEach(panes, function (pane) { + pane.selected = false; + }); + pane.selected = true; + this.selectCallback({ pane: pane }); + }; + + this.addPane = function (pane) { + if (panes.length === 0) $scope.select(pane); + panes.push(pane); + }; + }, + templateUrl: "/mix-app/views/app-shared/components/tabs-verticle/tabs.html", + replace: true, + }; +}); + sharedComponents.component("tags", { templateUrl: "/mix-app/views/app-shared/components/tags/tags.html", controller: [ @@ -9768,47 +9768,6 @@ sharedComponents.component("uploadCroppie", { ], }); -sharedComponents.component("youtubeEditor", { - templateUrl: - "/mix-app/views/app-shared/components/youtube-editor/youtube-editor.html", - controller: [ - "$rootScope", - "$scope", - "$sce", - function ($rootScope, $scope, $sce) { - var ctrl = this; - ctrl.isPlay = false; - ctrl.loadVideo = function () { - ctrl.isPlay = false; - ctrl.src = ""; - if (ctrl.code) { - ctrl.img = - "https://img.youtube.com/vi/" + ctrl.code + "/sddefault.jpg"; - } - }; - ctrl.playVideo = function () { - ctrl.isPlay = true; - ctrl.src = $sce.trustAsResourceUrl( - "https://www.youtube.com/embed/" + - ctrl.code + - "?rel=0&showinfo=0&autoplay=1" - ); - }; - ctrl.searchVideo = function () { - // search - $rootScope.preview( - "message", - "ToDo: Integrate youtube search (https://developers.google.com/youtube/v3/docs/search/list) \r\n PATH: portal-app/app/app-shared/components/youtube-editor/youtube-editor.js" - ); - }; - }, - ], - bindings: { - code: "=", - hideInput: "=?", - }, -}); - "use strict"; appShared.controller("VideoCallController", [ "$scope", @@ -10142,6 +10101,47 @@ sharedComponents.component("videoCall", { }, }); +sharedComponents.component("youtubeEditor", { + templateUrl: + "/mix-app/views/app-shared/components/youtube-editor/youtube-editor.html", + controller: [ + "$rootScope", + "$scope", + "$sce", + function ($rootScope, $scope, $sce) { + var ctrl = this; + ctrl.isPlay = false; + ctrl.loadVideo = function () { + ctrl.isPlay = false; + ctrl.src = ""; + if (ctrl.code) { + ctrl.img = + "https://img.youtube.com/vi/" + ctrl.code + "/sddefault.jpg"; + } + }; + ctrl.playVideo = function () { + ctrl.isPlay = true; + ctrl.src = $sce.trustAsResourceUrl( + "https://www.youtube.com/embed/" + + ctrl.code + + "?rel=0&showinfo=0&autoplay=1" + ); + }; + ctrl.searchVideo = function () { + // search + $rootScope.preview( + "message", + "ToDo: Integrate youtube search (https://developers.google.com/youtube/v3/docs/search/list) \r\n PATH: portal-app/app/app-shared/components/youtube-editor/youtube-editor.js" + ); + }; + }, + ], + bindings: { + code: "=", + hideInput: "=?", + }, +}); + /*! * angular-loading-bar v0.9.0 * https://chieffancypants.github.io/angular-loading-bar diff --git a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/components/filter-list/filter-list.html b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/components/filter-list/filter-list.html index f5c3677d9..59e6a42bb 100644 --- a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/components/filter-list/filter-list.html +++ b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/components/filter-list/filter-list.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/mix-database-data/list.html b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/mix-database-data/list.html index 338472e0e..b84bc8352 100644 --- a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/mix-database-data/list.html +++ b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/mix-database-data/list.html @@ -1 +1 @@ -
Total items:
\ No newline at end of file +
Total items:
\ No newline at end of file diff --git a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/post/components/filter-list/filter-list.html b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/post/components/filter-list/filter-list.html index aa18b3a54..1a87cf7ba 100644 --- a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/post/components/filter-list/filter-list.html +++ b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-portal/pages/post/components/filter-list/filter-list.html @@ -1 +1 @@ -
\ No newline at end of file +
\ No newline at end of file diff --git a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-shared/components/mix-column-preview/view.html b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-shared/components/mix-column-preview/view.html index c3a9c73d7..13904f8f7 100644 --- a/src/Mix.Cms.Web/wwwroot/mix-app/views/app-shared/components/mix-column-preview/view.html +++ b/src/Mix.Cms.Web/wwwroot/mix-app/views/app-shared/components/mix-column-preview/view.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file