402 lines
16 KiB
Plaintext
402 lines
16 KiB
Plaintext
@model Disco.Web.Areas.Config.Models.DeviceModel.ShowModel
|
|
@{
|
|
Authorization.Require(Claims.Config.DeviceModel.Show);
|
|
|
|
var canConfig = Authorization.Has(Claims.Config.DeviceModel.Configure);
|
|
var canViewPlugins = Authorization.Has(Claims.Config.Plugin.Install);
|
|
var isCustom = Model.DeviceModel.IsCustomModel();
|
|
|
|
if (canConfig)
|
|
{
|
|
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
|
|
}
|
|
|
|
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), Model.DeviceModel.ToString());
|
|
}
|
|
<div class="form" style="width: 530px">
|
|
<table>
|
|
<tr>
|
|
<th style="width: 150px">
|
|
Id:
|
|
</th>
|
|
<td>
|
|
@Html.DisplayFor(model => model.DeviceModel.Id)
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Description:
|
|
</th>
|
|
<td>
|
|
@if (canConfig)
|
|
{
|
|
@Html.EditorFor(model => model.DeviceModel.Description)
|
|
@AjaxHelpers.AjaxSave()
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script>
|
|
$(function () {
|
|
document.DiscoFunctions.PropertyChangeHelper(
|
|
$('#DeviceModel_Description'),
|
|
'Model Description',
|
|
'@Url.Action(MVC.API.DeviceModel.UpdateDescription(Model.DeviceModel.Id))',
|
|
'Description'
|
|
);
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@Html.DisplayFor(model => model.DeviceModel.Description)
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Manufacturer:
|
|
</th>
|
|
<td>
|
|
@if (isCustom && canConfig)
|
|
{
|
|
@Html.EditorFor(model => model.DeviceModel.Manufacturer)
|
|
@AjaxHelpers.AjaxSave()
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script>
|
|
$(function () {
|
|
document.DiscoFunctions.PropertyChangeHelper(
|
|
$('#DeviceModel_Manufacturer'),
|
|
'Manufacturer',
|
|
'@Url.Action(MVC.API.DeviceModel.UpdateManufacturer(Model.DeviceModel.Id))',
|
|
'manufacturer'
|
|
);
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@Html.DisplayFor(model => model.DeviceModel.Manufacturer)
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Model:
|
|
</th>
|
|
<td>
|
|
@if (isCustom && canConfig)
|
|
{
|
|
@Html.EditorFor(model => model.DeviceModel.Model)
|
|
@AjaxHelpers.AjaxSave()
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script>
|
|
$(function () {
|
|
document.DiscoFunctions.PropertyChangeHelper(
|
|
$('#DeviceModel_Model'),
|
|
'Model',
|
|
'@Url.Action(MVC.API.DeviceModel.UpdateModel(Model.DeviceModel.Id))',
|
|
'model'
|
|
);
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@Html.DisplayFor(model => model.DeviceModel.Model)
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Statistics</th>
|
|
<td>
|
|
<div><strong>@Model.DeviceCount.ToString("n0")</strong> @(Model.DeviceCount == 1 ? "devices is" : "devices are") of this model type.</div>
|
|
@if (Model.DeviceDecommissionedCount > 0)
|
|
{
|
|
<div class="smallMessage">@Model.DeviceDecommissionedCount.ToString("n0") @(Model.DeviceDecommissionedCount == 1 ? "device is" : "devices are") decommissioned.</div>
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Default Purchase Date:
|
|
</th>
|
|
<td>
|
|
@if (canConfig)
|
|
{
|
|
@Html.EditorFor(model => model.DeviceModel.DefaultPurchaseDate)
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script>
|
|
$(function () {
|
|
var dateField = $('#DeviceModel_DefaultPurchaseDate');
|
|
document.DiscoFunctions.DateChangeHelper(
|
|
dateField,
|
|
'None',
|
|
'@(Url.Action(MVC.API.DeviceModel.UpdateDefaultPurchaseDate(Model.DeviceModel.Id)))',
|
|
'DefaultPurchaseDate',
|
|
null,
|
|
true
|
|
);
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@CommonHelpers.FriendlyDate(Model.DeviceModel.DefaultPurchaseDate, "Unknown")
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Default Warranty Provider:
|
|
</th>
|
|
<td>
|
|
@if (canConfig)
|
|
{
|
|
if (Model.WarrantyProviders.Count > 0)
|
|
{
|
|
@Html.DropDownListFor(model => model.DeviceModel.DefaultWarrantyProvider, Model.WarrantyProviders.ToSelectListItems(Model.DeviceModel.DefaultWarrantyProvider, true, "None"))
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script>
|
|
$(function () {
|
|
document.DiscoFunctions.PropertyChangeHelper(
|
|
$('#DeviceModel_DefaultWarrantyProvider'),
|
|
null,
|
|
'@Url.Action(MVC.API.DeviceModel.UpdateDefaultWarrantyProvider(Model.DeviceModel.Id))',
|
|
'DefaultWarrantyProvider'
|
|
);
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
<span class="smallMessage">No warranty provider plugins installed</span>
|
|
}
|
|
if (canViewPlugins)
|
|
{
|
|
<div class="info-box">
|
|
<p class="fa-p">
|
|
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install warranty provider plugins.
|
|
</p>
|
|
</div>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Model.DeviceModel.DefaultWarrantyProvider == null)
|
|
{
|
|
<span class="smallMessage"><None Specified></span>
|
|
}
|
|
else
|
|
{
|
|
var provider = Model.WarrantyProviders.FirstOrDefault(wp => wp.Id == Model.DeviceModel.DefaultWarrantyProvider);
|
|
if (provider == null)
|
|
{
|
|
<span class="smallMessage"><None Specified></span>
|
|
}
|
|
else
|
|
{
|
|
@provider.Name
|
|
}
|
|
}
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Default Repair Provider:
|
|
</th>
|
|
<td>
|
|
@if (canConfig)
|
|
{
|
|
if (Model.RepairProviders.Count > 0)
|
|
{
|
|
@Html.DropDownListFor(model => model.DeviceModel.DefaultRepairProvider, Model.RepairProviders.ToSelectListItems(Model.DeviceModel.DefaultRepairProvider, true, "None"))
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script>
|
|
$(function () {
|
|
document.DiscoFunctions.PropertyChangeHelper(
|
|
$('#DeviceModel_DefaultRepairProvider'),
|
|
null,
|
|
'@Url.Action(MVC.API.DeviceModel.UpdateDefaultRepairProvider(Model.DeviceModel.Id))',
|
|
'DefaultRepairProvider'
|
|
);
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
<div>No repair provider plugins installed</div>
|
|
}
|
|
if (canViewPlugins)
|
|
{
|
|
<div class="info-box">
|
|
<p class="fa-p">
|
|
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install repair provider plugins.
|
|
</p>
|
|
</div>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Model.DeviceModel.DefaultRepairProvider == null)
|
|
{
|
|
<span class="smallMessage"><None Specified></span>
|
|
}
|
|
else
|
|
{
|
|
var provider = Model.RepairProviders.FirstOrDefault(wp => wp.Id == Model.DeviceModel.DefaultRepairProvider);
|
|
if (provider == null)
|
|
{
|
|
<span class="smallMessage"><None Specified></span>
|
|
}
|
|
else
|
|
{
|
|
@provider.Name
|
|
}
|
|
}
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Type:
|
|
</th>
|
|
<td>
|
|
@Html.DisplayFor(model => model.DeviceModel.ModelType)
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>
|
|
Image:
|
|
</th>
|
|
<td>
|
|
<img alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, Model.DeviceModel.ImageHash()))" />
|
|
@if (canConfig)
|
|
{
|
|
<hr />
|
|
using (Html.BeginForm(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
|
{
|
|
@Html.AntiForgeryToken()
|
|
<input type="file" name="Image" id="Image" style="width: 220px;" />
|
|
<input class="button small" type="submit" value="Upload Image" />
|
|
}
|
|
}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<h2>Components</h2>
|
|
@Html.Partial(MVC.Config.DeviceModel.Views._DeviceComponentsTable, Model.DeviceComponentsModel)
|
|
@Html.Partial(MVC.Config.Shared.Views._DeviceGroupDocumentBulkGenerate, Model)
|
|
<div class="actionBar">
|
|
@if (Model.CanDecommission)
|
|
{
|
|
<button id="DeviceModel_Decommission" class="button">Decommission All Devices</button>
|
|
<div id="DeviceModel_Decommission_Dialog" class="dialog" title="Model Device Decommission">
|
|
@using (Html.BeginForm(MVC.API.Device.DeviceModelDecommission(Model.DeviceModel.Id)))
|
|
{
|
|
@Html.AntiForgeryToken()
|
|
<div class="clearfix" style="margin-bottom: 10px;">
|
|
<i class="fa fa-question-circle fa-lg information"></i> Why are these devices 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="DeviceModel_Decommission_Dialog_Reason_@((int)decommissionReason)"
|
|
name="decommissionReason" value="@((int)decommissionReason)" @((decommissionReason == DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty) />
|
|
<label for="DeviceModel_Decommission_Dialog_Reason_@((int)decommissionReason)">@(decommissionReason.ReasonMessage())</label>
|
|
</li>
|
|
}
|
|
</ul>
|
|
<br />
|
|
<label>
|
|
<input type="checkbox" value="true" name="unassignUsers" />
|
|
Unassign devices users
|
|
</label>
|
|
</div>
|
|
}
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
let buttonDialog = null;
|
|
$('#DeviceModel_Decommission').click(function () {
|
|
if (!buttonDialog) {
|
|
buttonDialog = $('#DeviceModel_Decommission_Dialog')
|
|
.dialog({
|
|
resizable: false,
|
|
modal: true,
|
|
autoOpen: false,
|
|
buttons: {
|
|
"Decommission": function () {
|
|
const $this = $(this);
|
|
$this.find('form').trigger('submit');
|
|
$this.dialog("disable");
|
|
$this.dialog("option", "buttons", null);
|
|
},
|
|
Cancel: function () {
|
|
$(this).dialog("close");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
buttonDialog.dialog('open');
|
|
return false;
|
|
});
|
|
|
|
});
|
|
</script>
|
|
}
|
|
@if (Model.CanDelete)
|
|
{
|
|
<button id="buttonDelete" type="button" class="button">Delete</button>
|
|
<div id="dialogConfirmDelete" class="dialog" title="Delete this Device Model?">
|
|
@using (Html.BeginForm(MVC.API.DeviceModel.Delete(Model.DeviceModel.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)
|
|
{
|
|
if (Authorization.Has(Claims.Device.Actions.Export))
|
|
{
|
|
@Html.ActionLinkButton("Export Devices", MVC.Device.Export(null, Disco.Models.Services.Devices.DeviceExportTypes.Model, Model.DeviceModel.Id))
|
|
}
|
|
if (Authorization.Has(Claims.Device.Search) && Model.DeviceCount > 0)
|
|
{
|
|
@Html.ActionLinkButton(string.Format("View {0} Device{1}", Model.DeviceCount, (Model.DeviceCount != 1 ? "s" : null)), MVC.Search.Query(Model.DeviceModel.Id.ToString(), "DeviceModel"))
|
|
}
|
|
}
|
|
</div>
|