feature: scheduled flag removal

This commit is contained in:
Gary Sharp
2025-09-19 12:18:45 +10:00
parent 356762c811
commit 7603cac01a
34 changed files with 2210 additions and 1055 deletions
@@ -1,5 +1,4 @@
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services;
using Disco.Services.Web;
using System;
using System.Data.Entity;
@@ -10,34 +9,25 @@ namespace Disco.Web.Areas.API.Controllers
{
public partial class DeviceFlagAssignmentController : AuthorizedDatabaseController
{
const string pComments = "comments";
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult Update(int id, string key, string value = null, bool? redirect = null)
public virtual ActionResult Edit(int id, string comments, DateTime? removeDate, 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
.Include(a => a.DeviceFlag)
.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");
}
.FirstOrDefault(a => a.Id == id)
?? throw new Exception("Invalid Device Flag Assignment Id");
if (!assignment.CanEdit())
throw new InvalidOperationException("Editing comments for device flags is denied");
assignment.OnEdit(comments, removeDate);
Database.SaveChanges();
if (redirect.HasValue && redirect.Value)
return Redirect($"{Url.Action(MVC.Device.Show(assignment.DeviceSerialNumber))}#DeviceDetailTab-Flags");
else
@@ -52,43 +42,30 @@ namespace Disco.Web.Areas.API.Controllers
}
}
#region Update Shortcut Methods
[HttpPost, ValidateAntiForgeryToken]
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.CanEdit())
throw new InvalidOperationException("Editing comments for device flags is denied");
assignment.OnEdit(comments);
Database.SaveChanges();
}
#endregion
#region Actions
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult AddDevice(int id, string deviceSerialNumber, string comments)
public virtual ActionResult AddDevice(int id, string deviceSerialNumber, string comments, DateTime? removeDate)
{
Database.Configuration.LazyLoadingEnabled = true;
var flag = Database.DeviceFlags.Find(id);
if (flag == null)
throw new ArgumentException("Invalid Device Flag Id", nameof(id));
var flag = Database.DeviceFlags.Find(id)
?? 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));
var device = Database.Devices
.Include(u => u.DeviceFlagAssignments)
.FirstOrDefault(d => d.SerialNumber == deviceSerialNumber)
?? throw new ArgumentException("Invalid Device Serial Number", nameof(deviceSerialNumber));
if (!device.CanAddDeviceFlag(flag))
return Unauthorized("Adding device flag is denied");
var assignment = device.OnAddDeviceFlag(Database, flag, comments);
if (removeDate.HasValue && removeDate.Value < DateTime.Today.AddDays(1))
removeDate = null;
if (device.CanRemoveDeviceFlag(flag))
device.OnAddDeviceFlag(Database, flag, comments, removeDate);
else
device.OnAddDeviceFlag(Database, flag, comments);
Database.SaveChanges();
@@ -102,9 +79,8 @@ namespace Disco.Web.Areas.API.Controllers
var assignment = Database.DeviceFlagAssignments
.Include(a => a.DeviceFlag)
.FirstOrDefault(a => a.Id == id);
if (assignment == null)
throw new ArgumentException("Invalid Device Flag Assignment Id", nameof(id));
.FirstOrDefault(a => a.Id == id)
?? throw new ArgumentException("Invalid Device Flag Assignment Id", nameof(id));
if (!assignment.CanRemove())
return Unauthorized("Removing device flag assignment is denied");
@@ -10,6 +10,7 @@ using Disco.Web.Areas.API.Models.Shared;
using Disco.Web.Areas.Config.Models.DeviceFlag;
using Disco.Web.Extensions;
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
@@ -17,12 +18,13 @@ 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";
private const string pName = "name";
private const string pDescription = "description";
private const string pIcon = "icon";
private const string pIconColour = "iconcolour";
private const string pDefaultRemoveDays = "defaultremovedays";
private const string pOnAssignmentExpression = "onassignmentexpression";
private const string pOnUnassignmentExpression = "onunassignmentexpression";
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
[HttpPost, ValidateAntiForgeryToken]
@@ -53,6 +55,9 @@ namespace Disco.Web.Areas.API.Controllers
case pIconColour:
UpdateIconColour(flag, value);
break;
case pDefaultRemoveDays:
UpdateDefaultRemoveDays(flag, value);
break;
case pOnAssignmentExpression:
UpdateOnAssignmentExpression(flag, value);
break;
@@ -143,6 +148,12 @@ namespace Disco.Web.Areas.API.Controllers
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult UpdateDefaultRemoveDays(int id, [Range(1, int.MaxValue)] int? defaultRemoveDays = null, bool? redirect = null)
{
return Update(id, pDefaultRemoveDays, defaultRemoveDays?.ToString(), redirect);
}
[DiscoAuthorize(Claims.Config.DeviceFlag.Configure)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult UpdateOnAssignmentExpression(int id, string OnAssignmentExpression = null, bool redirect = false)
{
return Update(id, pOnAssignmentExpression, OnAssignmentExpression, redirect);
@@ -280,6 +291,23 @@ namespace Disco.Web.Areas.API.Controllers
}
}
private void UpdateDefaultRemoveDays(DeviceFlag deviceFlag, string defaultRemoveDays)
{
if (string.IsNullOrWhiteSpace(defaultRemoveDays))
{
deviceFlag.DefaultRemoveDays = null;
}
else
{
if (!int.TryParse(defaultRemoveDays, out var days) || days < 1)
throw new ArgumentOutOfRangeException(nameof(defaultRemoveDays), "Unable to parse days");
deviceFlag.DefaultRemoveDays = days;
}
DeviceFlagService.Update(Database, deviceFlag);
}
private void UpdateOnAssignmentExpression(DeviceFlag deviceFlag, string onAssignmentExpression)
{
if (string.IsNullOrWhiteSpace(onAssignmentExpression))
@@ -1,5 +1,4 @@
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services;
using Disco.Services.Web;
using System;
using System.Data.Entity;
@@ -10,34 +9,25 @@ namespace Disco.Web.Areas.API.Controllers
{
public partial class UserFlagAssignmentController : AuthorizedDatabaseController
{
const string pComments = "comments";
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult Update(int id, string key, string value = null, bool? redirect = null)
public virtual ActionResult Edit(int id, string comments, DateTime? removeDate, bool? redirect = null)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException(nameof(id));
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException(nameof(key));
var userFlagAssignment = Database.UserFlagAssignments
.Include(a => a.UserFlag)
.FirstOrDefault(a => a.Id == id);
if (userFlagAssignment != null)
{
switch (key.ToLower())
{
case pComments:
UpdateComments(userFlagAssignment, value);
break;
default:
throw new Exception("Invalid Update Key");
}
}
else
{
throw new Exception("Invalid User Flag Assignment Id");
}
.FirstOrDefault(a => a.Id == id)
?? throw new Exception("Invalid User Flag Assignment Id");
if (!userFlagAssignment.CanEdit())
throw new InvalidOperationException("Editing comments for user flags is denied");
userFlagAssignment.OnEdit(comments, removeDate);
Database.SaveChanges();
if (redirect.HasValue && redirect.Value)
return Redirect($"{Url.Action(MVC.User.Show(userFlagAssignment.UserId))}#UserDetailTab-Flags");
else
@@ -52,44 +42,31 @@ namespace Disco.Web.Areas.API.Controllers
}
}
#region Update Shortcut Methods
[HttpPost, ValidateAntiForgeryToken]
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(UserFlagAssignment userFlagAssignment, string comments)
{
if (!userFlagAssignment.CanEdit())
throw new InvalidOperationException("Editing comments for user flags is denied");
userFlagAssignment.OnEdit(comments);
Database.SaveChanges();
}
#endregion
#region Actions
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult AddUser(int id, string UserId, string Comments)
public virtual ActionResult AddUser(int id, string UserId, string Comments, DateTime? RemoveDate)
{
Database.Configuration.LazyLoadingEnabled = true;
var userFlag = Database.UserFlags.Find(id);
if (userFlag == null)
throw new ArgumentException("Invalid User Flag Id", nameof(id));
var userFlag = Database.UserFlags.Find(id)
?? throw new ArgumentException("Invalid User Flag Id", nameof(id));
var user = Database.Users.Include(u => u.UserFlagAssignments).FirstOrDefault(u => u.UserId == UserId);
if (user == null)
throw new ArgumentException("Invalid User Id", nameof(UserId));
var user = Database.Users
.Include(u => u.UserFlagAssignments)
.FirstOrDefault(u => u.UserId == UserId)
?? throw new ArgumentException("Invalid User Id", nameof(UserId));
if (!user.CanAddUserFlag(userFlag))
return Unauthorized("Adding user flag is denied");
var userFlagAssignment = user.OnAddUserFlag(Database, userFlag, Comments);
if (RemoveDate.HasValue && RemoveDate.Value < DateTime.Today.AddDays(1))
RemoveDate = null;
if (user.CanRemoveUserFlag(userFlag))
user.OnAddUserFlag(Database, userFlag, Comments, RemoveDate);
else
user.OnAddUserFlag(Database, userFlag, Comments);
Database.SaveChanges();
@@ -103,9 +80,8 @@ namespace Disco.Web.Areas.API.Controllers
var userFlagAssignment = Database.UserFlagAssignments
.Include(a => a.UserFlag)
.FirstOrDefault(a => a.Id == id);
if (userFlagAssignment == null)
throw new ArgumentException("Invalid User Flag Assignment Id", nameof(id));
.FirstOrDefault(a => a.Id == id)
?? throw new ArgumentException("Invalid User Flag Assignment Id", nameof(id));
if (!userFlagAssignment.CanRemove())
return Unauthorized("Removing user flag assignment is denied");
@@ -10,6 +10,7 @@ using Disco.Web.Areas.API.Models.Shared;
using Disco.Web.Areas.Config.Models.UserFlag;
using Disco.Web.Extensions;
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web.Mvc;
@@ -17,12 +18,13 @@ namespace Disco.Web.Areas.API.Controllers
{
public partial class UserFlagController : 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";
private const string pName = "name";
private const string pDescription = "description";
private const string pIcon = "icon";
private const string pIconColour = "iconcolour";
private const string pDefaultRemoveDays = "defaultremovedays";
private const string pOnAssignmentExpression = "onassignmentexpression";
private const string pOnUnassignmentExpression = "onunassignmentexpression";
[DiscoAuthorize(Claims.Config.UserFlag.Configure)]
[HttpPost, ValidateAntiForgeryToken]
@@ -53,6 +55,9 @@ namespace Disco.Web.Areas.API.Controllers
case pIconColour:
UpdateIconColour(flag, value);
break;
case pDefaultRemoveDays:
UpdateDefaultRemoveDays(flag, value);
break;
case pOnAssignmentExpression:
UpdateOnAssignmentExpression(flag, value);
break;
@@ -143,6 +148,12 @@ namespace Disco.Web.Areas.API.Controllers
}
[DiscoAuthorize(Claims.Config.UserFlag.Configure)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult UpdateDefaultRemoveDays(int id, [Range(1, int.MaxValue)] int? defaultRemoveDays = null, bool? redirect = null)
{
return Update(id, pDefaultRemoveDays, defaultRemoveDays?.ToString(), redirect);
}
[DiscoAuthorize(Claims.Config.UserFlag.Configure)]
[HttpPost, ValidateAntiForgeryToken]
public virtual ActionResult UpdateOnAssignmentExpression(int id, string OnAssignmentExpression = null, bool redirect = false)
{
return Update(id, pOnAssignmentExpression, OnAssignmentExpression, redirect);
@@ -280,6 +291,23 @@ namespace Disco.Web.Areas.API.Controllers
}
}
private void UpdateDefaultRemoveDays(UserFlag userFlag, string defaultRemoveDays)
{
if (string.IsNullOrWhiteSpace(defaultRemoveDays))
{
userFlag.DefaultRemoveDays = null;
}
else
{
if (!int.TryParse(defaultRemoveDays, out var days) || days < 1)
throw new ArgumentOutOfRangeException(nameof(defaultRemoveDays), "Unable to parse days");
userFlag.DefaultRemoveDays = days;
}
UserFlagService.Update(Database, userFlag);
}
private void UpdateOnAssignmentExpression(UserFlag UserFlag, string OnAssignmentExpression)
{
if (string.IsNullOrWhiteSpace(OnAssignmentExpression))
@@ -3,7 +3,7 @@
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);
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null || i.DefaultRemoveDays.HasValue);
}
<div id="Config_DeviceFlags_Index">
@if (Model.DeviceFlags.Count == 0)
@@ -59,6 +59,10 @@
{
<i class="fa fa-bolt fa-lg alert" title="Has Expressions"></i>
}
@if (item.DefaultRemoveDays.HasValue)
{
<i class="fa fa-clock-o fa-lg" title="Has Default Unassignment"></i>
}
</td>
}
</tr>
@@ -49,7 +49,7 @@ namespace Disco.Web.Areas.Config.Views.DeviceFlag
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);
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null || i.DefaultRemoveDays.HasValue);
#line default
@@ -141,37 +141,37 @@ WriteLiteral(" </tr>\r\n");
#line hidden
WriteLiteral(" <tr>\r\n <td>\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 1229), Tuple.Create("\"", 1285)
WriteAttribute("href", Tuple.Create(" href=\"", 1261), Tuple.Create("\"", 1317)
#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))
, Tuple.Create(Tuple.Create("", 1268), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.DeviceFlag.Index(item.Id))
#line default
#line hidden
, 1236), false)
, 1268), 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)
WriteAttribute("class", Tuple.Create(" class=\"", 1351), Tuple.Create("\"", 1404)
, Tuple.Create(Tuple.Create("", 1359), Tuple.Create("fa", 1359), true)
, Tuple.Create(Tuple.Create(" ", 1361), Tuple.Create("fa-", 1362), true)
#line 34 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1333), Tuple.Create<System.Object, System.Int32>(item.Icon
, Tuple.Create(Tuple.Create("", 1365), 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)
, 1365), false)
, Tuple.Create(Tuple.Create(" ", 1377), Tuple.Create("fa-lg", 1378), true)
, Tuple.Create(Tuple.Create(" ", 1383), Tuple.Create("d-", 1384), true)
#line 34 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1354), Tuple.Create<System.Object, System.Int32>(item.IconColour
, Tuple.Create(Tuple.Create("", 1386), Tuple.Create<System.Object, System.Int32>(item.IconColour
#line default
#line hidden
, 1354), false)
, 1386), false)
);
WriteLiteral("></i>\r\n");
@@ -313,12 +313,37 @@ WriteLiteral("></i>\r\n");
}
#line default
#line hidden
WriteLiteral(" ");
#line 62 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (item.DefaultRemoveDays.HasValue)
{
#line default
#line hidden
WriteLiteral(" <i");
WriteLiteral(" class=\"fa fa-clock-o fa-lg\"");
WriteLiteral(" title=\"Has Default Unassignment\"");
WriteLiteral("></i>\r\n");
#line 65 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n");
#line 63 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 67 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
@@ -327,7 +352,7 @@ WriteLiteral(" </td>\r\n");
WriteLiteral(" </tr>\r\n");
#line 65 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 69 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
@@ -336,7 +361,7 @@ WriteLiteral(" </tr>\r\n");
WriteLiteral(" </table>\r\n");
#line 67 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 71 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
@@ -349,13 +374,13 @@ WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n");
#line 69 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 73 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line default
#line hidden
#line 69 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 73 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (Authorization.Has(Claims.Config.DeviceFlag.Export) && Model.DeviceFlags.Count > 0)
{
@@ -363,14 +388,14 @@ WriteLiteral(">\r\n");
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 75 "..\..\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 75 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
@@ -380,7 +405,7 @@ WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 73 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 77 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
if (Authorization.Has(Claims.Config.DeviceFlag.Create))
{
@@ -388,14 +413,14 @@ WriteLiteral(" ");
#line default
#line hidden
#line 75 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
#line 79 "..\..\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 79 "..\..\Areas\Config\Views\DeviceFlag\Index.cshtml"
}
@@ -212,6 +212,50 @@
}
</td>
</tr>
<tr>
<th>
Scheduled Unassignment:
</th>
<td>
@if (canConfig)
{
<input id="DeviceFlag_DefaultRemoveDays" type="number" min="1" max="@int.MaxValue" value="@Model.DeviceFlag.DefaultRemoveDays" />
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
@:days
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#DeviceFlag_DefaultRemoveDays'),
'Invalid Value',
'@(Url.Action(MVC.API.DeviceFlag.UpdateDefaultRemoveDays(Model.DeviceFlag.Id)))',
'defaultRemoveDays'
);
});
</script>
}
else
{
if (Model.DeviceFlag.DefaultRemoveDays.HasValue)
{
<span><strong>@Model.DeviceFlag.DefaultRemoveDays</strong> days</span>
}
else
{
<span><em>Not Enabled</em></span>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>
Optionally specify the number of days a flag is removed from a device.
If one (1), the flag will be removed that night (midnight).<br />
If the user has permission, the date can be adjusted when assigning the flag.
Changing this value does not affect existing assignments.
</p>
</div>
</td>
</tr>
@if (hideAdvanced)
{
<tr>
File diff suppressed because it is too large Load Diff
@@ -3,7 +3,7 @@
Authorization.Require(Claims.Config.UserFlag.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "User Flags");
var showTags = Model.UserFlags.Keys.Any(i => i.UserDevicesLinkedGroup != null || i.UsersLinkedGroup != null ||
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null);
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null || i.DefaultRemoveDays.HasValue);
}
<div id="Config_UserFlags_Index">
@if (Model.UserFlags.Count == 0)
@@ -59,6 +59,10 @@
{
<i class="fa fa-bolt fa-lg alert" title="Has Expressions"></i>
}
@if (item.DefaultRemoveDays.HasValue)
{
<i class="fa fa-clock-o fa-lg" title="Has Default Unassignment"></i>
}
</td>
}
</tr>
@@ -49,7 +49,7 @@ namespace Disco.Web.Areas.Config.Views.UserFlag
Authorization.Require(Claims.Config.UserFlag.Show);
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "User Flags");
var showTags = Model.UserFlags.Keys.Any(i => i.UserDevicesLinkedGroup != null || i.UsersLinkedGroup != null ||
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null);
i.OnAssignmentExpression != null || i.OnUnassignmentExpression != null || i.DefaultRemoveDays.HasValue);
#line default
@@ -141,37 +141,37 @@ WriteLiteral(" </tr>\r\n");
#line hidden
WriteLiteral(" <tr>\r\n <td>\r\n <a");
WriteAttribute("href", Tuple.Create(" href=\"", 1211), Tuple.Create("\"", 1265)
WriteAttribute("href", Tuple.Create(" href=\"", 1243), Tuple.Create("\"", 1297)
#line 33 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1218), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.UserFlag.Index(item.Id))
, Tuple.Create(Tuple.Create("", 1250), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.Config.UserFlag.Index(item.Id))
#line default
#line hidden
, 1218), false)
, 1250), false)
);
WriteLiteral(">\r\n <i");
WriteAttribute("class", Tuple.Create(" class=\"", 1299), Tuple.Create("\"", 1352)
, Tuple.Create(Tuple.Create("", 1307), Tuple.Create("fa", 1307), true)
, Tuple.Create(Tuple.Create(" ", 1309), Tuple.Create("fa-", 1310), true)
WriteAttribute("class", Tuple.Create(" class=\"", 1331), Tuple.Create("\"", 1384)
, Tuple.Create(Tuple.Create("", 1339), Tuple.Create("fa", 1339), true)
, Tuple.Create(Tuple.Create(" ", 1341), Tuple.Create("fa-", 1342), true)
#line 34 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1313), Tuple.Create<System.Object, System.Int32>(item.Icon
, Tuple.Create(Tuple.Create("", 1345), Tuple.Create<System.Object, System.Int32>(item.Icon
#line default
#line hidden
, 1313), false)
, Tuple.Create(Tuple.Create(" ", 1325), Tuple.Create("fa-lg", 1326), true)
, Tuple.Create(Tuple.Create(" ", 1331), Tuple.Create("d-", 1332), true)
, 1345), false)
, Tuple.Create(Tuple.Create(" ", 1357), Tuple.Create("fa-lg", 1358), true)
, Tuple.Create(Tuple.Create(" ", 1363), Tuple.Create("d-", 1364), true)
#line 34 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
, Tuple.Create(Tuple.Create("", 1334), Tuple.Create<System.Object, System.Int32>(item.IconColour
, Tuple.Create(Tuple.Create("", 1366), Tuple.Create<System.Object, System.Int32>(item.IconColour
#line default
#line hidden
, 1334), false)
, 1366), false)
);
WriteLiteral("></i>\r\n");
@@ -313,12 +313,37 @@ WriteLiteral("></i>\r\n");
}
#line default
#line hidden
WriteLiteral(" ");
#line 62 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
if (item.DefaultRemoveDays.HasValue)
{
#line default
#line hidden
WriteLiteral(" <i");
WriteLiteral(" class=\"fa fa-clock-o fa-lg\"");
WriteLiteral(" title=\"Has Default Unassignment\"");
WriteLiteral("></i>\r\n");
#line 65 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n");
#line 63 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 67 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
}
@@ -327,7 +352,7 @@ WriteLiteral(" </td>\r\n");
WriteLiteral(" </tr>\r\n");
#line 65 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 69 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
}
@@ -336,7 +361,7 @@ WriteLiteral(" </tr>\r\n");
WriteLiteral(" </table>\r\n");
#line 67 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 71 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
}
@@ -349,13 +374,13 @@ WriteLiteral(" class=\"actionBar\"");
WriteLiteral(">\r\n");
#line 69 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 73 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line default
#line hidden
#line 69 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 73 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
if (Authorization.Has(Claims.Config.UserFlag.Export) && Model.UserFlags.Count > 0)
{
@@ -363,14 +388,14 @@ WriteLiteral(">\r\n");
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 75 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
Write(Html.ActionLinkButton("Export", MVC.Config.UserFlag.Export()));
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 75 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
}
@@ -380,7 +405,7 @@ WriteLiteral(">\r\n");
WriteLiteral(" ");
#line 73 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 77 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
if (Authorization.Has(Claims.Config.UserFlag.Create))
{
@@ -388,14 +413,14 @@ WriteLiteral(" ");
#line default
#line hidden
#line 75 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 79 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
Write(Html.ActionLinkButton("Create User Flag", MVC.Config.UserFlag.Create()));
#line default
#line hidden
#line 75 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
#line 79 "..\..\Areas\Config\Views\UserFlag\Index.cshtml"
}
@@ -213,6 +213,50 @@
}
</td>
</tr>
<tr>
<th>
Default Assignment Removal:
</th>
<td>
@if (canConfig)
{
<input id="UserFlag_DefaultRemoveDays" type="number" min="1" max="@int.MaxValue" value="@Model.UserFlag.DefaultRemoveDays" />
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
@:days
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#UserFlag_DefaultRemoveDays'),
'Invalid Value',
'@(Url.Action(MVC.API.UserFlag.UpdateDefaultRemoveDays(Model.UserFlag.Id)))',
'defaultRemoveDays'
);
});
</script>
}
else
{
if (Model.UserFlag.DefaultRemoveDays.HasValue)
{
<span><strong>@Model.UserFlag.DefaultRemoveDays</strong> days</span>
}
else
{
<span><em>Not Enabled</em></span>
}
}
<div class="info-box">
<p class="fa-p">
<i class="fa fa-fw fa-info-circle"></i>
Optionally specify the number of days a flag is removed from a user.
If one (1), the flag will be removed that night (midnight).<br />
If the user has permission, the date can be adjusted when assigning the flag.
Changing this value does not affect existing assignments.
</p>
</div>
</td>
</tr>
@if (hideAdvanced)
{
<tr>
File diff suppressed because it is too large Load Diff