Update #74: Friendly disconnected messages

When the live connection to the server is interrupted some ui elements
are disabled. If the connection fails (due to errors or failed
reconnection) a dialog instructs the user to check their connection and
refresh the browser. Relates to Device, Job and User pages (logs and
attachments).
This commit is contained in:
Gary Sharp
2014-08-28 14:59:39 +10:00
parent 41e061df54
commit bbe4cccc91
16 changed files with 883 additions and 598 deletions
+9
View File
@@ -357,6 +357,15 @@
background-color: #ededed; background-color: #ededed;
border: 1px solid #cccccc; border: 1px solid #cccccc;
} }
#deviceShowResources #Attachments div.attachmentInput span.action.disabled {
color: rgba(51, 51, 51, 0.2);
cursor: default;
}
#deviceShowResources #Attachments div.attachmentInput span.action.disabled:hover {
color: rgba(51, 51, 51, 0.2);
background-color: inherit;
border: 1px solid #ffffff;
}
#Devices_Export .Devices_Export_Type_Target { #Devices_Export .Devices_Export_Type_Target {
margin-top: 10px; margin-top: 10px;
display: none; display: none;
+11
View File
@@ -330,6 +330,17 @@
background-color: @SubtleColour; background-color: @SubtleColour;
border: 1px solid @SubtleBorderColour; border: 1px solid @SubtleBorderColour;
} }
&.disabled {
color: fade(@HeaderBackgroundColour, 20%);
cursor: default;
&:hover {
color: fade(@HeaderBackgroundColour, 20%);
background-color: inherit;
border: 1px solid @white;
}
}
} }
} }
} }
File diff suppressed because one or more lines are too long
+18
View File
@@ -346,6 +346,15 @@
background-color: #ededed; background-color: #ededed;
border: 1px solid #cccccc; border: 1px solid #cccccc;
} }
#jobShowResources #Comments div.commentInput span.action.disabled {
color: rgba(51, 51, 51, 0.2);
cursor: default;
}
#jobShowResources #Comments div.commentInput span.action.disabled:hover {
color: rgba(51, 51, 51, 0.2);
background-color: inherit;
border: 1px solid #ffffff;
}
#jobShowResources #AttachmentsContainer { #jobShowResources #AttachmentsContainer {
padding: 0; padding: 0;
} }
@@ -446,6 +455,15 @@
background-color: #ededed; background-color: #ededed;
border: 1px solid #cccccc; border: 1px solid #cccccc;
} }
#jobShowResources #Attachments div.attachmentInput span.action.disabled {
color: rgba(51, 51, 51, 0.2);
cursor: default;
}
#jobShowResources #Attachments div.attachmentInput span.action.disabled:hover {
color: rgba(51, 51, 51, 0.2);
background-color: inherit;
border: 1px solid #ffffff;
}
#Job_Show_Job_Actions_AddQueue_Dialog { #Job_Show_Job_Actions_AddQueue_Dialog {
height: 400px; height: 400px;
} }
+22
View File
@@ -336,6 +336,17 @@
background-color: @SubtleColour; background-color: @SubtleColour;
border: 1px solid @SubtleBorderColour; border: 1px solid @SubtleBorderColour;
} }
&.disabled {
color: fade(@HeaderBackgroundColour, 20%);
cursor: default;
&:hover {
color: fade(@HeaderBackgroundColour, 20%);
background-color: inherit;
border: 1px solid @white;
}
}
} }
} }
} }
@@ -452,6 +463,17 @@
background-color: @SubtleColour; background-color: @SubtleColour;
border: 1px solid @SubtleBorderColour; border: 1px solid @SubtleBorderColour;
} }
&.disabled {
color: fade(@HeaderBackgroundColour, 20%);
cursor: default;
&:hover {
color: fade(@HeaderBackgroundColour, 20%);
background-color: inherit;
border: 1px solid @white;
}
}
} }
} }
} }
File diff suppressed because one or more lines are too long
+9
View File
@@ -444,6 +444,15 @@
background-color: #ededed; background-color: #ededed;
border: 1px solid #cccccc; border: 1px solid #cccccc;
} }
#userShowResources #Attachments div.attachmentInput span.action.disabled {
color: rgba(51, 51, 51, 0.2);
cursor: default;
}
#userShowResources #Attachments div.attachmentInput span.action.disabled:hover {
color: rgba(51, 51, 51, 0.2);
background-color: inherit;
border: 1px solid #ffffff;
}
#User_Show_Details_Actions_CreateJob_Dialog #CreateJob_Assignments { #User_Show_Details_Actions_CreateJob_Dialog #CreateJob_Assignments {
margin-top: 6px; margin-top: 6px;
background-color: #ffffff; background-color: #ffffff;
+11
View File
@@ -463,6 +463,17 @@
background-color: @SubtleColour; background-color: @SubtleColour;
border: 1px solid @SubtleBorderColour; border: 1px solid @SubtleBorderColour;
} }
&.disabled {
color: fade(@HeaderBackgroundColour, 20%);
cursor: default;
&:hover {
color: fade(@HeaderBackgroundColour, 20%);
background-color: inherit;
border: 1px solid @white;
}
}
} }
} }
} }
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -2406,7 +2406,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties> </WebProjectProperties>
</FlavorProperties> </FlavorProperties>
<UserProperties BuildVersion_StartDate="2014/6/1" BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" /> <UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" BuildVersion_StartDate="2014/6/1" />
</VisualStudio> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
<PropertyGroup> <PropertyGroup>
@@ -46,7 +46,7 @@
{ {
<div class="Disco-AttachmentUpload-Progress"></div> <div class="Disco-AttachmentUpload-Progress"></div>
<div class="attachmentInput clearfix"> <div class="attachmentInput clearfix">
<span class="action upload fa fa-upload" title="Attach File"></span><span class="action photo fa fa-camera" title="Capture Image"></span> <span class="action upload fa fa-upload disabled" title="Attach File"></span><span class="action photo fa fa-camera disabled" title="Capture Image"></span>
</div> </div>
} }
<script type="text/javascript"> <script type="text/javascript">
@@ -69,13 +69,46 @@
hub.client.removeAttachment = onRemoveAttachment; hub.client.removeAttachment = onRemoveAttachment;
$.connection.hub.qs = { DeviceSerialNumber: '@(Model.Device.SerialNumber)' }; $.connection.hub.qs = { DeviceSerialNumber: '@(Model.Device.SerialNumber)' };
$.connection.hub.error(onHubError); $.connection.hub.error(onHubFailed);
$.connection.hub.disconnected(onHubFailed);
$.connection.hub.reconnecting(function () {
$('#AttachmentsContainer').find('span.action').addClass('disabled');
});
$.connection.hub.reconnected(function () {
$('#AttachmentsContainer').find('span.action').removeClass('disabled');
});
// Start Connection // Start Connection
$.connection.hub.start().fail(onHubError); $.connection.hub.start(function () {
$('#AttachmentsContainer').find('span.action').removeClass('disabled');
}).fail(onHubFailed);
function onHubError(error) { function onHubFailed(error) {
alert('Live-update Error: ' + error); // Disable UI
$('#AttachmentsContainer').find('span.action').addClass('disabled');
// 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>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.href = window.location.href;
},
'Close': function () {
$(this).dialog('destroy');
}
}
});
}
} }
function onAddAttachment(id, quick) { function onAddAttachment(id, quick) {
@@ -209,10 +242,16 @@
var $attachmentInput = $Attachments.find('.attachmentInput'); var $attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.photo').click(function () { $attachmentInput.find('.photo').click(function () {
attachmentUploader.uploadImage(); if ($(this).hasClass('disabled'))
alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
else
attachmentUploader.uploadImage();
}); });
$attachmentInput.find('.upload').click(function () { $attachmentInput.find('.upload').click(function () {
attachmentUploader.uploadFiles(); if ($(this).hasClass('disabled'))
alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
else
attachmentUploader.uploadFiles();
}); });
var resourcesTab; var resourcesTab;
@@ -345,13 +345,13 @@ WriteLiteral(" class=\"attachmentInput clearfix\"");
WriteLiteral(">\r\n <span"); WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"action upload fa fa-upload\""); WriteLiteral(" class=\"action upload fa fa-upload disabled\"");
WriteLiteral(" title=\"Attach File\""); WriteLiteral(" title=\"Attach File\"");
WriteLiteral("></span><span"); WriteLiteral("></span><span");
WriteLiteral(" class=\"action photo fa fa-camera\""); WriteLiteral(" class=\"action photo fa fa-camera disabled\"");
WriteLiteral(" title=\"Capture Image\""); WriteLiteral(" title=\"Capture Image\"");
@@ -396,23 +396,45 @@ WriteLiteral(@">
#line default #line default
#line hidden #line hidden
WriteLiteral(@"' }; WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n " +
$.connection.hub.error(onHubError); " $.connection.hub.disconnected(onHubFailed);\r\n\r\n " +
" $.connection.hub.reconnecting(function () {\r\n " +
// Start Connection " $(\'#AttachmentsContainer\').find(\'span.action\').addClass(\'disabled\');\r" +
$.connection.hub.start().fail(onHubError); "\n });\r\n $.connection.hub.r" +
"econnected(function () {\r\n $(\'#AttachmentsContain" +
function onHubError(error) { "er\').find(\'span.action\').removeClass(\'disabled\');\r\n }" +
alert('Live-update Error: ' + error); ");\r\n\r\n // Start Connection\r\n " +
} " $.connection.hub.start(function () {\r\n $(\'#Att" +
"achmentsContainer\').find(\'span.action\').removeClass(\'disabled\');\r\n " +
function onAddAttachment(id, quick) { " }).fail(onHubFailed);\r\n\r\n function onHu" +
var data = { id: id }; "bFailed(error) {\r\n // Disable UI\r\n " +
$.ajax({ " $(\'#AttachmentsContainer\').find(\'span.action\').addClass(\'disabl" +
url: '"); "ed\');\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>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: tru" +
"e,\r\n buttons: {\r\n " +
" \'Refresh Now\': function () {\r\n " +
" $(this).dialog(\'option\', \'buttons\', null);\r\n " +
" window.location.href = window.loca" +
"tion.href;\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 onAddAttachment(" +
"id, quick) {\r\n var data = { id: id };\r\n " +
" $.ajax({\r\n url: \'");
#line 84 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 117 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.Attachment())); Write(Url.Action(MVC.API.Device.Attachment()));
@@ -427,13 +449,13 @@ WriteLiteral(@"',
"); ");
#line 90 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 123 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 90 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 123 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canRemoveAnyAttachments) if (canRemoveAnyAttachments)
{ {
@@ -447,7 +469,7 @@ WriteLiteral("buildAttachment(a, true, quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 93 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 126 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
} }
else if (canRemoveOwnAttachments) else if (canRemoveOwnAttachments)
{ {
@@ -460,7 +482,7 @@ WriteLiteral(" ");
WriteLiteral("buildAttachment(a, (a.AuthorId === \'"); WriteLiteral("buildAttachment(a, (a.AuthorId === \'");
#line 96 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 129 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(CurrentUser.UserId); Write(CurrentUser.UserId);
@@ -471,7 +493,7 @@ WriteLiteral("\'), quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 97 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 130 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
} }
else else
{ {
@@ -486,7 +508,7 @@ WriteLiteral("buildAttachment(a, false, quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 101 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 134 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
} }
@@ -513,7 +535,7 @@ WriteLiteral(@" } else {
e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '"); e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '");
#line 120 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 153 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentDownload())); Write(Url.Action(MVC.API.Device.AttachmentDownload()));
@@ -545,7 +567,7 @@ WriteLiteral(@"/' + a.Id);
img.attr('src', '"); img.attr('src', '");
#line 143 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 176 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentThumbnail())); Write(Url.Action(MVC.API.Device.AttachmentThumbnail()));
@@ -596,13 +618,13 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n
" }\r\n\r\n"); " }\r\n\r\n");
#line 202 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 235 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 202 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 235 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canAddAttachments) if (canAddAttachments)
{ {
@@ -613,7 +635,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
" \'"); " \'");
#line 206 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 239 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null))); Write(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)));
@@ -623,26 +645,32 @@ WriteLiteral("\',\r\n $Attachments.find(\'.Disco-Atta
"rget\'),\r\n $Attachments.find(\'.Disco-AttachmentUpload-" + "rget\'),\r\n $Attachments.find(\'.Disco-AttachmentUpload-" +
"Progress\'));\r\n\r\n var $attachmentInput = $Attachments." + "Progress\'));\r\n\r\n var $attachmentInput = $Attachments." +
"find(\'.attachmentInput\');\r\n $attachmentInput.find(\'.p" + "find(\'.attachmentInput\');\r\n $attachmentInput.find(\'.p" +
"hoto\').click(function () {\r\n attachmentUploader.u" + "hoto\').click(function () {\r\n if ($(this).hasClass" +
"ploadImage();\r\n });\r\n $att" + "(\'disabled\'))\r\n alert(\'Disconnected from the " +
"achmentInput.find(\'.upload\').click(function () {\r\n " + "Disco ICT Server, please refresh this page and try again\');\r\n " +
" attachmentUploader.uploadFiles();\r\n });\r\n\r\n " + " else\r\n attachmentUploader.upload" +
" var resourcesTab;\r\n $(document).o" + "Image();\r\n });\r\n $attachme" +
"n(\'dragover\', function () {\r\n if (!resourcesTab) " + "ntInput.find(\'.upload\').click(function () {\r\n if " +
"{\r\n var tabs = $Attachments.closest(\'.ui-tabs" + "($(this).hasClass(\'disabled\'))\r\n alert(\'Disco" +
"\');\r\n resourcesTab = {\r\n " + "nnected from the Disco ICT Server, please refresh this page and try again\');\r\n " +
" tabs: tabs,\r\n resource" + " else\r\n attachme" +
"sIndex: tabs.children(\'ul.ui-tabs-nav\').find(\'a[href=\"#DeviceDetailTab-Resources" + "ntUploader.uploadFiles();\r\n });\r\n\r\n " +
"\"]\').closest(\'li\').index()\r\n };\r\n " + " var resourcesTab;\r\n $(document).on(\'dragove" +
" }\r\n var selectedIndex = resou" + "r\', function () {\r\n if (!resourcesTab) {\r\n " +
"rcesTab.tabs.tabs(\'option\', \'active\');\r\n if (reso" + " var tabs = $Attachments.closest(\'.ui-tabs\');\r\n " +
"urcesTab.resourcesIndex !== selectedIndex)\r\n " + " resourcesTab = {\r\n " +
"resourcesTab.tabs.tabs(\'option\', \'active\', resourcesTab.resourcesIndex);\r\n " + " tabs: tabs,\r\n resourcesIndex: ta" +
" });\r\n //#endregion\r\n " + "bs.children(\'ul.ui-tabs-nav\').find(\'a[href=\"#DeviceDetailTab-Resources\"]\').close" +
" "); "st(\'li\').index()\r\n };\r\n " +
" }\r\n var selectedIndex = resourcesTab.ta" +
"bs.tabs(\'option\', \'active\');\r\n if (resourcesTab.r" +
"esourcesIndex !== selectedIndex)\r\n resourcesT" +
"ab.tabs.tabs(\'option\', \'active\', resourcesTab.resourcesIndex);\r\n " +
" });\r\n //#endregion\r\n " +
" ");
#line 232 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 271 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
} }
@@ -651,7 +679,7 @@ WriteLiteral("\',\r\n $Attachments.find(\'.Disco-Atta
WriteLiteral(" "); WriteLiteral(" ");
#line 233 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 272 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
@@ -684,7 +712,7 @@ WriteLiteral(@"
url: '"); url: '");
#line 258 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 297 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentRemove())); Write(Url.Action(MVC.API.Device.AttachmentRemove()));
@@ -712,7 +740,7 @@ WriteLiteral("\',\r\n dataType: \'jso
"endregion\r\n "); "endregion\r\n ");
#line 285 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 324 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
} }
@@ -749,7 +777,7 @@ WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n <scr
"etailTab-ResourcesLink\">Attachments ["); "etailTab-ResourcesLink\">Attachments [");
#line 306 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 345 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Model.Device.DeviceAttachments == null ? 0 : Model.Device.DeviceAttachments.Count); Write(Model.Device.DeviceAttachments == null ? 0 : Model.Device.DeviceAttachments.Count);
+82 -28
View File
@@ -44,7 +44,7 @@
{ {
<div class="commentInput clearfix"> <div class="commentInput clearfix">
<textarea class="commentInput" placeholder="write comment..." accesskey="l"></textarea> <textarea class="commentInput" placeholder="write comment..." accesskey="l"></textarea>
<span class="action post commentInputPost fa fa-comment" title="Post Comment"></span> <span class="action post commentInputPost fa fa-comment disabled" title="Post Comment"></span>
</div> </div>
} }
</div> </div>
@@ -77,7 +77,7 @@
{ {
<div class="Disco-AttachmentUpload-Progress"></div> <div class="Disco-AttachmentUpload-Progress"></div>
<div class="attachmentInput clearfix"> <div class="attachmentInput clearfix">
<span class="action upload fa fa-upload" title="Attach File"></span><span class="action photo fa fa-camera" title="Capture Image"></span> <span class="action upload fa fa-upload disabled" title="Attach File"></span><span class="action photo fa fa-camera disabled" title="Capture Image"></span>
</div> </div>
} }
</div> </div>
@@ -140,29 +140,39 @@
}); });
function postComment() { function postComment() {
if ($Comments.find('.commentInputPost').hasClass('disabled')) {
alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
return;
}
var comment = $CommentInput.val(); var comment = $CommentInput.val();
if (comment != '') {
var data = { comment: comment } if (comment == '') {
$.ajax({ alert('Enter a comment to post');
url: '@Url.Action(MVC.API.Job.CommentPost(Model.Job.Id, null))', $CommentInput.focus();
dataType: 'json', return;
data: data, }
success: function (d) {
if (d.Result == 'OK') { var data = { comment: comment }
// Should be added via Repository Notifications $.ajax({
// addComment(d.Comment, false); url: '@Url.Action(MVC.API.Job.CommentPost(Model.Job.Id, null))',
$CommentInput.val('').attr('disabled', false).focus(); dataType: 'json',
} else { data: data,
alert('Unable to post comment: ' + d.Result); success: function (d) {
$CommentInput.attr('disabled', false); if (d.Result == 'OK') {
} // Should be added via Repository Notifications
}, // addComment(d.Comment, false);
error: function (jqXHR, textStatus, errorThrown) { $CommentInput.val('').attr('disabled', false).focus();
alert('Unable to post comment: ' + textStatus); } else {
alert('Unable to post comment: ' + d.Result);
$CommentInput.attr('disabled', false); $CommentInput.attr('disabled', false);
} }
}); },
} error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to post comment: ' + textStatus);
$CommentInput.attr('disabled', false);
}
});
} }
//#endregion //#endregion
@@ -314,10 +324,16 @@
var $attachmentInput = $Attachments.find('.attachmentInput'); var $attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.photo').click(function () { $attachmentInput.find('.photo').click(function () {
attachmentUploader.uploadImage(); if ($(this).hasClass('disabled'))
alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
else
attachmentUploader.uploadImage();
}); });
$attachmentInput.find('.upload').click(function () { $attachmentInput.find('.upload').click(function () {
attachmentUploader.uploadFiles(); if ($(this).hasClass('disabled'))
alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
else
attachmentUploader.uploadFiles();
}); });
var resourcesTab; var resourcesTab;
@@ -556,13 +572,51 @@
</text>} </text>}
$.connection.hub.qs = { JobId: jobId }; $.connection.hub.qs = { JobId: jobId };
$.connection.hub.error(onHubError); $.connection.hub.error(onHubFailed);
$.connection.hub.disconnected(onHubFailed);
$.connection.hub.reconnecting(function () {
$('#CommentsContainer').find('span.action').addClass('disabled');
$('#AttachmentsContainer').find('span.action').addClass('disabled');
});
$.connection.hub.reconnected(function () {
$('#CommentsContainer').find('span.action').removeClass('disabled');
$('#AttachmentsContainer').find('span.action').removeClass('disabled');
});
// Start Connection // Start Connection
$.connection.hub.start().fail(onHubError); $.connection.hub.start(function () {
$('#CommentsContainer').find('span.action').removeClass('disabled');
$('#AttachmentsContainer').find('span.action').removeClass('disabled');
}).fail(onHubFailed);
function onHubError(error) { function onHubFailed(error) {
alert('Live-update Error: ' + error); // Disable UI
$('#CommentsContainer').find('textarea.commentInput').attr('readonly', 'readonly');
$('#CommentsContainer').find('span.action').addClass('disabled');
$('#AttachmentsContainer').find('span.action').addClass('disabled');
// 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>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.href = window.location.href;
},
'Close': function () {
$(this).dialog('destroy');
}
}
});
}
} }
//#endregion //#endregion
@@ -284,7 +284,7 @@ WriteLiteral(" accesskey=\"l\"");
WriteLiteral("></textarea>\r\n <span"); WriteLiteral("></textarea>\r\n <span");
WriteLiteral(" class=\"action post commentInputPost fa fa-comment\""); WriteLiteral(" class=\"action post commentInputPost fa fa-comment disabled\"");
WriteLiteral(" title=\"Post Comment\""); WriteLiteral(" title=\"Post Comment\"");
@@ -324,14 +324,14 @@ WriteLiteral(">\r\n <div");
WriteLiteral(" id=\"Attachments\""); WriteLiteral(" id=\"Attachments\"");
WriteAttribute("class", Tuple.Create(" class=\"", 2939), Tuple.Create("\"", 3014) WriteAttribute("class", Tuple.Create(" class=\"", 2948), Tuple.Create("\"", 3023)
#line 56 "..\..\Views\Job\JobParts\Resources.cshtml" #line 56 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 2947), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments" , Tuple.Create(Tuple.Create("", 2956), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments"
#line default #line default
#line hidden #line hidden
, 2947), false) , 2956), false)
); );
WriteLiteral(">\r\n <div"); WriteLiteral(">\r\n <div");
@@ -361,14 +361,14 @@ WriteLiteral(">\r\n");
#line hidden #line hidden
WriteLiteral(" <a"); WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 3351), Tuple.Create("\"", 3408) WriteAttribute("href", Tuple.Create(" href=\"", 3360), Tuple.Create("\"", 3417)
#line 63 "..\..\Views\Job\JobParts\Resources.cshtml" #line 63 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 3358), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentDownload(ja.Id)) , Tuple.Create(Tuple.Create("", 3367), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentDownload(ja.Id))
#line default #line default
#line hidden #line hidden
, 3358), false) , 3367), false)
); );
WriteLiteral(" data-attachmentid=\""); WriteLiteral(" data-attachmentid=\"");
@@ -397,42 +397,42 @@ WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"icon\""); WriteLiteral(" class=\"icon\"");
WriteAttribute("title", Tuple.Create(" title=\"", 3518), Tuple.Create("\"", 3538) WriteAttribute("title", Tuple.Create(" title=\"", 3527), Tuple.Create("\"", 3547)
#line 64 "..\..\Views\Job\JobParts\Resources.cshtml" #line 64 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 3526), Tuple.Create<System.Object, System.Int32>(ja.Filename , Tuple.Create(Tuple.Create("", 3535), Tuple.Create<System.Object, System.Int32>(ja.Filename
#line default #line default
#line hidden #line hidden
, 3526), false) , 3535), false)
); );
WriteLiteral(">\r\n <img"); WriteLiteral(">\r\n <img");
WriteLiteral(" alt=\"Attachment Thumbnail\""); WriteLiteral(" alt=\"Attachment Thumbnail\"");
WriteAttribute("src", Tuple.Create(" src=\"", 3609), Tuple.Create("\"", 3668) WriteAttribute("src", Tuple.Create(" src=\"", 3618), Tuple.Create("\"", 3677)
#line 65 "..\..\Views\Job\JobParts\Resources.cshtml" #line 65 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 3615), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id)) , Tuple.Create(Tuple.Create("", 3624), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Job.AttachmentThumbnail(ja.Id))
#line default #line default
#line hidden #line hidden
, 3615), false) , 3624), false)
); );
WriteLiteral(" /></span>\r\n <span"); WriteLiteral(" /></span>\r\n <span");
WriteLiteral(" class=\"comments\""); WriteLiteral(" class=\"comments\"");
WriteAttribute("title", Tuple.Create(" title=\"", 3735), Tuple.Create("\"", 3755) WriteAttribute("title", Tuple.Create(" title=\"", 3744), Tuple.Create("\"", 3764)
#line 66 "..\..\Views\Job\JobParts\Resources.cshtml" #line 66 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 3743), Tuple.Create<System.Object, System.Int32>(ja.Comments , Tuple.Create(Tuple.Create("", 3752), Tuple.Create<System.Object, System.Int32>(ja.Comments
#line default #line default
#line hidden #line hidden
, 3743), false) , 3752), false)
); );
WriteLiteral(">\r\n"); WriteLiteral(">\r\n");
@@ -527,14 +527,14 @@ WriteLiteral(" data-livestamp=\"");
#line hidden #line hidden
WriteLiteral("\""); WriteLiteral("\"");
WriteAttribute("title", Tuple.Create(" title=\"", 4450), Tuple.Create("\"", 4488) WriteAttribute("title", Tuple.Create(" title=\"", 4459), Tuple.Create("\"", 4497)
#line 72 "..\..\Views\Job\JobParts\Resources.cshtml" #line 72 "..\..\Views\Job\JobParts\Resources.cshtml"
, Tuple.Create(Tuple.Create("", 4458), Tuple.Create<System.Object, System.Int32>(ja.Timestamp.ToFullDateTime() , Tuple.Create(Tuple.Create("", 4467), Tuple.Create<System.Object, System.Int32>(ja.Timestamp.ToFullDateTime()
#line default #line default
#line hidden #line hidden
, 4458), false) , 4467), false)
); );
WriteLiteral(">"); WriteLiteral(">");
@@ -583,13 +583,13 @@ WriteLiteral(" class=\"attachmentInput clearfix\"");
WriteLiteral(">\r\n <span"); WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"action upload fa fa-upload\""); WriteLiteral(" class=\"action upload fa fa-upload disabled\"");
WriteLiteral(" title=\"Attach File\""); WriteLiteral(" title=\"Attach File\"");
WriteLiteral("></span><span"); WriteLiteral("></span><span");
WriteLiteral(" class=\"action photo fa fa-camera\""); WriteLiteral(" class=\"action photo fa fa-camera disabled\"");
WriteLiteral(" title=\"Capture Image\""); WriteLiteral(" title=\"Capture Image\"");
@@ -735,45 +735,55 @@ WriteLiteral(@"
}); });
function postComment() { function postComment() {
if ($Comments.find('.commentInputPost').hasClass('disabled')) {
alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
return;
}
var comment = $CommentInput.val(); var comment = $CommentInput.val();
if (comment != '') {
var data = { comment: comment } if (comment == '') {
$.ajax({ alert('Enter a comment to post');
url: '"); $CommentInput.focus();
return;
}
var data = { comment: comment }
$.ajax({
url: '");
#line 147 "..\..\Views\Job\JobParts\Resources.cshtml" #line 158 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.CommentPost(Model.Job.Id, null))); Write(Url.Action(MVC.API.Job.CommentPost(Model.Job.Id, null)));
#line default #line default
#line hidden #line hidden
WriteLiteral(@"', WriteLiteral(@"',
dataType: 'json', dataType: 'json',
data: data, data: data,
success: function (d) { success: function (d) {
if (d.Result == 'OK') { if (d.Result == 'OK') {
// Should be added via Repository Notifications // Should be added via Repository Notifications
// addComment(d.Comment, false); // addComment(d.Comment, false);
$CommentInput.val('').attr('disabled', false).focus(); $CommentInput.val('').attr('disabled', false).focus();
} else { } else {
alert('Unable to post comment: ' + d.Result); alert('Unable to post comment: ' + d.Result);
$CommentInput.attr('disabled', false);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to post comment: ' + textStatus);
$CommentInput.attr('disabled', false); $CommentInput.attr('disabled', false);
} }
}); },
} error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to post comment: ' + textStatus);
$CommentInput.attr('disabled', false);
}
});
} }
//#endregion //#endregion
"); ");
#line 169 "..\..\Views\Job\JobParts\Resources.cshtml" #line 179 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -782,7 +792,7 @@ WriteLiteral(@"',
WriteLiteral(" "); WriteLiteral(" ");
#line 170 "..\..\Views\Job\JobParts\Resources.cshtml" #line 180 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyLogs || canRemoveOwnLogs) if (canRemoveAnyLogs || canRemoveOwnLogs)
{ {
@@ -816,7 +826,7 @@ WriteLiteral(@"
url: '"); url: '");
#line 196 "..\..\Views\Job\JobParts\Resources.cshtml" #line 206 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.CommentRemove())); Write(Url.Action(MVC.API.Job.CommentRemove()));
@@ -854,7 +864,7 @@ WriteLiteral(@"',
"); ");
#line 225 "..\..\Views\Job\JobParts\Resources.cshtml" #line 235 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -864,7 +874,7 @@ WriteLiteral("\r\n function loadLiveComment(key) {\r\n
" url: \'"); " url: \'");
#line 229 "..\..\Views\Job\JobParts\Resources.cshtml" #line 239 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.Comment())); Write(Url.Action(MVC.API.Job.Comment()));
@@ -875,13 +885,13 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"d.JobId == jobId) {\r\n"); "d.JobId == jobId) {\r\n");
#line 234 "..\..\Views\Job\JobParts\Resources.cshtml" #line 244 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 234 "..\..\Views\Job\JobParts\Resources.cshtml" #line 244 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyLogs) if (canRemoveAnyLogs)
{ {
@@ -890,7 +900,7 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
WriteLiteral("addComment(d, false, true);"); WriteLiteral("addComment(d, false, true);");
#line 235 "..\..\Views\Job\JobParts\Resources.cshtml" #line 245 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
else if (canRemoveOwnLogs) else if (canRemoveOwnLogs)
{ {
@@ -900,7 +910,7 @@ WriteLiteral("addComment(d, false, true);");
WriteLiteral("addComment(d, false, (d.AuthorId === \'"); WriteLiteral("addComment(d, false, (d.AuthorId === \'");
#line 237 "..\..\Views\Job\JobParts\Resources.cshtml" #line 247 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(CurrentUser.UserId); Write(CurrentUser.UserId);
@@ -909,7 +919,7 @@ WriteLiteral("addComment(d, false, (d.AuthorId === \'");
WriteLiteral("\'));"); WriteLiteral("\'));");
#line 237 "..\..\Views\Job\JobParts\Resources.cshtml" #line 247 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
else else
{ {
@@ -919,7 +929,7 @@ WriteLiteral("\'));");
WriteLiteral("addComment(d, false, false);"); WriteLiteral("addComment(d, false, false);");
#line 239 "..\..\Views\Job\JobParts\Resources.cshtml" #line 249 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -953,14 +963,14 @@ WriteLiteral("\r\n }\r\n },\r\n
"= liveRemoveComment;\r\n //#endregion\r\n });\r\n </script>\r\n"); "= liveRemoveComment;\r\n //#endregion\r\n });\r\n </script>\r\n");
#line 287 "..\..\Views\Job\JobParts\Resources.cshtml" #line 297 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 288 "..\..\Views\Job\JobParts\Resources.cshtml" #line 298 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowAttachments) if (canShowAttachments)
{ {
@@ -981,7 +991,7 @@ WriteLiteral(@" <script>
var jobId = parseInt('"); var jobId = parseInt('");
#line 301 "..\..\Views\Job\JobParts\Resources.cshtml" #line 311 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id); Write(Model.Job.Id);
@@ -992,13 +1002,13 @@ WriteLiteral("\');\r\n\r\n //#region Attachments\r\n var $
"tput\');\r\n\r\n"); "tput\');\r\n\r\n");
#line 307 "..\..\Views\Job\JobParts\Resources.cshtml" #line 317 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 307 "..\..\Views\Job\JobParts\Resources.cshtml" #line 317 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canAddAttachments) if (canAddAttachments)
{ {
@@ -1008,42 +1018,36 @@ WriteLiteral("\r\n //#region Add Attachments\r\n var attac
" document.Disco.AttachmentUploader(\r\n \'"); " document.Disco.AttachmentUploader(\r\n \'");
#line 311 "..\..\Views\Job\JobParts\Resources.cshtml" #line 321 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null))); Write(Url.Action(MVC.API.Job.AttachmentUpload(Model.Job.Id, null)));
#line default #line default
#line hidden #line hidden
WriteLiteral(@"', WriteLiteral("\',\r\n $Attachments.find(\'.Disco-AttachmentUpload-DropTarget\'),\r\n " +
$Attachments.find('.Disco-AttachmentUpload-DropTarget'), " $Attachments.find(\'.Disco-AttachmentUpload-Progress\'));\r\n\r\n " +
$Attachments.find('.Disco-AttachmentUpload-Progress')); " var $attachmentInput = $Attachments.find(\'.attachmentInput\');\r\n $" +
"attachmentInput.find(\'.photo\').click(function () {\r\n if ($(this)." +
var $attachmentInput = $Attachments.find('.attachmentInput'); "hasClass(\'disabled\'))\r\n alert(\'Disconnected from the Disco IC" +
$attachmentInput.find('.photo').click(function () { "T Server, please refresh this page and try again\');\r\n else\r\n " +
attachmentUploader.uploadImage(); " attachmentUploader.uploadImage();\r\n });\r\n $" +
}); "attachmentInput.find(\'.upload\').click(function () {\r\n if ($(this)" +
$attachmentInput.find('.upload').click(function () { ".hasClass(\'disabled\'))\r\n alert(\'Disconnected from the Disco I" +
attachmentUploader.uploadFiles(); "CT Server, please refresh this page and try again\');\r\n else\r\n " +
}); " attachmentUploader.uploadFiles();\r\n });\r\n\r\n " +
" var resourcesTab;\r\n $(document).on(\'dragover\', function () {\r\n " +
var resourcesTab; " if (!resourcesTab) {\r\n var tabs = $Attachments.clo" +
$(document).on('dragover', function () { "sest(\'.ui-tabs\');\r\n resourcesTab = {\r\n " +
if (!resourcesTab) { " tabs: tabs,\r\n resourcesIndex: tabs.children(\'ul.ui-tabs-" +
var tabs = $Attachments.closest('.ui-tabs'); "nav\').find(\'a[href=\"#jobDetailTab-Resources\"]\').closest(\'li\').index()\r\n " +
resourcesTab = { " };\r\n }\r\n var selectedIndex = resourcesT" +
tabs: tabs, "ab.tabs.tabs(\'option\', \'active\');\r\n if (resourcesTab.resourcesInd" +
resourcesIndex: tabs.children('ul.ui-tabs-nav').find('a[href=""#jobDetailTab-Resources""]').closest('li').index() "ex !== selectedIndex)\r\n resourcesTab.tabs.tabs(\'option\', \'act" +
}; "ive\', resourcesTab.resourcesIndex);\r\n });\r\n //#endregion\r\n" +
} " ");
var selectedIndex = resourcesTab.tabs.tabs('option', 'active');
if (resourcesTab.resourcesIndex !== selectedIndex)
resourcesTab.tabs.tabs('option', 'active', resourcesTab.resourcesIndex);
});
//#endregion
");
#line 337 "..\..\Views\Job\JobParts\Resources.cshtml" #line 353 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -1052,13 +1056,13 @@ WriteLiteral(@"',
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 339 "..\..\Views\Job\JobParts\Resources.cshtml" #line 355 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 339 "..\..\Views\Job\JobParts\Resources.cshtml" #line 355 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
@@ -1093,7 +1097,7 @@ WriteLiteral(@"
url: '"); url: '");
#line 366 "..\..\Views\Job\JobParts\Resources.cshtml" #line 382 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentRemove())); Write(Url.Action(MVC.API.Job.AttachmentRemove()));
@@ -1129,7 +1133,7 @@ WriteLiteral(@"',
"); ");
#line 393 "..\..\Views\Job\JobParts\Resources.cshtml" #line 409 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -1139,7 +1143,7 @@ WriteLiteral("\r\n function addAttachment(key, quick) {\r\n
"id: key };\r\n $.ajax({\r\n url: \'"); "id: key };\r\n $.ajax({\r\n url: \'");
#line 398 "..\..\Views\Job\JobParts\Resources.cshtml" #line 414 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.Attachment())); Write(Url.Action(MVC.API.Job.Attachment()));
@@ -1150,13 +1154,13 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"\'OK\') {\r\n var a = d.Attachment;\r\n"); "\'OK\') {\r\n var a = d.Attachment;\r\n");
#line 404 "..\..\Views\Job\JobParts\Resources.cshtml" #line 420 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 404 "..\..\Views\Job\JobParts\Resources.cshtml" #line 420 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyAttachments) if (canRemoveAnyAttachments)
{ {
@@ -1170,7 +1174,7 @@ WriteLiteral("buildAttachment(a, true, quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 407 "..\..\Views\Job\JobParts\Resources.cshtml" #line 423 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
else if (canRemoveOwnAttachments) else if (canRemoveOwnAttachments)
{ {
@@ -1183,7 +1187,7 @@ WriteLiteral(" ");
WriteLiteral("buildAttachment(a, (a.AuthorId === \'"); WriteLiteral("buildAttachment(a, (a.AuthorId === \'");
#line 410 "..\..\Views\Job\JobParts\Resources.cshtml" #line 426 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(CurrentUser.UserId); Write(CurrentUser.UserId);
@@ -1194,7 +1198,7 @@ WriteLiteral("\'), quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 411 "..\..\Views\Job\JobParts\Resources.cshtml" #line 427 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
else else
{ {
@@ -1209,7 +1213,7 @@ WriteLiteral("buildAttachment(a, false, quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 415 "..\..\Views\Job\JobParts\Resources.cshtml" #line 431 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -1236,7 +1240,7 @@ WriteLiteral(@" } else {
e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '"); e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '");
#line 434 "..\..\Views\Job\JobParts\Resources.cshtml" #line 450 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentDownload())); Write(Url.Action(MVC.API.Job.AttachmentDownload()));
@@ -1268,7 +1272,7 @@ WriteLiteral(@"/' + a.Id);
img.attr('src', '"); img.attr('src', '");
#line 457 "..\..\Views\Job\JobParts\Resources.cshtml" #line 473 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.AttachmentThumbnail())); Write(Url.Action(MVC.API.Job.AttachmentThumbnail()));
@@ -1315,14 +1319,14 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\
"script>\r\n"); "script>\r\n");
#line 527 "..\..\Views\Job\JobParts\Resources.cshtml" #line 543 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 528 "..\..\Views\Job\JobParts\Resources.cshtml" #line 544 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs || canShowAttachments) if (canShowLogs || canShowAttachments)
{ {
@@ -1332,7 +1336,7 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\
WriteLiteral(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'"); WriteLiteral(" <script>\r\n $(function () {\r\n var jobId = parseInt(\'");
#line 532 "..\..\Views\Job\JobParts\Resources.cshtml" #line 548 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id); Write(Model.Job.Id);
@@ -1342,7 +1346,7 @@ WriteLiteral("\');\r\n\r\n //#region LiveEvents\r\n var hu
"dates;\r\n\r\n // Map Functions\r\n"); "dates;\r\n\r\n // Map Functions\r\n");
#line 538 "..\..\Views\Job\JobParts\Resources.cshtml" #line 554 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs) if (canShowLogs)
{ {
@@ -1353,14 +1357,14 @@ WriteLiteral("\r\n hub.client.addLog = document.DiscoFunctions.liveLo
" "); " ");
#line 542 "..\..\Views\Job\JobParts\Resources.cshtml" #line 558 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 543 "..\..\Views\Job\JobParts\Resources.cshtml" #line 559 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowAttachments) if (canShowAttachments)
{ {
@@ -1381,30 +1385,48 @@ WriteLiteral(@"
"); ");
#line 556 "..\..\Views\Job\JobParts\Resources.cshtml" #line 572 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(@" WriteLiteral("\r\n $.connection.hub.qs = { JobId: jobId };\r\n $.connection.h" +
$.connection.hub.qs = { JobId: jobId }; "ub.error(onHubFailed);\r\n $.connection.hub.disconnected(onHubFailed);\r" +
$.connection.hub.error(onHubError); "\n\r\n $.connection.hub.reconnecting(function () {\r\n $(\'#" +
"CommentsContainer\').find(\'span.action\').addClass(\'disabled\');\r\n $" +
// Start Connection "(\'#AttachmentsContainer\').find(\'span.action\').addClass(\'disabled\');\r\n " +
$.connection.hub.start().fail(onHubError); " });\r\n $.connection.hub.reconnected(function () {\r\n $(" +
"\'#CommentsContainer\').find(\'span.action\').removeClass(\'disabled\');\r\n " +
function onHubError(error) { " $(\'#AttachmentsContainer\').find(\'span.action\').removeClass(\'disabled\');\r\n " +
alert('Live-update Error: ' + error); " });\r\n\r\n // Start Connection\r\n $.connection.hub.st" +
} "art(function () {\r\n $(\'#CommentsContainer\').find(\'span.action\').r" +
"emoveClass(\'disabled\');\r\n $(\'#AttachmentsContainer\').find(\'span.a" +
//#endregion "ction\').removeClass(\'disabled\');\r\n }).fail(onHubFailed);\r\n\r\n " +
}); " function onHubFailed(error) {\r\n // Disable UI\r\n " +
</script> " $(\'#CommentsContainer\').find(\'textarea.commentInput\').attr(\'readonly\', \'readonl" +
"); "y\');\r\n $(\'#CommentsContainer\').find(\'span.action\').addClass(\'disa" +
"bled\');\r\n $(\'#AttachmentsContainer\').find(\'span.action\').addClass" +
"(\'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>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: \'Disconn" +
"ected\',\r\n width: 400,\r\n mo" +
"dal: true,\r\n buttons: {\r\n " +
" \'Refresh Now\': function () {\r\n $(this).di" +
"alog(\'option\', \'buttons\', null);\r\n window.loc" +
"ation.href = window.location.href;\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 //#endregion\r\n });\r\n </script>\r\n");
#line 571 "..\..\Views\Job\JobParts\Resources.cshtml" #line 625 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
+226 -187
View File
@@ -46,7 +46,7 @@
{ {
<div class="Disco-AttachmentUpload-Progress"></div> <div class="Disco-AttachmentUpload-Progress"></div>
<div class="attachmentInput clearfix"> <div class="attachmentInput clearfix">
<span class="action upload fa fa-upload" title="Attach File"></span><span class="action photo fa fa-camera" title="Capture Image"></span> <span class="action upload fa fa-upload disabled" title="Attach File"></span><span class="action photo fa fa-camera disabled" title="Capture Image"></span>
</div> </div>
} }
<script type="text/javascript"> <script type="text/javascript">
@@ -67,24 +67,57 @@
hub.client.removeAttachment = onRemoveAttachment; hub.client.removeAttachment = onRemoveAttachment;
$.connection.hub.qs = { UserId: '@(Model.User.UserId.Replace(@"\", @"\\"))' }; $.connection.hub.qs = { UserId: '@(Model.User.UserId.Replace(@"\", @"\\"))' };
$.connection.hub.error(onHubError); $.connection.hub.error(onHubFailed);
$.connection.hub.disconnected(onHubFailed);
// Start Connection $.connection.hub.reconnecting(function () {
$.connection.hub.start().fail(onHubError); $('#AttachmentsContainer').find('span.action').addClass('disabled');
});
$.connection.hub.reconnected(function () {
$('#AttachmentsContainer').find('span.action').removeClass('disabled');
});
function onHubError(error) { // Start Connection
alert('Live-update Error: ' + error); $.connection.hub.start(function () {
} $('#AttachmentsContainer').find('span.action').removeClass('disabled');
}).fail(onHubFailed);
function onAddAttachment(id, quick) { function onHubFailed(error) {
var data = { id: id }; // Disable UI
$.ajax({ $('#AttachmentsContainer').find('span.action').addClass('disabled');
url: '@Url.Action(MVC.API.User.Attachment())',
dataType: 'json', // Show Dialog Message
data: data, if ($('.disconnected-dialog').length == 0) {
success: function (d) { $('<div>')
if (d.Result == 'OK') { .addClass('dialog disconnected-dialog')
var a = d.Attachment; .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>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.href = window.location.href;
},
'Close': function () {
$(this).dialog('destroy');
}
}
});
}
}
function onAddAttachment(id, quick) {
var data = { id: id };
$.ajax({
url: '@Url.Action(MVC.API.User.Attachment())',
dataType: 'json',
data: data,
success: function (d) {
if (d.Result == 'OK') {
var a = d.Attachment;
@if (canRemoveAnyAttachments) @if (canRemoveAnyAttachments)
{ {
<text>buildAttachment(a, true, quick);</text> <text>buildAttachment(a, true, quick);</text>
@@ -97,200 +130,206 @@
{ {
<text>buildAttachment(a, false, quick);</text> <text>buildAttachment(a, false, quick);</text>
} }
} else { } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to add attachment: ' + textStatus);
} }
}, });
error: function (jqXHR, textStatus, errorThrown) { }
alert('Unable to add attachment: ' + textStatus); function buildAttachment(a, canRemove, quick) {
} var t = '<a><span class="icon"><img alt="Attachment Thumbnail" /></span><span class="comments"></span><span class="author"></span>';
}); if (canRemove)
} t += '<span class="remove fa fa-times-circle"></span>';
function buildAttachment(a, canRemove, quick) { t += '<span class="timestamp"></span></a>';
var t = '<a><span class="icon"><img alt="Attachment Thumbnail" /></span><span class="comments"></span><span class="author"></span>';
if (canRemove)
t += '<span class="remove fa fa-times-circle"></span>';
t += '<span class="timestamp"></span></a>';
var e = $(t); var e = $(t);
e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '@(Url.Action(MVC.API.User.AttachmentDownload()))/' + a.Id); e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '@(Url.Action(MVC.API.User.AttachmentDownload()))/' + a.Id);
e.find('.comments').text(a.Description); e.find('.comments').text(a.Description);
e.find('.author').text(a.Author); e.find('.author').text(a.Author);
e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc); e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc);
if (canRemove) if (canRemove)
e.find('.remove').click(removeAttachment); e.find('.remove').click(removeAttachment);
if (!quick) if (!quick)
e.hide(); e.hide();
$attachmentOutput.append(e); $attachmentOutput.append(e);
onUpdate(); onUpdate();
if (!quick) if (!quick)
e.show('slow'); e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0) if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description }); e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else else
e.click(onDownload); e.click(onDownload);
// Add Thumbnail // Add Thumbnail
var buildThumbnail = function () { var buildThumbnail = function () {
var retryCount = 0; var retryCount = 0;
var img = e.find('.icon img'); var img = e.find('.icon img');
var setThumbnailUrl = function () { var setThumbnailUrl = function () {
img.attr('src', '@(Url.Action(MVC.API.User.AttachmentThumbnail()))/' + a.Id + '?v=' + retryCount); img.attr('src', '@(Url.Action(MVC.API.User.AttachmentThumbnail()))/' + a.Id + '?v=' + retryCount);
};
img.on('error', function () {
img.addClass('loading');
retryCount++;
if (retryCount < 6)
window.setTimeout(setThumbnailUrl, retryCount * 250);
});
img.on('load', function () {
img.removeClass('loading');
});
window.setTimeout(setThumbnailUrl, 100);
}; };
img.on('error', function () { buildThumbnail();
img.addClass('loading');
retryCount++;
if (retryCount < 6)
window.setTimeout(setThumbnailUrl, retryCount * 250);
});
img.on('load', function () {
img.removeClass('loading');
});
window.setTimeout(setThumbnailUrl, 100);
};
buildThumbnail();
}
function onDownload() {
var $this = $(this);
var url = $this.attr('href');
if ($.connection && $.connection.hub && $.connection.hub.transport &&
$.connection.hub.transport.name == 'foreverFrame') {
// SignalR active with foreverFrame transport - use popup window
window.open(url, '_blank', 'height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
} else {
// use iFrame
if (!$attachmentDownloadHost) {
$attachmentDownloadHost = $('<iframe>')
.attr({ 'src': url, 'title': 'Attachment Download Host' })
.addClass('hidden')
.appendTo('body')
.contents();
} else {
$attachmentDownloadHost[0].location.href = url;
}
} }
return false; function onDownload() {
}
function onRemoveAttachment(id) {
var a = $attachmentOutput.find('a[data-attachmentid=' + id + ']');
a.hide(300).delay(300).queue(function () {
var $this = $(this); var $this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0) var url = $this.attr('href');
Shadowbox.removeCache(this);
$this.find('.timestamp').livestamp('destroy');
$this.remove();
onUpdate();
});
}
function onUpdate() { if ($.connection && $.connection.hub && $.connection.hub.transport &&
var attachmentCount = $attachmentOutput.children('a').length; $.connection.hub.transport.name == 'foreverFrame') {
var tabHeading = 'Attachments [' + attachmentCount + ']'; // SignalR active with foreverFrame transport - use popup window
$('#UserDetailTab-ResourcesLink').text(tabHeading); window.open(url, '_blank', 'height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
} } else {
// use iFrame
if (!$attachmentDownloadHost) {
$attachmentDownloadHost = $('<iframe>')
.attr({ 'src': url, 'title': 'Attachment Download Host' })
.addClass('hidden')
.appendTo('body')
.contents();
} else {
$attachmentDownloadHost[0].location.href = url;
}
}
return false;
}
function onRemoveAttachment(id) {
var a = $attachmentOutput.find('a[data-attachmentid=' + id + ']');
a.hide(300).delay(300).queue(function () {
var $this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
Shadowbox.removeCache(this);
$this.find('.timestamp').livestamp('destroy');
$this.remove();
onUpdate();
});
}
function onUpdate() {
var attachmentCount = $attachmentOutput.children('a').length;
var tabHeading = 'Attachments [' + attachmentCount + ']';
$('#UserDetailTab-ResourcesLink').text(tabHeading);
}
@if (canAddAttachments) @if (canAddAttachments)
{<text> {<text>
//#region Add Attachments //#region Add Attachments
var attachmentUploader = new document.Disco.AttachmentUploader( var attachmentUploader = new document.Disco.AttachmentUploader(
'@(Url.Action(MVC.API.User.AttachmentUpload(Model.User.UserId, null)))', '@(Url.Action(MVC.API.User.AttachmentUpload(Model.User.UserId, null)))',
$Attachments.find('.Disco-AttachmentUpload-DropTarget'), $Attachments.find('.Disco-AttachmentUpload-DropTarget'),
$Attachments.find('.Disco-AttachmentUpload-Progress')); $Attachments.find('.Disco-AttachmentUpload-Progress'));
var $attachmentInput = $Attachments.find('.attachmentInput'); var $attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.photo').click(function () { $attachmentInput.find('.photo').click(function () {
attachmentUploader.uploadImage(); if ($(this).hasClass('disabled'))
}); alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
$attachmentInput.find('.upload').click(function () { else
attachmentUploader.uploadFiles(); attachmentUploader.uploadImage();
}); });
$attachmentInput.find('.upload').click(function () {
var resourcesTab; if ($(this).hasClass('disabled'))
$(document).on('dragover', function () { alert('Disconnected from the Disco ICT Server, please refresh this page and try again');
if (!resourcesTab) { else
var tabs = $Attachments.closest('.ui-tabs'); attachmentUploader.uploadFiles();
resourcesTab = {
tabs: tabs,
resourcesIndex: tabs.children('ul.ui-tabs-nav').find('a[href="#UserDetailTab-Resources"]').closest('li').index()
};
}
var selectedIndex = resourcesTab.tabs.tabs('option', 'active');
if (resourcesTab.resourcesIndex !== selectedIndex)
resourcesTab.tabs.tabs('option', 'active', resourcesTab.resourcesIndex);
});
//#endregion
</text>}
@if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{<text>
//#region Remove Attachments
$attachmentOutput.find('span.remove').click(removeAttachment);
function removeAttachment() {
$this = $(this).closest('a');
var data = { id: $this.attr('data-attachmentid') };
if (!$dialogRemoveAttachment) {
$dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({
resizable: false,
height: 140,
modal: true,
autoOpen: false
});
}
$dialogRemoveAttachment.dialog("enable");
$dialogRemoveAttachment.dialog('option', 'buttons', {
"Remove": function () {
$dialogRemoveAttachment.dialog("disable");
$dialogRemoveAttachment.dialog("option", "buttons", null);
$.ajax({
url: '@Url.Action(MVC.API.User.AttachmentRemove())',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
// Do nothing, await SignalR notification
} else {
alert('Unable to remove attachment: ' + d);
}
$dialogRemoveAttachment.dialog("close");
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to remove attachment: ' + textStatus);
$dialogRemoveAttachment.dialog("close");
}
});
},
Cancel: function () {
$dialogRemoveAttachment.dialog("close");
}
}); });
$dialogRemoveAttachment.dialog('open'); var resourcesTab;
$(document).on('dragover', function () {
if (!resourcesTab) {
var tabs = $Attachments.closest('.ui-tabs');
resourcesTab = {
tabs: tabs,
resourcesIndex: tabs.children('ul.ui-tabs-nav').find('a[href="#UserDetailTab-Resources"]').closest('li').index()
};
}
var selectedIndex = resourcesTab.tabs.tabs('option', 'active');
if (resourcesTab.resourcesIndex !== selectedIndex)
resourcesTab.tabs.tabs('option', 'active', resourcesTab.resourcesIndex);
});
//#endregion
</text>}
@if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{<text>
//#region Remove Attachments
return false; $attachmentOutput.find('span.remove').click(removeAttachment);
}
//#endregion function removeAttachment() {
$this = $(this).closest('a');
var data = { id: $this.attr('data-attachmentid') };
if (!$dialogRemoveAttachment) {
$dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({
resizable: false,
height: 140,
modal: true,
autoOpen: false
});
}
$dialogRemoveAttachment.dialog("enable");
$dialogRemoveAttachment.dialog('option', 'buttons', {
"Remove": function () {
$dialogRemoveAttachment.dialog("disable");
$dialogRemoveAttachment.dialog("option", "buttons", null);
$.ajax({
url: '@Url.Action(MVC.API.User.AttachmentRemove())',
dataType: 'json',
data: data,
success: function (d) {
if (d == 'OK') {
// Do nothing, await SignalR notification
} else {
alert('Unable to remove attachment: ' + d);
}
$dialogRemoveAttachment.dialog("close");
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to remove attachment: ' + textStatus);
$dialogRemoveAttachment.dialog("close");
}
});
},
Cancel: function () {
$dialogRemoveAttachment.dialog("close");
}
});
$dialogRemoveAttachment.dialog('open');
return false;
}
//#endregion
</text>} </text>}
$attachmentOutput.children('a').each(function () { $attachmentOutput.children('a').each(function () {
$this = $(this); $this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0) if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() }); $this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
else else
$this.click(onDownload); $this.click(onDownload);
});
}); });
});
</script> </script>
</div> </div>
</td> </td>
@@ -345,13 +345,13 @@ WriteLiteral(" class=\"attachmentInput clearfix\"");
WriteLiteral(">\r\n <span"); WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"action upload fa fa-upload\""); WriteLiteral(" class=\"action upload fa fa-upload disabled\"");
WriteLiteral(" title=\"Attach File\""); WriteLiteral(" title=\"Attach File\"");
WriteLiteral("></span><span"); WriteLiteral("></span><span");
WriteLiteral(" class=\"action photo fa fa-camera\""); WriteLiteral(" class=\"action photo fa fa-camera disabled\"");
WriteLiteral(" title=\"Capture Image\""); WriteLiteral(" title=\"Capture Image\"");
@@ -394,44 +394,66 @@ WriteLiteral(@">
#line default #line default
#line hidden #line hidden
WriteLiteral(@"' }; WriteLiteral("\' };\r\n $.connection.hub.error(onHubFailed);\r\n " +
$.connection.hub.error(onHubError); " $.connection.hub.disconnected(onHubFailed);\r\n\r\n " +
" $.connection.hub.reconnecting(function () {\r\n " +
// Start Connection " $(\'#AttachmentsContainer\').find(\'span.action\').addClass(\'disabled\');\r" +
$.connection.hub.start().fail(onHubError); "\n });\r\n $.connection.hub.r" +
"econnected(function () {\r\n $(\'#AttachmentsContain" +
function onHubError(error) { "er\').find(\'span.action\').removeClass(\'disabled\');\r\n }" +
alert('Live-update Error: ' + error); ");\r\n\r\n // Start Connection\r\n " +
} " $.connection.hub.start(function () {\r\n $(\'#Att" +
"achmentsContainer\').find(\'span.action\').removeClass(\'disabled\');\r\n " +
function onAddAttachment(id, quick) { " }).fail(onHubFailed);\r\n\r\n function onHu" +
var data = { id: id }; "bFailed(error) {\r\n // Disable UI\r\n " +
$.ajax({ " $(\'#AttachmentsContainer\').find(\'span.action\').addClass(\'disabl" +
url: '"); "ed\');\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>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: tru" +
"e,\r\n buttons: {\r\n " +
" \'Refresh Now\': function () {\r\n " +
" $(this).dialog(\'option\', \'buttons\', null);\r\n " +
" window.location.href = window.loca" +
"tion.href;\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 onAddAttachment(" +
"id, quick) {\r\n var data = { id: id };\r\n " +
" $.ajax({\r\n url: \'");
#line 82 "..\..\Views\User\UserParts\_Resources.cshtml" #line 115 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.Attachment())); Write(Url.Action(MVC.API.User.Attachment()));
#line default #line default
#line hidden #line hidden
WriteLiteral(@"', WriteLiteral(@"',
dataType: 'json', dataType: 'json',
data: data, data: data,
success: function (d) { success: function (d) {
if (d.Result == 'OK') { if (d.Result == 'OK') {
var a = d.Attachment; var a = d.Attachment;
"); ");
#line 88 "..\..\Views\User\UserParts\_Resources.cshtml" #line 121 "..\..\Views\User\UserParts\_Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 88 "..\..\Views\User\UserParts\_Resources.cshtml" #line 121 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canRemoveAnyAttachments) if (canRemoveAnyAttachments)
{ {
@@ -445,7 +467,7 @@ WriteLiteral("buildAttachment(a, true, quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 91 "..\..\Views\User\UserParts\_Resources.cshtml" #line 124 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
else if (canRemoveOwnAttachments) else if (canRemoveOwnAttachments)
{ {
@@ -458,7 +480,7 @@ WriteLiteral(" ");
WriteLiteral("buildAttachment(a, (a.AuthorId === \'"); WriteLiteral("buildAttachment(a, (a.AuthorId === \'");
#line 94 "..\..\Views\User\UserParts\_Resources.cshtml" #line 127 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(CurrentUser.UserId); Write(CurrentUser.UserId);
@@ -469,7 +491,7 @@ WriteLiteral("\'), quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 95 "..\..\Views\User\UserParts\_Resources.cshtml" #line 128 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
else else
{ {
@@ -484,159 +506,169 @@ WriteLiteral("buildAttachment(a, false, quick);");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 99 "..\..\Views\User\UserParts\_Resources.cshtml" #line 132 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(@" } else { WriteLiteral(@" } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('Unable to add attachment: ' + textStatus);
} }
}, });
error: function (jqXHR, textStatus, errorThrown) { }
alert('Unable to add attachment: ' + textStatus); function buildAttachment(a, canRemove, quick) {
} var t = '<a><span class=""icon""><img alt=""Attachment Thumbnail"" /></span><span class=""comments""></span><span class=""author""></span>';
}); if (canRemove)
} t += '<span class=""remove fa fa-times-circle""></span>';
function buildAttachment(a, canRemove, quick) { t += '<span class=""timestamp""></span></a>';
var t = '<a><span class=""icon""><img alt=""Attachment Thumbnail"" /></span><span class=""comments""></span><span class=""author""></span>';
if (canRemove)
t += '<span class=""remove fa fa-times-circle""></span>';
t += '<span class=""timestamp""></span></a>';
var e = $(t); var e = $(t);
e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '"); e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '");
#line 117 "..\..\Views\User\UserParts\_Resources.cshtml" #line 150 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentDownload())); Write(Url.Action(MVC.API.User.AttachmentDownload()));
#line default #line default
#line hidden #line hidden
WriteLiteral(@"/' + a.Id); WriteLiteral(@"/' + a.Id);
e.find('.comments').text(a.Description); e.find('.comments').text(a.Description);
e.find('.author').text(a.Author); e.find('.author').text(a.Author);
e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc); e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc);
if (canRemove) if (canRemove)
e.find('.remove').click(removeAttachment); e.find('.remove').click(removeAttachment);
if (!quick) if (!quick)
e.hide(); e.hide();
$attachmentOutput.append(e); $attachmentOutput.append(e);
onUpdate(); onUpdate();
if (!quick) if (!quick)
e.show('slow'); e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0) if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description }); e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description });
else else
e.click(onDownload); e.click(onDownload);
// Add Thumbnail // Add Thumbnail
var buildThumbnail = function () { var buildThumbnail = function () {
var retryCount = 0; var retryCount = 0;
var img = e.find('.icon img'); var img = e.find('.icon img');
var setThumbnailUrl = function () { var setThumbnailUrl = function () {
img.attr('src', '"); img.attr('src', '");
#line 140 "..\..\Views\User\UserParts\_Resources.cshtml" #line 173 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentThumbnail())); Write(Url.Action(MVC.API.User.AttachmentThumbnail()));
#line default #line default
#line hidden #line hidden
WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\r\n " + WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\r\n " +
" img.on(\'error\', function () {\r\n " + " img.on(\'error\', function () {\r\n " +
" img.addClass(\'loading\');\r\n retryCount" + " img.addClass(\'loading\');\r\n " +
"++;\r\n if (retryCount < 6)\r\n " + " retryCount++;\r\n if (retryCount < 6)" +
" window.setTimeout(setThumbnailUrl, retryCount * 250);\r\n " + "\r\n window.setTimeout(setThumbnailUrl," +
" });\r\n img.on(\'load\'," + " retryCount * 250);\r\n });\r\n " +
" function () {\r\n img.removeClass(\'loading\');\r" + " img.on(\'load\', function () {\r\n " +
"\n });\r\n window.set" + " img.removeClass(\'loading\');\r\n });\r\n " +
"Timeout(setThumbnailUrl, 100);\r\n };\r\n " + " window.setTimeout(setThumbnailUrl, 100);\r\n " +
" buildThumbnail();\r\n }\r\n\r\n " + " };\r\n buildThumbnail()" +
" function onDownload() {\r\n var $this = $(this);\r\n " + ";\r\n }\r\n\r\n function onDownl" +
" var url = $this.attr(\'href\');\r\n\r\n " + "oad() {\r\n var $this = $(this);\r\n " +
" if ($.connection && $.connection.hub && $.connection.hub.transport &&\r\n " + " var url = $this.attr(\'href\');\r\n\r\n " +
" $.connection.hub.transport.name =" + "if ($.connection && $.connection.hub && $.connection.hub.transport &&\r\n " +
"= \'foreverFrame\') {\r\n // SignalR active with fore" + " $.connection.hub.transport.name == \'f" +
"verFrame transport - use popup window\r\n window.op" + "oreverFrame\') {\r\n // SignalR active with fore" +
"en(url, \'_blank\', \'height=150,width=250,location=no,menubar=no,resizable=no,scro" + "verFrame transport - use popup window\r\n windo" +
"llbars=no,status=no,toolbar=no\');\r\n } else {\r\n " + "w.open(url, \'_blank\', \'height=150,width=250,location=no,menubar=no,resizable=no," +
" // use iFrame\r\n if (!$at" + "scrollbars=no,status=no,toolbar=no\');\r\n } else {\r" +
"tachmentDownloadHost) {\r\n $attachmentDownload" + "\n // use iFrame\r\n " +
"Host = $(\'<iframe>\')\r\n .attr({ \'src\': url" + " if (!$attachmentDownloadHost) {\r\n " +
", \'title\': \'Attachment Download Host\' })\r\n " + " $attachmentDownloadHost = $(\'<iframe>\')\r\n " +
" .addClass(\'hidden\')\r\n .appendTo(\'body\')" + " .attr({ \'src\': url, \'title\': \'Attachment Download Host\' })\r\n " +
"\r\n .contents();\r\n " + " .addClass(\'hidden\')\r\n " +
" } else {\r\n $attachmentDownloadHost[0]" + " .appendTo(\'body\')\r\n .c" +
".location.href = url;\r\n }\r\n " + "ontents();\r\n } else {\r\n " +
" }\r\n\r\n return false;\r\n }\r" + " $attachmentDownloadHost[0].location.href = url;\r\n " +
"\n\r\n function onRemoveAttachment(id) {\r\n " + " }\r\n }\r\n\r\n " +
" var a = $attachmentOutput.find(\'a[data-attachmentid=\' + id + \']\');\r\n\r\n" + " return false;\r\n }\r\n\r\n " +
" a.hide(300).delay(300).queue(function () {\r\n " + " function onRemoveAttachment(id) {\r\n va" +
" var $this = $(this);\r\n if" + "r a = $attachmentOutput.find(\'a[data-attachmentid=\' + id + \']\');\r\n\r\n " +
" a.hide(300).delay(300).queue(function () {\r\n " +
" var $this = $(this);\r\n if" +
" ($this.attr(\'data-mimetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n " + " ($this.attr(\'data-mimetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n " +
" Shadowbox.removeCache(this);\r\n " + " Shadowbox.removeCache(this);\r\n " +
" $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n " + " $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n " +
" $this.remove();\r\n onUpdate();\r\n " + " $this.remove();\r\n onUpdate" +
" });\r\n }\r\n\r\n funct" + "();\r\n });\r\n }\r\n\r\n " +
"ion onUpdate() {\r\n var attachmentCount = $attachmentO" + " function onUpdate() {\r\n va" +
"utput.children(\'a\').length;\r\n var tabHeading = \'Attac" + "r attachmentCount = $attachmentOutput.children(\'a\').length;\r\n " +
"hments [\' + attachmentCount + \']\';\r\n $(\'#UserDetailTa" + " var tabHeading = \'Attachments [\' + attachmentCount + \']\';\r\n " +
"b-ResourcesLink\').text(tabHeading);\r\n }\r\n\r\n"); " $(\'#UserDetailTab-ResourcesLink\').text(tabHeading);\r\n " +
" }\r\n\r\n");
#line 199 "..\..\Views\User\UserParts\_Resources.cshtml" #line 232 "..\..\Views\User\UserParts\_Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 199 "..\..\Views\User\UserParts\_Resources.cshtml" #line 232 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canAddAttachments) if (canAddAttachments)
{ {
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n //#region Add Attachments\r\n var " + WriteLiteral("\r\n //#region Add Attachments\r\n " +
"attachmentUploader = new document.Disco.AttachmentUploader(\r\n " + " var attachmentUploader = new document.Disco.AttachmentUploader(\r\n " +
" \'"); " \'");
#line 203 "..\..\Views\User\UserParts\_Resources.cshtml" #line 236 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentUpload(Model.User.UserId, null))); Write(Url.Action(MVC.API.User.AttachmentUpload(Model.User.UserId, null)));
#line default #line default
#line hidden #line hidden
WriteLiteral("\',\r\n $Attachments.find(\'.Disco-AttachmentUpload-DropTa" + WriteLiteral("\',\r\n $Attachments.find(\'.Disco-AttachmentUpload-DropTa" +
"rget\'),\r\n $Attachments.find(\'.Disco-AttachmentUpload-" + "rget\'),\r\n $Attachments.find(\'.Disco-AttachmentUpload-" +
"Progress\'));\r\n\r\n var $attachmentInput = $Attachments.find" + "Progress\'));\r\n\r\n var $attachmentInput = $Attachments." +
"(\'.attachmentInput\');\r\n $attachmentInput.find(\'.photo\').c" + "find(\'.attachmentInput\');\r\n $attachmentInput.find(\'.p" +
"lick(function () {\r\n attachmentUploader.uploadImage()" + "hoto\').click(function () {\r\n if ($(this).hasClass" +
";\r\n });\r\n $attachmentInput.find(\'." + "(\'disabled\'))\r\n alert(\'Disconnected from the " +
"upload\').click(function () {\r\n attachmentUploader.upl" + "Disco ICT Server, please refresh this page and try again\');\r\n " +
"oadFiles();\r\n });\r\n\r\n var resource" + " else\r\n attachmentUploader.upload" +
"sTab;\r\n $(document).on(\'dragover\', function () {\r\n " + "Image();\r\n });\r\n $attachme" +
" if (!resourcesTab) {\r\n var t" + "ntInput.find(\'.upload\').click(function () {\r\n if " +
"abs = $Attachments.closest(\'.ui-tabs\');\r\n resourc" + "($(this).hasClass(\'disabled\'))\r\n alert(\'Disco" +
"esTab = {\r\n tabs: tabs,\r\n " + "nnected from the Disco ICT Server, please refresh this page and try again\');\r\n " +
" resourcesIndex: tabs.children(\'ul.ui-tabs-nav\').find(\'a[href=\"#U" + " else\r\n attachme" +
"serDetailTab-Resources\"]\').closest(\'li\').index()\r\n " + "ntUploader.uploadFiles();\r\n });\r\n\r\n " +
" };\r\n }\r\n var selectedInd" + " var resourcesTab;\r\n $(document).on(\'dragove" +
"ex = resourcesTab.tabs.tabs(\'option\', \'active\');\r\n if" + "r\', function () {\r\n if (!resourcesTab) {\r\n " +
" (resourcesTab.resourcesIndex !== selectedIndex)\r\n " + " var tabs = $Attachments.closest(\'.ui-tabs\');\r\n " +
" resourcesTab.tabs.tabs(\'option\', \'active\', resourcesTab.resourcesIndex);\r\n " + " resourcesTab = {\r\n " +
" });\r\n //#endregion\r\n " + " tabs: tabs,\r\n resourcesIndex: ta" +
" "); "bs.children(\'ul.ui-tabs-nav\').find(\'a[href=\"#UserDetailTab-Resources\"]\').closest" +
"(\'li\').index()\r\n };\r\n " +
" }\r\n var selectedIndex = resourcesTab.tabs" +
".tabs(\'option\', \'active\');\r\n if (resourcesTab.res" +
"ourcesIndex !== selectedIndex)\r\n resourcesTab" +
".tabs.tabs(\'option\', \'active\', resourcesTab.resourcesIndex);\r\n " +
" });\r\n //#endregion\r\n " +
" ");
#line 229 "..\..\Views\User\UserParts\_Resources.cshtml" #line 268 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
#line default #line default
@@ -644,92 +676,83 @@ WriteLiteral("\',\r\n $Attachments.find(\'.Disco-Atta
WriteLiteral(" "); WriteLiteral(" ");
#line 230 "..\..\Views\User\UserParts\_Resources.cshtml" #line 269 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
#line default #line default
#line hidden #line hidden
WriteLiteral(@" WriteLiteral(@"
//#region Remove Attachments //#region Remove Attachments
$attachmentOutput.find('span.remove').click(removeAttachment); $attachmentOutput.find('span.remove').click(removeAttachment);
function removeAttachment() { function removeAttachment() {
$this = $(this).closest('a'); $this = $(this).closest('a');
var data = { id: $this.attr('data-attachmentid') }; var data = { id: $this.attr('data-attachmentid') };
if (!$dialogRemoveAttachment) { if (!$dialogRemoveAttachment) {
$dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({ $dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({
resizable: false, resizable: false,
height: 140, height: 140,
modal: true, modal: true,
autoOpen: false autoOpen: false
}); });
} }
$dialogRemoveAttachment.dialog(""enable""); $dialogRemoveAttachment.dialog(""enable"");
$dialogRemoveAttachment.dialog('option', 'buttons', { $dialogRemoveAttachment.dialog('option', 'buttons', {
""Remove"": function () { ""Remove"": function () {
$dialogRemoveAttachment.dialog(""disable""); $dialogRemoveAttachment.dialog(""disable"");
$dialogRemoveAttachment.dialog(""option"", ""buttons"", null); $dialogRemoveAttachment.dialog(""option"", ""buttons"", null);
$.ajax({ $.ajax({
url: '"); url: '");
#line 256 "..\..\Views\User\UserParts\_Resources.cshtml" #line 295 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentRemove())); Write(Url.Action(MVC.API.User.AttachmentRemove()));
#line default #line default
#line hidden #line hidden
WriteLiteral(@"', WriteLiteral("\',\r\n dataType: \'json\',\r\n " +
dataType: 'json', " data: data,\r\n " +
data: data, " success: function (d) {\r\n " +
success: function (d) { "if (d == \'OK\') {\r\n // Do noth" +
if (d == 'OK') { "ing, await SignalR notification\r\n " +
// Do nothing, await SignalR notification " } else {\r\n alert(\'Unable to " +
} else { "remove attachment: \' + d);\r\n }\r\n " +
alert('Unable to remove attachment: ' + d); " $dialogRemoveAttachment.dialog(\"c" +
} "lose\");\r\n },\r\n " +
$dialogRemoveAttachment.dialog(""close""); " error: function (jqXHR, textStatus, errorThrown) {\r\n " +
}, " alert(\'Unable to remove attachment: \' +" +
error: function (jqXHR, textStatus, errorThrown) { " textStatus);\r\n $dialogRemoveAtta" +
alert('Unable to remove attachment: ' + textStatus); "chment.dialog(\"close\");\r\n }\r\n " +
$dialogRemoveAttachment.dialog(""close""); " });\r\n },\r\n " +
} " Cancel: function () {\r\n " +
}); " $dialogRemoveAttachment.dialog(\"close\");\r\n " +
}, " }\r\n });\r\n\r\n " +
Cancel: function () { " $dialogRemoveAttachment.dialog(\'open\');\r\n\r\n " +
$dialogRemoveAttachment.dialog(""close""); " return false;\r\n }\r\n\r\n /" +
} "/#endregion\r\n ");
});
$dialogRemoveAttachment.dialog('open');
return false;
}
//#endregion
");
#line 284 "..\..\Views\User\UserParts\_Resources.cshtml" #line 323 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(@" WriteLiteral(@"
$attachmentOutput.children('a').each(function () { $attachmentOutput.children('a').each(function () {
$this = $(this); $this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0) if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() }); $this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
else else
$this.click(onDownload); $this.click(onDownload);
});
}); });
});
</script> </script>
</div> </div>
</td> </td>
@@ -739,7 +762,7 @@ WriteLiteral(@"
$('#UserDetailTabItems').append('<li><a href=""#UserDetailTab-Resources"" id=""UserDetailTab-ResourcesLink"">Attachments ["); $('#UserDetailTabItems').append('<li><a href=""#UserDetailTab-Resources"" id=""UserDetailTab-ResourcesLink"">Attachments [");
#line 300 "..\..\Views\User\UserParts\_Resources.cshtml" #line 339 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Model.User.UserAttachments == null ? 0 : Model.User.UserAttachments.Count); Write(Model.User.UserAttachments == null ? 0 : Model.User.UserAttachments.Count);
@@ -748,7 +771,7 @@ WriteLiteral(@"
WriteLiteral("]</a></li>\');\r\n </script>\r\n</div>\r\n"); WriteLiteral("]</a></li>\');\r\n </script>\r\n</div>\r\n");
#line 303 "..\..\Views\User\UserParts\_Resources.cshtml" #line 342 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
@@ -770,7 +793,7 @@ WriteLiteral(" class=\"fa fa-exclamation-triangle fa-lg\"");
WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n"); WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n");
#line 310 "..\..\Views\User\UserParts\_Resources.cshtml" #line 349 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
#line default #line default