Files
Disco/Disco.Web/Views/Device/DeviceParts/_Details.cshtml
T
2023-11-06 11:24:58 +11:00

475 lines
26 KiB
Plaintext

@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");
}
var processors = Model.Device.DeviceDetails.Processors();
var physicalMemory = Model.Device.DeviceDetails.PhysicalMemory();
var diskDrives = Model.Device.DeviceDetails.DiskDrives();
var networkAdapters = Model.Device.DeviceDetails.NetworkAdapters();
var lanMacAddress = Model.Device.DeviceDetails.LanMacAddress();
var wlanMacAddress = Model.Device.DeviceDetails.WLanMacAddress();
var bios = Model.Device.DeviceDetails.Bios();
var baseBoard = Model.Device.DeviceDetails.BaseBoard();
var computerSystem = Model.Device.DeviceDetails.ComputerSystem();
var batteries = Model.Device.DeviceDetails.Batteries();
}
<div id="DeviceDetailTab-Details" class="DevicePart">
<div id="DeviceDetailTab-DetailsContainer">
<table class="tableData">
<tbody>
@if (bios != null)
{
<tr class="device_detail_bios">
<th>BIOS</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Manufacturer</th>
<th>Serial Number</th>
<th>Version</th>
<th>System Version</th>
<th>Release Date</th>
</tr>
</thead>
<tbody>
@foreach (var b in bios)
{
<tr>
<td>@b.Manufacturer</td>
<td>@b.SerialNumber</td>
<td>@b.SMBIOSBIOSVersion @(b.SMBIOSMajorVersion.GetValueOrDefault(0)).@b.SMBIOSMinorVersion</td>
<td>@(b.SystemBiosMajorVersion).@b.SystemBiosMinorVersion</td>
<td>
@if (b.ReleaseDate.HasValue)
{
@b.ReleaseDate.Value.ToString("yyyy-MM-dd")
}
</td>
</tr>
}
</tbody>
</table>
</td>
</tr>
}
@if (baseBoard != null)
{
<tr class="device_detail_base_board">
<th>Base Board</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Manufacturer</th>
<th>Model</th>
<th>Product</th>
<th>Part Number</th>
<th>SKU</th>
<th>Serial Number</th>
<th>Config Options</th>
<th>Version</th>
</tr>
</thead>
<tbody>
@foreach (var b in baseBoard)
{
<tr>
<td>@b.Manufacturer</td>
<td>@b.Model</td>
<td>@b.Product</td>
<td>@b.PartNumber</td>
<td>@b.SKU</td>
<td>@b.SerialNumber</td>
<td>
@if (b.ConfigOptions != null)
{
<text>@string.Join("; ", b.ConfigOptions)</text>
}
</td>
<td>@b.Version</td>
</tr>
}
</tbody>
</table>
</td>
</tr>
}
@if (computerSystem != null)
{
<tr class="device_detail_computer_system">
<th>System</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Description</th>
<th>Form Factor</th>
<th>Type</th>
<th>Primary Owner</th>
<th>Chassis SKU</th>
<th>System SKU</th>
<th>OEM Reference</th>
<th>Time Zone</th>
<th>Roles</th>
</tr>
</thead>
<tbody>
@foreach (var c in computerSystem)
{
<tr>
<td>@c.Description</td>
<td>@c.PCSystemType</td>
<td>@c.SystemType</td>
<td>@c.PrimaryOwnerName @c.PrimaryOwnerContact</td>
<td>@c.ChassisSKUNumber</td>
<td>@c.SystemSKUNumber</td>
<td>
@if (c.OEMStringArray != null)
{
<text>@string.Join("; ", c.OEMStringArray)</text>
}
</td>
<td>
@if (c.CurrentTimeZone.HasValue)
{
@((c.CurrentTimeZone.Value / 60).ToString(@"00\:"))@(Math.Abs(c.CurrentTimeZone.Value % 60).ToString("00"))
}
</td>
<td>
@if (c.Roles != null)
{
<text>@string.Join("; ", c.Roles)</text>
}
</td>
</tr>
}
</tbody>
</table>
</td>
</tr>
}
@if (processors != null)
{
<tr class="device_detail_processors">
<th>Processors</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Architecture</th>
<th>Max Clock Speed</th>
<th>Cores</th>
<th>Logical Processors</th>
</tr>
</thead>
<tbody>
@foreach (var processor in processors)
{
<tr>
<td>@processor.Name</td>
<td>@processor.Description</td>
<td>@processor.Architecture</td>
<td>@processor.MaxClockSpeedFriendly()</td>
<td>@processor.NumberOfCores.GetValueOrDefault(0).ToString("N0")</td>
<td>@processor.NumberOfLogicalProcessors.GetValueOrDefault(0).ToString("N0")</td>
</tr>
}
</tbody>
</table>
</td>
</tr>
}
@if (physicalMemory != null)
{
<tr class="device_detail_memory">
<th>Memory</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Location</th>
<th>Manufacturer</th>
<th>Part Number</th>
<th>Serial Number</th>
<th>Capacity</th>
<th>Clock Speed</th>
</tr>
</thead>
<tbody>
@foreach (var memory in physicalMemory)
{
<tr>
<td>@memory.DeviceLocator</td>
<td>@memory.Manufacturer</td>
<td>@memory.PartNumber</td>
<td>@memory.SerialNumber</td>
<td>@memory.CapacityFriendly()</td>
<td>@memory.ConfiguredClockSpeed</td>
</tr>
}
</tbody>
</table>
</td>
</tr>
}
@if (networkAdapters != null)
{
<tr class="device_detail_network_adapters">
<th>Network Adapters</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Connection</th>
<th>Manufacturer</th>
<th>Product</th>
<th>Speed</th>
<th>MAC Address</th>
</tr>
</thead>
<tbody>
@foreach (var adapter in networkAdapters)
{
<tr>
<td>
@(adapter.NetConnectionID ?? "N/A") @if (adapter.IsWlanAdapter)
{<i class="fa fa-wifi"></i>}
</td>
<td>@adapter.Manufacturer</td>
<td>@adapter.ProductName</td>
<td>@adapter.SpeedFriendly()</td>
<td>@adapter.MACAddress</td>
</tr>
}
</tbody>
</table>
</td>
</tr>
}
else
{
if (lanMacAddress != null)
{
<tr class="device_detail_lan_mac_address">
<th>LAN MAC Address</th>
<td class="pad code">@(lanMacAddress)</td>
</tr>
}
if (wlanMacAddress != null)
{
<tr class="device_detail_wlan_mac_address">
<th>WLAN MAC Address</th>
<td class="pad code">@(wlanMacAddress)</td>
</tr>
}
}
@if (diskDrives != null)
{
<tr class="device_detail_disk_drives">
<th>Disk Drives</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Manufacturer</th>
<th>Model</th>
<th>Serial Number</th>
<th>Firmware</th>
<th>Type</th>
<th>Interface</th>
<th>Size</th>
</tr>
</thead>
<tbody>
@foreach (var disk in diskDrives)
{
<tr>
<td>@disk.Manufacturer</td>
<td>@disk.Model</td>
<td>@disk.SerialNumber</td>
<td>@disk.FirmwareRevision</td>
<td>@disk.MediaType</td>
<td>@disk.InterfaceType</td>
<td>@disk.SizeFriendly()</td>
</tr>
if (disk.Partitions != null)
{
// calculate stretched offsets
var minPartitionSize = (double)disk.Size * 0.1;
var diskSizeAdjusted = disk.Partitions.Sum(p => Math.Max(minPartitionSize, p.Size.GetValueOrDefault(0)));
var diskAdjustedOffet = (double)0;
<tr>
<td colspan="7">
<div class="partition">
@foreach (var partition in disk.Partitions)
{
var logicalDisk = partition.LogicalDisk;
var offsetPercentage = Math.Round(((partition.StartingOffset.GetValueOrDefault(0) + diskAdjustedOffet) / diskSizeAdjusted) * 100, 3);
var widthPercentage = Math.Round((Math.Max(minPartitionSize, partition.Size.GetValueOrDefault(0)) / diskSizeAdjusted) * 100, 3);
var freeSpacePercentage = 0d;
if (partition.Size < minPartitionSize)
{
diskAdjustedOffet += minPartitionSize - partition.Size.GetValueOrDefault(0);
}
var partitionTitle = partition.Type;
var tags = new List<string>();
if (partition.BootPartition.GetValueOrDefault(false))
{
tags.Add("Boot");
}
if (partition.PrimaryParition.GetValueOrDefault(false))
{
tags.Add("Primary");
}
if (logicalDisk != null)
{
partitionTitle = string.Format("{0} {1}", logicalDisk.DeviceID, logicalDisk.VolumeName);
tags.Add(logicalDisk.SizeFriendly());
tags.Add(logicalDisk.FreeSpaceFriendly() + " Free");
tags.Add(logicalDisk.FileSystem);
tags.Add(logicalDisk.DriveType);
freeSpacePercentage = Math.Round(((double)logicalDisk.FreeSpace.GetValueOrDefault(0) / logicalDisk.Size.GetValueOrDefault(0)) * 100, 3);
}
else
{
tags.Add(partition.SizeFriendly());
}
var tag = string.Join(" | ", tags);
<span title="@(partitionTitle) &#xA@(tag)" style="left: @(offsetPercentage)%; width: @(widthPercentage)%">
@if (freeSpacePercentage > 0.5)
{
<span class="freespace" style="left: @(100 - freeSpacePercentage)%; width: @(freeSpacePercentage)%"></span>
}
<span class="details">
<strong>@partitionTitle</strong>
<br />
@tag
</span>
</span>
}
</div>
</td>
</tr>
}
}
</tbody>
</table>
</td>
</tr>
}
<tr class="device_detail_ac_adapter">
<th>AC Adapter</th>
<td class="pad">
@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>
<tr class="device_detail_battery">
<th>Battery</th>
<td class="pad">
@if (canConfig)
{
@Html.TextBox("DeviceDetail_Battery", Model.Device.DeviceDetails.Battery()) @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader()
<script>
$(function () {
document.DiscoFunctions.PropertyChangeHelper($('#DeviceDetail_Battery'), 'Unknown', '@Url.Action(MVC.API.Device.UpdateDetailBattery(Model.Device.SerialNumber, null))', 'DetailBattery');
});
</script>
}
else
{
@(Model.Device.DeviceDetails.Battery() ?? "Unknown")
}
</td>
</tr>
@if (batteries != null)
{
<tr class="device_detail_batteries">
<th>&nbsp;</th>
<td>
<table class="tableData">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Availability</th>
<th>Chemistry</th>
<th>Design Voltage</th>
<th>Design Capacity</th>
<th>Capacity</th>
</tr>
</thead>
<tbody>
@foreach (var battery in batteries)
{
<tr>
<td>@battery.Name</td>
<td>@battery.Description</td>
<td>@battery.Availability</td>
<td>@battery.Chemistry</td>
<td>@battery.DesignVoltage.GetValueOrDefault(0).ToString("N0") mV</td>
<td>@battery.DesignCapacity.GetValueOrDefault(0).ToString("N0") mWh</td>
<td>@battery.FullChargeCapacity.GetValueOrDefault(0).ToString("N0") mWh</td>
</tr>
}
</tbody>
</table>
</td>
</tr>
}
<tr class="device_detail_keyboard">
<th>Keyboard</th>
<td class="pad">
@if (canConfig)
{
@Html.TextBox("DeviceDetail_Keyboard", Model.Device.DeviceDetails.Keyboard()) @AjaxHelpers.AjaxSave() @AjaxHelpers.AjaxLoader()
<script>
$(function () {
document.DiscoFunctions.PropertyChangeHelper($('#DeviceDetail_Keyboard'), 'Unknown', '@Url.Action(MVC.API.Device.UpdateDetailKeyboard(Model.Device.SerialNumber, null))', 'DetailKeyboard');
});
</script>
}
else
{
@(Model.Device.DeviceDetails.Keyboard() ?? "Unknown")
}
</td>
</tr>
@if (Model.Device.LastEnrolDate.HasValue)
{
<tr class="device_detail_update">
<td colspan="2"><em>Details collected @CommonHelpers.FriendlyDate(Model.Device.LastEnrolDate) at time of last enrolment</em></td>
</tr>
}
</tbody>
</table>
</div>
<script>
$('#DeviceDetailTabItems').append('<li><a href="#DeviceDetailTab-Details">Details</a></li>');
</script>
</div>