Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCST-2206: fixed an update process from the module list blade #2858

Merged
merged 8 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/VirtoCommerce.Platform.Core/Modularity/ModuleAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace VirtoCommerce.Platform.Core.Modularity
public enum ModuleAction
{
Install,
Uninstall
Uninstall,
Update
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,27 @@ public ActionResult<ModulePushNotification> InstallModules([FromBody] ModuleDesc
return Ok(result);
}

/// <summary>
/// Update modules
/// </summary>
/// <param name="modules">modules for update</param>
/// <returns></returns>
[HttpPost]
[Route("update")]
[Authorize(PlatformConstants.Security.Permissions.ModuleManage)]
public ActionResult<ModulePushNotification> UpdateModules([FromBody] ModuleDescriptor[] modules)
{
EnsureModulesCatalogInitialized();

var options = new ModuleBackgroundJobOptions
{
Action = ModuleAction.Update,
Modules = modules
};
var result = ScheduleJob(options);
return Ok(result);
}

/// <summary>
/// Uninstall module
/// </summary>
Expand Down Expand Up @@ -434,6 +455,7 @@ public void ModuleBackgroundJob(ModuleBackgroundJobOptions options, ModulePushNo
switch (options.Action)
{
case ModuleAction.Install:
case ModuleAction.Update:
_moduleInstaller.Install(moduleInfos, reportProgress);
break;
case ModuleAction.Uninstall:
Expand Down Expand Up @@ -466,12 +488,19 @@ public void ModuleBackgroundJob(ModuleBackgroundJobOptions options, ModulePushNo
_settingsManager.SetValue(PlatformConstants.Settings.Setup.ModulesAutoInstallState.Name, AutoInstallState.Completed);

notification.Finished = DateTime.UtcNow;
notification.Description = options.Action == ModuleAction.Install ? "Installation finished." : "Uninstalling finished.";
notification.Description = options.Action switch
{
ModuleAction.Install => "Installation finished.",
ModuleAction.Update => "Updating finished.",
_ => "Uninstalling finished."
};

notification.ProgressLog.Add(new ProgressMessage
{
Level = ProgressMessageLevel.Info,
Message = notification.Description,
});

_pushNotifier.Send(notification);
}
}
Expand Down Expand Up @@ -513,6 +542,10 @@ private ModulePushNotification ScheduleJob(ModuleBackgroundJobOptions options)
notification.Title = "Uninstall Module";
notification.ProgressLog.Add(new ProgressMessage { Level = ProgressMessageLevel.Info, Message = "Starting uninstall..." });
break;
case ModuleAction.Update:
notification.Title = "Update Module";
notification.ProgressLog.Add(new ProgressMessage { Level = ProgressMessageLevel.Info, Message = "Starting update..." });
break;
}

_pushNotifier.Send(notification);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "Start",
"end": "Ende",
"progress-messages": "Fortschrittsmeldungen",
"process-completed": "Modulinstallationsprozess abgeschlossen",
"process-completed": "Der Modulverwaltungsprozess ist abgeschlossen",
"restart-application": "Starten Sie die Anwendung jetzt oder später neu"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "Start",
"end": "End",
"progress-messages": "Progress messages",
"process-completed": "Module installation process completed",
"process-completed": "The module management process is completed",
"restart-application": "Restart the application now or later"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "Inicio",
"end": "Fin",
"progress-messages": "Mensajes de progreso",
"process-completed": "Proceso de instalación del módulo completado",
"process-completed": "El proceso de gestión del módulo se ha completado",
"restart-application": "Reiniciar la aplicación ahora o más tarde"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "Début",
"end": "Fin",
"progress-messages": "Messages de progression",
"process-completed": "Processus d'installation du module terminé",
"process-completed": "Le processus de gestion des modules est terminé",
"restart-application": "Redémarrer l'application maintenant ou plus tard"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "Inizio",
"end": "Fine",
"progress-messages": "Messaggi di avanzamento",
"process-completed": "Processo di installazione del modulo completato",
"process-completed": "Il processo di gestione del modulo è completato",
"restart-application": "Riavvia l'applicazione ora o più tardi"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "開始",
"end": "終了",
"progress-messages": "進行メッセージ",
"process-completed": "モジュールインストールプロセスが完了しました",
"process-completed": "モジュール管理プロセスが完了しました",
"restart-application": "アプリケーションを今すぐ再起動するか、後で再起動してください"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "Start",
"end": "Koniec",
"progress-messages": "Komunikaty o postępie",
"process-completed": "Proces instalacji modułu zakończony",
"process-completed": "Proces zarządzania modułem został zakończony",
"restart-application": "Uruchom ponownie aplikację teraz lub później"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "Início",
"end": "Fim",
"progress-messages": "Mensagens de progresso",
"process-completed": "Processo de instalação do módulo concluído",
"process-completed": "O processo de gestão do módulo está concluído",
"restart-application": "Reiniciar a aplicação agora ou mais tarde"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@
"start": "Начало",
"end": "Конец",
"progress-messages": "Сообщения о прогрессе",
"process-completed": "Процесс установки модуля завершен",
"restart-application": "Перезапустить приложение сейчас или позже"
"process-completed": "Процесс управления модулем завершен",
"restart-application": "Перезапустите приложение сейчас или позже"
}
},
"module-detail": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
"start": "开始",
"end": "结束",
"progress-messages": "进度消息",
"process-completed": "模块安装过程已完成",
"process-completed": "模块管理过程完成",
"restart-application": "立即重启应用程序或稍后重启"
}
},
Expand Down
9 changes: 4 additions & 5 deletions src/VirtoCommerce.Platform.Web/wwwroot/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ angular.uppercase = function (text) {
}
return text;
}

