New: Scheduled tasks shwon in UI under System

This commit is contained in:
Mark McDowall 2014-09-11 23:06:11 -07:00
parent 879035b28a
commit 2b0ddb6131
14 changed files with 310 additions and 8 deletions

View file

@ -0,0 +1,41 @@
'use strict';
define(
[
'Cells/NzbDroneCell',
'Commands/CommandController'
], function (NzbDroneCell, CommandController) {
return NzbDroneCell.extend({
className: 'execute-task-cell',
events: {
'click .x-execute' : '_executeTask'
},
render: function () {
this.$el.empty();
var task = this.model.get('name');
this.$el.html(
'<i class="icon-cogs x-execute" title="Execute {0}"></i>'.format(task)
);
CommandController.bindToCommand({
element: this.$el.find('.x-execute'),
command: {
name : task
}
});
return this;
},
_executeTask: function () {
CommandController.Execute(this.model.get('name'), {
name : this.model.get('name')
});
}
});
});

View file

@ -0,0 +1,19 @@
'use strict';
define(
[
'backbone.pageable',
'System/Task/TaskModel'
], function (PageableCollection, TaskModel) {
return PageableCollection.extend({
url : window.NzbDrone.ApiRoot + '/system/task',
model: TaskModel,
state: {
sortKey : 'name',
order : -1,
pageSize : 100000
},
mode: 'client'
});
});

View file

@ -0,0 +1,25 @@
'use strict';
define(
[
'Cells/NzbDroneCell',
'moment'
], function (NzbDroneCell, moment) {
return NzbDroneCell.extend({
className: 'task-interval-cell',
render: function () {
this.$el.empty();
var interval = this.model.get('interval');
var duration = moment.duration(interval, 'minutes').humanize();
this.$el.html(
duration.replace(/an?(?=\s)/, '1')
);
return this;
}
});
});

View file

@ -0,0 +1,73 @@
'use strict';
define(
[
'marionette',
'backgrid',
'System/Task/TaskCollection',
'Cells/RelativeTimeCell',
'System/Task/TaskIntervalCell',
'System/Task/ExecuteTaskCell',
'Shared/LoadingView'
], function (Marionette, Backgrid, BackupCollection, RelativeTimeCell, TaskIntervalCell, ExecuteTaskCell, LoadingView) {
return Marionette.Layout.extend({
template: 'System/Task/TaskLayoutTemplate',
regions: {
tasks : '#x-tasks'
},
columns: [
{
name : 'name',
label : 'Name',
sortable : true,
cell : 'string'
},
{
name : 'interval',
label : 'Interval',
sortable : true,
cell : TaskIntervalCell
},
{
name : 'lastExecution',
label : 'Last Execution',
sortable : true,
cell : RelativeTimeCell
},
{
name : 'nextExecution',
label : 'Next Execution',
sortable : true,
cell : RelativeTimeCell
},
{
name : 'this',
label : '',
sortable : false,
cell : ExecuteTaskCell
}
],
initialize: function () {
this.taskCollection = new BackupCollection();
this.listenTo(this.taskCollection, 'sync', this._showTasks);
},
onRender: function () {
this.tasks.show(new LoadingView());
this.taskCollection.fetch();
},
_showTasks: function () {
this.tasks.show(new Backgrid.Grid({
columns : this.columns,
collection: this.taskCollection,
className : 'table table-hover'
}));
}
});
});

View file

@ -0,0 +1,5 @@
<div class="row">
<div class="col-md-12">
<div id="x-tasks" class="table-responsive"/>
</div>
</div>

View file

@ -0,0 +1,9 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});