From 6a10382e7beb0287d935c85a6415283d7843d21e Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 30 Sep 2013 22:30:02 -0700 Subject: [PATCH] System now uses tabs instead of toolbar --- Gruntfile.js | 4 +- UI/Content/icons.less | 30 ++++++ UI/Controller.js | 45 +++++---- UI/Logs/Logs.less | 53 ----------- UI/Router.js | 16 +++- UI/System/About/AboutView.js | 14 +++ ...ewTemplate.html => AboutViewTemplate.html} | 0 UI/System/About/View.js | 9 -- UI/System/Layout.js | 63 ------------- UI/System/LayoutTemplate.html | 17 ---- UI/{ => System}/Logs/Files/ContentsModel.js | 0 UI/{ => System}/Logs/Files/ContentsView.js | 2 +- .../Logs/Files/ContentsViewTemplate.html | 0 UI/{ => System}/Logs/Files/FilenameCell.js | 0 .../Logs/Files/LogFileCollection.js} | 3 +- .../Logs/Files/LogFileLayout.js} | 44 +++++---- .../Logs/Files/LogFileLayoutTemplate.html} | 4 +- .../Logs/Files/LogFileModel.js} | 0 UI/{ => System}/Logs/Files/Row.js | 0 UI/System/Logs/Logs.less | 21 +++++ .../Logs/LogsCollection.js} | 4 +- UI/System/Logs/LogsLayout.js | 48 ++++++++++ UI/System/Logs/LogsLayoutTemplate.html | 11 +++ .../Model.js => System/Logs/LogsModel.js} | 0 .../Logs/Table}/LogLevelCell.js | 0 UI/{Logs => System/Logs/Table}/LogTimeCell.js | 0 .../Logs/Table/LogsTableLayout.js} | 40 ++++---- .../Logs/Table/LogsTableLayoutTemplate.html} | 4 +- UI/System/StatusModel.js | 4 +- UI/System/SystemLayout.js | 91 +++++++++++++++++++ UI/System/SystemLayoutTemplate.html | 11 +++ UI/{ => System}/Update/UpdateCollection.js | 2 +- .../Update/UpdateCollectionView.js | 2 +- UI/{ => System}/Update/UpdateItemView.js | 2 +- .../Update/UpdateItemViewTemplate.html | 0 UI/{ => System}/Update/UpdateLayout.js | 6 +- .../Update/UpdateLayoutTemplate.html | 0 UI/{ => System}/Update/UpdateModel.js | 0 UI/{ => System}/Update/update.less | 0 UI/index.html | 4 +- 40 files changed, 330 insertions(+), 224 deletions(-) delete mode 100644 UI/Logs/Logs.less create mode 100644 UI/System/About/AboutView.js rename UI/System/About/{ViewTemplate.html => AboutViewTemplate.html} (100%) delete mode 100644 UI/System/About/View.js delete mode 100644 UI/System/Layout.js delete mode 100644 UI/System/LayoutTemplate.html rename UI/{ => System}/Logs/Files/ContentsModel.js (100%) rename UI/{ => System}/Logs/Files/ContentsView.js (72%) rename UI/{ => System}/Logs/Files/ContentsViewTemplate.html (100%) rename UI/{ => System}/Logs/Files/FilenameCell.js (100%) rename UI/{Logs/Files/Collection.js => System/Logs/Files/LogFileCollection.js} (85%) rename UI/{Logs/Files/Layout.js => System/Logs/Files/LogFileLayout.js} (78%) rename UI/{Logs/Files/LayoutTemplate.html => System/Logs/Files/LogFileLayoutTemplate.html} (72%) rename UI/{Logs/Files/Model.js => System/Logs/Files/LogFileModel.js} (100%) rename UI/{ => System}/Logs/Files/Row.js (100%) create mode 100644 UI/System/Logs/Logs.less rename UI/{Logs/Collection.js => System/Logs/LogsCollection.js} (89%) create mode 100644 UI/System/Logs/LogsLayout.js create mode 100644 UI/System/Logs/LogsLayoutTemplate.html rename UI/{Logs/Model.js => System/Logs/LogsModel.js} (100%) rename UI/{Logs => System/Logs/Table}/LogLevelCell.js (100%) rename UI/{Logs => System/Logs/Table}/LogTimeCell.js (100%) rename UI/{Logs/Layout.js => System/Logs/Table/LogsTableLayout.js} (82%) rename UI/{Logs/LayoutTemplate.html => System/Logs/Table/LogsTableLayoutTemplate.html} (75%) create mode 100644 UI/System/SystemLayout.js create mode 100644 UI/System/SystemLayoutTemplate.html rename UI/{ => System}/Update/UpdateCollection.js (87%) rename UI/{ => System}/Update/UpdateCollectionView.js (83%) rename UI/{ => System}/Update/UpdateItemView.js (73%) rename UI/{ => System}/Update/UpdateItemViewTemplate.html (100%) rename UI/{ => System}/Update/UpdateLayout.js (91%) rename UI/{ => System}/Update/UpdateLayoutTemplate.html (100%) rename UI/{ => System}/Update/UpdateModel.js (100%) rename UI/{ => System}/Update/update.less (100%) diff --git a/Gruntfile.js b/Gruntfile.js index 7025f8c6b..3ce175cb2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -71,9 +71,9 @@ module.exports = function (grunt) { 'UI/AddSeries/addSeries.less', 'UI/Calendar/calendar.less', 'UI/Cells/cells.less', - 'UI/Logs/logs.less', 'UI/Settings/settings.less', - 'UI/Update/update.less' + 'UI/System/Logs/logs.less', + 'UI/System/Update/update.less' ], dest : outputRoot, ext: '.css' diff --git a/UI/Content/icons.less b/UI/Content/icons.less index 0a253e951..131e82b07 100644 --- a/UI/Content/icons.less +++ b/UI/Content/icons.less @@ -126,4 +126,34 @@ .icon-nd-unmonitored:before { .icon(@bookmark-empty); +} + +.icon-info:before { + .icon(@info-sign); + color : dodgerblue; +} + +.icon-debug:before { + .icon(@info-sign); + color : gray; +} + +.icon-trace:before { + .icon(@info-sign); + color : lightgrey; +} + +.icon-warn:before { + .icon(@exclamation-sign); + color : orange; +} + +.icon-error:before { + .icon(@bug); + color : red; +} + +.icon-fatal:before { + .icon(@remove-sign); + color : purple; } \ No newline at end of file diff --git a/UI/Controller.js b/UI/Controller.js index a4bc4d1f9..d252b0f32 100644 --- a/UI/Controller.js +++ b/UI/Controller.js @@ -11,16 +11,27 @@ define( 'Series/SeriesCollection', 'Missing/MissingLayout', 'Calendar/CalendarLayout', - 'Logs/Layout', - 'Logs/Files/Layout', 'Release/Layout', - 'System/Layout', + 'System/SystemLayout', 'SeasonPass/SeasonPassLayout', - 'Update/UpdateLayout', + 'System/Update/UpdateLayout', 'Shared/NotFoundView', 'Shared/Modal/Region' - ], function (App, Marionette, HistoryLayout, SettingsLayout, AddSeriesLayout, SeriesIndexLayout, SeriesDetailsLayout, SeriesCollection, MissingLayout, CalendarLayout, - LogsLayout, LogFileLayout, ReleaseLayout, SystemLayout, SeasonPassLayout, UpdateLayout, NotFoundView) { + ], function (App, + Marionette, + HistoryLayout, + SettingsLayout, + AddSeriesLayout, + SeriesIndexLayout, + SeriesDetailsLayout, + SeriesCollection, + MissingLayout, + CalendarLayout, + ReleaseLayout, + SystemLayout, + SeasonPassLayout, + UpdateLayout, + NotFoundView) { return Marionette.Controller.extend({ series: function () { @@ -31,7 +42,7 @@ define( seriesDetails: function (query) { var series = SeriesCollection.where({titleSlug: query}); - if (series.length != 0) { + if (series.length !== 0) { var targetSeries = series[0]; this._setTitle(targetSeries.get('title')); App.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries })); @@ -53,7 +64,7 @@ define( settings: function (action) { this._setTitle('Settings'); - App.mainRegion.show(new SettingsLayout({action: action})); + App.mainRegion.show(new SettingsLayout({ action: action })); }, missing: function () { @@ -73,21 +84,9 @@ define( App.mainRegion.show(new ReleaseLayout()); }, - logs: function (action) { - if (action) { - this._setTitle('log files'); - App.mainRegion.show(new LogFileLayout()); - } - - else { - this._setTitle('logs'); - App.mainRegion.show(new LogsLayout()); - } - }, - - system: function () { - this._setTitle('system'); - App.mainRegion.show(new SystemLayout()); + system: function (action) { + this._setTitle('System'); + App.mainRegion.show(new SystemLayout({ action: action })); }, seasonPass: function () { diff --git a/UI/Logs/Logs.less b/UI/Logs/Logs.less deleted file mode 100644 index 3c3a2a5a0..000000000 --- a/UI/Logs/Logs.less +++ /dev/null @@ -1,53 +0,0 @@ -@import "../Content/FontAwesome/font-awesome"; -@import "../Shared/Styles/clickable"; - -#logs-screen { - - .log-time-cell{ - width: 80px; - } - - .log-level-cell{ - width: 12px; - font-size: 14px; - } - - td{ - font-size: 13px; - } - - - .icon-info:before { - .icon(@info-sign); - color : dodgerblue; - } - - .icon-debug:before { - .icon(@info-sign); - color : gray; - } - - .icon-trace:before { - .icon(@info-sign); - color : lightgrey; - } - - .icon-warn:before { - .icon(@exclamation-sign); - color : orange; - } - - .icon-error:before { - .icon(@bug); - color : red; - } - - .icon-fatal:before { - .icon(@remove-sign); - color : purple; - } -} - -.log-file-row { - .clickable; -} \ No newline at end of file diff --git a/UI/Router.js b/UI/Router.js index 22c13b04f..f792762b5 100644 --- a/UI/Router.js +++ b/UI/Router.js @@ -2,6 +2,7 @@ require( [ 'app', + 'backbone', 'marionette', 'Controller', 'Series/SeriesCollection', @@ -10,7 +11,16 @@ require( 'Navbar/NavbarView', 'jQuery/RouteBinder', 'jquery' - ], function (App, Marionette, Controller, SeriesCollection, ProgressMessageCollection, CommandMessengerCollectionView, NavbarView, RouterBinder, $) { + ], function (App, + Backbone, + Marionette, + Controller, + SeriesCollection, + ProgressMessageCollection, + CommandMessengerCollectionView, + NavbarView, + RouterBinder, + $) { var Router = Marionette.AppRouter.extend({ @@ -26,12 +36,10 @@ require( 'settings/:action(/:query)' : 'settings', 'missing' : 'missing', 'history' : 'history', - 'logs' : 'logs', - 'logs/:action' : 'logs', 'rss' : 'rss', 'system' : 'system', + 'system/:action' : 'system', 'seasonpass' : 'seasonPass', - 'update' : 'update', ':whatever' : 'notFound' } }); diff --git a/UI/System/About/AboutView.js b/UI/System/About/AboutView.js new file mode 100644 index 000000000..f87b8758e --- /dev/null +++ b/UI/System/About/AboutView.js @@ -0,0 +1,14 @@ +'use strict'; +define( + [ + 'marionette', + 'System/StatusModel' + ], function (Marionette, StatusModel) { + return Marionette.ItemView.extend({ + template: 'System/About/AboutViewTemplate', + + initialize: function () { + this.model = StatusModel; + } + }); + }); diff --git a/UI/System/About/ViewTemplate.html b/UI/System/About/AboutViewTemplate.html similarity index 100% rename from UI/System/About/ViewTemplate.html rename to UI/System/About/AboutViewTemplate.html diff --git a/UI/System/About/View.js b/UI/System/About/View.js deleted file mode 100644 index d737002f2..000000000 --- a/UI/System/About/View.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; -define( - [ - 'marionette' - ], function (Marionette) { - return Marionette.ItemView.extend({ - template: 'System/About/ViewTemplate' - }); - }); diff --git a/UI/System/Layout.js b/UI/System/Layout.js deleted file mode 100644 index 5f4778c59..000000000 --- a/UI/System/Layout.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; -define( - [ - 'app', - 'marionette', - 'System/StatusModel', - 'System/About/View', - 'Logs/Layout', - 'Shared/Toolbar/ToolbarLayout' - ], function (App, - Marionette, - StatusModel, - AboutView, - LogsLayout, - ToolbarLayout) { - return Marionette.Layout.extend({ - template: 'System/LayoutTemplate', - - regions: { - toolbar : '#toolbar', - about : '#about', - loading : '#loading' - }, - - leftSideButtons: { - type : 'default', - storeState: false, - items : - [ - { - title: 'Logs', - icon : 'icon-book', - route: 'logs' - }, - { - title : 'Updates', - icon : 'icon-upload-alt', - route : 'update' - } - ] - }, - - initialize: function () { - this.statusModel = StatusModel; - }, - - onRender: function () { - this._showToolbar(); - this.about.show(new AboutView({ model: this.statusModel })); - }, - - _showToolbar: function () { - this.toolbar.show(new ToolbarLayout({ - left : - [ - this.leftSideButtons - ], - context: this - })); - } - }); - }); - diff --git a/UI/System/LayoutTemplate.html b/UI/System/LayoutTemplate.html deleted file mode 100644 index 3760f7c46..000000000 --- a/UI/System/LayoutTemplate.html +++ /dev/null @@ -1,17 +0,0 @@ -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
\ No newline at end of file diff --git a/UI/Logs/Files/ContentsModel.js b/UI/System/Logs/Files/ContentsModel.js similarity index 100% rename from UI/Logs/Files/ContentsModel.js rename to UI/System/Logs/Files/ContentsModel.js diff --git a/UI/Logs/Files/ContentsView.js b/UI/System/Logs/Files/ContentsView.js similarity index 72% rename from UI/Logs/Files/ContentsView.js rename to UI/System/Logs/Files/ContentsView.js index 9105467bc..2fd2cd1a1 100644 --- a/UI/Logs/Files/ContentsView.js +++ b/UI/System/Logs/Files/ContentsView.js @@ -6,6 +6,6 @@ define( 'marionette' ], function (App, Marionette) { return Marionette.ItemView.extend({ - template: 'Logs/Files/ContentsViewTemplate' + template: 'System/Logs/Files/ContentsViewTemplate' }); }); diff --git a/UI/Logs/Files/ContentsViewTemplate.html b/UI/System/Logs/Files/ContentsViewTemplate.html similarity index 100% rename from UI/Logs/Files/ContentsViewTemplate.html rename to UI/System/Logs/Files/ContentsViewTemplate.html diff --git a/UI/Logs/Files/FilenameCell.js b/UI/System/Logs/Files/FilenameCell.js similarity index 100% rename from UI/Logs/Files/FilenameCell.js rename to UI/System/Logs/Files/FilenameCell.js diff --git a/UI/Logs/Files/Collection.js b/UI/System/Logs/Files/LogFileCollection.js similarity index 85% rename from UI/Logs/Files/Collection.js rename to UI/System/Logs/Files/LogFileCollection.js index 0b2a5c8bb..b26a983fe 100644 --- a/UI/Logs/Files/Collection.js +++ b/UI/System/Logs/Files/LogFileCollection.js @@ -1,5 +1,6 @@ 'use strict'; -define(['Logs/Files/Model' ], + +define(['System/Logs/Files/LogFileModel' ], function (LogFileModel) { return Backbone.Collection.extend({ url : window.NzbDrone.ApiRoot + '/log/files', diff --git a/UI/Logs/Files/Layout.js b/UI/System/Logs/Files/LogFileLayout.js similarity index 78% rename from UI/Logs/Files/Layout.js rename to UI/System/Logs/Files/LogFileLayout.js index 43d9145c6..959e1aee3 100644 --- a/UI/Logs/Files/Layout.js +++ b/UI/System/Logs/Files/LogFileLayout.js @@ -4,16 +4,17 @@ define( 'app', 'marionette', 'backgrid', - 'Logs/Files/FilenameCell', + 'System/Logs/Files/FilenameCell', 'Cells/RelativeDateCell', - 'Logs/Files/Collection', - 'Logs/Files/Row', - 'Logs/Files/ContentsView', - 'Logs/Files/ContentsModel', - 'Shared/Toolbar/ToolbarLayout' - ], function (App, Marionette, Backgrid, FilenameCell, RelativeDateCell, LogFileCollection, LogFileRow, ContentsView, ContentsModel, ToolbarLayout) { + 'System/Logs/Files/LogFileCollection', + 'System/Logs/Files/Row', + 'System/Logs/Files/ContentsView', + 'System/Logs/Files/ContentsModel', + 'Shared/Toolbar/ToolbarLayout', + 'Shared/LoadingView' + ], function (App, Marionette, Backgrid, FilenameCell, RelativeDateCell, LogFileCollection, LogFileRow, ContentsView, ContentsModel, ToolbarLayout, LoadingView) { return Marionette.Layout.extend({ - template: 'Logs/Files/LayoutTemplate', + template: 'System/Logs/Files/LogFileLayoutTemplate', regions: { toolbar : '#x-toolbar', @@ -38,8 +39,8 @@ define( initialize: function () { this.collection = new LogFileCollection(); - App.vent.on(App.Commands.ShowLogFile, this._showLogFile, this); + App.vent.on(App.Events.CommandComplete, this._commandComplete, this); }, onShow: function () { @@ -51,15 +52,19 @@ define( _fetchAndShow: function () { var self = this; + this.contents.close(); + var promise = this.collection.fetch(); promise.done(function () { - self._showLogFile({ model: self.collection.first() }); + if (self.collection.length > 0) { + self._showLogFile({ model: self.collection.first() }); + } }); }, _showToolbar: function () { - var leftSideButtons = { + var rightSideButtons = { type : 'default', storeState: false, items : @@ -76,17 +81,15 @@ define( icon : 'icon-trash', command : 'deleteLogFiles', successMessage : 'Log files have been deleted', - errorMessage : 'Failed to delete log files', - ownerContext : this, - onSuccess: this._refreshLogs + errorMessage : 'Failed to delete log files' } ] }; this.toolbar.show(new ToolbarLayout({ - left : + right : [ - leftSideButtons + rightSideButtons ], context: this })); @@ -102,8 +105,7 @@ define( }, _showLogFile: function (options) { - - this.contents.close(); + this.contents.show(new LoadingView()); if (!options.model) { return; @@ -127,6 +129,12 @@ define( _refreshLogs: function () { this._fetchAndShow(); + }, + + _commandComplete: function (options) { + if (options.command.get('name') === 'deletelogfiles') { + this._refreshLogs(); + } } }); }); diff --git a/UI/Logs/Files/LayoutTemplate.html b/UI/System/Logs/Files/LogFileLayoutTemplate.html similarity index 72% rename from UI/Logs/Files/LayoutTemplate.html rename to UI/System/Logs/Files/LogFileLayoutTemplate.html index df28d4b8a..024af966d 100644 --- a/UI/Logs/Files/LayoutTemplate.html +++ b/UI/System/Logs/Files/LogFileLayoutTemplate.html @@ -1,12 +1,12 @@ 
-
+
-
+
\ No newline at end of file diff --git a/UI/Logs/Files/Model.js b/UI/System/Logs/Files/LogFileModel.js similarity index 100% rename from UI/Logs/Files/Model.js rename to UI/System/Logs/Files/LogFileModel.js diff --git a/UI/Logs/Files/Row.js b/UI/System/Logs/Files/Row.js similarity index 100% rename from UI/Logs/Files/Row.js rename to UI/System/Logs/Files/Row.js diff --git a/UI/System/Logs/Logs.less b/UI/System/Logs/Logs.less new file mode 100644 index 000000000..c61c3a135 --- /dev/null +++ b/UI/System/Logs/Logs.less @@ -0,0 +1,21 @@ +@import "../../Shared/Styles/clickable"; + +#logs-screen { + + .log-time-cell{ + width: 80px; + } + + .log-level-cell{ + width: 12px; + font-size: 14px; + } + + td{ + font-size: 13px; + } +} + +.log-file-row { + .clickable; +} \ No newline at end of file diff --git a/UI/Logs/Collection.js b/UI/System/Logs/LogsCollection.js similarity index 89% rename from UI/Logs/Collection.js rename to UI/System/Logs/LogsCollection.js index 9b755203a..14c80374f 100644 --- a/UI/Logs/Collection.js +++ b/UI/System/Logs/LogsCollection.js @@ -1,5 +1,7 @@ 'use strict'; -define(['backbone.pageable', 'Logs/Model', ], function (PagableCollection, LogsModel) { + +define(['backbone.pageable', 'System/Logs/LogsModel'], + function (PagableCollection, LogsModel) { return PagableCollection.extend({ url : window.NzbDrone.ApiRoot + '/log', model: LogsModel, diff --git a/UI/System/Logs/LogsLayout.js b/UI/System/Logs/LogsLayout.js new file mode 100644 index 000000000..15511b431 --- /dev/null +++ b/UI/System/Logs/LogsLayout.js @@ -0,0 +1,48 @@ +'use strict'; +define( + [ + 'marionette', + 'System/Logs/Table/LogsTableLayout', + 'System/Logs/Files/LogFileLayout' + ], function (Marionette, LogsTableLayout, LogsFileLayout) { + return Marionette.Layout.extend({ + template: 'System/Logs/LogsLayoutTemplate', + + ui: { + tableTab: '.x-table-tab', + filesTab: '.x-files-tab' + }, + + regions: { + table: '#table', + files: '#files' + }, + + events: { + 'click .x-table-tab': '_showTable', + 'click .x-files-tab': '_showFiles' + }, + + 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()); + } + }); + }); diff --git a/UI/System/Logs/LogsLayoutTemplate.html b/UI/System/Logs/LogsLayoutTemplate.html new file mode 100644 index 000000000..23881fc79 --- /dev/null +++ b/UI/System/Logs/LogsLayoutTemplate.html @@ -0,0 +1,11 @@ +
+ + +
+
+
+
+
\ No newline at end of file diff --git a/UI/Logs/Model.js b/UI/System/Logs/LogsModel.js similarity index 100% rename from UI/Logs/Model.js rename to UI/System/Logs/LogsModel.js diff --git a/UI/Logs/LogLevelCell.js b/UI/System/Logs/Table/LogLevelCell.js similarity index 100% rename from UI/Logs/LogLevelCell.js rename to UI/System/Logs/Table/LogLevelCell.js diff --git a/UI/Logs/LogTimeCell.js b/UI/System/Logs/Table/LogTimeCell.js similarity index 100% rename from UI/Logs/LogTimeCell.js rename to UI/System/Logs/Table/LogTimeCell.js diff --git a/UI/Logs/Layout.js b/UI/System/Logs/Table/LogsTableLayout.js similarity index 82% rename from UI/Logs/Layout.js rename to UI/System/Logs/Table/LogsTableLayout.js index 807ca580e..1eb1ef132 100644 --- a/UI/Logs/Layout.js +++ b/UI/System/Logs/Table/LogsTableLayout.js @@ -3,14 +3,15 @@ define( [ 'marionette', 'backgrid', - 'Logs/LogTimeCell', - 'Logs/LogLevelCell', + 'System/Logs/Table/LogTimeCell', + 'System/Logs/Table/LogLevelCell', 'Shared/Grid/Pager', - 'Logs/Collection', - 'Shared/Toolbar/ToolbarLayout' - ], function (Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout) { + 'System/Logs/LogsCollection', + 'Shared/Toolbar/ToolbarLayout', + 'Shared/LoadingView' + ], function (Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) { return Marionette.Layout.extend({ - template: 'Logs/LayoutTemplate', + template: 'System/Logs/Table/LogsTableLayoutTemplate', regions: { grid : '#x-grid', @@ -55,16 +56,25 @@ define( initialize: function () { this.collection = new LogCollection(); - this.collection.fetch(); + this.collectionPromise = this.collection.fetch(); + }, + + onRender: function () { + this.grid.show(new LoadingView()); }, onShow: function () { + var self = this; this._showToolbar(); - this._showTable(); + + this.collectionPromise.done(function () { + self._showTable(); + }); }, - _showTable: function () { + + _showTable: function () { this.grid.show(new Backgrid.Grid({ row : Backgrid.Row, columns : this.columns, @@ -79,7 +89,7 @@ define( }, _showToolbar: function () { - var leftSideButtons = { + var rightSideButtons = { type : 'default', storeState: false, items : @@ -99,20 +109,14 @@ define( errorMessage : 'Failed to clear logs', ownerContext : this, onSuccess : this._refreshLogs - }, - - { - title: 'Files', - icon : 'icon-file', - route: 'logs/files' } ] }; this.toolbar.show(new ToolbarLayout({ - left : + right : [ - leftSideButtons + rightSideButtons ], context: this })); diff --git a/UI/Logs/LayoutTemplate.html b/UI/System/Logs/Table/LogsTableLayoutTemplate.html similarity index 75% rename from UI/Logs/LayoutTemplate.html rename to UI/System/Logs/Table/LogsTableLayoutTemplate.html index 43529ab0f..aae6c4dfc 100644 --- a/UI/Logs/LayoutTemplate.html +++ b/UI/System/Logs/Table/LogsTableLayoutTemplate.html @@ -1,11 +1,11 @@ 
-
+
-
+
diff --git a/UI/System/StatusModel.js b/UI/System/StatusModel.js index 20805cec7..3210fe3e6 100644 --- a/UI/System/StatusModel.js +++ b/UI/System/StatusModel.js @@ -4,12 +4,12 @@ define( 'backbone' ], function (Backbone) { - var model = Backbone.Model.extend({ + var StatusModel = Backbone.Model.extend({ url: window.NzbDrone.ApiRoot + '/system/status' }); - var instance = new model(); + var instance = new StatusModel(); instance.fetch(); return instance; }); diff --git a/UI/System/SystemLayout.js b/UI/System/SystemLayout.js new file mode 100644 index 000000000..ed41fd345 --- /dev/null +++ b/UI/System/SystemLayout.js @@ -0,0 +1,91 @@ +'use strict'; +define( + [ + 'app', + 'marionette', + 'System/About/AboutView', + 'System/Logs/LogsLayout', + 'System/Update/UpdateLayout' + ], function (App, + Marionette, + AboutView, + LogsLayout, + UpdateLayout) { + return Marionette.Layout.extend({ + template: 'System/SystemLayoutTemplate', + + regions: { + about : '#about', + logs : '#logs', + updates : '#updates' + }, + + ui: { + aboutTab : '.x-about-tab', + logsTab : '.x-logs-tab', + updatesTab: '.x-updates-tab' + }, + + events: { + 'click .x-about-tab' : '_showAbout', + 'click .x-logs-tab' : '_showLogs', + 'click .x-updates-tab': '_showUpdates' + }, + + 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; + default: + this._showAbout(); + } + }, + + _navigate:function(route){ + require(['Router'], function(){ + App.Router.navigate(route); + }); + }, + + _showAbout: function (e) { + if (e) { + e.preventDefault(); + } + + this.about.show(new AboutView()); + this.ui.aboutTab.tab('show'); + this._navigate('system/about'); + }, + + _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'); + } + }); + }); + diff --git a/UI/System/SystemLayoutTemplate.html b/UI/System/SystemLayoutTemplate.html new file mode 100644 index 000000000..bddcf83b0 --- /dev/null +++ b/UI/System/SystemLayoutTemplate.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/UI/Update/UpdateCollection.js b/UI/System/Update/UpdateCollection.js similarity index 87% rename from UI/Update/UpdateCollection.js rename to UI/System/Update/UpdateCollection.js index b1e7bcf60..a6d5accf6 100644 --- a/UI/Update/UpdateCollection.js +++ b/UI/System/Update/UpdateCollection.js @@ -2,7 +2,7 @@ define( [ 'backbone', - 'Update/UpdateModel' + 'System/Update/UpdateModel' ], function (Backbone, UpdateModel) { return Backbone.Collection.extend({ url : window.NzbDrone.ApiRoot + '/update', diff --git a/UI/Update/UpdateCollectionView.js b/UI/System/Update/UpdateCollectionView.js similarity index 83% rename from UI/Update/UpdateCollectionView.js rename to UI/System/Update/UpdateCollectionView.js index 267af7f85..77f210d75 100644 --- a/UI/Update/UpdateCollectionView.js +++ b/UI/System/Update/UpdateCollectionView.js @@ -2,7 +2,7 @@ define( [ 'marionette', - 'Update/UpdateItemView' + 'System/Update/UpdateItemView' ], function (Marionette, UpdateItemView) { return Marionette.CollectionView.extend({ itemView: UpdateItemView diff --git a/UI/Update/UpdateItemView.js b/UI/System/Update/UpdateItemView.js similarity index 73% rename from UI/Update/UpdateItemView.js rename to UI/System/Update/UpdateItemView.js index 8d478f038..5271ec9b6 100644 --- a/UI/Update/UpdateItemView.js +++ b/UI/System/Update/UpdateItemView.js @@ -6,6 +6,6 @@ define( 'marionette' ], function (App, Marionette) { return Marionette.ItemView.extend({ - template: 'Update/UpdateItemViewTemplate' + template: 'System/Update/UpdateItemViewTemplate' }); }); diff --git a/UI/Update/UpdateItemViewTemplate.html b/UI/System/Update/UpdateItemViewTemplate.html similarity index 100% rename from UI/Update/UpdateItemViewTemplate.html rename to UI/System/Update/UpdateItemViewTemplate.html diff --git a/UI/Update/UpdateLayout.js b/UI/System/Update/UpdateLayout.js similarity index 91% rename from UI/Update/UpdateLayout.js rename to UI/System/Update/UpdateLayout.js index 4794f761c..fa2393afe 100644 --- a/UI/Update/UpdateLayout.js +++ b/UI/System/Update/UpdateLayout.js @@ -3,13 +3,13 @@ define( [ 'marionette', 'backgrid', - 'Update/UpdateCollection', - 'Update/UpdateCollectionView', + 'System/Update/UpdateCollection', + 'System/Update/UpdateCollectionView', 'Shared/Toolbar/ToolbarLayout', 'Shared/LoadingView' ], function (Marionette, Backgrid, UpdateCollection, UpdateCollectionView, ToolbarLayout, LoadingView) { return Marionette.Layout.extend({ - template: 'Update/UpdateLayoutTemplate', + template: 'System/Update/UpdateLayoutTemplate', regions: { updates: '#x-updates', diff --git a/UI/Update/UpdateLayoutTemplate.html b/UI/System/Update/UpdateLayoutTemplate.html similarity index 100% rename from UI/Update/UpdateLayoutTemplate.html rename to UI/System/Update/UpdateLayoutTemplate.html diff --git a/UI/Update/UpdateModel.js b/UI/System/Update/UpdateModel.js similarity index 100% rename from UI/Update/UpdateModel.js rename to UI/System/Update/UpdateModel.js diff --git a/UI/Update/update.less b/UI/System/Update/update.less similarity index 100% rename from UI/Update/update.less rename to UI/System/Update/update.less diff --git a/UI/index.html b/UI/index.html index 093473a8a..3e57b6590 100644 --- a/UI/index.html +++ b/UI/index.html @@ -11,11 +11,11 @@ - + - +