Sentry/assets/coffee/gpu.coffee

40 lines
1.2 KiB
CoffeeScript
Raw Normal View History

si = require('systeminformation')
window.addEventListener('load', () ->
# Set the option selector to trigger an info grab on element change
document.getElementById('gpuSelector').addEventListener('change', () ->
updateGpuInfo(@value)
)
# Load GPUs into the selector
loadGpus()
# Run the updateGpuInfo function with the default value of 0
updateGpuInfo()
, false)
loadGpus = () ->
si.graphics()
.then((data) ->
i = 0
while i < data.controllers.length
optionElem = document.createElement('option')
optionElem.innerText = data.controllers[i].model
optionElem.setAttribute('value', i)
document.getElementById('gpuSelector').appendChild(optionElem)
i++
).catch((error) ->
console.error(error)
)
updateGpuInfo = (gpuId = 0) ->
si.graphics()
.then((data) ->
document.getElementById('gpuInfo').innerText = data.controllers[gpuId].model
document.getElementById('gpuVendor').innerText = data.controllers[gpuId].vendor
document.getElementById('gpuVram').innerText = data.controllers[gpuId].vram + 'MB'
document.getElementById('gpuBus').innerText = data.controllers[gpuId].bus
).catch((error) ->
console.error(error)
)