Storage static labels implemented
This commit is contained in:
parent
35661641f4
commit
b9491244be
|
@ -3,11 +3,10 @@ package org.bsoftware.ward.services;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.ComputerSystem;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.PhysicalMemory;
|
||||
import oshi.hardware.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
|
@ -21,9 +20,9 @@ public class InfoService
|
|||
String processorName = centralProcessor.getProcessorIdentifier().getName();
|
||||
if (processorName.contains("@"))
|
||||
{
|
||||
processorName = processorName.substring(0, processorName.indexOf('@') - 1).trim();
|
||||
processorName = processorName.substring(0, processorName.indexOf('@') - 1);
|
||||
}
|
||||
infoBuffer.put("processorName", processorName);
|
||||
infoBuffer.put("processorName", processorName.trim());
|
||||
int coreCount = centralProcessor.getLogicalProcessorCount();
|
||||
infoBuffer.put("coreCount", coreCount + ((coreCount > 1) ? " Cores" : " Core"));
|
||||
infoBuffer.put("maxClockSpeed", (Math.round((centralProcessor.getMaxFreq() / 1E+9) * 10.0) / 10.0) + " GHz");
|
||||
|
@ -46,12 +45,30 @@ public class InfoService
|
|||
|
||||
private Map<String, String> getStorageInfo(Map<String, String> infoBuffer)
|
||||
{
|
||||
System.out.println(systemInfo.getHardware().getDiskStores().get(0).getSize());
|
||||
List<HWDiskStore> hwDiskStores = systemInfo.getHardware().getDiskStores();
|
||||
String storageName = hwDiskStores.get(0).getModel();
|
||||
if (storageName.contains("(Standard disk drives)"))
|
||||
{
|
||||
storageName = storageName.substring(0, storageName.indexOf("(Standard disk drives)") - 1);
|
||||
}
|
||||
infoBuffer.put("storageName", storageName.trim());
|
||||
long totalStorage = hwDiskStores.stream().mapToLong(HWDiskStore::getSize).sum();
|
||||
infoBuffer.put("totalStorage", Math.round(totalStorage / 1.074E+9) + " GiB Total");
|
||||
int diskCount = systemInfo.getHardware().getDiskStores().size();
|
||||
infoBuffer.put("diskCount", diskCount + ((diskCount > 1) ? " Disks" : " Disk"));
|
||||
GlobalMemory globalMemory = systemInfo.getHardware().getMemory();
|
||||
infoBuffer.put("swapAmount", globalMemory.getVirtualMemory().getSwapTotal() + " GiB Swap");
|
||||
return infoBuffer;
|
||||
}
|
||||
|
||||
@SuppressWarnings("IntegerDivisionInFloatingPointContext")
|
||||
private Map<String, String> getUptimeInfo(Map<String, String> infoBuffer)
|
||||
{
|
||||
long uptimeInSeconds = systemInfo.getOperatingSystem().getSystemUptime();
|
||||
infoBuffer.put("uptimeDays", String.valueOf(Math.round(Math.floor(uptimeInSeconds / 86400))));
|
||||
infoBuffer.put("uptimeHours", String.valueOf(Math.round(Math.floor((uptimeInSeconds % 86400) / 3600))));
|
||||
infoBuffer.put("uptimeMinutes", String.valueOf(Math.round(Math.floor((uptimeInSeconds / 60) % 60))));
|
||||
infoBuffer.put("uptimeSeconds", String.valueOf(Math.round(Math.floor(uptimeInSeconds % 60))));
|
||||
return infoBuffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
<div class = "hw-logo green-light"></div>
|
||||
<div class = "label-hw-info">
|
||||
<div class = "hw-type">Storage</div>
|
||||
<div class = "hw-name"> test </div>
|
||||
<div class = "hw-name" th:text = "${storageName}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "body">
|
||||
|
@ -135,9 +135,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class = "detailed-hw-info">
|
||||
<div class = "first-label"> test </div>
|
||||
<div class = "second-label"> test </div>
|
||||
<div class = "third-label"> test </div>
|
||||
<div class = "first-label" th:text = "${totalStorage}"></div>
|
||||
<div class = "second-label" th:text = "${diskCount}"></div>
|
||||
<div class = "third-label" th:text = "${swapAmount}"></div>
|
||||
</div>
|
||||
<div class = "dividers">
|
||||
<div class = "first-divider"></div>
|
||||
|
@ -162,10 +162,10 @@
|
|||
</div>
|
||||
<div class = "uptime-rectangle-grid">
|
||||
<div class = "values-grid">
|
||||
<div><p id = "uptime-days">00</p></div>
|
||||
<div><p id = "uptime-hours">00</p></div>
|
||||
<div><p id = "uptime-minutes">00</p></div>
|
||||
<div><p id = "uptime-seconds">00</p></div>
|
||||
<div><p id = "uptime-days" th:text = "${uptimeDays}"></p></div>
|
||||
<div><p id = "uptime-hours" th:text = "${uptimeHours}"></p></div>
|
||||
<div><p id = "uptime-minutes" th:text = "${uptimeMinutes}"></p></div>
|
||||
<div><p id = "uptime-seconds" th:text = "${uptimeSeconds}"></p></div>
|
||||
</div>
|
||||
<div class = "labels-grid">
|
||||
<div>DAYS</div>
|
||||
|
|
Loading…
Reference in New Issue