#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;
$.connection.hub.qs = { DeviceBatchId: '@(Model.DeviceBatch.Id)' };
$.connection.hub.error(onHubFailed);
$.connection.hub.disconnected(onHubFailed);
$.connection.hub.reconnecting(function () {
$Attachments.find('span.action.enabled').addClass('disabled');
@@ -756,13 +754,10 @@
$.connection.hub.reconnected(function () {
$Attachments.find('span.action.enabled').removeClass('disabled');
});
// Start Connection
$.connection.hub.start(function () {
$Attachments.find('span.action.enabled').removeClass('disabled');
}).fail(onHubFailed);
function onHubFailed(error) {
$.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(function () {
// Disable UI
$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) {
var data = { id: id };
@@ -2383,42 +2383,43 @@ WriteLiteral(@">
#line default
#line hidden
WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n " +
" $.connection.hub.disconnected(onHubFailed);\r\n\r\n " +
" $.connection.hub.reconnecting(function () {\r\n " +
" $Attachments.find(\'span.action.enabled\').addClass(\'disabled\');\r\n " +
" });\r\n $.connection.hub.reconne" +
"cted(function () {\r\n $Attachments.find(\'span.acti" +
"on.enabled\').removeClass(\'disabled\');\r\n });\r\n\r\n " +
" // Start Connection\r\n $.connect" +
"ion.hub.start(function () {\r\n $Attachments.find(\'" +
"span.action.enabled\').removeClass(\'disabled\');\r\n }).f" +
"ail(onHubFailed);\r\n\r\n function onHubFailed(error) {\r\n" +
" // Disable UI\r\n $" +
"Attachments.find(\'span.action.enabled\').addClass(\'disabled\');\r\n\r\n " +
" // Show Dialog Message\r\n if ($(\'" +
".disconnected-dialog\').length == 0) {\r\n $(\'<d" +
"iv>\')\r\n .addClass(\'dialog disconnected-di" +
"alog\')\r\n .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 er" +
"ror\"></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 ref" +
"resh this page to enable features.</div>\')\r\n " +
" .dialog({\r\n resizable: false,\r\n " +
" title: \'Disconnected\',\r\n " +
" width: 400,\r\n " +
" modal: true,\r\n buttons: {\r\n " +
" \'Refresh Now\': function () {\r\n " +
" $(this).dialog(\'option\', \'buttons" +
"\', null);\r\n window.location.r" +
"eload(true);\r\n },\r\n " +
" \'Close\': function () {\r\n " +
" $(this).dialog(\'destroy\');\r\n " +
" }\r\n }\r\n " +
" });\r\n }\r\n " +
" }\r\n\r\n function onAddAttachmen" +
"t(id, quick) {\r\n var data = { id: id };\r\n " +
" $.ajax({\r\n url: \'");
WriteLiteral("\' };\r\n\r\n $.connection.hub.reconnecting(function () {\r\n" +
" $Attachments.find(\'span.action.enabled\').addClas" +
"s(\'disabled\');\r\n });\r\n $.c" +
"onnection.hub.reconnected(function () {\r\n $Attach" +
"ments.find(\'span.action.enabled\').removeClass(\'disabled\');\r\n " +
" });\r\n $.connection.hub.error(function (error)" +
" {\r\n console.log(\'Server connection error: \' + er" +
"ror);\r\n });\r\n $.connection" +
".hub.disconnected(function () {\r\n // Disable UI\r\n" +
" $Attachments.find(\'span.action.enabled\').addClas" +
"s(\'disabled\');\r\n\r\n // Show Dialog Message\r\n " +
" if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
" $(\'<div>\')\r\n " +
".addClass(\'dialog disconnected-dialog\')\r\n " +
" .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>\')\r\n " +
" .dialog({\r\n " +
" resizable: false,\r\n title" +
": \'Disconnected\',\r\n width: 400,\r\n " +
" modal: true,\r\n " +
" buttons: {\r\n \'R" +
"efresh Now\': function () {\r\n " +
"$(this).dialog(\'option\', \'buttons\', null);\r\n " +
" window.location.reload(true);\r\n " +
" },\r\n \'Close\': func" +
"tion () {\r\n $(this).dialog(\'d" +
"estroy\');\r\n }\r\n " +
" }\r\n });\r\n " +
" }\r\n });\r\n\r\n " +
" // Start Connection\r\n $.connection.hub.st" +
"art(function () {\r\n $Attachments.find(\'span.actio" +
"n.enabled\').removeClass(\'disabled\');\r\n });\r\n\r\n " +
" function onAddAttachment(id, quick) {\r\n " +
" var data = { id: id };\r\n $.ajax({\r\n " +
" url: \'");
#line 795 "..\..\Areas\Config\Views\DeviceBatch\Show.cshtml"
@@ -2908,27 +2909,27 @@ WriteLiteral(" <li>\r\n
WriteLiteral(" type=\"radio\"");
WriteAttribute("id", Tuple.Create(" id=\"", 56824), Tuple.Create("\"", 56894)
, Tuple.Create(Tuple.Create("", 56829), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 56829), true)
WriteAttribute("id", Tuple.Create(" id=\"", 56868), Tuple.Create("\"", 56938)
, Tuple.Create(Tuple.Create("", 56873), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 56873), true)
#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 hidden
, 56868), false)
, 56912), false)
);
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"
, 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 hidden
, 56969), false)
, 57013), false)
);
WriteLiteral(" ");
@@ -2942,15 +2943,15 @@ WriteLiteral(" ");
#line hidden
WriteLiteral(" />\r\n <label");
WriteAttribute("for", Tuple.Create(" for=\"", 57135), Tuple.Create("\"", 57206)
, Tuple.Create(Tuple.Create("", 57141), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 57141), true)
WriteAttribute("for", Tuple.Create(" for=\"", 57179), Tuple.Create("\"", 57250)
, Tuple.Create(Tuple.Create("", 57185), Tuple.Create("DeviceBatch_Decommission_Dialog_Reason_", 57185), true)
#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 hidden
, 57180), false)
, 57224), false)
);
WriteLiteral(">");
@@ -5,7 +5,8 @@
Html.BundleDeferred("~/ClientScripts/Modules/Knockout");
Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR");
}
<h2>Documents Imported Today
<h2>
Documents Imported Today
</h2>
<div id="importStatus">
@Html.AntiForgeryToken()
@@ -13,7 +14,7 @@
<h3>No imported documents today</h3>
</div>
<div id="sessions" data-bind="visible: !noSessions(), foreach: { data: sessions, afterRender: sessionRendered }"
style="display: none">
style="display: none">
<div class="session">
<div class="clearfix">
<div class="sessionLeftPane">
@@ -56,16 +57,18 @@
<table class="logEventsViewport">
<thead>
<tr>
<th class="icon">&nbsp;
<th class="icon">
&nbsp;
</th>
<th class="message">Message
<th class="message">
Message
</th>
</tr>
</thead>
</table>
<div class="logEventsViewportContainer">
<div class="logEventsViewportNoLogs" data-bind="visible: messages().length == 0"
style="display: none">
style="display: none">
No logs
</div>
<table class="logEventsViewport" data-bind="visible: messages().length > 0" style="display: none">
@@ -309,13 +312,10 @@
logHub.client.receiveLog = parseLog
$.connection.hub.qs = { LogModules: '@(Disco.Services.Documents.DocumentsLog.Current.LiveLogGroupName)' };
$.connection.hub.error(onHubFailed);
$.connection.hub.start()
.done(function () { isLive = true; })
.fail(onHubFailed);
function onHubFailed(error) {
$.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(function () {
// Show Dialog Message
if ($('.disconnected-dialog').length == 0) {
$('<div>')
@@ -337,7 +337,11 @@
}
});
}
}
});
$.connection.hub.start()
.done(function () { isLive = true; });
}
init();
});
@@ -55,7 +55,7 @@ namespace Disco.Web.Areas.Config.Views.DocumentTemplate
#line default
#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\"");
@@ -64,7 +64,7 @@ WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 11 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
#line 12 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Html.AntiForgeryToken());
@@ -83,7 +83,7 @@ WriteLiteral(" id=\"sessions\"");
WriteLiteral(" data-bind=\"visible: !noSessions(), foreach: { data: sessions, afterRender: sessi" +
"onRendered }\"");
WriteLiteral("\r\n style=\"display: none\"");
WriteLiteral("\r\n style=\"display: none\"");
WriteLiteral(">\r\n <div");
@@ -210,12 +210,14 @@ WriteLiteral(">\r\n <thead>\r\n <tr>\r
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(">Message\r\n </th>\r\n </tr>\r\n " +
" </thead>\r\n </table>\r\n <div");
WriteLiteral(">\r\n Message\r\n </th>\r\n " +
" </tr>\r\n </thead>\r\n </tab" +
"le>\r\n <div");
WriteLiteral(" class=\"logEventsViewportContainer\"");
@@ -225,7 +227,7 @@ WriteLiteral(" class=\"logEventsViewportNoLogs\"");
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 " +
" <table");
@@ -287,7 +289,7 @@ WriteLiteral(">\r\n $(function () {\r\n var vm;\r\n var host =
"var urlDeviceShow = \'");
#line 104 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
#line 107 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
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 = \'");
#line 105 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
#line 108 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.Job.Show()));
@@ -305,7 +307,7 @@ WriteLiteral("/\'\r\n var urlJobShow = \'");
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()));
@@ -314,7 +316,7 @@ WriteLiteral("/\'\r\n var urlUserShow = \'");
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()));
@@ -323,7 +325,7 @@ WriteLiteral("/\'\r\n var urlPageThumbnail = \'");
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()));
@@ -332,7 +334,7 @@ WriteLiteral("/\'\r\n var urlDocumentTemplate = \'");
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()));
@@ -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: \'");
#line 288 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
#line 291 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml"
Write(Url.Action(MVC.API.Logging.RetrieveEvents()));
@@ -476,32 +478,33 @@ WriteLiteral(@"',
$.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);
#line default
#line hidden
WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n\r\n $.connectio" +
"n.hub.start()\r\n .done(function () { isLive = true; })\r\n " +
" .fail(onHubFailed);\r\n\r\n function onHubFailed(error) {\r\n " +
" // Show Dialog Message\r\n if ($(\'.disconnected-dialog\').le" +
"ngth == 0) {\r\n $(\'<div>\')\r\n .addClass(" +
"\'dialog disconnected-dialog\')\r\n .html(\'<h3><span class=\"f" +
"a-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stac" +
"k-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, t" +
"hen refresh this page to enable features.</div>\')\r\n .dial" +
"og({\r\n resizable: false,\r\n " +
" title: \'Disconnected\',\r\n width: 400,\r\n " +
" modal: true,\r\n buttons: {\r\n " +
" \'Refresh Now\': function () {\r\n " +
" $(this).dialog(\'option\', \'buttons\', null);\r\n " +
" window.location.reload(true);\r\n },\r\n " +
" \'Close\': function () {\r\n " +
" $(this).dialog(\'destroy\');\r\n }\r\n " +
" }\r\n });\r\n }\r\n }" +
"\r\n }\r\n init();\r\n });\r\n</script>\r\n");
WriteLiteral("\' };\r\n $.connection.hub.error(function (error) {\r\n cons" +
"ole.log(\'Server connection error: \' + error);\r\n });\r\n $.co" +
"nnection.hub.disconnected(function () {\r\n // Show Dialog Message\r" +
"\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
" $(\'<div>\')\r\n .addClass(\'dialog disconnected-dialog\')\r\n" +
" .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>Disconne" +
"cted 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>\')\r\n .dialog({\r\n " +
" resizable: false,\r\n title: \'Disconnected\',\r\n " +
" width: 400,\r\n modal: true,\r\n " +
" buttons: {\r\n \'Refresh No" +
"w\': function () {\r\n $(this).dialog(\'option\', " +
"\'buttons\', null);\r\n window.location.reload(tr" +
"ue);\r\n },\r\n \'Close" +
"\': function () {\r\n $(this).dialog(\'destroy\');" +
"\r\n }\r\n }\r\n " +
" });\r\n }\r\n });\r\n\r\n $.connection." +
"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
$.connection.hub.qs = { LogModules: '@(Disco.Services.Devices.Enrolment.EnrolmentLog.Current.LiveLogGroupName)' };
$.connection.hub.error(onHubFailed);
$.connection.hub.start()
.done(function () { isLive = true; })
.fail(onHubFailed);
function onHubFailed(error) {
$.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(function (error) {
// Show Dialog Message
if ($('.disconnected-dialog').length == 0) {
$('<div>')
@@ -435,7 +432,11 @@
}
});
}
}
});
$.connection.hub.start()
.done(function () { isLive = true; });
}
$('#dialogSession').on('click', '#formResolveSessionPending button', function (e) {
const $button = $(this);
@@ -831,34 +831,35 @@ WriteLiteral(@"',
#line default
#line hidden
WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n\r\n $.connectio" +
"n.hub.start()\r\n .done(function () { isLive = true; })\r\n " +
" .fail(onHubFailed);\r\n\r\n function onHubFailed(error) {\r\n " +
" // Show Dialog Message\r\n if ($(\'.disconnected-dialog\').le" +
"ngth == 0) {\r\n $(\'<div>\')\r\n .addClass(" +
"\'dialog disconnected-dialog\')\r\n .html(\'<h3><span class=\"f" +
"a-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stac" +
"k-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, t" +
"hen refresh this page to enable features.</div>\')\r\n .dial" +
"og({\r\n resizable: false,\r\n " +
" title: \'Disconnected\',\r\n width: 400,\r\n " +
" modal: true,\r\n buttons: {\r\n " +
" \'Refresh Now\': function () {\r\n " +
" $(this).dialog(\'option\', \'buttons\', null);\r\n " +
" window.location.reload(true);\r\n },\r\n " +
" \'Close\': function () {\r\n " +
" $(this).dialog(\'destroy\');\r\n }\r\n " +
" }\r\n });\r\n }\r\n }" +
"\r\n }\r\n $(\'#dialogSession\').on(\'click\', \'#formResolveSessionPending" +
" button\', function (e) {\r\n const $button = $(this);\r\n cons" +
"t $form = $button.closest(\'form\');\r\n const body = new FormData($form[" +
"0]);\r\n body.append(\'approve\', $button.val());\r\n fetch($for" +
"m.attr(\'action\'), {\r\n method: \'POST\',\r\n body: body" +
"\r\n }).then(function (response) {\r\n if (!response.ok) {" +
"\r\n alert(\'Failed to resolve pending session: \' + response.sta" +
"tusText);\r\n }\r\n });\r\n });\r\n init();\r\n " +
" });\r\n</script>\r\n");
WriteLiteral("\' };\r\n $.connection.hub.error(function (error) {\r\n cons" +
"ole.log(\'Server connection error: \' + error);\r\n });\r\n $.co" +
"nnection.hub.disconnected(function (error) {\r\n // Show Dialog Mes" +
"sage\r\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
" $(\'<div>\')\r\n .addClass(\'dialog disconnected-dialo" +
"g\')\r\n .html(\'<h3><span class=\"fa-stack fa-lg\"><i class=\"f" +
"a fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x error\"></i></span>Dis" +
"connected from the Disco ICT Server</h3><div>This page is not receiving live upd" +
"ates. Please ensure you are connected to the server, then refresh this page to e" +
"nable features.</div>\')\r\n .dialog({\r\n " +
" resizable: false,\r\n title: \'Disconnected\',\r\n " +
" width: 400,\r\n modal: true," +
"\r\n buttons: {\r\n \'Refre" +
"sh Now\': function () {\r\n $(this).dialog(\'opti" +
"on\', \'buttons\', null);\r\n window.location.relo" +
"ad(true);\r\n },\r\n \'" +
"Close\': function () {\r\n $(this).dialog(\'destr" +
"oy\');\r\n }\r\n }\r\n " +
" });\r\n }\r\n });\r\n\r\n $.connec" +
"tion.hub.start()\r\n .done(function () { isLive = true; });\r\n\r\n " +
" }\r\n $(\'#dialogSession\').on(\'click\', \'#formResolveSessionPending butto" +
"n\', function (e) {\r\n const $button = $(this);\r\n const $for" +
"m = $button.closest(\'form\');\r\n const body = new FormData($form[0]);\r\n" +
" body.append(\'approve\', $button.val());\r\n fetch($form.attr" +
"(\'action\'), {\r\n method: \'POST\',\r\n body: body\r\n " +
" }).then(function (response) {\r\n if (!response.ok) {\r\n " +
" alert(\'Failed to resolve pending session: \' + response.statusTex" +
"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.error(onHubFailed);
$.connection.hub.start().fail(onHubFailed);
function onHubFailed(error) {
$.connection.hub.error(function (error) {
console.log('Server connection error: ' + error);
});
$.connection.hub.disconnected(function () {
// Show Dialog Message
if ($('.disconnected-dialog').length == 0) {
$('<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 " +
" if (liveEventReceivedFunction) liveEventReceivedFunction(message);\r\n " +
" };\r\n\r\n $.connection.hub.qs = {LogModules: logModule" +
"LiveGroupName};\r\n $.connection.hub.error(onHubFailed);\r\n\r\n " +
" $.connection.hub.start().fail(onHubFailed);\r\n\r\n " +
" function onHubFailed(error) {\r\n // Show Dialog Messag" +
"e\r\n if ($(\'.disconnected-dialog\').length == 0) {\r\n " +
" $(\'<div>\')\r\n .addClass(\'dial" +
"og disconnected-dialog\')\r\n .html(\'<h3><span class" +
"=\"fa-stack fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-s" +
"tack-2x error\"></i></span>Disconnected from the Disco ICT Server</h3><div>This p" +
"age is not receiving live updates. Please ensure you are connected to the server" +
", then refresh this page to enable features.</div>\')\r\n " +
" .dialog({\r\n resizable: false,\r\n " +
" title: \'Disconnected\',\r\n " +
" width: 400,\r\n modal: true,\r\n " +
" buttons: {\r\n \'" +
"Refresh Now\': function () {\r\n $(this)" +
".dialog(\'option\', \'buttons\', null);\r\n " +
" window.location.reload(true);\r\n },\r\n " +
" \'Close\': function () {\r\n " +
" $(this).dialog(\'destroy\');\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" +
"iv>\r\n");
"LiveGroupName};\r\n $.connection.hub.error(function (error) {\r\n" +
" console.log(\'Server connection error: \' + error);\r\n " +
" });\r\n $.connection.hub.disconnected(function (" +
") {\r\n // Show Dialog Message\r\n if " +
"($(\'.disconnected-dialog\').length == 0) {\r\n $(\'<div>\'" +
")\r\n .addClass(\'dialog disconnected-dialog\')\r\n " +
" .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>Disc" +
"onnected from the Disco ICT Server</h3><div>This page is not receiving live upda" +
"tes. Please ensure you are connected to the server, then refresh this page to en" +
"able features.</div>\')\r\n .dialog({\r\n " +
" resizable: false,\r\n ti" +
"tle: \'Disconnected\',\r\n width: 400,\r\n " +
" modal: true,\r\n but" +
"tons: {\r\n \'Refresh Now\': function () {\r\n " +
" $(this).dialog(\'option\', \'buttons\', n" +
"ull);\r\n window.location.reload(true);" +
"\r\n },\r\n " +
" \'Close\': function () {\r\n $(this" +
").dialog(\'destroy\');\r\n }\r\n " +
" }\r\n });\r\n " +
" }\r\n })\r\n\r\n $.connection.hub.start();\r" +
"\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)
window.clearTimeout(self.FullUpdateToken);
$.connection.hub.stop();
if (self.FinishedMessage())
window.setTimeout(function () { window.location.href = self.FinishedUrl(); }, 3000);
@@ -247,35 +246,36 @@
notificationsHub.client.updateTaskStatus = vm.Update;
$.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()
.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>
@@ -229,75 +229,77 @@ WriteLiteral("\';\r\n\r\n var view = $(\'#Logging_Task_Status\');\r\n
" if (self.FinishedTimestamp()) {\r\n if (self.FinishedUrl()" +
" && !self.TaskExceptionMessage()) {\r\n\r\n if (self.FullUpda" +
"teToken)\r\n window.clearTimeout(self.FullUpdateToken);" +
"\r\n $.connection.hub.stop();\r\n\r\n if" +
" (self.FinishedMessage())\r\n window.setTimeout(functio" +
"n () { window.location.href = self.FinishedUrl(); }, 3000);\r\n " +
" else\r\n window.location.href = self.FinishedUrl()" +
";\r\n }\r\n }\r\n }\r\n\r\n self.I" +
"nitialize = function (taskStatus) {\r\n self.TaskName(taskStatus.Ta" +
"skName);\r\n self.FinishedUrl(taskStatus.FinishedUrl);\r\n\r\n " +
" self.Progress(taskStatus.Progress);\r\n self.CurrentProcess(" +
"taskStatus.CurrentProcess);\r\n self.CurrentDescription(taskStatus." +
"CurrentDescription);\r\n\r\n self.IsRunning(taskStatus.IsRunning);\r\n\r" +
"\n self.TaskExceptionMessage(taskStatus.TaskExceptionMessage);\r\n\r\n" +
" self.FinishedTimestamp(taskStatus.FinishedTimestamp);\r\n " +
" self.NextScheduledTimestamp(taskStatus.NextScheduledTimestamp);\r\n\r\n " +
" self.FinishedMessage(taskStatus.FinishedMessage);\r\n\r\n s" +
"elf.Initialized(true);\r\n\r\n self.Finished();\r\n }\r\n " +
" self.Update = function (taskStatus) {\r\n if (!self.Initiali" +
"zed())\r\n return;\r\n\r\n if (self.FullUpdateToken)" +
"\r\n window.clearTimeout(self.FullUpdateToken);\r\n\r\n " +
" if (taskStatus) {\r\n $.each(taskStatus, function (key, val" +
"ue) {\r\n switch (key) {\r\n case " +
"\'Progress\':\r\n self.Progress(value);\r\n " +
" break;\r\n case \'CurrentProcess\':\r\n" +
" self.CurrentProcess(value);\r\n " +
" break;\r\n case \'CurrentDescription\':\r\n " +
" self.CurrentDescription(value);\r\n " +
" break;\r\n case \'IsRunning\':\r\n " +
" self.IsRunning(value);\r\n bre" +
"ak;\r\n case \'TaskExceptionMessage\':\r\n " +
" self.TaskExceptionMessage(value);\r\n " +
" break;\r\n case \'NextScheduledTimestamp\':\r\n " +
" self.NextScheduledTimestamp(value);\r\n " +
" break;\r\n case \'FinishedUrl\':\r\n " +
" self.FinishedUrl(value);\r\n br" +
"eak;\r\n case \'FinishedMessage\':\r\n " +
" self.FinishedMessage(value);\r\n break;\r" +
"\n case \'FinishedTimestamp\':\r\n " +
" self.FinishedTimestamp(value);\r\n window.s" +
"etTimeout(self.Finished, 1);\r\n break;\r\n " +
" default:\r\n // Ignore\r\n " +
" }\r\n });\r\n }\r\n\r\n " +
"if (!self.FinishedTimestamp())\r\n self.FullUpdateToken = windo" +
"w.setTimeout(self.FullUpdate, 2000);\r\n }\r\n\r\n self.FullUpda" +
"te = function () {\r\n self.FullUpdateToken = null;\r\n\r\n " +
" if (!self.FinishedTimestamp())\r\n notificationsHub.server." +
"getStatus()\r\n .done(self.Initialize);\r\n }\r\n " +
" }\r\n\r\n vm = new statusViewModel(sessionId);\r\n ko.applyBindings" +
"(vm, view[0]);\r\n\r\n // Start Live Connection\r\n updateWithLive();\r\n\r" +
"\n function updateWithLive() {\r\n notificationsHub = $.connectio" +
"n.scheduledTaskNotifications;\r\n notificationsHub.client.initializeTas" +
"kStatus = vm.Initialize;\r\n notificationsHub.client.updateTaskStatus =" +
" vm.Update;\r\n\r\n $.connection.hub.qs = { TaskSessionId: sessionId };\r\n" +
" $.connection.hub.error(onHubFailed);\r\n\r\n $.connection.hub" +
".start()\r\n .fail(onHubFailed);\r\n }\r\n\r\n function onH" +
"ubFailed(error) {\r\n // Show Dialog Message\r\n if ($(\'.disco" +
"nnected-dialog\').length == 0) {\r\n $(\'<div>\')\r\n " +
" .addClass(\'dialog disconnected-dialog\')\r\n .html(\'<h3><span c" +
"lass=\"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>Th" +
"is page is not receiving live updates. Please ensure you are connected to the se" +
"rver, then refresh this page to enable features.</div>\')\r\n .d" +
"ialog({\r\n resizable: false,\r\n titl" +
"e: \'Disconnected\',\r\n width: 400,\r\n " +
" modal: true,\r\n buttons: {\r\n \'" +
"Refresh Now\': function () {\r\n $(this).dialog(\'opt" +
"ion\', \'buttons\', null);\r\n window.location.reload(" +
"true);\r\n },\r\n \'Close\': fun" +
"ction () {\r\n $(this).dialog(\'destroy\');\r\n " +
" }\r\n }\r\n });\r\n " +
" }\r\n }\r\n\r\n });\r\n</script>\r\n");
"\r\n\r\n if (self.FinishedMessage())\r\n " +
" window.setTimeout(function () { window.location.href = self.FinishedUrl(); " +
"}, 3000);\r\n else\r\n window.loca" +
"tion.href = self.FinishedUrl();\r\n }\r\n }\r\n " +
" }\r\n\r\n self.Initialize = function (taskStatus) {\r\n " +
" self.TaskName(taskStatus.TaskName);\r\n self.FinishedUrl(taskSta" +
"tus.FinishedUrl);\r\n\r\n self.Progress(taskStatus.Progress);\r\n " +
" self.CurrentProcess(taskStatus.CurrentProcess);\r\n self." +
"CurrentDescription(taskStatus.CurrentDescription);\r\n\r\n self.IsRun" +
"ning(taskStatus.IsRunning);\r\n\r\n self.TaskExceptionMessage(taskSta" +
"tus.TaskExceptionMessage);\r\n\r\n self.FinishedTimestamp(taskStatus." +
"FinishedTimestamp);\r\n self.NextScheduledTimestamp(taskStatus.Next" +
"ScheduledTimestamp);\r\n\r\n self.FinishedMessage(taskStatus.Finished" +
"Message);\r\n\r\n self.Initialized(true);\r\n\r\n self.Fin" +
"ished();\r\n }\r\n self.Update = function (taskStatus) {\r\n " +
" if (!self.Initialized())\r\n return;\r\n\r\n " +
" if (self.FullUpdateToken)\r\n window.clearTimeout(self.Ful" +
"lUpdateToken);\r\n\r\n if (taskStatus) {\r\n $.each(" +
"taskStatus, function (key, value) {\r\n switch (key) {\r\n " +
" case \'Progress\':\r\n self." +
"Progress(value);\r\n break;\r\n " +
" case \'CurrentProcess\':\r\n self.CurrentProces" +
"s(value);\r\n break;\r\n c" +
"ase \'CurrentDescription\':\r\n self.CurrentDescripti" +
"on(value);\r\n break;\r\n " +
"case \'IsRunning\':\r\n self.IsRunning(value);\r\n " +
" break;\r\n case \'TaskExcepti" +
"onMessage\':\r\n self.TaskExceptionMessage(value);\r\n" +
" break;\r\n case \'NextSc" +
"heduledTimestamp\':\r\n self.NextScheduledTimestamp(" +
"value);\r\n break;\r\n cas" +
"e \'FinishedUrl\':\r\n self.FinishedUrl(value);\r\n " +
" break;\r\n case \'FinishedMe" +
"ssage\':\r\n self.FinishedMessage(value);\r\n " +
" break;\r\n case \'FinishedTimesta" +
"mp\':\r\n self.FinishedTimestamp(value);\r\n " +
" window.setTimeout(self.Finished, 1);\r\n " +
" break;\r\n default:\r\n " +
" // Ignore\r\n }\r\n });\r\n " +
" }\r\n\r\n if (!self.FinishedTimestamp())\r\n " +
" self.FullUpdateToken = window.setTimeout(self.FullUpdate, 2000);\r\n " +
"}\r\n\r\n self.FullUpdate = function () {\r\n self.FullUpdat" +
"eToken = null;\r\n\r\n if (!self.FinishedTimestamp())\r\n " +
" notificationsHub.server.getStatus()\r\n .done(self.In" +
"itialize);\r\n }\r\n }\r\n\r\n vm = new statusViewModel(session" +
"Id);\r\n ko.applyBindings(vm, view[0]);\r\n\r\n // Start Live Connection" +
"\r\n updateWithLive();\r\n\r\n function updateWithLive() {\r\n " +
"notificationsHub = $.connection.scheduledTaskNotifications;\r\n notific" +
"ationsHub.client.initializeTaskStatus = vm.Initialize;\r\n notification" +
"sHub.client.updateTaskStatus = vm.Update;\r\n\r\n $.connection.hub.qs = {" +
" TaskSessionId: sessionId };\r\n $.connection.hub.error(function (error" +
") {\r\n console.log(\'Server connection error: \' + error);\r\n " +
" });\r\n $.connection.hub.disconnected(function () {\r\n " +
" // Show Dialog Message\r\n if ($(\'.disconnected-dialog\').length =" +
"= 0) {\r\n $(\'<div>\')\r\n .addClass(\'dialo" +
"g disconnected-dialog\')\r\n .html(\'<h3><span class=\"fa-stac" +
"k fa-lg\"><i class=\"fa fa-wifi fa-stack-1x\"></i><i class=\"fa fa-ban fa-stack-2x e" +
"rror\"></i></span>Disconnected from the Disco ICT Server</h3><div>This page is no" +
"t receiving live updates. Please ensure you are connected to the server, then re" +
"fresh this page to enable features.</div>\')\r\n .dialog({\r\n" +
" resizable: false,\r\n title" +
": \'Disconnected\',\r\n width: 400,\r\n " +
" modal: true,\r\n buttons: {\r\n " +
" \'Refresh Now\': function () {\r\n " +
"$(this).dialog(\'option\', \'buttons\', null);\r\n " +
"window.location.reload(true);\r\n },\r\n " +
" \'Close\': function () {\r\n $" +
"(this).dialog(\'destroy\');\r\n }\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");
}
}