Added possibility to enable / disable tasks.
This commit is contained in:
parent
8f8d78d1df
commit
53a0ecd366
7 changed files with 109 additions and 46 deletions
admin/js
|
@ -14,6 +14,13 @@ myApp.config(['NgAdminConfigurationProvider', function(NgAdminConfigurationProvi
|
|||
.baseApiUrl('/internal/api/')
|
||||
.debug(true);
|
||||
|
||||
function taskClasses(task) {
|
||||
if (!task) {
|
||||
return;
|
||||
}
|
||||
return task.values.enabled ? 'task-enabled' : 'task-disabled';
|
||||
}
|
||||
|
||||
var tasks = nga.entity('tasks').label('Background-Jobs');
|
||||
tasks
|
||||
.listView()
|
||||
|
@ -22,14 +29,17 @@ myApp.config(['NgAdminConfigurationProvider', function(NgAdminConfigurationProvi
|
|||
.batchActions([])
|
||||
.exportFields([])
|
||||
.fields([
|
||||
nga.field('id'),
|
||||
nga.field('name'),
|
||||
nga.field('schedule'),
|
||||
nga.field('runningSince').map(formatMoment),
|
||||
nga.field('lastRunStarted').map(formatMoment)
|
||||
nga.field('id').cssClasses(taskClasses),
|
||||
nga.field('name').cssClasses(taskClasses),
|
||||
nga.field('schedule').cssClasses(taskClasses),
|
||||
nga.field('state').cssClasses(taskClasses),
|
||||
nga.field('runningSince').map(formatMoment).cssClasses(taskClasses),
|
||||
nga.field('lastRunStarted').map(formatMoment).cssClasses(taskClasses)
|
||||
])
|
||||
.listActions(
|
||||
'<fa-task-action-button action="run" task="entry" label="Run" size="sm"></fa-task-action-button>'
|
||||
'<fa-task-action-button action="run" task="entry" button="primary" label="run" size="sm"></fa-task-action-button> ' +
|
||||
'<fa-task-action-button disabled="entry.values.enabled" button="success" action="enable" icon="off" task="entry" label="enable" size="sm"></fa-task-action-button> ' +
|
||||
'<fa-task-action-button disabled="!entry.values.enabled" button="warning" action="disable" icon="off" task="entry" label="disable" size="sm"></fa-task-action-button>'
|
||||
)
|
||||
;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ angular.module('ffffngAdmin')
|
|||
var link = function (scope) {
|
||||
scope.label = scope.label || 'ACTION';
|
||||
scope.icon = scope.icon || 'play';
|
||||
scope.button = scope.button || 'default';
|
||||
|
||||
scope.perform = function () {
|
||||
var task = scope.task();
|
||||
|
@ -28,12 +29,14 @@ angular.module('ffffngAdmin')
|
|||
'icon': '@',
|
||||
'task': '&',
|
||||
'size': '@',
|
||||
'label': '@'
|
||||
'label': '@',
|
||||
'button': '@',
|
||||
'disabled': '='
|
||||
},
|
||||
|
||||
'template':
|
||||
'<a class="btn btn-default" ng-class="size ? \'btn-\' + size : \'\'" ng-click="perform()">' +
|
||||
'<button class="btn btn-{{ button }}" ng-disabled="disabled" ng-class="size ? \'btn-\' + size : \'\'" ng-click="perform()">' +
|
||||
'<span class="glyphicon glyphicon-{{ icon }}" aria-hidden="true"></span> <span class="hidden-xs">{{ label }}</span>' +
|
||||
'</a>'
|
||||
'</button>'
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue