Migrate activity monitoring to the new events API

This commit is contained in:
Alessandro Pignotti 2024-07-04 16:53:20 +02:00
parent 36db7dd37d
commit 9b07e72065

View file

@ -248,6 +248,23 @@ __ __ _ __ ____ __
}
term.onData(readData);
function hddCallback(state)
{
var h = document.getElementById("hddactivity");
if(state == "ready")
h.textContent = "\u{1F7E2}";
else
h.textContent = "\u{1F7E0}";
}
function cpuCallback(state)
{
var h = document.getElementById("cpuactivity");
if(state == "ready")
h.textContent = "\u{1F7E2}";
else
h.textContent = "\u{1F7E0}";
}
//Actual CheerpX and bash specific logic
function runBash()
{
@ -277,6 +294,8 @@ __ __ _ __ ____ __
async function runTest(cx)
{
cx.registerCallback("cpuActivity", cpuCallback);
cx.registerCallback("diskActivity", hddCallback);
registerNetworkLogin(cx, networkInterface);
term.scrollToBottom();
@ -308,24 +327,8 @@ __ __ _ __ ____ __
{
printOnTerm.printError(printOnTerm.getErrorMessage(err));
}
function devCallback(state)
{
var h = document.getElementById("hddactivity");
if(state == "ready")
h.textContent = "\u{1F7E2}";
else
h.textContent = "\u{1F7E0}";
}
function cpuCallback(state)
{
var h = document.getElementById("cpuactivity");
if(state == "ready")
h.textContent = "\u{1F7E2}";
else
h.textContent = "\u{1F7E0}";
}
// The device url and type are replaced by Github Actions.
CheerpXApp.create({devices:[{type:DEVICE_TYPE,url:IMAGE_URL,name:"block1"}],mounts:[{type:"ext2",dev:"block1",path:"/"},{type:"cheerpOS",dev:"/app",path:"/app"},{type:"cheerpOS",dev:"/str",path:"/data"},{type:"devs",dev:"",path:"/dev"}], networkInterface: networkInterface, activityInterface: {cpu: cpuCallback, dev: devCallback}}).then(runTest, failCallback);
CheerpXApp.create({devices:[{type:DEVICE_TYPE,url:IMAGE_URL,name:"block1"}],mounts:[{type:"ext2",dev:"block1",path:"/"},{type:"cheerpOS",dev:"/app",path:"/app"},{type:"cheerpOS",dev:"/str",path:"/data"},{type:"devs",dev:"",path:"/dev"}], networkInterface: networkInterface}).then(runTest, failCallback);
}
function initialMessage()
{