fixes #134 - hide decommissioned device profiles by default

This commit is contained in:
Gary Sharp
2023-11-09 20:05:25 +11:00
parent 7ace4d1c7e
commit 2e091383ec
4 changed files with 144 additions and 47 deletions
@@ -2,6 +2,22 @@
@using Disco.Web.Areas.Config.Models.DeviceProfile @using Disco.Web.Areas.Config.Models.DeviceProfile
@{ @{
Authorization.Require(Claims.Config.DeviceProfile.Show); Authorization.Require(Claims.Config.DeviceProfile.Show);
var hasDecommissionedBatches = Model.DeviceProfiles.Any(dp => dp.DeviceCount > 0 && dp.DeviceDecommissionedCount >= dp.DeviceCount);
}
@if (hasDecommissionedBatches)
{
<a id="Config_DeviceProfiles_ShowDecommissioned" href="#" class="button small">Show Decommissioned (@(Model.DeviceProfiles.Count(db => db.DeviceCount > 0 && db.DeviceDecommissionedCount >= db.DeviceCount)))</a>
<script>
$(function () {
$('#Config_DeviceProfiles_ShowDecommissioned').click(function () {
$(this).remove();
$('.deviceProfileTable')
.find('tr.hidden').removeClass('hidden')
.filter('.decommissioned-padding').remove();
return false;
}).detach().appendTo('#layout_PageHeading');
})
</script>
} }
@if (DiscoApplication.MultiSiteMode) @if (DiscoApplication.MultiSiteMode)
{ {
@@ -9,11 +25,11 @@
foreach (var deviceProfilesGroup in deviceProfilesGrouped) foreach (var deviceProfilesGroup in deviceProfilesGrouped)
{ {
if (deviceProfilesGroup.Key != null) if (deviceProfilesGroup.Key != null)
{ <h2>@deviceProfilesGroup.Key</h2> } {<h2>@deviceProfilesGroup.Key</h2> }
@Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, deviceProfilesGroup.Cast<_IndexModelItem>(), new ViewDataDictionary()) @Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, deviceProfilesGroup.Cast<_IndexModelItem>(), new ViewDataDictionary())
} }
} }
else else
{ {
@Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, Model.DeviceProfiles.Cast<_IndexModelItem>(), new ViewDataDictionary()) @Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, Model.DeviceProfiles.Cast<_IndexModelItem>(), new ViewDataDictionary())
} }
@@ -53,6 +53,7 @@ namespace Disco.Web.Areas.Config.Views.DeviceProfile
#line 3 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 3 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
Authorization.Require(Claims.Config.DeviceProfile.Show); Authorization.Require(Claims.Config.DeviceProfile.Show);
var hasDecommissionedBatches = Model.DeviceProfiles.Any(dp => dp.DeviceCount > 0 && dp.DeviceDecommissionedCount >= dp.DeviceCount);
#line default #line default
@@ -60,7 +61,54 @@ namespace Disco.Web.Areas.Config.Views.DeviceProfile
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 6 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 7 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
if (hasDecommissionedBatches)
{
#line default
#line hidden
WriteLiteral(" <a");
WriteLiteral(" id=\"Config_DeviceProfiles_ShowDecommissioned\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Show Decommissioned (");
#line 9 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
Write(Model.DeviceProfiles.Count(db => db.DeviceCount > 0 && db.DeviceDecommissionedCount >= db.DeviceCount));
#line default
#line hidden
WriteLiteral(")</a>\r\n");
WriteLiteral(@" <script>
$(function () {
$('#Config_DeviceProfiles_ShowDecommissioned').click(function () {
$(this).remove();
$('.deviceProfileTable')
.find('tr.hidden').removeClass('hidden')
.filter('.decommissioned-padding').remove();
return false;
}).detach().appendTo('#layout_PageHeading');
})
</script>
");
#line 21 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
}
#line default
#line hidden
#line 22 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
if (DiscoApplication.MultiSiteMode) if (DiscoApplication.MultiSiteMode)
{ {
var deviceProfilesGrouped = Model.DeviceProfiles.OrderBy(i => i.AddressName).GroupBy(i => i.AddressName); var deviceProfilesGrouped = Model.DeviceProfiles.OrderBy(i => i.AddressName).GroupBy(i => i.AddressName);
@@ -71,11 +119,11 @@ WriteLiteral("\r\n");
#line default #line default
#line hidden #line hidden
WriteLiteral(" <h2>"); WriteLiteral("<h2>");
#line 12 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 28 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
Write(deviceProfilesGroup.Key); Write(deviceProfilesGroup.Key);
#line default #line default
@@ -83,23 +131,23 @@ WriteLiteral(" <h2>");
WriteLiteral("</h2> "); WriteLiteral("</h2> ");
#line 12 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 28 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
} }
#line default #line default
#line hidden #line hidden
#line 13 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 29 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
Write(Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, deviceProfilesGroup.Cast<_IndexModelItem>(), new ViewDataDictionary())); Write(Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, deviceProfilesGroup.Cast<_IndexModelItem>(), new ViewDataDictionary()));
#line default #line default
#line hidden #line hidden
#line 13 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 29 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
} }
} }
else else
{ {
@@ -108,14 +156,14 @@ else
#line default #line default
#line hidden #line hidden
#line 18 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 34 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
Write(Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, Model.DeviceProfiles.Cast<_IndexModelItem>(), new ViewDataDictionary())); Write(Html.Partial(MVC.Config.DeviceProfile.Views._TableRender, Model.DeviceProfiles.Cast<_IndexModelItem>(), new ViewDataDictionary()));
#line default #line default
#line hidden #line hidden
#line 18 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml" #line 34 "..\..\Areas\Config\Views\DeviceProfile\_Table.cshtml"
} }
@@ -24,7 +24,8 @@
</tr> </tr>
@foreach (var item in Model) @foreach (var item in Model)
{ {
<tr> var isDecommissioned = item.DeviceCount > 0 && item.DeviceDecommissionedCount >= item.DeviceCount;
<tr class="@(isDecommissioned ? "hidden" : null)">
<td> <td>
@Html.ActionLink(item.Name, MVC.Config.DeviceProfile.Index(item.Id)) @Html.ActionLink(item.Name, MVC.Config.DeviceProfile.Index(item.Id))
</td> </td>
@@ -64,5 +65,9 @@
</td> </td>
} }
</tr> </tr>
if (isDecommissioned)
{
<tr class="hidden decommissioned-padding"></tr>
}
} }
</table> </table>
@@ -109,16 +109,29 @@ WriteLiteral(" </tr>\r\n");
#line 25 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 25 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
foreach (var item in Model) foreach (var item in Model)
{ {
var isDecommissioned = item.DeviceCount > 0 && item.DeviceDecommissionedCount >= item.DeviceCount;
#line default #line default
#line hidden #line hidden
WriteLiteral(" <tr>\r\n <td>\r\n"); WriteLiteral(" <tr");
WriteAttribute("class", Tuple.Create(" class=\"", 769), Tuple.Create("\"", 814)
#line 28 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
, Tuple.Create(Tuple.Create("", 777), Tuple.Create<System.Object, System.Int32>(isDecommissioned ? "hidden" : null
#line default
#line hidden
, 777), false)
);
WriteLiteral(">\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 29 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 30 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
Write(Html.ActionLink(item.Name, MVC.Config.DeviceProfile.Index(item.Id))); Write(Html.ActionLink(item.Name, MVC.Config.DeviceProfile.Index(item.Id)));
@@ -129,7 +142,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 32 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 33 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
Write(Html.DisplayFor(modelItem => item.Description)); Write(Html.DisplayFor(modelItem => item.Description));
@@ -140,7 +153,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 35 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 36 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
Write(Html.DisplayFor(modelItem => item.DistributionType)); Write(Html.DisplayFor(modelItem => item.DistributionType));
@@ -149,13 +162,13 @@ WriteLiteral(" ");
WriteLiteral("\r\n </td>\r\n <td>\r\n"); WriteLiteral("\r\n </td>\r\n <td>\r\n");
#line 38 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 39 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
#line default #line default
#line hidden #line hidden
#line 38 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 39 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
if (item.DeviceCount > 0 && Authorization.Has(Claims.Device.Search)) if (item.DeviceCount > 0 && Authorization.Has(Claims.Device.Search))
{ {
@@ -165,7 +178,7 @@ WriteLiteral("\r\n </td>\r\n <td>\r\n");
WriteLiteral(" <span>"); WriteLiteral(" <span>");
#line 40 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 41 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
Write(Html.ActionLink(string.Format("View {0}", item.DeviceCount), MVC.Search.Query(item.Id.ToString(), "DeviceProfile"))); Write(Html.ActionLink(string.Format("View {0}", item.DeviceCount), MVC.Search.Query(item.Id.ToString(), "DeviceProfile")));
@@ -174,7 +187,7 @@ WriteLiteral(" <span>");
WriteLiteral("</span>\r\n"); WriteLiteral("</span>\r\n");
#line 41 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 42 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
} }
else else
{ {
@@ -185,7 +198,7 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" <span>"); WriteLiteral(" <span>");
#line 44 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 45 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
Write(item.DeviceCount.ToString("n0")); Write(item.DeviceCount.ToString("n0"));
@@ -194,7 +207,7 @@ WriteLiteral(" <span>");
WriteLiteral("</span>\r\n"); WriteLiteral("</span>\r\n");
#line 45 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 46 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
} }
@@ -203,7 +216,7 @@ WriteLiteral("</span>\r\n");
WriteLiteral(" "); WriteLiteral(" ");
#line 46 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 47 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
if (item.DeviceDecommissionedCount > 0) if (item.DeviceDecommissionedCount > 0)
{ {
@@ -214,21 +227,21 @@ WriteLiteral(" <span");
WriteLiteral(" class=\"smallMessage\""); WriteLiteral(" class=\"smallMessage\"");
WriteAttribute("title", Tuple.Create(" title=\"", 1540), Tuple.Create("\"", 1611) WriteAttribute("title", Tuple.Create(" title=\"", 1694), Tuple.Create("\"", 1765)
#line 48 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 49 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
, Tuple.Create(Tuple.Create("", 1548), Tuple.Create<System.Object, System.Int32>(item.DeviceDecommissionedCount.ToString("n0") , Tuple.Create(Tuple.Create("", 1702), Tuple.Create<System.Object, System.Int32>(item.DeviceDecommissionedCount.ToString("n0")
#line default #line default
#line hidden #line hidden
, 1548), false) , 1702), false)
, Tuple.Create(Tuple.Create(" ", 1596), Tuple.Create("Decommissioned", 1597), true) , Tuple.Create(Tuple.Create(" ", 1750), Tuple.Create("Decommissioned", 1751), true)
); );
WriteLiteral(">\r\n ("); WriteLiteral(">\r\n (");
#line 49 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 50 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
Write(item.DeviceDecommissionedCount.ToString("n0")); Write(item.DeviceDecommissionedCount.ToString("n0"));
@@ -237,7 +250,7 @@ WriteLiteral(">\r\n (");
WriteLiteral(")\r\n </span>\r\n"); WriteLiteral(")\r\n </span>\r\n");
#line 51 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 52 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
} }
@@ -246,13 +259,13 @@ WriteLiteral(")\r\n </span>\r\n");
WriteLiteral(" </td>\r\n"); WriteLiteral(" </td>\r\n");
#line 53 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 54 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
#line default #line default
#line hidden #line hidden
#line 53 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 54 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
if (showTags) if (showTags)
{ {
@@ -262,13 +275,13 @@ WriteLiteral(" </td>\r\n");
WriteLiteral(" <td>\r\n"); WriteLiteral(" <td>\r\n");
#line 56 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 57 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
#line default #line default
#line hidden #line hidden
#line 56 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 57 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
if (item.IsLinked) if (item.IsLinked)
{ {
@@ -284,7 +297,7 @@ WriteLiteral(" title=\"Is Linked\"");
WriteLiteral("></i>\r\n"); WriteLiteral("></i>\r\n");
#line 59 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 60 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
} }
else else
{ {
@@ -299,7 +312,7 @@ WriteLiteral("&nbsp;");
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 63 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 64 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
} }
@@ -308,7 +321,7 @@ WriteLiteral("\r\n");
WriteLiteral(" </td>\r\n"); WriteLiteral(" </td>\r\n");
#line 65 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 66 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
} }
@@ -317,7 +330,22 @@ WriteLiteral(" </td>\r\n");
WriteLiteral(" </tr>\r\n"); WriteLiteral(" </tr>\r\n");
#line 67 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml" #line 68 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
if (isDecommissioned)
{
#line default
#line hidden
WriteLiteral(" <tr");
WriteLiteral(" class=\"hidden decommissioned-padding\"");
WriteLiteral("></tr>\r\n");
#line 71 "..\..\Areas\Config\Views\DeviceProfile\_TableRender.cshtml"
}
} }