1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 12:32:31 +01:00

added more import code in ui.

some jshint cleanup.
This commit is contained in:
kay.one 2013-01-29 22:52:31 -08:00
parent 572ef0743c
commit c511292abe
15 changed files with 112 additions and 91 deletions

View File

@ -1,6 +1,4 @@
using System; using NLog;
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;

View File

@ -3,8 +3,6 @@
using System.IO; using System.IO;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using PetaPoco; using PetaPoco;
@ -70,7 +68,7 @@ public virtual List<String> GetUnmappedFolders(string path)
{ {
if (!_seriesProvider.SeriesPathExists(seriesFolder)) if (!_seriesProvider.SeriesPathExists(seriesFolder))
{ {
results.Add(seriesFolder.Normalize()); results.Add(new DirectoryInfo(seriesFolder.Normalize()).Name);
} }
} }

View File

@ -25,6 +25,7 @@
<OldToolsVersion>4.0</OldToolsVersion> <OldToolsVersion>4.0</OldToolsVersion>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
<JSLintSkip>\_backboneApp\JsLibraries\|\Scripts\</JSLintSkip>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

View File

@ -1,27 +1,28 @@
/// <reference path="../../app.js" /> 'use strict;'
/// <reference path="../../app.js" />
/// <reference path="SearchResultView.js" /> /// <reference path="SearchResultView.js" />
NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
template: "AddSeries/AddNewSeries/AddNewSeriesTemplate", template: 'AddSeries/AddNewSeries/AddNewSeriesTemplate',
route: "Series/add/new", route: 'Series/add/new',
ui: { ui: {
seriesSearch: '.search input' seriesSearch: '.search input'
}, },
regions: { regions: {
searchResult: "#search-result", searchResult: '#search-result',
}, },
collection: new NzbDrone.AddSeries.SearchResultCollection(), collection: new NzbDrone.AddSeries.SearchResultCollection(),
initialize: function (options) { initialize: function (options) {
if (options.rootFolders === undefined) { if (options.rootFolders === undefined) {
throw "rootFolder arg is required."; throw 'rootFolder arg. is required.';
} }
if (options.qualityProfiles === undefined) { if (options.qualityProfiles === undefined) {
throw "qualityProfiles arg is required."; throw 'qualityProfiles arg. is required.';
} }
this.rootFoldersCollection = options.rootFolders; this.rootFoldersCollection = options.rootFolders;
@ -31,12 +32,12 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
onRender: function () { onRender: function () {
console.log('binding auto complete'); console.log('binding auto complete');
var self = this; var self = this;
this.ui.seriesSearch this.ui.seriesSearch
.data('timeout', null) .data('timeout', null)
.keyup(function () { .keyup(function () {
clearTimeout(self.$el.data('timeout')); window.clearTimeout(self.$el.data('timeout'));
self.$el.data('timeout', setTimeout(self.search, 500, self)); self.$el.data('timeout', window.setTimeout(self.search, 500, self));
}); });
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection }); this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
@ -48,7 +49,7 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
var term = context.ui.seriesSearch.val(); var term = context.ui.seriesSearch.val();
context.collection.reset(); context.collection.reset();
if (term != "") { if (term !== '') {
context.searchResult.show(new NzbDrone.Shared.SpinnerView()); context.searchResult.show(new NzbDrone.Shared.SpinnerView());
context.collection.fetch({ context.collection.fetch({

View File

@ -1,21 +1,22 @@
<div class="accordion-heading"> <div class="accordion-group">
<a href="http://thetvdb.com/?tab=series&id={{id}}" target="_blank" class="icon-info-sign pull-left"></a> <div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" href="#{{id}}">{{seriesName}} {{seriesYear}}</a> <a href="http://thetvdb.com/?tab=series&id={{id}}" target="_blank" class="icon-info-sign pull-left"></a>
</div> <a class="accordion-toggle" data-toggle="collapse" href="#{{id}}">{{seriesName}} {{seriesYear}}</a>
<div id="{{id}}" class="accordion-body collapse"> </div>
<div class="accordion-inner"> <div id="{{id}}" class="accordion-body collapse">
<select class="span7 x-root-folder"> <div class="accordion-inner">
{{#each rootFolders.models}} <select class="span7 x-root-folder">
{{#each rootFolders.models}}
<option value="{{id}}">{{attributes.path}}</option> <option value="{{id}}">{{attributes.path}}</option>
{{/each}} {{/each}}
</select> </select>
<select class="span2 x-quality-profile"> <select class="span2 x-quality-profile">
{{#each qualityProfiles.models}} {{#each qualityProfiles.models}}
<option value="{{id}}">{{attributes.name}}</option> <option value="{{id}}">{{attributes.name}}</option>
{{/each}} {{/each}}
</select> </select>
<div class="btn btn-success pull-right icon-plus x-add"> <div class="btn btn-success pull-right icon-plus x-add">
</div>
</div> </div>
</div> </div>
<div name="overview"></div>
</div> </div>

View File

@ -1,4 +1,6 @@
/// <reference path="../../app.js" /> 'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="../../app.js" />
/// <reference path="../SearchResultModel.js" /> /// <reference path="../SearchResultModel.js" />
/// <reference path="../../Series/SeriesModel.js" /> /// <reference path="../../Series/SeriesModel.js" />
/// <reference path="../SearchResultCollection.js" /> /// <reference path="../SearchResultCollection.js" />
@ -6,11 +8,12 @@
NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({ NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/AddNewSeries/SearchResultTemplate", template: "AddSeries/AddNewSeries/SearchResultTemplate",
className: 'search-item accordion-group', className: 'search-item',
ui: { ui: {
qualityProfile: '.x-quality-profile', qualityProfile: '.x-quality-profile',
rootFolder: '.x-root-folder' rootFolder: '.x-root-folder',
addButton: '.x-add'
}, },
events: { events: {
@ -38,6 +41,8 @@ NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
path: path path: path
}); });
var self = this;
model.save(undefined, { model.save(undefined, {
success: function () { success: function () {
var notificationModel = new NzbDrone.Shared.NotificationModel({ var notificationModel = new NzbDrone.Shared.NotificationModel({
@ -47,6 +52,7 @@ NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
}); });
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel); NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
self.close();
} }
}); });
} }
@ -62,8 +68,5 @@ NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend(
initialize: function () { initialize: function () {
this.listenTo(this.collection, 'reset', this.render); this.listenTo(this.collection, 'reset', this.render);
}, }
}); });

View File

@ -6,29 +6,31 @@
/// <reference path="ImportExistingSeries/ImportSeriesView.js" /> /// <reference path="ImportExistingSeries/ImportSeriesView.js" />
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
template: "AddSeries/addSeriesLayoutTemplate", template: 'AddSeries/addSeriesLayoutTemplate',
regions: { regions: {
addNew: "#add-new", addNew: '#add-new',
importExisting: "#import-existing", importExisting: '#import-existing',
rootFolders: "#root-folders" rootFolders: '#root-folders'
}, },
ui: { ui: {
addNewTab: ".x-add-new-tab", addNewTab: '.x-add-new-tab',
importExistingTab: ".x-import-existing-tab", importExistingTab: '.x-import-existing-tab',
rootFoldersTab: ".x-root-folders-tab", rootFoldersTab: '.x-root-folders-tab'
}, },
events: { events: {
"click .x-add-new-tab": 'showAddNew', 'click .x-add-new-tab': 'showAddNew',
"click .x-import-existing-tab": 'showImport', 'click .x-import-existing-tab': 'showImport',
"click .x-root-folders-tab": 'showRootFolders', 'click .x-root-folders-tab': 'showRootFolders'
}, },
showAddNew: function (e) { showAddNew: function (e) {
if (e) e.preventDefault(); if (e) {
e.preventDefault();
}
this.ui.addNewTab.tab('show'); this.ui.addNewTab.tab('show');
NzbDrone.Router.navigate('series/add/new'); NzbDrone.Router.navigate('series/add/new');
@ -36,14 +38,18 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
}, },
showImport: function (e) { showImport: function (e) {
if (e) e.preventDefault(); if (e) {
e.preventDefault();
}
this.ui.importExistingTab.tab('show'); this.ui.importExistingTab.tab('show');
NzbDrone.Router.navigate('series/add/import'); NzbDrone.Router.navigate('series/add/import');
}, },
showRootFolders: function (e) { showRootFolders: function (e) {
if (e) e.preventDefault(); if (e) {
e.preventDefault();
}
this.ui.rootFoldersTab.tab('show'); this.ui.rootFoldersTab.tab('show');
NzbDrone.Router.navigate('series/add/rootfolders'); NzbDrone.Router.navigate('series/add/rootfolders');
@ -90,7 +96,7 @@ NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
}, },
evaluateActions: function () { evaluateActions: function () {
if (this.rootFolderCollection.length == 0) { if (this.rootFolderCollection.length === 0) {
this.ui.addNewTab.hide(); this.ui.addNewTab.hide();
this.ui.importExistingTab.hide(); this.ui.importExistingTab.hide();
this.showRootFolders(); this.showRootFolders();

View File

@ -1,5 +1,15 @@
{{#each unmappedFolders}} <div class="accordion result-list span12 offset4 ">
<div> <h2>{{path}}</h2>
{{this}} {{#each unmappedFolders}}
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" href="#{{../id}}_{{@index}}">{{this}}</a>
</div>
<div id="{{../id}}_{{@index}}" class="accordion-body collapse">
<div class="accordion-inner">
{{this}}
</div>
</div>
</div>
{{/each}}
</div> </div>
{{/each}}

View File

@ -1,28 +1,28 @@
/// <reference path="../../app.js" /> 'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="../../app.js" />
/// <reference path="../../Series/SeriesModel.js" /> /// <reference path="../../Series/SeriesModel.js" />
/// <reference path="../SearchResultCollection.js" /> /// <reference path="../SearchResultCollection.js" />
NzbDrone.AddSeries.ExistingFolderItemView = Backbone.Marionette.ItemView.extend({ NzbDrone.AddSeries.ExistingFolderItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/ImportExistingSeries/ImportSeriesTemplate", template: "AddSeries/ImportExistingSeries/ImportSeriesTemplate",
events: { events: {
//'click .x-add': 'add' //'click .x-add': 'add'
}, }
}); });
NzbDrone.AddSeries.ExistingFolderListView = Backbone.Marionette.CollectionView.extend({ NzbDrone.AddSeries.ExistingFolderListView = Backbone.Marionette.CollectionView.extend({
itemView: NzbDrone.AddSeries.ExistingFolderItemView, itemView: NzbDrone.AddSeries.ExistingFolderItemView,
initialize: function (options) { initialize: function () {
if (this.collection === undefined) { if (this.collection === undefined) {
throw "root folder collection is required."; throw "root folder collection is required.";
} }
this.listenTo(this.collection, 'reset', this.render, this); this.listenTo(this.collection, 'reset', this.render, this);
}, }
}); });

View File

@ -1,10 +1,11 @@
/// <reference path="../../app.js" /> 'use strict;'
/// <reference path="../../app.js" />
/// <reference path="RootDirModel.js" /> /// <reference path="RootDirModel.js" />
/// <reference path="RootDirCollection.js" /> /// <reference path="RootDirCollection.js" />
NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({ NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/RootDir/RootDirItemTemplate", template: 'AddSeries/RootDir/RootDirItemTemplate',
tagName: 'tr', tagName: 'tr',
events: { events: {
@ -30,15 +31,15 @@ NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
}); });
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({ NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
template: "AddSeries/RootDir/RootDirTemplate", template: 'AddSeries/RootDir/RootDirTemplate',
route: "series/add/rootdir", route: 'series/add/rootdir',
ui: { ui: {
pathInput: '.x-path input' pathInput: '.x-path input'
}, },
regions: { regions: {
currentDirs: "#current-dirs", currentDirs: '#current-dirs',
}, },
events: { events: {
@ -74,7 +75,7 @@ NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
var term = context.ui.seriesSearch.val(); var term = context.ui.seriesSearch.val();
if (term == "") { if (term === "") {
context.collection.reset(); context.collection.reset();
} else { } else {
console.log(term); console.log(term);

View File

@ -13,7 +13,7 @@ NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
//}; //};
//Todo: Cutoff should be something that is allowed (double check) //Todo: Cutoff should be something that is allowed (double check)
this.validators.cutoff = function (value) { this.validators.cutoff = function (value) {
return value != null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' }; return value !== null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' };
}; };
}, },

View File

@ -19,13 +19,13 @@ NzbDrone.Shared.NotificationModel = Backbone.Model.extend({
return "icon"; return "icon";
} }
if (this.get('level') == 'info') { if (this.get('level') === 'info') {
return "icon-info-sign"; return "icon-info-sign";
} }
else if (this.get('level') == 'success') { else if (this.get('level') === 'success') {
return 'icon-ok-sign'; return 'icon-ok-sign';
} }
else if (this.get('level') == 'error') { else if (this.get('level') === 'error') {
return 'icon-warning-sign'; return 'icon-warning-sign';
} }

View File

@ -46,12 +46,12 @@ window.onerror = function (msg, url, line) {
var a = document.createElement('a'); var a = document.createElement('a');
a.href = url; a.href = url;
model.set('title', a.pathname.split('/').pop() + " : " + line); model.set('title', a.pathname.split('/').pop() + ' : ' + line);
model.set('message', msg); model.set('message', msg);
model.set('level', 'error'); model.set('level', 'error');
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(model); NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(model);
} catch (error) { } catch (error) {
alert("Couldn't report JS error. " + error); alert('Couldn\'t report JS error. ' + error);
} }
var suppressErrorAlert = false; var suppressErrorAlert = false;
@ -60,7 +60,9 @@ window.onerror = function (msg, url, line) {
$(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) { $(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) {
if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) return; if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) {
return;
}
var model = new NzbDrone.Shared.NotificationModel(); var model = new NzbDrone.Shared.NotificationModel();
model.set('title', ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText); model.set('title', ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText);
model.set('message', xmlHttpRequest.responseText); model.set('message', xmlHttpRequest.responseText);

View File

@ -2,7 +2,7 @@
NzbDrone.Shared.SpinnerView = Backbone.Marionette.ItemView.extend({ NzbDrone.Shared.SpinnerView = Backbone.Marionette.ItemView.extend({
template: "Shared/SpinnerTemplate", template: 'Shared/SpinnerTemplate',
className: 'nz-spinner row', className: 'nz-spinner row',
}); });

View File

@ -12,15 +12,15 @@
/// <reference path="JsLibraries/backbone.modelbinder.js" /> /// <reference path="JsLibraries/backbone.modelbinder.js" />
/// <reference path="JsLibraries/bootstrap.js" /> /// <reference path="JsLibraries/bootstrap.js" />
if (typeof console == "undefined") { if (typeof console === undefined) {
window.console = { log: function () { } }; window.console = { log: function () { } };
} }
NzbDrone = new Backbone.Marionette.Application(); NzbDrone = new Backbone.Marionette.Application();
NzbDrone.Series = NzbDrone.module("Series"); NzbDrone.Series = NzbDrone.module('Series');
NzbDrone.AddSeries = NzbDrone.module("AddSeries"); NzbDrone.AddSeries = NzbDrone.module('AddSeries');
NzbDrone.Quality = NzbDrone.module("Quality"); NzbDrone.Quality = NzbDrone.module('Quality');
NzbDrone.Shared = NzbDrone.module("Shared"); NzbDrone.Shared = NzbDrone.module('Shared');
/* /*
_.templateSettings = { _.templateSettings = {
@ -36,7 +36,7 @@ NzbDrone.Constants = {
}; };
NzbDrone.Events = { NzbDrone.Events = {
DisplayInMainRegion: "DisplayInMainRegion" DisplayInMainRegion: 'DisplayInMainRegion'
}; };
@ -58,9 +58,9 @@ NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
controller: new NzbDrone.Controller(), controller: new NzbDrone.Controller(),
// "someMethod" must exist at controller.someMethod // "someMethod" must exist at controller.someMethod
appRoutes: { appRoutes: {
"series/add": "addSeries", 'series/add': 'addSeries',
"series/add/:action(/:query)": "addSeries", 'series/add/:action(/:query)': 'addSeries',
":whatever": "notFound" ':whatever': 'notFound'
} }
@ -68,12 +68,12 @@ NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
NzbDrone.addInitializer(function (options) { NzbDrone.addInitializer(function (options) {
console.log("starting application"); console.log('starting application');
NzbDrone.addRegions({ NzbDrone.addRegions({
mainRegion: "#main-region", mainRegion: '#main-region',
notificationRegion: "#notification-region" notificationRegion: '#notification-region'
}); });
NzbDrone.Router = new NzbDrone.Router(); NzbDrone.Router = new NzbDrone.Router();