diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a833c5..b15cdf6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest] steps: - name: Checkout branch diff --git a/DEVELOPER.md b/DEVELOPER.md new file mode 100644 index 0000000..52bfae5 --- /dev/null +++ b/DEVELOPER.md @@ -0,0 +1,26 @@ +# Development environment documentation +## Required technologies and tools +- [Node Package Manager (NPM)](https://www.npmjs.com/package/npm): a package management system used to maintain packages used by the application. NPM 3 or higher is required. +- [Gulp](https://gulpjs.com/docs/en/getting-started/quick-start): a build system used to build the application. +- [Electron](http://electron.atom.io/): The app is built with Electron v10.4.7. +- [Node.js](https://nodejs.org/) (v14.x is required). +- [Visual Studio Code](https://code.visualstudio.com/) is a good choice as an editor: it's cross-platform and is actually built on top of Electron. That said, everything can be used. + +To manage multiple versions of **`Node.js`** &/or **`npm`**, consider using a [node version manager](https://github.com/search?q=node+version+manager+archived%3Afalse&type=repositories&ref=advsearch). +## How to build and run the application +The following are the commands to run the application. After checking out the repo: +1. To install node dependencies: `npm install` +2. To install gulp: `npm install -g gulp` (it's easiest to have it installed globally) +3. To build the UI: `gulp` or `gulp build` +4. To run it: `npm start` +5. To run tests: `npm test` +6. To build and create a developer .exe file: `gulp package` + +## Useful commands and properties +- `gulp watch`: it will automatically detect when you save a file and run the corresponding build task so you only have to refresh the app when developing. +- `--no-sandbox`: the property `--no-sandbox` has been inserted to `npm start` to disable sandbox mode to prevent GPU mismanagement errors, caused by Electron conflicts, during virtualization on a Linux operating system. It is necessary, however, that this property be entered while starting the built program from the terminal. For example, starting the AppImage from the terminal we would type `./NomeAppImage --no-sandbox`. This way, the application will be started without any problems. + +## Latest builds +The master branch is built automatically on git pushes and the output, for successful builds. Please find the artifacts by clicking in the run [of the Package workflow](https://github.com/INTO-CPS-Association/into-cps-application/actions?query=workflow%3APackage). + +These builds represent ongoing work. They have not been fully tested and are not guaranteed to work. Normally, you are advised to use one of the [releases](https://github.com/INTO-CPS-Association/into-cps-application/releases). diff --git a/docs/first_steps.rst b/docs/first_steps.rst index 482cd12..1fb4f01 100644 --- a/docs/first_steps.rst +++ b/docs/first_steps.rst @@ -30,7 +30,6 @@ Development Build 1. clone the repository: ``git clone https://github.com/INTO-CPS-Association/into-cps-application/tree/development`` 2. change working directory to repository: ``cd into-cps-application`` 3. install node dependencies: ``npm install`` -4. install other resources: ``gulp init`` 5. build ui: ``gulp`` 6. run the test: ``npm test`` diff --git a/package.json b/package.json index acd1688..e299ebc 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ }, "electronVersion": "10.1.3", "scripts": { - "start": "electron dist/main.js", + "start": "electron --no-sandbox dist/main.js", "test": "npx playwright test", "dist": "electron-builder --x64 -p never" }, diff --git a/src/CoeServerStatusUiController.ts b/src/CoeServerStatusUiController.ts index 10977b5..694c61e 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 COE '; + console.log("button: ", button); + button.setAttribute('onclick', 'coeViewController.stopCoe()'); + icon.style.color = 'green'; + } else { + button.innerHTML = 'Start COE '; + 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/angular2-app/coe/coe-simulation.service.ts b/src/angular2-app/coe/coe-simulation.service.ts index 0cee172..46fea6a 100644 --- a/src/angular2-app/coe/coe-simulation.service.ts +++ b/src/angular2-app/coe/coe-simulation.service.ts @@ -175,7 +175,7 @@ export class CoeSimulationService implements OnDestroy { }).catch(err => this.errorHandler(err)); } - errorHandler(err: Response, stopped?: boolean) { + errorHandler(err: { error?: string, statusText?: string, status?: number }, stopped?: boolean) { console.warn(err); if (stopped) { this.progress = 0; @@ -185,7 +185,13 @@ export class CoeSimulationService implements OnDestroy { this.errorReport(false, "Error: " + err.statusText, true) } else { this.progress = 0; - this.errorReport(true, "Error: " + err.statusText); + console.log("err: ", err); + if('error' in err){ + let errorMessage = typeof err.error === 'string' ? err.error : ''; + this.errorReport(true, "Error: " + err.statusText + (errorMessage ? " - " + errorMessage : "") + ". Check CoE Server and/or CoE Log for more details."); + } else{ + this.errorReport(true, "Error: " + err.statusText); + } } } diff --git a/src/bottom.html b/src/bottom.html index 0bff819..7589cb3 100644 --- a/src/bottom.html +++ b/src/bottom.html @@ -2,13 +2,14 @@