Feature #7: AC Adapter Device Detail
This commit is contained in:
@@ -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";
|
||||
/// <summary>
|
||||
/// Gets the ACAdapter Device Detail Value
|
||||
/// </summary>
|
||||
/// <returns>The ACAdapter or null</returns>
|
||||
public static string ACAdapter(this IEnumerable<DeviceDetail> details)
|
||||
{
|
||||
return details.GetDetail(ScopeHardware, KeyACAdapter);
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the ACAdapter Device Detail Value
|
||||
/// </summary>
|
||||
public static void ACAdapter(this IEnumerable<DeviceDetail> details, Device device, string ACAdapter)
|
||||
{
|
||||
device.SetDetail(ScopeHardware, KeyACAdapter, ACAdapter);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ namespace Disco.Services.Authorization
|
||||
{ "Job.ShowNonWarrantyRepairs", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, 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<Func<RoleClaims, bool>, Action<RoleClaims, bool>, 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<Func<RoleClaims, bool>, Action<RoleClaims, bool>, 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<Func<RoleClaims, bool>, Action<RoleClaims, bool>, 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<Func<RoleClaims, bool>, Action<RoleClaims, bool>, 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<Func<RoleClaims, bool>, Action<RoleClaims, bool>, 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<Func<RoleClaims, bool>, Action<RoleClaims, bool>, 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<IClaimNavigatorItem>() {
|
||||
new ClaimNavigatorItem("Device.Properties", "Device Properties", "Permissions related to Device Properties", false, new List<IClaimNavigatorItem>() {
|
||||
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
|
||||
/// </summary>
|
||||
public const string AssetNumber = "Device.Properties.AssetNumber";
|
||||
|
||||
/// <summary>Detail Properties
|
||||
/// <para>Can update detail properties</para>
|
||||
/// </summary>
|
||||
public const string Details = "Device.Properties.Details";
|
||||
|
||||
/// <summary>Device Batch Property
|
||||
/// <para>Can update property</para>
|
||||
/// </summary>
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
<div id="DeviceDetailTab-Details" class="DevicePart">
|
||||
<div id="DeviceDetailTab-DetailsContainer">
|
||||
@@ -14,6 +21,23 @@
|
||||
<th>WLAN MAC Address</th>
|
||||
<td>@(Model.Device.DeviceDetails.WLanMacAddress() ?? "Unknown")</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>AC Adapter</th>
|
||||
<td>@if (canConfig)
|
||||
{
|
||||
@Html.TextBox("DeviceDetail_ACAdapter", Model.Device.DeviceDetails.ACAdapter()) @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper($('#DeviceDetail_ACAdapter'), 'Unknown', '@Url.Action(MVC.API.Device.UpdateDetailACAdapter(Model.Device.SerialNumber, null))', 'DetailACAdapter');
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
@(Model.Device.DeviceDetails.ACAdapter() ?? "Unknown")
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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 <tbody>\r\n <tr>\r\n
|
||||
"ress</th>\r\n <td>");
|
||||
|
||||
|
||||
#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("</td>\r\n </tr>\r\n <tr>\r\n
|
||||
"MAC Address</th>\r\n <td>");
|
||||
|
||||
|
||||
#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("</td>\r\n </tr>\r\n </tbody>\r\n </table>\r\n </div>\r" +
|
||||
"\n <script>\r\n $(\'#DeviceDetailTabItems\').append(\'<li><a href=\"#DeviceDe" +
|
||||
"tailTab-Details\">Details</a></li>\');\r\n </script>\r\n</div>\r\n");
|
||||
WriteLiteral("</td>\r\n </tr>\r\n <tr>\r\n <th>AC Ad" +
|
||||
"apter</th>\r\n <td>");
|
||||
|
||||
|
||||
#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(" <script>\r\n $(function () {\r\n " +
|
||||
" document.DiscoFunctions.PropertyChangeHelper($(\'#D" +
|
||||
"eviceDetail_ACAdapter\'), \'Unknown\', \'");
|
||||
|
||||
|
||||
#line 31 "..\..\Views\Device\DeviceParts\_Details.cshtml"
|
||||
Write(Url.Action(MVC.API.Device.UpdateDetailACAdapter(Model.Device.SerialNumber, null)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\', \'DetailACAdapter\');\r\n });\r\n " +
|
||||
"</script>\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(" </td>\r\n </tr>\r\n </tbody>\r\n <" +
|
||||
"/table>\r\n </div>\r\n <script>\r\n $(\'#DeviceDetailTabItems\').append(\'<l" +
|
||||
"i><a href=\"#DeviceDetailTab-Details\">Details</a></li>\');\r\n </script>\r\n</div>\r" +
|
||||
"\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user