@model Disco.Web.Areas.Config.Models.DeviceFlag.ShowModel @using Disco.Services.Interop.ActiveDirectory; @using Disco.Services.Devices.DeviceFlags; @using Disco.Web.Areas.Config.Models.Shared; @{ Authorization.Require(Claims.Config.DeviceFlag.Show); ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Flags", MVC.Config.DeviceFlag.Index(null), Model.DeviceFlag.ToString()); var canConfig = Authorization.Has(Claims.Config.DeviceFlag.Configure); var canDelete = Authorization.Has(Claims.Config.DeviceFlag.Delete); var canBulkAssignment = Authorization.HasAll(Claims.Device.Actions.AddFlags, Claims.Device.Actions.RemoveFlags, Claims.Device.ShowFlagAssignments); var canShowDevices = Model.CurrentAssignmentCount > 0 && Authorization.HasAll(Claims.Device.Search, Claims.Device.ShowFlagAssignments); var canExportCurrent = Model.CurrentAssignmentCount > 0 && Authorization.Has(Claims.Config.DeviceFlag.Export); var canExportAll = Model.TotalAssignmentCount > 0 && Authorization.Has(Claims.Config.DeviceFlag.Export); var hideAdvanced = Model.Permission.IsDefault() && Model.DeviceFlag.DevicesLinkedGroup == null && Model.DeviceFlag.DeviceUsersLinkedGroup == null && Model.DeviceFlag.OnAssignmentExpression == null && Model.DeviceFlag.OnUnassignmentExpression == null; Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers"); }
@if (hideAdvanced) { }
Id: @Html.DisplayFor(model => model.DeviceFlag.Id)
Name: @if (canConfig) { @Html.EditorFor(model => model.DeviceFlag.Name) @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader() } else { @Model.DeviceFlag.Name }
Description: @if (canConfig) {@Html.EditorFor(model => model.DeviceFlag.Description) @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader() } else {
                    @if (string.IsNullOrEmpty(Model.DeviceFlag.Description))
                    {
                    <None>
                    }
                    else
                    {
                        @Model.DeviceFlag.Description.ToHtmlComment()
                    }
                    
}
Statistics:
@Model.CurrentAssignmentCount device@(Model.CurrentAssignmentCount != 1 ? "s" : null) currently assigned
@Model.TotalAssignmentCount total device historical assignment@(Model.TotalAssignmentCount != 1 ? "s" : null)
Icon: @if (canConfig) {
Update
@using (Html.BeginForm(MVC.API.DeviceFlag.UpdateIconAndColour(id: Model.DeviceFlag.Id, redirect: true))) { @Html.AntiForgeryToken() }
@foreach (var colour in Model.ThemeColours) { }
@foreach (var icon in Model.Icons) { }
}
Scheduled Unassignment: @if (canConfig) { @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader() @:days } else { if (Model.DeviceFlag.DefaultRemoveDays.HasValue) { @Model.DeviceFlag.DefaultRemoveDays days } else { Not Enabled } }

Optionally specify the number of days a flag is removed from a device. If one (1), the flag will be removed that night (midnight).
If the user has permission, the date can be adjusted when assigning the flag. Changing this value does not affect existing assignments.

Assignment Permission
Override:
@if (!Model.Permission.IsDefault()) { var permission = Model.Permission;
@if (permission.Inherit) { Inheriting from Authorization Roles } else { Authorization Roles are Ignored }
if (!permission.HasSubjects()) { There are no users/groups associated with this permission override } else { if (permission.IsSimple()) { @foreach (var subjectId in permission.CanShowSubjectIds) { }
Users/Groups/Roles
@{ int roleId; if (subjectId.StartsWith("[") && int.TryParse(subjectId.Trim('[', ']'), out roleId)) { @Disco.Services.Users.UserService.GetAuthorizationRoleName(roleId) @subjectId } else { @subjectId } }

All users/groups/roles can view, assign, edit assignments, and remove assignments for this flag.

} else { var subjects = permission.AllSubjects(); @foreach (var subjectId in subjects.OrderBy(s => s)) { }
Users/Groups/Roles View Assign Edit Remove
@{ int roleId; if (subjectId.StartsWith("[") && int.TryParse(subjectId.Trim('[', ']'), out roleId)) { @Disco.Services.Users.UserService.GetAuthorizationRoleName(roleId) @subjectId } else { @subjectId } } @if (permission.CanShowSubjectIds.Contains(subjectId)) { } @if (permission.CanAssignSubjectIds.Contains(subjectId)) { } @if (permission.CanEditSubjectIds.Contains(subjectId)) { } @if (permission.CanRemoveSubjectIds.Contains(subjectId)) { }
} } } @if (canConfig) { var permission = Model.Permission;
@using (Html.BeginForm(MVC.API.DeviceFlag.Permission(Model.DeviceFlag.Id))) { @Html.AntiForgeryToken()
@{ var subjects = permission.AllSubjects(); foreach (var subjectId in subjects.OrderBy(s => s)) { } }
User/Group/Role View Assign Edit Remove
@subjectId
}
}

