2022-08-23 23:54:13 -04:00
|
|
|
si = require('systeminformation')
|
|
|
|
|
2022-10-28 01:06:09 -04:00
|
|
|
window.addEventListener('load', () ->
|
2022-08-23 23:54:13 -04:00
|
|
|
# Set the option selector to trigger an info grab on element change
|
|
|
|
document.getElementById('diskSelector').addEventListener('change', () ->
|
|
|
|
updateDiskInfo(@value)
|
|
|
|
)
|
|
|
|
|
|
|
|
# Load GPUs into the selector
|
|
|
|
loadDisks()
|
|
|
|
|
|
|
|
# Run the updateGpuInfo function with the default value of 0
|
|
|
|
updateDiskInfo()
|
|
|
|
|
2022-08-24 00:23:36 -04:00
|
|
|
# Start running our function to update the drive's temperature
|
|
|
|
setDiskTemp()
|
2022-10-28 01:06:09 -04:00
|
|
|
, false)
|
2022-08-24 00:23:36 -04:00
|
|
|
|
2022-08-23 23:54:13 -04:00
|
|
|
loadDisks = () ->
|
|
|
|
si.diskLayout()
|
|
|
|
.then((data) ->
|
|
|
|
i = 0
|
|
|
|
while i < data.length
|
|
|
|
optionElem = document.createElement('option')
|
2022-08-23 23:59:05 -04:00
|
|
|
diskName = data[i].name + ' (' + data[i].device + ')'
|
2022-08-23 23:54:13 -04:00
|
|
|
optionElem.innerText = diskName
|
|
|
|
optionElem.setAttribute('value', i)
|
|
|
|
document.getElementById('diskSelector').appendChild(optionElem)
|
|
|
|
i++
|
|
|
|
).catch((error) ->
|
|
|
|
console.error(error)
|
|
|
|
)
|
|
|
|
|
|
|
|
updateDiskInfo = (diskId = 0) ->
|
|
|
|
si.diskLayout()
|
|
|
|
.then((data) ->
|
|
|
|
document.getElementById('diskInfo').innerText = data[diskId].name
|
|
|
|
document.getElementById('diskPath').innerText = data[diskId].device
|
|
|
|
document.getElementById('diskType').innerText = data[diskId].type
|
|
|
|
document.getElementById('diskSize').innerText = formatBytes(data[diskId].size)
|
|
|
|
document.getElementById('diskVendor').innerText = data[diskId].vendor
|
|
|
|
).catch((error) ->
|
|
|
|
console.error(error)
|
|
|
|
)
|
2022-08-24 00:23:36 -04:00
|
|
|
|
|
|
|
setDiskTemp = (diskId = -1) ->
|
|
|
|
selector = document.getElementById('diskSelector')
|
|
|
|
if selector.length < 1
|
|
|
|
return
|
|
|
|
|
|
|
|
if (diskId = -1)
|
|
|
|
diskId = selector.value
|
|
|
|
|
|
|
|
si.diskLayout()
|
|
|
|
.then((data) ->
|
|
|
|
if (data[diskId].temperature)
|
|
|
|
document.getElementById('diskTemp').innerText = data[diskId].temperature
|
|
|
|
).catch((error) ->
|
|
|
|
console.error(error)
|
|
|
|
)
|
|
|
|
setTimeout(setDiskTemp, 2000)
|