qol: online upload: remove dialog when attachment received

This commit is contained in:
Gary Sharp
2025-08-01 11:40:02 +10:00
parent be7ee4cae8
commit d291ad464f
9 changed files with 237 additions and 200 deletions
@@ -218,12 +218,12 @@
} }
self.onlineUploadDisplay = function () { self.onlineUploadDisplay = function () {
if (!!window.QRCode && !!self.onlineUploadSession) { if (!!window.QRCode && !!self.onlineUploadSession) {
var dialog = $('<div>') const dialog = $('<div>')
.attr({ .attr({
title: 'Online Upload', title: 'Online Upload',
'class': 'dialog Disco-AttachmentUpload-OnlineUploadDialog' 'class': 'dialog Disco-AttachmentUpload-OnlineUploadDialog'
}); });
var qrCode = QRCode({ const qrCode = QRCode({
msg: self.onlineUploadSession.SessionUri, msg: self.onlineUploadSession.SessionUri,
ecl: 'L' ecl: 'L'
}); });
@@ -234,11 +234,15 @@
$('<div class="info-box"><p class="fa-p"><i class="fa fa-info-circle information"></i> Scan the QR Code or send the link to upload files</p></div>') $('<div class="info-box"><p class="fa-p"><i class="fa fa-info-circle information"></i> Scan the QR Code or send the link to upload files</p></div>')
.appendTo(dialog); .appendTo(dialog);
var expiration = new Date(self.onlineUploadSession.Expiration); const expiration = new Date(self.onlineUploadSession.Expiration);
var sessionExpiration = setTimeout(function () { const sessionExpiration = setTimeout(function () {
dialog.dialog('close'); dialog.dialog('close');
}, expiration.getTime() - new Date().getTime()); }, expiration.getTime() - new Date().getTime());
self.onlineUploadCloseDialog = function () {
dialog.dialog('close');
};
dialog.dialog({ dialog.dialog({
resizable: false, resizable: false,
width: 500, width: 500,
@@ -248,6 +252,7 @@
if (!!sessionExpiration) { if (!!sessionExpiration) {
window.clearTimeout(sessionExpiration); window.clearTimeout(sessionExpiration);
} }
self.onlineUploadCloseDialog = null;
dialog.dialog('destroy').remove(); dialog.dialog('destroy').remove();
} }
}); });
File diff suppressed because one or more lines are too long
@@ -218,12 +218,12 @@
} }
self.onlineUploadDisplay = function () { self.onlineUploadDisplay = function () {
if (!!window.QRCode && !!self.onlineUploadSession) { if (!!window.QRCode && !!self.onlineUploadSession) {
var dialog = $('<div>') const dialog = $('<div>')
.attr({ .attr({
title: 'Online Upload', title: 'Online Upload',
'class': 'dialog Disco-AttachmentUpload-OnlineUploadDialog' 'class': 'dialog Disco-AttachmentUpload-OnlineUploadDialog'
}); });
var qrCode = QRCode({ const qrCode = QRCode({
msg: self.onlineUploadSession.SessionUri, msg: self.onlineUploadSession.SessionUri,
ecl: 'L' ecl: 'L'
}); });
@@ -234,11 +234,15 @@
$('<div class="info-box"><p class="fa-p"><i class="fa fa-info-circle information"></i> Scan the QR Code or send the link to upload files</p></div>') $('<div class="info-box"><p class="fa-p"><i class="fa fa-info-circle information"></i> Scan the QR Code or send the link to upload files</p></div>')
.appendTo(dialog); .appendTo(dialog);
var expiration = new Date(self.onlineUploadSession.Expiration); const expiration = new Date(self.onlineUploadSession.Expiration);
var sessionExpiration = setTimeout(function () { const sessionExpiration = setTimeout(function () {
dialog.dialog('close'); dialog.dialog('close');
}, expiration.getTime() - new Date().getTime()); }, expiration.getTime() - new Date().getTime());
self.onlineUploadCloseDialog = function () {
dialog.dialog('close');
};
dialog.dialog({ dialog.dialog({
resizable: false, resizable: false,
width: 500, width: 500,
@@ -248,6 +252,7 @@
if (!!sessionExpiration) { if (!!sessionExpiration) {
window.clearTimeout(sessionExpiration); window.clearTimeout(sessionExpiration);
} }
self.onlineUploadCloseDialog = null;
dialog.dialog('destroy').remove(); dialog.dialog('destroy').remove();
} }
}); });
@@ -59,6 +59,7 @@
const $attachmentOutput = $Attachments.find('.attachmentOutput'); const $attachmentOutput = $Attachments.find('.attachmentOutput');
let $attachmentDownloadHost = null; let $attachmentDownloadHost = null;
let $dialogRemoveAttachment = null; let $dialogRemoveAttachment = null;
let attachmentUploader = null;
function onAttachmentAdded(id, quick) { function onAttachmentAdded(id, quick) {
var data = { id: id }; var data = { id: id };
@@ -76,6 +77,10 @@
buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick); buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick);
else else
buildAttachment(a, false, quick); buildAttachment(a, false, quick);
if (attachmentUploader && attachmentUploader.onlineUploadCloseDialog) {
attachmentUploader.onlineUploadCloseDialog();
}
} else { } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
} }
@@ -182,7 +187,7 @@
@if (canAddAttachments) @if (canAddAttachments)
{<text> {<text>
//#region Add Attachments //#region Add Attachments
var attachmentUploader = new document.Disco.AttachmentUploader($Attachments); attachmentUploader = new document.Disco.AttachmentUploader($Attachments);
var $attachmentInput = $Attachments.find('.attachmentInput'); var $attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.online-upload').on('click', function () { $attachmentInput.find('.online-upload').on('click', function () {
@@ -452,6 +452,7 @@ WriteLiteral(@">
const $attachmentOutput = $Attachments.find('.attachmentOutput'); const $attachmentOutput = $Attachments.find('.attachmentOutput');
let $attachmentDownloadHost = null; let $attachmentDownloadHost = null;
let $dialogRemoveAttachment = null; let $dialogRemoveAttachment = null;
let attachmentUploader = null;
function onAttachmentAdded(id, quick) { function onAttachmentAdded(id, quick) {
var data = { id: id }; var data = { id: id };
@@ -459,7 +460,7 @@ WriteLiteral(@">
url: '"); url: '");
#line 66 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 67 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.Attachment())); Write(Url.Action(MVC.API.Device.Attachment()));
@@ -475,24 +476,28 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"anRemoveOwnAttachments\'))\r\n build" + "anRemoveOwnAttachments\'))\r\n build" +
"Attachment(a, (a.AuthorId === $Attachments.attr(\'data-userid\')), quick);\r\n " + "Attachment(a, (a.AuthorId === $Attachments.attr(\'data-userid\')), quick);\r\n " +
" else\r\n " + " else\r\n " +
" buildAttachment(a, false, quick);\r\n " + " buildAttachment(a, false, quick);\r\n\r\n " +
" } else {\r\n alert(\'Unable to ad" + " if (attachmentUploader && attachmentUploader.onlineUploadCloseDialo" +
"d attachment: \' + d.Result);\r\n }\r\n " + "g) {\r\n attachmentUploader.onlineU" +
" },\r\n error: func" + "ploadCloseDialog();\r\n }\r\n " +
"tion (jqXHR, textStatus, errorThrown) {\r\n " + " } else {\r\n " +
" alert(\'Unable to add attachment: \' + d.Result);\r\n " +
" }\r\n },\r\n " +
" error: function (jqXHR, textStatus, errorThrown) {\r\n " +
" alert(\'Unable to add attachment: \' + textStatus);\r\n " + " alert(\'Unable to add attachment: \' + textStatus);\r\n " +
" }\r\n });\r\n }\r\n\r" + " }\r\n });\r\n " +
"\n function buildAttachment(a, canRemove, quick) {\r\n " + " }\r\n\r\n function buildAttachment(a, ca" +
" var t = \'<a><span class=\"icon\"><img alt=\"Attachmen" + "nRemove, quick) {\r\n var t = \'<a><span class=\"icon" +
"t Thumbnail\" /></span><span class=\"comments\"></span><span class=\"author\"></span>" + "\"><img alt=\"Attachment Thumbnail\" /></span><span class=\"comments\"></span><span c" +
"\';\r\n if (canRemove)\r\n " + "lass=\"author\"></span>\';\r\n if (canRemove)\r\n " +
" t += \'<span class=\"remove fa fa-times-circle\"></span>\';\r\n " + " t += \'<span class=\"remove fa fa-times-circle\"></spa" +
" t += \'<span class=\"timestamp\"></span></a>\';\r\n\r\n " + "n>\';\r\n t += \'<span class=\"timestamp\"></span></a>\'" +
" var e = $(t);\r\n\r\n e.attr(\'data-at" + ";\r\n\r\n var e = $(t);\r\n\r\n " +
"tachmentid\', a.Id).attr(\'data-mimetype\', a.MimeType).attr(\'href\', \'"); " e.attr(\'data-attachmentid\', a.Id).attr(\'data-mimetype\', a.MimeType).attr(\'" +
"href\', \'");
#line 97 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 102 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentDownload())); Write(Url.Action(MVC.API.Device.AttachmentDownload()));
@@ -524,7 +529,7 @@ WriteLiteral(@"/' + a.Id);
img.attr('src', '"); img.attr('src', '");
#line 120 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 125 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentThumbnail())); Write(Url.Action(MVC.API.Device.AttachmentThumbnail()));
@@ -577,60 +582,60 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n
".onAttachmentRemoved = onAttachmentRemoved;\r\n\r\n"); ".onAttachmentRemoved = onAttachmentRemoved;\r\n\r\n");
#line 182 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 187 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 182 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 187 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canAddAttachments) if (canAddAttachments)
{ {
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n //#region Add Attachments\r\n " + WriteLiteral("\r\n //#region Add Attachments\r\n " +
" var attachmentUploader = new document.Disco.AttachmentUploader($Attachments)" + " attachmentUploader = new document.Disco.AttachmentUploader($Attachments);\r\n\r" +
";\r\n\r\n var $attachmentInput = $Attachments.find(\'.atta" + "\n var $attachmentInput = $Attachments.find(\'.attachme" +
"chmentInput\');\r\n $attachmentInput.find(\'.online-uploa" + "ntInput\');\r\n $attachmentInput.find(\'.online-upload\')." +
"d\').on(\'click\', function () {\r\n if ($(this).hasCl" + "on(\'click\', function () {\r\n if ($(this).hasClass(" +
"ass(\'disabled\'))\r\n alert(\'Disconnected from t" + "\'disabled\'))\r\n alert(\'Disconnected from the D" +
"he Disco ICT Server, please refresh this page and try again\');\r\n " + "isco ICT Server, please refresh this page and try again\');\r\n " +
" else\r\n attachmentUploader.onl" + " else\r\n attachmentUploader.onlineU" +
"ineUpload();\r\n });\r\n if (w" + "pload();\r\n });\r\n if (windo" +
"indow.location.protocol != \'https:\') {\r\n $attachm" + "w.location.protocol != \'https:\') {\r\n $attachmentI" +
"entInput.find(\'.photo\')\r\n .removeClass(\'enabl" + "nput.find(\'.photo\')\r\n .removeClass(\'enabled\')" +
"ed\')\r\n .addClass(\'disabled\')\r\n " + "\r\n .addClass(\'disabled\')\r\n " +
" .attr(\'title\', \'Capture Image: this functionality is only a" + " .attr(\'title\', \'Capture Image: this functionality is only avail" +
"vailable over a HTTPS connection\');\r\n }\r\n " + "able over a HTTPS connection\');\r\n }\r\n " +
" $attachmentInput.find(\'.photo\').click(function () {\r\n " + " $attachmentInput.find(\'.photo\').click(function () {\r\n " +
" if (!$(this).hasClass(\'enabled\'))\r\n " + " if (!$(this).hasClass(\'enabled\'))\r\n " +
" alert(\'This functionality is only available over a HTTPS connection\'" + " alert(\'This functionality is only available over a HTTPS connection\');\r\n" +
");\r\n else if ($(this).hasClass(\'disabled\'))\r\n " + " else if ($(this).hasClass(\'disabled\'))\r\n " +
" alert(\'Disconnected from the Disco ICT Server, p" + " alert(\'Disconnected from the Disco ICT Server, pleas" +
"lease refresh this page and try again\');\r\n else\r\n" + "e refresh this page and try again\');\r\n else\r\n " +
" attachmentUploader.uploadImage();\r\n " + " attachmentUploader.uploadImage();\r\n " +
" });\r\n $attachmentInput.find(\'.uplo" + " });\r\n $attachmentInput.find(\'.upload\')" +
"ad\').click(function () {\r\n if ($(this).hasClass(\'" + ".click(function () {\r\n if ($(this).hasClass(\'disa" +
"disabled\'))\r\n alert(\'Disconnected from the Di" + "bled\'))\r\n alert(\'Disconnected from the Disco " +
"sco ICT Server, please refresh this page and try again\');\r\n " + "ICT Server, please refresh this page and try again\');\r\n " +
" else\r\n attachmentUploader.uploadFi" + " else\r\n attachmentUploader.uploadFiles(" +
"les();\r\n });\r\n\r\n var resou" + ");\r\n });\r\n\r\n var resources" +
"rcesTab;\r\n $(document).on(\'dragover\', function () {\r\n" + "Tab;\r\n $(document).on(\'dragover\', function () {\r\n " +
" if (!resourcesTab) {\r\n " + " if (!resourcesTab) {\r\n " +
" var tabs = $Attachments.closest(\'.ui-tabs\');\r\n " + " var tabs = $Attachments.closest(\'.ui-tabs\');\r\n " +
" resourcesTab = {\r\n tabs: tabs" + " resourcesTab = {\r\n tabs: tabs,\r\n " +
",\r\n resourcesIndex: tabs.children(\'ul.ui-" + " resourcesIndex: tabs.children(\'ul.ui-tabs" +
"tabs-nav\').find(\'a[href=\"#DeviceDetailTab-Resources\"]\').closest(\'li\').index()\r\n " + "-nav\').find(\'a[href=\"#DeviceDetailTab-Resources\"]\').closest(\'li\').index()\r\n " +
" };\r\n }\r\n " + " };\r\n }\r\n " +
" var selectedIndex = resourcesTab.tabs.tabs(\'option\', \'" + " var selectedIndex = resourcesTab.tabs.tabs(\'option\', \'acti" +
"active\');\r\n if (resourcesTab.resourcesIndex !== s" + "ve\');\r\n if (resourcesTab.resourcesIndex !== selec" +
"electedIndex)\r\n resourcesTab.tabs.tabs(\'optio" + "tedIndex)\r\n resourcesTab.tabs.tabs(\'option\', " +
"n\', \'active\', resourcesTab.resourcesIndex);\r\n });\r\n " + "\'active\', resourcesTab.resourcesIndex);\r\n });\r\n " +
" //#endregion\r\n "); " //#endregion\r\n ");
#line 229 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 234 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
} }
@@ -639,7 +644,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
WriteLiteral(" "); WriteLiteral(" ");
#line 230 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 235 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
@@ -682,7 +687,7 @@ WriteLiteral("\r\n //#region Remove Attachments\r\n
" }\r\n //#endregion\r\n "); " }\r\n //#endregion\r\n ");
#line 281 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 286 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
} }
@@ -719,7 +724,7 @@ WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n <scr
"etailTab-ResourcesLink\">Attachments ["); "etailTab-ResourcesLink\">Attachments [");
#line 302 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line 307 "..\..\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);
@@ -298,11 +298,12 @@
//#region Attachments //#region Attachments
var $Attachments = $('#Attachments'); var $Attachments = $('#Attachments');
var $attachmentOutput = $Attachments.find('.attachmentOutput'); var $attachmentOutput = $Attachments.find('.attachmentOutput');
let attachmentUploader = null;
@if (canAddAttachments) @if (canAddAttachments)
{<text> {<text>
//#region Add Attachments //#region Add Attachments
var attachmentUploader = new document.Disco.AttachmentUploader($Attachments); attachmentUploader = new document.Disco.AttachmentUploader($Attachments);
var $attachmentInput = $Attachments.find('.attachmentInput'); var $attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.online-upload').on('click', function () { $attachmentInput.find('.online-upload').on('click', function () {
@@ -424,6 +425,10 @@
buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick); buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick);
else else
buildAttachment(a, false, quick); buildAttachment(a, false, quick);
if (attachmentUploader && attachmentUploader.onlineUploadCloseDialog) {
attachmentUploader.onlineUploadCloseDialog();
}
} else { } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
} }
@@ -989,55 +989,54 @@ WriteLiteral(@" <script>
#line hidden #line hidden
WriteLiteral("\');\r\n\r\n //#region Attachments\r\n var $Attachments = $(\'#Atta" + WriteLiteral("\');\r\n\r\n //#region Attachments\r\n var $Attachments = $(\'#Atta" +
"chments\');\r\n var $attachmentOutput = $Attachments.find(\'.attachmentOu" + "chments\');\r\n var $attachmentOutput = $Attachments.find(\'.attachmentOu" +
"tput\');\r\n\r\n"); "tput\');\r\n let attachmentUploader = null;\r\n\r\n");
#line 302 "..\..\Views\Job\JobParts\Resources.cshtml" #line 303 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 302 "..\..\Views\Job\JobParts\Resources.cshtml" #line 303 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canAddAttachments) if (canAddAttachments)
{ {
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n //#region Add Attachments\r\n var attachmentUploader = new" + WriteLiteral("\r\n //#region Add Attachments\r\n attachmentUploader = new doc" +
" document.Disco.AttachmentUploader($Attachments);\r\n\r\n var $attachment" + "ument.Disco.AttachmentUploader($Attachments);\r\n\r\n var $attachmentInpu" +
"Input = $Attachments.find(\'.attachmentInput\');\r\n $attachmentInput.fin" + "t = $Attachments.find(\'.attachmentInput\');\r\n $attachmentInput.find(\'." +
"d(\'.online-upload\').on(\'click\', function () {\r\n if ($(this).hasCl" + "online-upload\').on(\'click\', function () {\r\n if ($(this).hasClass(" +
"ass(\'disabled\'))\r\n alert(\'Disconnected from the Disco ICT Ser" + "\'disabled\'))\r\n alert(\'Disconnected from the Disco ICT Server," +
"ver, please refresh this page and try again\');\r\n else\r\n " + " please refresh this page and try again\');\r\n else\r\n " +
" attachmentUploader.onlineUpload();\r\n });\r\n if (w" + " attachmentUploader.onlineUpload();\r\n });\r\n if (windo" +
"indow.location.protocol != \'https:\') {\r\n $attachmentInput.find(\'." + "w.location.protocol != \'https:\') {\r\n $attachmentInput.find(\'.phot" +
"photo\')\r\n .removeClass(\'enabled\')\r\n .addCl" + "o\')\r\n .removeClass(\'enabled\')\r\n .addClass(" +
"ass(\'disabled\')\r\n .attr(\'title\', \'Capture Image: this functio" + "\'disabled\')\r\n .attr(\'title\', \'Capture Image: this functionali" +
"nality is only available over a HTTPS connection\');\r\n }\r\n " + "ty is only available over a HTTPS connection\');\r\n }\r\n $att" +
"$attachmentInput.find(\'.photo\').click(function () {\r\n if (!$(this" + "achmentInput.find(\'.photo\').click(function () {\r\n if (!$(this).ha" +
").hasClass(\'enabled\'))\r\n alert(\'This functionality is only av" + "sClass(\'enabled\'))\r\n alert(\'This functionality is only availa" +
"ailable over a HTTPS connection\');\r\n else if ($(this).hasClass(\'d" + "ble over a HTTPS connection\');\r\n else if ($(this).hasClass(\'disab" +
"isabled\'))\r\n alert(\'Disconnected from the Disco ICT Server, p" + "led\'))\r\n alert(\'Disconnected from the Disco ICT Server, pleas" +
"lease refresh this page and try again\');\r\n else\r\n " + "e refresh this page and try again\');\r\n else\r\n " +
" attachmentUploader.uploadImage();\r\n });\r\n $attachmentI" + "attachmentUploader.uploadImage();\r\n });\r\n $attachmentInput" +
"nput.find(\'.upload\').click(function () {\r\n if ($(this).hasClass(\'" + ".find(\'.upload\').click(function () {\r\n if ($(this).hasClass(\'disa" +
"disabled\'))\r\n alert(\'Disconnected from the Disco ICT Server, " + "bled\'))\r\n alert(\'Disconnected from the Disco ICT Server, plea" +
"please refresh this page and try again\');\r\n else\r\n " + "se refresh this page and try again\');\r\n else\r\n " +
" attachmentUploader.uploadFiles();\r\n });\r\n\r\n var resou" + " attachmentUploader.uploadFiles();\r\n });\r\n\r\n var resources" +
"rcesTab;\r\n $(document).on(\'dragover\', function () {\r\n " + "Tab;\r\n $(document).on(\'dragover\', function () {\r\n if (" +
"if (!resourcesTab) {\r\n var tabs = $Attachments.closest(\'.ui-t" + "!resourcesTab) {\r\n var tabs = $Attachments.closest(\'.ui-tabs\'" +
"abs\');\r\n resourcesTab = {\r\n tabs: tabs" + ");\r\n resourcesTab = {\r\n tabs: tabs,\r\n " +
",\r\n resourcesIndex: tabs.children(\'ul.ui-tabs-nav\').find(" + " resourcesIndex: tabs.children(\'ul.ui-tabs-nav\').find(\'a[h" +
"\'a[href=\"#jobDetailTab-Resources\"]\').closest(\'li\').index()\r\n " + "ref=\"#jobDetailTab-Resources\"]\').closest(\'li\').index()\r\n };\r\n" +
"};\r\n }\r\n var selectedIndex = resourcesTab.tabs.tab" + " }\r\n var selectedIndex = resourcesTab.tabs.tabs(\'o" +
"s(\'option\', \'active\');\r\n if (resourcesTab.resourcesIndex !== sele" + "ption\', \'active\');\r\n if (resourcesTab.resourcesIndex !== selected" +
"ctedIndex)\r\n resourcesTab.tabs.tabs(\'option\', \'active\', resou" + "Index)\r\n resourcesTab.tabs.tabs(\'option\', \'active\', resources" +
"rcesTab.resourcesIndex);\r\n });\r\n //#endregion\r\n " + "Tab.resourcesIndex);\r\n });\r\n //#endregion\r\n ");
" ");
#line 349 "..\..\Views\Job\JobParts\Resources.cshtml" #line 350 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -1046,13 +1045,13 @@ WriteLiteral("\r\n //#region Add Attachments\r\n var attac
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 351 "..\..\Views\Job\JobParts\Resources.cshtml" #line 352 "..\..\Views\Job\JobParts\Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 351 "..\..\Views\Job\JobParts\Resources.cshtml" #line 352 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
@@ -1105,7 +1104,7 @@ WriteLiteral("></i>&nbsp;Are you sure?</p></div>\')\r\n .
" }\r\n\r\n //#endregion\r\n\r\n "); " }\r\n\r\n //#endregion\r\n\r\n ");
#line 409 "..\..\Views\Job\JobParts\Resources.cshtml" #line 410 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -1115,7 +1114,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 414 "..\..\Views\Job\JobParts\Resources.cshtml" #line 415 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Url.Action(MVC.API.Job.Attachment())); Write(Url.Action(MVC.API.Job.Attachment()));
@@ -1129,22 +1128,25 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"lse if ($Attachments.hasClass(\'canRemoveOwnAttachments\'))\r\n " + "lse if ($Attachments.hasClass(\'canRemoveOwnAttachments\'))\r\n " +
" buildAttachment(a, (a.AuthorId === $Attachments.attr(\'data-userid\'))," + " buildAttachment(a, (a.AuthorId === $Attachments.attr(\'data-userid\'))," +
" quick);\r\n else\r\n buil" + " quick);\r\n else\r\n buil" +
"dAttachment(a, false, quick);\r\n } else {\r\n " + "dAttachment(a, false, quick);\r\n\r\n if (attachmentUploa" +
" alert(\'Unable to add attachment: \' + d.Result);\r\n " + "der && attachmentUploader.onlineUploadCloseDialog) {\r\n " +
" }\r\n },\r\n error: function (jqXHR, tex" + " attachmentUploader.onlineUploadCloseDialog();\r\n " +
"tStatus, errorThrown) {\r\n alert(\'Unable to add attachment" + " }\r\n } else {\r\n alert(\'Unable " +
": \' + textStatus);\r\n }\r\n });\r\n }\r\n " + "to add attachment: \' + d.Result);\r\n }\r\n " +
" function buildAttachment(a, canRemove, quick) {\r\n if (" + " },\r\n error: function (jqXHR, textStatus, errorThrown) {\r\n " +
"parseInt(a.ParentId) == jobId) {\r\n var t = \'<a><span class=\"i" + " alert(\'Unable to add attachment: \' + textStatus);\r\n " +
"con\"><img alt=\"Attachment Thumbnail\" /></span><span class=\"comments\"></span><spa" + " }\r\n });\r\n }\r\n function buildAt" +
"n class=\"author\"></span>\';\r\n if (canRemove)\r\n " + "tachment(a, canRemove, quick) {\r\n if (parseInt(a.ParentId) == job" +
" t += \'<span class=\"remove fa fa-times-circle\"></span>\';\r\n " + "Id) {\r\n var t = \'<a><span class=\"icon\"><img alt=\"Attachment T" +
" t += \'<span class=\"timestamp\"></span></a>\';\r\n\r\n var e = " + "humbnail\" /></span><span class=\"comments\"></span><span class=\"author\"></span>\';\r" +
"$(t);\r\n\r\n e.attr(\'data-attachmentid\', a.Id).attr(\'data-mimety" + "\n if (canRemove)\r\n t += \'<span class=\"" +
"pe\', a.MimeType).attr(\'href\', \'"); "remove fa fa-times-circle\"></span>\';\r\n t += \'<span class=\"tim" +
"estamp\"></span></a>\';\r\n\r\n var e = $(t);\r\n\r\n " +
" e.attr(\'data-attachmentid\', a.Id).attr(\'data-mimetype\', a.MimeType).attr(\'href" +
"\', \'");
#line 445 "..\..\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()));
@@ -1176,7 +1178,7 @@ WriteLiteral(@"/' + a.Id);
img.attr('src', '"); img.attr('src', '");
#line 468 "..\..\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()));
@@ -1223,14 +1225,14 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n };\
"script>\r\n"); "script>\r\n");
#line 538 "..\..\Views\Job\JobParts\Resources.cshtml" #line 543 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 539 "..\..\Views\Job\JobParts\Resources.cshtml" #line 544 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs || canShowAttachments) if (canShowLogs || canShowAttachments)
{ {
@@ -1240,7 +1242,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 543 "..\..\Views\Job\JobParts\Resources.cshtml" #line 548 "..\..\Views\Job\JobParts\Resources.cshtml"
Write(Model.Job.Id); Write(Model.Job.Id);
@@ -1250,7 +1252,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 549 "..\..\Views\Job\JobParts\Resources.cshtml" #line 554 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowLogs) if (canShowLogs)
{ {
@@ -1261,14 +1263,14 @@ WriteLiteral("\r\n hub.client.addLog = document.DiscoFunctions.liveLo
" "); " ");
#line 553 "..\..\Views\Job\JobParts\Resources.cshtml" #line 558 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 554 "..\..\Views\Job\JobParts\Resources.cshtml" #line 559 "..\..\Views\Job\JobParts\Resources.cshtml"
if (canShowAttachments) if (canShowAttachments)
{ {
@@ -1289,7 +1291,7 @@ WriteLiteral(@"
"); ");
#line 567 "..\..\Views\Job\JobParts\Resources.cshtml" #line 572 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
@@ -1331,7 +1333,7 @@ WriteLiteral("\r\n $.connection.hub.qs = { JobId: jobId };\r\n
"});\r\n\r\n //#endregion\r\n });\r\n </script>\r\n"); "});\r\n\r\n //#endregion\r\n });\r\n </script>\r\n");
#line 619 "..\..\Views\Job\JobParts\Resources.cshtml" #line 624 "..\..\Views\Job\JobParts\Resources.cshtml"
} }
#line default #line default
@@ -59,6 +59,7 @@
var $attachmentOutput = $Attachments.find('.attachmentOutput'); var $attachmentOutput = $Attachments.find('.attachmentOutput');
var $dialogRemoveAttachment = null; var $dialogRemoveAttachment = null;
let $attachmentDownloadHost = null; let $attachmentDownloadHost = null;
let attachmentUploader = null;
function onAttachmentAdded(id, quick) { function onAttachmentAdded(id, quick) {
var data = { id: id }; var data = { id: id };
@@ -76,6 +77,10 @@
buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick); buildAttachment(a, (a.AuthorId === $Attachments.attr('data-userid')), quick);
else else
buildAttachment(a, false, quick); buildAttachment(a, false, quick);
if (attachmentUploader && attachmentUploader.onlineUploadCloseDialog) {
attachmentUploader.onlineUploadCloseDialog();
}
} else { } else {
alert('Unable to add attachment: ' + d.Result); alert('Unable to add attachment: ' + d.Result);
} }
@@ -181,7 +186,7 @@
@if (canAddAttachments) @if (canAddAttachments)
{<text> {<text>
//#region Add Attachments //#region Add Attachments
var attachmentUploader = new document.Disco.AttachmentUploader($Attachments); attachmentUploader = new document.Disco.AttachmentUploader($Attachments);
var $attachmentInput = $Attachments.find('.attachmentInput'); var $attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.online-upload').on('click', function () { $attachmentInput.find('.online-upload').on('click', function () {
@@ -452,6 +452,7 @@ WriteLiteral(@">
var $attachmentOutput = $Attachments.find('.attachmentOutput'); var $attachmentOutput = $Attachments.find('.attachmentOutput');
var $dialogRemoveAttachment = null; var $dialogRemoveAttachment = null;
let $attachmentDownloadHost = null; let $attachmentDownloadHost = null;
let attachmentUploader = null;
function onAttachmentAdded(id, quick) { function onAttachmentAdded(id, quick) {
var data = { id: id }; var data = { id: id };
@@ -459,7 +460,7 @@ WriteLiteral(@">
url: '"); url: '");
#line 66 "..\..\Views\User\UserParts\_Resources.cshtml" #line 67 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.Attachment())); Write(Url.Action(MVC.API.User.Attachment()));
@@ -475,24 +476,28 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"anRemoveOwnAttachments\'))\r\n build" + "anRemoveOwnAttachments\'))\r\n build" +
"Attachment(a, (a.AuthorId === $Attachments.attr(\'data-userid\')), quick);\r\n " + "Attachment(a, (a.AuthorId === $Attachments.attr(\'data-userid\')), quick);\r\n " +
" else\r\n " + " else\r\n " +
" buildAttachment(a, false, quick);\r\n " + " buildAttachment(a, false, quick);\r\n\r\n " +
" } else {\r\n alert(\'Unable to ad" + " if (attachmentUploader && attachmentUploader.onlineUploadCloseDialo" +
"d attachment: \' + d.Result);\r\n }\r\n " + "g) {\r\n attachmentUploader.onlineU" +
" },\r\n error: func" + "ploadCloseDialog();\r\n }\r\n " +
"tion (jqXHR, textStatus, errorThrown) {\r\n " + " } else {\r\n " +
" alert(\'Unable to add attachment: \' + d.Result);\r\n " +
" }\r\n },\r\n " +
" error: function (jqXHR, textStatus, errorThrown) {\r\n " +
" alert(\'Unable to add attachment: \' + textStatus);\r\n " + " alert(\'Unable to add attachment: \' + textStatus);\r\n " +
" }\r\n });\r\n }\r\n " + " }\r\n });\r\n " +
" function buildAttachment(a, canRemove, quick) {\r\n " + " }\r\n function buildAttachment(a, canR" +
" var t = \'<a><span class=\"icon\"><img alt=\"Attachment " + "emove, quick) {\r\n var t = \'<a><span class=\"icon\">" +
"Thumbnail\" /></span><span class=\"comments\"></span><span class=\"author\"></span>\';" + "<img alt=\"Attachment Thumbnail\" /></span><span class=\"comments\"></span><span cla" +
"\r\n if (canRemove)\r\n " + "ss=\"author\"></span>\';\r\n if (canRemove)\r\n " +
" t += \'<span class=\"remove fa fa-times-circle\"></span>\';\r\n " + " t += \'<span class=\"remove fa fa-times-circle\"></span>" +
" t += \'<span class=\"timestamp\"></span></a>\';\r\n\r\n " + "\';\r\n t += \'<span class=\"timestamp\"></span></a>\';\r" +
" var e = $(t);\r\n\r\n e.attr(\'data-atta" + "\n\r\n var e = $(t);\r\n\r\n " +
"chmentid\', a.Id).attr(\'data-mimetype\', a.MimeType).attr(\'href\', \'"); " e.attr(\'data-attachmentid\', a.Id).attr(\'data-mimetype\', a.MimeType).attr(\'hr" +
"ef\', \'");
#line 96 "..\..\Views\User\UserParts\_Resources.cshtml" #line 101 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentDownload())); Write(Url.Action(MVC.API.User.AttachmentDownload()));
@@ -524,7 +529,7 @@ WriteLiteral(@"/' + a.Id);
img.attr('src', '"); img.attr('src', '");
#line 119 "..\..\Views\User\UserParts\_Resources.cshtml" #line 124 "..\..\Views\User\UserParts\_Resources.cshtml"
Write(Url.Action(MVC.API.User.AttachmentThumbnail())); Write(Url.Action(MVC.API.User.AttachmentThumbnail()));
@@ -577,60 +582,60 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n
"DiscoFunctions.onAttachmentRemoved = onAttachmentRemoved;\r\n\r\n"); "DiscoFunctions.onAttachmentRemoved = onAttachmentRemoved;\r\n\r\n");
#line 181 "..\..\Views\User\UserParts\_Resources.cshtml" #line 186 "..\..\Views\User\UserParts\_Resources.cshtml"
#line default #line default
#line hidden #line hidden
#line 181 "..\..\Views\User\UserParts\_Resources.cshtml" #line 186 "..\..\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 " + WriteLiteral("\r\n //#region Add Attachments\r\n " +
" var attachmentUploader = new document.Disco.AttachmentUploader($Attachments)" + " attachmentUploader = new document.Disco.AttachmentUploader($Attachments);\r\n\r" +
";\r\n\r\n var $attachmentInput = $Attachments.find(\'.atta" + "\n var $attachmentInput = $Attachments.find(\'.attachme" +
"chmentInput\');\r\n $attachmentInput.find(\'.online-uploa" + "ntInput\');\r\n $attachmentInput.find(\'.online-upload\')." +
"d\').on(\'click\', function () {\r\n if ($(this).hasCl" + "on(\'click\', function () {\r\n if ($(this).hasClass(" +
"ass(\'disabled\'))\r\n alert(\'Disconnected from t" + "\'disabled\'))\r\n alert(\'Disconnected from the D" +
"he Disco ICT Server, please refresh this page and try again\');\r\n " + "isco ICT Server, please refresh this page and try again\');\r\n " +
" else\r\n attachmentUploader.onl" + " else\r\n attachmentUploader.onlineU" +
"ineUpload();\r\n });\r\n if (w" + "pload();\r\n });\r\n if (windo" +
"indow.location.protocol != \'https:\') {\r\n $attachm" + "w.location.protocol != \'https:\') {\r\n $attachmentI" +
"entInput.find(\'.photo\')\r\n .removeClass(\'enabl" + "nput.find(\'.photo\')\r\n .removeClass(\'enabled\')" +
"ed\')\r\n .addClass(\'disabled\')\r\n " + "\r\n .addClass(\'disabled\')\r\n " +
" .attr(\'title\', \'Capture Image: this functionality is only a" + " .attr(\'title\', \'Capture Image: this functionality is only avail" +
"vailable over a HTTPS connection\');\r\n }\r\n " + "able over a HTTPS connection\');\r\n }\r\n " +
" $attachmentInput.find(\'.photo\').click(function () {\r\n " + " $attachmentInput.find(\'.photo\').click(function () {\r\n " +
" if (!$(this).hasClass(\'enabled\'))\r\n " + " if (!$(this).hasClass(\'enabled\'))\r\n " +
" alert(\'This functionality is only available over a HTTPS connection\'" + " alert(\'This functionality is only available over a HTTPS connection\');\r\n" +
");\r\n else if ($(this).hasClass(\'disabled\'))\r\n " + " else if ($(this).hasClass(\'disabled\'))\r\n " +
" alert(\'Disconnected from the Disco ICT Server, p" + " alert(\'Disconnected from the Disco ICT Server, pleas" +
"lease refresh this page and try again\');\r\n else\r\n" + "e refresh this page and try again\');\r\n else\r\n " +
" attachmentUploader.uploadImage();\r\n " + " attachmentUploader.uploadImage();\r\n " +
" });\r\n $attachmentInput.find(\'.uplo" + " });\r\n $attachmentInput.find(\'.upload\')" +
"ad\').click(function () {\r\n if ($(this).hasClass(\'" + ".click(function () {\r\n if ($(this).hasClass(\'disa" +
"disabled\'))\r\n alert(\'Disconnected from the Di" + "bled\'))\r\n alert(\'Disconnected from the Disco " +
"sco ICT Server, please refresh this page and try again\');\r\n " + "ICT Server, please refresh this page and try again\');\r\n " +
" else\r\n attachmentUploader.uploadFi" + " else\r\n attachmentUploader.uploadFiles(" +
"les();\r\n });\r\n\r\n var resou" + ");\r\n });\r\n\r\n var resources" +
"rcesTab;\r\n $(document).on(\'dragover\', function () {\r\n" + "Tab;\r\n $(document).on(\'dragover\', function () {\r\n " +
" if (!resourcesTab) {\r\n " + " if (!resourcesTab) {\r\n " +
" var tabs = $Attachments.closest(\'.ui-tabs\');\r\n " + " var tabs = $Attachments.closest(\'.ui-tabs\');\r\n " +
" resourcesTab = {\r\n tabs: tabs" + " resourcesTab = {\r\n tabs: tabs,\r\n " +
",\r\n resourcesIndex: tabs.children(\'ul.ui-" + " resourcesIndex: tabs.children(\'ul.ui-tabs" +
"tabs-nav\').find(\'a[href=\"#UserDetailTab-Resources\"]\').closest(\'li\').index()\r\n " + "-nav\').find(\'a[href=\"#UserDetailTab-Resources\"]\').closest(\'li\').index()\r\n " +
" };\r\n }\r\n " + " };\r\n }\r\n " +
" var selectedIndex = resourcesTab.tabs.tabs(\'option\', \'ac" + " var selectedIndex = resourcesTab.tabs.tabs(\'option\', \'active" +
"tive\');\r\n if (resourcesTab.resourcesIndex !== sel" + "\');\r\n if (resourcesTab.resourcesIndex !== selecte" +
"ectedIndex)\r\n resourcesTab.tabs.tabs(\'option\'" + "dIndex)\r\n resourcesTab.tabs.tabs(\'option\', \'a" +
", \'active\', resourcesTab.resourcesIndex);\r\n });\r\n " + "ctive\', resourcesTab.resourcesIndex);\r\n });\r\n " +
" //#endregion\r\n "); " //#endregion\r\n ");
#line 228 "..\..\Views\User\UserParts\_Resources.cshtml" #line 233 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
@@ -639,7 +644,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
WriteLiteral(" "); WriteLiteral(" ");
#line 229 "..\..\Views\User\UserParts\_Resources.cshtml" #line 234 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
@@ -683,7 +688,7 @@ WriteLiteral("\r\n //#region Remove Attachments\r\n\r
""); "");
#line 282 "..\..\Views\User\UserParts\_Resources.cshtml" #line 287 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
@@ -707,7 +712,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 298 "..\..\Views\User\UserParts\_Resources.cshtml" #line 303 "..\..\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);
@@ -716,7 +721,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 301 "..\..\Views\User\UserParts\_Resources.cshtml" #line 306 "..\..\Views\User\UserParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments) if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{ {
@@ -738,7 +743,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 308 "..\..\Views\User\UserParts\_Resources.cshtml" #line 313 "..\..\Views\User\UserParts\_Resources.cshtml"
} }
#line default #line default