hide decommissioned device profiles and batches by default when updating a devices batch or profile

This commit is contained in:
Gary Sharp
2023-11-09 20:48:16 +11:00
parent 2e091383ec
commit 46222f2a78
8 changed files with 375 additions and 206 deletions
+4
View File
@@ -213,6 +213,10 @@
background-color: #cddbec;
font-weight: 600;
}
#Device_Show_Policies_Profile_Actions_Update_Dialog label,
#Device_Show_Policies_Batch_Actions_Update_Dialog label {
display: block;
}
#DeviceDetailTab-JobsContainer div.jobTable {
margin: -1px;
border: 1px solid #ddd;
+3
View File
@@ -185,6 +185,9 @@
}
}
}
label {
display: block;
}
}
#DeviceDetailTab-JobsContainer {
File diff suppressed because one or more lines are too long
+22 -2
View File
@@ -245,10 +245,30 @@ namespace Disco.Web.Controllers
//}
if (Authorization.Has(Claims.Device.Properties.DeviceProfile))
m.DeviceProfiles = Database.DeviceProfiles.ToList();
{
var profiles = Database.DeviceProfiles.Select(dp =>
new
{
Profile = dp,
DecommissionedCount = dp.Devices.Count(d => d.DecommissionedDate.HasValue),
DeviceCount = dp.Devices.Count(),
}).ToList();
m.DeviceProfiles = profiles.Select(p => p.Profile).OrderBy(p => p.Name).ToList();
m.DecommissionedDeviceProfileIds = new HashSet<int>(profiles.Where(p => p.DeviceCount > 0 && p.DecommissionedCount == p.DeviceCount).Select(p => p.Profile.Id));
}
if (Authorization.Has(Claims.Device.Properties.DeviceBatch))
m.DeviceBatches = Database.DeviceBatches.ToList();
{
var batches = Database.DeviceBatches.Select(db =>
new
{
Batch = db,
DecommissionedCount = db.Devices.Count(d => d.DecommissionedDate.HasValue),
DeviceCount = db.Devices.Count(),
}).ToList();
m.DeviceBatches = batches.Select(b => b.Batch).OrderBy(b => b.Name).ToList();
m.DecommissionedDeviceBatchIds = new HashSet<int>(batches.Where(b => b.DeviceCount > 0 && b.DecommissionedCount == b.DeviceCount).Select(b => b.Batch.Id));
}
if (Authorization.Has(Claims.Device.ShowJobs))
{
+2
View File
@@ -14,11 +14,13 @@ namespace Disco.Web.Models.Device
public Disco.Models.Repository.Device Device { get; set; }
public List<Disco.Models.Repository.DeviceProfile> DeviceProfiles { get; set; }
public HashSet<int> DecommissionedDeviceProfileIds { get; set; }
public Disco.Models.BI.Config.OrganisationAddress DeviceProfileDefaultOrganisationAddress { get; set; }
public List<PluginFeatureManifest> DeviceProfileCertificateProviders { get; set; }
public List<PluginFeatureManifest> DeviceProfileWirelessProfileProviders { get; set; }
public List<Disco.Models.Repository.DeviceBatch> DeviceBatches { get; set; }
public HashSet<int> DecommissionedDeviceBatchIds { get; set; }
public JobTableModel Jobs { get; set; }
public List<Disco.Models.Repository.DeviceCertificate> Certificates { get; set; }
@@ -393,11 +393,23 @@
<ul class="none">
@foreach (var dp in Model.DeviceProfiles.OrderBy(i => i.Name))
{
<li>
<input type="radio" data-deviceprofileid="@dp.Id" name="DeviceProfile" id="DeviceProfile_@(dp.Id)" /><label for="DeviceProfile_@(dp.Id)" title="Distribution: @(dp.DistributionType)">@dp.Name</label>
var isDecommissioned = Model.DecommissionedDeviceProfileIds.Contains(dp.Id);
<li class="@(isDecommissioned ? "hidden" : null)">
<label title="Distribution: @(dp.DistributionType)">
<input type="radio" data-deviceprofileid="@dp.Id" name="DeviceProfile" />
@dp.Name
</label>
</li>
if (isDecommissioned)
{
<li class="hidden decommissioned-padding"></li>
}
}
</ul>
@if (Model.DecommissionedDeviceProfileIds.Count > 0)
{
<a class="button small show-decommissioned" href="#">Show Decommissioned</a>
}
</div>
</div>
<script>
@@ -442,6 +454,16 @@
dialogContainers.removeClass('selected');
$(this).closest('li').addClass('selected');
});
buttonDialog.find('.show-decommissioned')
.click(function (e) {
e.preventDefault();
var $this = $(this);
buttonDialog.find('ul.none')
.find('li.hidden').removeClass('hidden')
.filter('.decommissioned-padding').remove();
$this.remove();
return false;
})
}
dialogInputs.filter('[data-deviceprofileid=' + currentProfile + ']').prop('checked', true).change();
@@ -523,11 +545,23 @@
<ul class="none">
@foreach (var db in Model.DeviceBatches.OrderBy(i => i.Name))
{
<li>
<input type="radio" data-devicebatchid="@db.Id" name="DeviceBatch" id="DeviceBatch_@(db.Id)" /><label for="DeviceBatch_@(db.Id)" title="Purchased: @(db.PurchaseDate.ToLongDateString())">@db.Name</label>
var isDecommissioned = Model.DecommissionedDeviceBatchIds.Contains(db.Id);
<li class="@(isDecommissioned ? "hidden" : null)">
<label title="Purchased: @(db.PurchaseDate.ToLongDateString())">
<input type="radio" data-devicebatchid="@db.Id" name="DeviceBatch" />
@db.Name
</label>
</li>
if (isDecommissioned)
{
<li class="hidden decommissioned-padding"></li>
}
}
</ul>
@if (Model.DecommissionedDeviceBatchIds.Count > 0)
{
<a class="button small show-decommissioned" href="#">Show Decommissioned</a>
}
</div>
</div>
<script>
@@ -572,6 +606,16 @@
dialogContainers.removeClass('selected');
$(this).closest('li').addClass('selected');
});
buttonDialog.find('.show-decommissioned')
.click(function (e) {
e.preventDefault();
var $this = $(this);
buttonDialog.find('ul.none')
.find('li.hidden').removeClass('hidden')
.filter('.decommissioned-padding').remove();
$this.remove();
return false;
})
}
if (!!currentBatch) {
File diff suppressed because it is too large Load Diff