Skip to content

Commit

Permalink
upd
Browse files Browse the repository at this point in the history
  • Loading branch information
nhathoang989 committed Dec 25, 2023
1 parent e407a64 commit e60599a
Show file tree
Hide file tree
Showing 31 changed files with 213 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/app/app-client/components/service-hub-client/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/app/app-client/services/user-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/app/app-portal/app-portal-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
1 change: 1 addition & 0 deletions src/app/app-portal/components/hub-messages/hub-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
1 change: 1 addition & 0 deletions src/app/app-portal/components/log-stream/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 9 additions & 7 deletions src/app/app-portal/components/media-file-upload/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
header: "=?",
accept: "=?",
src: "=",
srcUrl: "=",
srcUrl: "=?",
fileModel: "=?",
type: "=?",
auto: "=?",
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/app-portal/components/media-file-upload/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>
<h3 class="text-primary" ng-if="$ctrl.progress">Loaded {{$ctrl.progress}}%</h3>
</div>
<div ng-if="!$ctrl.isImage && $ctrl.srcUrl !== '/'">
<div ng-if="!$ctrl.isImage && $ctrl.srcUrl">
<a href="{{$ctrl.srcUrl}}" target="_blank">View</a>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/app/app-portal/components/mix-database-form/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/app/app-portal/components/service-hub-portal/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/app/app-portal/components/video-chat-hub/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
64 changes: 47 additions & 17 deletions src/app/app-portal/pages/application/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,20 +39,20 @@ app.controller("MixApplicationController", [
$scope.request.columns = [
"id",
"displayName",
"baseRoute",
"baseHref",
"detailUrl",
"createdDateTime",
"createdBy",
];
$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,
Expand All @@ -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(
Expand All @@ -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;
}
};
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit e60599a

Please sign in to comment.