瀏覽代碼

Migrate activity monitoring to the new events API

Alessandro Pignotti 1 年之前
父節點
當前提交
9b07e72065
共有 1 個文件被更改,包括 20 次插入17 次删除
  1. 20 17
      index.html

+ 20 - 17
index.html

@@ -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()
 	{