added more import code in ui.

some jshint cleanup.
pull/3113/head
kay.one 12 years ago
parent 572ef0743c
commit c511292abe

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

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.IO;
using NLog;
using NzbDrone.Common;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository;
using PetaPoco;
@ -70,7 +68,7 @@ namespace NzbDrone.Core.Providers
{
if (!_seriesProvider.SeriesPathExists(seriesFolder))
{
results.Add(seriesFolder.Normalize());
results.Add(new DirectoryInfo(seriesFolder.Normalize()).Name);
}
}

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

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

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

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

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

@ -1,5 +1,15 @@
{{#each unmappedFolders}}
<div>
{{this}}
<div class="accordion result-list span12 offset4 ">
<h2>{{path}}</h2>
{{#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>
{{/each}}

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

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

@ -13,7 +13,7 @@ NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
//};
//Todo: Cutoff should be something that is allowed (double check)
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' };
};
},

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

@ -46,12 +46,12 @@ window.onerror = function (msg, url, line) {
var a = document.createElement('a');
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('level', 'error');
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(model);
} catch (error) {
alert("Couldn't report JS error. " + error);
alert('Couldn\'t report JS error. ' + error);
}
var suppressErrorAlert = false;
@ -60,7 +60,9 @@ window.onerror = function (msg, url, line) {
$(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();
model.set('title', ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText);
model.set('message', xmlHttpRequest.responseText);

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

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

Loading…
Cancel
Save