a099d68915
Initial Release; Includes Database and MVC refactoring
671 lines
33 KiB
Plaintext
671 lines
33 KiB
Plaintext
@model Disco.Web.Areas.Config.Models.DeviceProfile.ShowModel
|
|
@{
|
|
Authorization.Require(Claims.Config.DeviceProfile.Show);
|
|
|
|
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Profiles", MVC.Config.DeviceProfile.Index(null), Model.DeviceProfile.ToString());
|
|
|
|
var canConfig = Authorization.Has(Claims.Config.DeviceProfile.Configure);
|
|
var canConfigExpression = Authorization.Has(Claims.Config.DeviceProfile.ConfigureComputerNameTemplate);
|
|
var canDelete = (Authorization.Has(Claims.Config.DeviceProfile.Delete) && Model.CanDelete);
|
|
|
|
if (canConfig)
|
|
{
|
|
Html.BundleDeferred("~/Style/jQueryUI/dynatree");
|
|
Html.BundleDeferred("~/ClientScripts/Modules/jQueryUI-DynaTree");
|
|
}
|
|
}
|
|
<div id="configurationDeviceProfileShow" class="form" style="width: 600px">
|
|
<table>
|
|
<tr>
|
|
<th>Id:
|
|
</th>
|
|
<td>
|
|
@Html.DisplayFor(model => model.DeviceProfile.Id)
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Name:
|
|
</th>
|
|
<td>@if (canConfig)
|
|
{
|
|
@Html.TextBoxFor(model => model.DeviceProfile.Name)
|
|
@AjaxHelpers.AjaxSave()
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
var $Name = $('#DeviceProfile_Name');
|
|
var $NameAjaxSave = $Name.next('.ajaxSave');
|
|
$Name
|
|
.watermark('Profile Short Name')
|
|
.focus(function () { $Name.select() })
|
|
.keydown(function (e) {
|
|
$NameAjaxSave.show();
|
|
if (e.which == 13) {
|
|
$(this).blur();
|
|
}
|
|
}).blur(function () {
|
|
$NameAjaxSave.hide();
|
|
})
|
|
.change(function () {
|
|
$NameAjaxSave.hide();
|
|
var $ajaxLoading = $NameAjaxSave.next('.ajaxLoading').show();
|
|
var data = { ProfileName: $Name.val() };
|
|
$.ajax({
|
|
url: '@Url.Action(MVC.API.DeviceProfile.UpdateName(Model.DeviceProfile.Id))',
|
|
dataType: 'json',
|
|
data: data,
|
|
success: function (d) {
|
|
if (d == 'OK') {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
} else {
|
|
$ajaxLoading.hide();
|
|
alert('Unable to update name: ' + d);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('Unable to update name: ' + textStatus);
|
|
$ajaxLoading.hide();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@Model.DeviceProfile.Name
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Short Name:
|
|
</th>
|
|
<td>@if (canConfig)
|
|
{
|
|
@Html.TextBoxFor(model => model.DeviceProfile.ShortName)
|
|
@AjaxHelpers.AjaxSave()
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
var $ShortName = $('#DeviceProfile_ShortName');
|
|
var $ShortNameAjaxSave = $ShortName.next('.ajaxSave');
|
|
$ShortName
|
|
.watermark('Profile Short Name')
|
|
.focus(function () { $ShortName.select() })
|
|
.keydown(function (e) {
|
|
$ShortNameAjaxSave.show();
|
|
if (e.which == 13) {
|
|
$(this).blur();
|
|
}
|
|
}).blur(function () {
|
|
$ShortNameAjaxSave.hide();
|
|
})
|
|
.change(function () {
|
|
$ShortNameAjaxSave.hide();
|
|
var $ajaxLoading = $ShortNameAjaxSave.next('.ajaxLoading').show();
|
|
var data = { ShortName: $ShortName.val() };
|
|
$.ajax({
|
|
url: '@Url.Action(MVC.API.DeviceProfile.UpdateShortName(Model.DeviceProfile.Id))',
|
|
dataType: 'json',
|
|
data: data,
|
|
success: function (d) {
|
|
if (d == 'OK') {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
} else {
|
|
$ajaxLoading.hide();
|
|
alert('Unable to update short name: ' + d);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('Unable to update short name: ' + textStatus);
|
|
$ajaxLoading.hide();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@Model.DeviceProfile.ShortName
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Description:
|
|
</th>
|
|
<td>@if (canConfig)
|
|
{
|
|
@Html.TextBoxFor(model => model.DeviceProfile.Description)
|
|
@AjaxHelpers.AjaxSave()
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
var $Description = $('#DeviceProfile_Description');
|
|
var $DescriptionAjaxSave = $Description.next('.ajaxSave');
|
|
$Description
|
|
.watermark('Profile Description')
|
|
.focus(function () { $Description.select() })
|
|
.keydown(function (e) {
|
|
$DescriptionAjaxSave.show();
|
|
if (e.which == 13) {
|
|
$(this).blur();
|
|
}
|
|
}).blur(function () {
|
|
$DescriptionAjaxSave.hide();
|
|
})
|
|
.change(function () {
|
|
$DescriptionAjaxSave.hide();
|
|
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
|
|
var data = { Description: $Description.val() };
|
|
$.ajax({
|
|
url: '@Url.Action(MVC.API.DeviceProfile.UpdateDescription(Model.DeviceProfile.Id))',
|
|
dataType: 'json',
|
|
data: data,
|
|
success: function (d) {
|
|
if (d == 'OK') {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
} else {
|
|
$ajaxLoading.hide();
|
|
alert('Unable to update description: ' + d);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('Unable to update description: ' + textStatus);
|
|
$ajaxLoading.hide();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@Model.DeviceProfile.Description
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Members</th>
|
|
<td>
|
|
<div><strong>@Model.DeviceCount.ToString("n0")</strong> @(Model.DeviceCount == 1 ? "devices is a member" : "devices are members") of this profile.</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>Distribution Type:
|
|
</th>
|
|
<td>@if (canConfig)
|
|
{
|
|
@Html.DropDownList("DeviceProfile_DistributionType", Model.DeviceProfileDistributionTypes)
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
$('#DeviceProfile_DistributionType').change(function () {
|
|
var $this = $(this);
|
|
var $ajaxLoading = $this.next('.ajaxLoading').show();
|
|
var data = { DistributionType: $this.val() };
|
|
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateDistributionType(Model.DeviceProfile.Id))', data, function (response, result) {
|
|
if (result != 'success' || response != 'OK') {
|
|
alert('Unable to change Distribution Type:\n' + response);
|
|
$ajaxLoading.hide();
|
|
} else {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
@Model.DeviceProfile.DistributionType.ToString()
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Address:
|
|
</th>
|
|
<td>@if (canConfig)
|
|
{
|
|
@Html.DropDownListFor(m => m.DeviceProfile.DefaultOrganisationAddress, Model.OrganisationAddresses.ToSelectListItems(Model.DeviceProfile.DefaultOrganisationAddress, true, "None"))
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
$('#DeviceProfile_DefaultOrganisationAddress').change(function () {
|
|
var $this = $(this);
|
|
var $ajaxLoading = $this.next('.ajaxLoading').show();
|
|
var data = { DefaultOrganisationAddress: $this.val() };
|
|
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateDefaultOrganisationAddress(Model.DeviceProfile.Id))', data, function (response, result) {
|
|
if (result != 'success' || response != 'OK') {
|
|
alert('Unable to change Address:\n' + response);
|
|
$ajaxLoading.hide();
|
|
} else {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
if (Model.DefaultOrganisationAddress == null)
|
|
{
|
|
<span class="smallMessage"><None Specified></span>
|
|
}
|
|
else
|
|
{
|
|
@Model.DefaultOrganisationAddress.ToString()
|
|
}
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Allocate Certificates:
|
|
</th>
|
|
<td>@if (canConfig)
|
|
{
|
|
@Html.DropDownListFor(model => model.DeviceProfile.CertificateProviderId, Model.CertificateProviders.ToSelectListItems(null, true, "Not Allocated"))
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
var $field = $('#DeviceProfile_CertificateProviderId');
|
|
var $ajaxLoading = $field.next('.ajaxLoading');
|
|
$field
|
|
.change(function () {
|
|
$ajaxLoading.show();
|
|
var data = { CertificateProviderId: $field.val() };
|
|
$.ajax({
|
|
url: '@Url.Action(MVC.API.DeviceProfile.UpdateCertificateProviderId(Model.DeviceProfile.Id))',
|
|
dataType: 'json',
|
|
data: data,
|
|
success: function (d) {
|
|
if (d == 'OK') {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
} else {
|
|
$ajaxLoading.hide();
|
|
alert('Unable to update Certificate Provider Id: ' + d);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('Unable to update Certificate Provider Id: ' + textStatus);
|
|
$ajaxLoading.hide();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrEmpty(Model.DeviceProfile.CertificateProviderId))
|
|
{
|
|
<span class="smallMessage"><None Allocated></span>
|
|
}
|
|
else
|
|
{
|
|
var cp = Model.CertificateProviders.FirstOrDefault(p => p.Id == Model.DeviceProfile.CertificateProviderId);
|
|
if (cp == null)
|
|
{
|
|
<span class="smallMessage"><None Allocated></span>
|
|
}
|
|
else
|
|
{
|
|
@cp.Name
|
|
}
|
|
}
|
|
}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Computer Name Template Expression:
|
|
</th>
|
|
<td>@if (canConfig && canConfigExpression)
|
|
{
|
|
@Html.TextBoxFor(model => model.DeviceProfile.ComputerNameTemplate)
|
|
@AjaxHelpers.AjaxSave()
|
|
@AjaxHelpers.AjaxLoader()
|
|
<a id="expressionBrowserAnchor" href="@(Url.Action(MVC.Config.DocumentTemplate.ExpressionBrowser()))"> </a>
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
var $ComputerNameTemplate = $('#DeviceProfile_ComputerNameTemplate');
|
|
var $ajaxSave = $ComputerNameTemplate.next('.ajaxSave');
|
|
$ComputerNameTemplate
|
|
.focus(function () { $ComputerNameTemplate.select() })
|
|
.keydown(function (e) {
|
|
$ajaxSave.show();
|
|
if (e.which == 13) {
|
|
$(this).blur();
|
|
}
|
|
}).blur(function () {
|
|
$ajaxSave.hide();
|
|
})
|
|
.change(function () {
|
|
$ajaxSave.hide();
|
|
var $ajaxLoading = $ajaxSave.next('.ajaxLoading').show();
|
|
var data = { ComputerNameTemplate: $ComputerNameTemplate.val() };
|
|
$.ajax({
|
|
url: '@(Url.Action(MVC.API.DeviceProfile.UpdateComputerNameTemplate(Model.DeviceProfile.Id)))',
|
|
dataType: 'json',
|
|
data: data,
|
|
success: function (d) {
|
|
if (d == 'OK') {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
} else {
|
|
$ajaxLoading.hide();
|
|
alert('Unable to update computer name template: ' + d);
|
|
}
|
|
},
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
alert('Unable to update computer name template: ' + textStatus);
|
|
$ajaxLoading.hide();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrWhiteSpace(Model.DeviceProfile.ComputerNameTemplate))
|
|
{
|
|
<span class="smallMessage"><None Specified></span>
|
|
}
|
|
else
|
|
{
|
|
<div class="code">
|
|
@Model.DeviceProfile.ComputerNameTemplate
|
|
</div>
|
|
}
|
|
}
|
|
<div style="margin-top: 8px;">
|
|
<label for="DeviceProfile_ProvisionADAccount">
|
|
Provision Active Directory Account:
|
|
</label>
|
|
@if (canConfig)
|
|
{
|
|
<input id="DeviceProfile_ProvisionADAccount" type="checkbox" @(Model.DeviceProfile.ProvisionADAccount ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
$('#DeviceProfile_ProvisionADAccount').click(function () {
|
|
var $this = $(this);
|
|
var $ajaxLoading = $this.next('.ajaxLoading').show();
|
|
var data = { ProvisionADAccount: $this.is(':checked') };
|
|
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateProvisionADAccount(Model.DeviceProfile.Id))', data, function (response, result) {
|
|
if (result != 'success' || response != 'OK') {
|
|
alert('Unable to change Provision AD Account:\n' + response);
|
|
$ajaxLoading.hide();
|
|
} else {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
<input id="DeviceProfile_ProvisionADAccount" type="checkbox" @(Model.DeviceProfile.ProvisionADAccount ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty)) disabled="disabled" />
|
|
}
|
|
</div>
|
|
<div style="margin-top: 8px;">
|
|
<label for="DeviceProfile_EnforceComputerNameConvention">
|
|
Enforce Naming Convention:
|
|
</label>
|
|
@if (canConfig)
|
|
{
|
|
<input id="DeviceProfile_EnforceComputerNameConvention" type="checkbox" @(Model.DeviceProfile.EnforceComputerNameConvention ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
$('#DeviceProfile_EnforceComputerNameConvention').click(function () {
|
|
var $this = $(this);
|
|
var $ajaxLoading = $this.next('.ajaxLoading').show();
|
|
var data = { EnforceComputerNameConvention: $this.is(':checked') };
|
|
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateEnforceComputerNameConvention(Model.DeviceProfile.Id))', data, function (response, result) {
|
|
if (result != 'success' || response != 'OK') {
|
|
alert('Unable to change Enforce Computer Name Convention:\n' + response);
|
|
$ajaxLoading.hide();
|
|
} else {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
<input id="DeviceProfile_EnforceComputerNameConvention" type="checkbox" @(Model.DeviceProfile.EnforceComputerNameConvention ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty)) disabled="disabled" />
|
|
}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>Default Organisational Unit:
|
|
</th>
|
|
<td>@if (canConfig)
|
|
{
|
|
@Html.HiddenFor(model => model.DeviceProfile.OrganisationalUnit)
|
|
<div id="displayOrganisationalUnit">
|
|
</div>
|
|
<a id="changeOrganisationalUnit" href="#">Change</a>@AjaxHelpers.AjaxLoader()
|
|
<div id="dialogOrganisationalUnit" title="Default Organisational Unit">
|
|
<div id="treeOrganisationalUnit">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
var ouValue = $('#DeviceProfile_OrganisationalUnit');
|
|
var ouDisplay = $('#displayOrganisationalUnit');
|
|
var ouTree = $('#treeOrganisationalUnit');
|
|
var ouChangeLink = $('#changeOrganisationalUnit');
|
|
var ouTreeLoaded = false;
|
|
var ouFriendlyName = function (ou) {
|
|
return ou.replace(/ou=/gi, '').split(',').reverse().join(' > ');
|
|
};
|
|
var updateDisplayOrganisationalUnit = function () {
|
|
var value = ouValue.val();
|
|
if (value) {
|
|
ouDisplay.text(ouFriendlyName(value));
|
|
} else {
|
|
ouDisplay.text('{Default Computers Container}');
|
|
}
|
|
};
|
|
var ouSet = function (ou) {
|
|
$ajaxLoading = ouChangeLink.next('.ajaxLoading').show();
|
|
var data = { OrganisationalUnit: ou };
|
|
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateOrganisationalUnit(Model.DeviceProfile.Id, null))', data, function (response, result) {
|
|
if (result != 'success' || response != 'OK') {
|
|
alert('Unable to change Organisational Unit:\n' + response);
|
|
$ajaxLoading.hide();
|
|
} else {
|
|
ouValue.val(ou);
|
|
updateDisplayOrganisationalUnit();
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
}
|
|
});
|
|
}
|
|
var ouUpdateTree = function () {
|
|
var dynaTree = ouTree.dynatree("getTree");
|
|
var value = ouValue.val();
|
|
if (value) {
|
|
dynaTree.activateKey(value);
|
|
} else {
|
|
var activeNode = dynaTree.getActiveNode();
|
|
if (activeNode)
|
|
activeNode.deactivate();
|
|
}
|
|
}
|
|
|
|
var ouDialog = $('#dialogOrganisationalUnit').dialog({
|
|
autoOpen: false,
|
|
buttons: {
|
|
'Use Default Container': function () {
|
|
ouSet('');
|
|
$(this).dialog("close");
|
|
},
|
|
'Save': function () {
|
|
var node = ouTree.dynatree("getTree").getActiveNode();
|
|
if (node) {
|
|
ouSet(node.data.key);
|
|
$(this).dialog("close");
|
|
} else {
|
|
alert('Select an Organisational Unit to Save')
|
|
}
|
|
}
|
|
},
|
|
draggable: false,
|
|
modal: true,
|
|
resizable: false,
|
|
width: 400,
|
|
height: 400
|
|
});
|
|
|
|
var ouChange = function () {
|
|
if (!ouTreeLoaded) {
|
|
$.getJSON('@(Url.Action(MVC.API.DeviceProfile.OrganisationalUnits()))', null, function (data) {
|
|
var dynatreeDataTransformer = function (element) {
|
|
var child = {
|
|
title: element.Name,
|
|
key: element.Path,
|
|
isFolder: true
|
|
}
|
|
if (element.Children) {
|
|
child.children = [];
|
|
for (var i = 0; i < element.Children.length; i++) {
|
|
child.children.push(dynatreeDataTransformer(element.Children[i]));
|
|
}
|
|
}
|
|
return child;
|
|
};
|
|
var dynatreeData = [];
|
|
for (var i = 0; i < data.length; i++) {
|
|
dynatreeData.push(dynatreeDataTransformer(data[i]));
|
|
}
|
|
|
|
ouTree.dynatree({
|
|
children: dynatreeData,
|
|
onActivate: function (node) {
|
|
//alert('node selected: ' + node.data.key);
|
|
}
|
|
});
|
|
ouTreeLoaded = true;
|
|
ouUpdateTree();
|
|
});
|
|
} else {
|
|
ouUpdateTree();
|
|
}
|
|
ouDialog.dialog('open');
|
|
};
|
|
|
|
ouChangeLink.click(ouChange);
|
|
updateDisplayOrganisationalUnit();
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrEmpty(Model.DeviceProfile.OrganisationalUnit))
|
|
{
|
|
<span>{Default Computers Container}</span>
|
|
}
|
|
else
|
|
{
|
|
<span>
|
|
@string.Join(" > ", Model.DeviceProfile.OrganisationalUnit.Split(',').Select(s => s.Substring(3)).Reverse())
|
|
</span>
|
|
}
|
|
}
|
|
<div style="margin-top: 8px;">
|
|
<label for="DeviceProfile_EnforceOrganisationalUnit">
|
|
Enforce:
|
|
</label>
|
|
@if (canConfig)
|
|
{
|
|
<input id="DeviceProfile_EnforceOrganisationalUnit" type="checkbox" @(Model.DeviceProfile.EnforceOrganisationalUnit ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty))/>
|
|
@AjaxHelpers.AjaxLoader()
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
$('#DeviceProfile_EnforceOrganisationalUnit').click(function () {
|
|
var $this = $(this);
|
|
var $ajaxLoading = $this.next('.ajaxLoading').show();
|
|
var data = { EnforceOrganisationalUnit: $this.is(':checked') };
|
|
$.getJSON('@Url.Action(MVC.API.DeviceProfile.UpdateEnforceOrganisationalUnit(Model.DeviceProfile.Id))', data, function (response, result) {
|
|
if (result != 'success' || response != 'OK') {
|
|
alert('Unable to change Enforce Organisation Unit:\n' + response);
|
|
$ajaxLoading.hide();
|
|
} else {
|
|
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
}
|
|
else
|
|
{
|
|
<input id="DeviceProfile_EnforceOrganisationalUnit" type="checkbox" @(Model.DeviceProfile.EnforceOrganisationalUnit ? new MvcHtmlString("checked=\"checked\" ") : new MvcHtmlString(string.Empty)) disabled="disabled" />
|
|
}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
@if (canDelete)
|
|
{
|
|
<div id="dialogConfirmDelete" title="Delete this Device Profile?">
|
|
<p>
|
|
<span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
|
|
This item will be permanently deleted and cannot be recovered. Are you sure?
|
|
</p>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(function () {
|
|
|
|
var button = $('#buttonDelete');
|
|
var buttonLink = button.attr('href');
|
|
button.attr('href', '#');
|
|
button.click(function () {
|
|
$("#dialogConfirmDelete").dialog('open');
|
|
});
|
|
|
|
$("#dialogConfirmDelete").dialog({
|
|
resizable: false,
|
|
height: 140,
|
|
modal: true,
|
|
autoOpen: false,
|
|
buttons: {
|
|
"Delete": function () {
|
|
$(this).dialog('disable');
|
|
window.location.href = buttonLink;
|
|
},
|
|
Cancel: function () {
|
|
$(this).dialog("close");
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
</script>
|
|
}
|
|
<div class="actionBar">
|
|
@if (canDelete)
|
|
{
|
|
@Html.ActionLinkButton("Delete", MVC.API.DeviceProfile.Delete(Model.DeviceProfile.Id, true), "buttonDelete")
|
|
}
|
|
@if (Authorization.Has(Claims.Device.Actions.Export))
|
|
{
|
|
@Html.ActionLinkButton("Export Devices", MVC.API.DeviceProfile.ExportDevices(Model.DeviceProfile.Id))
|
|
}
|
|
@if (Authorization.Has(Claims.Device.Search))
|
|
{
|
|
@Html.ActionLinkButton("View Devices", MVC.Search.Query(Model.DeviceProfile.Id.ToString(), "DeviceProfile"))
|
|
}
|
|
</div>
|