From: Jérôme Benoit Date: Wed, 14 Feb 2024 20:37:25 +0000 (+0100) Subject: refactor(ui): use JSON format as runtime configuration X-Git-Tag: v1.2.37~50 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9d76f5ec92a3f5865ef2cefd5a253cab3aa2e5fe;p=e-mobility-charging-stations-simulator.git refactor(ui): use JSON format as runtime configuration Signed-off-by: Jérôme Benoit --- diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16d73816..48e5cfb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -112,9 +112,7 @@ jobs: if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }} run: pnpm lint - name: pnpm build - run: | - pnpm build:prepare - pnpm build + run: pnpm build - name: pnpm test run: pnpm test - name: pnpm coverage diff --git a/docker/Dockerfile b/docker/Dockerfile index 24881891..0ffd4bf2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -25,7 +25,6 @@ RUN set -ex \ && pnpm set progress=false \ && pnpm config set depth 0 \ && pnpm install --ignore-scripts --frozen-lockfile \ - && pnpm build:prepare \ && pnpm build FROM node:lts-alpine diff --git a/ui/web/.gitignore b/ui/web/.gitignore index 73475000..447b9ddd 100644 --- a/ui/web/.gitignore +++ b/ui/web/.gitignore @@ -1,7 +1,7 @@ .DS_Store node_modules /dist -/src/assets/config.ts +/public/config.json # Created by git for backups. To disable backups in git: # $ git config --global mergetool.keepBackup false diff --git a/ui/web/README.md b/ui/web/README.md index 1f5fdd33..f2c21d13 100644 --- a/ui/web/README.md +++ b/ui/web/README.md @@ -35,7 +35,7 @@ See [here](./../../README.md#charging-stations-simulator-configuration) for more #### Web UI configuration -Copy the configuration template [src/assets/config-template.ts](src/assets/config-template.ts) to `src/assets/config.ts`. +Copy the configuration template [src/assets/config-template.json](src/assets/config-template.json) to `public/config.json`. ### Run @@ -61,7 +61,7 @@ pnpm start For both options above you can then follow the link displayed in the terminal at the end of compilation. The Web UI looks like the following -![webui](./assets/webui.png) +![webui](./src/assets/webui.png) 1. With the top 2 buttons you can now stop and afterwards start the simulator and inspect the server console for the number of charging stations, e.g. with the default configuration: `Charging stations simulator ... started with 10 charging station(s)` 2. Each charging station is a row in the table below, try "Stop Charging Station" and refresh with the large blue button and see the status Started turns from Yes into No. diff --git a/ui/web/package.json b/ui/web/package.json index 80d418fb..3d9d373c 100644 --- a/ui/web/package.json +++ b/ui/web/package.json @@ -22,7 +22,6 @@ "start": "pnpm build && node start.js", "dev": "vite", "preview": "vite preview", - "build:prepare": "node build-prepare.js", "build": "vite build", "clean:dist": "npx rimraf dist", "clean:node_modules": "npx rimraf node_modules", diff --git a/ui/web/src/assets/config-template.json b/ui/web/src/assets/config-template.json new file mode 100644 index 00000000..1997f9d1 --- /dev/null +++ b/ui/web/src/assets/config-template.json @@ -0,0 +1,14 @@ +{ + "uiServer": { + "host": "localhost", + "port": 8080, + "protocol": "ui", + "version": "0.0.1", + "authentication": { + "enabled": false, + "type": "basic-auth", + "username": "admin", + "password": "admin" + } + } +} diff --git a/ui/web/src/assets/config-template.ts b/ui/web/src/assets/config-template.ts deleted file mode 100644 index b5807ce4..00000000 --- a/ui/web/src/assets/config-template.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { AuthenticationType, type ConfigurationData, Protocol, ProtocolVersion } from '@/types' - -const configuration: ConfigurationData = { - uiServer: { - host: 'localhost', - port: 8080, - protocol: Protocol.UI, - version: ProtocolVersion['0.0.1'], - authentication: { - enabled: false, - type: AuthenticationType.BASIC_AUTH, - username: 'admin', - password: 'admin' - } - } -} - -export default configuration diff --git a/ui/web/src/assets/logo.png b/ui/web/src/assets/logo.png deleted file mode 100644 index f3d2503f..00000000 Binary files a/ui/web/src/assets/logo.png and /dev/null differ diff --git a/ui/web/assets/webui.png b/ui/web/src/assets/webui.png similarity index 100% rename from ui/web/assets/webui.png rename to ui/web/src/assets/webui.png diff --git a/ui/web/src/components/charging-stations/CSConnector.vue b/ui/web/src/components/charging-stations/CSConnector.vue index 29bb0718..08852683 100644 --- a/ui/web/src/components/charging-stations/CSConnector.vue +++ b/ui/web/src/components/charging-stations/CSConnector.vue @@ -23,12 +23,12 @@ diff --git a/ui/web/src/components/charging-stations/CSData.vue b/ui/web/src/components/charging-stations/CSData.vue index befdbb4b..d077ca6e 100644 --- a/ui/web/src/components/charging-stations/CSData.vue +++ b/ui/web/src/components/charging-stations/CSData.vue @@ -21,7 +21,7 @@