This commit is contained in:
Bob Wen 2021-03-08 14:58:51 +08:00 committed by GitHub
parent eeebc595ed
commit c0804d85e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 47 additions and 4 deletions

View File

@ -1,9 +1,27 @@
window.onload = function () {
resize_canvas();
var chart = new SmoothieChart({ millisPerPixel: 200, maxValueScale: 1.1, minValueScale: 1.1, scaleSmoothing: 0.1, grid: { fillStyle: '#ffffff', millisPerLine: 5000, verticalSections: 8 }, labels: { fillStyle: '#0000ff', fontSize: 18, precision: 1 }, timestampFormatter: SmoothieChart.timeFormatter }),
canvas = document.getElementById('smoothie-chart'),
series = new TimeSeries();
average_array = []
i18n();
var chart = new SmoothieChart({
millisPerPixel: 200,
maxValueScale: 1.1,
minValueScale: 1.1,
scaleSmoothing: 0.1,
grid: {
fillStyle: '#ffffff',
millisPerLine: 30000,
verticalSections: 5
},
labels: {
fillStyle: '#0000ff',
fontSize: 18,
precision: 1
},
timestampFormatter: SmoothieChart.timeFormatter
});
var canvas = document.getElementById('smoothie-chart');
var series = new TimeSeries();
var average_array = [];
chart.addTimeSeries(series, { lineWidth: 3.5, strokeStyle: '#ff0000' });
chart.streamTo(canvas, 500);
@ -21,6 +39,7 @@ window.onload = function () {
});
};
setInterval(function () { run_proc(series, average_array) }, 2000);
run_proc(series, average_array);
}
function resize_canvas() {
@ -35,3 +54,27 @@ function average(array) {
}
return Math.round(sum * 10 / count) / 10;
}
function i18n() {
var init = function () {
var C_ = cockpit.gettext;
var po_file = './i18n/' + cockpit.language + '.json';
console.debug('i18n:', po_file);
fetch(po_file)
.then(response => response.json())
.then(data => {
cockpit.locale(data);
document.getElementById("title").innerHTML = C_('CPU Temperature');
document.getElementById("key_cur_temp").innerHTML = C_('Current Temperature:');
document.getElementById("key_avg_temp").innerHTML = C_('Average Temperature (5m):');
});
};
check_language_timer = setInterval(() => {
if (cockpit.language) {
clearInterval(check_language_timer);
init();
return;
}
}, 1000);
}