From 951e0837566060a54e3aed4aa10049571096982a Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 14 Feb 2013 22:46:42 -0800 Subject: [PATCH] server exceptions are formatted much nicer in the ui. --- .gitignore | 1 + NzbDrone.Api/Extentions/Serializer.cs | 4 ++-- .../AddSeries/Existing/ImportSeriesView.js | 24 ++++++++++++------- NzbDrone.Web/_backboneApp/Content/base.css | 4 ++++ .../_backboneApp/Shared/NotificationModel.js | 15 ++++++------ .../Shared/NotificationTemplate.html | 4 ++-- 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index c391dc4da..052177bef 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,4 @@ UpdateLogs/ NzbDrone.Web/cassette-cache/* *.eq NzbDrone.Web/_backboneApp/.idea/workspace.xml +*/.idea/workspace.xml diff --git a/NzbDrone.Api/Extentions/Serializer.cs b/NzbDrone.Api/Extentions/Serializer.cs index f3d438727..9210f0381 100644 --- a/NzbDrone.Api/Extentions/Serializer.cs +++ b/NzbDrone.Api/Extentions/Serializer.cs @@ -12,7 +12,7 @@ namespace NzbDrone.Api.Extentions { DateTimeZoneHandling = DateTimeZoneHandling.Utc, NullValueHandling = NullValueHandling.Ignore, - Formatting = Formatting.None, + Formatting = Formatting.Indented, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate }; @@ -20,7 +20,7 @@ namespace NzbDrone.Api.Extentions { DateTimeZoneHandling = Settings.DateTimeZoneHandling, NullValueHandling = NullValueHandling.Ignore, - Formatting = Formatting.None, + Formatting = Formatting.Indented, DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, ContractResolver = new CamelCasePropertyNamesContractResolver() }; diff --git a/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js b/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js index eec8516ee..891f8d0c1 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/Existing/ImportSeriesView.js @@ -1,14 +1,7 @@ 'use strict'; define([ - 'app', - 'AddSeries/RootFolders/RootFolderCollection', - 'Quality/QualityProfileCollection', - 'Shared/NotificationCollection', - 'AddSeries/Existing/UnmappedFolderModel', - 'AddSeries/SearchResultCollection', - 'Series/SeriesModel'], - function (app, rootFolders, qualityProfileCollection, notificationCollection) { + 'app', 'AddSeries/RootFolders/RootFolderCollection', 'Quality/QualityProfileCollection', 'Shared/NotificationCollection', 'AddSeries/Existing/UnmappedFolderModel', 'AddSeries/SearchResultCollection', 'Series/SeriesModel'], function (app, rootFolders, qualityProfileCollection, notificationCollection) { NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({ @@ -34,6 +27,21 @@ define([ var self = this; + var seriesCollection = new NzbDrone.Series.SeriesCollection(); + + seriesCollection.add(model, {success:function () { + var notificationModel = new NzbDrone.Shared.NotificationModel({ + title:'Added', + message:title, + level:'success' + }); + + notificationCollection.push(notificationModel); + self.close(); + } + }); + + return; model.save(undefined, { success:function () { var notificationModel = new NzbDrone.Shared.NotificationModel({ diff --git a/NzbDrone.Web/_backboneApp/Content/base.css b/NzbDrone.Web/_backboneApp/Content/base.css index aaa5af9df..50ae9b570 100644 --- a/NzbDrone.Web/_backboneApp/Content/base.css +++ b/NzbDrone.Web/_backboneApp/Content/base.css @@ -73,6 +73,10 @@ body { padding-right: 10px; } +#notification-region pre{ + font-size: 12px; +} + .line { height: 4em; diff --git a/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js b/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js index 798445423..095a38562 100644 --- a/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js +++ b/NzbDrone.Web/_backboneApp/Shared/NotificationModel.js @@ -2,16 +2,15 @@ NzbDrone.Shared.NotificationModel = Backbone.Model.extend({ mutators:{ - pre:function () { - try { - if (this.get('message')) { - return this.get('message').lines().lenght > 1; - } - } catch (error) { - return false; - } + preFormattedMessage:function () { + return this.get('message').replace(/\\r\\n/g, '
'); + }, + + isPreFormatted:function () { + return this.get('message').indexOf('\\r\\n') !== -1; }, + iconClass:function () { if (this.has('icon')) { diff --git a/NzbDrone.Web/_backboneApp/Shared/NotificationTemplate.html b/NzbDrone.Web/_backboneApp/Shared/NotificationTemplate.html index 8bc4600aa..69d9faedb 100644 --- a/NzbDrone.Web/_backboneApp/Shared/NotificationTemplate.html +++ b/NzbDrone.Web/_backboneApp/Shared/NotificationTemplate.html @@ -1,8 +1,8 @@ 
{{title}} - {{#if preFormatted}} -
 {{message}}
+ {{#if isPreFormatted}} +
{{{preFormattedMessage}}}
{{else}} {{message}} {{/if}}