angular.lowercase = function (text) {
if (text) {
return text.toLowerCase();
}
return text;
}


angular.module('platformWebApp', AppDependencies).controller('platformWebApp.appCtrl', ['$rootScope', '$scope', 'platformWebApp.mainMenuService',
'platformWebApp.i18n', 'platformWebApp.modules', 'platformWebApp.moduleHelper', '$state', 'platformWebApp.bladeNavigationService', 'platformWebApp.userProfile',
'platformWebApp.i18n', 'platformWebApp.modulesApi', 'platformWebApp.moduleHelper', '$state', 'platformWebApp.bladeNavigationService', 'platformWebApp.userProfile',
'platformWebApp.settings', 'platformWebApp.common', 'THEME_SETTINGS', 'platformWebApp.webApps',
function ($rootScope, $scope, mainMenuService,
i18n, modules, moduleHelper, $state, bladeNavigationService, userProfile, settings, common, THEME_SETTINGS, webApps) {
function ($rootScope, $scope, mainMenuService, i18n, modulesApi, moduleHelper, $state, bladeNavigationService, userProfile, settings, common, THEME_SETTINGS, webApps) {

$scope.closeError = function () {
$scope.platformError = undefined;
Expand Down Expand Up @@ -47,7 +46,7 @@ angular.module('platformWebApp', AppDependencies).controller('platformWebApp.app
angular.forEach(mainMenuService.menuItems, function (menuItem) { mainMenuService.resetMenuItemDefaults(menuItem); });

if (authContext.isAuthenticated) {
modules.query().$promise.then(function (results) {
modulesApi.query().$promise.then(function (results) {
moduleHelper.modules = results;
moduleHelper.onLoaded();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
angular.module('platformWebApp')
.controller('platformWebApp.moduleDetailController', ['$scope', 'platformWebApp.dialogService', 'platformWebApp.bladeNavigationService', 'platformWebApp.modules', 'platformWebApp.moduleHelper', 'FileUploader', 'platformWebApp.settings', function ($scope, dialogService, bladeNavigationService, modules, moduleHelper, FileUploader, settings) {
.controller('platformWebApp.moduleDetailController', ['$scope', 'platformWebApp.bladeNavigationService', 'platformWebApp.moduleHelper', 'FileUploader', 'platformWebApp.settings', function ($scope, bladeNavigationService, moduleHelper, FileUploader, settings) {
var blade = $scope.blade;

blade.headIcon = 'fa fa-cubes';
blade.fallbackIconUrl = '/images/module-logo.png';

function initializeBlade() {
if (blade.currentEntity.isInstalled) {
var canUpdate = $scope.allowInstallModules && _.any(moduleHelper.allmodules, function (x) {
var canUpdate = $scope.allowInstallModules && _.any(moduleHelper.modules, function (x) {
return x.id === blade.currentEntity.id && !x.isInstalled;
});

blade.toolbarCommands = [
{
name: "platform.commands.update", icon: 'fa fa-upload',
executeMethod: function () {
blade.currentEntity = _.last(_.where(moduleHelper.allmodules, { id: blade.currentEntity.id, isInstalled: false }));
blade.currentEntity = _.last(_.where(moduleHelper.modules, { id: blade.currentEntity.id, isInstalled: false }));
initializeBlade();
},
canExecuteMethod: function () { return canUpdate; },
Expand Down Expand Up @@ -53,7 +56,7 @@ angular.module('platformWebApp')
} else {
blade.toolbarCommands = [];
blade.mode = blade.currentEntity.$installedVersion ? 'update' : 'install';
$scope.availableVersions = _.where(moduleHelper.allmodules, { id: blade.currentEntity.id, isInstalled: false });
$scope.availableVersions = _.where(moduleHelper.modules, { id: blade.currentEntity.id, isInstalled: false });
blade.isLoading = false;
}
}
Expand All @@ -67,7 +70,7 @@ angular.module('platformWebApp')
}

$scope.isModulePresent = function (dependencyId) {
return _.any(moduleHelper.allmodules, function (x) {
return _.any(moduleHelper.modules, function (x) {
return x.id === dependencyId;
});
}
Expand All @@ -77,82 +80,17 @@ angular.module('platformWebApp')
};

$scope.openDependencyModule = function (dependency) {
module = _.findWhere(moduleHelper.allmodules, { id: dependency.id, version: dependency.version }) ||
_.findWhere(moduleHelper.allmodules, { id: dependency.id }) ||
module = _.findWhere(moduleHelper.modules, { id: dependency.id, version: dependency.version }) ||
_.findWhere(moduleHelper.modules, { id: dependency.id }) ||
module;
blade.parentBlade.selectNode(module);
};

$scope.confirmActionInDialog = function (action) {
blade.isLoading = true;

//var clone = {
// id: blade.currentEntity.id,
// version: blade.currentEntity.version,
//};
var selection = [blade.currentEntity];
var modulesApiMethod = action === 'uninstall' ? modules.getDependents : modules.getDependencies;
modulesApiMethod(selection, function (data) {
blade.isLoading = false;

var dialog = {
id: "confirmation",
action: action,
selection: selection,
dependencies: data,
callback: function (resume) {
if (resume) {
blade.isLoading = true;
_.each(selection, function (x) {
if (!_.findWhere(data, { id: x.id })) {
data.push(x);
}
});

switch (action) {
case 'install':
case 'update':
modulesApiMethod = modules.install;
break;
case 'uninstall':
modulesApiMethod = modules.uninstall;
break;
}
modulesApiMethod(data, function (data) {
// show module (un)installation progress
var newBlade = {
id: 'moduleInstallProgress',
currentEntity: data,
controller: 'platformWebApp.moduleInstallProgressController',
template: '$(Platform)/Scripts/app/modularity/wizards/newModule/module-wizard-progress-step.tpl.html'
};
switch (action) {
case 'install':
_.extend(newBlade, { title: 'platform.blades.module-wizard-progress-step.title-install' });
break;
case 'update':
_.extend(newBlade, { title: 'platform.blades.module-wizard-progress-step.title-update' });
break;
case 'uninstall':
_.extend(newBlade, { title: 'platform.blades.module-wizard-progress-step.title-uninstall' });
break;
}
bladeNavigationService.showBlade(newBlade, blade.parentBlade);
}, function (error) {
bladeNavigationService.setError('Error ' + error.status, blade);
});
}
}
}
dialogService.showDialog(dialog, '$(Platform)/Scripts/app/modularity/dialogs/moduleAction-dialog.tpl.html', 'platformWebApp.confirmDialogController');
}, function (error) {
bladeNavigationService.setError('Error ' + error.status, blade);
});
moduleHelper.performAction(action, selection, blade, true);
};

blade.headIcon = 'fa fa-cubes';
blade.fallbackIconUrl = '/images/module-logo.png';

if (blade.mode === 'advanced') {
// the uploader
var uploader = $scope.uploader = new FileUploader({
Expand Down
Loading
Loading