1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-18 21:35:51 -04:00

SignalR for tasks, better handling of future/disabled jobs

This commit is contained in:
Mark McDowall
2014-09-12 17:04:02 -07:00
parent 80ed203258
commit 51b397a00c
6 changed files with 96 additions and 11 deletions

View File

@@ -0,0 +1,45 @@
'use strict';
define(
[
'Cells/NzbDroneCell',
'moment',
'Shared/UiSettingsModel'
], function (NzbDroneCell, moment, UiSettings) {
return NzbDroneCell.extend({
className: 'next-execution-cell',
render: function () {
this.$el.empty();
var interval = this.model.get('interval');
var nextExecution = moment(this.model.get('nextExecution'));
if (interval === 0 ) {
this.$el.html('-');
}
else if (moment().isAfter(nextExecution)) {
this.$el.html('now');
}
else {
var result = '<span title="{0}">{1}</span>';
if (UiSettings.get('showRelativeDates')) {
var tooltip = nextExecution.format(UiSettings.longDateTime());
var text = nextExecution.fromNow();
this.$el.html(result.format(tooltip, text));
}
else {
this.$el.html(nextExecution.format(UiSettings.longDateTime()));
}
}
return this;
}
});
});

View File

@@ -13,11 +13,15 @@ define(
this.$el.empty();
var interval = this.model.get('interval');
var duration = moment.duration(interval, 'minutes').humanize();
var duration = moment.duration(interval, 'minutes').humanize().replace(/an?(?=\s)/, '1');
this.$el.html(
duration.replace(/an?(?=\s)/, '1')
);
if (interval === 0 ) {
this.$el.html('disabled');
}
else {
this.$el.html(duration);
}
return this;
}

View File

@@ -7,8 +7,17 @@ define(
'Cells/RelativeTimeCell',
'System/Task/TaskIntervalCell',
'System/Task/ExecuteTaskCell',
'Shared/LoadingView'
], function (Marionette, Backgrid, BackupCollection, RelativeTimeCell, TaskIntervalCell, ExecuteTaskCell, LoadingView) {
'System/Task/NextExecutionCell',
'Shared/LoadingView',
'Mixins/backbone.signalr.mixin'
], function (Marionette,
Backgrid,
BackupCollection,
RelativeTimeCell,
TaskIntervalCell,
ExecuteTaskCell,
NextExecutionCell,
LoadingView) {
return Marionette.Layout.extend({
template: 'System/Task/TaskLayoutTemplate',
@@ -39,7 +48,7 @@ define(
name : 'nextExecution',
label : 'Next Execution',
sortable : true,
cell : RelativeTimeCell
cell : NextExecutionCell
},
{
name : 'this',
@@ -53,6 +62,7 @@ define(
this.taskCollection = new BackupCollection();
this.listenTo(this.taskCollection, 'sync', this._showTasks);
this.taskCollection.bindSignalR();
},
onRender: function () {

View File

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