removed NzbDrone. namespace, everything is done using require.

This commit is contained in:
Keivan Beigi 2013-06-24 16:41:59 -07:00
commit b0bd3f34f1
121 changed files with 2570 additions and 2587 deletions

View file

@ -1,37 +1,41 @@
'use strict';
define(['app', 'History/Model', 'backbone.pageable'], function (App, HistoryModel, PageableCollection) {
return PageableCollection.extend({
url : NzbDrone.Constants.ApiRoot + '/history',
model : NzbDrone.History.Model,
'use strict';
define(
[
'History/Model',
'backbone.pageable'
], function ( HistoryModel, PageableCollection) {
return PageableCollection.extend({
url : window.ApiRoot + '/history',
model: HistoryModel,
state: {
pageSize: 15,
sortKey: 'date',
order: 1
},
state: {
pageSize: 15,
sortKey : 'date',
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'
}
},
parseState: function (resp) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
}
},
parseState: function (resp, queryParams, state) {
return {totalRecords: resp.totalRecords};
},
parseRecords: function (resp) {
if (resp) {
return resp.records;
}
return resp;
}
});
});
});

View file

@ -1,41 +1,44 @@
'use strict';
define(['app', 'Cells/NzbDroneCell' ], function () {
return NzbDrone.Cells.NzbDroneCell.extend({
define(
[
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className: 'history-event-type-cell',
className: 'history-event-type-cell',
render: function () {
this.$el.empty();
render: function () {
this.$el.empty();
if (this.cellValue) {
if (this.cellValue) {
var icon;
var toolTip;
var icon;
var toolTip;
switch (this.cellValue) {
case 'grabbed':
icon = 'icon-cloud-download';
toolTip = 'Episode grabbed from indexer and sent to download client';
break;
case 'seriesFolderImported':
icon = 'icon-hdd';
toolTip = 'Existing episode file added to library';
break;
case 'downloadFolderImported':
icon = 'icon-download-alt';
toolTip = 'Episode downloaded successfully and picked up from download client';
break;
default :
icon = 'icon-question';
toolTip = 'unknown event';
switch (this.cellValue) {
case 'grabbed':
icon = 'icon-cloud-download';
toolTip = 'Episode grabbed from indexer and sent to download client';
break;
case 'seriesFolderImported':
icon = 'icon-hdd';
toolTip = 'Existing episode file added to library';
break;
case 'downloadFolderImported':
icon = 'icon-download-alt';
toolTip = 'Episode downloaded successfully and picked up from download client';
break;
default :
icon = 'icon-question';
toolTip = 'unknown event';
}
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, toolTip));
}
this.$el.html('<i class="{0}" title="{1}"/>'.format(icon, toolTip));
return this;
}
return this;
}
});
});
});

View file

@ -1,33 +1,19 @@
'use strict';
define([
'app',
'History/Collection',
'History/EventTypeCell',
'Cells/RelativeDateCell',
'Cells/TemplatedCell',
'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell',
'Cells/QualityCell',
'Shared/Toolbar/ToolbarLayout',
'Shared/Grid/Pager',
'Shared/Grid/HeaderCell',
'Shared/LoadingView'
],
function (App,
HistoryCollection,
EventTypeCell,
RelativeDateCell,
TemplatedCell,
SeriesTitleCell,
EpisodeNumberCell,
EpisodeTitleCell,
QualityCell,
ToolbarLayout,
Pager,
HeaderCell,
LoadingView) {
return Backbone.Marionette.Layout.extend({
define(
[
'marionette',
'backgrid',
'History/Collection',
'History/EventTypeCell',
'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell',
'Cells/QualityCell',
'Cells/RelativeDateCell',
'Shared/Grid/Pager',
'Shared/LoadingView'
], function (Marionette, Backgrid, HistoryCollection, EventTypeCell, SeriesTitleCell, EpisodeNumberCell, EpisodeTitleCell, QualityCell, RelativeDateCell, GridPager, LoadingView) {
return Marionette.Layout.extend({
template: 'History/HistoryLayoutTemplate',
regions: {
@ -36,54 +22,53 @@ define([
pager : '#x-pager'
},
columns: [
{
name: 'eventType',
label:'',
cell : EventTypeCell
},
{
name : 'series',
label : 'Series',
cell : SeriesTitleCell
},
{
name : 'episode',
label : 'Episode',
sortable: false,
cell : EpisodeNumberCell
},
{
name : 'episode',
label : 'Episode Title',
sortable: false,
cell : EpisodeTitleCell
},
{
name : 'quality',
label : 'Quality',
cell : QualityCell
},
{
name : 'date',
label: 'Date',
cell : RelativeDateCell
}
],
_showTable: function () {
this.history.show(new Backgrid.Grid(
columns:
[
{
row : NzbDrone.History.Row,
columns : this.columns,
collection: this.historyCollection,
className : 'table table-hover'
}));
name : 'eventType',
label: '',
cell : EventTypeCell
},
{
name : 'series',
label: 'Series',
cell : SeriesTitleCell
},
{
name : 'episode',
label : 'Episode',
sortable: false,
cell : EpisodeNumberCell
},
{
name : 'episode',
label : 'Episode Title',
sortable: false,
cell : EpisodeTitleCell
},
{
name : 'quality',
label: 'Quality',
cell : QualityCell
},
{
name : 'date',
label: 'Date',
cell : RelativeDateCell
}
],
this.pager.show(new Pager({
_showTable: function (collection) {
this.history.show(new Backgrid.Grid({
columns : this.columns,
collection: this.historyCollection
collection: collection,
className : 'table table-hover'
}));
this.pager.show(new GridPager({
columns : this.columns,
collection: collection
}));
},
@ -92,16 +77,11 @@ define([
this.history.show(new LoadingView());
this.historyCollection = new HistoryCollection();
this.historyCollection.fetch()
.done(function () {
self._showTable();
});
//this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this}));
var collection = new HistoryCollection();
collection.fetch().done(function () {
self._showTable(collection);
});
}
})
;
})
;
});
});

View file

@ -1,22 +1,25 @@
'use strict';
define(['app','Series/SeriesModel', 'Series/EpisodeModel'], function () {
NzbDrone.History.Model = Backbone.Model.extend({
mutators: {
seasonNumber: function () {
return this.get('episode').seasonNumber;
'use strict';
define(
[
'backbone',
'Series/SeriesModel',
'Series/EpisodeModel'
], function (Backbone, SeriesModel, EpisodeModel) {
return Backbone.Model.extend({
mutators: {
seasonNumber: function () {
return this.get('episode').seasonNumber;
},
paddedEpisodeNumber: function () {
return this.get('episode').episodeNumber.pad(2);
}
},
paddedEpisodeNumber: function () {
return this.get('episode').episodeNumber.pad(2);
parse: function (model) {
model.series = new SeriesModel(model.series);
model.episode = new EpisodeModel(model.episode);
return model;
}
},
parse: function (model) {
model.series = new NzbDrone.Series.SeriesModel(model.series);
model.episode = new NzbDrone.Series.EpisodeModel(model.episode);
return model;
}
});
});
});