security: use more antiforgery tokens
This commit is contained in:
@@ -4,20 +4,21 @@
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), "Create");
|
||||
}
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
@Html.ValidationSummary(false)
|
||||
<div class="form" style="width: 450px">
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name:</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.Name)<br />@Html.ValidationMessageFor(model => model.DeviceBatch.Name)
|
||||
@Html.EditorFor(model => model.Name)<br />@Html.ValidationMessageFor(model => model.Name)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Purchase Date:</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.PurchaseDate)<br />@Html.ValidationMessageFor(model => model.DeviceBatch.PurchaseDate)
|
||||
@Html.EditorFor(model => model.PurchaseDate)<br />@Html.ValidationMessageFor(model => model.PurchaseDate)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -29,6 +30,7 @@
|
||||
$(function () {
|
||||
$('#Name').focus().select();
|
||||
$('#PurchaseDate').datepicker({
|
||||
minDate: new Date(1900, 1-1, 1),
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
dateFormat: 'yy/mm/dd'
|
||||
|
||||
@@ -57,20 +57,34 @@ WriteLiteral("\r\n");
|
||||
|
||||
#line 6 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
using (Html.BeginForm())
|
||||
{
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 8 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationSummary(false));
|
||||
Write(Html.AntiForgeryToken());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 8 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 9 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationSummary(false));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 9 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
|
||||
|
||||
|
||||
@@ -88,8 +102,8 @@ WriteLiteral(">\r\n <table>\r\n <tr>\r\n <th>Na
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 14 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.EditorFor(model => model.DeviceBatch.Name));
|
||||
#line 15 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.EditorFor(model => model.Name));
|
||||
|
||||
|
||||
#line default
|
||||
@@ -97,8 +111,8 @@ WriteLiteral(" ");
|
||||
WriteLiteral("<br />");
|
||||
|
||||
|
||||
#line 14 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.DeviceBatch.Name));
|
||||
#line 15 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.Name));
|
||||
|
||||
|
||||
#line default
|
||||
@@ -109,8 +123,8 @@ WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 20 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.EditorFor(model => model.DeviceBatch.PurchaseDate));
|
||||
#line 21 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.EditorFor(model => model.PurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
@@ -118,8 +132,8 @@ WriteLiteral(" ");
|
||||
WriteLiteral("<br />");
|
||||
|
||||
|
||||
#line 20 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.DeviceBatch.PurchaseDate));
|
||||
#line 21 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.PurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
@@ -146,6 +160,7 @@ WriteLiteral(@">
|
||||
$(function () {
|
||||
$('#Name').focus().select();
|
||||
$('#PurchaseDate').datepicker({
|
||||
minDate: new Date(1900, 1-1, 1),
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
dateFormat: 'yy/mm/dd'
|
||||
@@ -155,7 +170,7 @@ WriteLiteral(@">
|
||||
");
|
||||
|
||||
|
||||
#line 38 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
#line 40 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="DeviceBatch_PurchaseDetails_Container">
|
||||
<div id="DeviceBatch_PurchaseDetails_Container" data-updateurl="@(Url.Action(MVC.API.DeviceBatch.UpdatePurchaseDetails(Model.DeviceBatch.Id)))">
|
||||
<div>
|
||||
Details @AjaxHelpers.AjaxLoader("ajaxPurchaseDetails")
|
||||
</div>
|
||||
@@ -294,50 +294,39 @@
|
||||
@Html.EditorFor(model => model.DeviceBatch.PurchaseDetails)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$field: $('#DeviceBatch_PurchaseDetails'),
|
||||
fieldName: 'PurchaseDetails',
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajax' + model.fieldName + '_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajax' + model.fieldName + '_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = {};
|
||||
data[model.fieldName] = model.$field.tinymce().getContent();
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdatePurchaseDetails(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update purchase details: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update purchase details: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
const $field = $('#DeviceBatch_PurchaseDetails');
|
||||
|
||||
model.$field.tinymce({
|
||||
async function updated() {
|
||||
$('#ajaxPurchaseDetails_loading').show();
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('purchaseDetails', $field.tinymce().getContent())
|
||||
|
||||
const response = await fetch($('#DeviceBatch_PurchaseDetails_Container').attr('data-updateurl'), {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$('#ajaxPurchaseDetails_ok').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to update purchase details: ' + response.statusText);
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Unable to update purchase details: ' + e);
|
||||
}
|
||||
$('#ajaxPurchaseDetails_loading').hide();
|
||||
}
|
||||
|
||||
$field.tinymce({
|
||||
theme: 'simple',
|
||||
add_unload_trigger: false,
|
||||
schema: "html5",
|
||||
statusbar: false,
|
||||
setup: function (ed) {
|
||||
ed.on('init', function () {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
$(ed.getWin()).blur(function () { updated(); });
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -390,7 +379,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="DeviceBatch_WarrantyDetails_Container">
|
||||
<div id="DeviceBatch_WarrantyDetails_Container" data-updateurl="@(Url.Action(MVC.API.DeviceBatch.UpdateWarrantyDetails(Model.DeviceBatch.Id)))">
|
||||
<div>
|
||||
Details @AjaxHelpers.AjaxLoader("ajaxWarrantyDetails")
|
||||
</div>
|
||||
@@ -399,50 +388,39 @@
|
||||
@Html.EditorFor(model => model.DeviceBatch.WarrantyDetails)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$field: $('#DeviceBatch_WarrantyDetails'),
|
||||
fieldName: 'WarrantyDetails',
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajax' + model.fieldName + '_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajax' + model.fieldName + '_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = {};
|
||||
data[model.fieldName] = model.$field.tinymce().getContent();
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdateWarrantyDetails(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update warranty details: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update warranty details: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
const $field = $('#DeviceBatch_WarrantyDetails');
|
||||
|
||||
model.$field.tinymce({
|
||||
async function updated() {
|
||||
$('#ajaxWarrantyDetails_loading').show();
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('warrantyDetails', $field.tinymce().getContent())
|
||||
|
||||
const response = await fetch($('#DeviceBatch_WarrantyDetails_Container').attr('data-updateurl'), {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$('#ajaxWarrantyDetails_ok').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to update warranty details: ' + response.statusText);
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Unable to update warranty details: ' + e);
|
||||
}
|
||||
$('#ajaxWarrantyDetails_loading').hide();
|
||||
}
|
||||
|
||||
$field.tinymce({
|
||||
theme: 'simple',
|
||||
add_unload_trigger: false,
|
||||
schema: "html5",
|
||||
statusbar: false,
|
||||
setup: function (ed) {
|
||||
ed.on('init', function () {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
$(ed.getWin()).blur(function () { updated(); });
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -555,7 +533,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="DeviceBatch_InsuranceDetails_Container">
|
||||
<div id="DeviceBatch_InsuranceDetails_Container" data-updateurl="@(Url.Action(MVC.API.DeviceBatch.UpdateInsuranceDetails(Model.DeviceBatch.Id)))">
|
||||
<div>
|
||||
Details @AjaxHelpers.AjaxLoader("ajaxInsuranceDetails")
|
||||
</div>
|
||||
@@ -564,48 +542,38 @@
|
||||
@Html.EditorFor(model => model.DeviceBatch.InsuranceDetails)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$field: $('#DeviceBatch_InsuranceDetails'),
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajaxInsuranceDetails_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajaxInsuranceDetails_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = { InsuranceDetails: model.$field.tinymce().getContent() };
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdateInsuranceDetails(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update insurance details: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update insurance details: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
const $field = $('#DeviceBatch_InsuranceDetails');
|
||||
async function updated() {
|
||||
$('#ajaxInsuranceDetails_loading').show();
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('insuranceDetails', $field.tinymce().getContent())
|
||||
|
||||
model.$field.tinymce({
|
||||
const response = await fetch($('#DeviceBatch_InsuranceDetails_Container').attr('data-updateurl'), {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$('#ajaxInsuranceDetails_ok').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to update insurance details: ' + response.statusText);
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Unable to update insurance details: ' + e);
|
||||
}
|
||||
$('#ajaxInsuranceDetails_loading').hide();
|
||||
}
|
||||
|
||||
$field.tinymce({
|
||||
theme: 'simple',
|
||||
add_unload_trigger: false,
|
||||
schema: "html5",
|
||||
statusbar: false,
|
||||
setup: function (ed) {
|
||||
ed.on('init', function () {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
$(ed.getWin()).blur(function () { updated(); });
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -622,7 +590,7 @@
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr id="DeviceBatch_Comments_Container" data-updateurl="@(Url.Action(MVC.API.DeviceBatch.UpdateComments(Model.DeviceBatch.Id)))">
|
||||
<th>
|
||||
Comments:<br />
|
||||
@AjaxHelpers.AjaxLoader("ajaxComments")
|
||||
@@ -632,53 +600,43 @@
|
||||
{
|
||||
@Html.EditorFor(model => model.DeviceBatch.Comments)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$field: $('#DeviceBatch_Comments'),
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajaxComments_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajaxComments_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = { Comments: model.$field.tinymce().getContent() };
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdateComments(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update comments: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update comments: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
$(function () {
|
||||
const $field = $('#DeviceBatch_Comments');
|
||||
async function updated() {
|
||||
$('#ajaxComments_loading').show();
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('comments', $field.tinymce().getContent())
|
||||
|
||||
model.$field.tinymce({
|
||||
theme: 'simple',
|
||||
add_unload_trigger: false,
|
||||
schema: "html5",
|
||||
statusbar: false,
|
||||
setup: function (ed) {
|
||||
ed.on('init', function () {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
});
|
||||
const response = await fetch($('#DeviceBatch_Comments_Container').attr('data-updateurl'), {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$('#ajaxComments_ok').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to update comments: ' + response.statusText);
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Unable to update comments: ' + e);
|
||||
}
|
||||
$('#ajaxComments_loading').hide();
|
||||
}
|
||||
|
||||
$field.tinymce({
|
||||
theme: 'simple',
|
||||
add_unload_trigger: false,
|
||||
schema: "html5",
|
||||
statusbar: false,
|
||||
setup: function (ed) {
|
||||
ed.on('init', function () {
|
||||
$(ed.getWin()).blur(function () { updated(); });
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
@@ -693,8 +651,7 @@
|
||||
<tr>
|
||||
<th>Attachments:</th>
|
||||
<td>
|
||||
<div id="DeviceBatch_Attachments" class="@(canConfig ? "canAddAttachments" : "cannotAddAttachments")" data-uploadurl="@(Url.Action(MVC.API.DeviceBatch.AttachmentUpload(Model.DeviceBatch.Id, null)))">
|
||||
@Html.AntiForgeryToken()
|
||||
<div id="DeviceBatch_Attachments" class="@(canConfig ? "canAddAttachments" : "cannotAddAttachments")" data-uploadurl="@(Url.Action(MVC.API.DeviceBatch.AttachmentUpload(Model.DeviceBatch.Id, null)))" data-removeurl="@Url.Action(MVC.API.DeviceBatch.AttachmentRemove())">
|
||||
<div class="Disco-AttachmentUpload-DropTarget">
|
||||
<h2>Drop Attachments Here</h2>
|
||||
</div>
|
||||
@@ -708,7 +665,7 @@
|
||||
<img alt="Attachment Thumbnail" src="@(Url.Action(MVC.API.DeviceBatch.AttachmentThumbnail(attachment.Id)))" />
|
||||
</span>
|
||||
<span class="comments" title="@attachment.Comments">
|
||||
@attachment.Comments
|
||||
@(attachment.Comments ?? attachment.Filename)
|
||||
</span><span class="author">@attachment.TechUser.ToString()</span>@if (canConfig)
|
||||
{<text><span class="remove fa fa-times-circle"></span></text>}<span class="timestamp" title="@attachment.Timestamp.ToFullDateTime()" data-livestamp="@attachment.Timestamp.ToUnixEpoc()">@attachment.Timestamp.ToFullDateTime()</span>
|
||||
</a>
|
||||
@@ -926,12 +883,10 @@
|
||||
});
|
||||
//#endregion
|
||||
//#region Remove Attachments
|
||||
$attachmentOutput.find('span.remove').click(removeAttachment);
|
||||
$attachmentOutput.find('span.remove').on('click', removeAttachment);
|
||||
|
||||
function removeAttachment() {
|
||||
$this = $(this).closest('a');
|
||||
|
||||
var data = { id: $this.attr('data-attachmentid') };
|
||||
const attachmentId = $(this).closest('a').attr('data-attachmentid');
|
||||
|
||||
if (!$dialogRemoveAttachment) {
|
||||
$dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({
|
||||
@@ -942,31 +897,28 @@
|
||||
});
|
||||
}
|
||||
|
||||
$dialogRemoveAttachment.dialog("enable");
|
||||
$dialogRemoveAttachment.dialog('option', 'buttons', {
|
||||
"Remove": function () {
|
||||
$dialogRemoveAttachment.dialog("disable");
|
||||
$dialogRemoveAttachment.dialog("option", "buttons", null);
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceBatch.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");
|
||||
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('id', attachmentId);
|
||||
fetch($Attachments.attr('data-removeurl'), {
|
||||
method: 'POST',
|
||||
body: body
|
||||
}).then(r => {
|
||||
if (!r.ok) {
|
||||
alert('Unable to remove attachment: ' + r.statusText);
|
||||
}
|
||||
$dialogRemoveAttachment.dialog('close');
|
||||
}).catch(e => {
|
||||
alert('Unable to remove attachment: ' + e);
|
||||
$dialogRemoveAttachment.dialog('close');
|
||||
});
|
||||
},
|
||||
Cancel: function () {
|
||||
$dialogRemoveAttachment.dialog("close");
|
||||
$(this).dialog("close");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1044,7 +996,7 @@
|
||||
{
|
||||
<button id="DeviceBatch_Decommission" class="button">Decommission All Devices</button>
|
||||
<div id="DeviceBatch_Decommission_Dialog" class="dialog" title="Batch Device Decommission">
|
||||
@using (Html.BeginForm(MVC.API.Device.DeviceBatchDecommission(Model.DeviceBatch.Id), FormMethod.Post))
|
||||
@using (Html.BeginForm(MVC.API.Device.DeviceBatchDecommission(Model.DeviceBatch.Id)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
<div class="clearfix" style="margin-bottom: 10px;">
|
||||
@@ -1101,7 +1053,44 @@
|
||||
}
|
||||
@if (Model.CanDelete)
|
||||
{
|
||||
@Html.ActionLinkButton("Delete", MVC.API.DeviceBatch.Delete(Model.DeviceBatch.Id, true), "buttonDelete")
|
||||
<button id="buttonDelete" type="button" class="button">Delete</button>
|
||||
<div id="dialogConfirmDelete" class="dialog" title="Delete this Device Batch?">
|
||||
@using (Html.BeginForm(MVC.API.DeviceBatch.Delete(Model.DeviceBatch.Id, true)))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
}
|
||||
<p>
|
||||
<i class="fa fa-exclamation-triangle fa-lg warning"></i>
|
||||
This item will be permanently deleted and cannot be recovered. Are you sure?
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
let dialog = null;
|
||||
$('#buttonDelete').on('click', function () {
|
||||
if (!dialog) {
|
||||
dialog = $("#dialogConfirmDelete").dialog({
|
||||
resizable: false,
|
||||
width: 300,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Delete": function () {
|
||||
$(this)
|
||||
.dialog("option", "buttons", null)
|
||||
.find('form').trigger('submit');
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@if (Model.DeviceCount > 0)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,14 @@
|
||||
@{
|
||||
Authorization.Require(Claims.Config.DeviceBatch.ShowTimeline);
|
||||
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), "Timeline");
|
||||
Html.BundleDeferred("~/Style/Timeline");
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Timeline");
|
||||
}
|
||||
<div id="deviceBatchesTimeline" style="height: 550px;">
|
||||
<div id="deviceBatchesTimeline" style="height: 550px;" data-url="@(Url.Action(MVC.API.DeviceBatch.Timeline()))">
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var dataUrl = '@(Url.Action(MVC.API.DeviceBatch.Timeline()))';
|
||||
var tl;
|
||||
|
||||
$(function () {
|
||||
@@ -23,7 +22,7 @@
|
||||
var sixMonthsDate = new Date();
|
||||
sixMonthsDate.setDate(currentDate.getDate());
|
||||
sixMonthsDate.setMonth(currentDate.getMonth() + 6);
|
||||
|
||||
|
||||
var hotZoneStart1 = new Date(currentDate.getFullYear(), 0, 1, 10, 0, 0);
|
||||
var hotZoneEnd1 = new Date(currentDate.getFullYear(), 11, 31, 10, 0, 0);
|
||||
var hotZoneStart2 = new Date(currentDate.getFullYear() + 1, 0, 1, 10, 0, 0);
|
||||
@@ -37,18 +36,18 @@
|
||||
var bandInfos = [
|
||||
Timeline.createHotZoneBandInfo({
|
||||
zones: [
|
||||
{
|
||||
start: hotZoneStart1,
|
||||
end: hotZoneEnd1,
|
||||
magnify: 4,
|
||||
unit: Timeline.DateTime.MONTH
|
||||
},
|
||||
{
|
||||
start: hotZoneStart2,
|
||||
end: hotZoneEnd2,
|
||||
magnify: 4,
|
||||
unit: Timeline.DateTime.MONTH
|
||||
}
|
||||
{
|
||||
start: hotZoneStart1,
|
||||
end: hotZoneEnd1,
|
||||
magnify: 4,
|
||||
unit: Timeline.DateTime.MONTH
|
||||
},
|
||||
{
|
||||
start: hotZoneStart2,
|
||||
end: hotZoneEnd2,
|
||||
magnify: 4,
|
||||
unit: Timeline.DateTime.MONTH
|
||||
}
|
||||
],
|
||||
eventSource: eventSource,
|
||||
width: "85%",
|
||||
@@ -106,17 +105,26 @@
|
||||
});
|
||||
|
||||
// Load Events
|
||||
$.ajax({
|
||||
url: dataUrl,
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
eventSource.loadJSON(data, dataUrl);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to load Timeline Data: ' + errorThrown);
|
||||
async function loadEventsAsync() {
|
||||
try {
|
||||
const dataUrl = $('#deviceBatchesTimeline').attr('data-url');
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
const response = await fetch(dataUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
eventSource.loadJSON(data, dataUrl);
|
||||
} else {
|
||||
alert('Unable to load Timeline Data: ' + response.statusText);
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Unable to load Timeline Data: ' + e);
|
||||
}
|
||||
});
|
||||
}
|
||||
loadEventsAsync();
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Disco.Web.Areas.Config.Views.DeviceBatch
|
||||
#line 1 "..\..\Areas\Config\Views\DeviceBatch\Timeline.cshtml"
|
||||
|
||||
Authorization.Require(Claims.Config.DeviceBatch.ShowTimeline);
|
||||
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), "Timeline");
|
||||
Html.BundleDeferred("~/Style/Timeline");
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Timeline");
|
||||
@@ -61,74 +61,83 @@ WriteLiteral(" id=\"deviceBatchesTimeline\"");
|
||||
|
||||
WriteLiteral(" style=\"height: 550px;\"");
|
||||
|
||||
WriteLiteral(">\r\n</div>\r\n<script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(">\r\n (function () {\r\n var dataUrl = \'");
|
||||
WriteLiteral(" data-url=\"");
|
||||
|
||||
|
||||
#line 12 "..\..\Areas\Config\Views\DeviceBatch\Timeline.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceBatch.Timeline()));
|
||||
#line 8 "..\..\Areas\Config\Views\DeviceBatch\Timeline.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceBatch.Timeline()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\';\r\n var tl;\r\n\r\n $(function () {\r\n\r\n var eventSource = n" +
|
||||
"ew Timeline.DefaultEventSource();\r\n\r\n var currentDate = new Date();\r\n" +
|
||||
" currentDate = new Date(currentDate.getFullYear(), currentDate.getMon" +
|
||||
"th(), currentDate.getDay(), 10, 0, 0);\r\n var tomorrowDate = new Date(" +
|
||||
");\r\n tomorrowDate.setDate(currentDate.getDate() + 1);\r\n va" +
|
||||
"r sixMonthsDate = new Date();\r\n sixMonthsDate.setDate(currentDate.get" +
|
||||
"Date());\r\n sixMonthsDate.setMonth(currentDate.getMonth() + 6);\r\n " +
|
||||
" \r\n var hotZoneStart1 = new Date(currentDate.getFullYear(), 0, " +
|
||||
"1, 10, 0, 0);\r\n var hotZoneEnd1 = new Date(currentDate.getFullYear()," +
|
||||
" 11, 31, 10, 0, 0);\r\n var hotZoneStart2 = new Date(currentDate.getFul" +
|
||||
"lYear() + 1, 0, 1, 10, 0, 0);\r\n var hotZoneEnd2 = new Date(currentDat" +
|
||||
"e.getFullYear() + 1, 11, 31, 10, 0, 0);\r\n //hotZoneEnd.setDate(hotZon" +
|
||||
"eEnd.getDate() - 1);\r\n\r\n //hotZoneStart = hotZoneStart.toLocaleDateSt" +
|
||||
"ring();\r\n //hotZoneEnd = hotZoneEnd.toLocaleDateString();\r\n\r\n\r\n " +
|
||||
" var bandInfos = [\r\n Timeline.createHotZoneBandInfo({\r\n " +
|
||||
" zones: [\r\n {\r\n start: h" +
|
||||
"otZoneStart1,\r\n end: hotZoneEnd1,\r\n " +
|
||||
" magnify: 4,\r\n unit: Timeline.DateTime.MONTH\r\n " +
|
||||
" },\r\n {\r\n start: hotZoneStart" +
|
||||
"2,\r\n end: hotZoneEnd2,\r\n magnify: " +
|
||||
"4,\r\n unit: Timeline.DateTime.MONTH\r\n }" +
|
||||
"\r\n ],\r\n eventSource: eventSource,\r\n " +
|
||||
" width: \"85%\",\r\n intervalUnit: Timeline.DateTime." +
|
||||
"YEAR,\r\n intervalPixels: 150,\r\n timeZone: 1" +
|
||||
"0,\r\n date: sixMonthsDate\r\n }),\r\n " +
|
||||
" Timeline.createBandInfo({\r\n eventSource: eventSource,\r\n " +
|
||||
" width: \"15%\",\r\n intervalUnit: Timeline.DateTi" +
|
||||
"me.YEAR,\r\n intervalPixels: 150,\r\n overview" +
|
||||
": true,\r\n timeZone: 10,\r\n date: sixMonthsD" +
|
||||
"ate\r\n })\r\n ];\r\n bandInfos[1].syncWith = 0;\r" +
|
||||
"\n bandInfos[1].highlight = true;\r\n\r\n for (var i = 0; i < b" +
|
||||
"andInfos.length; i++) {\r\n bandInfos[i].decorators = [\r\n " +
|
||||
" new Timeline.SpanHighlightDecorator({\r\n startDa" +
|
||||
"te: currentDate,\r\n endDate: tomorrowDate,\r\n " +
|
||||
" color: \"#CC2222\",\r\n opacity: 50\r\n " +
|
||||
" }),\r\n new Timeline.SpanHighlightDecorator({\r\n " +
|
||||
" startDate: hotZoneStart1,\r\n endDate: hotZon" +
|
||||
"eEnd1,\r\n color: \"#CEA5A5\",\r\n opaci" +
|
||||
"ty: 50\r\n }),\r\n new Timeline.SpanHighlightD" +
|
||||
"ecorator({\r\n startDate: hotZoneStart2,\r\n " +
|
||||
" endDate: hotZoneEnd2,\r\n color: \"#CCB7B7\",\r\n " +
|
||||
" opacity: 50\r\n })\r\n ];\r\n " +
|
||||
" }\r\n\r\n tl = Timeline.create($(\'#deviceBatchesTimeline\')[0], band" +
|
||||
"Infos);\r\n\r\n var tlResizeLayoutHandle = null;\r\n $(window).r" +
|
||||
"esize(function () {\r\n if (tlResizeLayoutHandle)\r\n " +
|
||||
" window.clearTimeout(tlResizeLayoutHandle);\r\n tlResizeLayoutHa" +
|
||||
"ndle = window.setTimeout(function () {\r\n tlResizeLayoutHandle" +
|
||||
" = null;\r\n tl.layout();\r\n }, 500);\r\n " +
|
||||
" });\r\n\r\n // Load Events\r\n $.ajax({\r\n url: " +
|
||||
"dataUrl,\r\n dataType: \'json\',\r\n type: \'POST\',\r\n " +
|
||||
" success: function (data) {\r\n eventSource.loadJSON" +
|
||||
"(data, dataUrl);\r\n },\r\n error: function (jqXHR, te" +
|
||||
"xtStatus, errorThrown) {\r\n alert(\'Unable to load Timeline Dat" +
|
||||
"a: \' + errorThrown);\r\n }\r\n });\r\n });\r\n\r\n })(" +
|
||||
");\r\n\r\n</script>\r\n");
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n</div>\r\n<script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(">\r\n (function () {\r\n var tl;\r\n\r\n $(function () {\r\n\r\n " +
|
||||
"var eventSource = new Timeline.DefaultEventSource();\r\n\r\n var currentD" +
|
||||
"ate = new Date();\r\n currentDate = new Date(currentDate.getFullYear()," +
|
||||
" currentDate.getMonth(), currentDate.getDay(), 10, 0, 0);\r\n var tomor" +
|
||||
"rowDate = new Date();\r\n tomorrowDate.setDate(currentDate.getDate() + " +
|
||||
"1);\r\n var sixMonthsDate = new Date();\r\n sixMonthsDate.setD" +
|
||||
"ate(currentDate.getDate());\r\n sixMonthsDate.setMonth(currentDate.getM" +
|
||||
"onth() + 6);\r\n\r\n var hotZoneStart1 = new Date(currentDate.getFullYear" +
|
||||
"(), 0, 1, 10, 0, 0);\r\n var hotZoneEnd1 = new Date(currentDate.getFull" +
|
||||
"Year(), 11, 31, 10, 0, 0);\r\n var hotZoneStart2 = new Date(currentDate" +
|
||||
".getFullYear() + 1, 0, 1, 10, 0, 0);\r\n var hotZoneEnd2 = new Date(cur" +
|
||||
"rentDate.getFullYear() + 1, 11, 31, 10, 0, 0);\r\n //hotZoneEnd.setDate" +
|
||||
"(hotZoneEnd.getDate() - 1);\r\n\r\n //hotZoneStart = hotZoneStart.toLocal" +
|
||||
"eDateString();\r\n //hotZoneEnd = hotZoneEnd.toLocaleDateString();\r\n\r\n\r" +
|
||||
"\n var bandInfos = [\r\n Timeline.createHotZoneBandInfo({" +
|
||||
"\r\n zones: [\r\n {\r\n " +
|
||||
" start: hotZoneStart1,\r\n end: hotZoneEnd1,\r\n " +
|
||||
" magnify: 4,\r\n unit: Timeline" +
|
||||
".DateTime.MONTH\r\n },\r\n {\r\n " +
|
||||
" start: hotZoneStart2,\r\n end: hotZ" +
|
||||
"oneEnd2,\r\n magnify: 4,\r\n u" +
|
||||
"nit: Timeline.DateTime.MONTH\r\n }\r\n ],\r" +
|
||||
"\n eventSource: eventSource,\r\n width: \"85%\"" +
|
||||
",\r\n intervalUnit: Timeline.DateTime.YEAR,\r\n " +
|
||||
" intervalPixels: 150,\r\n timeZone: 10,\r\n d" +
|
||||
"ate: sixMonthsDate\r\n }),\r\n Timeline.createBandInfo" +
|
||||
"({\r\n eventSource: eventSource,\r\n width: \"1" +
|
||||
"5%\",\r\n intervalUnit: Timeline.DateTime.YEAR,\r\n " +
|
||||
" intervalPixels: 150,\r\n overview: true,\r\n " +
|
||||
" timeZone: 10,\r\n date: sixMonthsDate\r\n })\r\n" +
|
||||
" ];\r\n bandInfos[1].syncWith = 0;\r\n bandInfos[1]" +
|
||||
".highlight = true;\r\n\r\n for (var i = 0; i < bandInfos.length; i++) {\r\n" +
|
||||
" bandInfos[i].decorators = [\r\n new Timeline.Sp" +
|
||||
"anHighlightDecorator({\r\n startDate: currentDate,\r\n " +
|
||||
" endDate: tomorrowDate,\r\n color: \"#CC2222" +
|
||||
"\",\r\n opacity: 50\r\n }),\r\n " +
|
||||
" new Timeline.SpanHighlightDecorator({\r\n startDate: " +
|
||||
"hotZoneStart1,\r\n endDate: hotZoneEnd1,\r\n " +
|
||||
" color: \"#CEA5A5\",\r\n opacity: 50\r\n " +
|
||||
" }),\r\n new Timeline.SpanHighlightDecorator({\r\n " +
|
||||
" startDate: hotZoneStart2,\r\n endDate: hotZoneEn" +
|
||||
"d2,\r\n color: \"#CCB7B7\",\r\n opacity:" +
|
||||
" 50\r\n })\r\n ];\r\n }\r\n\r\n tl" +
|
||||
" = Timeline.create($(\'#deviceBatchesTimeline\')[0], bandInfos);\r\n\r\n va" +
|
||||
"r tlResizeLayoutHandle = null;\r\n $(window).resize(function () {\r\n " +
|
||||
" if (tlResizeLayoutHandle)\r\n window.clearTimeout(t" +
|
||||
"lResizeLayoutHandle);\r\n tlResizeLayoutHandle = window.setTimeout(" +
|
||||
"function () {\r\n tlResizeLayoutHandle = null;\r\n " +
|
||||
" tl.layout();\r\n }, 500);\r\n });\r\n\r\n // L" +
|
||||
"oad Events\r\n async function loadEventsAsync() {\r\n try " +
|
||||
"{\r\n const dataUrl = $(\'#deviceBatchesTimeline\').attr(\'data-ur" +
|
||||
"l\');\r\n const body = new FormData();\r\n body" +
|
||||
".append(\'__RequestVerificationToken\', document.body.dataset.antiforgery);\r\n " +
|
||||
" const response = await fetch(dataUrl, {\r\n " +
|
||||
"method: \'POST\',\r\n body: body\r\n });\r\n " +
|
||||
" if (response.ok) {\r\n const data = await" +
|
||||
" response.json();\r\n eventSource.loadJSON(data, dataUrl);\r" +
|
||||
"\n } else {\r\n alert(\'Unable to load Tim" +
|
||||
"eline Data: \' + response.statusText);\r\n }\r\n } " +
|
||||
"catch (e) {\r\n alert(\'Unable to load Timeline Data: \' + e);\r\n " +
|
||||
" }\r\n }\r\n loadEventsAsync();\r\n });\r\n\r\n" +
|
||||
" })();\r\n\r\n</script>\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user