mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-31 04:00:18 -07:00
New: Scheduled tasks shwon in UI under System
This commit is contained in:
parent
879035b28a
commit
2b0ddb6131
14 changed files with 310 additions and 8 deletions
41
src/UI/System/Task/ExecuteTaskCell.js
Normal file
41
src/UI/System/Task/ExecuteTaskCell.js
Normal 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')
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
19
src/UI/System/Task/TaskCollection.js
Normal file
19
src/UI/System/Task/TaskCollection.js
Normal 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'
|
||||
});
|
||||
});
|
25
src/UI/System/Task/TaskIntervalCell.js
Normal file
25
src/UI/System/Task/TaskIntervalCell.js
Normal 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;
|
||||
}
|
||||
});
|
||||
});
|
73
src/UI/System/Task/TaskLayout.js
Normal file
73
src/UI/System/Task/TaskLayout.js
Normal 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'
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
5
src/UI/System/Task/TaskLayoutTemplate.hbs
Normal file
5
src/UI/System/Task/TaskLayoutTemplate.hbs
Normal file
|
@ -0,0 +1,5 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="x-tasks" class="table-responsive"/>
|
||||
</div>
|
||||
</div>
|
9
src/UI/System/Task/TaskModel.js
Normal file
9
src/UI/System/Task/TaskModel.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue