diff --git a/Disco.BI/BI/Extensions/DeviceDetailExtensions.cs b/Disco.BI/BI/Extensions/DeviceDetailExtensions.cs index f024d884..00743498 100644 --- a/Disco.BI/BI/Extensions/DeviceDetailExtensions.cs +++ b/Disco.BI/BI/Extensions/DeviceDetailExtensions.cs @@ -63,7 +63,16 @@ namespace Disco.BI.Extensions } if (detail.Value != Value) - detail.Value = Value; + { + if (Value == null) + { + device.DeviceDetails.Remove(detail); + } + else + { + detail.Value = Value; + } + } } #endregion @@ -105,5 +114,24 @@ namespace Disco.BI.Extensions } #endregion + #region ACAdapter + public const string KeyACAdapter = "ACAdapter"; + /// + /// Gets the ACAdapter Device Detail Value + /// + /// The ACAdapter or null + public static string ACAdapter(this IEnumerable details) + { + return details.GetDetail(ScopeHardware, KeyACAdapter); + } + /// + /// Sets the ACAdapter Device Detail Value + /// + public static void ACAdapter(this IEnumerable details, Device device, string ACAdapter) + { + device.SetDetail(ScopeHardware, KeyACAdapter, ACAdapter); + } + #endregion + } } diff --git a/Disco.Services/Authorization/Claims.cs b/Disco.Services/Authorization/Claims.cs index ad2ba00c..a9534e4b 100644 --- a/Disco.Services/Authorization/Claims.cs +++ b/Disco.Services/Authorization/Claims.cs @@ -147,6 +147,7 @@ namespace Disco.Services.Authorization { "Job.ShowNonWarrantyRepairs", new Tuple, Action, string, string, bool>(c => c.Job.ShowNonWarrantyRepairs, (c, v) => c.Job.ShowNonWarrantyRepairs = v, "Show Non-Warranty Repairs", "Can show non-warranty job repairs", false) }, { "Job.ShowWarranty", new Tuple, Action, string, string, bool>(c => c.Job.ShowWarranty, (c, v) => c.Job.ShowWarranty = v, "Show Warranty", "Can show job warranty", false) }, { "Device.Properties.AssetNumber", new Tuple, Action, string, string, bool>(c => c.Device.Properties.AssetNumber, (c, v) => c.Device.Properties.AssetNumber = v, "Asset Number Property", "Can update property", false) }, + { "Device.Properties.Details", new Tuple, Action, string, string, bool>(c => c.Device.Properties.Details, (c, v) => c.Device.Properties.Details = v, "Detail Properties", "Can update detail properties", false) }, { "Device.Properties.DeviceBatch", new Tuple, Action, string, string, bool>(c => c.Device.Properties.DeviceBatch, (c, v) => c.Device.Properties.DeviceBatch = v, "Device Batch Property", "Can update property", false) }, { "Device.Properties.DeviceProfile", new Tuple, Action, string, string, bool>(c => c.Device.Properties.DeviceProfile, (c, v) => c.Device.Properties.DeviceProfile = v, "Device Profile Property", "Can update property", false) }, { "Device.Properties.Location", new Tuple, Action, string, string, bool>(c => c.Device.Properties.Location, (c, v) => c.Device.Properties.Location = v, "Location Property", "Can update property", false) }, @@ -350,6 +351,7 @@ namespace Disco.Services.Authorization new ClaimNavigatorItem("Device", "Device", "Permissions related to Devices", false, new List() { new ClaimNavigatorItem("Device.Properties", "Device Properties", "Permissions related to Device Properties", false, new List() { new ClaimNavigatorItem("Device.Properties.AssetNumber", false), + new ClaimNavigatorItem("Device.Properties.Details", false), new ClaimNavigatorItem("Device.Properties.DeviceBatch", false), new ClaimNavigatorItem("Device.Properties.DeviceProfile", false), new ClaimNavigatorItem("Device.Properties.Location", false) @@ -577,6 +579,7 @@ namespace Disco.Services.Authorization c.Job.ShowNonWarrantyRepairs = true; c.Job.ShowWarranty = true; c.Device.Properties.AssetNumber = true; + c.Device.Properties.Details = true; c.Device.Properties.DeviceBatch = true; c.Device.Properties.DeviceProfile = true; c.Device.Properties.Location = true; @@ -1382,6 +1385,11 @@ namespace Disco.Services.Authorization /// public const string AssetNumber = "Device.Properties.AssetNumber"; + /// Detail Properties + /// Can update detail properties + /// + public const string Details = "Device.Properties.Details"; + /// Device Batch Property /// Can update property /// diff --git a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs index 7a5ce4e5..1c278a9e 100644 --- a/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs +++ b/Disco.Services/Authorization/Roles/ClaimGroups/Device/DevicePropertiesClaims.cs @@ -20,5 +20,8 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Device [ClaimDetails("Location Property", "Can update property")] public bool Location { get; set; } + + [ClaimDetails("Detail Properties", "Can update detail properties")] + public bool Details { get; set; } } } diff --git a/Disco.Web/Areas/API/Controllers/DeviceController.cs b/Disco.Web/Areas/API/Controllers/DeviceController.cs index ba5390d9..1a02e78d 100644 --- a/Disco.Web/Areas/API/Controllers/DeviceController.cs +++ b/Disco.Web/Areas/API/Controllers/DeviceController.cs @@ -20,6 +20,7 @@ namespace Disco.Web.Areas.API.Controllers const string pAssignedUserId = "assigneduserid"; const string pLocation = "location"; const string pAllowUnauthenticatedEnrol = "allowunauthenticatedenrol"; + const string pDetailACAdapter = "detailacadapter"; public virtual ActionResult Update(string id, string key, string value = null, bool redirect = false) { @@ -60,6 +61,10 @@ namespace Disco.Web.Areas.API.Controllers Authorization.Require(Claims.Device.Actions.AllowUnauthenticatedEnrol); UpdateAllowUnauthenticatedEnrol(device, value); break; + case pDetailACAdapter: + Authorization.Require(Claims.Device.Properties.Details); + UpdateDetailACAdapter(device, value); + break; default: throw new Exception("Invalid Update Key"); } @@ -120,6 +125,12 @@ namespace Disco.Web.Areas.API.Controllers return Update(id, pAllowUnauthenticatedEnrol, AllowUnauthenticatedEnrol, redirect); } + [DiscoAuthorize(Claims.Device.Properties.Details)] + public virtual ActionResult UpdateDetailACAdapter(string id, string DetailACAdapter = null, bool redirect = false) + { + return Update(id, pDetailACAdapter, DetailACAdapter, redirect); + } + #endregion #region Update Properties @@ -203,7 +214,7 @@ namespace Disco.Web.Areas.API.Controllers if (!string.IsNullOrEmpty(UserId)) { u = UserService.GetUser(UserId, Database, true); - + if (u == null) throw new Exception("Invalid Username"); } @@ -225,6 +236,14 @@ namespace Disco.Web.Areas.API.Controllers Database.SaveChanges(); } } + private void UpdateDetailACAdapter(Disco.Models.Repository.Device device, string ACAdapter) + { + if (string.IsNullOrWhiteSpace(ACAdapter)) + device.DeviceDetails.ACAdapter(device, null); + else + device.DeviceDetails.ACAdapter(device, ACAdapter.Trim()); + Database.SaveChanges(); + } #endregion #region Device Actions @@ -321,7 +340,8 @@ namespace Disco.Web.Areas.API.Controllers { var timeStamp = DateTime.Now; Stream pdf; - using (var generationState = Disco.Models.BI.DocumentTemplates.DocumentState.DefaultState()){ + using (var generationState = Disco.Models.BI.DocumentTemplates.DocumentState.DefaultState()) + { pdf = documentTemplate.GeneratePdf(Database, device, UserService.CurrentUser, timeStamp, generationState); } Database.SaveChanges(); @@ -474,7 +494,7 @@ namespace Disco.Web.Areas.API.Controllers } return Json(new Models.Attachment.AttachmentsModel() { Result = "Invalid Device Serial Number" }, JsonRequestBehavior.AllowGet); } - + [DiscoAuthorizeAny(Claims.Job.Actions.RemoveAnyAttachments, Claims.Job.Actions.RemoveOwnAttachments)] public virtual ActionResult AttachmentRemove(int id) { @@ -538,7 +558,7 @@ namespace Disco.Web.Areas.API.Controllers var filename = string.Format("DiscoDeviceExport-AllDevices-{0:yyyyMMdd-HHmmss}.csv", DateTime.Now); return File(export, "text/csv", filename); - } + } #endregion diff --git a/Disco.Web/T4MVC.cs b/Disco.Web/T4MVC.cs index d394947d..c8235cec 100644 --- a/Disco.Web/T4MVC.cs +++ b/Disco.Web/T4MVC.cs @@ -3349,6 +3349,12 @@ namespace Disco.Web.Areas.API.Controllers } [NonAction] [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] + public virtual System.Web.Mvc.ActionResult UpdateDetailACAdapter() + { + return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateDetailACAdapter); + } + [NonAction] + [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] public virtual System.Web.Mvc.ActionResult Decommission() { return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Decommission); @@ -3448,6 +3454,7 @@ namespace Disco.Web.Areas.API.Controllers public readonly string UpdateLocation = "UpdateLocation"; public readonly string UpdateAssignedUserId = "UpdateAssignedUserId"; public readonly string UpdateAllowUnauthenticatedEnrol = "UpdateAllowUnauthenticatedEnrol"; + public readonly string UpdateDetailACAdapter = "UpdateDetailACAdapter"; public readonly string Decommission = "Decommission"; public readonly string Recommission = "Recommission"; public readonly string Delete = "Delete"; @@ -3475,6 +3482,7 @@ namespace Disco.Web.Areas.API.Controllers public const string UpdateLocation = "UpdateLocation"; public const string UpdateAssignedUserId = "UpdateAssignedUserId"; public const string UpdateAllowUnauthenticatedEnrol = "UpdateAllowUnauthenticatedEnrol"; + public const string UpdateDetailACAdapter = "UpdateDetailACAdapter"; public const string Decommission = "Decommission"; public const string Recommission = "Recommission"; public const string Delete = "Delete"; @@ -3564,6 +3572,16 @@ namespace Disco.Web.Areas.API.Controllers public readonly string AllowUnauthenticatedEnrol = "AllowUnauthenticatedEnrol"; public readonly string redirect = "redirect"; } + static readonly ActionParamsClass_UpdateDetailACAdapter s_params_UpdateDetailACAdapter = new ActionParamsClass_UpdateDetailACAdapter(); + [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] + public ActionParamsClass_UpdateDetailACAdapter UpdateDetailACAdapterParams { get { return s_params_UpdateDetailACAdapter; } } + [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] + public class ActionParamsClass_UpdateDetailACAdapter + { + public readonly string id = "id"; + public readonly string DetailACAdapter = "DetailACAdapter"; + public readonly string redirect = "redirect"; + } static readonly ActionParamsClass_Decommission s_params_Decommission = new ActionParamsClass_Decommission(); [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] public ActionParamsClass_Decommission DecommissionParams { get { return s_params_Decommission; } } @@ -3778,6 +3796,18 @@ namespace Disco.Web.Areas.API.Controllers return callInfo; } + partial void UpdateDetailACAdapterOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string DetailACAdapter, bool redirect); + + public override System.Web.Mvc.ActionResult UpdateDetailACAdapter(string id, string DetailACAdapter, bool redirect) + { + var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateDetailACAdapter); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DetailACAdapter", DetailACAdapter); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect); + UpdateDetailACAdapterOverride(callInfo, id, DetailACAdapter, redirect); + return callInfo; + } + partial void DecommissionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, int Reason, bool redirect); public override System.Web.Mvc.ActionResult Decommission(string id, int Reason, bool redirect) diff --git a/Disco.Web/Views/Device/DeviceParts/_Details.cshtml b/Disco.Web/Views/Device/DeviceParts/_Details.cshtml index 14e979ef..63a897dd 100644 --- a/Disco.Web/Views/Device/DeviceParts/_Details.cshtml +++ b/Disco.Web/Views/Device/DeviceParts/_Details.cshtml @@ -1,6 +1,13 @@ @model Disco.Web.Models.Device.ShowModel @{ Authorization.Require(Claims.Device.ShowDetails); + + var canConfig = Authorization.Has(Claims.Device.Properties.Details); + + if (canConfig) + { + Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers"); + } }
@@ -14,6 +21,23 @@ WLAN MAC Address @(Model.Device.DeviceDetails.WLanMacAddress() ?? "Unknown") + + AC Adapter + @if (canConfig) + { + @Html.TextBox("DeviceDetail_ACAdapter", Model.Device.DeviceDetails.ACAdapter()) @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader() + + } + else + { + @(Model.Device.DeviceDetails.ACAdapter() ?? "Unknown") + } + +
diff --git a/Disco.Web/Views/Device/DeviceParts/_Details.generated.cs b/Disco.Web/Views/Device/DeviceParts/_Details.generated.cs index 37017834..0997724b 100644 --- a/Disco.Web/Views/Device/DeviceParts/_Details.generated.cs +++ b/Disco.Web/Views/Device/DeviceParts/_Details.generated.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.18051 +// Runtime Version:4.0.30319.34003 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -47,6 +47,13 @@ namespace Disco.Web.Views.Device.DeviceParts Authorization.Require(Claims.Device.ShowDetails); + var canConfig = Authorization.Has(Claims.Device.Properties.Details); + + if (canConfig) + { + Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers"); + } + #line default #line hidden @@ -68,7 +75,7 @@ WriteLiteral(">\r\n \r\n \r\n "ress\r\n "); - #line 11 "..\..\Views\Device\DeviceParts\_Details.cshtml" + #line 18 "..\..\Views\Device\DeviceParts\_Details.cshtml" Write(Model.Device.DeviceDetails.LanMacAddress() ?? "Unknown"); @@ -78,15 +85,105 @@ WriteLiteral("\r\n \r\n \r\n "MAC Address\r\n "); - #line 15 "..\..\Views\Device\DeviceParts\_Details.cshtml" + #line 22 "..\..\Views\Device\DeviceParts\_Details.cshtml" Write(Model.Device.DeviceDetails.WLanMacAddress() ?? "Unknown"); #line default #line hidden -WriteLiteral("\r\n \r\n \r\n \r\n
\r" + -"\n \r\n\r\n"); +WriteLiteral("\r\n \r\n \r\n AC Ad" + +"apter\r\n "); + + + #line 26 "..\..\Views\Device\DeviceParts\_Details.cshtml" + if (canConfig) + { + + + #line default + #line hidden + + #line 28 "..\..\Views\Device\DeviceParts\_Details.cshtml" + Write(Html.TextBox("DeviceDetail_ACAdapter", Model.Device.DeviceDetails.ACAdapter())); + + + #line default + #line hidden + + #line 28 "..\..\Views\Device\DeviceParts\_Details.cshtml" + + + #line default + #line hidden + + #line 28 "..\..\Views\Device\DeviceParts\_Details.cshtml" + Write(AjaxHelpers.AjaxSave()); + + + #line default + #line hidden + + #line 28 "..\..\Views\Device\DeviceParts\_Details.cshtml" + + + #line default + #line hidden + + #line 28 "..\..\Views\Device\DeviceParts\_Details.cshtml" + Write(AjaxHelpers.AjaxLoader()); + + + #line default + #line hidden + + #line 28 "..\..\Views\Device\DeviceParts\_Details.cshtml" + + + + #line default + #line hidden +WriteLiteral(" \r\n"); + + + #line 34 "..\..\Views\Device\DeviceParts\_Details.cshtml" + } + else + { + + + #line default + #line hidden + + #line 37 "..\..\Views\Device\DeviceParts\_Details.cshtml" + Write(Model.Device.DeviceDetails.ACAdapter() ?? "Unknown"); + + + #line default + #line hidden + + #line 37 "..\..\Views\Device\DeviceParts\_Details.cshtml" + + } + + + #line default + #line hidden +WriteLiteral(" \r\n \r\n \r\n <" + +"/table>\r\n \r\n \r\n\r" + +"\n"); } }