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

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
@@ -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>