From e60599a3c13514cdc1de27f33c574ad19bbea304 Mon Sep 17 00:00:00 2001 From: Eric Nguyen Date: Mon, 25 Dec 2023 15:25:23 +0700 Subject: [PATCH] upd --- .../mix-messages-hub-client/script.js | 1 + .../components/service-hub-client/script.js | 1 + src/app/app-client/services/user-services.js | 6 +- src/app/app-portal/app-portal-controller.js | 1 + .../high-frequency-messages/script.js | 1 + .../components/hub-messages/hub-messages.js | 1 + .../components/log-stream/script.js | 1 + .../components/media-file-upload/script.js | 16 +- .../components/media-file-upload/view.html | 2 +- .../components/mix-database-form/script.js | 1 + .../components/service-hub-portal/script.js | 1 + .../template-editor/templateEditor.js | 1 + .../components/video-chat-hub/script.js | 1 + .../pages/application/controller.js | 64 +++++-- .../app-portal/pages/application/details.html | 174 +++++++++++------- .../app-portal/pages/application/list.html | 6 +- .../app-portal/pages/application/services.js | 11 ++ .../app-portal/pages/audit-log/controller.js | 1 + .../pages/order-detail/controller.js | 1 + .../pages/order-detail/details.html | 2 +- .../app-portal/pages/role/role-services.js | 2 +- .../pages/template/template-controller.js | 1 + .../app-portal/pages/user/user-services.js | 12 +- .../app-security/pages/register/_services.js | 2 +- .../pages/reset-password/_services.js | 2 +- .../messenger/messenger-controller.js | 1 + .../components/service-hub/_script.js | 2 +- src/app/app-shared/components/store/script.js | 1 + .../video-call/video-call-controller.js | 1 + src/app/app-shared/services/api-services.js | 4 +- src/app/app-shared/services/auth-services.js | 14 +- 31 files changed, 213 insertions(+), 122 deletions(-) diff --git a/src/app/app-client/components/mix-messages-hub-client/script.js b/src/app/app-client/components/mix-messages-hub-client/script.js index a8eab81c8..a1cc18c55 100644 --- a/src/app/app-client/components/mix-messages-hub-client/script.js +++ b/src/app/app-client/components/mix-messages-hub-client/script.js @@ -13,6 +13,7 @@ function ($rootScope, $scope, columnService, service) { var ctrl = this; BaseHub.call(this, ctrl); + $scope.host = `${$rootScope.globalSettings.domain}/${ctrl.host}`; ctrl.mixConfigurations = $rootScope.globalSettings; ctrl.user = { loggedIn: false, diff --git a/src/app/app-client/components/service-hub-client/script.js b/src/app/app-client/components/service-hub-client/script.js index 28c4062e5..ae5c54938 100644 --- a/src/app/app-client/components/service-hub-client/script.js +++ b/src/app/app-client/components/service-hub-client/script.js @@ -13,6 +13,7 @@ function ($rootScope, $scope, columnService, service) { var ctrl = this; BaseHub.call(this, ctrl); + $scope.host = `${$rootScope.globalSettings.domain}/${ctrl.host}`; ctrl.mixConfigurations = $rootScope.globalSettings; ctrl.user = { loggedIn: false, diff --git a/src/app/app-client/services/user-services.js b/src/app/app-client/services/user-services.js index 2099c5ba9..57860c8e7 100644 --- a/src/app/app-client/services/user-services.js +++ b/src/app/app-client/services/user-services.js @@ -5,7 +5,7 @@ app.factory("UserService", [ var usersServiceFactory = {}; var _getMyProfile = async function () { - var apiUrl = "/rest/mix-account/user"; + var apiUrl = "/rest/auth/user"; var url = apiUrl + "my-profile"; var req = { method: "GET", @@ -15,7 +15,7 @@ app.factory("UserService", [ }; var _saveUser = async function (user) { - var apiUrl = "/rest/mix-account/save"; + var apiUrl = "/rest/auth/save"; var req = { method: "POST", url: apiUrl, @@ -25,7 +25,7 @@ app.factory("UserService", [ }; var _register = async function (user) { - var apiUrl = "/rest/mix-account/"; + var apiUrl = "/rest/auth/"; var req = { method: "POST", url: apiUrl + "register", diff --git a/src/app/app-portal/app-portal-controller.js b/src/app/app-portal/app-portal-controller.js index 0a3e5d11c..f8344f8dc 100644 --- a/src/app/app-portal/app-portal-controller.js +++ b/src/app/app-portal/app-portal-controller.js @@ -23,6 +23,7 @@ app.controller("AppPortalController", [ localStorageService ) { BaseHub.call(this, $scope); + $scope.host = `${$rootScope.globalSettings.domain}/${$scope.host}`; $scope.isInit = false; $scope.pageTagName = ""; $scope.pageTagTypeName = ""; diff --git a/src/app/app-portal/components/high-frequency-messages/script.js b/src/app/app-portal/components/high-frequency-messages/script.js index a80af9443..74509429e 100644 --- a/src/app/app-portal/components/high-frequency-messages/script.js +++ b/src/app/app-portal/components/high-frequency-messages/script.js @@ -10,6 +10,7 @@ app.controller("HighFrequencyMessagesController", [ "AuthService", function ($scope, $rootScope, authService) { BaseHub.call(this, $scope); + $scope.host = `${$rootScope.globalSettings.domain}/${$scope.host}`; authService.fillAuthData(); $scope.newMsgCount = 0; $scope.messages = []; diff --git a/src/app/app-portal/components/hub-messages/hub-messages.js b/src/app/app-portal/components/hub-messages/hub-messages.js index 7ccea8a44..ea8cb579d 100644 --- a/src/app/app-portal/components/hub-messages/hub-messages.js +++ b/src/app/app-portal/components/hub-messages/hub-messages.js @@ -10,6 +10,7 @@ app.controller("HubMessagesController", [ "AuthService", function ($scope, $rootScope, authService) { BaseHub.call(this, $scope); + $scope.host = `${$rootScope.globalSettings.domain}/${$scope.host}`; authService.fillAuthData(); $scope.newMsgCount = 0; $scope.messages = []; diff --git a/src/app/app-portal/components/log-stream/script.js b/src/app/app-portal/components/log-stream/script.js index 17c21d11d..48832507d 100644 --- a/src/app/app-portal/components/log-stream/script.js +++ b/src/app/app-portal/components/log-stream/script.js @@ -9,6 +9,7 @@ app.controller("LogStreamController", [ "AuthService", function ($scope, $rootScope, authService) { BaseHub.call(this, $scope); + $scope.host = `${$rootScope.globalSettings.domain}/${$scope.host}`; authService.fillAuthData(); $scope.keyword = ""; $scope.newMsgCount = 0; diff --git a/src/app/app-portal/components/media-file-upload/script.js b/src/app/app-portal/components/media-file-upload/script.js index d45d889d3..b265148e0 100644 --- a/src/app/app-portal/components/media-file-upload/script.js +++ b/src/app/app-portal/components/media-file-upload/script.js @@ -5,7 +5,7 @@ header: "=?", accept: "=?", src: "=", - srcUrl: "=", + srcUrl: "=?", fileModel: "=?", type: "=?", auto: "=?", @@ -30,12 +30,14 @@ if (ctrl.src) { ctrl.srcUrl = angular.copy(ctrl.src); } - if (!ctrl.srcUrl) { - ctrl.srcUrl = image_placeholder; - } - ctrl.isImage = ctrl.srcUrl - .toLowerCase() - .match(/([/|.|\w|\s|-])*\.(?:jpg|jpeg|gif|png|svg|webp)/g); + // if (!ctrl.srcUrl) { + // ctrl.srcUrl = image_placeholder; + // } + ctrl.isImage = + ctrl.srcUrl != undefined && + ctrl.srcUrl + .toLowerCase() + .match(/([/|.|\w|\s|-])*\.(?:jpg|jpeg|gif|png|svg|webp)/g); ctrl.maxHeight = ctrl.maxHeight || "200px"; ctrl.id = Math.floor(Math.random() * 100); if (ctrl.uploadOptions) { diff --git a/src/app/app-portal/components/media-file-upload/view.html b/src/app/app-portal/components/media-file-upload/view.html index 31dbe8bb2..894a50562 100644 --- a/src/app/app-portal/components/media-file-upload/view.html +++ b/src/app/app-portal/components/media-file-upload/view.html @@ -34,7 +34,7 @@

Loaded {{$ctrl.progress}}%

-
+
View
diff --git a/src/app/app-portal/components/mix-database-form/script.js b/src/app/app-portal/components/mix-database-form/script.js index 4e11e69ec..8f85b92f7 100644 --- a/src/app/app-portal/components/mix-database-form/script.js +++ b/src/app/app-portal/components/mix-database-form/script.js @@ -46,6 +46,7 @@ modules.component("mixDatabaseForm", { ) { var ctrl = this; BaseHub.call(this, ctrl); + $scope.host = `${$rootScope.globalSettings.domain}/${ctrl.host}`; ctrl.isBusy = false; ctrl.attributes = []; ctrl.isInRole = $rootScope.isInRole; diff --git a/src/app/app-portal/components/service-hub-portal/script.js b/src/app/app-portal/components/service-hub-portal/script.js index 6ff60e728..622fea6bc 100644 --- a/src/app/app-portal/components/service-hub-portal/script.js +++ b/src/app/app-portal/components/service-hub-portal/script.js @@ -14,6 +14,7 @@ function ($rootScope, $scope, columnService, service, userServices) { var ctrl = this; BaseHub.call(this, ctrl); + $scope.host = `${$rootScope.globalSettings.domain}/${ctrl.host}`; ctrl.mixConfigurations = $rootScope.globalSettings; ctrl.user = { loggedIn: false, diff --git a/src/app/app-portal/components/template-editor/templateEditor.js b/src/app/app-portal/components/template-editor/templateEditor.js index cffa0a7b4..abcfe8c16 100644 --- a/src/app/app-portal/components/template-editor/templateEditor.js +++ b/src/app/app-portal/components/template-editor/templateEditor.js @@ -38,6 +38,7 @@ ); var ctrl = this; BaseHub.call(this, ctrl); + $scope.host = `${$rootScope.globalSettings.domain}/${ctrl.host}`; ctrl.themeRequest = angular.copy(ngAppSettings.request); ctrl.request = angular.copy(ngAppSettings.request); ctrl.isNull = false; diff --git a/src/app/app-portal/components/video-chat-hub/script.js b/src/app/app-portal/components/video-chat-hub/script.js index 88967380d..295829b8e 100644 --- a/src/app/app-portal/components/video-chat-hub/script.js +++ b/src/app/app-portal/components/video-chat-hub/script.js @@ -13,6 +13,7 @@ function ($rootScope, $scope, service, viewmodel, connectionManager) { var ctrl = this; BaseHub.call(this, ctrl); + $scope.host = `${$rootScope.globalSettings.domain}/${ctrl.host}`; ctrl.mixConfigurations = $rootScope.globalSettings; ctrl.init = function () { diff --git a/src/app/app-portal/pages/application/controller.js b/src/app/app-portal/pages/application/controller.js index 8e21b69d9..ef4df27cd 100644 --- a/src/app/app-portal/pages/application/controller.js +++ b/src/app/app-portal/pages/application/controller.js @@ -26,6 +26,7 @@ app.controller("MixApplicationController", [ service ); BaseHub.call(this, $scope); + $scope.host = `${$rootScope.globalSettings.domain}/${$scope.host}`; $scope.progress = 0; $scope.viewMode = "list"; $scope.current = null; @@ -38,7 +39,7 @@ app.controller("MixApplicationController", [ $scope.request.columns = [ "id", "displayName", - "baseRoute", + "baseHref", "detailUrl", "createdDateTime", "createdBy", @@ -46,12 +47,12 @@ app.controller("MixApplicationController", [ $scope.canDrag = $scope.request.orderBy !== "Priority" || $scope.request.direction !== "0"; - $scope.generateBaseRoute = (forceRename) => { + $scope.generateBaseHref = (forceRename) => { if ( forceRename || - ($scope.viewmodel.displayName && !$scope.viewmodel.baseRoute) + ($scope.viewmodel.displayName && !$scope.viewmodel.baseHref) ) { - $scope.viewmodel.baseRoute = `/app/${$rootScope.generateKeyword( + $scope.viewmodel.baseHref = `/app/${$rootScope.generateKeyword( $scope.viewmodel.displayName, "-", false, @@ -66,26 +67,51 @@ app.controller("MixApplicationController", [ $scope.onConnected = () => { $scope.joinRoom("Theme"); }; - await $scope.getThemes(); + if (!$scope.viewmodel.id) { + await $scope.getThemes(); + } }; $scope.install = async function () { $rootScope.isBusy = true; $scope.installStatus = "Downloading"; var resp = await service.install($scope.viewmodel); + if (resp && resp.success) { + $rootScope.isBusy = false; + $("html, body").animate({ scrollTop: "0px" }, 500); + $scope.$apply(); + } else { + if (resp) { + $rootScope.showErrors(resp.errors || ["Failed"]); + } + $rootScope.isBusy = false; + $scope.$apply(); + } + }; + $scope.restore = async function () { + $rootScope.isBusy = true; + $scope.installStatus = "Restoring"; + $("html, body").animate({ scrollTop: "0px" }, 500); + var resp = await service.restore({ + appId: $scope.viewmodel.id, + packageFilePath: $scope.viewmodel.appSettings.activePackage, + }); if (resp && resp.success) { $scope.data = resp.data; $rootScope.isBusy = false; + $scope.installStatus = "Finished"; + $scope.status = ""; $scope.$apply(); } else { if (resp) { $rootScope.showErrors(resp.errors || ["Failed"]); } $rootScope.isBusy = false; + $scope.installStatus = ""; + $scope.status = ""; $scope.$apply(); } }; - $scope.receiveMessage = function (resp) { - let msg = JSON.parse(resp); + $scope.receiveMessage = function (msg) { switch (msg.action) { case "Downloading": var index = $scope.data.items.findIndex( @@ -94,17 +120,19 @@ app.controller("MixApplicationController", [ var progress = Math.round(msg.message); if (index >= 0) { $scope.progress = progress; - if (progress == 100) { - setTimeout(() => { - $location.url("/admin/mix-application/list"); - }, 200); - } $scope.$apply(); } break; - + case "Finished": + $scope.installStatus = "Finished"; + $location.url("/admin/mix-application/list"); + $scope.$apply(); + break; default: - console.log(msg); + setTimeout(() => { + $scope.status = msg.message; + $scope.$apply(); + }, 200); break; } }; @@ -135,7 +163,9 @@ app.controller("MixApplicationController", [ } }; $scope.select = function (theme) { - $scope.viewmodel.packateFilePath = theme.additionalData.builtSourceCode; + $scope.viewmodel.packageFilePath = theme.additionalData.builtSourceCode; + $scope.viewmodel.displayName = theme.additionalData.title; + $scope.generateBaseHref(true); $scope.current = theme; // TODO: verify user - theme to enable install $scope.current.canInstall = true; @@ -145,8 +175,8 @@ app.controller("MixApplicationController", [ $scope.viewMode = "list"; }; $scope.validate = function () { - if ($scope.viewmodel.baseRoute.indexOf("/app/") != 0) { - $rootScope.showErrors(['baseRoute must start with "/app/"']); + if ($scope.viewmodel.baseHref.indexOf("/mixapp/") != 0) { + $rootScope.showErrors(['baseHref must start with "/mixapp/"']); return false; } return true; diff --git a/src/app/app-portal/pages/application/details.html b/src/app/app-portal/pages/application/details.html index 8fd3cafad..09697a7b9 100644 --- a/src/app/app-portal/pages/application/details.html +++ b/src/app/app-portal/pages/application/details.html @@ -24,7 +24,7 @@

@@ -44,6 +51,29 @@

+
+
+
+
+
+
+

+ +

+
+
+
@@ -53,7 +83,7 @@

type="text" class="form-control" ng-model="viewmodel.displayName" - ng-blur="generateBaseRoute(false)" + ng-blur="generateBaseHref(false)" />

@@ -67,12 +97,12 @@

@@ -92,22 +122,80 @@

>

-
-
-
-
+
+
+
+
+ ng-repeat="post in data.items track by $index" + class="col-md-4" + > +
+ +
+
+ {{post.title}} +
+ by + {{post.properties.authorName}} + in + {{post.additionalData.category}} +
+ + +
+
+ Select +
+
+
+
+
-
+ +
+ +
@@ -122,62 +210,6 @@

-
-
-
-
-
-
- -
-
- {{post.title}} -
- by - {{post.properties.authorName}} - in - {{post.additionalData.category}} -
- - -
-
- Select -
-
-
-
-
-
-
-
-
diff --git a/src/app/app-portal/pages/application/list.html b/src/app/app-portal/pages/application/list.html index 28d1feafd..7ca675ed6 100644 --- a/src/app/app-portal/pages/application/list.html +++ b/src/app/app-portal/pages/application/list.html @@ -18,7 +18,7 @@

All Applications

request="request" callback="getList(pageIndex)" create-url="'/admin/mix-application/create'" - create-text="'Create Tenant'" + create-text="'Create Application'" >
@@ -105,9 +105,9 @@

All Applications

diff --git a/src/app/app-portal/pages/application/services.js b/src/app/app-portal/pages/application/services.js index 2a263af0a..027751d8a 100644 --- a/src/app/app-portal/pages/application/services.js +++ b/src/app/app-portal/pages/application/services.js @@ -14,7 +14,18 @@ app.factory("MixApplicationRestService", [ }; return await this.getRestApiResult(req); }; + var _restore = async function (objData) { + var url = `${this.prefixUrl}/restore-package`; + var req = { + serviceBase: this.serviceBase, + method: "POST", + url: url, + data: JSON.stringify(objData), + }; + return await this.getRestApiResult(req); + }; serviceFactory.install = _install; + serviceFactory.restore = _restore; return serviceFactory; }, ]); diff --git a/src/app/app-portal/pages/audit-log/controller.js b/src/app/app-portal/pages/audit-log/controller.js index e7410f70a..312358932 100644 --- a/src/app/app-portal/pages/audit-log/controller.js +++ b/src/app/app-portal/pages/audit-log/controller.js @@ -26,6 +26,7 @@ app.controller("AuditLogController", [ service ); BaseHub.call(this, $scope); + $scope.host = `${$rootScope.globalSettings.domain}/${$scope.host}`; authService.fillAuthData(); $scope.request.status = null; $scope.messages = []; diff --git a/src/app/app-portal/pages/order-detail/controller.js b/src/app/app-portal/pages/order-detail/controller.js index f0898974a..962c0f748 100644 --- a/src/app/app-portal/pages/order-detail/controller.js +++ b/src/app/app-portal/pages/order-detail/controller.js @@ -24,6 +24,7 @@ app.controller("OrderDetailController", [ service ); BaseHub.call(this, $scope); + $scope.host = `${$rootScope.globalSettings.domain}/${$scope.host}`; $scope.progress = 0; $scope.viewMode = "list"; $scope.current = null; diff --git a/src/app/app-portal/pages/order-detail/details.html b/src/app/app-portal/pages/order-detail/details.html index e8d4b000f..430c8e64c 100644 --- a/src/app/app-portal/pages/order-detail/details.html +++ b/src/app/app-portal/pages/order-detail/details.html @@ -54,7 +54,7 @@