From 7907d92fa781333af999888a86a07d448a366183 Mon Sep 17 00:00:00 2001 From: Simone Micalizzi Date: Wed, 19 Jun 2024 19:04:57 +0200 Subject: [PATCH 01/16] changed COE Console link into Launch button, added proper styling to simulate tag --- src/CoeServerStatusUiController.ts | 29 +++++++++++++++++++++++++++-- src/bottom.html | 16 ++++++++++++---- src/preview.html | 10 +++++++--- src/styles.css | 13 ++++++++++++- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/CoeServerStatusUiController.ts b/src/CoeServerStatusUiController.ts index 10977b5..6b5b1fc 100644 --- a/src/CoeServerStatusUiController.ts +++ b/src/CoeServerStatusUiController.ts @@ -124,8 +124,29 @@ export class CoeServerStatusUiController { btnLaunch.disabled = coe.isRunning(); var btnStop = document.getElementById("coe-btn-stop"); btnStop.disabled = !coe.isRunning(); + var btnBottomLaunch = document.getElementById("coe-btn-launch-bottom"); + var btnBottomStop = document.getElementById("coe-btn-launch-bottom"); } + public updateButtonState() { + var coe = IntoCpsApp.getInstance().getCoeProcess(); + console.log("is running: ", coe.isRunning()); + let button = document.getElementById("coe-btn-launch-bottom"); + let icon = document.getElementById("coeIconColor"); + + if (coe.isRunning()) { + button.innerHTML = 'Stop '; + console.log("button: ", button); + button.setAttribute('onclick', 'coeViewController.stopCoe()'); + icon.style.color = 'green'; + } else { + button.innerHTML = 'Launch '; + button.setAttribute('onclick', 'coeViewController.launchCoe()'); + icon.style.color = 'red'; + } + } + + consoleAutoScroll() { let div = this.outputDiv; if (!$(div).is(":visible")) @@ -162,9 +183,10 @@ export class CoeServerStatusUiController { let index = coe.subscribePrepareSimulationCallback(this.type, this.prepareSimulationCallback()); this.isSubscribed = true; this.setStatusIcons(); - + this.updateButtonState(); + if (!this.coeStatusRunning) { - window.setInterval(() => { this.setStatusIcons(); this.truncateVisibleLog() }, 3000); + window.setInterval(() => { this.setStatusIcons(); this.truncateVisibleLog(), this.updateButtonState()}, 3000); window.setInterval(() => { this.consoleAutoScroll() }, 800); this.coeStatusRunning = true; } @@ -196,6 +218,8 @@ export class CoeServerStatusUiController { if (!coe.isRunning()) { coe.start(); } + + this.updateButtonState(); } public stopCoe() { @@ -203,6 +227,7 @@ export class CoeServerStatusUiController { if (coe.isRunning()) { coe.stop(); } + this.updateButtonState(); } } diff --git a/src/bottom.html b/src/bottom.html index 0bff819..6cba569 100644 --- a/src/bottom.html +++ b/src/bottom.html @@ -2,13 +2,21 @@