Flag actions are normally authorized globally by @if (Authorization.Has(Claims.DiscoAdminAccount)) { Authorization Roles. } else { Authorization Roles. } Overriding individual flag permissions allows for targeted authorization.

On Assignment
Expression:
@if (canConfig) { @Html.EditorFor(model => model.DeviceFlag.OnAssignmentExpression) @AjaxHelpers.AjaxRemove() @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader() } else { if (string.IsNullOrWhiteSpace(Model.DeviceFlag.OnAssignmentExpression)) { <None Specified> } else {
@Model.DeviceFlag.OnAssignmentExpression
} }

This expression will be evaluated whenever the flag is assigned to a device. The output of the expression will be shown with the flag assignment.

On Unassignment
Expression:
@if (canConfig) { @Html.EditorFor(model => model.DeviceFlag.OnUnassignmentExpression) @AjaxHelpers.AjaxRemove() @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader() } else { if (string.IsNullOrWhiteSpace(Model.DeviceFlag.OnUnassignmentExpression)) { <None Specified> } else {
@Model.DeviceFlag.OnUnassignmentExpression
} }

This expression will be evaluated whenever the flag is removed from a device. The output of the expression will be shown with the flag assignment.

Linked Groups:
@Html.Partial(MVC.Config.Shared.Views.LinkedGroupInstance, new LinkedGroupModel() { CanConfigure = canConfig, CategoryDescription = DeviceFlagDevicesManagedGroup.GetCategoryDescription(Model.DeviceFlag), Description = DeviceFlagDevicesManagedGroup.GetDescription(Model.DeviceFlag), ManagedGroup = Model.DevicesLinkedGroup, IncludeFilterBeginDate = true, UpdateUrl = Url.Action(MVC.API.DeviceFlag.UpdateDevicesLinkedGroup(Model.DeviceFlag.Id, redirect: true)) }) @Html.Partial(MVC.Config.Shared.Views.LinkedGroupInstance, new LinkedGroupModel() { CanConfigure = canConfig, CategoryDescription = DeviceFlagDeviceAssignedUsersManagedGroup.GetCategoryDescription(Model.DeviceFlag), Description = DeviceFlagDeviceAssignedUsersManagedGroup.GetDescription(Model.DeviceFlag), ManagedGroup = Model.AssignedUserLinkedGroup, IncludeFilterBeginDate = true, UpdateUrl = Url.Action(MVC.API.DeviceFlag.UpdateAssignedUserLinkedGroup(Model.DeviceFlag.Id, redirect: true)) }) @if (canConfig) { @Html.Partial(MVC.Config.Shared.Views.LinkedGroupShared) }
@if (canBulkAssignment || canDelete || canShowDevices || canExportCurrent || canExportAll) {
@if (canExportCurrent) { @Html.ActionLinkButton("Export Current Assignments", MVC.Config.DeviceFlag.Export(null, Model.DeviceFlag.Id, true), "Config_DeviceFlags_Actions_ExportCurrent_Button") } @if (canExportAll) { @Html.ActionLinkButton("Export All Assignments", MVC.Config.DeviceFlag.Export(null, Model.DeviceFlag.Id, false), "Config_DeviceFlags_Actions_ExportAll_Button") } @if (canBulkAssignment) { Bulk Assign Devices

Select the mode used to assign devices:

Add

Specified devices will have this flag added. Devices who already have this flag will be skipped.

Override

Specified devices will have this flag added. Specified devices which already have this flag will be skipped. Devices who already have this flag but are not specified will have the flag removed.

Enter multiple Device Serial Numbers separated by <new line>, commas (,) or semicolons (;).

Loading current assignments...

@Html.AntiForgeryToken()

Comments:

} @if (canDelete) {
@using (Html.BeginForm(MVC.API.DeviceFlag.Delete(Model.DeviceFlag.Id, true))) { @Html.AntiForgeryToken() }

This item will be permanently deleted and cannot be recovered.

@if (Model.CurrentAssignmentCount > 0) { @Model.CurrentAssignmentCount device@(Model.CurrentAssignmentCount != 1 ? "s are" : " is") currently assigned

} Are you sure?

} @if (canShowDevices) { @Html.ActionLinkButton(string.Format("Show {0} device{1}", Model.CurrentAssignmentCount, (Model.CurrentAssignmentCount == 1 ? null : "s")), MVC.Search.Query(Model.DeviceFlag.Id.ToString(), "DeviceFlag"), "Config_DeviceFlags_Actions_ShowDevices_Button") }
}