Add cancel action for active app tasks
This commit is contained in:
@@ -189,6 +189,12 @@ app.filter('installError', function () {
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('activeTask', function () {
|
||||
return function (app) {
|
||||
return app.taskId !== null;
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('installSuccess', function () {
|
||||
return function (app) {
|
||||
return app.installationState === ISTATES.INSTALLED;
|
||||
@@ -324,6 +330,47 @@ app.filter('installationStateLabel', function() {
|
||||
};
|
||||
});
|
||||
|
||||
// this appears when task is getting canceled
|
||||
app.filter('installationStateCancelTask', function() {
|
||||
return function(app) {
|
||||
switch (app.installationState) {
|
||||
case ISTATES.PENDING_INSTALL: return 'installing';
|
||||
case ISTATES.PENDING_CLONE: return 'cloning';
|
||||
case ISTATES.PENDING_CONFIGURE: return 'configuring';
|
||||
case ISTATES.PENDING_UNINSTALL: return 'uninstalling';
|
||||
case ISTATES.PENDING_RESTORE: return 'restoring';
|
||||
case ISTATES.PENDING_UPDATE: return 'updating';
|
||||
case ISTATES.PENDING_BACKUP: return 'backing up';
|
||||
case ISTATES.INSTALLED: {
|
||||
if (app.runState === 'pending_start') return 'starting';
|
||||
else if (app.runState === 'pending_stop') return 'stopping';
|
||||
}
|
||||
}
|
||||
|
||||
return app.installationState;
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('installationStateCancelTooltip', function() {
|
||||
return function(app) {
|
||||
switch (app.installationState) {
|
||||
case ISTATES.PENDING_INSTALL: return 'install';
|
||||
case ISTATES.PENDING_CLONE: return 'clone';
|
||||
case ISTATES.PENDING_CONFIGURE: return 'configure';
|
||||
case ISTATES.PENDING_UNINSTALL: return 'uninstall';
|
||||
case ISTATES.PENDING_RESTORE: return 'restore';
|
||||
case ISTATES.PENDING_UPDATE: return 'update';
|
||||
case ISTATES.PENDING_BACKUP: return 'backup';
|
||||
case ISTATES.INSTALLED: {
|
||||
if (app.runState === 'pending_start') return 'start';
|
||||
else if (app.runState === 'pending_stop') return 'stop';
|
||||
}
|
||||
}
|
||||
|
||||
return app.installationState;
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('readyToUpdate', function () {
|
||||
return function (apps) {
|
||||
return apps.every(function (app) {
|
||||
|
||||
+26
-4
@@ -457,6 +457,27 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal cancel app -->
|
||||
<div class="modal fade" id="appCancelModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Cancel {{ appCancel.app.fqdn }}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
The app at {{ appCancel.app.fqdn }} is <b>{{ appCancel.app | installationStateCancelTask }}</b>. Do you want to cancel this operation?
|
||||
<br/>
|
||||
<br/>
|
||||
You can Restore or Repair the app to get it running again.
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-danger" ng-click="appCancel.submit()" ng-disabled="appCancel.busy"><i class="fa fa-circle-notch fa-spin" ng-show="appCancel.busy"></i> Stop {{ appCancel.app | installationStateCancelTooltip }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal uninstall app -->
|
||||
<div class="modal fade" id="appUninstallModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
@@ -565,10 +586,11 @@
|
||||
</div>
|
||||
|
||||
<div class="grid-item-actions" ng-show="user.admin">
|
||||
<a href="" ng-click="appUninstall.show(app)" uib-tooltip="Uninstall" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-times scale"></i></a>
|
||||
<a href="" ng-click="appRestore.show(app)" ng-show="backupsEnabled" uib-tooltip="Backups" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-archive scale"></i></a>
|
||||
<a href="" ng-click="appConfigure.show(app)" ng-show="(app.installationState === 'installed' || app.installationState === 'pending_configure') && !(app | installError)" uib-tooltip="Configure" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-pencil-alt scale"></i></a>
|
||||
<a href="" ng-click="appConfigure.show(app)" ng-show="app | installError" uib-tooltip="Repair" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-wrench scale"></i></a>
|
||||
<a href="" ng-show="app | activeTask" ng-click="appCancel.show(app)" uib-tooltip="Cancel {{app | installationStateCancelTooltip}}" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-ban scale"></i></a>
|
||||
<a href="" ng-hide="app | activeTask" ng-click="appUninstall.show(app)" uib-tooltip="Uninstall" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-times scale"></i></a>
|
||||
<a href="" ng-hide="!backupsEnabled || (app | activeTask)" ng-click="appRestore.show(app)" uib-tooltip="Backups" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-archive scale"></i></a>
|
||||
<a href="" ng-hide="(app | activeTask) || (app | installError)" ng-click="appConfigure.show(app)" uib-tooltip="Configure" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-pencil-alt scale"></i></a>
|
||||
<a href="" ng-hide="(app | activeTask) || !(app | installError)" ng-click="appConfigure.show(app)" uib-tooltip="Repair" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-wrench scale"></i></a>
|
||||
<a ng-href="{{ '/terminal.html?id=' + app.id }}" target="_blank" uib-tooltip="Terminal" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-terminal scale"></i></a>
|
||||
<a ng-href="{{ '/logs.html?appId=' + app.id }}" target="_blank" uib-tooltip="Logs" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-file-alt scale"></i></a>
|
||||
<a href="" ng-click="showInformation(app)" uib-tooltip="Information" tooltip-placement="right" tooltip-class="app-tooltip"><i class="fa fa-info-circle scale"></i></a>
|
||||
|
||||
@@ -456,6 +456,29 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
|
||||
}
|
||||
};
|
||||
|
||||
$scope.appCancel = {
|
||||
app: {},
|
||||
busy: false,
|
||||
|
||||
show: function (app) {
|
||||
$scope.appCancel.app = app;
|
||||
$scope.appCancel.busy = false;
|
||||
|
||||
$('#appCancelModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
Client.stopTask($scope.appCancel.app.taskId, function (error) {
|
||||
if (error) Client.error(error);
|
||||
$scope.appCancel.busy = false;
|
||||
|
||||
$('#appCancelModal').modal('hide');
|
||||
});
|
||||
|
||||
return false; // prevent propagation and default
|
||||
}
|
||||
};
|
||||
|
||||
$scope.appInfo = {
|
||||
app: {},
|
||||
message: ''
|
||||
|
||||
Reference in New Issue
Block a user