Added a CPU info page with some rudimentary CPU temperature polling
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Gregory Ballantine 2022-05-25 16:23:42 -04:00
parent 056a5ad2a6
commit fb1d0fc664
6 changed files with 74 additions and 35 deletions

View File

@ -1,13 +1,22 @@
si = require('systeminformation') si = require('systeminformation')
window.onload = () -> window.onload = () ->
# Grab the static CPU information
si.cpu() si.cpu()
.then((data) -> .then((data) ->
document.getElementById('cpuInfo').innerText = data.brand document.getElementById('cpuInfo').innerText = data.brand
document.getElementById('cpuCores').innerText = data.physicalCores
document.getElementById('cpuThreads').innerText = data.cores
document.getElementById('cpuClock').innerText = data.speed
console.log(data) console.log(data)
).catch((error) -> ).catch((error) ->
console.error(error) console.error(error)
) )
# Start the CPU temperature loop
setCpuTemp()
setCpuTemp = () ->
si.cpuTemperature() si.cpuTemperature()
.then((data) -> .then((data) ->
document.getElementById('cpuTemp').innerText = data.main document.getElementById('cpuTemp').innerText = data.main
@ -15,11 +24,4 @@ window.onload = () ->
).catch((error) -> ).catch((error) ->
console.error(error) console.error(error)
) )
setTimeout(setCpuTemp, 2000)
si.graphics()
.then((data) ->
document.getElementById('gpuInfo').innerText = data.controllers[0].model
console.log(data)
).catch((error) ->
console.error(error)
)

10
assets/coffee/gpu.coffee Normal file
View File

@ -0,0 +1,10 @@
si = require('systeminformation')
window.onload = () ->
si.graphics()
.then((data) ->
document.getElementById('gpuInfo').innerText = data.controllers[0].model
console.log(data)
).catch((error) ->
console.error(error)
)

View File

@ -30,6 +30,16 @@ button
.container.fluid .container.fluid
max-width: 100% max-width: 100%
.pageLink
text-decoration: none
i
font-size: 10rem
p
margin-top: 10px
color: #212121
font-size: 2.5rem
text-decoration: none
#header h1 #header h1
text-align: center text-align: center

27
assets/twig/cpu.twig Normal file
View File

@ -0,0 +1,27 @@
{% extends 'layout.twig' %}
{% block scripts %}
<script src="./js/cpu.js" charset="utf-8"></script>
{% endblock %}
{% block content %}
<header class="row">
<div class="columns twelve u-text-center">
<h1>Sentry System Info</h1>
</div>
</header>
<section class="row">
<h5>CPU Model: <span id="cpuInfo">Random CPU</span></h5>
<p><span id="cpuCores">2</span>c/<span id="cpuThreads">4</span>t @ <span id="cpuClock">2.0</span>Ghz</p>
<p>CPU temperature: <span id="cpuTemp">12</span>&deg;C</p>
</section>
<section class="row">
<div class="columns twelve">
<a href="index.html">Back</a>
</div>
</section>
{% endblock %}

View File

@ -1,39 +1,29 @@
{% extends 'layout.twig' %} {% extends 'layout.twig' %}
{% block scripts %}
<script src="./js/index.js" charset="utf-8"></script>
{% endblock %}
{% block content %} {% block content %}
<header class="row"> <header class="row">
<div class="columns twelve u-text-center"> <div class="columns twelve u-text-center">
<h1>Sentry System Info</h1> <h1>Sentry System Monitor</h1>
</div> </div>
</header> </header>
<section class="row"> <section class="row">
<table class="columns twelve"> <!-- CPU info page link -->
<thead> <div class="columns six u-text-center">
<tr> <a class="pageLink" href="cpu.html">
<th>HW Type</th> <i class="fa-solid fa-microchip"></i>
<th>Hardware Model Info.</th> <p class="u-text-center">CPU</p>
<th>Current Temp.</th> </a>
</tr> </div>
</thead>
<tbody> <!-- GPU info page link -->
<tr> <div class="columns six u-text-center">
<td>CPU</td> <a class="pageLink" href="gpu.html">
<td id="cpuInfo"></td> <i class="fa-solid fa-display"></i>
<td id="cpuTemp"></td> <p class="u-text-center">Graphics Card</p>
</tr> </a>
<tr> </div>
<td>GPU</td>
<td id="gpuInfo"></td>
<td id="gpuTemp"></td>
</tr>
</tbody>
</table>
</section> </section>
{% endblock %} {% endblock %}

View File

@ -3,8 +3,8 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<link rel="stylesheet" href="{{ file_root }}/styles/skeleton-2.0.4.min.css"> <link rel="stylesheet" href="{{ file_root }}/styles/skeleton-2.0.4.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
<link rel="stylesheet" href="{{ file_root }}//styles/sentry.css"> <link rel="stylesheet" href="{{ file_root }}//styles/sentry.css">
<title>Sentry System Monitor</title> <title>Sentry System Monitor</title>
<script src="{{ file_root }}/js/sentry.js" charset="utf-8"></script> <script src="{{ file_root }}/js/sentry.js" charset="utf-8"></script>