client: create initial table definitions

These will (hopefully) be used to decide on the layout of the UI for 
each table.
This commit is contained in:
Starbeamrainbowlabs 2022-02-26 21:58:20 +00:00
parent 5d0e480f1c
commit 36a96a84fd
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 107 additions and 0 deletions

View file

@ -0,0 +1,20 @@
"use strict";
/**
* Converts a filesize into a human-readable string.
* Ported from PHP: https://github.com/sbrl/Pepperminty-Wiki/blob/0a81c940c5803856db250b29f54658476bc81e21/core/05-functions.php#L57-L73
* @see http://php.net/manual/en/function.filesize.php#106569 The original source
* @author rommel
* @author Edited by Starbeamrainbowlabs
* @param {number} bytes The number of bytes to convert.
* @param {number} decimals The number of decimal places to preserve.
* @return {string} A human-readable filesize.
*/
function human_filesize(bytes, decimals = 2) {
let sz = ["b", "kib", "mib", "gib", "tib", "pib", "eib", "yib", "zib"];
let factor = Math.floor((bytes.toString().length - 1) / 3);
let result = Math.round(bytes / (1024 ** factor), decimals);
return result + sz[factor];
}
export default human_filesize;

View file

@ -0,0 +1,9 @@
"use strict";
import cpu from './tabledefs/cpu.mjs';
import cpu_live from './tabledefs/cpu_live.mjs';
export default {
cpu,
cpu_live
}

View file

@ -0,0 +1,44 @@
"use strict";
import human_filesize from '../misc/human_filesize.mjs';
export default [
{
name: "Model",
type: "table",
content: "{{manufacturer}} {{brand}}"
},
{
name: "Speed (GHz)",
type: "table",
content: {
"Speed": "{{speed}}",
"Speed (min)": "{{speedMin}}",
"Speed (max)": "{{speedMax}}",
}
},
{
name: "Core layout",
type: "table",
content: {
"Processors": "{{processors}}",
"Cores": "{{cores}}",
"Physical Cores": "{{physicalCores}}"
}
},
{
name: "Governor",
type: "table",
content: "{{governor}}"
},
{
name: "Cache",
type: "table",
content: {
"L1 (data)": (table) => `${human_filesize(table.cache.l1d)}`,
"L1 (instruction)": (table) => `${human_filesize(table.cache.l1i)}`,
"L2": (table) => `${human_filesize(table.cache.l2)}`,
"L3": (table) => `${human_filesize(table.cache.l3)}`,
}
},
];

View file

@ -0,0 +1,34 @@
"use strict";
import human_filesize from '../misc/human_filesize.mjs';
export default [
{
name: "Frequency (GHz)",
type: "guage",
guage: { min: 0, max: 6 },
content: {
"min": "frequency.min",
"max": "frequency.max",
"average": "frequency.avg"
}
},
{
name: "Frequency per-core (GHz)",
type: "guage",
guage: { min: 0, max: 6 },
content: (table) => table.frequency.cores
},
{
name: "Temperature (°C)",
type: "guage",
guage: { min: 0, max: 100 },
content: "main",
},
{
name: "Chipset temperature (°C)",
type: "guage",
guage: { min: 0, max: 100 },
content: "main"
}
];