Fix: Grids will no longer display alerts when navigating to another page while the grid is still loading.

pull/4/head
Mark McDowall 13 years ago
parent 68e1a0bc4d
commit 2635ff9bee

@ -380,6 +380,7 @@
<Content Include="Scripts\jquery.validate.unobtrusive.min.js" /> <Content Include="Scripts\jquery.validate.unobtrusive.min.js" />
<Content Include="Scripts\NzbDrone\addSeries.js" /> <Content Include="Scripts\NzbDrone\addSeries.js" />
<Content Include="Scripts\NzbDrone\AutoComplete.js" /> <Content Include="Scripts\NzbDrone\AutoComplete.js" />
<Content Include="Scripts\NzbDrone\grid.js" />
<Content Include="Scripts\NzbDrone\settings.js" /> <Content Include="Scripts\NzbDrone\settings.js" />
<Content Include="Scripts\NzbDrone\localSearch.js" /> <Content Include="Scripts\NzbDrone\localSearch.js" />
<Content Include="Scripts\NzbDrone\Notification.js" /> <Content Include="Scripts\NzbDrone\Notification.js" />

@ -32,9 +32,10 @@
}); });
jqXHR.error(function (xhr, ajaxOptions, thrownError) { jqXHR.error(function (xhr, textStatus, thrownError) {
//ignore notification errors. //ignore notification errors.
if (this.url.indexOf("/notification/Comet") !== 0) { if (this.url.indexOf("/notification/Comet") !== 0) {
alert("Status: " + textStatus + ", Error: " + thrownError);
$.gritter.add({ $.gritter.add({
title: 'Request failed', title: 'Request failed',
text: this.url, text: this.url,

@ -0,0 +1,4 @@
function grid_onError(e) {
//Suppress the alert
e.preventDefault();
}

@ -1,4 +1,5 @@
@model List<HistoryModel> @model List<HistoryModel>
@using NzbDrone.Common
@using NzbDrone.Web.Models @using NzbDrone.Web.Models
@using NzbDrone.Web.Helpers @using NzbDrone.Web.Helpers
@{ViewBag.Title = "History";} @{ViewBag.Title = "History";}
@ -49,6 +50,11 @@
.Pageable( .Pageable(
c => c =>
c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious)) c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious))
.ClientEvents(clientEvents =>
{
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
})
.Render();} .Render();}
</div> </div>
<script type="text/javascript"> <script type="text/javascript">

@ -1,3 +1,4 @@
@using NzbDrone.Common
@using NzbDrone.Core.Instrumentation @using NzbDrone.Core.Instrumentation
@using NzbDrone.Web.Helpers @using NzbDrone.Web.Helpers
@model IEnumerable<NzbDrone.Core.Instrumentation.Log> @model IEnumerable<NzbDrone.Core.Instrumentation.Log>
@ -50,6 +51,11 @@
.Filterable() .Filterable()
.ClientEvents(c => c.OnRowDataBound("onRowDataBound")) .ClientEvents(c => c.OnRowDataBound("onRowDataBound"))
.Scrollable(c => c.Height(500)) .Scrollable(c => c.Height(500))
.ClientEvents(clientEvents =>
{
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
})
.Render();} .Render();}
<script type="text/javascript"> <script type="text/javascript">
function reloadGrid() { function reloadGrid() {

@ -1,4 +1,5 @@
@using NzbDrone.Core.Model @using NzbDrone.Common
@using NzbDrone.Core.Model
@{ViewBag.Title = "Misnamed";} @{ViewBag.Title = "Misnamed";}
@section ActionMenu{ @section ActionMenu{
<ul class="sub-menu"> <ul class="sub-menu">
@ -47,6 +48,8 @@
.ClientEvents(clientEvents => .ClientEvents(clientEvents =>
{ {
clientEvents.OnDataBound("grid_dataBound"); clientEvents.OnDataBound("grid_dataBound");
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
}) })
.Render();} .Render();}
</div> </div>

@ -1,4 +1,5 @@
@model List<MissingEpisodeModel> @model List<MissingEpisodeModel>
@using NzbDrone.Common
@using NzbDrone.Web.Helpers @using NzbDrone.Web.Helpers
@using NzbDrone.Web.Models; @using NzbDrone.Web.Models;
@{ViewBag.Title="Missing";} @{ViewBag.Title="Missing";}
@ -48,4 +49,9 @@
.Pageable( .Pageable(
c => c =>
c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious)) c.PageSize(20).Position(GridPagerPosition.Bottom).Style(GridPagerStyles.NextPrevious))
.ClientEvents(clientEvents =>
{
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
})
.Render();} .Render();}

@ -1,4 +1,5 @@
@model SeriesModel @model SeriesModel
@using NzbDrone.Common
@using NzbDrone.Web.Helpers @using NzbDrone.Web.Helpers
@using NzbDrone.Web.Models @using NzbDrone.Web.Models
@{ViewBag.Title = Model.Title;} @{ViewBag.Title = Model.Title;}
@ -128,6 +129,8 @@
{ {
clientEvents.OnRowDataBound("grid_rowBound"); clientEvents.OnRowDataBound("grid_rowBound");
clientEvents.OnDataBound("grid_dataBound"); clientEvents.OnDataBound("grid_dataBound");
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
}) })
.Sortable(sorting => sorting .Sortable(sorting => sorting
.OrderBy(sortOrder => sortOrder.Add(o => o.EpisodeNumber).Descending()).SortMode(GridSortMode.SingleColumn)) .OrderBy(sortOrder => sortOrder.Add(o => o.EpisodeNumber).Descending()).SortMode(GridSortMode.SingleColumn))

@ -1,3 +1,4 @@
@using NzbDrone.Common
@using NzbDrone.Web.Helpers @using NzbDrone.Web.Helpers
@using NzbDrone.Web.Models; @using NzbDrone.Web.Models;
@model IEnumerable<NzbDrone.Core.Repository.Series> @model IEnumerable<NzbDrone.Core.Repository.Series>
@ -98,6 +99,8 @@
clientEvents.OnEdit("grid_edit"); clientEvents.OnEdit("grid_edit");
clientEvents.OnSave("grid_save"); clientEvents.OnSave("grid_save");
clientEvents.OnRowDataBound("grid_rowBound"); clientEvents.OnRowDataBound("grid_rowBound");
if(EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
}) })
.Render();} .Render();}
@section Scripts{ @section Scripts{

@ -34,6 +34,7 @@
@Html.IncludeScript("NzbDrone/AutoComplete.js") @Html.IncludeScript("NzbDrone/AutoComplete.js")
@Html.IncludeScript("NzbDrone/Notification.js") @Html.IncludeScript("NzbDrone/Notification.js")
@Html.IncludeScript("NzbDrone/AutoBind.js") @Html.IncludeScript("NzbDrone/AutoBind.js")
@Html.IncludeScript("NzbDrone/grid.js")
@RenderSection("Scripts", required: false) @RenderSection("Scripts", required: false)
</body> </body>
</html> </html>

@ -1,4 +1,5 @@
@model List<UpcomingEpisodeModel> @model List<UpcomingEpisodeModel>
@using NzbDrone.Common
@using NzbDrone.Web.Helpers @using NzbDrone.Web.Helpers
@using NzbDrone.Web.Models @using NzbDrone.Web.Models
@{ViewBag.Title = "Upcoming";} @{ViewBag.Title = "Upcoming";}
@ -43,6 +44,11 @@
)) ))
.DataBinding(data => data.Ajax().Select("_AjaxBindingYesterday", "Upcoming")) .DataBinding(data => data.Ajax().Select("_AjaxBindingYesterday", "Upcoming"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true))
.ClientEvents(clientEvents =>
{
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
})
.Render();} .Render();}
</div> </div>
</div> </div>
@ -78,6 +84,11 @@
)) ))
.DataBinding(data => data.Ajax().Select("_AjaxBindingToday", "Upcoming")) .DataBinding(data => data.Ajax().Select("_AjaxBindingToday", "Upcoming"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true))
.ClientEvents(clientEvents =>
{
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
})
.Render();} .Render();}
</div> </div>
</div> </div>
@ -115,6 +126,11 @@
.DataBinding(data => data.Ajax().Select("_AjaxBindingTomorrow", "Upcoming")) .DataBinding(data => data.Ajax().Select("_AjaxBindingTomorrow", "Upcoming"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true))
.ClientEvents(clientEvents =>
{
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
})
.Render();} .Render();}
</div> </div>
</div> </div>
@ -151,6 +167,11 @@
)) ))
.DataBinding(data => data.Ajax().Select("_AjaxBindingWeek", "Upcoming")) .DataBinding(data => data.Ajax().Select("_AjaxBindingWeek", "Upcoming"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.AirDateTime).Ascending()).Enabled(true))
.ClientEvents(clientEvents =>
{
if (EnviromentProvider.IsProduction)
clientEvents.OnError("grid_onError");
})
.Render();} .Render();}
</div> </div>
</div> </div>

Loading…
Cancel
Save