From 4176e7e9e4f23f1deb811e16cfa50b31247b54bc Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 31 Jan 2013 19:15:19 -0800 Subject: [PATCH] add existing is almost done. --- NzbDrone.Web/NzbDrone.Web.csproj | 1 - .../FolderMatchResultViewTemplatate.html | 8 +++---- .../AddSeries/Existing/ImportSeriesView.js | 18 ++++++++++++++- .../RootFolderCompositeViewTemplate.html | 22 +++---------------- .../Existing/RootFoldersCompositeView.html | 15 ------------- ...UnmappedFolderCompositeViewTemplatate.html | 17 +++++++++----- .../AddSeries/New/AddNewSeriesView.js | 17 ++++++++++---- .../_backboneApp/AddSeries/addSeries.css | 17 ++++++++++++++ .../Content/Bootstrap/variables.less | 2 +- NzbDrone.Web/_backboneApp/Content/base.css | 14 ++++++++++++ .../_backboneApp/Shared/NotificationModel.js | 4 +++- .../_backboneApp/Shared/NotificationView.js | 20 ++++++++++++----- 12 files changed, 98 insertions(+), 57 deletions(-) delete mode 100644 NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFoldersCompositeView.html diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 4a1a057fb..2340aaeee 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -187,7 +187,6 @@ - diff --git a/NzbDrone.Web/_backboneApp/AddSeries/Existing/FolderMatchResultViewTemplatate.html b/NzbDrone.Web/_backboneApp/AddSeries/Existing/FolderMatchResultViewTemplatate.html index 4d068190e..9ade9671c 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/Existing/FolderMatchResultViewTemplatate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/Existing/FolderMatchResultViewTemplatate.html @@ -1,5 +1,5 @@ -
- -
{{seriesName}} {{seriesYear}}
-
+
+ + {{seriesName}} {{seriesYear}} +
diff --git a/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js b/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js index b00846f47..0c4253570 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js @@ -21,14 +21,30 @@ NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.Co 'click .x-search': 'search' }, + ui: { + searchButton: '.x-search' + }, + initialize: function () { this.collection = new NzbDrone.AddSeries.SearchResultCollection(); }, search: function () { + var icon = this.ui.searchButton.find('icon'); + + icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled'); + + + this.collection.fetch({ - data: $.param({ term: 'simpsons' }) + data: $.param({ term: this.model.get('folder') }), + success: function () { + icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search'); + }, + fail:function() { + icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search'); + } }); } diff --git a/NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFolderCompositeViewTemplate.html b/NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFolderCompositeViewTemplate.html index a2cf5b87c..580fa0905 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFolderCompositeViewTemplate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFolderCompositeViewTemplate.html @@ -1,20 +1,4 @@ -
-

{{path}}

- -
- -
- - +
+

{{path}}

+
diff --git a/NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFoldersCompositeView.html b/NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFoldersCompositeView.html deleted file mode 100644 index 282e553cd..000000000 --- a/NzbDrone.Web/_backboneApp/AddSeries/Existing/RootFoldersCompositeView.html +++ /dev/null @@ -1,15 +0,0 @@ -
-

{{path}}

- {{#each unmappedFolders}} -
-
- {{this}} -
-
-
- {{this}} -
-
-
- {{/each}} -
diff --git a/NzbDrone.Web/_backboneApp/AddSeries/Existing/UnmappedFolderCompositeViewTemplatate.html b/NzbDrone.Web/_backboneApp/AddSeries/Existing/UnmappedFolderCompositeViewTemplatate.html index 7e45741d7..58692cc04 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/Existing/UnmappedFolderCompositeViewTemplatate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/Existing/UnmappedFolderCompositeViewTemplatate.html @@ -1,7 +1,14 @@ -
- {{folder}} - -
- +
+
+
+ {{folder}} + + +
+
+
+
diff --git a/NzbDrone.Web/_backboneApp/AddSeries/New/AddNewSeriesView.js b/NzbDrone.Web/_backboneApp/AddSeries/New/AddNewSeriesView.js index 769fb9492..63a042f53 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/New/AddNewSeriesView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/New/AddNewSeriesView.js @@ -35,7 +35,7 @@ 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 () { @@ -48,14 +48,16 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({ }, search: function (context) { - + + context.abortExistingRequest(); + var term = context.ui.seriesSearch.val(); context.collection.reset(); - + if (term !== '') { context.searchResult.show(new NzbDrone.Shared.SpinnerView()); - context.collection.fetch({ + context.currentSearchRequest = context.collection.fetch({ data: $.param({ term: term }), success: function (model) { context.resultUpdated(model, context); @@ -67,6 +69,13 @@ NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({ } }, + abortExistingRequest : function () { + if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) { + console.log('aborting previous pending search request.'); + this.currentSearchRequest.abort(); + } + }, + resultUpdated: function (options, context) { _.each(options.models, function (model) { diff --git a/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css b/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css index 809a1594a..1bada16ab 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css +++ b/NzbDrone.Web/_backboneApp/AddSeries/addSeries.css @@ -52,3 +52,20 @@ .search-item select { font-size: 16px; } + +/*Existing*/ +.unmapped-folder-view { + background: #fcf8e3; + margin-top: 20px; + padding: 20px; +} + + .unmapped-folder-view .folder-header { + font-size: 30px; + font-weight:300 + + } + +.existing-root-folder-view, h1 { + padding: 10px 0px 20px 0px; +} diff --git a/NzbDrone.Web/_backboneApp/Content/Bootstrap/variables.less b/NzbDrone.Web/_backboneApp/Content/Bootstrap/variables.less index ed6a90fb6..c17c72e96 100644 --- a/NzbDrone.Web/_backboneApp/Content/Bootstrap/variables.less +++ b/NzbDrone.Web/_backboneApp/Content/Bootstrap/variables.less @@ -44,7 +44,7 @@ // Typography // ------------------------- -@sansFontFamily: "Segoe UI","Segoe WP", "Helvetica Neue", Helvetica, Arial, sans-serif; +@sansFontFamily: "open sans", "Segoe UI","Segoe WP", "Helvetica Neue", Helvetica, Arial, sans-serif; @serifFontFamily: Georgia, "Times New Roman", Times, serif; @monoFontFamily: Monaco, Menlo, Consolas, "Courier New", monospace; diff --git a/NzbDrone.Web/_backboneApp/Content/base.css b/NzbDrone.Web/_backboneApp/Content/base.css index f0868aa5d..fdbb5dab8 100644 --- a/NzbDrone.Web/_backboneApp/Content/base.css +++ b/NzbDrone.Web/_backboneApp/Content/base.css @@ -67,3 +67,17 @@ body { #notification-region i { padding-right: 10px; } + + +.line { + height: 4em; + line-height: 4em; +} + + .line > [class^="icon-"], .line > [class*=" icon-"] { + margin-top: 1em; + height: 1em; + line-height: 1em; + } + + diff --git a/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js b/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js index 14b94de11..73deeeb4d 100644 --- a/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js +++ b/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js @@ -3,7 +3,9 @@ NzbDrone.Shared.NotificationModel = Backbone.Model.extend({ mutators: { pre: function () { - return this.get('message').lines().lenght > 1; + if (this.get('message')) { + return this.get('message').lines().lenght > 1; + } }, iconClass: function () { diff --git a/NzbDrone.Web/_backboneApp/Shared/NotificationView.js b/NzbDrone.Web/_backboneApp/Shared/NotificationView.js index 5d24d4890..4df05825f 100644 --- a/NzbDrone.Web/_backboneApp/Shared/NotificationView.js +++ b/NzbDrone.Web/_backboneApp/Shared/NotificationView.js @@ -51,24 +51,32 @@ window.onerror = function (msg, url, line) { model.set('level', 'error'); NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(model); } catch (error) { - alert('Couldn\'t report JS error. ' + error); + + console.log("An error occurred while reporting error. " + error); + console.log(msg); + alert('Couldn\'t report JS error. ' + msg); } - var suppressErrorAlert = false; - return suppressErrorAlert; + return false; //don't suppress default alerts and logs. }; $(document).ajaxError(function (event, xmlHttpRequest, ajaxOptions) { + //don't report 200 error codes if (xmlHttpRequest.status >= 200 && xmlHttpRequest.status <= 300) { - return; + return undefined; + } + + //doesn't report aborted requests + if (xmlHttpRequest.statusText === 'abort') { + return undefined; } + var model = new NzbDrone.Shared.NotificationModel(); model.set('title', ajaxOptions.type + " " + ajaxOptions.url + " : " + xmlHttpRequest.statusText); model.set('message', xmlHttpRequest.responseText); model.set('level', 'error'); NzbDrone.Shared.NotificationCollectionView.Instance.collection.push(model); - var suppressErrorAlert = false; - return suppressErrorAlert; + return false; }); \ No newline at end of file