security: use more antiforgery tokens
This commit is contained in:
@@ -6,16 +6,20 @@
|
||||
<div id="DeviceDetailTab-Certificates" class="DevicePart">
|
||||
<div class="genericData certificateTable">
|
||||
@if (Model.Certificates.Count() > 0)
|
||||
{
|
||||
{
|
||||
<table class="genericData certificateTable">
|
||||
<tr>
|
||||
<th>Name
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>Enabled
|
||||
<th>
|
||||
Enabled
|
||||
</th>
|
||||
<th>Allocated
|
||||
<th>
|
||||
Allocated
|
||||
</th>
|
||||
<th>Expires
|
||||
<th>
|
||||
Expires
|
||||
</th>
|
||||
</tr>
|
||||
@foreach (var item in Model.Certificates)
|
||||
@@ -24,7 +28,7 @@
|
||||
<td>
|
||||
@if (hasDownloadCert)
|
||||
{
|
||||
@Html.ActionLink(item.Name, MVC.API.DeviceCertificate.Download(item.Id))
|
||||
<a href="#" class="certificateDownload" data-id="@item.Id">@item.Name</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -43,9 +47,28 @@
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
if (hasDownloadCert)
|
||||
{
|
||||
using (Html.BeginForm(MVC.API.DeviceCertificate.Download()))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="hidden" name="id" />
|
||||
}
|
||||
<script>
|
||||
$(function () {
|
||||
$('#DeviceDetailTab-Certificates').on('click', '.certificateDownload', function (e) {
|
||||
e.preventDefault();
|
||||
const form = $('#DeviceDetailTab-Certificates').find('form');
|
||||
form.find('input[name="id"]').val($(this).attr('data-id'));
|
||||
form.trigger('submit');
|
||||
return false;
|
||||
})
|
||||
})
|
||||
</script>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
<span class="smallMessage">No Certificates Allocated</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -73,7 +73,7 @@ WriteLiteral(">\r\n");
|
||||
|
||||
#line 8 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
if (Model.Certificates.Count() > 0)
|
||||
{
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
@@ -84,25 +84,29 @@ WriteLiteral(" class=\"genericData certificateTable\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<tr>
|
||||
<th>Name
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>Enabled
|
||||
<th>
|
||||
Enabled
|
||||
</th>
|
||||
<th>Allocated
|
||||
<th>
|
||||
Allocated
|
||||
</th>
|
||||
<th>Expires
|
||||
<th>
|
||||
Expires
|
||||
</th>
|
||||
</tr>
|
||||
");
|
||||
|
||||
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 25 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 25 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
foreach (var item in Model.Certificates)
|
||||
{
|
||||
|
||||
@@ -112,29 +116,49 @@ WriteLiteral(@">
|
||||
WriteLiteral(" <tr>\r\n <td>\r\n");
|
||||
|
||||
|
||||
#line 25 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 29 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 25 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 29 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
if (hasDownloadCert)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 27 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(Html.ActionLink(item.Name, MVC.API.DeviceCertificate.Download(item.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" class=\"certificateDownload\"");
|
||||
|
||||
WriteLiteral(" data-id=\"");
|
||||
|
||||
|
||||
#line 27 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(item.Id);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(item.Name);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</a>\r\n");
|
||||
|
||||
|
||||
#line 32 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -143,14 +167,14 @@ WriteLiteral(" <tr>\r\n <td>\r\n");
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 35 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(item.Name);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 35 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
|
||||
}
|
||||
|
||||
@@ -162,7 +186,7 @@ WriteLiteral(" </td>\r\n <td>\r\n"
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 35 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 39 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(item.Enabled);
|
||||
|
||||
|
||||
@@ -173,7 +197,7 @@ WriteLiteral("\r\n </td>\r\n <td>\
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 38 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 42 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(CommonHelpers.FriendlyDate(item.AllocatedDate));
|
||||
|
||||
|
||||
@@ -184,7 +208,7 @@ WriteLiteral("\r\n </td>\r\n <td>\
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 41 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 45 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(CommonHelpers.FriendlyDate(item.ExpirationDate));
|
||||
|
||||
|
||||
@@ -193,7 +217,7 @@ WriteLiteral(" ");
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 44 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 48 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -202,10 +226,63 @@ WriteLiteral("\r\n </td>\r\n </tr>\r\n
|
||||
WriteLiteral(" </table>\r\n");
|
||||
|
||||
|
||||
#line 46 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 50 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
if (hasDownloadCert)
|
||||
{
|
||||
using (Html.BeginForm(MVC.API.DeviceCertificate.Download()))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 54 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(Html.AntiForgeryToken());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 54 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <input");
|
||||
|
||||
WriteLiteral(" type=\"hidden\"");
|
||||
|
||||
WriteLiteral(" name=\"id\"");
|
||||
|
||||
WriteLiteral(" />\r\n");
|
||||
|
||||
|
||||
#line 56 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(@" <script>
|
||||
$(function () {
|
||||
$('#DeviceDetailTab-Certificates').on('click', '.certificateDownload', function (e) {
|
||||
e.preventDefault();
|
||||
const form = $('#DeviceDetailTab-Certificates').find('form');
|
||||
form.find('input[name=""id""]').val($(this).attr('data-id'));
|
||||
form.trigger('submit');
|
||||
return false;
|
||||
})
|
||||
})
|
||||
</script>
|
||||
");
|
||||
|
||||
|
||||
#line 68 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
@@ -217,7 +294,7 @@ WriteLiteral(" class=\"smallMessage\"");
|
||||
WriteLiteral(">No Certificates Allocated</span>\r\n");
|
||||
|
||||
|
||||
#line 50 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 73 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -227,7 +304,7 @@ WriteLiteral(" </div>\r\n <script>\r\n $(\'#DeviceDetailTabItems\')
|
||||
"\"#DeviceDetailTab-Certificates\">Certificates [");
|
||||
|
||||
|
||||
#line 53 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
#line 76 "..\..\Views\Device\DeviceParts\_Certificates.cshtml"
|
||||
Write(Model.Certificates.Count);
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
var canRemoveOwnComments = Authorization.Has(Claims.Device.Actions.RemoveOwnComments);
|
||||
}
|
||||
<div id="Comments" class="@(canAddComments ? "canAddComments" : "cannotAddComments") @(canRemoveAnyComments ? "canRemoveAnyComments" : "cannotRemoveAnyComments") @(canRemoveOwnComments ? "canRemoveOwnComments" : "cannotRemoveOwnComments")" data-id="@Model.Device.SerialNumber" data-userid="@CurrentUser.UserId" data-addurl="@Url.Action(MVC.API.Device.CommentAdd(Model.Device.SerialNumber))" data-removeurl="@Url.Action(MVC.API.Device.CommentRemove())" data-geturl="@Url.Action(MVC.API.Device.Comment())">
|
||||
@Html.AntiForgeryToken()
|
||||
@if (canAddComments)
|
||||
{
|
||||
<div class="commentInput">
|
||||
@@ -48,7 +47,7 @@
|
||||
}
|
||||
async function onCommentAddedAsync(id) {
|
||||
const formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', $comments.find('input[name="__RequestVerificationToken"]').val());
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
formData.append('id', id);
|
||||
|
||||
const response = await fetch($comments.attr('data-geturl'), {
|
||||
@@ -136,7 +135,7 @@
|
||||
$commentInput.prop('disabled', true);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', $comments.find('input[name="__RequestVerificationToken"]').val());
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
formData.append('comment', comment);
|
||||
|
||||
const response = await fetch($comments.attr('data-addurl'), {
|
||||
@@ -194,7 +193,7 @@
|
||||
}
|
||||
async function removeCommentAsync(commentId) {
|
||||
const formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', $comments.find('input[name="__RequestVerificationToken"]').val());
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
formData.append('id', commentId);
|
||||
|
||||
const response = await fetch($comments.attr('data-removeurl'), {
|
||||
|
||||
@@ -139,25 +139,14 @@ WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 9 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
Write(Html.AntiForgeryToken());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 10 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 10 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 9 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
if (canAddComments)
|
||||
{
|
||||
|
||||
@@ -189,7 +178,7 @@ WriteLiteral(" class=\"fa fa-comment\"");
|
||||
WriteLiteral("></i></button>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 16 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 15 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -202,13 +191,13 @@ WriteLiteral(" class=\"commentOutput\"");
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 18 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 17 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 18 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 17 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
foreach (var c in Model.Device.DeviceComments.OrderBy(m => m.Timestamp))
|
||||
{
|
||||
|
||||
@@ -222,7 +211,7 @@ WriteLiteral(" class=\"comment\"");
|
||||
WriteLiteral(" data-commentid=\"");
|
||||
|
||||
|
||||
#line 20 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 19 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
Write(c.Id);
|
||||
|
||||
|
||||
@@ -237,7 +226,7 @@ WriteLiteral(" class=\"author\"");
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 20 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
Write(c.TechUser.ToStringFriendly());
|
||||
|
||||
|
||||
@@ -246,7 +235,7 @@ WriteLiteral(">");
|
||||
WriteLiteral("</span>");
|
||||
|
||||
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 20 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
if (canRemoveAnyComments || (canRemoveOwnComments && c.TechUserId.Equals(CurrentUser.UserId, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
|
||||
@@ -259,7 +248,7 @@ WriteLiteral(" class=\"remove fa fa-times-circle\"");
|
||||
WriteLiteral("></span>");
|
||||
|
||||
|
||||
#line 22 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
@@ -271,7 +260,7 @@ WriteLiteral(" class=\"timestamp\"");
|
||||
WriteLiteral(" data-livestamp=\"");
|
||||
|
||||
|
||||
#line 22 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
Write(c.Timestamp.ToUnixEpoc());
|
||||
|
||||
|
||||
@@ -279,20 +268,20 @@ WriteLiteral(" data-livestamp=\"");
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 1737), Tuple.Create("\"", 1774)
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 1707), Tuple.Create("\"", 1744)
|
||||
|
||||
#line 22 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1745), Tuple.Create<System.Object, System.Int32>(c.Timestamp.ToFullDateTime()
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1715), Tuple.Create<System.Object, System.Int32>(c.Timestamp.ToFullDateTime()
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1745), false)
|
||||
, 1715), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 22 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
Write(c.Timestamp.ToFullDateTime());
|
||||
|
||||
|
||||
@@ -305,7 +294,7 @@ WriteLiteral(" class=\"comment\"");
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 23 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 22 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
Write(c.Comments.ToHtmlComment());
|
||||
|
||||
|
||||
@@ -314,7 +303,7 @@ WriteLiteral(">");
|
||||
WriteLiteral("</div>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 25 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 24 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -331,40 +320,40 @@ WriteLiteral(" </div>\r\n</div>\r\n<script>\r\n if (!document.DiscoFunctio
|
||||
"croll to Bottom\r\n }\r\n });\r\n\r\n function onCommentAdded(i" +
|
||||
"d) {\r\n onCommentAddedAsync(id);\r\n }\r\n async function on" +
|
||||
"CommentAddedAsync(id) {\r\n const formData = new FormData();\r\n " +
|
||||
" formData.append(\'__RequestVerificationToken\', $comments.find(\'input[name=\"__R" +
|
||||
"equestVerificationToken\"]\').val());\r\n formData.append(\'id\', id);\r\n\r\n " +
|
||||
" const response = await fetch($comments.attr(\'data-geturl\'), {\r\n " +
|
||||
" method: \'POST\',\r\n body: formData\r\n });\r\n\r\n " +
|
||||
" if (!response.ok) {\r\n alert(\'Unable to load live commen" +
|
||||
"t \' + id + \': \' + response.statusText);\r\n } else {\r\n c" +
|
||||
"onst comment = await response.json();\r\n\r\n if ($comments.hasClass(" +
|
||||
"\'canRemoveAnyComments\'))\r\n renderComment(comment, false, true" +
|
||||
");\r\n else if ($comments.hasClass(\'canRemoveOwnComments\'))\r\n " +
|
||||
" renderComment(comment, false, (comment.AuthorId === $comments.attr" +
|
||||
"(\'data-userid\')));\r\n else\r\n renderComment(comm" +
|
||||
"ent, false, false);\r\n }\r\n }\r\n function onCommentRemoved" +
|
||||
"(id) {\r\n $commentOutput.children(\'div[data-commentid=\"\' + id + \'\"]\')." +
|
||||
"slideUp(300).delay(300).queue(function () {\r\n const $this = $(thi" +
|
||||
"s);\r\n $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n " +
|
||||
" $this.remove();\r\n });\r\n }\r\n function renderComment" +
|
||||
"(c, quick, canRemove) {\r\n let t = \'<div><span class=\"author\" />\';\r\n " +
|
||||
" if (canRemove)\r\n t += \'<span class=\"remove fa fa-times-" +
|
||||
"circle\" />\';\r\n t += \'<span class=\"timestamp\" /><div class=\"comment\" /" +
|
||||
"></div>\';\r\n\r\n const e = $(t);\r\n e.attr(\'data-commentid\', c" +
|
||||
".Id);\r\n e.find(\'.author\').text(c.Author);\r\n e.find(\'.times" +
|
||||
"tamp\').text(c.TimestampFull).attr(\'title\', c.TimestampFull).livestamp(c.Timestam" +
|
||||
"pUnixEpoc);\r\n e.find(\'.comment\').html(c.HtmlComments);\r\n\r\n " +
|
||||
" $commentOutput.append(e);\r\n\r\n if (!quick) {\r\n e.anima" +
|
||||
"te({ backgroundColor: \'#ffff99\' }, 500, function () {\r\n e.ani" +
|
||||
"mate({ backgroundColor: \'#fafafa\' }, 500, function () {\r\n " +
|
||||
" e.css(\'background-color\', \'\');\r\n });\r\n });\r\n " +
|
||||
" $commentOutput.animate({ scrollTop: $commentOutput[0].scrollHeigh" +
|
||||
"t }, 250)\r\n }\r\n }\r\n\r\n document.DiscoFunctions.onComment" +
|
||||
"Added = onCommentAdded;\r\n document.DiscoFunctions.onCommentRemoved = onCo" +
|
||||
"mmentRemoved;\r\n });\r\n</script>\r\n");
|
||||
" formData.append(\'__RequestVerificationToken\', document.body.dataset.antiforge" +
|
||||
"ry);\r\n formData.append(\'id\', id);\r\n\r\n const response = awa" +
|
||||
"it fetch($comments.attr(\'data-geturl\'), {\r\n method: \'POST\',\r\n " +
|
||||
" body: formData\r\n });\r\n\r\n if (!response.ok) {\r\n" +
|
||||
" alert(\'Unable to load live comment \' + id + \': \' + response.stat" +
|
||||
"usText);\r\n } else {\r\n const comment = await response.j" +
|
||||
"son();\r\n\r\n if ($comments.hasClass(\'canRemoveAnyComments\'))\r\n " +
|
||||
" renderComment(comment, false, true);\r\n else if ($c" +
|
||||
"omments.hasClass(\'canRemoveOwnComments\'))\r\n renderComment(com" +
|
||||
"ment, false, (comment.AuthorId === $comments.attr(\'data-userid\')));\r\n " +
|
||||
" else\r\n renderComment(comment, false, false);\r\n " +
|
||||
" }\r\n }\r\n function onCommentRemoved(id) {\r\n $commentOut" +
|
||||
"put.children(\'div[data-commentid=\"\' + id + \'\"]\').slideUp(300).delay(300).queue(f" +
|
||||
"unction () {\r\n const $this = $(this);\r\n $this.find" +
|
||||
"(\'.timestamp\').livestamp(\'destroy\');\r\n $this.remove();\r\n " +
|
||||
" });\r\n }\r\n function renderComment(c, quick, canRemove) {\r\n " +
|
||||
" let t = \'<div><span class=\"author\" />\';\r\n if (canRemove)\r\n " +
|
||||
" t += \'<span class=\"remove fa fa-times-circle\" />\';\r\n t += " +
|
||||
"\'<span class=\"timestamp\" /><div class=\"comment\" /></div>\';\r\n\r\n const " +
|
||||
"e = $(t);\r\n e.attr(\'data-commentid\', c.Id);\r\n e.find(\'.aut" +
|
||||
"hor\').text(c.Author);\r\n e.find(\'.timestamp\').text(c.TimestampFull).at" +
|
||||
"tr(\'title\', c.TimestampFull).livestamp(c.TimestampUnixEpoc);\r\n e.find" +
|
||||
"(\'.comment\').html(c.HtmlComments);\r\n\r\n $commentOutput.append(e);\r\n\r\n " +
|
||||
" if (!quick) {\r\n e.animate({ backgroundColor: \'#ffff99\'" +
|
||||
" }, 500, function () {\r\n e.animate({ backgroundColor: \'#fafaf" +
|
||||
"a\' }, 500, function () {\r\n e.css(\'background-color\', \'\');" +
|
||||
"\r\n });\r\n });\r\n $commentOutput.a" +
|
||||
"nimate({ scrollTop: $commentOutput[0].scrollHeight }, 250)\r\n }\r\n " +
|
||||
" }\r\n\r\n document.DiscoFunctions.onCommentAdded = onCommentAdded;\r\n " +
|
||||
" document.DiscoFunctions.onCommentRemoved = onCommentRemoved;\r\n });\r\n</scrip" +
|
||||
"t>\r\n");
|
||||
|
||||
|
||||
#line 107 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 106 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
if (canAddComments)
|
||||
{
|
||||
|
||||
@@ -385,25 +374,25 @@ WriteLiteral(" <script>\r\n $(function () {\r\n const $comm
|
||||
" alert(\'Enter a comment to post\');\r\n $commentInput.focus(" +
|
||||
");\r\n return;\r\n }\r\n\r\n $commentIn" +
|
||||
"put.prop(\'disabled\', true);\r\n\r\n const formData = new FormData();\r" +
|
||||
"\n formData.append(\'__RequestVerificationToken\', $comments.find(\'i" +
|
||||
"nput[name=\"__RequestVerificationToken\"]\').val());\r\n formData.appe" +
|
||||
"nd(\'comment\', comment);\r\n\r\n const response = await fetch($comment" +
|
||||
"s.attr(\'data-addurl\'), {\r\n method: \'POST\',\r\n " +
|
||||
" body: formData\r\n });\r\n\r\n if (response.ok) {\r\n " +
|
||||
" $commentInput.val(\'\').prop(\'disabled\', false).focus();\r\n " +
|
||||
" } else {\r\n alert(\'Unable to add comment: \' + respon" +
|
||||
"se.statusText);\r\n $commentInput.prop(\'disabled\', false).focus" +
|
||||
"();\r\n }\r\n }\r\n });\r\n </script>\r\n");
|
||||
"\n formData.append(\'__RequestVerificationToken\', document.body.dat" +
|
||||
"aset.antiforgery);\r\n formData.append(\'comment\', comment);\r\n\r\n " +
|
||||
" const response = await fetch($comments.attr(\'data-addurl\'), {\r\n " +
|
||||
" method: \'POST\',\r\n body: formData\r\n " +
|
||||
" });\r\n\r\n if (response.ok) {\r\n $commentInput" +
|
||||
".val(\'\').prop(\'disabled\', false).focus();\r\n } else {\r\n " +
|
||||
" alert(\'Unable to add comment: \' + response.statusText);\r\n " +
|
||||
" $commentInput.prop(\'disabled\', false).focus();\r\n }\r\n " +
|
||||
" }\r\n });\r\n </script>\r\n");
|
||||
|
||||
|
||||
#line 156 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 155 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 157 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 156 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
if (canRemoveAnyComments || canRemoveOwnComments)
|
||||
{
|
||||
|
||||
@@ -430,17 +419,16 @@ WriteLiteral(" <script>\r\n $(function () {\r\n const $comm
|
||||
" $dialogRemove.dialog(\"close\");\r\n }\r\n }).dialo" +
|
||||
"g(\'open\');\r\n }\r\n async function removeCommentAsync(comment" +
|
||||
"Id) {\r\n const formData = new FormData();\r\n formDat" +
|
||||
"a.append(\'__RequestVerificationToken\', $comments.find(\'input[name=\"__RequestVeri" +
|
||||
"ficationToken\"]\').val());\r\n formData.append(\'id\', commentId);\r\n\r\n" +
|
||||
" const response = await fetch($comments.attr(\'data-removeurl\'), {" +
|
||||
"\r\n method: \'POST\',\r\n body: formData\r\n " +
|
||||
" });\r\n\r\n if (!response.ok) {\r\n alert" +
|
||||
"(\'Unable to remove comment: \' + response.statusText);\r\n }\r\n " +
|
||||
" $dialogRemove.dialog(\"close\");\r\n }\r\n });\r\n </scri" +
|
||||
"pt>\r\n");
|
||||
"a.append(\'__RequestVerificationToken\', document.body.dataset.antiforgery);\r\n " +
|
||||
" formData.append(\'id\', commentId);\r\n\r\n const response " +
|
||||
"= await fetch($comments.attr(\'data-removeurl\'), {\r\n method: \'" +
|
||||
"POST\',\r\n body: formData\r\n });\r\n\r\n " +
|
||||
" if (!response.ok) {\r\n alert(\'Unable to remove comment: \' +" +
|
||||
" response.statusText);\r\n }\r\n $dialogRemove.dialog(" +
|
||||
"\"close\");\r\n }\r\n });\r\n </script>\r\n");
|
||||
|
||||
|
||||
#line 212 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
#line 211 "..\..\Views\Device\DeviceParts\_Comments.cshtml"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
<table id="deviceShowResources">
|
||||
<tr>
|
||||
<td id="AttachmentsContainer">
|
||||
<div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments") @(canRemoveAnyAttachments ? "canRemoveAnyAttachments" : "cannotRemoveAnyAttachments") @(canRemoveOwnAttachments ? "canRemoveOwnAttachments" : "cannotRemoveOwnAttachments")" data-userid="@CurrentUser.UserId" data-uploadurl="@(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.Device.AttachmentOnlineUploadSession(Model.Device.SerialNumber)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")">
|
||||
@Html.AntiForgeryToken()
|
||||
<div id="Attachments" class="@(canAddAttachments ? "canAddAttachments" : "cannotAddAttachments") @(canRemoveAnyAttachments ? "canRemoveAnyAttachments" : "cannotRemoveAnyAttachments") @(canRemoveOwnAttachments ? "canRemoveOwnAttachments" : "cannotRemoveOwnAttachments")" data-userid="@CurrentUser.UserId" data-uploadurl="@(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null)))" data-onlineuploadurl="@(Url.Action(MVC.API.Device.AttachmentOnlineUploadSession(Model.Device.SerialNumber)))" data-qrcodeurl="@Url.Content("~/ClientSource/Scripts/Modules/qrcode.min.js")" data-removeurl="@Url.Action(MVC.API.Device.AttachmentRemove())">
|
||||
<div class="Disco-AttachmentUpload-DropTarget">
|
||||
<h2>Drop Attachments Here</h2>
|
||||
</div>
|
||||
@@ -236,8 +235,6 @@
|
||||
function removeAttachment() {
|
||||
$this = $(this).closest('a');
|
||||
|
||||
var data = { id: $this.attr('data-attachmentid') };
|
||||
|
||||
if (!$dialogRemoveAttachment) {
|
||||
$dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({
|
||||
resizable: false,
|
||||
@@ -247,35 +244,36 @@
|
||||
});
|
||||
}
|
||||
|
||||
$dialogRemoveAttachment.dialog("enable");
|
||||
async function removeAttachmentAsync(id) {
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('id', id);
|
||||
|
||||
try {
|
||||
const response = await fetch($Attachments.attr('data-removeurl'), {
|
||||
body: body,
|
||||
method: 'POST'
|
||||
});
|
||||
if (!response.ok) {
|
||||
alert('Unable to remove attachment: ' + response.statusText);
|
||||
}
|
||||
$dialogRemoveAttachment.dialog("close");
|
||||
} catch (e) {
|
||||
alert('Unable to remove attachment: ' + e);
|
||||
$dialogRemoveAttachment.dialog("close");
|
||||
}
|
||||
}
|
||||
|
||||
const attachmentId = $this.attr('data-attachmentid');
|
||||
$dialogRemoveAttachment.dialog('option', 'buttons', {
|
||||
"Remove": function () {
|
||||
$dialogRemoveAttachment.dialog("disable");
|
||||
$dialogRemoveAttachment.dialog("option", "buttons", null);
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.Device.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");
|
||||
}
|
||||
});
|
||||
removeAttachmentAsync(attachmentId);
|
||||
},
|
||||
Cancel: function () {
|
||||
$dialogRemoveAttachment.dialog("close");
|
||||
}
|
||||
});
|
||||
|
||||
$dialogRemoveAttachment.dialog('open');
|
||||
}).dialog('open');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -149,18 +149,18 @@ WriteLiteral(" data-qrcodeurl=\"");
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
WriteLiteral(" data-removeurl=\"");
|
||||
|
||||
|
||||
#line 22 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(Html.AntiForgeryToken());
|
||||
#line 21 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(Url.Action(MVC.API.Device.AttachmentRemove()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"Disco-AttachmentUpload-DropTarget\"");
|
||||
|
||||
@@ -172,13 +172,13 @@ WriteLiteral(" class=\"attachmentOutput\"");
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 26 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 26 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
if (Model.Device.DeviceAttachments != null)
|
||||
{
|
||||
foreach (var da in Model.Device.DeviceAttachments.OrderByDescending(a => a.Id))
|
||||
@@ -189,20 +189,20 @@ WriteLiteral(">\r\n");
|
||||
#line hidden
|
||||
WriteLiteral(" <a");
|
||||
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1912), Tuple.Create("\"", 1972)
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1930), Tuple.Create("\"", 1990)
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1919), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentDownload(da.Id))
|
||||
#line 30 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1937), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentDownload(da.Id))
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1919), false)
|
||||
, 1937), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" data-attachmentid=\"");
|
||||
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 30 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(da.Id);
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ WriteLiteral("\"");
|
||||
WriteLiteral(" data-mimetype=\"");
|
||||
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 30 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(da.MimeType);
|
||||
|
||||
|
||||
@@ -225,28 +225,28 @@ WriteLiteral(">\r\n <span");
|
||||
|
||||
WriteLiteral(" class=\"icon\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 2086), Tuple.Create("\"", 2106)
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 2104), Tuple.Create("\"", 2124)
|
||||
|
||||
#line 32 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2094), Tuple.Create<System.Object, System.Int32>(da.Filename
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2112), Tuple.Create<System.Object, System.Int32>(da.Filename
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 2094), false)
|
||||
, 2112), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n <img");
|
||||
|
||||
WriteLiteral(" alt=\"Attachment Thumbnail\"");
|
||||
|
||||
WriteAttribute("src", Tuple.Create(" src=\"", 2181), Tuple.Create("\"", 2243)
|
||||
WriteAttribute("src", Tuple.Create(" src=\"", 2199), Tuple.Create("\"", 2261)
|
||||
|
||||
#line 33 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2187), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentThumbnail(da.Id))
|
||||
#line 32 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2205), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.Device.AttachmentThumbnail(da.Id))
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 2187), false)
|
||||
, 2205), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" />\r\n </span>\r\n " +
|
||||
@@ -254,40 +254,40 @@ WriteLiteral(" />\r\n </span>\r\n
|
||||
|
||||
WriteLiteral(" class=\"comments\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 2352), Tuple.Create("\"", 2389)
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 2370), Tuple.Create("\"", 2407)
|
||||
|
||||
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2360), Tuple.Create<System.Object, System.Int32>(da.Comments ?? da.Filename
|
||||
#line 34 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2378), Tuple.Create<System.Object, System.Int32>(da.Comments ?? da.Filename
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 2360), false)
|
||||
, 2378), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
if (!string.IsNullOrEmpty(da.DocumentTemplateId))
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 37 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(da.DocumentTemplate.Description);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 37 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -295,14 +295,14 @@ WriteLiteral(">\r\n");
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 39 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 38 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(da.Comments ?? da.Filename);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 39 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 38 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
@@ -314,7 +314,7 @@ WriteLiteral(" class=\"author\"");
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 39 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(da.TechUser.ToString());
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ WriteLiteral(">");
|
||||
WriteLiteral("</span>");
|
||||
|
||||
|
||||
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 39 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
if (canRemoveAnyAttachments || (canRemoveOwnAttachments && da.TechUserId.Equals(CurrentUser.UserId, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
|
||||
@@ -336,7 +336,7 @@ WriteLiteral(" class=\"remove fa fa-times-circle\"");
|
||||
WriteLiteral("></span>");
|
||||
|
||||
|
||||
#line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
@@ -345,20 +345,20 @@ WriteLiteral("<span");
|
||||
|
||||
WriteLiteral(" class=\"timestamp\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 3044), Tuple.Create("\"", 3082)
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 3062), Tuple.Create("\"", 3100)
|
||||
|
||||
#line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 3052), Tuple.Create<System.Object, System.Int32>(da.Timestamp.ToFullDateTime()
|
||||
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 3070), Tuple.Create<System.Object, System.Int32>(da.Timestamp.ToFullDateTime()
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 3052), false)
|
||||
, 3070), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" data-livestamp=\"");
|
||||
|
||||
|
||||
#line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(da.Timestamp.ToUnixEpoc());
|
||||
|
||||
|
||||
@@ -369,7 +369,7 @@ WriteLiteral("\"");
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 40 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(da.Timestamp.ToFullDateTime());
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ WriteLiteral(">");
|
||||
WriteLiteral("</span>\r\n </a>\r\n");
|
||||
|
||||
|
||||
#line 43 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 42 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,13 +388,13 @@ WriteLiteral("</span>\r\n </a>\r\n");
|
||||
WriteLiteral(" </div>\r\n");
|
||||
|
||||
|
||||
#line 46 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 45 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 46 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 45 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
if (canAddAttachments)
|
||||
{
|
||||
|
||||
@@ -432,7 +432,7 @@ WriteLiteral(" title=\"Upload with Online Services\"");
|
||||
WriteLiteral("></span>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 52 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 51 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ WriteLiteral(@">
|
||||
url: '");
|
||||
|
||||
|
||||
#line 67 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 66 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(Url.Action(MVC.API.Device.Attachment()));
|
||||
|
||||
|
||||
@@ -492,7 +492,7 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
|
||||
"tachmentid\', a.Id).attr(\'data-mimetype\', a.MimeType).attr(\'href\', \'");
|
||||
|
||||
|
||||
#line 98 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 97 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(Url.Action(MVC.API.Device.AttachmentDownload()));
|
||||
|
||||
|
||||
@@ -524,7 +524,7 @@ WriteLiteral(@"/' + a.Id);
|
||||
img.attr('src', '");
|
||||
|
||||
|
||||
#line 121 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 120 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(Url.Action(MVC.API.Device.AttachmentThumbnail()));
|
||||
|
||||
|
||||
@@ -577,13 +577,13 @@ WriteLiteral("/\' + a.Id + \'?v=\' + retryCount);\r\n
|
||||
".onAttachmentRemoved = onAttachmentRemoved;\r\n\r\n");
|
||||
|
||||
|
||||
#line 183 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 182 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 183 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 182 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
if (canAddAttachments)
|
||||
{
|
||||
|
||||
@@ -630,7 +630,7 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
|
||||
" //#endregion\r\n ");
|
||||
|
||||
|
||||
#line 230 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 229 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -639,68 +639,50 @@ WriteLiteral("\r\n //#region Add Attachments\r\n
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 231 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 230 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
if (canRemoveAnyAttachments || canRemoveOwnAttachments)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(@"
|
||||
//#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: '");
|
||||
WriteLiteral("\r\n //#region Remove Attachments\r\n " +
|
||||
" $attachmentOutput.find(\'span.remove\').click(removeAttachment);\r\n\r\n " +
|
||||
" function removeAttachment() {\r\n " +
|
||||
" $this = $(this).closest(\'a\');\r\n\r\n if (!$dialo" +
|
||||
"gRemoveAttachment) {\r\n $dialogRemoveAttachmen" +
|
||||
"t = $(\'#dialogRemoveAttachment\').dialog({\r\n " +
|
||||
" resizable: false,\r\n height: 140,\r\n " +
|
||||
" modal: true,\r\n " +
|
||||
" autoOpen: false\r\n });\r\n " +
|
||||
" }\r\n\r\n async function removeAt" +
|
||||
"tachmentAsync(id) {\r\n const body = new FormDa" +
|
||||
"ta();\r\n body.append(\'__RequestVerificationTok" +
|
||||
"en\', document.body.dataset.antiforgery);\r\n bo" +
|
||||
"dy.append(\'id\', id);\r\n\r\n try {\r\n " +
|
||||
" const response = await fetch($Attachments.attr(\'data-" +
|
||||
"removeurl\'), {\r\n body: body,\r\n " +
|
||||
" method: \'POST\'\r\n " +
|
||||
" });\r\n if (!response.ok) {\r\n " +
|
||||
" alert(\'Unable to remove attachment: \'" +
|
||||
" + response.statusText);\r\n }\r\n " +
|
||||
" $dialogRemoveAttachment.dialog(\"close\");\r\n " +
|
||||
" } catch (e) {\r\n " +
|
||||
" alert(\'Unable to remove attachment: \' + e);\r\n " +
|
||||
" $dialogRemoveAttachment.dialog(\"close\");\r\n " +
|
||||
" }\r\n }\r\n\r\n con" +
|
||||
"st attachmentId = $this.attr(\'data-attachmentid\');\r\n " +
|
||||
" $dialogRemoveAttachment.dialog(\'option\', \'buttons\', {\r\n " +
|
||||
" \"Remove\": function () {\r\n " +
|
||||
"$dialogRemoveAttachment.dialog(\"option\", \"buttons\", null);\r\n " +
|
||||
" removeAttachmentAsync(attachmentId);\r\n " +
|
||||
" },\r\n Cancel: function () {\r\n " +
|
||||
" $dialogRemoveAttachment.dialog(\"close\");\r\n " +
|
||||
" }\r\n }).dialog(" +
|
||||
"\'open\');\r\n\r\n return false;\r\n " +
|
||||
" }\r\n //#endregion\r\n ");
|
||||
|
||||
|
||||
#line 256 "..\..\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 " +
|
||||
" success: function (d) {\r\n " +
|
||||
"if (d == \'OK\') {\r\n // Do noth" +
|
||||
"ing, await SignalR notification\r\n " +
|
||||
" } else {\r\n alert(\'Unable to " +
|
||||
"remove attachment: \' + d);\r\n }\r\n " +
|
||||
" $dialogRemoveAttachment.dialog(\"c" +
|
||||
"lose\");\r\n },\r\n " +
|
||||
" error: function (jqXHR, textStatus, errorThrown) {\r\n " +
|
||||
" alert(\'Unable to remove attachment: \' +" +
|
||||
" textStatus);\r\n $dialogRemoveAtta" +
|
||||
"chment.dialog(\"close\");\r\n }\r\n " +
|
||||
" });\r\n },\r\n " +
|
||||
" Cancel: 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 ");
|
||||
|
||||
|
||||
#line 283 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 281 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -737,7 +719,7 @@ WriteLiteral("></i> Are you sure?\r\n </p>\r\n </div>\r\n <scr
|
||||
"etailTab-ResourcesLink\">Attachments [");
|
||||
|
||||
|
||||
#line 304 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
#line 302 "..\..\Views\Device\DeviceParts\_Resources.cshtml"
|
||||
Write(Model.Device.DeviceAttachments == null ? 0 : Model.Device.DeviceAttachments.Count);
|
||||
|
||||
|
||||
|
||||
@@ -148,34 +148,43 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
<span id="Device_Show_Details_Status_LastSeen" class="@lastSeenClass">@CommonHelpers.FriendlyDate(Model.Device.LastNetworkLogonDate)</span>
|
||||
<span id="Device_Show_Details_Status_LastSeen" class="@lastSeenClass" data-updateurl="@(Url.Action(MVC.API.Device.LastNetworkLogonDate(Model.Device.SerialNumber)))">@CommonHelpers.FriendlyDate(Model.Device.LastNetworkLogonDate)</span>
|
||||
</td>
|
||||
@if (!string.IsNullOrEmpty(Model.Device.ComputerName))
|
||||
{
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var updated = false;
|
||||
var span = $('#Device_Show_Details_Status_LastSeen');
|
||||
var spanProgress = null;
|
||||
const span = $('#Device_Show_Details_Status_LastSeen');
|
||||
let updated = false;
|
||||
let spanProgress = null;
|
||||
|
||||
$.getJSON('@(Url.Action(MVC.API.Device.LastNetworkLogonDate(Model.Device.SerialNumber)))', function (response, result) {
|
||||
async function updateLastNetworkLogonDate() {
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
|
||||
const response = await fetch(span.attr('data-updateurl'), {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
updated = true;
|
||||
if (spanProgress)
|
||||
spanProgress.remove();
|
||||
|
||||
if (result != 'success') {
|
||||
alert('Unable to retrieve latest network logon date:\n' + response);
|
||||
if (!response.ok) {
|
||||
alert('Unable to retrieve latest network logon date:\n' + response.statusText);
|
||||
$('<span>').addClass('smallMessage').text('[may not be current]').appendTo(span);
|
||||
} else {
|
||||
const result = await response.json();
|
||||
var spanClasses = '',
|
||||
diff = moment().valueOf() - response.UnixEpoc;
|
||||
diff = moment().valueOf() - result.UnixEpoc;
|
||||
if (diff > 2592000000) // 30 Days
|
||||
spanClasses = 'error';
|
||||
else if (diff > 604800000) // 7 Days
|
||||
spanClasses = 'alert';
|
||||
span.removeClass('alert error').addClass(spanClasses).attr('title', response.Formatted).text(response.Formatted).livestamp(response.UnixEpoc);
|
||||
span.removeClass('alert error').addClass(spanClasses).attr('title', result.Formatted).text(result.Formatted).livestamp(result.UnixEpoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
updateLastNetworkLogonDate();
|
||||
|
||||
window.setTimeout(function () {
|
||||
if (!updated) {
|
||||
spanProgress = $('<i>').addClass('ajaxLoading showInitially').attr('title', 'Loading...').appendTo(span);
|
||||
@@ -223,11 +232,11 @@
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(assignedUser.PhoneNumber))
|
||||
{
|
||||
<div id="Device_Show_User_PhoneNumber" title="Phone Number"><a href="tel:@assignedUser.PhoneNumber" data-clipboard>@assignedUser.PhoneNumber</a></div>
|
||||
<div id="Device_Show_User_PhoneNumber" title="Phone Number"><a href="tel:@assignedUser.PhoneNumber" data-clipboard>@assignedUser.PhoneNumber</a></div>
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(assignedUser.EmailAddress))
|
||||
{
|
||||
<div id="Device_Show_User_EmailAddress" title="Email Address"><a href="mailto:@(Model.Device.AssignedUser.EmailAddress)" data-clipboard="@assignedUser.DisplayName <@assignedUser.EmailAddress>">@assignedUser.EmailAddress</a></div>
|
||||
<div id="Device_Show_User_EmailAddress" title="Email Address"><a href="mailto:@(Model.Device.AssignedUser.EmailAddress)" data-clipboard="@assignedUser.DisplayName <@assignedUser.EmailAddress>">@assignedUser.EmailAddress</a></div>
|
||||
}
|
||||
}
|
||||
@if (Authorization.Has(Claims.User.ShowFlagAssignments))
|
||||
@@ -550,26 +559,29 @@
|
||||
}
|
||||
@if (Model.Device.CanUpdateDeviceBatch())
|
||||
{
|
||||
@Html.ActionLinkSmallButton("Update Batch", MVC.API.Device.UpdateDeviceBatchId(Model.Device.SerialNumber, null, true), "Device_Show_Policies_Batch_Actions_Update_Button")
|
||||
|
||||
<button id="Device_Show_Policies_Batch_Actions_Update_Button" class="button small">Update Batch</button>
|
||||
<div id="Device_Show_Policies_Batch_Actions_Update_Dialog" class="dialog" title="Assign to Device Batch">
|
||||
<div>
|
||||
<ul class="none">
|
||||
@foreach (var db in Model.DeviceBatches.OrderBy(i => i.Name))
|
||||
{
|
||||
var isDecommissioned = Model.DecommissionedDeviceBatchIds.Contains(db.Id);
|
||||
<li class="@(isDecommissioned ? "hidden" : null)">
|
||||
<label title="Purchased: @(db.PurchaseDate.ToLongDateString())">
|
||||
<input type="radio" data-devicebatchid="@db.Id" name="DeviceBatch" />
|
||||
@db.Name
|
||||
</label>
|
||||
</li>
|
||||
if (isDecommissioned)
|
||||
@using (Html.BeginForm(MVC.API.Device.UpdateDeviceBatchId(Model.Device.SerialNumber, null, true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
<ul class="none">
|
||||
@foreach (var db in Model.DeviceBatches.OrderBy(i => i.Name))
|
||||
{
|
||||
<li class="hidden decommissioned-padding"></li>
|
||||
var isDecommissioned = Model.DecommissionedDeviceBatchIds.Contains(db.Id);
|
||||
<li class="@(isDecommissioned ? "hidden" : null)">
|
||||
<label title="Purchased: @(db.PurchaseDate.ToLongDateString())">
|
||||
<input type="radio" data-devicebatchid="@db.Id" name="DeviceBatchId" value="@db.Id" />
|
||||
@db.Name
|
||||
</label>
|
||||
</li>
|
||||
if (isDecommissioned)
|
||||
{
|
||||
<li class="hidden decommissioned-padding"></li>
|
||||
}
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</ul>
|
||||
}
|
||||
@if (Model.DecommissionedDeviceBatchIds.Count > 0)
|
||||
{
|
||||
<a class="button small show-decommissioned" href="#">Show Decommissioned</a>
|
||||
@@ -598,10 +610,9 @@
|
||||
var deviceBatchId = dialogInputs.filter(':checked').attr('data-devicebatchid');
|
||||
|
||||
if (deviceBatchId) {
|
||||
var $this = $(this);
|
||||
$this.dialog("disable");
|
||||
$this.dialog("option", "buttons", null);
|
||||
window.location.href = button.attr('href') + '&DeviceBatchId=' + deviceBatchId;
|
||||
$(this)
|
||||
.dialog("option", "buttons", null)
|
||||
.find('form').trigger('submit');
|
||||
} else {
|
||||
alert('A device batch must be selected');
|
||||
}
|
||||
@@ -677,6 +688,7 @@
|
||||
<br />
|
||||
@using (Html.BeginForm(MVC.API.Device.UpdateAssignedUserId(Model.Device.SerialNumber, redirect: true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
<input id="Device_Show_User_Actions_Assign_UserId" name="AssignedUserId" type="text" />
|
||||
}
|
||||
</div>
|
||||
@@ -863,8 +875,12 @@
|
||||
}
|
||||
@if (Model.Device.CanUpdateTrustEnrol())
|
||||
{
|
||||
@Html.ActionLinkSmallButton("Trust Enrol", MVC.API.Device.UpdateAllowUnauthenticatedEnrol(Model.Device.SerialNumber, true.ToString(), true), "Device_Show_Device_Actions_TrustEnrol_Button")
|
||||
<button id="Device_Show_Device_Actions_TrustEnrol_Button" type="button" class="button small">Trust Enrol</button>
|
||||
<div id="Device_Show_Device_Actions_TrustEnrol_Dialog" class="dialog" title="Trust this Device?">
|
||||
@using (Html.BeginForm(MVC.API.Device.UpdateAllowUnauthenticatedEnrol(Model.Device.SerialNumber, true.ToString(), true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
}
|
||||
<p>
|
||||
Devices flagged as 'trusted' are allowed a single-use device enrolment without providing authentication (for example: Active Directory Computer Account).
|
||||
</p>
|
||||
@@ -882,12 +898,9 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var button = $('#Device_Show_Device_Actions_TrustEnrol_Button');
|
||||
var buttonDialog;
|
||||
button.click(function () {
|
||||
let buttonDialog;
|
||||
$('#Device_Show_Device_Actions_TrustEnrol_Button').click(function () {
|
||||
if (!buttonDialog) {
|
||||
var buttonLink = button.attr('href');
|
||||
button.attr('href', '#');
|
||||
buttonDialog = $('#Device_Show_Device_Actions_TrustEnrol_Dialog').dialog({
|
||||
resizable: false,
|
||||
width: 400,
|
||||
@@ -895,10 +908,9 @@
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Trust": function () {
|
||||
var $this = $(this);
|
||||
$this.dialog("disable");
|
||||
$this.dialog("option", "buttons", null);
|
||||
window.location.href = buttonLink;
|
||||
$(this)
|
||||
.dialog("option", "buttons", null)
|
||||
.find('form').trigger('submit');
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
@@ -906,18 +918,19 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buttonDialog.dialog('open');
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@if (Model.Device.CanUpdateUntrustEnrol())
|
||||
{
|
||||
@Html.ActionLinkSmallButton("Untrust Enrol", MVC.API.Device.UpdateAllowUnauthenticatedEnrol(Model.Device.SerialNumber, false.ToString(), true), "Device_Show_Device_Actions_UntrustEnrol_Button")
|
||||
<div id="Device_Show_Device_Actions_UntrustEnrol_Dialog" title="Untrust this Device?">
|
||||
<button id="Device_Show_Device_Actions_UntrustEnrol_Button" type="button" class="button small">Untrust Enrol</button>
|
||||
<div id="Device_Show_Device_Actions_UntrustEnrol_Dialog" class="dialog" title="Untrust this Device?">
|
||||
@using (Html.BeginForm(MVC.API.Device.UpdateAllowUnauthenticatedEnrol(Model.Device.SerialNumber, false.ToString(), true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
}
|
||||
<div class="info-box">
|
||||
<p class="fa-p" style="margin-bottom: 1em;">
|
||||
<i class="fa fa-info-circle"></i>This action will require the device to enrol with authentication (for example: domain joined).
|
||||
@@ -929,137 +942,130 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var button = $('#Device_Show_Device_Actions_UntrustEnrol_Button');
|
||||
var buttonDialog = $('#Device_Show_Device_Actions_UntrustEnrol_Dialog');
|
||||
var buttonLink = button.attr('href');
|
||||
button.attr('href', '#');
|
||||
button.click(function () {
|
||||
buttonDialog.dialog('open');
|
||||
return false;
|
||||
});
|
||||
buttonDialog.dialog({
|
||||
resizable: false,
|
||||
width: 400,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Untrust": function () {
|
||||
var $this = $(this);
|
||||
$this.dialog("disable");
|
||||
$this.dialog("option", "buttons", null);
|
||||
window.location.href = buttonLink;
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
let buttonDialog = null;
|
||||
$('#Device_Show_Device_Actions_UntrustEnrol_Button').on('click', function () {
|
||||
if (!buttonDialog) {
|
||||
buttonDialog = $('#Device_Show_Device_Actions_UntrustEnrol_Dialog').dialog({
|
||||
resizable: false,
|
||||
width: 400,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Untrust": function () {
|
||||
$(this)
|
||||
.dialog("option", "buttons", null)
|
||||
.find('form').trigger('submit');
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
buttonDialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@if (Model.Device.CanDecommission())
|
||||
{
|
||||
@Html.ActionLinkSmallButton("Decommission", MVC.API.Device.Decommission(), "Device_Show_Device_Actions_Decommission_Button")
|
||||
<button id="Device_Show_Device_Actions_Decommission_Button" type="button" class="button small">Decommission</button>
|
||||
<div id="Device_Show_Device_Actions_Decommission_Dialog" class="dialog" title="Device Decommissioning">
|
||||
<div class="clearfix" style="margin-bottom: 10px;">
|
||||
<i class="fa fa-question-circle fa-lg information"></i> Why is this device to be decommissioned?
|
||||
</div>
|
||||
<div>
|
||||
<ul class="none">
|
||||
@foreach (DecommissionReasons decommissionReason in Enum.GetValues(typeof(DecommissionReasons)).Cast<DecommissionReasons>().OrderBy(r => r.ToString()))
|
||||
{
|
||||
<li>
|
||||
<input type="radio" id="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)"
|
||||
name="Device_Show_Device_Actions_Decommission_Reason" value="@((int)decommissionReason)" @((decommissionReason == DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty) />
|
||||
<label for="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)">@(decommissionReason.ReasonMessage())</label>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
@using (Html.BeginForm(MVC.API.Device.Decommission(Model.Device.SerialNumber, null, true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
<div class="clearfix" style="margin-bottom: 10px;">
|
||||
<i class="fa fa-question-circle fa-lg information"></i> Why is this device to be decommissioned?
|
||||
</div>
|
||||
<div>
|
||||
<ul class="none">
|
||||
@foreach (DecommissionReasons decommissionReason in Enum.GetValues(typeof(DecommissionReasons)).Cast<DecommissionReasons>().OrderBy(r => r.ToString()))
|
||||
{
|
||||
<li>
|
||||
<input type="radio" id="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)"
|
||||
name="Reason" value="@((int)decommissionReason)" @((decommissionReason == DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty) />
|
||||
<label for="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)">@(decommissionReason.ReasonMessage())</label>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var button = $('#Device_Show_Device_Actions_Decommission_Button');
|
||||
var buttonDialog = null;
|
||||
var deviceSerialNumber = '@(Model.Device.SerialNumber)';
|
||||
|
||||
button.click(function () {
|
||||
|
||||
$('#Device_Show_Device_Actions_Decommission_Button').on('click', function () {
|
||||
if (!buttonDialog) {
|
||||
buttonDialog = $('#Device_Show_Device_Actions_Decommission_Dialog')
|
||||
.dialog({
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Decommission": function () {
|
||||
|
||||
var reasonId = buttonDialog.find('input:checked').val();
|
||||
|
||||
var $this = $(this);
|
||||
$this.dialog("disable");
|
||||
$this.dialog("option", "buttons", null);
|
||||
|
||||
var url = button.attr('href') + '/' + deviceSerialNumber + '?Reason=' + reasonId + '&redirect=True';
|
||||
|
||||
window.location.href = url;
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
.dialog({
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Decommission": function () {
|
||||
$(this)
|
||||
.dialog("option", "buttons", null)
|
||||
.find('form').trigger('submit');
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
buttonDialog.dialog('open');
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@if (Model.Device.CanRecommission())
|
||||
{
|
||||
@Html.ActionLinkSmallButton("Recommission", MVC.API.Device.Recommission(Model.Device.SerialNumber, true), "Device_Show_Device_Actions_Recommission_Button")
|
||||
<div id="Device_Show_Device_Actions_Recommission_Dialog" title="Recommission this Device?">
|
||||
<button id="Device_Show_Device_Actions_Recommission_Button" type="button" class="button small">Recommission</button>
|
||||
<div id="Device_Show_Device_Actions_Recommission_Dialog" class="dialog" title="Recommission this Device?">
|
||||
@using (Html.BeginForm(MVC.API.Device.Recommission(Model.Device.SerialNumber, true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
}
|
||||
<p>
|
||||
<i class="fa fa-exclamation-triangle fa-lg"></i> Are you sure?
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var button = $('#Device_Show_Device_Actions_Recommission_Button');
|
||||
var buttonDialog = $('#Device_Show_Device_Actions_Recommission_Dialog');
|
||||
var buttonLink = button.attr('href');
|
||||
button.attr('href', '#');
|
||||
button.click(function () {
|
||||
buttonDialog.dialog('open');
|
||||
return false;
|
||||
});
|
||||
buttonDialog.dialog({
|
||||
resizable: false,
|
||||
height: 140,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Recommission": function () {
|
||||
var $this = $(this);
|
||||
$this.dialog("disable");
|
||||
$this.dialog("option", "buttons", null);
|
||||
window.location.href = buttonLink;
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
let buttonDialog = null;
|
||||
$('#Device_Show_Device_Actions_Recommission_Button').on('click', function () {
|
||||
if (!buttonDialog) {
|
||||
buttonDialog = $('#Device_Show_Device_Actions_Recommission_Dialog').dialog({
|
||||
resizable: false,
|
||||
height: 140,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Recommission": function () {
|
||||
$(this)
|
||||
.dialog("option", "buttons", null)
|
||||
.find('form').trigger('submit');
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
buttonDialog.dialog('open');
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@if (Model.Device.CanDelete())
|
||||
{
|
||||
@Html.ActionLinkSmallButton("Delete Device", MVC.API.Device.Delete(Model.Device.SerialNumber, true), "Device_Show_Device_Actions_Delete_Button")
|
||||
<div id="Device_Show_Device_Actions_Delete_Dialog" title="Delete this Device?">
|
||||
<button id="Device_Show_Device_Actions_Delete_Button" type="button" class="button small">Delete Device</button>
|
||||
<div id="Device_Show_Device_Actions_Delete_Dialog" class="dialog" title="Delete this Device?">
|
||||
@using (Html.BeginForm(MVC.API.Device.Delete(Model.Device.SerialNumber, true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
}
|
||||
<p>
|
||||
<i class="fa fa-exclamation-triangle fa-lg"></i>
|
||||
This item will be permanently deleted and cannot be recovered.<br />
|
||||
@@ -1069,30 +1075,27 @@
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var button = $('#Device_Show_Device_Actions_Delete_Button');
|
||||
var buttonDialog = $('#Device_Show_Device_Actions_Delete_Dialog');
|
||||
var buttonLink = button.attr('href');
|
||||
button.attr('href', '#');
|
||||
button.click(function () {
|
||||
buttonDialog.dialog('open');
|
||||
return false;
|
||||
});
|
||||
buttonDialog.dialog({
|
||||
resizable: false,
|
||||
height: 200,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Delete": function () {
|
||||
var $this = $(this);
|
||||
$this.dialog("disable");
|
||||
$this.dialog("option", "buttons", null);
|
||||
window.location.href = buttonLink;
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
let buttonDialog = null;
|
||||
$('#Device_Show_Device_Actions_Delete_Button').on('click', function () {
|
||||
if (!buttonDialog) {
|
||||
buttonDialog = $('#Device_Show_Device_Actions_Delete_Dialog').dialog({
|
||||
resizable: false,
|
||||
height: 200,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Delete": function () {
|
||||
$(this)
|
||||
.dialog("option", "buttons", null)
|
||||
.find('form').trigger('submit');
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
buttonDialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user