mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-16 21:16:24 -04:00
rjs -> webpack
This commit is contained in:
@@ -1,19 +1,13 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone.pageable',
|
||||
'System/Backup/BackupModel'
|
||||
], function (PageableCollection, BackupModel) {
|
||||
return PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/system/backup',
|
||||
model: BackupModel,
|
||||
var PageableCollection = require('backbone.pageable');
|
||||
var BackupModel = require('./BackupModel');
|
||||
|
||||
state: {
|
||||
sortKey : 'time',
|
||||
order : 1,
|
||||
pageSize : 100000
|
||||
},
|
||||
|
||||
mode: 'client'
|
||||
});
|
||||
});
|
||||
module.exports = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/system/backup',
|
||||
model : BackupModel,
|
||||
state : {
|
||||
sortKey : 'time',
|
||||
order : 1,
|
||||
pageSize : 100000
|
||||
},
|
||||
mode : 'client'
|
||||
});
|
||||
@@ -1,10 +1,3 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Backup/BackupEmptyViewTemplate'
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({template : 'System/Backup/BackupEmptyViewTemplate'});
|
||||
@@ -1,12 +1,6 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/TemplatedCell'
|
||||
], function (TemplatedCell) {
|
||||
return TemplatedCell.extend({
|
||||
var TemplatedCell = require('../../Cells/TemplatedCell');
|
||||
|
||||
className: 'series-title-cell',
|
||||
template : 'System/Backup/BackupFilenameCellTemplate'
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = TemplatedCell.extend({
|
||||
className : 'series-title-cell',
|
||||
template : 'System/Backup/BackupFilenameCellTemplate'
|
||||
});
|
||||
@@ -1,106 +1,80 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'System/Backup/BackupCollection',
|
||||
'Cells/RelativeDateCell',
|
||||
'System/Backup/BackupFilenameCell',
|
||||
'System/Backup/BackupTypeCell',
|
||||
'System/Backup/BackupEmptyView',
|
||||
'Shared/LoadingView',
|
||||
'Shared/Toolbar/ToolbarLayout'
|
||||
], function (vent, Marionette, Backgrid, BackupCollection, RelativeDateCell, BackupFilenameCell, BackupTypeCell, EmptyView, LoadingView, ToolbarLayout) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Backup/BackupLayoutTemplate',
|
||||
var vent = require('../../vent');
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var BackupCollection = require('./BackupCollection');
|
||||
var RelativeDateCell = require('../../Cells/RelativeDateCell');
|
||||
var BackupFilenameCell = require('./BackupFilenameCell');
|
||||
var BackupTypeCell = require('./BackupTypeCell');
|
||||
var EmptyView = require('./BackupEmptyView');
|
||||
var LoadingView = require('../../Shared/LoadingView');
|
||||
var ToolbarLayout = require('../../Shared/Toolbar/ToolbarLayout');
|
||||
|
||||
regions: {
|
||||
backups : '#x-backups',
|
||||
toolbar : '#x-backup-toolbar'
|
||||
},
|
||||
|
||||
columns: [
|
||||
{
|
||||
name : 'type',
|
||||
label : '',
|
||||
sortable : false,
|
||||
cell : BackupTypeCell
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : 'Name',
|
||||
sortable : false,
|
||||
cell : BackupFilenameCell
|
||||
},
|
||||
{
|
||||
name : 'time',
|
||||
label : 'Time',
|
||||
sortable : false,
|
||||
cell : RelativeDateCell
|
||||
}
|
||||
],
|
||||
|
||||
leftSideButtons: {
|
||||
type : 'default',
|
||||
storeState: false,
|
||||
collapse : false,
|
||||
items :
|
||||
[
|
||||
{
|
||||
title : 'Backup',
|
||||
icon : 'icon-file-text',
|
||||
command : 'backup',
|
||||
properties : { type: 'manual' },
|
||||
successMessage: 'Database and settings were backed up successfully',
|
||||
errorMessage : 'Backup Failed!'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.backupCollection = new BackupCollection();
|
||||
|
||||
this.listenTo(this.backupCollection, 'sync', this._showBackups);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this._showToolbar();
|
||||
this.backups.show(new LoadingView());
|
||||
|
||||
this.backupCollection.fetch();
|
||||
},
|
||||
|
||||
_showBackups: function () {
|
||||
|
||||
if (this.backupCollection.length === 0) {
|
||||
this.backups.show(new EmptyView());
|
||||
}
|
||||
|
||||
else {
|
||||
this.backups.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection: this.backupCollection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
}
|
||||
},
|
||||
|
||||
_showToolbar : function () {
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left :
|
||||
[
|
||||
this.leftSideButtons
|
||||
],
|
||||
context: this
|
||||
}));
|
||||
},
|
||||
|
||||
_commandComplete: function (options) {
|
||||
if (options.command.get('name') === 'backup') {
|
||||
this.backupCollection.fetch();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Backup/BackupLayoutTemplate',
|
||||
regions : {
|
||||
backups : '#x-backups',
|
||||
toolbar : '#x-backup-toolbar'
|
||||
},
|
||||
columns : [{
|
||||
name : 'type',
|
||||
label : '',
|
||||
sortable : false,
|
||||
cell : BackupTypeCell
|
||||
}, {
|
||||
name : 'this',
|
||||
label : 'Name',
|
||||
sortable : false,
|
||||
cell : BackupFilenameCell
|
||||
}, {
|
||||
name : 'time',
|
||||
label : 'Time',
|
||||
sortable : false,
|
||||
cell : RelativeDateCell
|
||||
}],
|
||||
leftSideButtons : {
|
||||
type : 'default',
|
||||
storeState : false,
|
||||
collapse : false,
|
||||
items : [{
|
||||
title : 'Backup',
|
||||
icon : 'icon-file-text',
|
||||
command : 'backup',
|
||||
properties : {type : 'manual'},
|
||||
successMessage : 'Database and settings were backed up successfully',
|
||||
errorMessage : 'Backup Failed!'
|
||||
}]
|
||||
},
|
||||
initialize : function(){
|
||||
this.backupCollection = new BackupCollection();
|
||||
this.listenTo(this.backupCollection, 'sync', this._showBackups);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
},
|
||||
onRender : function(){
|
||||
this._showToolbar();
|
||||
this.backups.show(new LoadingView());
|
||||
this.backupCollection.fetch();
|
||||
},
|
||||
_showBackups : function(){
|
||||
if(this.backupCollection.length === 0) {
|
||||
this.backups.show(new EmptyView());
|
||||
}
|
||||
else {
|
||||
this.backups.show(new Backgrid.Grid({
|
||||
columns : this.columns,
|
||||
collection : this.backupCollection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
}
|
||||
},
|
||||
_showToolbar : function(){
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left : [this.leftSideButtons],
|
||||
context : this
|
||||
}));
|
||||
},
|
||||
_commandComplete : function(options){
|
||||
if(options.command.get('name') === 'backup') {
|
||||
this.backupCollection.fetch();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,9 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
var Backbone = require('backbone');
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Model.extend({});
|
||||
@@ -1,33 +1,21 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
|
||||
className: 'backup-type-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
var icon = 'icon-time';
|
||||
var title = 'Scheduled';
|
||||
|
||||
var type = this.model.get(this.column.get('name'));
|
||||
|
||||
if (type === 'manual') {
|
||||
icon = 'icon-book';
|
||||
title = 'Manual';
|
||||
}
|
||||
|
||||
else if (type === 'update') {
|
||||
icon = 'icon-retweet';
|
||||
title = 'Before update';
|
||||
}
|
||||
|
||||
this.$el.html('<i class="{0}" title="{1}"></i>'.format(icon, title));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'backup-type-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var icon = 'icon-time';
|
||||
var title = 'Scheduled';
|
||||
var type = this.model.get(this.column.get('name'));
|
||||
if(type === 'manual') {
|
||||
icon = 'icon-book';
|
||||
title = 'Manual';
|
||||
}
|
||||
else if(type === 'update') {
|
||||
icon = 'icon-retweet';
|
||||
title = 'Before update';
|
||||
}
|
||||
this.$el.html('<i class="{0}" title="{1}"></i>'.format(icon, title));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,14 +1,9 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'System/StatusModel'
|
||||
], function (Marionette, StatusModel) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Info/About/AboutViewTemplate',
|
||||
var Marionette = require('marionette');
|
||||
var StatusModel = require('../../StatusModel');
|
||||
|
||||
initialize: function () {
|
||||
this.model = StatusModel;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'System/Info/About/AboutViewTemplate',
|
||||
initialize : function(){
|
||||
this.model = StatusModel;
|
||||
}
|
||||
});
|
||||
@@ -1,11 +1,7 @@
|
||||
'use strict';
|
||||
var Backbone = require('backbone');
|
||||
var DiskSpaceModel = require('./DiskSpaceModel');
|
||||
|
||||
define(['backbone',
|
||||
'System/Info/DiskSpace/DiskSpaceModel'],
|
||||
function(Backbone, DiskSpaceModel) {
|
||||
return Backbone.Collection.extend({
|
||||
|
||||
url : window.NzbDrone.ApiRoot +'/diskspace',
|
||||
model : DiskSpaceModel
|
||||
});
|
||||
module.exports = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/diskspace',
|
||||
model : DiskSpaceModel
|
||||
});
|
||||
@@ -1,62 +1,46 @@
|
||||
'use strict';
|
||||
define([
|
||||
'vent',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'System/Info/DiskSpace/DiskSpaceCollection',
|
||||
'Shared/LoadingView',
|
||||
'System/Info/DiskSpace/DiskSpacePathCell',
|
||||
'Cells/FileSizeCell'
|
||||
], function (vent,Marionette,Backgrid,DiskSpaceCollection,LoadingView, DiskSpacePathCell, FileSizeCell) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Info/DiskSpace/DiskSpaceLayoutTemplate',
|
||||
var vent = require('../../../vent');
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var DiskSpaceCollection = require('./DiskSpaceCollection');
|
||||
var LoadingView = require('../../../Shared/LoadingView');
|
||||
var DiskSpacePathCell = require('./DiskSpacePathCell');
|
||||
var FileSizeCell = require('../../../Cells/FileSizeCell');
|
||||
|
||||
regions: {
|
||||
grid: '#x-grid'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'path',
|
||||
label : 'Location',
|
||||
cell : DiskSpacePathCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'freeSpace',
|
||||
label : 'Free Space',
|
||||
cell : FileSizeCell,
|
||||
sortable : false
|
||||
},
|
||||
{
|
||||
name : 'totalSpace',
|
||||
label : 'Total Space',
|
||||
cell : FileSizeCell,
|
||||
sortable : false
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new DiskSpaceCollection();
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
},
|
||||
|
||||
onRender : function() {
|
||||
this.grid.show(new LoadingView());
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
_showTable: function() {
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row: Backgrid.Row,
|
||||
columns: this.columns,
|
||||
collection: this.collection,
|
||||
className:'table table-hover'
|
||||
}));
|
||||
}
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Info/DiskSpace/DiskSpaceLayoutTemplate',
|
||||
regions : {grid : '#x-grid'},
|
||||
columns : [{
|
||||
name : 'path',
|
||||
label : 'Location',
|
||||
cell : DiskSpacePathCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'freeSpace',
|
||||
label : 'Free Space',
|
||||
cell : FileSizeCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'totalSpace',
|
||||
label : 'Total Space',
|
||||
cell : FileSizeCell,
|
||||
sortable : false
|
||||
}],
|
||||
initialize : function(){
|
||||
this.collection = new DiskSpaceCollection();
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
},
|
||||
onRender : function(){
|
||||
this.grid.show(new LoadingView());
|
||||
},
|
||||
onShow : function(){
|
||||
this.collection.fetch();
|
||||
},
|
||||
_showTable : function(){
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row : Backgrid.Row,
|
||||
columns : this.columns,
|
||||
collection : this.collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
}
|
||||
});
|
||||
@@ -1,6 +1,3 @@
|
||||
'use strict';
|
||||
define(['backbone'], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backbone.Model.extend({});
|
||||
@@ -1,28 +1,16 @@
|
||||
'use strict';
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
define(
|
||||
[
|
||||
'backgrid'
|
||||
], function (Backgrid) {
|
||||
return Backgrid.Cell.extend({
|
||||
|
||||
className: 'disk-space-path-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
|
||||
var path = this.model.get('path');
|
||||
var label = this.model.get('label');
|
||||
|
||||
var contents = path;
|
||||
|
||||
if (label) {
|
||||
contents += ' ({0})'.format(label);
|
||||
}
|
||||
|
||||
this.$el.html(contents);
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Cell.extend({
|
||||
className : 'disk-space-path-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var path = this.model.get('path');
|
||||
var label = this.model.get('label');
|
||||
var contents = path;
|
||||
if(label) {
|
||||
contents += ' ({0})'.format(label);
|
||||
}
|
||||
this.$el.html(contents);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,18 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../../Cells/NzbDroneCell');
|
||||
|
||||
className: 'log-level-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var level = this._getValue();
|
||||
this.$el.html('<i class="icon-nd-health-{0}" title="{1}"/>'.format(this._getValue().toLowerCase(), level));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'log-level-cell',
|
||||
render : function(){
|
||||
var level = this._getValue();
|
||||
this.$el.html('<i class="icon-nd-health-{0}" title="{1}"/>'.format(this._getValue().toLowerCase(), level));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,64 +1,47 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'Health/HealthCollection',
|
||||
'System/Info/Health/HealthCell',
|
||||
'System/Info/Health/HealthWikiCell',
|
||||
'System/Info/Health/HealthOkView'
|
||||
], function (Marionette, Backgrid, HealthCollection, HealthCell, HealthWikiCell, HealthOkView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Info/Health/HealthLayoutTemplate',
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var HealthCollection = require('../../../Health/HealthCollection');
|
||||
var HealthCell = require('./HealthCell');
|
||||
var HealthWikiCell = require('./HealthWikiCell');
|
||||
var HealthOkView = require('./HealthOkView');
|
||||
|
||||
regions: {
|
||||
grid: '#x-health-grid'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name: 'type',
|
||||
label: '',
|
||||
cell: HealthCell,
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
label: 'Message',
|
||||
cell: 'string',
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name: 'wikiUrl',
|
||||
label: '',
|
||||
cell: HealthWikiCell,
|
||||
sortable: false
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.listenTo(HealthCollection, 'sync', this.render);
|
||||
HealthCollection.fetch();
|
||||
},
|
||||
|
||||
onRender : function() {
|
||||
if (HealthCollection.length === 0) {
|
||||
this.grid.show(new HealthOkView());
|
||||
}
|
||||
|
||||
else {
|
||||
this._showTable();
|
||||
}
|
||||
},
|
||||
|
||||
_showTable: function() {
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row: Backgrid.Row,
|
||||
columns: this.columns,
|
||||
collection: HealthCollection,
|
||||
className:'table table-hover'
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Info/Health/HealthLayoutTemplate',
|
||||
regions : {grid : '#x-health-grid'},
|
||||
columns : [{
|
||||
name : 'type',
|
||||
label : '',
|
||||
cell : HealthCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'message',
|
||||
label : 'Message',
|
||||
cell : 'string',
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'wikiUrl',
|
||||
label : '',
|
||||
cell : HealthWikiCell,
|
||||
sortable : false
|
||||
}],
|
||||
initialize : function(){
|
||||
this.listenTo(HealthCollection, 'sync', this.render);
|
||||
HealthCollection.fetch();
|
||||
},
|
||||
onRender : function(){
|
||||
if(HealthCollection.length === 0) {
|
||||
this.grid.show(new HealthOkView());
|
||||
}
|
||||
else {
|
||||
this._showTable();
|
||||
}
|
||||
},
|
||||
_showTable : function(){
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row : Backgrid.Row,
|
||||
columns : this.columns,
|
||||
collection : HealthCollection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
}
|
||||
});
|
||||
@@ -1,9 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Info/Health/HealthOkViewTemplate'
|
||||
});
|
||||
});
|
||||
var Marionette = require('marionette');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({template : 'System/Info/Health/HealthOkViewTemplate'});
|
||||
@@ -1,29 +1,21 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'backgrid'
|
||||
], function ($, Backgrid) {
|
||||
return Backgrid.UriCell.extend({
|
||||
var $ = require('jquery');
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
className: 'wiki-link-cell',
|
||||
|
||||
title: 'Read the Wiki for more information',
|
||||
|
||||
text: 'Wiki',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
var rawValue = this.model.get(this.column.get("name"));
|
||||
var formattedValue = this.formatter.fromRaw(rawValue, this.model);
|
||||
this.$el.append($("<a>", {
|
||||
tabIndex: -1,
|
||||
href: rawValue,
|
||||
title: this.title || formattedValue,
|
||||
target: this.target
|
||||
}).text(this.text));
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.UriCell.extend({
|
||||
className : 'wiki-link-cell',
|
||||
title : 'Read the Wiki for more information',
|
||||
text : 'Wiki',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var rawValue = this.model.get(this.column.get('name'));
|
||||
var formattedValue = this.formatter.fromRaw(rawValue, this.model);
|
||||
this.$el.append($('<a>', {
|
||||
tabIndex : -1,
|
||||
href : rawValue,
|
||||
title : this.title || formattedValue,
|
||||
target : this.target
|
||||
}).text(this.text));
|
||||
this.delegateEvents();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,9 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Info/MoreInfo/MoreInfoViewTemplate'
|
||||
});
|
||||
});
|
||||
var Marionette = require('marionette');
|
||||
|
||||
module.exports = Marionette.ItemView.extend({template : 'System/Info/MoreInfo/MoreInfoViewTemplate'});
|
||||
@@ -1,34 +1,22 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'marionette',
|
||||
'System/Info/About/AboutView',
|
||||
'System/Info/DiskSpace/DiskSpaceLayout',
|
||||
'System/Info/Health/HealthLayout',
|
||||
'System/Info/MoreInfo/MoreInfoView'
|
||||
], function (Backbone,
|
||||
Marionette,
|
||||
AboutView,
|
||||
DiskSpaceLayout,
|
||||
HealthLayout,
|
||||
MoreInfoView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Info/SystemInfoLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
about : '#about',
|
||||
diskSpace : '#diskspace',
|
||||
health : '#health',
|
||||
moreInfo : '#more-info'
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.health.show(new HealthLayout());
|
||||
this.diskSpace.show(new DiskSpaceLayout());
|
||||
this.about.show(new AboutView());
|
||||
this.moreInfo.show(new MoreInfoView());
|
||||
}
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
var Marionette = require('marionette');
|
||||
var AboutView = require('./About/AboutView');
|
||||
var DiskSpaceLayout = require('./DiskSpace/DiskSpaceLayout');
|
||||
var HealthLayout = require('./Health/HealthLayout');
|
||||
var MoreInfoView = require('./MoreInfo/MoreInfoView');
|
||||
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Info/SystemInfoLayoutTemplate',
|
||||
regions : {
|
||||
about : '#about',
|
||||
diskSpace : '#diskspace',
|
||||
health : '#health',
|
||||
moreInfo : '#more-info'
|
||||
},
|
||||
onRender : function(){
|
||||
this.health.show(new HealthLayout());
|
||||
this.diskSpace.show(new DiskSpaceLayout());
|
||||
this.about.show(new AboutView());
|
||||
this.moreInfo.show(new MoreInfoView());
|
||||
}
|
||||
});
|
||||
@@ -1,17 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
url: function () {
|
||||
return this.get('contentsUrl');
|
||||
},
|
||||
var Backbone = require('backbone');
|
||||
|
||||
parse: function (contents) {
|
||||
var response = {};
|
||||
response.contents = contents;
|
||||
return response;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Model.extend({
|
||||
url : function(){
|
||||
return this.get('contentsUrl');
|
||||
},
|
||||
parse : function(contents){
|
||||
var response = {};
|
||||
response.contents = contents;
|
||||
return response;
|
||||
}
|
||||
});
|
||||
@@ -1,10 +1,3 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Logs/Files/ContentsViewTemplate'
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({template : 'System/Logs/Files/ContentsViewTemplate'});
|
||||
@@ -1,17 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'../../../Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../../Cells/NzbDroneCell');
|
||||
|
||||
className: 'download-log-cell',
|
||||
|
||||
render: function () {
|
||||
this.$el.empty();
|
||||
this.$el.html('<a href="{0}" class="no-router" target="_blank">Download</a>'.format(this.cellValue));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'download-log-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
this.$el.html('<a href="{0}" class="no-router" target="_blank">Download</a>'.format(this.cellValue));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,18 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'../../../Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../../Cells/NzbDroneCell');
|
||||
|
||||
className: 'log-filename-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var filename = this._getValue();
|
||||
this.$el.html(filename);
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'log-filename-cell',
|
||||
render : function(){
|
||||
var filename = this._getValue();
|
||||
this.$el.html(filename);
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,17 +1,11 @@
|
||||
'use strict';
|
||||
var Backbone = require('backbone');
|
||||
var LogFileModel = require('./LogFileModel');
|
||||
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'System/Logs/Files/LogFileModel'
|
||||
], function (Backbone, LogFileModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/log/file',
|
||||
model: LogFileModel,
|
||||
|
||||
state: {
|
||||
sortKey: 'lastWriteTime',
|
||||
order : 1
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/log/file',
|
||||
model : LogFileModel,
|
||||
state : {
|
||||
sortKey : 'lastWriteTime',
|
||||
order : 1
|
||||
}
|
||||
});
|
||||
@@ -1,155 +1,108 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'System/Logs/Files/FilenameCell',
|
||||
'Cells/RelativeDateCell',
|
||||
'System/Logs/Files/DownloadLogCell',
|
||||
'System/Logs/Files/Row',
|
||||
'System/Logs/Files/ContentsView',
|
||||
'System/Logs/Files/ContentsModel',
|
||||
'Shared/Toolbar/ToolbarLayout',
|
||||
'Shared/LoadingView',
|
||||
'jQuery/jquery.spin'
|
||||
], function (vent,
|
||||
Marionette,
|
||||
Backgrid,
|
||||
FilenameCell,
|
||||
RelativeDateCell,
|
||||
DownloadLogCell,
|
||||
LogFileRow,
|
||||
ContentsView,
|
||||
ContentsModel,
|
||||
ToolbarLayout,
|
||||
LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Logs/Files/LogFileLayoutTemplate',
|
||||
var vent = require('../../../vent');
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var FilenameCell = require('./FilenameCell');
|
||||
var RelativeDateCell = require('../../../Cells/RelativeDateCell');
|
||||
var DownloadLogCell = require('./DownloadLogCell');
|
||||
var LogFileRow = require('./Row');
|
||||
var ContentsView = require('./ContentsView');
|
||||
var ContentsModel = require('./ContentsModel');
|
||||
var ToolbarLayout = require('../../../Shared/Toolbar/ToolbarLayout');
|
||||
var LoadingView = require('../../../Shared/LoadingView');
|
||||
require('../../../jQuery/jquery.spin');
|
||||
|
||||
regions: {
|
||||
toolbar : '#x-toolbar',
|
||||
grid : '#x-grid',
|
||||
contents : '#x-contents'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'filename',
|
||||
label: 'Filename',
|
||||
cell : FilenameCell,
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name : 'lastWriteTime',
|
||||
label: 'Last Write Time',
|
||||
cell : RelativeDateCell,
|
||||
sortable: false
|
||||
},
|
||||
{
|
||||
name : 'downloadUrl',
|
||||
label : '',
|
||||
cell : DownloadLogCell,
|
||||
sortable: false
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function (options) {
|
||||
this.collection = options.collection;
|
||||
this.deleteFilesCommand = options.deleteFilesCommand;
|
||||
|
||||
this.listenTo(vent, vent.Commands.ShowLogFile, this._fetchLogFileContents);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
this.listenTo(this.collection, 'sync', this._collectionSynced);
|
||||
|
||||
this.collection.fetch();
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this._showToolbar();
|
||||
this._showTable();
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
|
||||
var leftSideButtons = {
|
||||
type : 'default',
|
||||
storeState: false,
|
||||
items :
|
||||
[
|
||||
{
|
||||
title : 'Refresh',
|
||||
icon : 'icon-refresh',
|
||||
ownerContext : this,
|
||||
callback : this._refreshTable
|
||||
},
|
||||
{
|
||||
title : 'Delete Log Files',
|
||||
icon : 'icon-trash',
|
||||
command : this.deleteFilesCommand,
|
||||
successMessage : 'Log files have been deleted',
|
||||
errorMessage : 'Failed to delete log files'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left :
|
||||
[
|
||||
leftSideButtons
|
||||
],
|
||||
context: this
|
||||
}));
|
||||
},
|
||||
|
||||
_showTable: function () {
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row : LogFileRow,
|
||||
columns : this.columns,
|
||||
collection: this.collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
},
|
||||
|
||||
_collectionSynced: function () {
|
||||
if (!this.collection.any()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var model = this.collection.first();
|
||||
this._fetchLogFileContents({ model: model });
|
||||
},
|
||||
|
||||
_fetchLogFileContents: function (options) {
|
||||
this.contents.show(new LoadingView());
|
||||
|
||||
var model = options.model;
|
||||
var contentsModel = new ContentsModel(model.toJSON());
|
||||
|
||||
this.listenToOnce(contentsModel, 'sync', this._showDetails);
|
||||
|
||||
contentsModel.fetch({ dataType: 'text' });
|
||||
},
|
||||
|
||||
_showDetails: function (model) {
|
||||
this.contents.show(new ContentsView({ model: model }));
|
||||
},
|
||||
|
||||
_refreshTable: function (buttonContext) {
|
||||
this.contents.close();
|
||||
var promise = this.collection.fetch();
|
||||
|
||||
//Would be nice to spin the icon on the refresh button
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
|
||||
_commandComplete: function (options) {
|
||||
if (options.command.get('name') === this.deleteFilesCommand.toLowerCase()) {
|
||||
this._refreshTable();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Logs/Files/LogFileLayoutTemplate',
|
||||
regions : {
|
||||
toolbar : '#x-toolbar',
|
||||
grid : '#x-grid',
|
||||
contents : '#x-contents'
|
||||
},
|
||||
columns : [{
|
||||
name : 'filename',
|
||||
label : 'Filename',
|
||||
cell : FilenameCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'lastWriteTime',
|
||||
label : 'Last Write Time',
|
||||
cell : RelativeDateCell,
|
||||
sortable : false
|
||||
}, {
|
||||
name : 'downloadUrl',
|
||||
label : '',
|
||||
cell : DownloadLogCell,
|
||||
sortable : false
|
||||
}],
|
||||
initialize : function(options){
|
||||
this.collection = options.collection;
|
||||
this.deleteFilesCommand = options.deleteFilesCommand;
|
||||
this.listenTo(vent, vent.Commands.ShowLogFile, this._fetchLogFileContents);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
this.listenTo(this.collection, 'sync', this._collectionSynced);
|
||||
this.collection.fetch();
|
||||
},
|
||||
onShow : function(){
|
||||
this._showToolbar();
|
||||
this._showTable();
|
||||
},
|
||||
_showToolbar : function(){
|
||||
var leftSideButtons = {
|
||||
type : 'default',
|
||||
storeState : false,
|
||||
items : [{
|
||||
title : 'Refresh',
|
||||
icon : 'icon-refresh',
|
||||
ownerContext : this,
|
||||
callback : this._refreshTable
|
||||
}, {
|
||||
title : 'Delete Log Files',
|
||||
icon : 'icon-trash',
|
||||
command : this.deleteFilesCommand,
|
||||
successMessage : 'Log files have been deleted',
|
||||
errorMessage : 'Failed to delete log files'
|
||||
}]
|
||||
};
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left : [leftSideButtons],
|
||||
context : this
|
||||
}));
|
||||
},
|
||||
_showTable : function(){
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row : LogFileRow,
|
||||
columns : this.columns,
|
||||
collection : this.collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
},
|
||||
_collectionSynced : function(){
|
||||
if(!this.collection.any()) {
|
||||
return;
|
||||
}
|
||||
var model = this.collection.first();
|
||||
this._fetchLogFileContents({model : model});
|
||||
},
|
||||
_fetchLogFileContents : function(options){
|
||||
this.contents.show(new LoadingView());
|
||||
var model = options.model;
|
||||
var contentsModel = new ContentsModel(model.toJSON());
|
||||
this.listenToOnce(contentsModel, 'sync', this._showDetails);
|
||||
contentsModel.fetch({dataType : 'text'});
|
||||
},
|
||||
_showDetails : function(model){
|
||||
this.contents.show(new ContentsView({model : model}));
|
||||
},
|
||||
_refreshTable : function(buttonContext){
|
||||
this.contents.close();
|
||||
var promise = this.collection.fetch();
|
||||
if(buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
_commandComplete : function(options){
|
||||
if(options.command.get('name') === this.deleteFilesCommand.toLowerCase()) {
|
||||
this._refreshTable();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,8 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backbone.Model.extend({});
|
||||
@@ -1,19 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'../../../vent',
|
||||
'backgrid'
|
||||
], function (vent, Backgrid) {
|
||||
var vent = require('../../../vent');
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
return Backgrid.Row.extend({
|
||||
className: 'log-file-row',
|
||||
|
||||
events: {
|
||||
'click': '_showDetails'
|
||||
},
|
||||
|
||||
_showDetails: function () {
|
||||
vent.trigger(vent.Commands.ShowLogFile, { model: this.model });
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Row.extend({
|
||||
className : 'log-file-row',
|
||||
events : {"click" : '_showDetails'},
|
||||
_showDetails : function(){
|
||||
vent.trigger(vent.Commands.ShowLogFile, {model : this.model});
|
||||
}
|
||||
});
|
||||
@@ -1,58 +1,45 @@
|
||||
'use strict';
|
||||
var PagableCollection = require('backbone.pageable');
|
||||
var LogsModel = require('./LogsModel');
|
||||
var AsFilteredCollection = require('../../Mixins/AsFilteredCollection');
|
||||
var AsPersistedStateCollection = require('../../Mixins/AsPersistedStateCollection');
|
||||
|
||||
define(
|
||||
[
|
||||
'backbone.pageable',
|
||||
'System/Logs/LogsModel',
|
||||
'Mixins/AsFilteredCollection',
|
||||
'Mixins/AsPersistedStateCollection'
|
||||
],
|
||||
function (PagableCollection, LogsModel, AsFilteredCollection, AsPersistedStateCollection) {
|
||||
module.exports = (function(){
|
||||
var collection = PagableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/log',
|
||||
model: LogsModel,
|
||||
tableName: 'logs',
|
||||
|
||||
state: {
|
||||
pageSize: 50,
|
||||
sortKey : 'time',
|
||||
order : 1
|
||||
url : window.NzbDrone.ApiRoot + '/log',
|
||||
model : LogsModel,
|
||||
tableName : 'logs',
|
||||
state : {
|
||||
pageSize : 50,
|
||||
sortKey : 'time',
|
||||
order : 1
|
||||
},
|
||||
|
||||
queryParams: {
|
||||
totalPages : null,
|
||||
totalRecords: null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
'-1': 'asc',
|
||||
'1' : 'desc'
|
||||
queryParams : {
|
||||
totalPages : null,
|
||||
totalRecords : null,
|
||||
pageSize : 'pageSize',
|
||||
sortKey : 'sortKey',
|
||||
order : 'sortDir',
|
||||
directions : {
|
||||
"-1" : 'asc',
|
||||
"1" : 'desc'
|
||||
}
|
||||
},
|
||||
|
||||
// Filter Modes
|
||||
filterModes: {
|
||||
'all' : [null, null],
|
||||
'info' : ['level', 'Info'],
|
||||
'warn' : ['level', 'Warn'],
|
||||
'error' : ['level', 'Error']
|
||||
filterModes : {
|
||||
"all" : [null, null],
|
||||
"info" : ['level', 'Info'],
|
||||
"warn" : ['level', 'Warn'],
|
||||
"error" : ['level', 'Error']
|
||||
},
|
||||
|
||||
parseState: function (resp, queryParams, state) {
|
||||
return {totalRecords: resp.totalRecords};
|
||||
parseState : function(resp, queryParams, state){
|
||||
return {totalRecords : resp.totalRecords};
|
||||
},
|
||||
|
||||
parseRecords: function (resp) {
|
||||
if (resp) {
|
||||
parseRecords : function(resp){
|
||||
if(resp) {
|
||||
return resp.records;
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
});
|
||||
|
||||
collection = AsFilteredCollection.apply(collection);
|
||||
|
||||
return AsPersistedStateCollection.apply(collection);
|
||||
});
|
||||
}).call(this);
|
||||
@@ -1,68 +1,54 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'System/Logs/Table/LogsTableLayout',
|
||||
'System/Logs/Files/LogFileLayout',
|
||||
'System/Logs/Files/LogFileCollection',
|
||||
'System/Logs/Updates/LogFileCollection'
|
||||
], function (Marionette, LogsTableLayout, LogsFileLayout, LogFileCollection, UpdateLogFileCollection) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Logs/LogsLayoutTemplate',
|
||||
var Marionette = require('marionette');
|
||||
var LogsTableLayout = require('./Table/LogsTableLayout');
|
||||
var LogsFileLayout = require('./Files/LogFileLayout');
|
||||
var LogFileCollection = require('./Files/LogFileCollection');
|
||||
var UpdateLogFileCollection = require('./Updates/LogFileCollection');
|
||||
|
||||
ui: {
|
||||
tableTab : '.x-table-tab',
|
||||
filesTab : '.x-files-tab',
|
||||
updateFilesTab : '.x-update-files-tab'
|
||||
},
|
||||
|
||||
regions: {
|
||||
table : '#table',
|
||||
files : '#files',
|
||||
updateFiles : '#update-files'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-table-tab' : '_showTable',
|
||||
'click .x-files-tab' : '_showFiles',
|
||||
'click .x-update-files-tab' : '_showUpdateFiles'
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this._showTable();
|
||||
},
|
||||
|
||||
_showTable: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.ui.tableTab.tab('show');
|
||||
this.table.show(new LogsTableLayout());
|
||||
},
|
||||
|
||||
_showFiles: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.ui.filesTab.tab('show');
|
||||
this.files.show(new LogsFileLayout({
|
||||
collection: new LogFileCollection(),
|
||||
deleteFilesCommand: 'deleteLogFiles'
|
||||
}));
|
||||
},
|
||||
|
||||
_showUpdateFiles: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.ui.updateFilesTab.tab('show');
|
||||
this.updateFiles.show(new LogsFileLayout({
|
||||
collection: new UpdateLogFileCollection(),
|
||||
deleteFilesCommand: 'deleteUpdateLogFiles'
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Logs/LogsLayoutTemplate',
|
||||
ui : {
|
||||
tableTab : '.x-table-tab',
|
||||
filesTab : '.x-files-tab',
|
||||
updateFilesTab : '.x-update-files-tab'
|
||||
},
|
||||
regions : {
|
||||
table : '#table',
|
||||
files : '#files',
|
||||
updateFiles : '#update-files'
|
||||
},
|
||||
events : {
|
||||
"click .x-table-tab" : '_showTable',
|
||||
"click .x-files-tab" : '_showFiles',
|
||||
"click .x-update-files-tab" : '_showUpdateFiles'
|
||||
},
|
||||
onShow : function(){
|
||||
this._showTable();
|
||||
},
|
||||
_showTable : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.ui.tableTab.tab('show');
|
||||
this.table.show(new LogsTableLayout());
|
||||
},
|
||||
_showFiles : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.ui.filesTab.tab('show');
|
||||
this.files.show(new LogsFileLayout({
|
||||
collection : new LogFileCollection(),
|
||||
deleteFilesCommand : 'deleteLogFiles'
|
||||
}));
|
||||
},
|
||||
_showUpdateFiles : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.ui.updateFilesTab.tab('show');
|
||||
this.updateFiles.show(new LogsFileLayout({
|
||||
collection : new UpdateLogFileCollection(),
|
||||
deleteFilesCommand : 'deleteUpdateLogFiles'
|
||||
}));
|
||||
}
|
||||
});
|
||||
@@ -1,8 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backbone.Model.extend({});
|
||||
@@ -1,11 +1,4 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette'
|
||||
], function (vent, Marionette) {
|
||||
var vent = require('../../../../vent');
|
||||
var Marionette = require('marionette');
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Logs/Table/Details/LogDetailsViewTemplate'
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({template : 'System/Logs/Table/Details/LogDetailsViewTemplate'});
|
||||
@@ -1,18 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell'
|
||||
], function (NzbDroneCell) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../../Cells/NzbDroneCell');
|
||||
|
||||
className: 'log-level-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var level = this._getValue();
|
||||
this.$el.html('<i class="icon-{0}" title="{1}"/>'.format(this._getValue().toLowerCase(), level));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'log-level-cell',
|
||||
render : function(){
|
||||
var level = this._getValue();
|
||||
this.$el.html('<i class="icon-{0}" title="{1}"/>'.format(this._getValue().toLowerCase(), level));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,19 +1,10 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'backgrid'
|
||||
], function (vent, Backgrid) {
|
||||
var vent = require('../../../vent');
|
||||
var Backgrid = require('backgrid');
|
||||
|
||||
return Backgrid.Row.extend({
|
||||
className: 'log-row',
|
||||
|
||||
events: {
|
||||
'click': '_showDetails'
|
||||
},
|
||||
|
||||
_showDetails: function () {
|
||||
vent.trigger(vent.Commands.ShowLogDetails, { model: this.model });
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backgrid.Row.extend({
|
||||
className : 'log-row',
|
||||
events : {"click" : '_showDetails'},
|
||||
_showDetails : function(){
|
||||
vent.trigger(vent.Commands.ShowLogDetails, {model : this.model});
|
||||
}
|
||||
});
|
||||
@@ -1,20 +1,12 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'moment',
|
||||
'Shared/UiSettingsModel'
|
||||
], function (NzbDroneCell, moment, UiSettings) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../../Cells/NzbDroneCell');
|
||||
var moment = require('moment');
|
||||
var UiSettings = require('../../../Shared/UiSettingsModel');
|
||||
|
||||
className: 'log-time-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
var date = moment(this._getValue());
|
||||
this.$el.html('<span title="{1}">{0}</span>'.format(date.format(UiSettings.time(true, false)), date.format(UiSettings.longDateTime(true))));
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'log-time-cell',
|
||||
render : function(){
|
||||
var date = moment(this._getValue());
|
||||
this.$el.html('<span title="{1}">{0}</span>'.format(date.format(UiSettings.time(true, false)), date.format(UiSettings.longDateTime(true))));
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,189 +1,137 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'System/Logs/Table/LogTimeCell',
|
||||
'System/Logs/Table/LogLevelCell',
|
||||
'System/Logs/Table/LogRow',
|
||||
'Shared/Grid/Pager',
|
||||
'System/Logs/LogsCollection',
|
||||
'Shared/Toolbar/ToolbarLayout',
|
||||
'Shared/LoadingView',
|
||||
'jQuery/jquery.spin'
|
||||
], function (vent, Marionette, Backgrid, LogTimeCell, LogLevelCell, LogRow, GridPager, LogCollection, ToolbarLayout, LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Logs/Table/LogsTableLayoutTemplate',
|
||||
var vent = require('../../../vent');
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var LogTimeCell = require('./LogTimeCell');
|
||||
var LogLevelCell = require('./LogLevelCell');
|
||||
var LogRow = require('./LogRow');
|
||||
var GridPager = require('../../../Shared/Grid/Pager');
|
||||
var LogCollection = require('../LogsCollection');
|
||||
var ToolbarLayout = require('../../../Shared/Toolbar/ToolbarLayout');
|
||||
var LoadingView = require('../../../Shared/LoadingView');
|
||||
require('../../../jQuery/jquery.spin');
|
||||
|
||||
regions: {
|
||||
grid : '#x-grid',
|
||||
toolbar: '#x-toolbar',
|
||||
pager : '#x-pager'
|
||||
},
|
||||
|
||||
attributes: {
|
||||
id: 'logs-screen'
|
||||
},
|
||||
|
||||
columns:
|
||||
[
|
||||
{
|
||||
name : 'level',
|
||||
label : '',
|
||||
sortable: true,
|
||||
cell : LogLevelCell
|
||||
},
|
||||
{
|
||||
name : 'logger',
|
||||
label : 'Component',
|
||||
sortable: true,
|
||||
cell : Backgrid.StringCell.extend({
|
||||
className: 'log-logger-cell'
|
||||
})
|
||||
},
|
||||
{
|
||||
name : 'message',
|
||||
label : 'Message',
|
||||
sortable: false,
|
||||
cell : Backgrid.StringCell.extend({
|
||||
className: 'log-message-cell'
|
||||
})
|
||||
},
|
||||
{
|
||||
name : 'time',
|
||||
label: 'Time',
|
||||
cell : LogTimeCell
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new LogCollection();
|
||||
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.grid.show(new LoadingView());
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this._showToolbar();
|
||||
},
|
||||
|
||||
_showTable: function () {
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row : LogRow,
|
||||
columns : this.columns,
|
||||
collection: this.collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection: this.collection
|
||||
}));
|
||||
},
|
||||
|
||||
_showToolbar: function () {
|
||||
var filterButtons = {
|
||||
type : 'radio',
|
||||
storeState : true,
|
||||
menuKey : 'logs.filterMode',
|
||||
defaultAction: 'all',
|
||||
items :
|
||||
[
|
||||
{
|
||||
key : 'all',
|
||||
title : '',
|
||||
tooltip : 'All',
|
||||
icon : 'icon-circle-blank',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'info',
|
||||
title : '',
|
||||
tooltip : 'Info',
|
||||
icon : 'icon-info',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'warn',
|
||||
title : '',
|
||||
tooltip : 'Warn',
|
||||
icon : 'icon-warn',
|
||||
callback : this._setFilter
|
||||
},
|
||||
{
|
||||
key : 'error',
|
||||
title : '',
|
||||
tooltip : 'Error',
|
||||
icon : 'icon-error',
|
||||
callback : this._setFilter
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var leftSideButtons = {
|
||||
type : 'default',
|
||||
storeState: false,
|
||||
items :
|
||||
[
|
||||
{
|
||||
title : 'Refresh',
|
||||
icon : 'icon-refresh',
|
||||
ownerContext : this,
|
||||
callback : this._refreshTable
|
||||
},
|
||||
|
||||
{
|
||||
title : 'Clear Logs',
|
||||
icon : 'icon-trash',
|
||||
command : 'clearLog'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left :
|
||||
[
|
||||
leftSideButtons
|
||||
],
|
||||
right :
|
||||
[
|
||||
filterButtons
|
||||
],
|
||||
context: this
|
||||
}));
|
||||
},
|
||||
|
||||
_refreshTable: function (buttonContext) {
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.fetch({ reset: true });
|
||||
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
|
||||
_setFilter: function(buttonContext) {
|
||||
var mode = buttonContext.model.get('key');
|
||||
|
||||
this.collection.setFilterMode(mode, { reset: false });
|
||||
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.fetch({ reset: true });
|
||||
|
||||
if (buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
|
||||
_commandComplete: function (options) {
|
||||
if (options.command.get('name') === 'clearlog') {
|
||||
this._refreshTable();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Logs/Table/LogsTableLayoutTemplate',
|
||||
regions : {
|
||||
grid : '#x-grid',
|
||||
toolbar : '#x-toolbar',
|
||||
pager : '#x-pager'
|
||||
},
|
||||
attributes : {id : 'logs-screen'},
|
||||
columns : [{
|
||||
name : 'level',
|
||||
label : '',
|
||||
sortable : true,
|
||||
cell : LogLevelCell
|
||||
}, {
|
||||
name : 'logger',
|
||||
label : 'Component',
|
||||
sortable : true,
|
||||
cell : Backgrid.StringCell.extend({className : 'log-logger-cell'})
|
||||
}, {
|
||||
name : 'message',
|
||||
label : 'Message',
|
||||
sortable : false,
|
||||
cell : Backgrid.StringCell.extend({className : 'log-message-cell'})
|
||||
}, {
|
||||
name : 'time',
|
||||
label : 'Time',
|
||||
cell : LogTimeCell
|
||||
}],
|
||||
initialize : function(){
|
||||
this.collection = new LogCollection();
|
||||
this.listenTo(this.collection, 'sync', this._showTable);
|
||||
this.listenTo(vent, vent.Events.CommandComplete, this._commandComplete);
|
||||
},
|
||||
onRender : function(){
|
||||
this.grid.show(new LoadingView());
|
||||
},
|
||||
onShow : function(){
|
||||
this._showToolbar();
|
||||
},
|
||||
_showTable : function(){
|
||||
this.grid.show(new Backgrid.Grid({
|
||||
row : LogRow,
|
||||
columns : this.columns,
|
||||
collection : this.collection,
|
||||
className : 'table table-hover'
|
||||
}));
|
||||
this.pager.show(new GridPager({
|
||||
columns : this.columns,
|
||||
collection : this.collection
|
||||
}));
|
||||
},
|
||||
_showToolbar : function(){
|
||||
var filterButtons = {
|
||||
type : 'radio',
|
||||
storeState : true,
|
||||
menuKey : 'logs.filterMode',
|
||||
defaultAction : 'all',
|
||||
items : [{
|
||||
key : 'all',
|
||||
title : '',
|
||||
tooltip : 'All',
|
||||
icon : 'icon-circle-blank',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'info',
|
||||
title : '',
|
||||
tooltip : 'Info',
|
||||
icon : 'icon-info',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'warn',
|
||||
title : '',
|
||||
tooltip : 'Warn',
|
||||
icon : 'icon-warn',
|
||||
callback : this._setFilter
|
||||
}, {
|
||||
key : 'error',
|
||||
title : '',
|
||||
tooltip : 'Error',
|
||||
icon : 'icon-error',
|
||||
callback : this._setFilter
|
||||
}]
|
||||
};
|
||||
var leftSideButtons = {
|
||||
type : 'default',
|
||||
storeState : false,
|
||||
items : [{
|
||||
title : 'Refresh',
|
||||
icon : 'icon-refresh',
|
||||
ownerContext : this,
|
||||
callback : this._refreshTable
|
||||
}, {
|
||||
title : 'Clear Logs',
|
||||
icon : 'icon-trash',
|
||||
command : 'clearLog'
|
||||
}]
|
||||
};
|
||||
this.toolbar.show(new ToolbarLayout({
|
||||
left : [leftSideButtons],
|
||||
right : [filterButtons],
|
||||
context : this
|
||||
}));
|
||||
},
|
||||
_refreshTable : function(buttonContext){
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.fetch({reset : true});
|
||||
if(buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
_setFilter : function(buttonContext){
|
||||
var mode = buttonContext.model.get('key');
|
||||
this.collection.setFilterMode(mode, {reset : false});
|
||||
this.collection.state.currentPage = 1;
|
||||
var promise = this.collection.fetch({reset : true});
|
||||
if(buttonContext) {
|
||||
buttonContext.ui.icon.spinForPromise(promise);
|
||||
}
|
||||
},
|
||||
_commandComplete : function(options){
|
||||
if(options.command.get('name') === 'clearlog') {
|
||||
this._refreshTable();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,17 +1,11 @@
|
||||
'use strict';
|
||||
var Backbone = require('backbone');
|
||||
var LogFileModel = require('./LogFileModel');
|
||||
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'System/Logs/Updates/LogFileModel'
|
||||
], function (Backbone, LogFileModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/log/file/update',
|
||||
model: LogFileModel,
|
||||
|
||||
state: {
|
||||
sortKey: 'lastWriteTime',
|
||||
order : 1
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/log/file/update',
|
||||
model : LogFileModel,
|
||||
state : {
|
||||
sortKey : 'lastWriteTime',
|
||||
order : 1
|
||||
}
|
||||
});
|
||||
@@ -1,8 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backbone.Model.extend({});
|
||||
@@ -1,14 +1,8 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'api!system/status'
|
||||
], function (Backbone, statusData) {
|
||||
var Backbone = require('backbone');
|
||||
var ApiData = require('../Shared/ApiData');
|
||||
|
||||
var StatusModel = Backbone.Model.extend({
|
||||
url: window.NzbDrone.ApiRoot + '/system/status'
|
||||
});
|
||||
|
||||
var instance = new StatusModel(statusData);
|
||||
return instance;
|
||||
});
|
||||
module.exports = (function(){
|
||||
var StatusModel = Backbone.Model.extend({url : window.NzbDrone.ApiRoot + '/system/status'});
|
||||
var instance = new StatusModel(ApiData.get('system/status'));
|
||||
return instance;
|
||||
}).call(this);
|
||||
@@ -1,155 +1,125 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'jquery',
|
||||
'backbone',
|
||||
'marionette',
|
||||
'System/Info/SystemInfoLayout',
|
||||
'System/Logs/LogsLayout',
|
||||
'System/Update/UpdateLayout',
|
||||
'System/Backup/BackupLayout',
|
||||
'System/Task/TaskLayout',
|
||||
'Shared/Messenger'
|
||||
], function ($,
|
||||
Backbone,
|
||||
Marionette,
|
||||
SystemInfoLayout,
|
||||
LogsLayout,
|
||||
UpdateLayout,
|
||||
BackupLayout,
|
||||
TaskLayout,
|
||||
Messenger) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/SystemLayoutTemplate',
|
||||
var $ = require('jquery');
|
||||
var Backbone = require('backbone');
|
||||
var Marionette = require('marionette');
|
||||
var SystemInfoLayout = require('./Info/SystemInfoLayout');
|
||||
var LogsLayout = require('./Logs/LogsLayout');
|
||||
var UpdateLayout = require('./Update/UpdateLayout');
|
||||
var BackupLayout = require('./Backup/BackupLayout');
|
||||
var TaskLayout = require('./Task/TaskLayout');
|
||||
var Messenger = require('../Shared/Messenger');
|
||||
|
||||
regions: {
|
||||
info : '#info',
|
||||
logs : '#logs',
|
||||
updates : '#updates',
|
||||
backup : '#backup',
|
||||
tasks : '#tasks'
|
||||
},
|
||||
|
||||
ui: {
|
||||
infoTab : '.x-info-tab',
|
||||
logsTab : '.x-logs-tab',
|
||||
updatesTab : '.x-updates-tab',
|
||||
backupTab : '.x-backup-tab',
|
||||
tasksTab : '.x-tasks-tab'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-info-tab' : '_showInfo',
|
||||
'click .x-logs-tab' : '_showLogs',
|
||||
'click .x-updates-tab' : '_showUpdates',
|
||||
'click .x-backup-tab' : '_showBackup',
|
||||
'click .x-tasks-tab' : '_showTasks',
|
||||
'click .x-shutdown' : '_shutdown',
|
||||
'click .x-restart' : '_restart'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
if (options.action) {
|
||||
this.action = options.action.toLowerCase();
|
||||
}
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
switch (this.action) {
|
||||
case 'logs':
|
||||
this._showLogs();
|
||||
break;
|
||||
case 'updates':
|
||||
this._showUpdates();
|
||||
break;
|
||||
case 'backup':
|
||||
this._showBackup();
|
||||
break;
|
||||
case 'tasks':
|
||||
this._showTasks();
|
||||
break;
|
||||
default:
|
||||
this._showInfo();
|
||||
}
|
||||
},
|
||||
|
||||
_navigate: function (route){
|
||||
Backbone.history.navigate(route, { trigger: true, replace: true });
|
||||
},
|
||||
|
||||
_showInfo: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.info.show(new SystemInfoLayout());
|
||||
this.ui.infoTab.tab('show');
|
||||
this._navigate('system/info');
|
||||
},
|
||||
|
||||
_showLogs: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.logs.show(new LogsLayout());
|
||||
this.ui.logsTab.tab('show');
|
||||
this._navigate('system/logs');
|
||||
},
|
||||
|
||||
_showUpdates: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.updates.show(new UpdateLayout());
|
||||
this.ui.updatesTab.tab('show');
|
||||
this._navigate('system/updates');
|
||||
},
|
||||
|
||||
_showBackup: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.backup.show(new BackupLayout());
|
||||
this.ui.backupTab.tab('show');
|
||||
this._navigate('system/backup');
|
||||
},
|
||||
|
||||
_showTasks: function (e) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.tasks.show(new TaskLayout());
|
||||
this.ui.tasksTab.tab('show');
|
||||
this._navigate('system/tasks');
|
||||
},
|
||||
|
||||
_shutdown: function () {
|
||||
$.ajax({
|
||||
url: window.NzbDrone.ApiRoot + '/system/shutdown',
|
||||
type: 'POST'
|
||||
});
|
||||
|
||||
Messenger.show({
|
||||
message: 'Sonarr will shutdown shortly',
|
||||
type: 'info'
|
||||
});
|
||||
},
|
||||
|
||||
_restart: function () {
|
||||
$.ajax({
|
||||
url: window.NzbDrone.ApiRoot + '/system/restart',
|
||||
type: 'POST'
|
||||
});
|
||||
|
||||
Messenger.show({
|
||||
message: 'Sonarr will restart shortly',
|
||||
type: 'info'
|
||||
});
|
||||
}
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/SystemLayoutTemplate',
|
||||
regions : {
|
||||
info : '#info',
|
||||
logs : '#logs',
|
||||
updates : '#updates',
|
||||
backup : '#backup',
|
||||
tasks : '#tasks'
|
||||
},
|
||||
ui : {
|
||||
infoTab : '.x-info-tab',
|
||||
logsTab : '.x-logs-tab',
|
||||
updatesTab : '.x-updates-tab',
|
||||
backupTab : '.x-backup-tab',
|
||||
tasksTab : '.x-tasks-tab'
|
||||
},
|
||||
events : {
|
||||
"click .x-info-tab" : '_showInfo',
|
||||
"click .x-logs-tab" : '_showLogs',
|
||||
"click .x-updates-tab" : '_showUpdates',
|
||||
"click .x-backup-tab" : '_showBackup',
|
||||
"click .x-tasks-tab" : '_showTasks',
|
||||
"click .x-shutdown" : '_shutdown',
|
||||
"click .x-restart" : '_restart'
|
||||
},
|
||||
initialize : function(options){
|
||||
if(options.action) {
|
||||
this.action = options.action.toLowerCase();
|
||||
}
|
||||
},
|
||||
onShow : function(){
|
||||
switch (this.action) {
|
||||
case 'logs':
|
||||
this._showLogs();
|
||||
break;
|
||||
case 'updates':
|
||||
this._showUpdates();
|
||||
break;
|
||||
case 'backup':
|
||||
this._showBackup();
|
||||
break;
|
||||
case 'tasks':
|
||||
this._showTasks();
|
||||
break;
|
||||
default:
|
||||
this._showInfo();
|
||||
}
|
||||
},
|
||||
_navigate : function(route){
|
||||
Backbone.history.navigate(route, {
|
||||
trigger : true,
|
||||
replace : true
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
_showInfo : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.info.show(new SystemInfoLayout());
|
||||
this.ui.infoTab.tab('show');
|
||||
this._navigate('system/info');
|
||||
},
|
||||
_showLogs : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.logs.show(new LogsLayout());
|
||||
this.ui.logsTab.tab('show');
|
||||
this._navigate('system/logs');
|
||||
},
|
||||
_showUpdates : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.updates.show(new UpdateLayout());
|
||||
this.ui.updatesTab.tab('show');
|
||||
this._navigate('system/updates');
|
||||
},
|
||||
_showBackup : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.backup.show(new BackupLayout());
|
||||
this.ui.backupTab.tab('show');
|
||||
this._navigate('system/backup');
|
||||
},
|
||||
_showTasks : function(e){
|
||||
if(e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
this.tasks.show(new TaskLayout());
|
||||
this.ui.tasksTab.tab('show');
|
||||
this._navigate('system/tasks');
|
||||
},
|
||||
_shutdown : function(){
|
||||
$.ajax({
|
||||
url : window.NzbDrone.ApiRoot + '/system/shutdown',
|
||||
type : 'POST'
|
||||
});
|
||||
Messenger.show({
|
||||
message : 'Sonarr will shutdown shortly',
|
||||
type : 'info'
|
||||
});
|
||||
},
|
||||
_restart : function(){
|
||||
$.ajax({
|
||||
url : window.NzbDrone.ApiRoot + '/system/restart',
|
||||
type : 'POST'
|
||||
});
|
||||
Messenger.show({
|
||||
message : 'Sonarr will restart shortly',
|
||||
type : 'info'
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,42 +1,21 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'Commands/CommandController'
|
||||
], function (NzbDroneCell, CommandController) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
var CommandController = require('../../Commands/CommandController');
|
||||
|
||||
className: 'execute-task-cell',
|
||||
|
||||
events: {
|
||||
'click .x-execute' : '_executeTask'
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
||||
this.$el.empty();
|
||||
|
||||
var name = this.model.get('name');
|
||||
var task = this.model.get('taskName');
|
||||
|
||||
this.$el.html(
|
||||
'<i class="icon-refresh icon-can-spin x-execute" title="Execute {0}"></i>'.format(name)
|
||||
);
|
||||
|
||||
CommandController.bindToCommand({
|
||||
element: this.$el.find('.x-execute'),
|
||||
command: {
|
||||
name : task
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
_executeTask: function () {
|
||||
CommandController.Execute(this.model.get('taskName'), {
|
||||
name : this.model.get('taskName')
|
||||
});
|
||||
}
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'execute-task-cell',
|
||||
events : {"click .x-execute" : '_executeTask'},
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var name = this.model.get('name');
|
||||
var task = this.model.get('taskName');
|
||||
this.$el.html('<i class="icon-refresh icon-can-spin x-execute" title="Execute {0}"></i>'.format(name));
|
||||
CommandController.bindToCommand({
|
||||
element : this.$el.find('.x-execute'),
|
||||
command : {name : task}
|
||||
});
|
||||
});
|
||||
return this;
|
||||
},
|
||||
_executeTask : function(){
|
||||
CommandController.Execute(this.model.get('taskName'), {name : this.model.get('taskName')});
|
||||
}
|
||||
});
|
||||
@@ -1,46 +1,31 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'moment',
|
||||
'Shared/UiSettingsModel'
|
||||
], function (NzbDroneCell, moment, UiSettings) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
var moment = require('moment');
|
||||
var UiSettings = require('../../Shared/UiSettingsModel');
|
||||
|
||||
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>';
|
||||
var tooltip = nextExecution.format(UiSettings.longDateTime());
|
||||
var text;
|
||||
|
||||
if (UiSettings.get('showRelativeDates')) {
|
||||
text = nextExecution.fromNow();
|
||||
}
|
||||
|
||||
else {
|
||||
text = nextExecution.format(UiSettings.shortDateTime());
|
||||
}
|
||||
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
|
||||
return this;
|
||||
module.exports = 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>';
|
||||
var tooltip = nextExecution.format(UiSettings.longDateTime());
|
||||
var text;
|
||||
if(UiSettings.get('showRelativeDates')) {
|
||||
text = nextExecution.fromNow();
|
||||
}
|
||||
});
|
||||
});
|
||||
else {
|
||||
text = nextExecution.format(UiSettings.shortDateTime());
|
||||
}
|
||||
this.$el.html(result.format(tooltip, text));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,19 +1,13 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone.pageable',
|
||||
'System/Task/TaskModel'
|
||||
], function (PageableCollection, TaskModel) {
|
||||
return PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/system/task',
|
||||
model: TaskModel,
|
||||
var PageableCollection = require('backbone.pageable');
|
||||
var TaskModel = require('./TaskModel');
|
||||
|
||||
state: {
|
||||
sortKey : 'name',
|
||||
order : -1,
|
||||
pageSize : 100000
|
||||
},
|
||||
|
||||
mode: 'client'
|
||||
});
|
||||
});
|
||||
module.exports = PageableCollection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/system/task',
|
||||
model : TaskModel,
|
||||
state : {
|
||||
sortKey : 'name',
|
||||
order : -1,
|
||||
pageSize : 100000
|
||||
},
|
||||
mode : 'client'
|
||||
});
|
||||
@@ -1,29 +1,18 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'Cells/NzbDroneCell',
|
||||
'moment'
|
||||
], function (NzbDroneCell, moment) {
|
||||
return NzbDroneCell.extend({
|
||||
var NzbDroneCell = require('../../Cells/NzbDroneCell');
|
||||
var moment = require('moment');
|
||||
|
||||
className: 'task-interval-cell',
|
||||
|
||||
render: function () {
|
||||
|
||||
this.$el.empty();
|
||||
|
||||
var interval = this.model.get('interval');
|
||||
var duration = moment.duration(interval, 'minutes').humanize().replace(/an?(?=\s)/, '1');
|
||||
|
||||
if (interval === 0 ) {
|
||||
this.$el.html('disabled');
|
||||
}
|
||||
|
||||
else {
|
||||
this.$el.html(duration);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = NzbDroneCell.extend({
|
||||
className : 'task-interval-cell',
|
||||
render : function(){
|
||||
this.$el.empty();
|
||||
var interval = this.model.get('interval');
|
||||
var duration = moment.duration(interval, 'minutes').humanize().replace(/an?(?=\s)/, '1');
|
||||
if(interval === 0) {
|
||||
this.$el.html('disabled');
|
||||
}
|
||||
else {
|
||||
this.$el.html(duration);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -1,83 +1,56 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'System/Task/TaskCollection',
|
||||
'Cells/RelativeTimeCell',
|
||||
'System/Task/TaskIntervalCell',
|
||||
'System/Task/ExecuteTaskCell',
|
||||
'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',
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var BackupCollection = require('./TaskCollection');
|
||||
var RelativeTimeCell = require('../../Cells/RelativeTimeCell');
|
||||
var TaskIntervalCell = require('./TaskIntervalCell');
|
||||
var ExecuteTaskCell = require('./ExecuteTaskCell');
|
||||
var NextExecutionCell = require('./NextExecutionCell');
|
||||
var LoadingView = require('../../Shared/LoadingView');
|
||||
require('../../Mixins/backbone.signalr.mixin');
|
||||
|
||||
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 : NextExecutionCell
|
||||
},
|
||||
{
|
||||
name : 'this',
|
||||
label : '',
|
||||
sortable : false,
|
||||
cell : ExecuteTaskCell
|
||||
}
|
||||
],
|
||||
|
||||
initialize: function () {
|
||||
this.taskCollection = new BackupCollection();
|
||||
|
||||
this.listenTo(this.taskCollection, 'sync', this._showTasks);
|
||||
this.taskCollection.bindSignalR();
|
||||
},
|
||||
|
||||
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'
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = 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 : NextExecutionCell
|
||||
}, {
|
||||
name : 'this',
|
||||
label : '',
|
||||
sortable : false,
|
||||
cell : ExecuteTaskCell
|
||||
}],
|
||||
initialize : function(){
|
||||
this.taskCollection = new BackupCollection();
|
||||
this.listenTo(this.taskCollection, 'sync', this._showTasks);
|
||||
this.taskCollection.bindSignalR();
|
||||
},
|
||||
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'
|
||||
}));
|
||||
}
|
||||
});
|
||||
@@ -1,9 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
var Backbone = require('backbone');
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Model.extend({});
|
||||
@@ -1,10 +1,3 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Update/EmptyViewTemplate'
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.ItemView.extend({template : 'System/Update/EmptyViewTemplate'});
|
||||
@@ -1,11 +1,7 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'System/Update/UpdateModel'
|
||||
], function (Backbone, UpdateModel) {
|
||||
return Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/update',
|
||||
model: UpdateModel
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
var UpdateModel = require('./UpdateModel');
|
||||
|
||||
module.exports = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/update',
|
||||
model : UpdateModel
|
||||
});
|
||||
@@ -1,12 +1,8 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'System/Update/UpdateItemView',
|
||||
'System/Update/EmptyView'
|
||||
], function (Marionette, UpdateItemView, EmptyView) {
|
||||
return Marionette.CollectionView.extend({
|
||||
itemView : UpdateItemView,
|
||||
emptyView: EmptyView
|
||||
});
|
||||
});
|
||||
var Marionette = require('marionette');
|
||||
var UpdateItemView = require('./UpdateItemView');
|
||||
var EmptyView = require('./EmptyView');
|
||||
|
||||
module.exports = Marionette.CollectionView.extend({
|
||||
itemView : UpdateItemView,
|
||||
emptyView : EmptyView
|
||||
});
|
||||
@@ -1,38 +1,23 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
var CommandController = require('../../Commands/CommandController');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'Commands/CommandController'
|
||||
], function (Marionette, CommandController) {
|
||||
return Marionette.ItemView.extend({
|
||||
template: 'System/Update/UpdateItemViewTemplate',
|
||||
|
||||
events: {
|
||||
'click .x-install-update': '_installUpdate'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.updating = false;
|
||||
},
|
||||
|
||||
_installUpdate: function () {
|
||||
if (this.updating) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updating = true;
|
||||
var self = this;
|
||||
|
||||
var promise = CommandController.Execute('installUpdate', { updatePackage: this.model.toJSON() });
|
||||
|
||||
promise.done(function () {
|
||||
window.setTimeout(function () {
|
||||
self.updating = false;
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'System/Update/UpdateItemViewTemplate',
|
||||
events : {"click .x-install-update" : '_installUpdate'},
|
||||
initialize : function(){
|
||||
this.updating = false;
|
||||
},
|
||||
_installUpdate : function(){
|
||||
if(this.updating) {
|
||||
return;
|
||||
}
|
||||
this.updating = true;
|
||||
var self = this;
|
||||
var promise = CommandController.Execute('installUpdate', {updatePackage : this.model.toJSON()});
|
||||
promise.done(function(){
|
||||
window.setTimeout(function(){
|
||||
self.updating = false;
|
||||
}, 5000);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -1,33 +1,21 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'backgrid',
|
||||
'System/Update/UpdateCollection',
|
||||
'System/Update/UpdateCollectionView',
|
||||
'Shared/LoadingView'
|
||||
], function (Marionette, Backgrid, UpdateCollection, UpdateCollectionView, LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'System/Update/UpdateLayoutTemplate',
|
||||
var Marionette = require('marionette');
|
||||
var Backgrid = require('backgrid');
|
||||
var UpdateCollection = require('./UpdateCollection');
|
||||
var UpdateCollectionView = require('./UpdateCollectionView');
|
||||
var LoadingView = require('../../Shared/LoadingView');
|
||||
|
||||
regions: {
|
||||
updates: '#x-updates'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.updateCollection = new UpdateCollection();
|
||||
|
||||
this.listenTo(this.updateCollection, 'sync', this._showUpdates);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.updates.show(new LoadingView());
|
||||
|
||||
this.updateCollection.fetch();
|
||||
},
|
||||
|
||||
_showUpdates: function () {
|
||||
this.updates.show(new UpdateCollectionView({ collection: this.updateCollection }));
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'System/Update/UpdateLayoutTemplate',
|
||||
regions : {updates : '#x-updates'},
|
||||
initialize : function(){
|
||||
this.updateCollection = new UpdateCollection();
|
||||
this.listenTo(this.updateCollection, 'sync', this._showUpdates);
|
||||
},
|
||||
onRender : function(){
|
||||
this.updates.show(new LoadingView());
|
||||
this.updateCollection.fetch();
|
||||
},
|
||||
_showUpdates : function(){
|
||||
this.updates.show(new UpdateCollectionView({collection : this.updateCollection}));
|
||||
}
|
||||
});
|
||||
@@ -1,9 +1,3 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
var Backbone = require('backbone');
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Model.extend({});
|
||||
Reference in New Issue
Block a user