#138 device flags configuration API and UI

This commit is contained in:
Gary Sharp
2024-01-14 17:59:30 +11:00
parent cd858c2215
commit 6ce6e2cccf
32 changed files with 6242 additions and 54 deletions
@@ -0,0 +1,123 @@
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using System;
using System.Data.Entity;
using System.Linq;
using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers
{
public partial class DeviceFlagAssignmentController : AuthorizedDatabaseController
{
const string pComments = "comments";
public virtual ActionResult Update(int id, string key, string value = null, bool? redirect = null)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException(nameof(id));
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException(nameof(key));
var assignment = Database.DeviceFlagAssignments.FirstOrDefault(a => a.Id == id);
if (assignment != null)
{
switch (key.ToLower())
{
case pComments:
UpdateComments(assignment, value);
break;
default:
throw new Exception("Invalid Update Key");
}
}
else
{
throw new Exception("Invalid Device Flag Assignment Id");
}
if (redirect.HasValue && redirect.Value)
return Redirect($"{Url.Action(MVC.Device.Show(assignment.DeviceSerialNumber))}#DeviceDetailTab-Flags");
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect.HasValue && redirect.Value)
throw;
else
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#region Update Shortcut Methods
[DiscoAuthorizeAny(Claims.Device.Actions.EditFlags)]
public virtual ActionResult UpdateComments(int id, string Comments = null, bool? redirect = null)
{
return Update(id, pComments, Comments, redirect);
}
#endregion
#region Update Properties
private void UpdateComments(DeviceFlagAssignment assignment, string Comments)
{
if (!assignment.CanEditComments())
throw new InvalidOperationException("Editing comments for device flags is denied");
assignment.OnEditComments(Comments);
Database.SaveChanges();
}
#endregion
#region Actions
[DiscoAuthorizeAny(Claims.Device.Actions.AddFlags)]
public virtual ActionResult AddDevice(int id, string DeviceSerialNumber, string Comments)
{
Database.Configuration.LazyLoadingEnabled = true;
var flag = Database.DeviceFlags.Find(id);
if (flag == null)
throw new ArgumentException("Invalid Device Flag Id", nameof(id));
var device = Database.Devices.Include(u => u.DeviceFlagAssignments).FirstOrDefault(d => d.SerialNumber == DeviceSerialNumber);
if (device == null)
throw new ArgumentException("Invalid Device Serial Number", nameof(DeviceSerialNumber));
if (!device.CanAddDeviceFlag(flag))
throw new InvalidOperationException("Adding device flag is denied");
var addingUser = Database.Users.Find(CurrentUser.UserId);
var assignment = device.OnAddDeviceFlag(Database, flag, addingUser, Comments);
Database.SaveChanges();
return Redirect($"{Url.Action(MVC.Device.Show(device.SerialNumber))}#DeviceDetailTab-Flags");
}
[DiscoAuthorizeAny(Claims.Device.Actions.RemoveFlags)]
public virtual ActionResult RemoveDevice(int id)
{
Database.Configuration.LazyLoadingEnabled = true;
var assignment = Database.DeviceFlagAssignments.FirstOrDefault(a => a.Id == id);
if (assignment == null)
throw new ArgumentException("Invalid Device Flag Assignment Id", nameof(id));
if (!assignment.CanRemove())
throw new InvalidOperationException("Removing device flag assignment is denied");
var removingUser = Database.Users.Find(CurrentUser.UserId);
assignment.OnRemove(Database, removingUser);
Database.SaveChanges();
return Redirect($"{Url.Action(MVC.Device.Show(assignment.DeviceSerialNumber))}#DeviceDetailTab-Flags");
}
#endregion
}
}
@@ -0,0 +1,454 @@
using Disco.Models.Repository;
using Disco.Models.Services.Devices.DeviceFlag;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Devices.DeviceFlags;
using Disco.Services.Exporting;
using Disco.Services.Interop.ActiveDirectory;
using Disco.Services.Tasks;
using Disco.Services.Web;
using Disco.Web.Areas.Config.Models.DeviceFlag;
using Disco.Web.Extensions;
using System;
using System.Linq;
using System.Web;
using System.Web.Caching;
using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers
{
public partial class DeviceFlagController : AuthorizedDatabaseController
{
const string pName = "name";
const string pDescription = "description";
const string pIcon = "icon";
const string pIconColour = "iconcolour";
const string pOnAssignmentExpression = "onassignmentexpression";
const string pOnUnassignmentExpression = "onunassignmentexpression";
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult Update(int id, string key, string value = null, bool? redirect = null)
{
Authorization.Require(Claims.Config.DeviceFlag.Configure);
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException("key");
var flag = Database.DeviceFlags.Find(id);
if (flag != null)
{
switch (key.ToLower())
{
case pName:
UpdateName(flag, value);
break;
case pDescription:
UpdateDescription(flag, value);
break;
case pIcon:
UpdateIcon(flag, value);
break;
case pIconColour:
UpdateIconColour(flag, value);
break;
case pOnAssignmentExpression:
UpdateOnAssignmentExpression(flag, value);
break;
case pOnUnassignmentExpression:
UpdateOnUnassignmentExpression(flag, value);
break;
default:
throw new Exception("Invalid Update Key");
}
}
else
{
throw new Exception("Invalid Device Flag Id");
}
if (redirect.HasValue && redirect.Value)
return RedirectToAction(MVC.Config.DeviceFlag.Index(flag.Id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect.HasValue && redirect.Value)
throw;
else
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#region Update Shortcut Methods
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateName(int id, string FlagName = null, bool? redirect = null)
{
return Update(id, pName, FlagName, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateDescription(int id, string Description = null, bool? redirect = null)
{
return Update(id, pDescription, Description, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateIcon(int id, string Icon = null, bool? redirect = null)
{
return Update(id, pIcon, Icon, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateIconColour(int id, string IconColour = null, bool? redirect = null)
{
return Update(id, pIconColour, IconColour, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateIconAndColour(int id, string Icon = null, string IconColour = null, bool redirect = false)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
var DeviceFlag = Database.DeviceFlags.Find(id);
if (DeviceFlag != null)
{
UpdateIconAndColour(DeviceFlag, Icon, IconColour);
}
else
{
throw new ArgumentException("Invalid Device Flag Id", "id");
}
if (redirect)
return RedirectToAction(MVC.Config.DeviceFlag.Index(DeviceFlag.Id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateOnAssignmentExpression(int id, string OnAssignmentExpression = null, bool redirect = false)
{
return Update(id, pOnAssignmentExpression, OnAssignmentExpression, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateOnUnassignmentExpression(int id, string OnUnassignmentExpression = null, bool redirect = false)
{
return Update(id, pOnUnassignmentExpression, OnUnassignmentExpression, redirect);
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateDevicesLinkedGroup(int id, string GroupId = null, DateTime? FilterBeginDate = null, bool redirect = false)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
var deviceFlag = Database.DeviceFlags.Find(id);
if (deviceFlag == null)
throw new ArgumentException("Invalid Device Flag Id", "id");
var syncTaskStatus = UpdateDevicesLinkedGroup(deviceFlag, GroupId, FilterBeginDate);
if (redirect)
if (syncTaskStatus == null)
return RedirectToAction(MVC.Config.DeviceFlag.Index(deviceFlag.Id));
else
{
syncTaskStatus.SetFinishedUrl(Url.Action(MVC.Config.DeviceFlag.Index(deviceFlag.Id)));
return RedirectToAction(MVC.Config.Logging.TaskStatus(syncTaskStatus.SessionId));
}
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect)
throw;
else
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult UpdateAssignedUserLinkedGroup(int id, string GroupId = null, DateTime? FilterBeginDate = null, bool redirect = false)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
var DeviceFlag = Database.DeviceFlags.Find(id);
if (DeviceFlag == null)
throw new ArgumentException("Invalid Device Flag Id", "id");
var syncTaskStatus = UpdateAssignedUserLinkedGroup(DeviceFlag, GroupId, FilterBeginDate);
if (redirect)
if (syncTaskStatus == null)
return RedirectToAction(MVC.Config.DeviceFlag.Index(DeviceFlag.Id));
else
{
syncTaskStatus.SetFinishedUrl(Url.Action(MVC.Config.DeviceFlag.Index(DeviceFlag.Id)));
return RedirectToAction(MVC.Config.Logging.TaskStatus(syncTaskStatus.SessionId));
}
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect)
throw;
else
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
#endregion
#region Update Properties
private void UpdateIconAndColour(DeviceFlag deviceFlag, string icon, string iconColour)
{
if (string.IsNullOrWhiteSpace(icon))
throw new ArgumentNullException("Icon");
if (string.IsNullOrWhiteSpace(iconColour))
throw new ArgumentNullException("IconColour");
if (deviceFlag.Icon != icon ||
deviceFlag.IconColour != iconColour)
{
deviceFlag.Icon = icon;
deviceFlag.IconColour = iconColour;
DeviceFlagService.Update(Database, deviceFlag);
}
}
private void UpdateIcon(DeviceFlag deviceFlag, string icon)
{
if (string.IsNullOrWhiteSpace(icon))
throw new ArgumentNullException("Icon");
if (deviceFlag.Icon != icon)
{
deviceFlag.Icon = icon;
DeviceFlagService.Update(Database, deviceFlag);
}
}
private void UpdateIconColour(DeviceFlag deviceFlag, string iconColour)
{
if (string.IsNullOrWhiteSpace(iconColour))
throw new ArgumentNullException("IconColour");
if (deviceFlag.IconColour != iconColour)
{
deviceFlag.IconColour = iconColour;
DeviceFlagService.Update(Database, deviceFlag);
}
}
private void UpdateName(DeviceFlag deviceFlag, string name)
{
if (deviceFlag.Name != name)
{
deviceFlag.Name = name;
DeviceFlagService.Update(Database, deviceFlag);
}
}
private void UpdateDescription(DeviceFlag deviceFlag, string description)
{
if (deviceFlag.Description != description)
{
deviceFlag.Description = description;
DeviceFlagService.Update(Database, deviceFlag);
}
}
private void UpdateOnAssignmentExpression(DeviceFlag deviceFlag, string onAssignmentExpression)
{
if (string.IsNullOrWhiteSpace(onAssignmentExpression))
{
deviceFlag.OnAssignmentExpression = null;
}
else
{
deviceFlag.OnAssignmentExpression = onAssignmentExpression.Trim();
}
// Invalidate Cache
deviceFlag.OnAssignmentExpressionInvalidateCache();
DeviceFlagService.Update(Database, deviceFlag);
}
private void UpdateOnUnassignmentExpression(DeviceFlag deviceFlag, string onUnassignmentExpression)
{
if (string.IsNullOrWhiteSpace(onUnassignmentExpression))
{
deviceFlag.OnUnassignmentExpression = null;
}
else
{
deviceFlag.OnUnassignmentExpression = onUnassignmentExpression.Trim();
}
// Invalidate Cache
deviceFlag.OnUnassignmentExpressionInvalidateCache();
DeviceFlagService.Update(Database, deviceFlag);
}
private ScheduledTaskStatus UpdateDevicesLinkedGroup(DeviceFlag deviceFlag, string devicesLinkedGroup, DateTime? filterBeginDate)
{
var configJson = ADManagedGroup.ValidConfigurationToJson(DeviceFlagDevicesManagedGroup.GetKey(deviceFlag), devicesLinkedGroup, filterBeginDate);
if (deviceFlag.DevicesLinkedGroup != configJson)
{
deviceFlag.DevicesLinkedGroup = configJson;
DeviceFlagService.Update(Database, deviceFlag);
if (deviceFlag.DevicesLinkedGroup != null && DeviceFlagDevicesManagedGroup.TryGetManagedGroup(deviceFlag, out var managedGroup))
{
// Sync Group
return ADManagedGroupsSyncTask.ScheduleSync(managedGroup);
}
}
return null;
}
private ScheduledTaskStatus UpdateAssignedUserLinkedGroup(DeviceFlag deviceFlag, string assignedUserLinkedGroup, DateTime? filterBeginDate)
{
var configJson = ADManagedGroup.ValidConfigurationToJson(DeviceFlagDeviceAssignedUsersManagedGroup.GetKey(deviceFlag), assignedUserLinkedGroup, filterBeginDate);
if (deviceFlag.DeviceUsersLinkedGroup != configJson)
{
deviceFlag.DeviceUsersLinkedGroup = configJson;
DeviceFlagService.Update(Database, deviceFlag);
if (deviceFlag.DeviceUsersLinkedGroup != null && DeviceFlagDeviceAssignedUsersManagedGroup.TryGetManagedGroup(deviceFlag, out var managedGroup))
{
// Sync Group
return ADManagedGroupsSyncTask.ScheduleSync(managedGroup);
}
}
return null;
}
#endregion
#region Actions
[DiscoAuthorizeAll(Claims.Config.DeviceFlag.Configure, Claims.Config.DeviceFlag.Delete)]
public virtual ActionResult Delete(int id, bool? redirect = false)
{
try
{
var uf = Database.DeviceFlags.FirstOrDefault(f => f.Id == id);
if (uf != null)
{
var status = DeviceFlagDeleteTask.ScheduleNow(uf.Id);
status.SetFinishedUrl(Url.Action(MVC.Config.DeviceFlag.Index(null)));
if (redirect.HasValue && redirect.Value)
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
throw new ArgumentException("Invalid Device Flag Id", nameof(id));
}
catch (Exception ex)
{
if (redirect.HasValue && redirect.Value)
throw;
else
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorizeAll(Claims.Config.DeviceFlag.Configure, Claims.Device.Actions.AddFlags, Claims.Device.Actions.RemoveFlags, Claims.Device.ShowFlagAssignments)]
public virtual ActionResult BulkAssignDevices(int id, bool Override, string DeviceSerialNumbers = null, string Comments = null)
{
if (id < 0)
throw new ArgumentNullException("id");
var flag = Database.DeviceFlags.FirstOrDefault(f => f.Id == id);
if (flag == null)
throw new ArgumentException("Invalid Device Flag Id", nameof(id));
var serialNumbers = DeviceSerialNumbers.Split(new string[] { Environment.NewLine, ",", ";" }, StringSplitOptions.RemoveEmptyEntries).Select(d => d.Trim()).Where(d => !string.IsNullOrEmpty(d)).ToList();
var taskStatus = DeviceFlagBulkAssignTask.ScheduleBulkAssignDevices(flag, CurrentUser, Comments, serialNumbers, Override);
taskStatus.SetFinishedUrl(Url.Action(MVC.Config.DeviceFlag.Index(flag.Id)));
return RedirectToAction(MVC.Config.Logging.TaskStatus(taskStatus.SessionId));
}
[DiscoAuthorizeAll(Claims.Config.DeviceFlag.Configure, Claims.Device.Actions.AddFlags, Claims.Device.Actions.RemoveFlags, Claims.Device.ShowFlagAssignments)]
public virtual ActionResult AssignedDevices(int id)
{
if (id < 0)
throw new ArgumentNullException(nameof(id));
var flag = Database.DeviceFlags.FirstOrDefault(f => f.Id == id);
if (flag == null)
throw new ArgumentException("Invalid Device Flag Id", nameof(id));
var serialNumbers = Database
.DeviceFlagAssignments
.Where(a => a.DeviceFlagId == flag.Id && !a.RemovedDate.HasValue)
.OrderBy(a => a.DeviceSerialNumber).Select(a => a.DeviceSerialNumber).ToList();
return Json(serialNumbers, JsonRequestBehavior.AllowGet);
}
#endregion
#region Exporting
internal const string ExportSessionCacheKey = "DeviceFlagExportContext_{0}";
[DiscoAuthorize(Claims.Config.DeviceFlag.Export)]
public virtual ActionResult Export(ExportModel Model)
{
if (Model == null || Model.Options == null)
throw new ArgumentNullException(nameof(Model));
// Start Export
var exportContext = DeviceFlagExportTask.ScheduleNow(Model.Options);
// Store Export Context in Web Cache
string key = string.Format(ExportSessionCacheKey, exportContext.TaskStatus.SessionId);
HttpRuntime.Cache.Insert(key, exportContext, null, DateTime.Now.AddMinutes(60), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
// Set Task Finished Url
var finishedActionResult = MVC.Config.DeviceFlag.Export(exportContext.TaskStatus.SessionId, null, null);
exportContext.TaskStatus.SetFinishedUrl(Url.Action(finishedActionResult));
// Try waiting for completion
if (exportContext.TaskStatus.WaitUntilFinished(TimeSpan.FromSeconds(2)))
return RedirectToAction(finishedActionResult);
else
return RedirectToAction(MVC.Config.Logging.TaskStatus(exportContext.TaskStatus.SessionId));
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Export)]
public virtual ActionResult ExportRetrieve(string Id)
{
if (string.IsNullOrWhiteSpace(Id))
throw new ArgumentNullException("Id");
string key = string.Format(ExportSessionCacheKey, Id);
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<DeviceFlagExportOptions>;
if (context == null)
throw new ArgumentException("The Id specified is invalid, or the export data expired (60 minutes)", nameof(Id));
if (context.Result == null || context.Result.Result == null)
throw new ArgumentException("The export session is still running, or failed to complete successfully", nameof(Id));
var fileStream = context.Result.Result;
return this.File(fileStream.GetBuffer(), 0, (int)fileStream.Length, context.Result.MimeType, context.Result.Filename);
}
#endregion
}
}
@@ -0,0 +1,159 @@
using Disco.Models.Areas.Config.UI.DeviceFlag;
using Disco.Models.Repository;
using Disco.Models.Services.Devices.DeviceFlag;
using Disco.Models.UI.Config.DeviceFlag;
using Disco.Services.Authorization;
using Disco.Services.Devices.DeviceFlags;
using Disco.Services.Exporting;
using Disco.Services.Extensions;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using Disco.Web.Areas.Config.Models.DeviceFlag;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class DeviceFlagController : AuthorizedDatabaseController
{
[DiscoAuthorize(Claims.Config.DeviceFlag.Show)]
public virtual ActionResult Index(int? id)
{
if (id.HasValue)
{
// Show
var m = Database.DeviceFlags.Where(f => f.Id == id.Value).Select(f =>
new ShowModel()
{
DeviceFlag = f,
CurrentAssignmentCount = f.DeviceFlagAssignments.Count(a => !a.RemovedDate.HasValue),
TotalAssignmentCount = f.DeviceFlagAssignments.Count()
}).FirstOrDefault();
if (m == null)
throw new ArgumentException("Invalid Device Flag Id");
if (DeviceFlagDevicesManagedGroup.TryGetManagedGroup(m.DeviceFlag, out var devicesManagedGroup))
m.DevicesLinkedGroup = devicesManagedGroup;
if (DeviceFlagDeviceAssignedUsersManagedGroup.TryGetManagedGroup(m.DeviceFlag, out var assignedUsersManagedGroup))
m.AssignedUserLinkedGroup = assignedUsersManagedGroup;
if (Authorization.Has(Claims.Config.DeviceFlag.Configure))
{
m.Icons = UIHelpers.Icons;
m.ThemeColours = UIHelpers.ThemeColours;
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagShowModel>(this.ControllerContext, m);
return View(MVC.Config.DeviceFlag.Views.Show, m);
}
else
{
// List Index
var m = new Models.DeviceFlag.IndexModel()
{
DeviceFlags = Database.DeviceFlags
.Select(uf => new
{
flag = uf,
assignmentCount = uf.DeviceFlagAssignments.Count(fa => !fa.RemovedDate.HasValue)
})
.ToDictionary(
pair => pair.flag,
pair => pair.assignmentCount)
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagIndexModel>(this.ControllerContext, m);
return View(m);
}
}
[DiscoAuthorizeAll(Claims.Config.DeviceFlag.Create, Claims.Config.DeviceFlag.Configure)]
public virtual ActionResult Create()
{
// Default Queue
var m = new CreateModel()
{
DeviceFlag = new DeviceFlag()
{
Icon = DeviceFlagService.RandomUnusedIcon(),
IconColour = DeviceFlagService.RandomUnusedThemeColour()
}
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagCreateModel>(this.ControllerContext, m);
return View(m);
}
[DiscoAuthorizeAll(Claims.Config.DeviceFlag.Create, Claims.Config.DeviceFlag.Configure), HttpPost]
public virtual ActionResult Create(CreateModel model)
{
if (ModelState.IsValid)
{
// Check for Existing
var existing = Database.DeviceFlags.Where(m => m.Name == model.DeviceFlag.Name).FirstOrDefault();
if (existing == null)
{
var flag = DeviceFlagService.CreateDeviceFlag(Database, model.DeviceFlag);
return RedirectToAction(MVC.Config.DeviceFlag.Index(flag.Id));
}
else
{
ModelState.AddModelError("Name", "A Device Flag with this name already exists.");
}
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagCreateModel>(this.ControllerContext, model);
return View(model);
}
#region Export
[DiscoAuthorizeAny(Claims.Config.DeviceFlag.Export), HttpGet]
public virtual ActionResult Export(string DownloadId, int? DeviceFlagId, bool? CurrentOnly)
{
var m = new ExportModel()
{
Options = DeviceFlagExportOptions.DefaultOptions(),
DeviceFlags = DeviceFlagService.GetDeviceFlags(),
};
if (!string.IsNullOrWhiteSpace(DownloadId))
{
string key = string.Format(API.Controllers.DeviceFlagController.ExportSessionCacheKey, DownloadId);
var context = HttpRuntime.Cache.Get(key) as ExportTaskContext<DeviceFlagExportOptions>;
if (context != null)
{
m.ExportSessionResult = context.Result;
m.ExportSessionId = DownloadId;
}
}
if (DeviceFlagId.HasValue && CurrentOnly.HasValue)
{
m.Options.DeviceFlagIds = new List<int>() { DeviceFlagId.Value };
m.Options.CurrentOnly = CurrentOnly.Value;
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagExportModel>(this.ControllerContext, m);
return View(m);
}
#endregion
}
}
@@ -0,0 +1,9 @@
using Disco.Models.UI.Config.DeviceFlag;
namespace Disco.Web.Areas.Config.Models.DeviceFlag
{
public class CreateModel : ConfigDeviceFlagCreateModel
{
public Disco.Models.Repository.DeviceFlag DeviceFlag { get; set; }
}
}
@@ -0,0 +1,17 @@
using Disco.Models.Areas.Config.UI.DeviceFlag;
using Disco.Models.Services.Devices.DeviceFlag;
using Disco.Models.Services.Exporting;
using System.Collections.Generic;
namespace Disco.Web.Areas.Config.Models.DeviceFlag
{
public class ExportModel : ConfigDeviceFlagExportModel
{
public DeviceFlagExportOptions Options { get; set; }
public string ExportSessionId { get; set; }
public ExportResult ExportSessionResult { get; set; }
public List<Disco.Models.Repository.DeviceFlag> DeviceFlags { get; set; }
}
}
@@ -0,0 +1,10 @@
using Disco.Models.UI.Config.DeviceFlag;
using System.Collections.Generic;
namespace Disco.Web.Areas.Config.Models.DeviceFlag
{
public class IndexModel : ConfigDeviceFlagIndexModel
{
public Dictionary<Disco.Models.Repository.DeviceFlag, int> DeviceFlags { get; set; }
}
}
@@ -0,0 +1,20 @@
using Disco.Models.UI.Config.DeviceFlag;
using Disco.Services.Devices.DeviceFlags;
using System.Collections.Generic;
namespace Disco.Web.Areas.Config.Models.DeviceFlag
{
public class ShowModel : ConfigDeviceFlagShowModel
{
public Disco.Models.Repository.DeviceFlag DeviceFlag { get; set; }
public int CurrentAssignmentCount { get; set; }
public int TotalAssignmentCount { get; set; }
public DeviceFlagDevicesManagedGroup DevicesLinkedGroup { get; set; }
public DeviceFlagDeviceAssignedUsersManagedGroup AssignedUserLinkedGroup { get; set; }
public IEnumerable<KeyValuePair<string, string>> Icons { get; set; }
public IEnumerable<KeyValuePair<string, string>> ThemeColours { get; set; }
}
}
@@ -72,7 +72,14 @@
<i class="fa fa-cog"></i>@Html.ActionLinkClass("Profiles", MVC.Config.DeviceProfile.Index(), "config")
<div class="pageMenuBlurb">
Configure Device Profiles including computer name generation, distribution and Active
Directory OU layout.
Directory OU layout.
</div>
}
@if (Authorization.Has(Claims.Config.DeviceFlag.Show))
{
<i class="fa fa-cog"></i>@Html.ActionLinkClass("Flags", MVC.Config.DeviceFlag.Index(), "config")
<div class="pageMenuBlurb">
Create and manage device flags.
</div>
}
@if (Authorization.Has(Claims.Config.Enrolment.Show))
@@ -114,7 +121,7 @@
<h2>Users</h2>
@if (Authorization.Has(Claims.Config.UserFlag.Show))
{
<i class="fa fa-cog"></i>@Html.ActionLinkClass("User Flags", MVC.Config.UserFlag.Index(), "config")
<i class="fa fa-cog"></i>@Html.ActionLinkClass("Flags", MVC.Config.UserFlag.Index(), "config")
<div class="pageMenuBlurb">
Create and manage user flags.
</div>
@@ -508,8 +508,8 @@ WriteLiteral(" <div");
WriteLiteral(" class=\"pageMenuBlurb\"");
WriteLiteral(">\r\n Configure Device Profiles including computer name " +
"generation, distribution and Active\r\n Directory OU layout.\r\n " +
" </div>\r\n");
"generation, distribution and Active\r\n Directory OU la" +
"yout.\r\n </div>\r\n");
#line 77 "..\..\Areas\Config\Views\Config\Index.cshtml"
@@ -522,7 +522,7 @@ WriteLiteral(" ");
#line 78 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.Has(Claims.Config.Enrolment.Show))
if (Authorization.Has(Claims.Config.DeviceFlag.Show))
{
@@ -542,13 +542,63 @@ WriteLiteral("></i>");
#line hidden
#line 80 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("Enrolment", MVC.Config.Enrolment.Index(), "config"));
Write(Html.ActionLinkClass("Flags", MVC.Config.DeviceFlag.Index(), "config"));
#line default
#line hidden
#line 80 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"pageMenuBlurb\"");
WriteLiteral(">\r\n Create and manage device flags.\r\n " +
" </div>\r\n");
#line 84 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 85 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.Has(Claims.Config.Enrolment.Show))
{
#line default
#line hidden
WriteLiteral(" <i");
WriteLiteral(" class=\"fa fa-cog\"");
WriteLiteral("></i>");
#line 87 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 87 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("Enrolment", MVC.Config.Enrolment.Index(), "config"));
#line default
#line hidden
#line 87 "..\..\Areas\Config\Views\Config\Index.cshtml"
@@ -562,7 +612,7 @@ WriteLiteral(">\r\n Configure Enrolment settings incl
"entials.\r\n </div>\r\n");
#line 84 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 91 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -571,7 +621,7 @@ WriteLiteral(">\r\n Configure Enrolment settings incl
WriteLiteral(" </div>\r\n </td>\r\n");
#line 87 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 94 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -580,7 +630,7 @@ WriteLiteral(" </div>\r\n </td>\r\n");
WriteLiteral(" ");
#line 88 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 95 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.HasAny(Claims.Config.JobPreferences.Show, Claims.Config.JobQueue.Show, Claims.Config.UserFlag.Show, Claims.Config.DocumentTemplate.Show))
{
@@ -590,13 +640,13 @@ WriteLiteral(" ");
WriteLiteral(" <td>\r\n");
#line 91 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 98 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 91 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 98 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.HasAny(Claims.Config.JobPreferences.Show, Claims.Config.JobQueue.Show))
{
@@ -610,13 +660,13 @@ WriteLiteral(" class=\"pageMenuArea noSeperator\"");
WriteLiteral(">\r\n <h2>Jobs</h2>\r\n");
#line 95 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 102 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 95 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 102 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.Has(Claims.Config.JobPreferences.Show))
{
@@ -630,20 +680,20 @@ WriteLiteral(" class=\"fa fa-cog\"");
WriteLiteral("></i>");
#line 97 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 104 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 97 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 104 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("General Preferences", MVC.Config.JobPreferences.Index(), "config"));
#line default
#line hidden
#line 97 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 104 "..\..\Areas\Config\Views\Config\Index.cshtml"
@@ -657,7 +707,7 @@ WriteLiteral(">\r\n Configure general preferences
"\r\n </div>\r\n");
#line 101 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 108 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -666,7 +716,7 @@ WriteLiteral(">\r\n Configure general preferences
WriteLiteral(" ");
#line 102 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 109 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.Has(Claims.Config.JobQueue.Show))
{
@@ -680,20 +730,20 @@ WriteLiteral(" class=\"fa fa-cog\"");
WriteLiteral("></i>");
#line 104 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 111 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 104 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 111 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("Job Queues", MVC.Config.JobQueue.Index(), "config"));
#line default
#line hidden
#line 104 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 111 "..\..\Areas\Config\Views\Config\Index.cshtml"
@@ -707,7 +757,7 @@ WriteLiteral(">\r\n Create and manage job queues
"ies and queue members.\r\n </div>\r\n");
#line 108 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 115 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -716,7 +766,7 @@ WriteLiteral(">\r\n Create and manage job queues
WriteLiteral(" </div>\r\n");
#line 110 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 117 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -725,7 +775,7 @@ WriteLiteral(" </div>\r\n");
WriteLiteral(" ");
#line 111 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 118 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.HasAny(Claims.Config.UserFlag.Show))
{
@@ -739,13 +789,13 @@ WriteLiteral(" class=\"pageMenuArea noSeperator\"");
WriteLiteral(">\r\n <h2>Users</h2>\r\n");
#line 115 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 122 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 115 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 122 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.Has(Claims.Config.UserFlag.Show))
{
@@ -759,21 +809,21 @@ WriteLiteral(" class=\"fa fa-cog\"");
WriteLiteral("></i>");
#line 117 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 124 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 117 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("User Flags", MVC.Config.UserFlag.Index(), "config"));
#line 124 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("Flags", MVC.Config.UserFlag.Index(), "config"));
#line default
#line hidden
#line 117 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 124 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
@@ -786,7 +836,7 @@ WriteLiteral(">\r\n Create and manage user flags.
" </div>\r\n");
#line 121 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 128 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -795,7 +845,7 @@ WriteLiteral(">\r\n Create and manage user flags.
WriteLiteral(" </div>\r\n");
#line 123 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 130 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -804,7 +854,7 @@ WriteLiteral(" </div>\r\n");
WriteLiteral(" ");
#line 124 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 131 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.HasAny(Claims.Config.DocumentTemplate.Show))
{
@@ -818,13 +868,13 @@ WriteLiteral(" class=\"pageMenuArea noSeperator\"");
WriteLiteral(">\r\n <h2>Features</h2>\r\n");
#line 128 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 135 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 128 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 135 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Authorization.Has(Claims.Config.DocumentTemplate.Show))
{
@@ -838,20 +888,20 @@ WriteLiteral(" class=\"fa fa-cog\"");
WriteLiteral("></i>");
#line 130 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 137 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 130 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 137 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Html.ActionLinkClass("Document Templates", MVC.Config.DocumentTemplate.Index(), "config"));
#line default
#line hidden
#line 130 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 137 "..\..\Areas\Config\Views\Config\Index.cshtml"
@@ -866,7 +916,7 @@ WriteLiteral(">\r\n Create, Update and Bulk Gener
" </div>\r\n");
#line 135 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 142 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -875,7 +925,7 @@ WriteLiteral(">\r\n Create, Update and Bulk Gener
WriteLiteral(" </div>\r\n");
#line 137 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 144 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -884,7 +934,7 @@ WriteLiteral(" </div>\r\n");
WriteLiteral(" </td>\r\n");
#line 139 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 146 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -893,7 +943,7 @@ WriteLiteral(" </td>\r\n");
WriteLiteral(" </tr>\r\n</table>\r\n");
#line 142 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 149 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Model.UpdateAvailable)
{
@@ -911,14 +961,14 @@ WriteLiteral(" class=\"fa fa-cloud-download info\"");
WriteLiteral("></i>\r\n <div>An updated version of Disco is available</div>\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 7818), Tuple.Create("\"", 7854)
WriteAttribute("href", Tuple.Create(" href=\"", 8211), Tuple.Create("\"", 8247)
#line 148 "..\..\Areas\Config\Views\Config\Index.cshtml"
, Tuple.Create(Tuple.Create("", 7825), Tuple.Create<System.Object, System.Int32>(Model.UpdateResponse.UrlLink
#line 155 "..\..\Areas\Config\Views\Config\Index.cshtml"
, Tuple.Create(Tuple.Create("", 8218), Tuple.Create<System.Object, System.Int32>(Model.UpdateResponse.UrlLink
#line default
#line hidden
, 7825), false)
, 8218), false)
);
WriteLiteral(" class=\"button small alert\"");
@@ -928,7 +978,7 @@ WriteLiteral(" target=\"_blank\"");
WriteLiteral(">Download v");
#line 148 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 155 "..\..\Areas\Config\Views\Config\Index.cshtml"
Write(Model.UpdateResponse.LatestVersion);
@@ -945,13 +995,13 @@ WriteLiteral(@" <script>
");
#line 156 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 163 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line default
#line hidden
#line 156 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 163 "..\..\Areas\Config\Views\Config\Index.cshtml"
if (Model.UpdateResponse.ReleasedDate < DateTime.Now.AddDays(-14))
{
@@ -967,7 +1017,7 @@ WriteLiteral("\r\n updateAvailableContainer.effect(\"shake\", { t
WriteLiteral("\r\n");
#line 162 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 169 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -976,7 +1026,7 @@ WriteLiteral("\r\n");
WriteLiteral("\r\n });\r\n })();\r\n </script>\r\n");
#line 167 "..\..\Areas\Config\Views\Config\Index.cshtml"
#line 174 "..\..\Areas\Config\Views\Config\Index.cshtml"
}
@@ -0,0 +1,36 @@
@model Disco.Web.Areas.Config.Models.DeviceFlag.CreateModel
@{
Authorization.RequireAll(Claims.Config.JobQueue.Create, Claims.Config.JobQueue.Configure);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Flags", MVC.Config.DeviceFlag.Index(null), "Create");
}
@using (Html.BeginForm())
{
@Html.HiddenFor(m => m.DeviceFlag.Icon)
@Html.HiddenFor(m => m.DeviceFlag.IconColour)
<div class="form" style="width: 450px">
<table>
<tr>
<th>Name:
</th>
<td>
@Html.EditorFor(model => model.DeviceFlag.Name)<br />@Html.ValidationMessageFor(model => model.DeviceFlag.Name)
</td>
</tr>
<tr>
<th>Description:
</th>
<td>
@Html.EditorFor(model => model.DeviceFlag.Description)<br />@Html.ValidationMessageFor(model => model.DeviceFlag.Description)
</td>
</tr>
</table>
<p class="actions">
<input type="submit" class="button" value="Create" />
</p>
</div>
<script type="text/javascript">
$(function () {
$('#DeviceFlag_Name').focus().select();
});
</script>
}
@@ -0,0 +1,172 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.DeviceFlag
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceFlag/Create.cshtml")]
public partial class Create : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DeviceFlag.CreateModel>
{
public Create()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
Authorization.RequireAll(Claims.Config.JobQueue.Create, Claims.Config.JobQueue.Configure);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Flags", MVC.Config.DeviceFlag.Index(null), "Create");
#line default
#line hidden
WriteLiteral("\r\n");
#line 6 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
using (Html.BeginForm())
{
#line default
#line hidden
#line 8 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
Write(Html.HiddenFor(m => m.DeviceFlag.Icon));
#line default
#line hidden
#line 8 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
#line default
#line hidden
#line 9 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
Write(Html.HiddenFor(m => m.DeviceFlag.IconColour));
#line default
#line hidden
#line 9 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 450px\"");
WriteLiteral(">\r\n <table>\r\n <tr>\r\n <th>Name:\r\n " +
"</th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 16 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
Write(Html.EditorFor(model => model.DeviceFlag.Name));
#line default
#line hidden
WriteLiteral("<br />");
#line 16 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
Write(Html.ValidationMessageFor(model => model.DeviceFlag.Name));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th" +
">Description:\r\n </th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 23 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
Write(Html.EditorFor(model => model.DeviceFlag.Description));
#line default
#line hidden
WriteLiteral("<br />");
#line 23 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
Write(Html.ValidationMessageFor(model => model.DeviceFlag.Description));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n </tr>\r\n </table>\r\n <p");
WriteLiteral(" class=\"actions\"");
WriteLiteral(">\r\n <input");
WriteLiteral(" type=\"submit\"");
WriteLiteral(" class=\"button\"");
WriteLiteral(" value=\"Create\"");
WriteLiteral(" />\r\n </p>\r\n </div>\r\n");
WriteLiteral(" <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n $(\'#DeviceFlag_Name\').focus().select();\r\n" +
" });\r\n </script>\r\n");
#line 36 "..\..\Areas\Config\Views\DeviceFlag\Create.cshtml"
}
#line default
#line hidden
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,185 @@
@using Disco.Web.Areas.Config.Models.DeviceFlag;
@model ExportModel
@{
Authorization.RequireAny(Claims.Config.DeviceFlag.Export);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Flags", MVC.Config.DeviceFlag.Index(null), "Export");
var optionsMetadata = ModelMetadata.FromLambdaExpression(m => m.Options, ViewData);
var optionGroups = optionsMetadata.Properties.Where(p => p.ShortDisplayName != null && p.ModelType == typeof(bool) && p.PropertyName != "CurrentOnly")
.GroupBy(m => m.ShortDisplayName);
}
<div id="DeviceFlag_Export">
@using (Html.BeginForm(MVC.API.DeviceFlag.Export()))
{
<div id="DeviceFlag_Export_Scope" class="form" style="width: 570px">
<h2>Export Scope</h2>
<table>
<tr>
<th style="width: 150px">
Device Flags:
</th>
<td>
@foreach (var flag in Model.DeviceFlags)
{
<div>
<label>
<input type="checkbox" id="Options_DeviceFlagIds" name="Options.DeviceFlagIds" value="@flag.Id" @(((bool)Model.Options.DeviceFlagIds.Contains(flag.Id)) ? "checked " : null) />
<i class="fa fa-@(flag.Icon) fa-lg d-@(flag.IconColour)"></i>
<span>@flag.Name</span>
</label>
</div>
}
</td>
</tr>
<tr>
<th>@Html.LabelFor(m => m.Options.CurrentOnly)</th>
<td>
@Html.CheckBoxFor(m => m.Options.CurrentOnly)
<p>Uncheck to include all historical device flag assignments.</p>
</td>
</tr>
<tr>
<th>@Html.LabelFor(m => m.Options.Format)</th>
<td>
@Html.DropDownListFor(m => m.Options.Format, Enum.GetNames(typeof(Disco.Models.Exporting.ExportFormat)).Select(v => new SelectListItem() { Value = v, Text = v }))
</td>
</tr>
</table>
</div>
<div id="DeviceFlag_Export_Fields" class="form" style="width: 570px; margin-top: 15px;">
<h2>Export Fields <a id="DeviceFlag_Export_Fields_Defaults" href="#">(Defaults)</a></h2>
<table>
@foreach (var optionGroup in optionGroups)
{
var optionFields = optionGroup.ToList();
var itemsPerColumn = (int)Math.Ceiling((double)optionFields.Count / 2);
<tr>
<th style="width: 120px;">
@optionGroup.Key
@if (optionFields.Count > 2)
{
<span style="display: block;" class="select"><a class="selectAll" href="#">ALL</a> | <a class="selectNone" href="#">NONE</a></span>
}
</th>
<td>
<div class="DeviceFlag_Export_Fields_Group">
<table class="none">
<tr>
<td style="width: 50%">
<ul class="none">
@foreach (var optionItem in optionFields.Take(itemsPerColumn))
{
<li title="@optionItem.Description">
<input type="checkbox" id="Options_@optionItem.PropertyName" name="Options.@optionItem.PropertyName" value="true" @(((bool)optionItem.Model) ? "checked " : null)/><label for="Options_@optionItem.PropertyName">@optionItem.DisplayName</label></li>
}
</ul>
</td>
<td style="width: 50%">
<ul class="none">
@foreach (var optionItem in optionFields.Skip(itemsPerColumn))
{
<li title="@optionItem.Description">
<input type="checkbox" id="Options_@optionItem.PropertyName" name="Options.@optionItem.PropertyName" value="true" @(((bool)optionItem.Model) ? "checked " : null)/><label for="Options_@optionItem.PropertyName">@optionItem.DisplayName</label></li>
}
</ul>
</td>
</tr>
</table>
</div>
</td>
</tr>
}
</table>
</div>
<script>
$(function () {
var exportDefaultFields = ['Name', 'AddedDate', 'UserId', 'UserDisplayName', 'Comments'];
var $exportFields = $('#DeviceFlag_Export_Fields');
var $exportScope = $('#DeviceFlag_Export_Scope');
var $form = $exportScope.closest('form');
var $exportingDialog = null;
$exportFields.on('click', 'a.selectAll,a.selectNone', function () {
var $this = $(this);
$this.closest('tr').find('input').prop('checked', $this.is('.selectAll'));
return false;
});
$('#DeviceFlag_Export_Fields_Defaults').click(function () {
$exportFields.find('input').prop('checked', false);
$.each(exportDefaultFields, function (index, value) {
$('#Options_' + value).prop('checked', true);
});
return false;
});
// Submit Validation
function submitHandler() {
var exportFieldCount = $exportFields.find('input:checked').length;
if (exportFieldCount > 0) {
if ($exportingDialog == null) {
$exportingDialog = $('#DeviceFlag_Export_Exporting').dialog({
width: 400,
height: 164,
resizable: false,
modal: true,
autoOpen: false
});
}
$exportingDialog.dialog('open');
$form[0].submit();
}
else
alert('Select at least one field to export.');
}
$.validator.unobtrusive.parse($form);
$form.data("validator").settings.submitHandler = submitHandler;
$('#DeviceFlag_Export_Download_Dialog').dialog({
width: 400,
height: 164,
resizable: false,
modal: true,
autoOpen: true
});
$('#DeviceFlag_Export_Button').click(function () {
$form.submit();
});
});
</script>
}
</div>
@if (Model.ExportSessionId != null)
{
<div id="DeviceFlag_Export_Download_Dialog" class="dialog" title="Export Device Flags">
<h4>@Model.ExportSessionResult.RecordCount record@(Model.ExportSessionResult.RecordCount != 1 ? "s" : null) were successfully exported.</h4>
<a href="@Url.Action(MVC.API.DeviceFlag.ExportRetrieve(Model.ExportSessionId))" class="button"><i class="fa fa-download fa-lg"></i>Download Device Flag Export</a>
</div>
<script>
$(function () {
$('#DeviceFlag_Export_Download_Dialog')
.dialog({
width: 400,
height: 164,
resizable: false,
modal: true,
autoOpen: true
});
});
</script>
}
<div id="DeviceFlag_Export_Exporting" class="dialog" title="Exporting Device Flags...">
<h4><i class="fa fa-lg fa-cog fa-spin" title="Please Wait"></i>Exporting device flags...</h4>
</div>
<div class="actionBar">
<a id="DeviceFlag_Export_Button" href="#" class="button">Export Device Flags</a>
</div>
@@ -0,0 +1,707 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.DeviceFlag
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
#line 1 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
using Disco.Web.Areas.Config.Models.DeviceFlag;
#line default
#line hidden
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceFlag/Export.cshtml")]
public partial class Export : Disco.Services.Web.WebViewPage<ExportModel>
{
public Export()
{
}
public override void Execute()
{
#line 3 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Authorization.RequireAny(Claims.Config.DeviceFlag.Export);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Flags", MVC.Config.DeviceFlag.Index(null), "Export");
var optionsMetadata = ModelMetadata.FromLambdaExpression(m => m.Options, ViewData);
var optionGroups = optionsMetadata.Properties.Where(p => p.ShortDisplayName != null && p.ModelType == typeof(bool) && p.PropertyName != "CurrentOnly")
.GroupBy(m => m.ShortDisplayName);
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"DeviceFlag_Export\"");
WriteLiteral(">\r\n");
#line 13 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
#line default
#line hidden
#line 13 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
using (Html.BeginForm(MVC.API.DeviceFlag.Export()))
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"DeviceFlag_Export_Scope\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 570px\"");
WriteLiteral(">\r\n <h2>Export Scope</h2>\r\n <table>\r\n <tr>\r\n" +
" <th");
WriteLiteral(" style=\"width: 150px\"");
WriteLiteral(">\r\n Device Flags:\r\n </th>\r\n " +
" <td>\r\n");
#line 23 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
#line default
#line hidden
#line 23 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
foreach (var flag in Model.DeviceFlags)
{
#line default
#line hidden
WriteLiteral(" <div>\r\n <label>\r\n " +
" <input");
WriteLiteral(" type=\"checkbox\"");
WriteLiteral(" id=\"Options_DeviceFlagIds\"");
WriteLiteral(" name=\"Options.DeviceFlagIds\"");
WriteAttribute("value", Tuple.Create(" value=\"", 1252), Tuple.Create("\"", 1268)
#line 27 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 1260), Tuple.Create<System.Object, System.Int32>(flag.Id
#line default
#line hidden
, 1260), false)
);
WriteLiteral(" ");
#line 27 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(((bool)Model.Options.DeviceFlagIds.Contains(flag.Id)) ? "checked " : null);
#line default
#line hidden
WriteLiteral(" />\r\n <i");
WriteAttribute("class", Tuple.Create(" class=\"", 1389), Tuple.Create("\"", 1442)
, Tuple.Create(Tuple.Create("", 1397), Tuple.Create("fa", 1397), true)
, Tuple.Create(Tuple.Create(" ", 1399), Tuple.Create("fa-", 1400), true)
#line 28 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 1403), Tuple.Create<System.Object, System.Int32>(flag.Icon
#line default
#line hidden
, 1403), false)
, Tuple.Create(Tuple.Create(" ", 1415), Tuple.Create("fa-lg", 1416), true)
, Tuple.Create(Tuple.Create(" ", 1421), Tuple.Create("d-", 1422), true)
#line 28 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 1424), Tuple.Create<System.Object, System.Int32>(flag.IconColour
#line default
#line hidden
, 1424), false)
);
WriteLiteral("></i>\r\n <span>");
#line 29 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(flag.Name);
#line default
#line hidden
WriteLiteral("</span>\r\n </label>\r\n </" +
"div>\r\n");
#line 32 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n </tr>\r\n <tr>\r\n " +
" <th>");
#line 36 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(Html.LabelFor(m => m.Options.CurrentOnly));
#line default
#line hidden
WriteLiteral("</th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 38 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(Html.CheckBoxFor(m => m.Options.CurrentOnly));
#line default
#line hidden
WriteLiteral("\r\n <p>Uncheck to include all historical device flag assign" +
"ments.</p>\r\n </td>\r\n </tr>\r\n <t" +
"r>\r\n <th>");
#line 43 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(Html.LabelFor(m => m.Options.Format));
#line default
#line hidden
WriteLiteral("</th>\r\n <td>\r\n");
WriteLiteral(" ");
#line 45 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(Html.DropDownListFor(m => m.Options.Format, Enum.GetNames(typeof(Disco.Models.Exporting.ExportFormat)).Select(v => new SelectListItem() { Value = v, Text = v })));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n </tr>\r\n </table>\r\n " +
" </div>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"DeviceFlag_Export_Fields\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 570px; margin-top: 15px;\"");
WriteLiteral(">\r\n <h2>Export Fields <a");
WriteLiteral(" id=\"DeviceFlag_Export_Fields_Defaults\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(">(Defaults)</a></h2>\r\n <table>\r\n");
#line 53 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
#line default
#line hidden
#line 53 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
foreach (var optionGroup in optionGroups)
{
var optionFields = optionGroup.ToList();
var itemsPerColumn = (int)Math.Ceiling((double)optionFields.Count / 2);
#line default
#line hidden
WriteLiteral(" <tr>\r\n <th");
WriteLiteral(" style=\"width: 120px;\"");
WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 59 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(optionGroup.Key);
#line default
#line hidden
WriteLiteral("\r\n");
#line 60 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
#line default
#line hidden
#line 60 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
if (optionFields.Count > 2)
{
#line default
#line hidden
WriteLiteral(" <span");
WriteLiteral(" style=\"display: block;\"");
WriteLiteral(" class=\"select\"");
WriteLiteral("><a");
WriteLiteral(" class=\"selectAll\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(">ALL</a> | <a");
WriteLiteral(" class=\"selectNone\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(">NONE</a></span>\r\n");
#line 63 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" </th>\r\n <td>\r\n " +
" <div");
WriteLiteral(" class=\"DeviceFlag_Export_Fields_Group\"");
WriteLiteral(">\r\n <table");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n <tr>\r\n " +
" <td");
WriteLiteral(" style=\"width: 50%\"");
WriteLiteral(">\r\n <ul");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n");
#line 71 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
foreach (var optionItem in optionFields.Take(itemsPerColumn))
{
#line default
#line hidden
WriteLiteral(" <li");
WriteAttribute("title", Tuple.Create(" title=\"", 3832), Tuple.Create("\"", 3863)
#line 73 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 3840), Tuple.Create<System.Object, System.Int32>(optionItem.Description
#line default
#line hidden
, 3840), false)
);
WriteLiteral(">\r\n <input");
WriteLiteral(" type=\"checkbox\"");
WriteAttribute("id", Tuple.Create(" id=\"", 3945), Tuple.Create("\"", 3982)
, Tuple.Create(Tuple.Create("", 3950), Tuple.Create("Options_", 3950), true)
#line 74 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 3958), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 3958), false)
);
WriteAttribute("name", Tuple.Create(" name=\"", 3983), Tuple.Create("\"", 4022)
, Tuple.Create(Tuple.Create("", 3990), Tuple.Create("Options.", 3990), true)
#line 74 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 3998), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 3998), false)
);
WriteLiteral(" value=\"true\"");
WriteLiteral(" ");
#line 74 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(((bool)optionItem.Model) ? "checked " : null);
#line default
#line hidden
WriteLiteral("/><label");
WriteAttribute("for", Tuple.Create(" for=\"", 4092), Tuple.Create("\"", 4130)
, Tuple.Create(Tuple.Create("", 4098), Tuple.Create("Options_", 4098), true)
#line 74 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4106), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 4106), false)
);
WriteLiteral(">");
#line 74 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(optionItem.DisplayName);
#line default
#line hidden
WriteLiteral("</label></li>\r\n");
#line 75 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" </ul>\r\n " +
" </td>\r\n <td");
WriteLiteral(" style=\"width: 50%\"");
WriteLiteral(">\r\n <ul");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n");
#line 80 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
#line default
#line hidden
#line 80 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
foreach (var optionItem in optionFields.Skip(itemsPerColumn))
{
#line default
#line hidden
WriteLiteral(" <li");
WriteAttribute("title", Tuple.Create(" title=\"", 4665), Tuple.Create("\"", 4696)
#line 82 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4673), Tuple.Create<System.Object, System.Int32>(optionItem.Description
#line default
#line hidden
, 4673), false)
);
WriteLiteral(">\r\n <input");
WriteLiteral(" type=\"checkbox\"");
WriteAttribute("id", Tuple.Create(" id=\"", 4778), Tuple.Create("\"", 4815)
, Tuple.Create(Tuple.Create("", 4783), Tuple.Create("Options_", 4783), true)
#line 83 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4791), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 4791), false)
);
WriteAttribute("name", Tuple.Create(" name=\"", 4816), Tuple.Create("\"", 4855)
, Tuple.Create(Tuple.Create("", 4823), Tuple.Create("Options.", 4823), true)
#line 83 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4831), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 4831), false)
);
WriteLiteral(" value=\"true\"");
WriteLiteral(" ");
#line 83 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(((bool)optionItem.Model) ? "checked " : null);
#line default
#line hidden
WriteLiteral("/><label");
WriteAttribute("for", Tuple.Create(" for=\"", 4925), Tuple.Create("\"", 4963)
, Tuple.Create(Tuple.Create("", 4931), Tuple.Create("Options_", 4931), true)
#line 83 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 4939), Tuple.Create<System.Object, System.Int32>(optionItem.PropertyName
#line default
#line hidden
, 4939), false)
);
WriteLiteral(">");
#line 83 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(optionItem.DisplayName);
#line default
#line hidden
WriteLiteral("</label></li>\r\n");
#line 84 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(@" </ul>
</td>
</tr>
</table>
</div>
</td>
</tr>
");
#line 92 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
}
#line default
#line hidden
WriteLiteral(" </table>\r\n </div>\r\n");
WriteLiteral(" <script>\r\n $(function () {\r\n var exportDefaultF" +
"ields = [\'Name\', \'AddedDate\', \'UserId\', \'UserDisplayName\', \'Comments\'];\r\n " +
" var $exportFields = $(\'#DeviceFlag_Export_Fields\');\r\n va" +
"r $exportScope = $(\'#DeviceFlag_Export_Scope\');\r\n var $form = $ex" +
"portScope.closest(\'form\');\r\n var $exportingDialog = null;\r\n\r\n " +
" $exportFields.on(\'click\', \'a.selectAll,a.selectNone\', function () {\r" +
"\n var $this = $(this);\r\n\r\n $this.closest(\'" +
"tr\').find(\'input\').prop(\'checked\', $this.is(\'.selectAll\'));\r\n\r\n " +
" return false;\r\n });\r\n\r\n $(\'#DeviceFlag_Export_F" +
"ields_Defaults\').click(function () {\r\n\r\n $exportFields.find(\'" +
"input\').prop(\'checked\', false);\r\n\r\n $.each(exportDefaultField" +
"s, function (index, value) {\r\n $(\'#Options_\' + value).pro" +
"p(\'checked\', true);\r\n });\r\n\r\n return false" +
";\r\n });\r\n\r\n // Submit Validation\r\n " +
"function submitHandler() {\r\n var exportFieldCount = $exportFi" +
"elds.find(\'input:checked\').length;\r\n\r\n if (exportFieldCount >" +
" 0) {\r\n\r\n if ($exportingDialog == null) {\r\n " +
" $exportingDialog = $(\'#DeviceFlag_Export_Exporting\').dialog({\r\n " +
" width: 400,\r\n height" +
": 164,\r\n resizable: false,\r\n " +
" modal: true,\r\n autoOpen: false\r\n " +
" });\r\n }\r\n $e" +
"xportingDialog.dialog(\'open\');\r\n\r\n $form[0].submit();\r\n " +
" }\r\n else\r\n alert(\'Se" +
"lect at least one field to export.\');\r\n }\r\n $.vali" +
"dator.unobtrusive.parse($form);\r\n $form.data(\"validator\").setting" +
"s.submitHandler = submitHandler;\r\n\r\n $(\'#DeviceFlag_Export_Downlo" +
"ad_Dialog\').dialog({\r\n width: 400,\r\n heigh" +
"t: 164,\r\n resizable: false,\r\n modal: true," +
"\r\n autoOpen: true\r\n });\r\n $(\'#D" +
"eviceFlag_Export_Button\').click(function () {\r\n $form.submit(" +
");\r\n });\r\n });\r\n </script>\r\n");
#line 159 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
}
#line default
#line hidden
WriteLiteral("</div>\r\n");
#line 161 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
if (Model.ExportSessionId != null)
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"DeviceFlag_Export_Download_Dialog\"");
WriteLiteral(" class=\"dialog\"");
WriteLiteral(" title=\"Export Device Flags\"");
WriteLiteral(">\r\n <h4>");
#line 164 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(Model.ExportSessionResult.RecordCount);
#line default
#line hidden
WriteLiteral(" record");
#line 164 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
Write(Model.ExportSessionResult.RecordCount != 1 ? "s" : null);
#line default
#line hidden
WriteLiteral(" were successfully exported.</h4>\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 8250), Tuple.Create("\"", 8326)
#line 165 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
, Tuple.Create(Tuple.Create("", 8257), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.DeviceFlag.ExportRetrieve(Model.ExportSessionId))
#line default
#line hidden
, 8257), false)
);
WriteLiteral(" class=\"button\"");
WriteLiteral("><i");
WriteLiteral(" class=\"fa fa-download fa-lg\"");
WriteLiteral("></i>Download Device Flag Export</a>\r\n </div>\r\n");
WriteLiteral(@" <script>
$(function () {
$('#DeviceFlag_Export_Download_Dialog')
.dialog({
width: 400,
height: 164,
resizable: false,
modal: true,
autoOpen: true
});
});
</script>
");
#line 179 "..\..\Areas\Config\Views\DeviceFlag\Export.cshtml"
}
#line default
#line hidden
WriteLiteral("<div");
WriteLiteral(" id=\"DeviceFlag_Export_Exporting\"");
WriteLiteral(" class=\"dialog\"");
WriteLiteral(" title=\"Exporting Device Flags...\"");
WriteLiteral(">\r\n <h4><i");
WriteLiteral(" class=\"fa fa-lg fa-cog fa-spin\"");
WriteLiteral(" title=\"Please Wait\"");
WriteLiteral("></i>Exporting device flags...</h4>\r\n</div>\r\n<div");
WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n <a");
WriteLiteral(" id=\"DeviceFlag_Export_Button\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" class=\"button\"");
WriteLiteral(">Export Device Flags</a>\r\n</div>\r\n");
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,78 @@
@model Disco.Web.Areas.Config.Models.DeviceFlag.IndexModel
@{
Authorization.Require(Claims.Config.DeviceFlag.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Flags");
var showTags = Model.DeviceFlags.Keys.Any(i => i.DevicesLinkedGroup != null || i.DeviceUsersLinkedGroup != null ||
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null);
}
<div id="Config_DeviceFlags_Index">
@if (Model.DeviceFlags.Count == 0)
{
<div class="form" style="width: 450px; padding: 100px 0;">
<h2>No device flags are configured</h2>
</div>
}
else
{
<table class="tableData">
<tr>
<th>Name</th>
<th>Description</th>
<th>Current&nbsp;Assignments</th>
@if (showTags)
{
<th>&nbsp;</th>
}
</tr>
@foreach (var pair in Model.DeviceFlags.OrderBy(i => i.Key.Name))
{
var item = pair.Key;
var assignmentCount = pair.Value;
<tr>
<td>
<a href="@Url.Action(MVC.Config.DeviceFlag.Index(item.Id))">
<i class="fa fa-@(item.Icon) fa-lg d-@(item.IconColour)"></i>
@item.Name
</a>
</td>
<td>
@if (string.IsNullOrWhiteSpace(item.Description))
{
<span class="smallMessage">&lt;none&gt;</span>
}
else
{
@item.Description.ToHtmlComment()
}
</td>
<td>
@assignmentCount.ToString("N0")
</td>
@if (showTags)
{
<td>
@if (item.DevicesLinkedGroup != null || item.DeviceUsersLinkedGroup != null)
{
<i class="fa fa-link fa-lg success" title="Is Linked"></i>
}
@if (item.OnAssignmentExpression != null || item.OnUnassignmentExpression != null)
{
<i class="fa fa-bolt fa-lg alert" title="Has Expressions"></i>
}
</td>
}
</tr>
}
</table>
}
<div class="actionBar">
@if (Authorization.Has(Claims.Config.DeviceFlag.Export) && Model.DeviceFlags.Count > 0)
{
@Html.ActionLinkButton("Export", MVC.Config.DeviceFlag.Export())
}
@if (Authorization.Has(Claims.Config.DeviceFlag.Create))
{
@Html.ActionLinkButton("Create Device Flag", MVC.Config.DeviceFlag.Create())
}
</div>
</div>
@@ -0,0 +1,410 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.DeviceFlag
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceFlag/Index.cshtml")]
public partial class Index : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.DeviceFlag.IndexModel>
{
public Index()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
Authorization.Require(Claims.Config.DeviceFlag.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Flags");
var showTags = Model.DeviceFlags.Keys.Any(i => i.DevicesLinkedGroup != null || i.DeviceUsersLinkedGroup != null ||
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null);
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"Config_DeviceFlags_Index\"");
WriteLiteral(">\r\n");
#line 9 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 9 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (Model.DeviceFlags.Count == 0)
{
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 450px; padding: 100px 0;\"");
WriteLiteral(">\r\n <h2>No device flags are configured</h2>\r\n </div>\r\n");
#line 14 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
else
{
#line default
#line hidden
WriteLiteral(" <table");
WriteLiteral(" class=\"tableData\"");
WriteLiteral(">\r\n <tr>\r\n <th>Name</th>\r\n <th>Descripti" +
"on</th>\r\n <th>Current&nbsp;Assignments</th>\r\n");
#line 22 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 22 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (showTags)
{
#line default
#line hidden
WriteLiteral(" <th>&nbsp;</th>\r\n");
#line 25 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </tr>\r\n");
#line 27 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 27 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
foreach (var pair in Model.DeviceFlags.OrderBy(i => i.Key.Name))
{
var item = pair.Key;
var assignmentCount = pair.Value;
#line default
#line hidden
WriteLiteral(" <tr>\r\n <td>\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 1229), Tuple.Create("\"", 1285)
#line 33 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1236), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.DeviceFlag.Index(item.Id))
#line default
#line hidden
, 1236), false)
);
WriteLiteral(">\r\n <i");
WriteAttribute("class", Tuple.Create(" class=\"", 1319), Tuple.Create("\"", 1372)
, Tuple.Create(Tuple.Create("", 1327), Tuple.Create("fa", 1327), true)
, Tuple.Create(Tuple.Create(" ", 1329), Tuple.Create("fa-", 1330), true)
#line 34 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1333), Tuple.Create<System.Object, System.Int32>(item.Icon
#line default
#line hidden
, 1333), false)
, Tuple.Create(Tuple.Create(" ", 1345), Tuple.Create("fa-lg", 1346), true)
, Tuple.Create(Tuple.Create(" ", 1351), Tuple.Create("d-", 1352), true)
#line 34 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1354), Tuple.Create<System.Object, System.Int32>(item.IconColour
#line default
#line hidden
, 1354), false)
);
WriteLiteral("></i>\r\n");
WriteLiteral(" ");
#line 35 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
Write(item.Name);
#line default
#line hidden
WriteLiteral("\r\n </a>\r\n </td>\r\n <t" +
"d>\r\n");
#line 39 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 39 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (string.IsNullOrWhiteSpace(item.Description))
{
#line default
#line hidden
WriteLiteral(" <span");
WriteLiteral(" class=\"smallMessage\"");
WriteLiteral(">&lt;none&gt;</span>\r\n");
#line 42 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
else
{
#line default
#line hidden
#line 45 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
Write(item.Description.ToHtmlComment());
#line default
#line hidden
#line 45 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n <td>\r\n");
WriteLiteral(" ");
#line 49 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
Write(assignmentCount.ToString("N0"));
#line default
#line hidden
WriteLiteral("\r\n </td>\r\n");
#line 51 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 51 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (showTags)
{
#line default
#line hidden
WriteLiteral(" <td>\r\n");
#line 54 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 54 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (item.DevicesLinkedGroup != null || item.DeviceUsersLinkedGroup != null)
{
#line default
#line hidden
WriteLiteral(" <i");
WriteLiteral(" class=\"fa fa-link fa-lg success\"");
WriteLiteral(" title=\"Is Linked\"");
WriteLiteral("></i>\r\n");
#line 57 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 58 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (item.OnAssignmentExpression != null || item.OnUnassignmentExpression != null)
{
#line default
#line hidden
WriteLiteral(" <i");
WriteLiteral(" class=\"fa fa-bolt fa-lg alert\"");
WriteLiteral(" title=\"Has Expressions\"");
WriteLiteral("></i>\r\n");
#line 61 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n");
#line 63 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </tr>\r\n");
#line 65 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </table>\r\n");
#line 67 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral("<div");
WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n");
#line 69 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 69 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (Authorization.Has(Claims.Config.DeviceFlag.Export) && Model.DeviceFlags.Count > 0)
{
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
Write(Html.ActionLinkButton("Export", MVC.Config.DeviceFlag.Export()));
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" ");
#line 73 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (Authorization.Has(Claims.Config.DeviceFlag.Create))
{
#line default
#line hidden
#line 75 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
Write(Html.ActionLinkButton("Create Device Flag", MVC.Config.DeviceFlag.Create()));
#line default
#line hidden
#line 75 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral("</div>\r\n</div>\r\n");
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,590 @@
@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.DeviceFlag.DevicesLinkedGroup == null &&
Model.DeviceFlag.DeviceUsersLinkedGroup == null &&
Model.DeviceFlag.OnAssignmentExpression == null &&
Model.DeviceFlag.OnUnassignmentExpression == null;
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
}
<div id="Config_DeviceFlags_Show" class="form@(hideAdvanced ? " Config_HideAdvanced" : null)" style="width: 550px">
<table>
<tr>
<th style="width: 150px">
Id:
</th>
<td>
@Html.DisplayFor(model => model.DeviceFlag.Id)
</td>
</tr>
<tr>
<th>
Name:
</th>
<td>
@if (canConfig)
{@Html.EditorFor(model => model.DeviceFlag.Name)
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceFlag_Name'),
'Invalid Name',
'@(Url.Action(MVC.API.DeviceFlag.UpdateName(Model.DeviceFlag.Id)))',
'FlagName'
);
});
</script>
}
else
{
@Model.DeviceFlag.Name
}
</td>
</tr>
<tr>
<th>
Description:
</th>
<td>
@if (canConfig)
{@Html.EditorFor(model => model.DeviceFlag.Description)
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceFlag_Description'),
'Invalid Description',
'@(Url.Action(MVC.API.DeviceFlag.UpdateDescription(Model.DeviceFlag.Id)))',
'Description'
);
});
</script>
}
else
{
<pre>
@if (string.IsNullOrEmpty(Model.DeviceFlag.Description))
{
<text>&lt;None&gt;</text>
}
else
{
@Model.DeviceFlag.Description.ToHtmlComment()
}
</pre>
}
</td>
</tr>
<tr>
<th>
Statistics:
</th>
<td>
<div><strong>@Model.CurrentAssignmentCount device@(Model.CurrentAssignmentCount != 1 ? "s" : null) currently assigned</strong></div>
<div>@Model.TotalAssignmentCount total device historical assignment@(Model.TotalAssignmentCount != 1 ? "s" : null)</div>
</td>
</tr>
<tr>
<th>
Icon:
</th>
<td>
<i id="Config_DeviceFlags_Icon" data-icon="@(Model.DeviceFlag.Icon)" data-colour="@(Model.DeviceFlag.IconColour)" class="fa fa-@(Model.DeviceFlag.Icon) fa-4x d-@(Model.DeviceFlag.IconColour)"></i>
@if (canConfig)
{
<div>
<a id="Config_DeviceFlags_Icon_Update" href="#" class="button small">Update</a>
<div id="Config_DeviceFlags_Icon_Update_Dialog" class="dialog" title="Device Flag Icon">
<div>
<div class="colours">
@foreach (var colour in Model.ThemeColours)
{
<i data-colour="@(colour.Key)" class="fa fa-square d-@(colour.Key)" title="@colour.Value"></i>
}
</div>
<div class="icons">
@foreach (var icon in Model.Icons)
{
<i data-icon="@(icon.Key)" class="fa fa-@(icon.Key)" title="@icon.Value"></i>
}
</div>
</div>
</div>
<script>
(function () {
var dialog, icon, colours, icons;
function showDialog() {
if (!dialog) {
dialog = $('#Config_DeviceFlags_Icon_Update_Dialog').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 1000,
buttons: {
"Save": save,
Cancel: cancel
}
});
colours = dialog.find('.colours');
icons = dialog.find('.icons');
colours.on('click', 'i', selectColour);
icons.on('click', 'i', selectIcon);
}
colours.find('i[data-colour="' + icon.attr('data-colour') + '"]').each(selectColour);
icons.find('i[data-icon="' + icon.attr('data-icon') + '"]').each(selectIcon);
dialog.dialog('open');
return false;
}
function selectColour() {
var $this = $(this),
colourCode = $this.attr('data-colour'),
previousColourCode = icons.attr('data-colour');
colours.find('i').removeClass('selected fa-check-square').addClass('fa-square');
$this.removeClass('fa-square').addClass('fa-check-square selected');
if (previousColourCode)
icons.removeClass('d-' + previousColourCode);
icons.attr('data-colour', colourCode)
icons.addClass('d-' + colourCode);
}
function selectIcon() {
var $this = $(this),
iconCode = $this.attr('data-icon');
icons.find('i').removeClass('selected');
$this.addClass('selected');
}
function save() {
var url = '@(Url.Action(MVC.API.DeviceFlag.UpdateIconAndColour(id: Model.DeviceFlag.Id, redirect: true)))',
data = {
Icon: icons.find('i.selected').attr('data-icon'),
IconColour: colours.find('i.selected').attr('data-colour')
};
window.location.href = url + '&' + $.param(data);
dialog.dialog("disable");
dialog.dialog("option", "buttons", null);
}
function cancel() {
$(this).dialog("close");
}
$(function () {
icon = $('#Config_DeviceFlags_Icon');
$('#Config_DeviceFlags_Icon_Update').click(showDialog);
});
}());
</script>
</div>
}
</td>
</tr>
@if (hideAdvanced)
{
<tr>
<td colspan="2" style="text-align: right;">
<button id="Config_HideAdvanced_Show" class="button small">Show Advanced Options</button>
<script>
$(function () {
$('#Config_HideAdvanced_Show').click(function () {
var $this = $(this);
$this.closest('.Config_HideAdvanced').removeClass('Config_HideAdvanced');
$this.closest('tr').remove();
});
});
</script>
</td>
</tr>
}
<tr class="Config_HideAdvanced_Item">
<th>
On Assignment<br />Expression:
</th>
<td>
@if (canConfig)
{
@Html.EditorFor(model => model.DeviceFlag.OnAssignmentExpression)
@AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var field = $('#DeviceFlag_OnAssignmentExpression');
var fieldRemove = field.next('.ajaxRemove');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DeviceFlag.UpdateOnAssignmentExpression(Model.DeviceFlag.Id))',
'OnAssignmentExpression'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
});
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
});
</script>
}
else
{
if (string.IsNullOrWhiteSpace(Model.DeviceFlag.OnAssignmentExpression))
{
<span class="smallMessage">&lt;None Specified&gt;</span>
}
else
{
<div class="code">
@Model.DeviceFlag.OnAssignmentExpression
</div>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>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.
</p>
</div>
</td>
</tr>
<tr class="Config_HideAdvanced_Item">
<th>
On Unassignment<br />Expression:
</th>
<td>
@if (canConfig)
{
@Html.EditorFor(model => model.DeviceFlag.OnUnassignmentExpression)
@AjaxHelpers.AjaxRemove()
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
var field = $('#DeviceFlag_OnUnassignmentExpression');
var fieldRemove = field.next('.ajaxRemove');
var fieldOriginalWidth, fieldOriginalHeight;
document.DiscoFunctions.PropertyChangeHelper(
field,
'None',
'@Url.Action(MVC.API.DeviceFlag.UpdateOnUnassignmentExpression(Model.DeviceFlag.Id))',
'OnUnassignmentExpression'
);
field.focus(function () {
fieldOriginalWidth = field.width();
fieldOriginalHeight = field.height();
field.css('overflow', 'visible').animate({ width: field.parent().width() - 42, height: 75 }, 200);
}).blur(function () {
field.css('overflow', 'hidden').animate({ width: fieldOriginalWidth, height: fieldOriginalHeight }, 200);
}).change(function () {
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
}).attr('placeholder', 'None').attr('spellcheck', 'false');
fieldRemove.click(function () {
field.val('').change();
});
if (!!field.val()) {
fieldRemove.show();
} else {
fieldRemove.hide();
}
});
</script>
}
else
{
if (string.IsNullOrWhiteSpace(Model.DeviceFlag.OnUnassignmentExpression))
{
<span class="smallMessage">&lt;None Specified&gt;</span>
}
else
{
<div class="code">
@Model.DeviceFlag.OnUnassignmentExpression
</div>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>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.
</p>
</div>
</td>
</tr>
<tr class="Config_HideAdvanced_Item">
<th>
Linked Groups:
</th>
<td>
<div>
@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)
}
</div>
</td>
</tr>
</table>
</div>
@if (canBulkAssignment || canDelete || canShowDevices || canExportCurrent || canExportAll)
{
<div class="actionBar">
@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)
{
<a href="#" id="Config_DeviceFlags_BulkAssign_Button" class="button">Bulk Assign Devices</a>
<div id="Config_DeviceFlags_BulkAssign_ModeDialog" class="dialog" title="Bulk Assign Device Mode">
<p>
Select the mode used to assign devices:
</p>
<div>
<div class="add">
<h5><i class="fa fa-plus fa-fw"></i>Add</h5>
<p>
Specified devices will have this flag <strong>added</strong>. Devices who already have this flag will be skipped.
</p>
</div>
<div class="override">
<h5><i class="fa fa-repeat fa-fw"></i>Override</h5>
<p>
Specified devices will have this flag <strong>added</strong>. Specified devices which already have this flag will be skipped.
Devices who already have this flag but are not specified will have the flag <strong>removed</strong>.
</p>
</div>
</div>
</div>
<div id="Config_DeviceFlags_BulkAssign_AssignDialog" class="dialog" title="Bulk Assign Devices">
<div class="brief">
<div>
Enter multiple <strong>Device Serial Numbers</strong> separated by <code>&lt;new line&gt;</code>, commas (<code>,</code>) or semicolons (<code>;</code>).
</div>
</div>
<div class="loading">
<h4><i class="fa fa-lg fa-cog fa-spin" title="Please Wait"></i>Loading current assignments...</h4>
</div>
<form action="#" method="post">
<textarea id="Config_DeviceFlags_BulkAssign_AssignDialog_DeviceSerialNumbers" name="DeviceSerialNumbers"></textarea>
<h4>Comments:</h4>
<textarea id="Config_DeviceFlags_BulkAssign_AssignDialog_Comments" name="Comments"></textarea>
</form>
</div>
<script>
$(function () {
var modeDialog, assignDialog, assignDeviceSerialNumbers;
function showModeDialog() {
if (!modeDialog) {
modeDialog = $('#Config_DeviceFlags_BulkAssign_ModeDialog').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 400,
buttons: {
Cancel: function () {
$(this).dialog('close');
}
}
});
modeDialog.find('.add').click(function () {
modeDialog.dialog('close');
showAssignDialog('Add');
});
modeDialog.find('.override').click(function () {
modeDialog.dialog('close');
showAssignDialog('Override');
});
}
modeDialog.dialog('open');
}
function showAssignDialog(mode) {
if (!assignDialog) {
assignDialog = $('#Config_DeviceFlags_BulkAssign_AssignDialog').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 460
});
assignDeviceSerialNumbers = $('#Config_DeviceFlags_BulkAssign_AssignDialog_DeviceSerialNumbers');
}
assignDialog.removeClass('loading');
var buttons = {};
buttons[mode + " Device Flags"] = function () {
$(this).find('form').submit();
$(this).dialog("disable");
}
buttons['Cancel'] = function () {
$(this).dialog('close');
}
assignDialog.dialog('option', 'buttons', buttons);
assignDialog.dialog('option', 'title', 'Bulk Assign Devices: ' + mode);
if (mode == "Override") {
assignDeviceSerialNumbers.closest('form').attr('action', '@(Url.Action(MVC.API.DeviceFlag.BulkAssignDevices(Model.DeviceFlag.Id, true)))');
assignDialog.addClass('loading');
$.getJSON('@Url.Action(MVC.API.DeviceFlag.AssignedDevices(Model.DeviceFlag.Id))', function (response, result) {
assignDialog.removeClass('loading');
if (result != 'success') {
alert('Unable to load current assignments:\n' + response);
assignDialog.dialog('close');
} else {
if (!!response) {
assignDeviceSerialNumbers.val(response.join('\n'));
} else {
assignDeviceSerialNumbers.val('');
}
}
});
}
else // Assume Add
{
assignDeviceSerialNumbers.closest('form').attr('action', '@(Url.Action(MVC.API.DeviceFlag.BulkAssignDevices(Model.DeviceFlag.Id, false)))');
}
assignDialog.dialog('open');
}
$('#Config_DeviceFlags_BulkAssign_Button').click(function () {
showModeDialog();
return false;
});
});
</script>
}
@if (canDelete)
{
@Html.ActionLinkButton("Delete", MVC.API.DeviceFlag.Delete(Model.DeviceFlag.Id, true), "Config_DeviceFlags_Actions_Delete_Button")
<div id="Config_DeviceFlags_Actions_Delete_Dialog" title="Delete this Device Flag?">
<p>
<i class="fa fa-exclamation-triangle fa-lg warning"></i>
This item will be permanently deleted and cannot be recovered.<br />
<br />
@if (Model.CurrentAssignmentCount > 0)
{
<strong>@Model.CurrentAssignmentCount device@(Model.CurrentAssignmentCount != 1 ? "s are" : " is") currently assigned</strong>
<br />
<br />
}
Are you sure?
</p>
</div>
<script type="text/javascript">
$(function () {
var button = $('#Config_DeviceFlags_Actions_Delete_Button');
var buttonDialog = $('#Config_DeviceFlags_Actions_Delete_Dialog');
var buttonLink = button.attr('href');
button.attr('href', '#');
button.click(function () {
buttonDialog.dialog('open');
return false;
});
buttonDialog.dialog({
resizable: false,
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");
}
}
});
});
</script>
}
@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")
}
</div>
}
File diff suppressed because it is too large Load Diff