1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-27 23:06:29 -04:00

UI Cleanup - Updated System, Tags and Wanted subtrees.

This commit is contained in:
Taloth Saldono
2015-02-14 11:18:21 +01:00
parent d6079a701c
commit 32fc68b9df
46 changed files with 1008 additions and 643 deletions
+3 -2
View File
@@ -1,10 +1,11 @@
var Backbone = require('backbone');
module.exports = Backbone.Model.extend({
url : function(){
url : function() {
return this.get('contentsUrl');
},
parse : function(contents){
parse : function(contents) {
var response = {};
response.contents = contents;
return response;
+3 -1
View File
@@ -1,3 +1,5 @@
var Marionette = require('marionette');
module.exports = Marionette.ItemView.extend({template : 'System/Logs/Files/ContentsViewTemplate'});
module.exports = Marionette.ItemView.extend({
template : 'System/Logs/Files/ContentsViewTemplate'
});
+3 -1
View File
@@ -2,9 +2,11 @@ var NzbDroneCell = require('../../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({
className : 'download-log-cell',
render : function(){
render : function() {
this.$el.empty();
this.$el.html('<a href="{0}" class="no-router" target="_blank">Download</a>'.format(this.cellValue));
return this;
}
});
+3 -1
View File
@@ -2,9 +2,11 @@ var NzbDroneCell = require('../../../Cells/NzbDroneCell');
module.exports = NzbDroneCell.extend({
className : 'log-filename-cell',
render : function(){
render : function() {
var filename = this._getValue();
this.$el.html(filename);
return this;
}
});
@@ -4,6 +4,7 @@ var LogFileModel = require('./LogFileModel');
module.exports = Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/log/file',
model : LogFileModel,
state : {
sortKey : 'lastWriteTime',
order : 1
+72 -45
View File
@@ -12,63 +12,79 @@ var LoadingView = require('../../../Shared/LoadingView');
require('../../../jQuery/jquery.spin');
module.exports = Marionette.Layout.extend({
template : 'System/Logs/Files/LogFileLayoutTemplate',
regions : {
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){
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(){
onShow : function() {
this._showToolbar();
this._showTable();
},
_showToolbar : function(){
_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'
}]
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(){
_showTable : function() {
this.grid.show(new Backgrid.Grid({
row : LogFileRow,
columns : this.columns,
@@ -76,32 +92,43 @@ module.exports = Marionette.Layout.extend({
className : 'table table-hover'
}));
},
_collectionSynced : function(){
if(!this.collection.any()) {
_collectionSynced : function() {
if (!this.collection.any()) {
return;
}
var model = this.collection.first();
this._fetchLogFileContents({model : model});
this._fetchLogFileContents({ model : model });
},
_fetchLogFileContents : function(options){
_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'});
contentsModel.fetch({ dataType : 'text' });
},
_showDetails : function(model){
this.contents.show(new ContentsView({model : model}));
_showDetails : function(model) {
this.contents.show(new ContentsView({ model : model }));
},
_refreshTable : function(buttonContext){
_refreshTable : function(buttonContext) {
this.contents.close();
var promise = this.collection.fetch();
if(buttonContext) {
//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()) {
_commandComplete : function(options) {
if (options.command.get('name') === this.deleteFilesCommand.toLowerCase()) {
this._refreshTable();
}
}
+8 -4
View File
@@ -2,9 +2,13 @@ var vent = require('vent');
var Backgrid = require('backgrid');
module.exports = Backgrid.Row.extend({
className : 'log-file-row',
events : {"click" : '_showDetails'},
_showDetails : function(){
vent.trigger(vent.Commands.ShowLogFile, {model : this.model});
className : 'log-file-row',
events : {
'click' : '_showDetails'
},
_showDetails : function() {
vent.trigger(vent.Commands.ShowLogFile, { model : this.model });
}
});