Moved source code under src folder - massive change

This commit is contained in:
Mark McDowall
2013-10-02 18:01:32 -07:00
parent 2fc8123d6b
commit 5bf0e197ec
1499 changed files with 1054 additions and 1444 deletions
+14
View File
@@ -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;
}
});
});
@@ -0,0 +1,8 @@
<dl class="dl-horizontal">
<dt>Version</dt>
<dd>{{version}}</dd>
<dt>AppData directory</dt>
<dd>{{appData}}</dd>
<dt>Startup directory</dt>
<dd>{{startupPath}}</dd>
</dl>
@@ -0,0 +1,8 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});
+11
View File
@@ -0,0 +1,11 @@
'use strict';
define(
[
'app',
'marionette'
], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'System/Logs/Files/ContentsViewTemplate'
});
});
@@ -0,0 +1,11 @@
<div class="row">
<div class="span12">
<h3>{{filename}}</h3>
</div>
</div>
<div class="row">
<div class="span12">
<pre>{{contents}}</pre>
</div>
</div>
+18
View File
@@ -0,0 +1,18 @@
'use strict';
define(
[
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className: 'log-filename-cell',
render: function () {
var filename = this._getValue();
this.$el.html(filename);
return this;
}
});
});
@@ -0,0 +1,14 @@
'use strict';
define(['System/Logs/Files/LogFileModel' ],
function (LogFileModel) {
return Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/log/files',
model: LogFileModel,
state: {
sortKey : 'lastWriteTime',
order : 1
}
});
});
+140
View File
@@ -0,0 +1,140 @@
'use strict';
define(
[
'app',
'marionette',
'backgrid',
'System/Logs/Files/FilenameCell',
'Cells/RelativeDateCell',
'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: 'System/Logs/Files/LogFileLayoutTemplate',
regions: {
toolbar : '#x-toolbar',
grid : '#x-grid',
contents : '#x-contents'
},
columns:
[
{
name : 'filename',
label: 'Filename',
cell : FilenameCell
},
{
name : 'lastWriteTime',
label: 'Last Write Time',
cell : RelativeDateCell
}
],
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 () {
this._fetchAndShow();
this._showToolbar();
this._showTable();
},
_fetchAndShow: function () {
var self = this;
this.contents.close();
var promise = this.collection.fetch();
promise.done(function () {
if (self.collection.length > 0) {
self._showLogFile({ model: self.collection.first() });
}
});
},
_showToolbar: function () {
var rightSideButtons = {
type : 'default',
storeState: false,
items :
[
{
title : 'Refresh',
icon : 'icon-refresh',
ownerContext : this,
callback : this._refreshLogs
},
{
title : 'Delete Log Files',
icon : 'icon-trash',
command : 'deleteLogFiles',
successMessage : 'Log files have been deleted',
errorMessage : 'Failed to delete log files'
}
]
};
this.toolbar.show(new ToolbarLayout({
right :
[
rightSideButtons
],
context: this
}));
},
_showTable: function () {
this.grid.show(new Backgrid.Grid({
row : LogFileRow,
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
}));
},
_showLogFile: function (options) {
this.contents.show(new LoadingView());
if (!options.model) {
return;
}
var self = this;
var filename = options.model.get('filename');
$.ajax({
url: '/log/' + filename,
success: function (data) {
var model = new ContentsModel({
filename: filename,
contents: data
});
self.contents.show(new ContentsView({ model: model }));
}
});
},
_refreshLogs: function () {
this._fetchAndShow();
},
_commandComplete: function (options) {
if (options.command.get('name') === 'deletelogfiles') {
this._refreshLogs();
}
}
});
});
@@ -0,0 +1,12 @@
<div id="x-toolbar"/>
<div class="row">
<div class="span10">
<div id="x-grid"/>
</div>
</div>
<div class="row">
<div class="span10">
<div id="x-contents"/>
</div>
</div>
+8
View File
@@ -0,0 +1,8 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});
+19
View File
@@ -0,0 +1,19 @@
'use strict';
define(
[
'app',
'backgrid'
], function (App, Backgrid) {
return Backgrid.Row.extend({
className: 'log-file-row',
events: {
'click': '_showContents'
},
_showContents: function () {
App.vent.trigger(App.Commands.ShowLogFile, { model: this.model });
}
});
});
+21
View File
@@ -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;
}
+39
View File
@@ -0,0 +1,39 @@
'use strict';
define(['backbone.pageable', 'System/Logs/LogsModel'],
function (PagableCollection, LogsModel) {
return PagableCollection.extend({
url : window.NzbDrone.ApiRoot + '/log',
model: LogsModel,
state: {
pageSize: 50,
sortKey : 'time',
order : 1
},
queryParams: {
totalPages : null,
totalRecords: null,
pageSize : 'pageSize',
sortKey : 'sortKey',
order : 'sortDir',
directions : {
'-1': 'asc',
'1' : 'desc'
}
},
parseState: function (resp, queryParams, state) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
}
});
});
+48
View File
@@ -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());
}
});
});
@@ -0,0 +1,11 @@
<div class="tabbable tabs-left">
<ul class="nav nav-tabs">
<li><a href="#table" class="x-table-tab no-router">Table</a></li>
<li><a href="#files" class="x-files-tab no-router">Files</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="table"></div>
<div class="tab-pane" id="files"></div>
</div>
</div>
+8
View File
@@ -0,0 +1,8 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});
+18
View File
@@ -0,0 +1,18 @@
'use strict';
define(
[
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return 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;
}
});
});
+20
View File
@@ -0,0 +1,20 @@
'use strict';
define(
[
'Cells/NzbDroneCell',
'moment'
], function (NzbDroneCell, Moment) {
return NzbDroneCell.extend({
className: 'log-time-cell',
render: function () {
var date = Moment(this._getValue());
this.$el.html(date.format('LT'));
this.$el.attr('title', date.format('LLLL'));
return this;
}
});
});
+131
View File
@@ -0,0 +1,131 @@
'use strict';
define(
[
'marionette',
'backgrid',
'System/Logs/Table/LogTimeCell',
'System/Logs/Table/LogLevelCell',
'Shared/Grid/Pager',
'System/Logs/LogsCollection',
'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView'
], function (Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) {
return 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.collectionPromise = this.collection.fetch();
},
onRender: function () {
this.grid.show(new LoadingView());
},
onShow: function () {
var self = this;
this._showToolbar();
this.collectionPromise.done(function () {
self._showTable();
});
},
_showTable: function () {
this.grid.show(new Backgrid.Grid({
row : Backgrid.Row,
columns : this.columns,
collection: this.collection,
className : 'table table-hover'
}));
this.pager.show(new GridPager({
columns : this.columns,
collection: this.collection
}));
},
_showToolbar: function () {
var rightSideButtons = {
type : 'default',
storeState: false,
items :
[
{
title : 'Refresh',
icon : 'icon-refresh',
ownerContext : this,
callback : this._refreshLogs
},
{
title : 'Clear Logs',
icon : 'icon-trash',
command : 'clearLog',
successMessage : 'Logs have been cleared',
errorMessage : 'Failed to clear logs',
ownerContext : this,
onSuccess : this._refreshLogs
}
]
};
this.toolbar.show(new ToolbarLayout({
right :
[
rightSideButtons
],
context: this
}));
},
_refreshLogs: function () {
this.collection.state.currentPage = 1;
this.collection.fetch({ reset: true });
this._showTable();
}
});
});
@@ -0,0 +1,11 @@
<div id="x-toolbar"/>
<div class="row">
<div class="span10">
<div id="x-grid"/>
</div>
</div>
<div class="row">
<div class="span10">
<div id="x-pager"/>
</div>
</div>
+15
View File
@@ -0,0 +1,15 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
var StatusModel = Backbone.Model.extend({
url: window.NzbDrone.ApiRoot + '/system/status'
});
var instance = new StatusModel();
instance.fetch();
return instance;
});
+91
View File
@@ -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');
}
});
});
+11
View File
@@ -0,0 +1,11 @@
<ul class="nav nav-tabs">
<li><a href="#about" class="x-about-tab no-router">About</a></li>
<li><a href="#logs" class="x-logs-tab no-router">Logs</a></li>
<li><a href="#updates" class="x-updates-tab no-router">Updates</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="about"></div>
<div class="tab-pane" id="logs"></div>
<div class="tab-pane" id="updates"></div>
</div>
+11
View File
@@ -0,0 +1,11 @@
'use strict';
define(
[
'backbone',
'System/Update/UpdateModel'
], function (Backbone, UpdateModel) {
return Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/update',
model: UpdateModel
});
});
@@ -0,0 +1,10 @@
'use strict';
define(
[
'marionette',
'System/Update/UpdateItemView'
], function (Marionette, UpdateItemView) {
return Marionette.CollectionView.extend({
itemView: UpdateItemView
});
});
+11
View File
@@ -0,0 +1,11 @@
'use strict';
define(
[
'app',
'marionette'
], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'System/Update/UpdateItemViewTemplate'
});
});
@@ -0,0 +1,23 @@
<div class="update">
<fieldset>
<legend>{{version}} <span class="date">- {{ShortDate releaseDate}} {{currentVersion version}}</span></legend>
{{#with changes}}
{{#each new}}
<div class="change">
<span class="label label-success">New</span> {{this}}
</div>
{{/each}}
{{#each fixed}}
<div class="change">
<span class="label label-info">Fixed</span> {{this}}
</div>
{{/each}}
{{/with}}
{{#unless changes}}
No notable changes
{{/unless}}
</fieldset>
</div>
+58
View File
@@ -0,0 +1,58 @@
'use strict';
define(
[
'marionette',
'backgrid',
'System/Update/UpdateCollection',
'System/Update/UpdateCollectionView',
'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView'
], function (Marionette, Backgrid, UpdateCollection, UpdateCollectionView, ToolbarLayout, LoadingView) {
return Marionette.Layout.extend({
template: 'System/Update/UpdateLayoutTemplate',
regions: {
updates: '#x-updates',
toolbar: '#x-toolbar'
},
leftSideButtons: {
type : 'default',
storeState: false,
items :
[
{
title : 'Check for Update',
icon : 'icon-nd-update',
command: 'applicationUpdate'
}
]
},
initialize: function () {
this.updateCollection = new UpdateCollection();
},
onRender: function () {
this.updates.show(new LoadingView());
this._showToolbar();
var self = this;
var promise = this.updateCollection.fetch();
promise.done(function (){
self.updates.show(new UpdateCollectionView({ collection: self.updateCollection }));
});
},
_showToolbar: function () {
this.toolbar.show(new ToolbarLayout({
left :
[
this.leftSideButtons
],
context: this
}));
}
});
});
@@ -0,0 +1,6 @@
<div id="x-toolbar"/>
<div class="row">
<div class="span12">
<div id="x-updates"/>
</div>
</div>
+9
View File
@@ -0,0 +1,9 @@
'use strict';
define(
[
'backbone'
], function (Backbone) {
return Backbone.Model.extend({
});
});
+25
View File
@@ -0,0 +1,25 @@
.update {
margin-bottom: 30px;
legend {
margin-bottom: 5px;
line-height: 30px;
.date {
font-size: 16px;
}
}
.changes-header {
font-size: 18px;
}
.label {
width: 40px;
text-align: center;
}
.change {
margin-bottom: 2px;
font-size: 13px;
}
}