Update: SignalR 2.0.3 Migration; Noticeboards

Migrate all SignalR 1.x Persistent Connections to SignalR 2.x Hubs.
Abstracts ScheduledTaskStatus with core interface and adds a Mock for
optional status reporting. Noticeboards rewritten (with new theme) to be
more resilient and accurate.
This commit is contained in:
Gary Sharp
2014-06-01 23:27:07 +10:00
parent f6fae26bc7
commit 4cd57f4a90
116 changed files with 9874 additions and 6462 deletions
@@ -8,8 +8,9 @@
Html.BundleDeferred("~/Style/Shadowbox");
Html.BundleDeferred("~/ClientScripts/Modules/Shadowbox");
Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR");
if (Authorization.Has(Claims.Device.Actions.AddAttachments))
if (canAddAttachments)
{
Html.BundleDeferred("~/ClientScripts/Modules/Silverlight");
}
@@ -49,68 +50,30 @@
modal: true
});
$(function () {
$Attachments = $('#Attachments');
$attachmentOutput = $Attachments.find('.attachmentOutput');
var $Attachments = $('#Attachments');
var $attachmentOutput = $Attachments.find('.attachmentOutput');
@if (canAddAttachments)
{<text>
//#region Add Attachments
if (!document.DiscoFunctions) {
document.DiscoFunctions = {};
var $dialogUpload = null;
var $dialogRemoveAttachment = null;
// Connect to Hub
var hub = $.connection.deviceUpdates;
// Map Functions
hub.client.addAttachment = onAddAttachment;
hub.client.removeAttachment = onRemoveAttachment;
$.connection.hub.qs = { DeviceSerialNumber: '@(Model.Device.SerialNumber)' };
$.connection.hub.error(onHubError);
// Start Connection
$.connection.hub.start().fail(onHubError);
function onHubError(error) {
alert('Live-update Error: ' + error);
}
document.DiscoFunctions.addAttachment = addAttachment;
$('#dialogUpload').dialog({
autoOpen: false,
draggable: false,
modal: true,
resizable: false,
width: 860,
height: 550,
close: function () {
silverlightUploadAttachment.content.Navigator.Navigate('/Hidden');
}
});
var onLoadNavigation = null;
var isLoaded = null;
Silverlight.createObject(
'@(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap)',
$('#silverlightHostUploadAttachment').get(0),
'silverlightUploadAttachment',
{ width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' },
{
onLoad: function () {
if (onLoadNavigation) {
silverlightUploadAttachment.content.Navigator.Navigate(onLoadNavigation);
isLoaded = true;
}
}
},
'UploadUrl=@(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)))'
);
$attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.photo').click(function () {
showDialog('/WebCam');
});
$attachmentInput.find('.upload').click(function () {
showDialog('/File');
});
silverlightUploadAttachment = $('#silverlightUploadAttachment').get(0);
function showDialog(navigationPath) {
$('#dialogUpload').dialog('open');
if (isLoaded) {
silverlightUploadAttachment.content.Navigator.Navigate(navigationPath);
} else {
onLoadNavigation = navigationPath;
}
};
function addAttachment(id, quick) {
function onAddAttachment(id, quick) {
var data = { id: id };
$.ajax({
url: '@Url.Action(MVC.API.Device.Attachment())',
@@ -135,10 +98,10 @@
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) {
@@ -159,12 +122,90 @@
if (!quick)
e.hide();
$attachmentOutput.append(e);
onUpdate();
if (!quick)
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Comments });
}
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 + ']';
$('#DeviceDetailTab-ResourcesLink').text(tabHeading);
}
@if (canAddAttachments)
{<text>
//#region Add Attachments
if (!document.DiscoFunctions) {
document.DiscoFunctions = {};
}
document.DiscoFunctions.addAttachment = function (Id) { return; /* Silverlight notification, do nothing use SignalR */ };
var $attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.photo').click(function () {
showDialog('/WebCam');
});
$attachmentInput.find('.upload').click(function () {
showDialog('/File');
});
var silverlightOnLoadNavigation = null;
var silverlightIsLoaded = null;
function showDialog(navigationPath) {
if (!$dialogUpload) {
$dialogUpload = $('#dialogUpload').dialog({
autoOpen: false,
draggable: false,
modal: true,
resizable: false,
width: 860,
height: 550,
close: function () {
var sl = $('#silverlightUploadAttachment').get(0);
if (sl.content)
sl.content.Navigator.Navigate('/Hidden');
}
});
Silverlight.createObject('@(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap)',
$('#silverlightHostUploadAttachment').get(0),
'silverlightUploadAttachment',
{ width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' },
{
onLoad: function () {
if (silverlightOnLoadNavigation) {
$('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(silverlightOnLoadNavigation);
silverlightIsLoaded = true;
}
}
},
'UploadUrl=@(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)))');
}
$dialogUpload.dialog('open');
if (silverlightIsLoaded) {
$('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(navigationPath);
} else {
silverlightOnLoadNavigation = navigationPath;
}
};
//#endregion
</text>}
@if (canRemoveAnyAttachments || canRemoveOwnAttachments)
@@ -172,18 +213,20 @@
//#region Remove Attachments
$attachmentOutput.find('span.remove').click(removeAttachment);
$('#dialogRemoveAttachment').dialog({
resizable: false,
height: 140,
modal: true,
autoOpen: false
});
function removeAttachment() {
$this = $(this).closest('a');
var data = { id: $this.attr('data-attachmentid') };
var $dialogRemoveAttachment = $('#dialogRemoveAttachment');
if (!$dialogRemoveAttachment) {
$dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({
resizable: false,
height: 140,
modal: true,
autoOpen: false
});
}
$dialogRemoveAttachment.dialog("enable");
$dialogRemoveAttachment.dialog('option', 'buttons', {
"Remove": function () {
@@ -195,13 +238,7 @@
data: data,
success: function (d) {
if (d == 'OK') {
$this.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();
});
// Do nothing, await SignalR notification
} else {
alert('Unable to remove attachment: ' + d);
}
@@ -213,7 +250,7 @@
}
});
},
"Cancel": function () {
Cancel: function () {
$dialogRemoveAttachment.dialog("close");
}
});
@@ -225,12 +262,12 @@
//#endregion
</text>}
$attachmentOutput.children('a').each(function () {
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
$attachmentOutput.children('a').each(function () {
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
});
});
});
</script>
</td>
</tr>
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
// Runtime Version:4.0.30319.34014
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -55,8 +55,9 @@ namespace Disco.Web.Views.Device.DeviceParts
Html.BundleDeferred("~/Style/Shadowbox");
Html.BundleDeferred("~/ClientScripts/Modules/Shadowbox");
Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR");
if (Authorization.Has(Claims.Device.Actions.AddAttachments))
if (canAddAttachments)
{
Html.BundleDeferred("~/ClientScripts/Modules/Silverlight");
}
@@ -78,14 +79,14 @@ WriteLiteral(">\r\n <tr>\r\n <td");
WriteLiteral(" id=\"Attachments\"");
WriteAttribute("class", Tuple.Create(" class=\"", 796), Tuple.Create("\"", 871)
WriteAttribute("class", Tuple.Create(" class=\"", 826), Tuple.Create("\"", 901)
#line 20 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 804), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments"
#line 21 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 834), Tuple.Create<System.Object, System.Int32>(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments"
#line default
#line hidden
, 804), false)
, 834), false)
);
WriteLiteral(">\r\n <div");
@@ -95,13 +96,13 @@ WriteLiteral(" class=\"attachmentOutput\"");
WriteLiteral(">\r\n");
#line 22 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 23 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default
#line hidden
#line 22 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 23 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (Model.Device.DeviceAttachments != null)
{
foreach (var da in Model.Device.DeviceAttachments)
@@ -112,20 +113,20 @@ WriteLiteral(">\r\n");
#line hidden
WriteLiteral(" <a");
WriteAttribute("href", Tuple.Create(" href=\"", 1141), Tuple.Create("\"", 1201)
WriteAttribute("href", Tuple.Create(" href=\"", 1171), Tuple.Create("\"", 1231)
#line 26 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1148), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentDownload(da.Id))
#line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1178), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentDownload(da.Id))
#line default
#line hidden
, 1148), false)
, 1178), false)
);
WriteLiteral(" data-attachmentid=\"");
#line 26 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.Id);
@@ -136,7 +137,7 @@ WriteLiteral("\"");
WriteLiteral(" data-mimetype=\"");
#line 26 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.MimeType);
@@ -148,68 +149,68 @@ WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"icon\"");
WriteAttribute("title", Tuple.Create(" title=\"", 1307), Tuple.Create("\"", 1327)
WriteAttribute("title", Tuple.Create(" title=\"", 1337), Tuple.Create("\"", 1357)
#line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1315), Tuple.Create<System.Object, System.Int32>(da.Filename
#line 28 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1345), Tuple.Create<System.Object, System.Int32>(da.Filename
#line default
#line hidden
, 1315), false)
, 1345), false)
);
WriteLiteral(">\r\n <img");
WriteLiteral(" alt=\"Attachment Thumbnail\"");
WriteAttribute("src", Tuple.Create(" src=\"", 1394), Tuple.Create("\"", 1456)
WriteAttribute("src", Tuple.Create(" src=\"", 1424), Tuple.Create("\"", 1486)
#line 28 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1400), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentThumbnail(da.Id))
#line 29 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1430), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentThumbnail(da.Id))
#line default
#line hidden
, 1400), false)
, 1430), false)
);
WriteLiteral(" /></span>\r\n <span");
WriteLiteral(" class=\"comments\"");
WriteAttribute("title", Tuple.Create(" title=\"", 1519), Tuple.Create("\"", 1539)
WriteAttribute("title", Tuple.Create(" title=\"", 1549), Tuple.Create("\"", 1569)
#line 29 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1527), Tuple.Create<System.Object, System.Int32>(da.Comments
#line 30 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 1557), Tuple.Create<System.Object, System.Int32>(da.Comments
#line default
#line hidden
, 1527), false)
, 1557), false)
);
WriteLiteral(">\r\n");
#line 30 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default
#line hidden
#line 30 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (!string.IsNullOrEmpty(da.DocumentTemplateId))
{
#line default
#line hidden
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 32 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.DocumentTemplate.Description);
#line default
#line hidden
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 32 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
else
{
@@ -217,14 +218,14 @@ WriteLiteral(">\r\n");
#line default
#line hidden
#line 33 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 34 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.Comments);
#line default
#line hidden
#line 33 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 34 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
#line default
@@ -236,7 +237,7 @@ WriteLiteral(" class=\"author\"");
WriteLiteral(">");
#line 34 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.TechUser.ToString());
@@ -245,7 +246,7 @@ WriteLiteral(">");
WriteLiteral("</span>");
#line 34 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canRemoveAnyAttachments || (canRemoveOwnAttachments && da.TechUserId == CurrentUser.UserId))
{
@@ -258,7 +259,7 @@ WriteLiteral(" class=\"remove fa fa-times-circle\"");
WriteLiteral("></span>");
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
#line default
@@ -267,20 +268,20 @@ WriteLiteral("<span");
WriteLiteral(" class=\"timestamp\"");
WriteAttribute("title", Tuple.Create(" title=\"", 2148), Tuple.Create("\"", 2186)
WriteAttribute("title", Tuple.Create(" title=\"", 2178), Tuple.Create("\"", 2216)
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 2156), Tuple.Create<System.Object, System.Int32>(da.Timestamp.ToFullDateTime()
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
, Tuple.Create(Tuple.Create("", 2186), Tuple.Create<System.Object, System.Int32>(da.Timestamp.ToFullDateTime()
#line default
#line hidden
, 2156), false)
, 2186), false)
);
WriteLiteral(" data-livestamp=\"");
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.Timestamp.ToUnixEpoc());
@@ -291,7 +292,7 @@ WriteLiteral("\"");
WriteLiteral(">");
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(da.Timestamp.ToFullDateTime());
@@ -300,7 +301,7 @@ WriteLiteral(">");
WriteLiteral("</span>\r\n </a> \r\n");
#line 37 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 38 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
}
@@ -310,13 +311,13 @@ WriteLiteral("</span>\r\n </a> \r\n");
WriteLiteral(" </div>\r\n");
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default
#line hidden
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canAddAttachments)
{
@@ -342,7 +343,7 @@ WriteLiteral(" title=\"Capture Image\"");
WriteLiteral("></span>\r\n </div>\r\n");
#line 45 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 46 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
@@ -358,106 +359,45 @@ WriteLiteral(@">
modal: true
});
$(function () {
$Attachments = $('#Attachments');
$attachmentOutput = $Attachments.find('.attachmentOutput');
var $Attachments = $('#Attachments');
var $attachmentOutput = $Attachments.find('.attachmentOutput');
");
var $dialogUpload = null;
var $dialogRemoveAttachment = null;
// Connect to Hub
var hub = $.connection.deviceUpdates;
// Map Functions
hub.client.addAttachment = onAddAttachment;
hub.client.removeAttachment = onRemoveAttachment;
$.connection.hub.qs = { DeviceSerialNumber: '");
#line 55 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 66 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Model.Device.SerialNumber);
#line default
#line hidden
#line 55 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canAddAttachments)
{
#line default
#line hidden
WriteLiteral(@"
//#region Add Attachments
if (!document.DiscoFunctions) {
document.DiscoFunctions = {};
WriteLiteral(@"' };
$.connection.hub.error(onHubError);
// Start Connection
$.connection.hub.start().fail(onHubError);
function onHubError(error) {
alert('Live-update Error: ' + error);
}
document.DiscoFunctions.addAttachment = addAttachment;
$('#dialogUpload').dialog({
autoOpen: false,
draggable: false,
modal: true,
resizable: false,
width: 860,
height: 550,
close: function () {
silverlightUploadAttachment.content.Navigator.Navigate('/Hidden');
}
});
var onLoadNavigation = null;
var isLoaded = null;
Silverlight.createObject(
'");
#line 80 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap);
#line default
#line hidden
WriteLiteral(@"',
$('#silverlightHostUploadAttachment').get(0),
'silverlightUploadAttachment',
{ width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' },
{
onLoad: function () {
if (onLoadNavigation) {
silverlightUploadAttachment.content.Navigator.Navigate(onLoadNavigation);
isLoaded = true;
}
}
},
'UploadUrl=");
#line 92 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)));
#line default
#line hidden
WriteLiteral(@"'
);
$attachmentInput = $Attachments.find('.attachmentInput');
$attachmentInput.find('.photo').click(function () {
showDialog('/WebCam');
});
$attachmentInput.find('.upload').click(function () {
showDialog('/File');
});
silverlightUploadAttachment = $('#silverlightUploadAttachment').get(0);
function showDialog(navigationPath) {
$('#dialogUpload').dialog('open');
if (isLoaded) {
silverlightUploadAttachment.content.Navigator.Navigate(navigationPath);
} else {
onLoadNavigation = navigationPath;
}
};
function addAttachment(id, quick) {
function onAddAttachment(id, quick) {
var data = { id: id };
$.ajax({
url: '");
#line 116 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 79 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.Attachment()));
@@ -472,13 +412,13 @@ WriteLiteral(@"',
");
#line 122 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 85 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default
#line hidden
#line 122 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 85 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canRemoveAnyAttachments)
{
@@ -492,7 +432,7 @@ WriteLiteral("buildAttachment(a, true, quick);");
WriteLiteral("\r\n");
#line 125 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 88 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
else if (canRemoveOwnAttachments)
{
@@ -505,7 +445,7 @@ WriteLiteral(" ");
WriteLiteral("buildAttachment(a, (a.AuthorId === \'");
#line 128 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 91 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(CurrentUser.UserId);
@@ -516,7 +456,7 @@ WriteLiteral("\'), quick);");
WriteLiteral("\r\n");
#line 129 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 92 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
else
{
@@ -531,7 +471,7 @@ WriteLiteral("buildAttachment(a, false, quick);");
WriteLiteral("\r\n");
#line 133 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 96 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
@@ -541,44 +481,24 @@ WriteLiteral(@" } else {
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");
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>';
WriteLiteral(" class=\"icon\"");
var e = $(t);
WriteLiteral("><img");
WriteLiteral(" alt=\"Attachment Thumbnail\"");
WriteLiteral(" /></span><span");
WriteLiteral(" class=\"comments\"");
WriteLiteral("></span><span");
WriteLiteral(" class=\"author\"");
WriteLiteral("></span>\';\r\n if (canRemove)\r\n " +
" t += \'<span");
WriteLiteral(" class=\"remove fa fa-times-circle\"");
WriteLiteral("></span>\';\r\n t += \'<span");
WriteLiteral(" class=\"timestamp\"");
WriteLiteral("></span></a>\';\r\n\r\n var e = $(t);\r\n\r\n " +
" e.attr(\'data-attachmentid\', a.Id).attr(\'data-mimetype\', a.MimeType).at" +
"tr(\'href\', \'");
e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '");
#line 152 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 115 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentDownload()));
@@ -587,32 +507,118 @@ WriteLiteral("></span></a>\';\r\n\r\n var e = $(t);\r
WriteLiteral("/\' + a.Id);\r\n e.find(\'.icon img\').attr(\'src\', \'");
#line 153 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 116 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentThumbnail()));
#line default
#line hidden
WriteLiteral(@"/' + a.Id);
e.find('.comments').text(a.Comments);
e.find('.author').text(a.Author);
e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc);
if (canRemove)
e.find('.remove').click(removeAttachment);
if (!quick)
e.hide();
$attachmentOutput.append(e);
if (!quick)
e.show('slow');
if (a.MimeType.toLowerCase().indexOf('image/') == 0)
e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Comments });
}
WriteLiteral("/\' + a.Id);\r\n e.find(\'.comments\').text(a.Comments);\r\n " +
" e.find(\'.author\').text(a.Author);\r\n " +
" e.find(\'.timestamp\').text(a.TimestampFull).attr(\'title\', a.TimestampFu" +
"ll).livestamp(a.TimestampUnixEpoc);\r\n if (canRemove)\r" +
"\n e.find(\'.remove\').click(removeAttachment);\r\n " +
" if (!quick)\r\n e.hide();\r" +
"\n $attachmentOutput.append(e);\r\n " +
" onUpdate();\r\n if (!quick)\r\n " +
" e.show(\'slow\');\r\n if (a.MimeType.toLower" +
"Case().indexOf(\'image/\') == 0)\r\n e.shadowbox({ ga" +
"llery: \'attachments\', player: \'img\', title: a.Comments });\r\n " +
" }\r\n\r\n function onRemoveAttachment(id) {\r\n " +
" var 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 " +
" Shadowbox.removeCache(this);\r\n " +
" $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n " +
" $this.remove();\r\n onUpdate();\r\n " +
" });\r\n }\r\n\r\n " +
" function onUpdate() {\r\n var attachmentCount = $attac" +
"hmentOutput.children(\'a\').length;\r\n var tabHeading = " +
"\'Attachments [\' + attachmentCount + \']\';\r\n $(\'#Device" +
"DetailTab-ResourcesLink\').text(tabHeading);\r\n }\r\n\r\n");
#line 151 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line default
#line hidden
#line 151 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canAddAttachments)
{
#line default
#line hidden
WriteLiteral("\r\n //#region Add Attachments\r\n if (" +
"!document.DiscoFunctions) {\r\n document.DiscoFunctions" +
" = {};\r\n }\r\n document.DiscoFunctio" +
"ns.addAttachment = function (Id) { return; /* Silverlight notification, do nothi" +
"ng use SignalR */ };\r\n\r\n var $attachmentInput = $Attachme" +
"nts.find(\'.attachmentInput\');\r\n $attachmentInput.find(\'.p" +
"hoto\').click(function () {\r\n showDialog(\'/WebCam\');\r\n" +
" });\r\n $attachmentInput.find(\'.upl" +
"oad\').click(function () {\r\n showDialog(\'/File\');\r\n " +
" });\r\n\r\n var silverlightOnLoadNavigat" +
"ion = null;\r\n var silverlightIsLoaded = null;\r\n\r\n " +
" function showDialog(navigationPath) {\r\n " +
" if (!$dialogUpload) {\r\n $dialogUpload = $(\'#di" +
"alogUpload\').dialog({\r\n autoOpen: false,\r\n " +
" draggable: false,\r\n " +
" modal: true,\r\n resizable: false,\r\n " +
" width: 860,\r\n " +
" height: 550,\r\n close: function () {\r\n " +
" var sl = $(\'#silverlightUploadAttachment\').get" +
"(0);\r\n if (sl.content)\r\n " +
" sl.content.Navigator.Navigate(\'/Hidden\');\r\n " +
" }\r\n });\r\n\r\n " +
" Silverlight.createObject(\'");
#line 186 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap);
#line default
#line hidden
WriteLiteral(@"',
$('#silverlightHostUploadAttachment').get(0),
'silverlightUploadAttachment',
{ width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' },
{
onLoad: function () {
if (silverlightOnLoadNavigation) {
$('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(silverlightOnLoadNavigation);
silverlightIsLoaded = true;
}
}
},
'UploadUrl=");
#line 198 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)));
#line default
#line hidden
WriteLiteral(@"');
}
$dialogUpload.dialog('open');
if (silverlightIsLoaded) {
$('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(navigationPath);
} else {
silverlightOnLoadNavigation = navigationPath;
}
};
//#endregion
");
#line 169 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 210 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
@@ -621,7 +627,7 @@ WriteLiteral(@"/' + a.Id);
WriteLiteral(" ");
#line 170 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 211 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
if (canRemoveAnyAttachments || canRemoveOwnAttachments)
{
@@ -631,18 +637,20 @@ WriteLiteral(@"
//#region Remove Attachments
$attachmentOutput.find('span.remove').click(removeAttachment);
$('#dialogRemoveAttachment').dialog({
resizable: false,
height: 140,
modal: true,
autoOpen: false
});
function removeAttachment() {
$this = $(this).closest('a');
var data = { id: $this.attr('data-attachmentid') };
var $dialogRemoveAttachment = $('#dialogRemoveAttachment');
if (!$dialogRemoveAttachment) {
$dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({
resizable: false,
height: 140,
modal: true,
autoOpen: false
});
}
$dialogRemoveAttachment.dialog(""enable"");
$dialogRemoveAttachment.dialog('option', 'buttons', {
""Remove"": function () {
@@ -652,52 +660,55 @@ WriteLiteral(@"
url: '");
#line 193 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 236 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Url.Action(MVC.API.Device.AttachmentRemove()));
#line default
#line hidden
WriteLiteral("\',\r\n dataType: \'json\',\r\n " +
" data: data,\r\n succe" +
"ss: function (d) {\r\n if (d == \'OK\') {" +
"\r\n $this.hide(300).delay(300).que" +
"ue(function () {\r\n var $this " +
"= $(this);\r\n if ($this.attr(\'" +
"data-mimetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n " +
" Shadowbox.removeCache(this);\r\n " +
" $this.find(\'.timestamp\').livestamp(\'destroy\');\r" +
"\n $this.remove();\r\n " +
" });\r\n " +
" } else {\r\n alert(\'Unable t" +
"o remove attachment: \' + d);\r\n }\r\n " +
" $dialogRemoveAttachment.dialog(\"close\")" +
";\r\n },\r\n " +
" error: function (jqXHR, textStatus, errorThrown) {\r\n " +
" alert(\'Unable to remove attachment: \' + textStatus);\r\n " +
" $dialogRemoveAttachment.dialog(\"close\")" +
";\r\n }\r\n " +
" });\r\n },\r\n \"Canc" +
"el\": function () {\r\n $dialogRemoveAttachment." +
"dialog(\"close\");\r\n }\r\n " +
" });\r\n\r\n $dialogRemoveAttachment.dialog(\'open\');\r\n\r\n " +
" return false;\r\n }\r\n " +
" //#endregion\r\n ");
WriteLiteral(@"',
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
");
#line 226 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 263 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
}
#line default
#line hidden
WriteLiteral(@"
$attachmentOutput.children('a').each(function () {
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
$attachmentOutput.children('a').each(function () {
$this = $(this);
if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0)
$this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() });
});
});
});
</script>
</td>
</tr>
@@ -731,7 +742,7 @@ WriteLiteral("></i>&nbsp;Are you sure?\r\n </p>\r\n </div>\r\n <scr
"etailTab-ResourcesLink\">Attachments [");
#line 248 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
#line 285 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
Write(Model.Device.DeviceAttachments == null ? 0 : Model.Device.DeviceAttachments.Count);