added sqlite support
This commit is contained in:
parent
6b443d2b95
commit
5fbc563c36
33
main.go
33
main.go
|
|
@ -1082,10 +1082,9 @@ const uiHTML = `<!DOCTYPE html>
|
||||||
for (let v = 0; v <= GAUGE_MAX_PERCENT + 0.0001; v += 5) {
|
for (let v = 0; v <= GAUGE_MAX_PERCENT + 0.0001; v += 5) {
|
||||||
const a = valueToAngle(v);
|
const a = valueToAngle(v);
|
||||||
const isMajor = Math.abs(v % 10) < 0.0001;
|
const isMajor = Math.abs(v % 10) < 0.0001;
|
||||||
const isWarn = Math.abs(v - WARNING_PERCENT) < 0.0001;
|
const isThreshold = Math.abs(v - WARNING_PERCENT) < 0.0001 || Math.abs(v - CRITICAL_PERCENT) < 0.0001;
|
||||||
const isCrit = Math.abs(v - CRITICAL_PERCENT) < 0.0001;
|
|
||||||
|
|
||||||
const r1 = isWarn || isCrit ? radius * 0.67 : isMajor ? radius * 0.73 : radius * 0.80;
|
const r1 = isThreshold ? radius * 0.67 : isMajor ? radius * 0.73 : radius * 0.80;
|
||||||
const r2 = radius * 0.96;
|
const r2 = radius * 0.96;
|
||||||
const p1 = polar(cx, cy, r1, a);
|
const p1 = polar(cx, cy, r1, a);
|
||||||
const p2 = polar(cx, cy, r2, a);
|
const p2 = polar(cx, cy, r2, a);
|
||||||
|
|
@ -1093,11 +1092,9 @@ const uiHTML = `<!DOCTYPE html>
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(p1.x, p1.y);
|
ctx.moveTo(p1.x, p1.y);
|
||||||
ctx.lineTo(p2.x, p2.y);
|
ctx.lineTo(p2.x, p2.y);
|
||||||
if (isWarn) {
|
|
||||||
ctx.strokeStyle = '#facc15';
|
if (isThreshold) {
|
||||||
ctx.lineWidth = 3;
|
ctx.strokeStyle = '#ffffff';
|
||||||
} else if (isCrit) {
|
|
||||||
ctx.strokeStyle = '#f87171';
|
|
||||||
ctx.lineWidth = 3;
|
ctx.lineWidth = 3;
|
||||||
} else if (isMajor) {
|
} else if (isMajor) {
|
||||||
ctx.strokeStyle = 'rgba(255,255,255,0.82)';
|
ctx.strokeStyle = 'rgba(255,255,255,0.82)';
|
||||||
|
|
@ -1313,14 +1310,10 @@ const uiHTML = `<!DOCTYPE html>
|
||||||
const labels = pts.map(p => p.time);
|
const labels = pts.map(p => p.time);
|
||||||
const dataL = pts.map(p => p.sila_l);
|
const dataL = pts.map(p => p.sila_l);
|
||||||
const dataR = pts.map(p => p.sila_r);
|
const dataR = pts.map(p => p.sila_r);
|
||||||
const warningLine = new Array(pts.length).fill(WARNING_PERCENT);
|
|
||||||
const criticalLine = new Array(pts.length).fill(CRITICAL_PERCENT);
|
|
||||||
|
|
||||||
lineChart.data.labels = labels;
|
lineChart.data.labels = labels;
|
||||||
lineChart.data.datasets[0].data = dataL;
|
lineChart.data.datasets[0].data = dataL;
|
||||||
lineChart.data.datasets[1].data = dataR;
|
lineChart.data.datasets[1].data = dataR;
|
||||||
lineChart.data.datasets[2].data = warningLine;
|
|
||||||
lineChart.data.datasets[3].data = criticalLine;
|
|
||||||
lineChart.update('none');
|
lineChart.update('none');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('History fetch error:', err);
|
console.warn('History fetch error:', err);
|
||||||
|
|
@ -1378,22 +1371,6 @@ const uiHTML = `<!DOCTYPE html>
|
||||||
tension: 0.22,
|
tension: 0.22,
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
data: []
|
data: []
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Warning %',
|
|
||||||
borderColor: '#eab308',
|
|
||||||
borderWidth: 1.4,
|
|
||||||
borderDash: [8, 8],
|
|
||||||
pointRadius: 0,
|
|
||||||
data: []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Critical %',
|
|
||||||
borderColor: '#ef4444',
|
|
||||||
borderWidth: 1.4,
|
|
||||||
borderDash: [8, 8],
|
|
||||||
pointRadius: 0,
|
|
||||||
data: []
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue