#172 attempt reconnect if signalR disconnects

This commit is contained in:
Gary Sharp
2025-07-17 12:44:06 +10:00
parent f8fd1a58a3
commit 0905a02aea
20 changed files with 539 additions and 524 deletions
@@ -747,8 +747,6 @@
hub.client.removeAttachment = onRemoveAttachment; hub.client.removeAttachment = onRemoveAttachment;
$.connection.hub.qs = { DeviceBatchId: '@(Model.DeviceBatch.Id)' }; $.connection.hub.qs = { DeviceBatchId: '@(Model.DeviceBatch.Id)' };
$.connection.hub.error(onHubFailed);
$.connection.hub.disconnected(onHubFailed);
$.connection.hub.reconnecting(function () { $.connection.hub.reconnecting(function () {
$Attachments.find('span.action.enabled').addClass('disabled'); $Attachments.find('span.action.enabled').addClass('disabled');
@@ -756,13 +754,10 @@
$.connection.hub.reconnected(function () { $.connection.hub.reconnected(function () {
$Attachments.find('span.action.enabled').removeClass('disabled'); $Attachments.find('span.action.enabled').removeClass('disabled');
}); });
$.connection.hub.error(function (error) {
// Start Connection console.log('Server connection error: ' + error);
$.connection.hub.start(function () { });
$Attachments.find('span.action.enabled').removeClass('disabled'); $.connection.hub.disconnected(function () {
}).fail(onHubFailed);
function onHubFailed(error) {
// Disable UI // Disable UI
$Attachments.find('span.action.enabled').addClass('disabled'); $Attachments.find('span.action.enabled').addClass('disabled');
@@ -787,7 +782,12 @@
} }
}); });
} }
} });
// Start Connection
$.connection.hub.start(function () {
$Attachments.find('span.action.enabled').removeClass('disabled');
});
function onAddAttachment(id, quick) { function onAddAttachment(id, quick) {
var data = { id: id }; var data = { id: id };
@@ -2383,42 +2383,43 @@ WriteLiteral(@">
#line default #line default
#line hidden #line hidden
WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n " + WriteLiteral("\' };\r\n\r\n $.connection.hub.reconnecting(function () {\r\n" +
" $.connection.hub.disconnected(onHubFailed);\r\n\r\n " + " $Attachments.find(\'span.action.enabled\').addClas" +
" $.connection.hub.reconnecting(function () {\r\n " + "s(\'disabled\');\r\n });\r\n $.c" +
" $Attachments.find(\'span.action.enabled\').addClass(\'disabled\');\r\n " + "onnection.hub.reconnected(function () {\r\n $Attach" +
" });\r\n $.connection.hub.reconne" + "ments.find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " +
"cted(function () {\r\n $Attachments.find(\'span.acti" + " });\r\n $.connection.hub.error(function (error)" +
"on.enabled\').removeClass(\'disabled\');\r\n });\r\n\r\n " + " {\r\n console.log(\'Server connection error: \' + er" +
" // Start Connection\r\n $.connect" + "ror);\r\n });\r\n $.connection" +
"ion.hub.start(function () {\r\n $Attachments.find(\'" + ".hub.disconnected(function () {\r\n // Disable UI\r\n" +
"span.action.enabled\').removeClass(\'disabled\');\r\n }).f" + " $Attachments.find(\'span.action.enabled\').addClas" +
"ail(onHubFailed);\r\n\r\n function onHubFailed(error) {\r\n" + "s(\'disabled\');\r\n\r\n // Show Dialog Message\r\n " +
" // Disable UI\r\n $" + " if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
"Attachments.find(\'span.action.enabled\').addClass(\'disabled\');\r\n\r\n " + " $(\'<div>\')\r\n " +
" // Show Dialog Message\r\n if ($(\'" + ".addClass(\'dialog disconnected-dialog\')\r\n " +
".disconnected-dialog\').length == 0) {\r\n $(\'<d" + " .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><" +
"iv>\')\r\n .addClass(\'dialog disconnected-di" + "i class=\"fa fa-ban fa-stack-2x error\"></i></span>Disconnected from the Disco ICT" +
"alog\')\r\n .html(\'<h3><span class=\"fa-stack" + " Server</h3><div>This page is not receiving live updates. Please ensure you are " +
" fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x er" + "connected to the server, then refresh this page to enable features.</div>\')\r\n " +
"ror\"></i></span>Disconnected from the Disco ICT Server</h3><div>This page is not" + " .dialog({\r\n " +
" receiving live updates. Please ensure you are connected to the server, then ref" + " resizable: false,\r\n title" +
"resh this page to enable features.</div>\')\r\n " + ": \'Disconnected\',\r\n width: 400,\r\n " +
" .dialog({\r\n resizable: false,\r\n " + " modal: true,\r\n " +
" title: \'Disconnected\',\r\n " + " buttons: {\r\n \'R" +
" width: 400,\r\n " + "efresh Now\': function () {\r\n " +
" modal: true,\r\n buttons: {\r\n " + "$(this).dialog(\'option\', \'buttons\', null);\r\n " +
" \'Refresh Now\': function () {\r\n " + " window.location.reload(true);\r\n " +
" $(this).dialog(\'option\', \'buttons" + " },\r\n \'Close\': func" +
"\', null);\r\n window.location.r" + "tion () {\r\n $(this).dialog(\'d" +
"eload(true);\r\n },\r\n " + "estroy\');\r\n }\r\n " +
" \'Close\': function () {\r\n " + " }\r\n });\r\n " +
" $(this).dialog(\'destroy\');\r\n " + " }\r\n });\r\n\r\n " +
" }\r\n }\r\n " + " // Start Connection\r\n $.connection.hub.st" +
" });\r\n }\r\n " + "art(function () {\r\n $Attachments.find(\'span.actio" +
" }\r\n\r\n function onAddAttachmen" + "n.enabled\').removeClass(\'disabled\');\r\n });\r\n\r\n " +
"t(id, quick) {\r\n var data = { id: id };\r\n " + " function onAddAttachment(id, quick) {\r\n " +
" $.ajax({\r\n url: \'"); " var data = { id: id };\r\n $.ajax({\r\n " +
" url: \'");
#line 795 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml" #line 795 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
@@ -2908,27 +2909,27 @@ WriteLiteral(" <li>\r\n
WriteLiteral(" type=\"radio\""); WriteLiteral(" type=\"radio\"");
WriteAttribute("id", Tuple.Create(" id=\"", 56824), Tuple.Create("\"", 56894) WriteAttribute("id", Tuple.Create(" id=\"", 56868), Tuple.Create("\"", 56938)
, Tuple.Create(Tuple.Create("", 56829), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 56829), true) , Tuple.Create(Tuple.Create("", 56873), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 56873), true)
#line 1058 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml" #line 1058 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
, Tuple.Create(Tuple.Create("", 56868), Tuple.Create<System.Object, System.Int32>((int)decommissionReason , Tuple.Create(Tuple.Create("", 56912), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default #line default
#line hidden #line hidden
, 56868), false) , 56912), false)
); );
WriteLiteral("\r\n name=\"decommissionReason\""); WriteLiteral("\r\n name=\"decommissionReason\"");
WriteAttribute("value", Tuple.Create(" value=\"", 56961), Tuple.Create("\"", 56995) WriteAttribute("value", Tuple.Create(" value=\"", 57005), Tuple.Create("\"", 57039)
#line 1059 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml" #line 1059 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
, Tuple.Create(Tuple.Create("", 56969), Tuple.Create<System.Object, System.Int32>((int)decommissionReason , Tuple.Create(Tuple.Create("", 57013), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default #line default
#line hidden #line hidden
, 56969), false) , 57013), false)
); );
WriteLiteral(" "); WriteLiteral(" ");
@@ -2942,15 +2943,15 @@ WriteLiteral(" ");
#line hidden #line hidden
WriteLiteral(" />\r\n <label"); WriteLiteral(" />\r\n <label");
WriteAttribute("for", Tuple.Create(" for=\"", 57135), Tuple.Create("\"", 57206) WriteAttribute("for", Tuple.Create(" for=\"", 57179), Tuple.Create("\"", 57250)
, Tuple.Create(Tuple.Create("", 57141), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 57141), true) , Tuple.Create(Tuple.Create("", 57185), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 57185), true)
#line 1060 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml" #line 1060 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
, Tuple.Create(Tuple.Create("", 57180), Tuple.Create<System.Object, System.Int32>((int)decommissionReason , Tuple.Create(Tuple.Create("", 57224), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default #line default
#line hidden #line hidden
, 57180), false) , 57224), false)
); );
WriteLiteral(">"); WriteLiteral(">");
@@ -5,7 +5,8 @@
Html.BundleDeferred("~/ClientScripts/Modules/Knockout"); Html.BundleDeferred("~/ClientScripts/Modules/Knockout");
Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR"); Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR");
} }
<h2>Documents Imported Today <h2>
Documents Imported Today
</h2> </h2>
<div id="importStatus"> <div id="importStatus">
@Html.AntiForgeryToken() @Html.AntiForgeryToken()
@@ -13,7 +14,7 @@
<h3>No imported documents today</h3> <h3>No imported documents today</h3>
</div> </div>
<div id="sessions" data-bind="visible: !noSessions(), foreach: { data: sessions, afterRender: sessionRendered }" <div id="sessions" data-bind="visible: !noSessions(), foreach: { data: sessions, afterRender: sessionRendered }"
style="display: none"> style="display: none">
<div class="session"> <div class="session">
<div class="clearfix"> <div class="clearfix">
<div class="sessionLeftPane"> <div class="sessionLeftPane">
@@ -56,16 +57,18 @@
<table class="logEventsViewport"> <table class="logEventsViewport">
<thead> <thead>
<tr> <tr>
<th class="icon">&nbsp; <th class="icon">
&nbsp;
</th> </th>
<th class="message">Message <th class="message">
Message
</th> </th>
</tr> </tr>
</thead> </thead>
</table> </table>
<div class="logEventsViewportContainer"> <div class="logEventsViewportContainer">
<div class="logEventsViewportNoLogs" data-bind="visible: messages().length == 0" <div class="logEventsViewportNoLogs" data-bind="visible: messages().length == 0"
style="display: none"> style="display: none">
No logs No logs
</div> </div>
<table class="logEventsViewport" data-bind="visible: messages().length > 0" style="display: none"> <table class="logEventsViewport" data-bind="visible: messages().length > 0" style="display: none">
@@ -309,13 +312,10 @@
logHub.client.receiveLog = parseLog logHub.client.receiveLog = parseLog
$.connection.hub.qs = { LogModules: '@(Disco.Services.Documents.DocumentsLog.Current.LiveLogGroupName)' }; $.connection.hub.qs = { LogModules: '@(Disco.Services.Documents.DocumentsLog.Current.LiveLogGroupName)' };
$.connection.hub.error(onHubFailed); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
$.connection.hub.start() });
.done(function () { isLive = true; }) $.connection.hub.disconnected(function () {
.fail(onHubFailed);
function onHubFailed(error) {
// Show Dialog Message // Show Dialog Message
if ($('.disconnected-dialog').length == 0) { if ($('.disconnected-dialog').length == 0) {
$('<div>') $('<div>')
@@ -337,7 +337,11 @@
} }
}); });
} }
} });
$.connection.hub.start()
.done(function () { isLive = true; });
} }
init(); init();
}); });
@@ -55,7 +55,7 @@ namespace Disco.Web.Areas.Config.Views.DocumentTemplate
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n<h2>Documents Imported Today\r\n</h2>\r\n<div"); WriteLiteral("\r\n<h2>\r\n Documents Imported Today\r\n</h2>\r\n<div");
WriteLiteral(" id=\"importStatus\""); WriteLiteral(" id=\"importStatus\"");
@@ -64,7 +64,7 @@ WriteLiteral(">\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 11 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 12 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Html.AntiForgeryToken()); Write(Html.AntiForgeryToken());
@@ -83,7 +83,7 @@ WriteLiteral(" id=\"sessions\"");
WriteLiteral(" data-bind=\"visible: !noSessions(), foreach: { data: sessions, afterRender: sessi" + WriteLiteral(" data-bind=\"visible: !noSessions(), foreach: { data: sessions, afterRender: sessi" +
"onRendered }\""); "onRendered }\"");
WriteLiteral("\r\n style=\"display: none\""); WriteLiteral("\r\n style=\"display: none\"");
WriteLiteral(">\r\n <div"); WriteLiteral(">\r\n <div");
@@ -210,12 +210,14 @@ WriteLiteral(">\r\n <thead>\r\n <tr>\r
WriteLiteral(" class=\"icon\""); WriteLiteral(" class=\"icon\"");
WriteLiteral(">&nbsp;\r\n </th>\r\n <th"); WriteLiteral(">\r\n &nbsp;\r\n </th>\r\n " +
" <th");
WriteLiteral(" class=\"message\""); WriteLiteral(" class=\"message\"");
WriteLiteral(">Message\r\n </th>\r\n </tr>\r\n " + WriteLiteral(">\r\n Message\r\n </th>\r\n " +
" </thead>\r\n </table>\r\n <div"); " </tr>\r\n </thead>\r\n </tab" +
"le>\r\n <div");
WriteLiteral(" class=\"logEventsViewportContainer\""); WriteLiteral(" class=\"logEventsViewportContainer\"");
@@ -225,7 +227,7 @@ WriteLiteral(" class=\"logEventsViewportNoLogs\"");
WriteLiteral(" data-bind=\"visible: messages().length == 0\""); WriteLiteral(" data-bind=\"visible: messages().length == 0\"");
WriteLiteral("\r\n style=\"display: none\""); WriteLiteral("\r\n style=\"display: none\"");
WriteLiteral(">\r\n No logs\r\n </div>\r\n " + WriteLiteral(">\r\n No logs\r\n </div>\r\n " +
" <table"); " <table");
@@ -287,7 +289,7 @@ WriteLiteral(">\r\n $(function () {\r\n var vm;\r\n var host =
"var urlDeviceShow = \'"); "var urlDeviceShow = \'");
#line 104 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 107 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.Device.Show())); Write(Url.Action(MVC.Device.Show()));
@@ -296,7 +298,7 @@ WriteLiteral(">\r\n $(function () {\r\n var vm;\r\n var host =
WriteLiteral("/\'\r\n var urlJobShow = \'"); WriteLiteral("/\'\r\n var urlJobShow = \'");
#line 105 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 108 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.Job.Show())); Write(Url.Action(MVC.Job.Show()));
@@ -305,7 +307,7 @@ WriteLiteral("/\'\r\n var urlJobShow = \'");
WriteLiteral("/\'\r\n var urlUserShow = \'"); WriteLiteral("/\'\r\n var urlUserShow = \'");
#line 106 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 109 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.User.Show())); Write(Url.Action(MVC.User.Show()));
@@ -314,7 +316,7 @@ WriteLiteral("/\'\r\n var urlUserShow = \'");
WriteLiteral("/\'\r\n var urlPageThumbnail = \'"); WriteLiteral("/\'\r\n var urlPageThumbnail = \'");
#line 107 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 110 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.API.DocumentTemplate.ImporterThumbnail())); Write(Url.Action(MVC.API.DocumentTemplate.ImporterThumbnail()));
@@ -323,7 +325,7 @@ WriteLiteral("/\'\r\n var urlPageThumbnail = \'");
WriteLiteral("/\'\r\n var urlDocumentTemplate = \'"); WriteLiteral("/\'\r\n var urlDocumentTemplate = \'");
#line 108 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 111 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.Config.DocumentTemplate.Index())); Write(Url.Action(MVC.Config.DocumentTemplate.Index()));
@@ -332,7 +334,7 @@ WriteLiteral("/\'\r\n var urlDocumentTemplate = \'");
WriteLiteral("/\';\r\n var urlManuallyAssign = \'"); WriteLiteral("/\';\r\n var urlManuallyAssign = \'");
#line 109 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 112 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.Config.DocumentTemplate.UndetectedPages())); Write(Url.Action(MVC.Config.DocumentTemplate.UndetectedPages()));
@@ -444,7 +446,7 @@ WriteLiteral("\';\r\n var isLive = false;\r\n\r\n function pageVie
"n\"]\').val()\r\n };\r\n $.ajax({\r\n url: \'"); "n\"]\').val()\r\n };\r\n $.ajax({\r\n url: \'");
#line 288 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 291 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.API.Logging.RetrieveEvents())); Write(Url.Action(MVC.API.Logging.RetrieveEvents()));
@@ -476,32 +478,33 @@ WriteLiteral(@"',
$.connection.hub.qs = { LogModules: '"); $.connection.hub.qs = { LogModules: '");
#line 311 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" #line 314 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Disco.Services.Documents.DocumentsLog.Current.LiveLogGroupName); Write(Disco.Services.Documents.DocumentsLog.Current.LiveLogGroupName);
#line default #line default
#line hidden #line hidden
WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n\r\n $.connectio" + WriteLiteral("\' };\r\n $.connection.hub.error(function (error) {\r\n cons" +
"n.hub.start()\r\n .done(function () { isLive = true; })\r\n " + "ole.log(\'Server connection error: \' + error);\r\n });\r\n $.co" +
" .fail(onHubFailed);\r\n\r\n function onHubFailed(error) {\r\n " + "nnection.hub.disconnected(function () {\r\n // Show Dialog Message\r" +
" // Show Dialog Message\r\n if ($(\'.disconnected-dialog\').le" + "\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
"ngth == 0) {\r\n $(\'<div>\')\r\n .addClass(" + " $(\'<div>\')\r\n .addClass(\'dialog disconnected-dialog\')\r\n" +
"\'dialog disconnected-dialog\')\r\n .html(\'<h3><span class=\"f" + " .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"fa fa-" +
"a-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stac" + "wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>Disconne" +
"k-2x error\"></i></span>Disconnected from the Disco ICT Server</h3><div>This page" + "cted from the Disco ICT Server</h3><div>This page is not receiving live updates." +
" is not receiving live updates. Please ensure you are connected to the server, t" + " Please ensure you are connected to the server, then refresh this page to enable" +
"hen refresh this page to enable features.</div>\')\r\n .dial" + " features.</div>\')\r\n .dialog({\r\n " +
"og({\r\n resizable: false,\r\n " + " resizable: false,\r\n title: \'Disconnected\',\r\n " +
" title: \'Disconnected\',\r\n width: 400,\r\n " + " width: 400,\r\n modal: true,\r\n " +
" modal: true,\r\n buttons: {\r\n " + " buttons: {\r\n \'Refresh No" +
" \'Refresh Now\': function () {\r\n " + "w\': function () {\r\n $(this).dialog(\'option\', " +
" $(this).dialog(\'option\', \'buttons\', null);\r\n " + "\'buttons\', null);\r\n window.location.reload(tr" +
" window.location.reload(true);\r\n },\r\n " + "ue);\r\n },\r\n \'Close" +
" \'Close\': function () {\r\n " + "\': function () {\r\n $(this).dialog(\'destroy\');" +
" $(this).dialog(\'destroy\');\r\n }\r\n " + "\r\n }\r\n }\r\n " +
" }\r\n });\r\n }\r\n }" + " });\r\n }\r\n });\r\n\r\n $.connection." +
"\r\n }\r\n init();\r\n });\r\n</script>\r\n"); "hub.start()\r\n .done(function () { isLive = true; });\r\n\r\n }" +
"\r\n init();\r\n });\r\n</script>\r\n");
} }
} }
@@ -407,13 +407,10 @@
logHub.client.receiveLog = parseLog logHub.client.receiveLog = parseLog
$.connection.hub.qs = { LogModules: '@(Disco.Services.Devices.Enrolment.EnrolmentLog.Current.LiveLogGroupName)' }; $.connection.hub.qs = { LogModules: '@(Disco.Services.Devices.Enrolment.EnrolmentLog.Current.LiveLogGroupName)' };
$.connection.hub.error(onHubFailed); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
$.connection.hub.start() });
.done(function () { isLive = true; }) $.connection.hub.disconnected(function (error) {
.fail(onHubFailed);
function onHubFailed(error) {
// Show Dialog Message // Show Dialog Message
if ($('.disconnected-dialog').length == 0) { if ($('.disconnected-dialog').length == 0) {
$('<div>') $('<div>')
@@ -435,7 +432,11 @@
} }
}); });
} }
} });
$.connection.hub.start()
.done(function () { isLive = true; });
} }
$('#dialogSession').on('click', '#formResolveSessionPending button', function (e) { $('#dialogSession').on('click', '#formResolveSessionPending button', function (e) {
const $button = $(this); const $button = $(this);
@@ -831,34 +831,35 @@ WriteLiteral(@"',
#line default #line default
#line hidden #line hidden
WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n\r\n $.connectio" + WriteLiteral("\' };\r\n $.connection.hub.error(function (error) {\r\n cons" +
"n.hub.start()\r\n .done(function () { isLive = true; })\r\n " + "ole.log(\'Server connection error: \' + error);\r\n });\r\n $.co" +
" .fail(onHubFailed);\r\n\r\n function onHubFailed(error) {\r\n " + "nnection.hub.disconnected(function (error) {\r\n // Show Dialog Mes" +
" // Show Dialog Message\r\n if ($(\'.disconnected-dialog\').le" + "sage\r\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
"ngth == 0) {\r\n $(\'<div>\')\r\n .addClass(" + " $(\'<div>\')\r\n .addClass(\'dialog disconnected-dialo" +
"\'dialog disconnected-dialog\')\r\n .html(\'<h3><span class=\"f" + "g\')\r\n .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"f" +
"a-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stac" + "a fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>Dis" +
"k-2x error\"></i></span>Disconnected from the Disco ICT Server</h3><div>This page" + "connected from the Disco ICT Server</h3><div>This page is not receiving live upd" +
" is not receiving live updates. Please ensure you are connected to the server, t" + "ates. Please ensure you are connected to the server, then refresh this page to e" +
"hen refresh this page to enable features.</div>\')\r\n .dial" + "nable features.</div>\')\r\n .dialog({\r\n " +
"og({\r\n resizable: false,\r\n " + " resizable: false,\r\n title: \'Disconnected\',\r\n " +
" title: \'Disconnected\',\r\n width: 400,\r\n " + " width: 400,\r\n modal: true," +
" modal: true,\r\n buttons: {\r\n " + "\r\n buttons: {\r\n \'Refre" +
" \'Refresh Now\': function () {\r\n " + "sh Now\': function () {\r\n $(this).dialog(\'opti" +
" $(this).dialog(\'option\', \'buttons\', null);\r\n " + "on\', \'buttons\', null);\r\n window.location.relo" +
" window.location.reload(true);\r\n },\r\n " + "ad(true);\r\n },\r\n \'" +
" \'Close\': function () {\r\n " + "Close\': function () {\r\n $(this).dialog(\'destr" +
" $(this).dialog(\'destroy\');\r\n }\r\n " + "oy\');\r\n }\r\n }\r\n " +
" }\r\n });\r\n }\r\n }" + " });\r\n }\r\n });\r\n\r\n $.connec" +
"\r\n }\r\n $(\'#dialogSession\').on(\'click\', \'#formResolveSessionPending" + "tion.hub.start()\r\n .done(function () { isLive = true; });\r\n\r\n " +
" button\', function (e) {\r\n const $button = $(this);\r\n cons" + " }\r\n $(\'#dialogSession\').on(\'click\', \'#formResolveSessionPending butto" +
"t $form = $button.closest(\'form\');\r\n const body = new FormData($form[" + "n\', function (e) {\r\n const $button = $(this);\r\n const $for" +
"0]);\r\n body.append(\'approve\', $button.val());\r\n fetch($for" + "m = $button.closest(\'form\');\r\n const body = new FormData($form[0]);\r\n" +
"m.attr(\'action\'), {\r\n method: \'POST\',\r\n body: body" + " body.append(\'approve\', $button.val());\r\n fetch($form.attr" +
"\r\n }).then(function (response) {\r\n if (!response.ok) {" + "(\'action\'), {\r\n method: \'POST\',\r\n body: body\r\n " +
"\r\n alert(\'Failed to resolve pending session: \' + response.sta" + " }).then(function (response) {\r\n if (!response.ok) {\r\n " +
"tusText);\r\n }\r\n });\r\n });\r\n init();\r\n " + " alert(\'Failed to resolve pending session: \' + response.statusTex" +
" });\r\n</script>\r\n"); "t);\r\n }\r\n });\r\n });\r\n init();\r\n });\r\n" +
"</script>\r\n");
} }
} }
@@ -122,11 +122,10 @@
}; };
$.connection.hub.qs = {LogModules: logModuleLiveGroupName}; $.connection.hub.qs = {LogModules: logModuleLiveGroupName};
$.connection.hub.error(onHubFailed); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
$.connection.hub.start().fail(onHubFailed); });
$.connection.hub.disconnected(function () {
function onHubFailed(error) {
// Show Dialog Message // Show Dialog Message
if ($('.disconnected-dialog').length == 0) { if ($('.disconnected-dialog').length == 0) {
$('<div>') $('<div>')
@@ -148,7 +147,9 @@
} }
}); });
} }
} })
$.connection.hub.start();
} }
} }
@@ -340,29 +340,30 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"ge.UseDisplay) logsViewModel.EventLogs.unshift(message);\r\n " + "ge.UseDisplay) logsViewModel.EventLogs.unshift(message);\r\n " +
" if (liveEventReceivedFunction) liveEventReceivedFunction(message);\r\n " + " if (liveEventReceivedFunction) liveEventReceivedFunction(message);\r\n " +
" };\r\n\r\n $.connection.hub.qs = {LogModules: logModule" + " };\r\n\r\n $.connection.hub.qs = {LogModules: logModule" +
"LiveGroupName};\r\n $.connection.hub.error(onHubFailed);\r\n\r\n " + "LiveGroupName};\r\n $.connection.hub.error(function (error) {\r\n" +
" $.connection.hub.start().fail(onHubFailed);\r\n\r\n " + " console.log(\'Server connection error: \' + error);\r\n " +
" function onHubFailed(error) {\r\n // Show Dialog Messag" + " });\r\n $.connection.hub.disconnected(function (" +
"e\r\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " + ") {\r\n // Show Dialog Message\r\n if " +
" $(\'<div>\')\r\n .addClass(\'dial" + "($(\'.disconnected-dialog\').length == 0) {\r\n $(\'<div>\'" +
"og disconnected-dialog\')\r\n .html(\'<h3><span class" + ")\r\n .addClass(\'dialog disconnected-dialog\')\r\n " +
"=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-s" + " .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"fa" +
"tack-2x error\"></i></span>Disconnected from the Disco ICT Server</h3><div>This p" + " fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>Disc" +
"age is not receiving live updates. Please ensure you are connected to the server" + "onnected from the Disco ICT Server</h3><div>This page is not receiving live upda" +
", then refresh this page to enable features.</div>\')\r\n " + "tes. Please ensure you are connected to the server, then refresh this page to en" +
" .dialog({\r\n resizable: false,\r\n " + "able features.</div>\')\r\n .dialog({\r\n " +
" title: \'Disconnected\',\r\n " + " resizable: false,\r\n ti" +
" width: 400,\r\n modal: true,\r\n " + "tle: \'Disconnected\',\r\n width: 400,\r\n " +
" buttons: {\r\n \'" + " modal: true,\r\n but" +
"Refresh Now\': function () {\r\n $(this)" + "tons: {\r\n \'Refresh Now\': function () {\r\n " +
".dialog(\'option\', \'buttons\', null);\r\n " + " $(this).dialog(\'option\', \'buttons\', n" +
" window.location.reload(true);\r\n },\r\n " + "ull);\r\n window.location.reload(true);" +
" \'Close\': function () {\r\n " + "\r\n },\r\n " +
" $(this).dialog(\'destroy\');\r\n " + " \'Close\': function () {\r\n $(this" +
" }\r\n }\r\n " + ").dialog(\'destroy\');\r\n }\r\n " +
" });\r\n }\r\n }\r\n }\r\n" + " }\r\n });\r\n " +
" }\r\n\r\n loadInitialData();\r\n });\r\n </script>\r\n</d" + " }\r\n })\r\n\r\n $.connection.hub.start();\r" +
"iv>\r\n"); "\n }\r\n }\r\n\r\n loadInitialData();\r\n });" +
"\r\n </script>\r\n</div>\r\n");
} }
} }
@@ -147,7 +147,6 @@
if (self.FullUpdateToken) if (self.FullUpdateToken)
window.clearTimeout(self.FullUpdateToken); window.clearTimeout(self.FullUpdateToken);
$.connection.hub.stop();
if (self.FinishedMessage()) if (self.FinishedMessage())
window.setTimeout(function () { window.location.href = self.FinishedUrl(); }, 3000); window.setTimeout(function () { window.location.href = self.FinishedUrl(); }, 3000);
@@ -247,35 +246,36 @@
notificationsHub.client.updateTaskStatus = vm.Update; notificationsHub.client.updateTaskStatus = vm.Update;
$.connection.hub.qs = { TaskSessionId: sessionId }; $.connection.hub.qs = { TaskSessionId: sessionId };
$.connection.hub.error(onHubFailed); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(function () {
// Show Dialog Message
if ($('.disconnected-dialog').length == 0) {
$('<div>')
.addClass('dialog disconnected-dialog')
.html('<h3><span class="fa-stack fa-lg"><i class="fa fa-wifi fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x error"></i></span>Disconnected from the Disco ICT Server</h3><div>This page is not receiving live updates. Please ensure you are connected to the server, then refresh this page to enable features.</div>')
.dialog({
resizable: false,
title: 'Disconnected',
width: 400,
modal: true,
buttons: {
'Refresh Now': function () {
$(this).dialog('option', 'buttons', null);
window.location.reload(true);
},
'Close': function () {
$(this).dialog('destroy');
}
}
});
}
})
$.connection.hub.start() $.connection.hub.start()
.fail(onHubFailed); .fail(onHubFailed);
} }
function onHubFailed(error) {
// Show Dialog Message
if ($('.disconnected-dialog').length == 0) {
$('<div>')
.addClass('dialog disconnected-dialog')
.html('<h3><span class="fa-stack fa-lg"><i class="fa fa-wifi fa-stack-1x"></i><i class="fa fa-ban fa-stack-2x error"></i></span>Disconnected from the Disco ICT Server</h3><div>This page is not receiving live updates. Please ensure you are connected to the server, then refresh this page to enable features.</div>')
.dialog({
resizable: false,
title: 'Disconnected',
width: 400,
modal: true,
buttons: {
'Refresh Now': function () {
$(this).dialog('option', 'buttons', null);
window.location.reload(true);
},
'Close': function () {
$(this).dialog('destroy');
}
}
});
}
}
}); });
</script> </script>
@@ -229,75 +229,77 @@ WriteLiteral("\';\r\n\r\n var view = $(\'#Logging_Task_Status\');\r\n
" if (self.FinishedTimestamp()) {\r\n if (self.FinishedUrl()" + " if (self.FinishedTimestamp()) {\r\n if (self.FinishedUrl()" +
" && !self.TaskExceptionMessage()) {\r\n\r\n if (self.FullUpda" + " && !self.TaskExceptionMessage()) {\r\n\r\n if (self.FullUpda" +
"teToken)\r\n window.clearTimeout(self.FullUpdateToken);" + "teToken)\r\n window.clearTimeout(self.FullUpdateToken);" +
"\r\n $.connection.hub.stop();\r\n\r\n if" + "\r\n\r\n if (self.FinishedMessage())\r\n " +
" (self.FinishedMessage())\r\n window.setTimeout(functio" + " window.setTimeout(function () { window.location.href = self.FinishedUrl(); " +
"n () { window.location.href = self.FinishedUrl(); }, 3000);\r\n " + "}, 3000);\r\n else\r\n window.loca" +
" else\r\n window.location.href = self.FinishedUrl()" + "tion.href = self.FinishedUrl();\r\n }\r\n }\r\n " +
";\r\n }\r\n }\r\n }\r\n\r\n self.I" + " }\r\n\r\n self.Initialize = function (taskStatus) {\r\n " +
"nitialize = function (taskStatus) {\r\n self.TaskName(taskStatus.Ta" + " self.TaskName(taskStatus.TaskName);\r\n self.FinishedUrl(taskSta" +
"skName);\r\n self.FinishedUrl(taskStatus.FinishedUrl);\r\n\r\n " + "tus.FinishedUrl);\r\n\r\n self.Progress(taskStatus.Progress);\r\n " +
" self.Progress(taskStatus.Progress);\r\n self.CurrentProcess(" + " self.CurrentProcess(taskStatus.CurrentProcess);\r\n self." +
"taskStatus.CurrentProcess);\r\n self.CurrentDescription(taskStatus." + "CurrentDescription(taskStatus.CurrentDescription);\r\n\r\n self.IsRun" +
"CurrentDescription);\r\n\r\n self.IsRunning(taskStatus.IsRunning);\r\n\r" + "ning(taskStatus.IsRunning);\r\n\r\n self.TaskExceptionMessage(taskSta" +
"\n self.TaskExceptionMessage(taskStatus.TaskExceptionMessage);\r\n\r\n" + "tus.TaskExceptionMessage);\r\n\r\n self.FinishedTimestamp(taskStatus." +
" self.FinishedTimestamp(taskStatus.FinishedTimestamp);\r\n " + "FinishedTimestamp);\r\n self.NextScheduledTimestamp(taskStatus.Next" +
" self.NextScheduledTimestamp(taskStatus.NextScheduledTimestamp);\r\n\r\n " + "ScheduledTimestamp);\r\n\r\n self.FinishedMessage(taskStatus.Finished" +
" self.FinishedMessage(taskStatus.FinishedMessage);\r\n\r\n s" + "Message);\r\n\r\n self.Initialized(true);\r\n\r\n self.Fin" +
"elf.Initialized(true);\r\n\r\n self.Finished();\r\n }\r\n " + "ished();\r\n }\r\n self.Update = function (taskStatus) {\r\n " +
" self.Update = function (taskStatus) {\r\n if (!self.Initiali" + " if (!self.Initialized())\r\n return;\r\n\r\n " +
"zed())\r\n return;\r\n\r\n if (self.FullUpdateToken)" + " if (self.FullUpdateToken)\r\n window.clearTimeout(self.Ful" +
"\r\n window.clearTimeout(self.FullUpdateToken);\r\n\r\n " + "lUpdateToken);\r\n\r\n if (taskStatus) {\r\n $.each(" +
" if (taskStatus) {\r\n $.each(taskStatus, function (key, val" + "taskStatus, function (key, value) {\r\n switch (key) {\r\n " +
"ue) {\r\n switch (key) {\r\n case " + " case \'Progress\':\r\n self." +
"\'Progress\':\r\n self.Progress(value);\r\n " + "Progress(value);\r\n break;\r\n " +
" break;\r\n case \'CurrentProcess\':\r\n" + " case \'CurrentProcess\':\r\n self.CurrentProces" +
" self.CurrentProcess(value);\r\n " + "s(value);\r\n break;\r\n c" +
" break;\r\n case \'CurrentDescription\':\r\n " + "ase \'CurrentDescription\':\r\n self.CurrentDescripti" +
" self.CurrentDescription(value);\r\n " + "on(value);\r\n break;\r\n " +
" break;\r\n case \'IsRunning\':\r\n " + "case \'IsRunning\':\r\n self.IsRunning(value);\r\n " +
" self.IsRunning(value);\r\n bre" + " break;\r\n case \'TaskExcepti" +
"ak;\r\n case \'TaskExceptionMessage\':\r\n " + "onMessage\':\r\n self.TaskExceptionMessage(value);\r\n" +
" self.TaskExceptionMessage(value);\r\n " + " break;\r\n case \'NextSc" +
" break;\r\n case \'NextScheduledTimestamp\':\r\n " + "heduledTimestamp\':\r\n self.NextScheduledTimestamp(" +
" self.NextScheduledTimestamp(value);\r\n " + "value);\r\n break;\r\n cas" +
" break;\r\n case \'FinishedUrl\':\r\n " + "e \'FinishedUrl\':\r\n self.FinishedUrl(value);\r\n " +
" self.FinishedUrl(value);\r\n br" + " break;\r\n case \'FinishedMe" +
"eak;\r\n case \'FinishedMessage\':\r\n " + "ssage\':\r\n self.FinishedMessage(value);\r\n " +
" self.FinishedMessage(value);\r\n break;\r" + " break;\r\n case \'FinishedTimesta" +
"\n case \'FinishedTimestamp\':\r\n " + "mp\':\r\n self.FinishedTimestamp(value);\r\n " +
" self.FinishedTimestamp(value);\r\n window.s" + " window.setTimeout(self.Finished, 1);\r\n " +
"etTimeout(self.Finished, 1);\r\n break;\r\n " + " break;\r\n default:\r\n " +
" default:\r\n // Ignore\r\n " + " // Ignore\r\n }\r\n });\r\n " +
" }\r\n });\r\n }\r\n\r\n " + " }\r\n\r\n if (!self.FinishedTimestamp())\r\n " +
"if (!self.FinishedTimestamp())\r\n self.FullUpdateToken = windo" + " self.FullUpdateToken = window.setTimeout(self.FullUpdate, 2000);\r\n " +
"w.setTimeout(self.FullUpdate, 2000);\r\n }\r\n\r\n self.FullUpda" + "}\r\n\r\n self.FullUpdate = function () {\r\n self.FullUpdat" +
"te = function () {\r\n self.FullUpdateToken = null;\r\n\r\n " + "eToken = null;\r\n\r\n if (!self.FinishedTimestamp())\r\n " +
" if (!self.FinishedTimestamp())\r\n notificationsHub.server." + " notificationsHub.server.getStatus()\r\n .done(self.In" +
"getStatus()\r\n .done(self.Initialize);\r\n }\r\n " + "itialize);\r\n }\r\n }\r\n\r\n vm = new statusViewModel(session" +
" }\r\n\r\n vm = new statusViewModel(sessionId);\r\n ko.applyBindings" + "Id);\r\n ko.applyBindings(vm, view[0]);\r\n\r\n // Start Live Connection" +
"(vm, view[0]);\r\n\r\n // Start Live Connection\r\n updateWithLive();\r\n\r" + "\r\n updateWithLive();\r\n\r\n function updateWithLive() {\r\n " +
"\n function updateWithLive() {\r\n notificationsHub = $.connectio" + "notificationsHub = $.connection.scheduledTaskNotifications;\r\n notific" +
"n.scheduledTaskNotifications;\r\n notificationsHub.client.initializeTas" + "ationsHub.client.initializeTaskStatus = vm.Initialize;\r\n notification" +
"kStatus = vm.Initialize;\r\n notificationsHub.client.updateTaskStatus =" + "sHub.client.updateTaskStatus = vm.Update;\r\n\r\n $.connection.hub.qs = {" +
" vm.Update;\r\n\r\n $.connection.hub.qs = { TaskSessionId: sessionId };\r\n" + " TaskSessionId: sessionId };\r\n $.connection.hub.error(function (error" +
" $.connection.hub.error(onHubFailed);\r\n\r\n $.connection.hub" + ") {\r\n console.log(\'Server connection error: \' + error);\r\n " +
".start()\r\n .fail(onHubFailed);\r\n }\r\n\r\n function onH" + " });\r\n $.connection.hub.disconnected(function () {\r\n " +
"ubFailed(error) {\r\n // Show Dialog Message\r\n if ($(\'.disco" + " // Show Dialog Message\r\n if ($(\'.disconnected-dialog\').length =" +
"nnected-dialog\').length == 0) {\r\n $(\'<div>\')\r\n " + "= 0) {\r\n $(\'<div>\')\r\n .addClass(\'dialo" +
" .addClass(\'dialog disconnected-dialog\')\r\n .html(\'<h3><span c" + "g disconnected-dialog\')\r\n .html(\'<h3><span class=\"fa-stac" +
"lass=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban " + "k fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x e" +
"fa-stack-2x error\"></i></span>Disconnected from the Disco ICT Server</h3><div>Th" + "rror\"></i></span>Disconnected from the Disco ICT Server</h3><div>This page is no" +
"is page is not receiving live updates. Please ensure you are connected to the se" + "t receiving live updates. Please ensure you are connected to the server, then re" +
"rver, then refresh this page to enable features.</div>\')\r\n .d" + "fresh this page to enable features.</div>\')\r\n .dialog({\r\n" +
"ialog({\r\n resizable: false,\r\n titl" + " resizable: false,\r\n title" +
"e: \'Disconnected\',\r\n width: 400,\r\n " + ": \'Disconnected\',\r\n width: 400,\r\n " +
" modal: true,\r\n buttons: {\r\n \'" + " modal: true,\r\n buttons: {\r\n " +
"Refresh Now\': function () {\r\n $(this).dialog(\'opt" + " \'Refresh Now\': function () {\r\n " +
"ion\', \'buttons\', null);\r\n window.location.reload(" + "$(this).dialog(\'option\', \'buttons\', null);\r\n " +
"true);\r\n },\r\n \'Close\': fun" + "window.location.reload(true);\r\n },\r\n " +
"ction () {\r\n $(this).dialog(\'destroy\');\r\n " + " \'Close\': function () {\r\n $" +
" }\r\n }\r\n });\r\n " + "(this).dialog(\'destroy\');\r\n }\r\n " +
" }\r\n }\r\n\r\n });\r\n</script>\r\n"); " }\r\n });\r\n }\r\n })\r\n\r\n " +
" $.connection.hub.start()\r\n .fail(onHubFailed);\r\n " +
" }\r\n\r\n });\r\n</script>\r\n");
} }
} }
@@ -131,9 +131,10 @@
hub.client.setTheme = setTheme; hub.client.setTheme = setTheme;
$.connection.hub.qs = { Noticeboard: '@(Disco.Services.Jobs.Noticeboards.HeldDevices.Name)' }; $.connection.hub.qs = { Noticeboard: '@(Disco.Services.Jobs.Noticeboards.HeldDevices.Name)' };
$.connection.hub.error(connectionError); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(connectionError); $.connection.hub.disconnected(connectionError);
$.connection.hub.reconnected(connectionError);
// Start Connection // Start Connection
$.connection.hub.start().fail(connectionError).done(loadData); $.connection.hub.start().fail(connectionError).done(loadData);
@@ -356,7 +357,6 @@
function connectionError() { function connectionError() {
try { try {
$('body').addClass('status-error'); $('body').addClass('status-error');
$.connection.hub.stop();
} catch (e) { } catch (e) {
// Ignore // Ignore
} }
@@ -256,9 +256,10 @@ WriteLiteral(">\r\n <li data-bind=\"css: { alert: IsAlert }\">\r\n
#line default #line default
#line hidden #line hidden
WriteLiteral(@"' }; WriteLiteral(@"' };
$.connection.hub.error(connectionError); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(connectionError); $.connection.hub.disconnected(connectionError);
$.connection.hub.reconnected(connectionError);
// Start Connection // Start Connection
$.connection.hub.start().fail(connectionError).done(loadData); $.connection.hub.start().fail(connectionError).done(loadData);
@@ -269,7 +270,7 @@ WriteLiteral(@"' };
$.getJSON('"); $.getJSON('");
#line 144 "..\..\Areas\Public\Views\HeldDevices\Noticeboard.cshtml" #line 145 "..\..\Areas\Public\Views\HeldDevices\Noticeboard.cshtml"
Write(Url.Action(MVC.Public.HeldDevices.HeldDevices())); Write(Url.Action(MVC.Public.HeldDevices.HeldDevices()));
@@ -399,54 +400,54 @@ WriteLiteral("\', null, function (data) {\r\n\r\n var inProce
"ngth > 0)\r\n itemFilters = filters;\r\n e" + "ngth > 0)\r\n itemFilters = filters;\r\n e" +
"lse\r\n itemFilters = null;\r\n }\r\n " + "lse\r\n itemFilters = null;\r\n }\r\n " +
" }\r\n\r\n function connectionError() {\r\n try {\r\n " + " }\r\n\r\n function connectionError() {\r\n try {\r\n " +
" $(\'body\').addClass(\'status-error\');\r\n $.connection" + " $(\'body\').addClass(\'status-error\');\r\n } catch (e) {\r\n " +
".hub.stop();\r\n } catch (e) {\r\n // Ignore\r\n " + " // Ignore\r\n }\r\n\r\n window.setTim" +
" }\r\n\r\n window.setTimeout(function () {\r\n " + "eout(function () {\r\n window.location.reload(true);\r\n " +
" window.location.reload(true);\r\n }, 10000);\r\n }\r\n" + " }, 10000);\r\n }\r\n\r\n // Helpers\r\n function" +
"\r\n // Helpers\r\n function rotateArray(koArray, element) {\r\n" + " rotateArray(koArray, element) {\r\n var items = koArray();\r\n\r\n " +
" var items = koArray();\r\n\r\n if (items.length <= 1)" + " if (items.length <= 1)\r\n return 0;\r\n\r\n " +
"\r\n return 0;\r\n\r\n if (element.height() < (eleme" + " if (element.height() < (element.parent().height() - 30)) {\r\n\r\n " +
"nt.parent().height() - 30)) {\r\n\r\n if (findUnsortedArrayTopInd" + " if (findUnsortedArrayTopIndex(items) !== 0)\r\n koAr" +
"ex(items) !== 0)\r\n koArray.sort(sortFunction);\r\n\r\n " + "ray.sort(sortFunction);\r\n\r\n // Don\'t rotate if small & sorted" +
" // Don\'t rotate if small & sorted correctly\r\n re" + " correctly\r\n return;\r\n }\r\n\r\n //" +
"turn;\r\n }\r\n\r\n // Move Last Item to Top\r\n " + " Move Last Item to Top\r\n var item = koArray.pop();\r\n " +
" var item = koArray.pop();\r\n koArray.unshift(item);\r\n " + " koArray.unshift(item);\r\n }\r\n function removeItemFromArr" +
" }\r\n function removeItemFromArray(koArray, deviceSerialNumber) {\r" + "ay(koArray, deviceSerialNumber) {\r\n var items = koArray();\r\n " +
"\n var items = koArray();\r\n for (var i = 0; i < ite" + " for (var i = 0; i < items.length; i++) {\r\n if (ite" +
"ms.length; i++) {\r\n if (items[i].DeviceSerialNumber == device" + "ms[i].DeviceSerialNumber == deviceSerialNumber) {\r\n koArr" +
"SerialNumber) {\r\n koArray.splice(i, 1);\r\n " + "ay.splice(i, 1);\r\n items = koArray();\r\n " +
" items = koArray();\r\n i--;\r\n }\r" + " i--;\r\n }\r\n }\r\n }\r\n " +
"\n }\r\n }\r\n function findUnsortedArrayTopInde" + " function findUnsortedArrayTopIndex(items) {\r\n // Only one Item\r\n" +
"x(items) {\r\n // Only one Item\r\n if (items.length <" + " if (items.length <= 1)\r\n return 0;\r\n\r\n " +
"= 1)\r\n return 0;\r\n\r\n for (var i = 1; i < items" + " for (var i = 1; i < items.length; i++) {\r\n var s = s" +
".length; i++) {\r\n var s = sortFunction(items[i - 1], items[i]" + "ortFunction(items[i - 1], items[i]);\r\n if (s > 0)\r\n " +
");\r\n if (s > 0)\r\n return i;\r\n " + " return i;\r\n }\r\n\r\n return 0;\r\n " +
" }\r\n\r\n return 0;\r\n }\r\n function findS" + " }\r\n function findSortedInsertIndex(koArray, heldDeviceItem) {\r\n " +
"ortedInsertIndex(koArray, heldDeviceItem) {\r\n var items = koArray" + " var items = koArray();\r\n var startIndex = findUnso" +
"();\r\n var startIndex = findUnsortedArrayTopIndex(items);\r\n " + "rtedArrayTopIndex(items);\r\n for (var i = startIndex; i < items.le" +
" for (var i = startIndex; i < items.length; i++) {\r\n " + "ngth; i++) {\r\n var s = sortFunction(heldDeviceItem, items[i])" +
"var s = sortFunction(heldDeviceItem, items[i]);\r\n if (s <= 0)" + ";\r\n if (s <= 0)\r\n return i;\r\n " +
"\r\n return i;\r\n }\r\n if (star" + " }\r\n if (startIndex !== 0) {\r\n for (var " +
"tIndex !== 0) {\r\n for (var i = 0; i < startIndex; i++) {\r\n " + "i = 0; i < startIndex; i++) {\r\n var s = sortFunction(held" +
" var s = sortFunction(heldDeviceItem, items[i]);\r\n " + "DeviceItem, items[i]);\r\n if (s <= 0)\r\n " +
" if (s <= 0)\r\n return i;\r\n " + " return i;\r\n }\r\n return startIndex" +
" }\r\n return startIndex;\r\n } else {\r\n " + ";\r\n } else {\r\n return -1;\r\n }\r\n" +
" return -1;\r\n }\r\n }\r\n functio" + " }\r\n function sortFunction(l, r) {\r\n return" +
"n sortFunction(l, r) {\r\n return l.DeviceDescription.toLowerCase()" + " l.DeviceDescription.toLowerCase() == r.DeviceDescription.toLowerCase() ? 0 : (l" +
" == r.DeviceDescription.toLowerCase() ? 0 : (l.DeviceDescription.toLowerCase() <" + ".DeviceDescription.toLowerCase() < r.DeviceDescription.toLowerCase() ? -1 : 1)\r\n" +
" r.DeviceDescription.toLowerCase() ? -1 : 1)\r\n }\r\n functio" + " }\r\n function isInProcess(i) {\r\n return !i." +
"n isInProcess(i) {\r\n return !i.ReadyForReturn && !i.WaitingForUse" + "ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n function " +
"rAction;\r\n }\r\n function isReadyForReturn(i) {\r\n " + "isReadyForReturn(i) {\r\n return i.ReadyForReturn && !i.WaitingForU" +
" return i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n " + "serAction;\r\n }\r\n function isWaitingForUserAction(i) {\r\n " +
" function isWaitingForUserAction(i) {\r\n return i.WaitingForUs" + " return i.WaitingForUserAction;\r\n }\r\n function" +
"erAction;\r\n }\r\n function getQueryStringParameters() {\r\n\r\n " + " getQueryStringParameters() {\r\n\r\n if (window.location.search.leng" +
" if (window.location.search.length === 0)\r\n ret" + "th === 0)\r\n return null;\r\n\r\n var params = {};\r" +
"urn null;\r\n\r\n var params = {};\r\n window.location.s" + "\n window.location.search.substr(1).split(\"&\").forEach(function (p" +
"earch.substr(1).split(\"&\").forEach(function (pair) {\r\n if (pa" + "air) {\r\n if (pair === \"\") return;\r\n var pa" +
"ir === \"\") return;\r\n var parts = pair.split(\"=\");\r\n " + "rts = pair.split(\"=\");\r\n params[parts[0]] = parts[1] && decod" +
" params[parts[0]] = parts[1] && decodeURIComponent(parts[1].replace(/\\+" + "eURIComponent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n " +
"/g, \" \"));\r\n });\r\n return params;\r\n }\r\n" + " return params;\r\n }\r\n\r\n init();\r\n });\r\n </scri" +
"\r\n init();\r\n });\r\n </script>\r\n</body>\r\n</html>"); "pt>\r\n</body>\r\n</html>");
} }
} }
@@ -131,9 +131,10 @@
hub.client.setTheme = setTheme; hub.client.setTheme = setTheme;
$.connection.hub.qs = { Noticeboard: '@(Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.Name)' }; $.connection.hub.qs = { Noticeboard: '@(Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.Name)' };
$.connection.hub.error(connectionError); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(connectionError); $.connection.hub.disconnected(connectionError);
$.connection.hub.reconnected(connectionError);
// Start Connection // Start Connection
$.connection.hub.start().fail(connectionError).done(loadData); $.connection.hub.start().fail(connectionError).done(loadData);
@@ -356,7 +357,6 @@
function connectionError() { function connectionError() {
try { try {
$('body').addClass('status-error'); $('body').addClass('status-error');
$.connection.hub.stop();
} catch (e) { } catch (e) {
// Ignore // Ignore
} }
@@ -257,9 +257,10 @@ WriteLiteral(">\r\n <li data-bind=\"css: { alert: IsAlert }\">\r\n
#line default #line default
#line hidden #line hidden
WriteLiteral(@"' }; WriteLiteral(@"' };
$.connection.hub.error(connectionError); $.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(connectionError); $.connection.hub.disconnected(connectionError);
$.connection.hub.reconnected(connectionError);
// Start Connection // Start Connection
$.connection.hub.start().fail(connectionError).done(loadData); $.connection.hub.start().fail(connectionError).done(loadData);
@@ -270,7 +271,7 @@ WriteLiteral(@"' };
$.getJSON('"); $.getJSON('");
#line 144 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml" #line 145 "..\..\Areas\Public\Views\UserHeldDevices\Noticeboard.cshtml"
Write(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevices())); Write(Url.Action(MVC.Public.UserHeldDevices.UserHeldDevices()));
@@ -399,54 +400,53 @@ WriteLiteral("\', null, function (data) {\r\n\r\n var inProce
"lters.length > 0)\r\n itemFilters = filters;\r\n " + "lters.length > 0)\r\n itemFilters = filters;\r\n " +
" else\r\n itemFilters = null;\r\n }\r\n " + " else\r\n itemFilters = null;\r\n }\r\n " +
" }\r\n\r\n function connectionError() {\r\n try {\r\n " + " }\r\n\r\n function connectionError() {\r\n try {\r\n " +
" $(\'body\').addClass(\'status-error\');\r\n $.co" + " $(\'body\').addClass(\'status-error\');\r\n } catch " +
"nnection.hub.stop();\r\n } catch (e) {\r\n // Igno" + "(e) {\r\n // Ignore\r\n }\r\n\r\n windo" +
"re\r\n }\r\n\r\n window.setTimeout(function () {\r\n " + "w.setTimeout(function () {\r\n window.location.reload(true);\r\n " +
" window.location.reload(true);\r\n }, 10000);\r\n " + " }, 10000);\r\n }\r\n\r\n // Helpers\r\n " +
" }\r\n\r\n // Helpers\r\n function rotateArray(koArray, elem" + "function rotateArray(koArray, element) {\r\n var items = koArray();" +
"ent) {\r\n var items = koArray();\r\n\r\n if (items.leng" + "\r\n\r\n if (items.length <= 1)\r\n return 0;\r\n\r\n " +
"th <= 1)\r\n return 0;\r\n\r\n if (element.height() " + " if (element.height() < (element.parent().height() - 30)) {\r\n\r\n " +
"< (element.parent().height() - 30)) {\r\n\r\n if (findUnsortedArr" + " if (findUnsortedArrayTopIndex(items) !== 0)\r\n " +
"ayTopIndex(items) !== 0)\r\n koArray.sort(sortFunction);\r\n\r" + " koArray.sort(sortFunction);\r\n\r\n // Don\'t rotate if small " +
"\n // Don\'t rotate if small & sorted correctly\r\n " + "& sorted correctly\r\n return;\r\n }\r\n\r\n " +
" return;\r\n }\r\n\r\n // Move Last Item to Top\r\n " + " // Move Last Item to Top\r\n var item = koArray.pop();\r\n " +
" var item = koArray.pop();\r\n koArray.unshift(item);\r" + " koArray.unshift(item);\r\n }\r\n function removeIte" +
"\n }\r\n function removeItemFromArray(koArray, UserId) {\r\n " + "mFromArray(koArray, UserId) {\r\n var items = koArray();\r\n " +
" var items = koArray();\r\n for (var i = 0; i < items.l" + " for (var i = 0; i < items.length; i++) {\r\n if (items[i" +
"ength; i++) {\r\n if (items[i].UserId == UserId) {\r\n " + "].UserId == UserId) {\r\n koArray.splice(i, 1);\r\n " +
" koArray.splice(i, 1);\r\n items = koArray();\r\n" + " items = koArray();\r\n i--;\r\n " +
" i--;\r\n }\r\n }\r\n " + " }\r\n }\r\n }\r\n function findUnsortedArrayT" +
" }\r\n function findUnsortedArrayTopIndex(items) {\r\n " + "opIndex(items) {\r\n // Only one Item\r\n if (items.le" +
"// Only one Item\r\n if (items.length <= 1)\r\n re" + "ngth <= 1)\r\n return 0;\r\n\r\n for (var i = 1; i <" +
"turn 0;\r\n\r\n for (var i = 1; i < items.length; i++) {\r\n " + " items.length; i++) {\r\n var s = sortFunction(items[i - 1], it" +
" var s = sortFunction(items[i - 1], items[i]);\r\n if (" + "ems[i]);\r\n if (s > 0)\r\n return i;\r\n " +
"s > 0)\r\n return i;\r\n }\r\n\r\n " + " }\r\n\r\n return 0;\r\n }\r\n function" +
"return 0;\r\n }\r\n function findSortedInsertIndex(koArray, he" + " findSortedInsertIndex(koArray, heldDeviceItem) {\r\n var items = k" +
"ldDeviceItem) {\r\n var items = koArray();\r\n var sta" + "oArray();\r\n var startIndex = findUnsortedArrayTopIndex(items);\r\n " +
"rtIndex = findUnsortedArrayTopIndex(items);\r\n for (var i = startI" + " for (var i = startIndex; i < items.length; i++) {\r\n " +
"ndex; i < items.length; i++) {\r\n var s = sortFunction(heldDev" + " var s = sortFunction(heldDeviceItem, items[i]);\r\n if (s" +
"iceItem, items[i]);\r\n if (s <= 0)\r\n re" + " <= 0)\r\n return i;\r\n }\r\n if" +
"turn i;\r\n }\r\n if (startIndex !== 0) {\r\n " + " (startIndex !== 0) {\r\n for (var i = 0; i < startIndex; i++) " +
" for (var i = 0; i < startIndex; i++) {\r\n var s =" + "{\r\n var s = sortFunction(heldDeviceItem, items[i]);\r\n " +
" sortFunction(heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " + " if (s <= 0)\r\n return i;\r\n " +
" return i;\r\n }\r\n " + " }\r\n return startIndex;\r\n } else {\r" +
" return startIndex;\r\n } else {\r\n return -1;\r\n " + "\n return -1;\r\n }\r\n }\r\n f" +
" }\r\n }\r\n function sortFunction(l, r) {\r\n " + "unction sortFunction(l, r) {\r\n return l.UserIdFriendly.toLowerCas" +
" return l.UserIdFriendly.toLowerCase() == r.UserIdFriendly.toLowerCas" + "e() == r.UserIdFriendly.toLowerCase() ? 0 : (l.UserIdFriendly.toLowerCase() < r." +
"e() ? 0 : (l.UserIdFriendly.toLowerCase() < r.UserIdFriendly.toLowerCase() ? -1 " + "UserIdFriendly.toLowerCase() ? -1 : 1)\r\n }\r\n function isIn" +
": 1)\r\n }\r\n function isInProcess(i) {\r\n retu" + "Process(i) {\r\n return !i.ReadyForReturn && !i.WaitingForUserActio" +
"rn !i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n fun" + "n;\r\n }\r\n function isReadyForReturn(i) {\r\n r" +
"ction isReadyForReturn(i) {\r\n return i.ReadyForReturn && !i.Waiti" + "eturn i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n f" +
"ngForUserAction;\r\n }\r\n function isWaitingForUserAction(i) " + "unction isWaitingForUserAction(i) {\r\n return i.WaitingForUserActi" +
"{\r\n return i.WaitingForUserAction;\r\n }\r\n fu" + "on;\r\n }\r\n function getQueryStringParameters() {\r\n\r\n " +
"nction getQueryStringParameters() {\r\n\r\n if (window.location.searc" + " if (window.location.search.length === 0)\r\n return nu" +
"h.length === 0)\r\n return null;\r\n\r\n var params " + "ll;\r\n\r\n var params = {};\r\n window.location.search." +
"= {};\r\n window.location.search.substr(1).split(\"&\").forEach(funct" + "substr(1).split(\"&\").forEach(function (pair) {\r\n if (pair ===" +
"ion (pair) {\r\n if (pair === \"\") return;\r\n " + " \"\") return;\r\n var parts = pair.split(\"=\");\r\n " +
"var parts = pair.split(\"=\");\r\n params[parts[0]] = parts[1] &&" + " params[parts[0]] = parts[1] && decodeURIComponent(parts[1].replace(/\\+/g, \" " +
" decodeURIComponent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n " + "\"));\r\n });\r\n return params;\r\n }\r\n\r\n " +
" return params;\r\n }\r\n\r\n init();\r\n });\r\n " + " init();\r\n });\r\n </script>\r\n</body>\r\n</html>\r\n");
"</script>\r\n</body>\r\n</html>\r\n");
} }
} }
+19 -19
View File
@@ -147,25 +147,10 @@
hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRemoved; hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRemoved;
$.connection.hub.qs = { DeviceSerialNumber: deviceSerialNumber }; $.connection.hub.qs = { DeviceSerialNumber: deviceSerialNumber };
$.connection.hub.error(onHubFailed); $.connection.hub.error(function (error) {
$.connection.hub.disconnected(onHubFailed); console.log('Server connection error: ' + error);
$.connection.hub.reconnecting(function () {
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
$('#Comments').find('button').prop('disabled', true);
}); });
$.connection.hub.reconnected(function () { $.connection.hub.disconnected(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
});
// Start Connection
$.connection.hub.start(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
}).fail(onHubFailed);
function onHubFailed(error) {
// Disable UI // Disable UI
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled'); $('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
$('#Comments').find('button').prop('disabled', true); $('#Comments').find('button').prop('disabled', true);
@@ -191,7 +176,22 @@
} }
}); });
} }
} });
$.connection.hub.reconnecting(function () {
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
$('#Comments').find('button').prop('disabled', true);
});
$.connection.hub.reconnected(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
});
// Start Connection
$.connection.hub.start(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
});
}); });
</script> </script>
} }
+34 -33
View File
@@ -514,39 +514,40 @@ WriteLiteral(" <script>\r\n $(function () {\r\n
"d;\r\n if (document.DiscoFunctions.onAttachmentRemoved)\r\n " + "d;\r\n if (document.DiscoFunctions.onAttachmentRemoved)\r\n " +
" hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRem" + " hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRem" +
"oved;\r\n\r\n $.connection.hub.qs = { DeviceSerialNumber: deviceSeria" + "oved;\r\n\r\n $.connection.hub.qs = { DeviceSerialNumber: deviceSeria" +
"lNumber };\r\n $.connection.hub.error(onHubFailed);\r\n " + "lNumber };\r\n $.connection.hub.error(function (error) {\r\n " +
" $.connection.hub.disconnected(onHubFailed);\r\n\r\n $.connection.hu" + " console.log(\'Server connection error: \' + error);\r\n })" +
"b.reconnecting(function () {\r\n $(\'#AttachmentsContainer\').fin" + ";\r\n $.connection.hub.disconnected(function () {\r\n " +
"d(\'span.action.enabled\').addClass(\'disabled\');\r\n $(\'#Comments" + " // Disable UI\r\n $(\'#AttachmentsContainer\').find(\'span.act" +
"\').find(\'button\').prop(\'disabled\', true);\r\n });\r\n " + "ion.enabled\').addClass(\'disabled\');\r\n $(\'#Comments\').find(\'bu" +
"$.connection.hub.reconnected(function () {\r\n $(\'#AttachmentsC" + "tton\').prop(\'disabled\', true);\r\n\r\n // Show Dialog Message\r\n " +
"ontainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " + " if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
" $(\'#Comments\').find(\'button\').prop(\'disabled\', false);\r\n });" + " $(\'<div>\')\r\n .addClass(\'dialog disconnected-d" +
"\r\n\r\n // Start Connection\r\n $.connection.hub.start(" + "ialog\')\r\n .html(\'<h3><span class=\"fa-stack fa-lg\"><i " +
"function () {\r\n $(\'#AttachmentsContainer\').find(\'span.action." + "class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></" +
"enabled\').removeClass(\'disabled\');\r\n $(\'#Comments\').find(\'but" + "span>Disconnected from the Disco ICT Server</h3><div>This page is not receiving " +
"ton\').prop(\'disabled\', false);\r\n }).fail(onHubFailed);\r\n\r\n " + "live updates. Please ensure you are connected to the server, then refresh this p" +
" function onHubFailed(error) {\r\n // Disable UI\r\n " + "age to enable features.</div>\')\r\n .dialog({\r\n " +
" $(\'#AttachmentsContainer\').find(\'span.action.enabled\').addClass(\'" + " resizable: false,\r\n title" +
"disabled\');\r\n $(\'#Comments\').find(\'button\').prop(\'disabled\', " + ": \'Disconnected\',\r\n width: 400,\r\n " +
"true);\r\n\r\n // Show Dialog Message\r\n if ($(" + " modal: true,\r\n buttons: {\r\n " +
"\'.disconnected-dialog\').length == 0) {\r\n $(\'<div>\')\r\n " + " \'Refresh Now\': function () {\r\n " +
" .addClass(\'dialog disconnected-dialog\')\r\n " + " $(this).dialog(\'option\', \'buttons\', null);\r\n " +
" .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-sta" + " window.location.reload(true);\r\n " +
"ck-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>Disconnected from t" + " },\r\n \'Close\': function () {\r\n " +
"he Disco ICT Server</h3><div>This page is not receiving live updates. Please ens" + " $(this).dialog(\'destroy\');\r\n " +
"ure you are connected to the server, then refresh this page to enable features.<" + " }\r\n }\r\n " +
"/div>\')\r\n .dialog({\r\n " + " });\r\n }\r\n });\r\n\r\n $.connec" +
"resizable: false,\r\n title: \'Disconnected\',\r\n " + "tion.hub.reconnecting(function () {\r\n $(\'#AttachmentsContaine" +
" width: 400,\r\n modal: t" + "r\').find(\'span.action.enabled\').addClass(\'disabled\');\r\n $(\'#C" +
"rue,\r\n buttons: {\r\n " + "omments\').find(\'button\').prop(\'disabled\', true);\r\n });\r\n " +
" \'Refresh Now\': function () {\r\n $(th" + " $.connection.hub.reconnected(function () {\r\n $(\'#Attac" +
"is).dialog(\'option\', \'buttons\', null);\r\n " + "hmentsContainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " +
"window.location.reload(true);\r\n },\r\n " + " $(\'#Comments\').find(\'button\').prop(\'disabled\', false);\r\n " +
" \'Close\': function () {\r\n " + " });\r\n\r\n // Start Connection\r\n $.connection.hub" +
" $(this).dialog(\'destroy\');\r\n }\r\n " + ".start(function () {\r\n $(\'#AttachmentsContainer\').find(\'span." +
" }\r\n });\r\n " + "action.enabled\').removeClass(\'disabled\');\r\n $(\'#Comments\').fi" +
" }\r\n }\r\n });\r\n </script>\r\n"); "nd(\'button\').prop(\'disabled\', false);\r\n });\r\n });\r\n " +
" </script>\r\n");
#line 197 "..\..\Views\Device\Show.cshtml" #line 197 "..\..\Views\Device\Show.cshtml"
+11 -12
View File
@@ -567,9 +567,6 @@
</text>} </text>}
$.connection.hub.qs = { JobId: jobId }; $.connection.hub.qs = { JobId: jobId };
$.connection.hub.error(onHubFailed);
$.connection.hub.disconnected(onHubFailed);
$.connection.hub.reconnecting(function () { $.connection.hub.reconnecting(function () {
$('#CommentsContainer').find('span.action').addClass('disabled'); $('#CommentsContainer').find('span.action').addClass('disabled');
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled'); $('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
@@ -578,14 +575,10 @@
$('#CommentsContainer').find('span.action').removeClass('disabled'); $('#CommentsContainer').find('span.action').removeClass('disabled');
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled'); $('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
}); });
$.connection.hub.error(function (error) {
// Start Connection console.log('Server connection error: ' + error);
$.connection.hub.start(function () { });
$('#CommentsContainer').find('span.action').removeClass('disabled'); $.connection.hub.disconnected(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
}).fail(onHubFailed);
function onHubFailed(error) {
// Disable UI // Disable UI
$('#CommentsContainer').find('textarea.commentInput').attr('readonly', 'readonly'); $('#CommentsContainer').find('textarea.commentInput').attr('readonly', 'readonly');
$('#CommentsContainer').find('span.action').addClass('disabled'); $('#CommentsContainer').find('span.action').addClass('disabled');
@@ -612,7 +605,13 @@
} }
}); });
} }
} });
// Start Connection
$.connection.hub.start(function () {
$('#CommentsContainer').find('span.action').removeClass('disabled');
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
});
//#endregion //#endregion
}); });
@@ -1337,42 +1337,42 @@ WriteLiteral(@"
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n $.connection.hub.qs = { JobId: jobId };\r\n $.connection.h" + WriteLiteral("\r\n $.connection.hub.qs = { JobId: jobId };\r\n $.connection.h" +
"ub.error(onHubFailed);\r\n $.connection.hub.disconnected(onHubFailed);\r" + "ub.reconnecting(function () {\r\n $(\'#CommentsContainer\').find(\'spa" +
"\n\r\n $.connection.hub.reconnecting(function () {\r\n $(\'#" + "n.action\').addClass(\'disabled\');\r\n $(\'#AttachmentsContainer\').fin" +
"CommentsContainer\').find(\'span.action\').addClass(\'disabled\');\r\n $" + "d(\'span.action.enabled\').addClass(\'disabled\');\r\n });\r\n $.c" +
"(\'#AttachmentsContainer\').find(\'span.action.enabled\').addClass(\'disabled\');\r\n " + "onnection.hub.reconnected(function () {\r\n $(\'#CommentsContainer\')" +
" });\r\n $.connection.hub.reconnected(function () {\r\n " + ".find(\'span.action\').removeClass(\'disabled\');\r\n $(\'#AttachmentsCo" +
" $(\'#CommentsContainer\').find(\'span.action\').removeClass(\'disabled\');\r\n " + "ntainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n });\r" +
" $(\'#AttachmentsContainer\').find(\'span.action.enabled\').removeClass(\'" + "\n $.connection.hub.error(function (error) {\r\n console." +
"disabled\');\r\n });\r\n\r\n // Start Connection\r\n $.c" + "log(\'Server connection error: \' + error);\r\n });\r\n $.connec" +
"onnection.hub.start(function () {\r\n $(\'#CommentsContainer\').find(" + "tion.hub.disconnected(function () {\r\n // Disable UI\r\n " +
"\'span.action\').removeClass(\'disabled\');\r\n $(\'#AttachmentsContaine" + " $(\'#CommentsContainer\').find(\'textarea.commentInput\').attr(\'readonly\', \'read" +
"r\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n }).fail(on" + "only\');\r\n $(\'#CommentsContainer\').find(\'span.action\').addClass(\'d" +
"HubFailed);\r\n\r\n function onHubFailed(error) {\r\n // Dis" + "isabled\');\r\n $(\'#AttachmentsContainer\').find(\'span.action.enabled" +
"able UI\r\n $(\'#CommentsContainer\').find(\'textarea.commentInput\').a" + "\').addClass(\'disabled\');\r\n\r\n // Show Dialog Message\r\n " +
"ttr(\'readonly\', \'readonly\');\r\n $(\'#CommentsContainer\').find(\'span" + " if ($(\'.disconnected-dialog\').length == 0) {\r\n $(\'<div>\')" +
".action\').addClass(\'disabled\');\r\n $(\'#AttachmentsContainer\').find" + "\r\n .addClass(\'dialog disconnected-dialog\')\r\n " +
"(\'span.action.enabled\').addClass(\'disabled\');\r\n\r\n // Show Dialog " + " .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-stack" +
"Message\r\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " + "-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>Disconnected from the" +
" $(\'<div>\')\r\n .addClass(\'dialog disconnected-di" + " Disco ICT Server</h3><div>This page is not receiving live updates. Please ensur" +
"alog\')\r\n .html(\'<h3><span class=\"fa-stack fa-lg\"><i class" + "e you are connected to the server, then refresh this page to enable features.</d" +
"=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>" + "iv>\')\r\n .dialog({\r\n resizable:" +
"Disconnected from the Disco ICT Server</h3><div>This page is not receiving live " + " false,\r\n title: \'Disconnected\',\r\n " +
"updates. Please ensure you are connected to the server, then refresh this page t" + " width: 400,\r\n modal: true,\r\n " +
"o enable features.</div>\')\r\n .dialog({\r\n " + " buttons: {\r\n \'Refresh Now\': function " +
" resizable: false,\r\n title: \'Disconnected\'," + "() {\r\n $(this).dialog(\'option\', \'buttons\', nu" +
"\r\n width: 400,\r\n modal: tr" + "ll);\r\n window.location.reload(true);\r\n " +
"ue,\r\n buttons: {\r\n \'Re" + " },\r\n \'Close\': function (" +
"fresh Now\': function () {\r\n $(this).dialog(\'o" + ") {\r\n $(this).dialog(\'destroy\');\r\n " +
"ption\', \'buttons\', null);\r\n window.location.r" + " }\r\n }\r\n }" +
"eload(true);\r\n },\r\n " + ");\r\n }\r\n });\r\n\r\n // Start Connection\r\n " +
" \'Close\': function () {\r\n $(this).dialog(\'de" + " $.connection.hub.start(function () {\r\n $(\'#CommentsContain" +
"stroy\');\r\n }\r\n }\r\n " + "er\').find(\'span.action\').removeClass(\'disabled\');\r\n $(\'#Attachmen" +
" });\r\n }\r\n }\r\n\r\n //#endr" + "tsContainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " +
"egion\r\n });\r\n </script>\r\n"); "});\r\n\r\n //#endregion\r\n });\r\n </script>\r\n");
#line 620 "..\..\Views\Job\JobParts\Resources.cshtml" #line 619 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
+19 -19
View File
@@ -137,25 +137,10 @@
hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRemoved; hub.client.attachmentRemoved = document.DiscoFunctions.onAttachmentRemoved;
$.connection.hub.qs = { UserId: userId }; $.connection.hub.qs = { UserId: userId };
$.connection.hub.error(onHubFailed); $.connection.hub.error(function (error) {
$.connection.hub.disconnected(onHubFailed); console.log('Server connection error: ' + error);
$.connection.hub.reconnecting(function () {
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
$('#Comments').find('button').prop('disabled', true);
}); });
$.connection.hub.reconnected(function () { $.connection.hub.disconnected(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
});
// Start Connection
$.connection.hub.start(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
}).fail(onHubFailed);
function onHubFailed(error) {
// Disable UI // Disable UI
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled'); $('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
$('#Comments').find('button').prop('disabled', true); $('#Comments').find('button').prop('disabled', true);
@@ -181,7 +166,22 @@
} }
}); });
} }
} });
$.connection.hub.reconnecting(function () {
$('#AttachmentsContainer').find('span.action.enabled').addClass('disabled');
$('#Comments').find('button').prop('disabled', true);
});
$.connection.hub.reconnected(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
});
// Start Connection
$.connection.hub.start(function () {
$('#AttachmentsContainer').find('span.action.enabled').removeClass('disabled');
$('#Comments').find('button').prop('disabled', false);
});
}); });
</script> </script>
} }
+34 -34
View File
@@ -456,40 +456,40 @@ WriteLiteral(" <script>\r\n $(function () {\r\n
"mentAdded = document.DiscoFunctions.onAttachmentAdded;\r\n if (docu" + "mentAdded = document.DiscoFunctions.onAttachmentAdded;\r\n if (docu" +
"ment.DiscoFunctions.onAttachmentRemoved)\r\n hub.client.attachm" + "ment.DiscoFunctions.onAttachmentRemoved)\r\n hub.client.attachm" +
"entRemoved = document.DiscoFunctions.onAttachmentRemoved;\r\n\r\n $.c" + "entRemoved = document.DiscoFunctions.onAttachmentRemoved;\r\n\r\n $.c" +
"onnection.hub.qs = { UserId: userId };\r\n $.connection.hub.error(o" + "onnection.hub.qs = { UserId: userId };\r\n $.connection.hub.error(f" +
"nHubFailed);\r\n $.connection.hub.disconnected(onHubFailed);\r\n\r\n " + "unction (error) {\r\n console.log(\'Server connection error: \' +" +
" $.connection.hub.reconnecting(function () {\r\n $(" + " error);\r\n });\r\n $.connection.hub.disconnected(fun" +
"\'#AttachmentsContainer\').find(\'span.action.enabled\').addClass(\'disabled\');\r\n " + "ction () {\r\n // Disable UI\r\n $(\'#Attachmen" +
" $(\'#Comments\').find(\'button\').prop(\'disabled\', true);\r\n " + "tsContainer\').find(\'span.action.enabled\').addClass(\'disabled\');\r\n " +
" });\r\n $.connection.hub.reconnected(function () {\r\n " + " $(\'#Comments\').find(\'button\').prop(\'disabled\', true);\r\n\r\n " +
" $(\'#AttachmentsContainer\').find(\'span.action.enabled\').removeClass(\'" + " // Show Dialog Message\r\n if ($(\'.disconnected-dialog\').leng" +
"disabled\');\r\n $(\'#Comments\').find(\'button\').prop(\'disabled\', " + "th == 0) {\r\n $(\'<div>\')\r\n .add" +
"false);\r\n });\r\n\r\n // Start Connection\r\n " + "Class(\'dialog disconnected-dialog\')\r\n .html(\'<h3><spa" +
" $.connection.hub.start(function () {\r\n $(\'#AttachmentsCo" + "n class=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-b" +
"ntainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " + "an fa-stack-2x error\"></i></span>Disconnected from the Disco ICT Server</h3><div" +
" $(\'#Comments\').find(\'button\').prop(\'disabled\', false);\r\n }).f" + ">This page is not receiving live updates. Please ensure you are connected to the" +
"ail(onHubFailed);\r\n\r\n function onHubFailed(error) {\r\n " + " server, then refresh this page to enable features.</div>\')\r\n " +
" // Disable UI\r\n $(\'#AttachmentsContainer\').find(\'span" + " .dialog({\r\n resizable: false,\r\n " +
".action.enabled\').addClass(\'disabled\');\r\n $(\'#Comments\').find" + " title: \'Disconnected\',\r\n w" +
"(\'button\').prop(\'disabled\', true);\r\n\r\n // Show Dialog Message" + "idth: 400,\r\n modal: true,\r\n " +
"\r\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " + " buttons: {\r\n \'Refresh Now\': functio" +
" $(\'<div>\')\r\n .addClass(\'dialog disconnect" + "n () {\r\n $(this).dialog(\'option\', \'button" +
"ed-dialog\')\r\n .html(\'<h3><span class=\"fa-stack fa-lg\"" + "s\', null);\r\n window.location.reload(true)" +
"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></" + ";\r\n },\r\n \'" +
"i></span>Disconnected from the Disco ICT Server</h3><div>This page is not receiv" + "Close\': function () {\r\n $(this).dialog(\'d" +
"ing live updates. Please ensure you are connected to the server, then refresh th" + "estroy\');\r\n }\r\n " +
"is page to enable features.</div>\')\r\n .dialog({\r\n " + " }\r\n });\r\n }\r\n });" +
" resizable: false,\r\n t" + "\r\n\r\n $.connection.hub.reconnecting(function () {\r\n " +
"itle: \'Disconnected\',\r\n width: 400,\r\n " + " $(\'#AttachmentsContainer\').find(\'span.action.enabled\').addClass(\'disabled\')" +
" modal: true,\r\n buttons: {\r\n " + ";\r\n $(\'#Comments\').find(\'button\').prop(\'disabled\', true);\r\n " +
" \'Refresh Now\': function () {\r\n " + " });\r\n $.connection.hub.reconnected(function () {\r\n " +
" $(this).dialog(\'option\', \'buttons\', null);\r\n " + " $(\'#AttachmentsContainer\').find(\'span.action.enabled\').remove" +
" window.location.reload(true);\r\n " + "Class(\'disabled\');\r\n $(\'#Comments\').find(\'button\').prop(\'disa" +
" },\r\n \'Close\': function () {\r\n " + "bled\', false);\r\n });\r\n\r\n // Start Connection\r\n " +
" $(this).dialog(\'destroy\');\r\n " + " $.connection.hub.start(function () {\r\n $(\'#Attach" +
" }\r\n }\r\n " + "mentsContainer\').find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " +
" });\r\n }\r\n }\r\n });\r\n " + " $(\'#Comments\').find(\'button\').prop(\'disabled\', false);\r\n " +
" </script>\r\n"); " });\r\n });\r\n </script>\r\n");
#line 187 "..\..\Views\User\Show.cshtml" #line 187 "..\..\Views\User\Show.cshtml"