docs: add ToC to ui/web/README.md
[e-mobility-charging-stations-simulator.git] / ui / web / README.md
CommitLineData
32de5a57
LM
1# Web UI
2
98262391 3The Web UI code and configuration is in the repository directory [ui/web](./../../ui/web/). Commands execution is relative to that directory.
603f3fdd 4
a4337853
JB
5## Table of contents
6
7- [Project setup](#project-setup)
8 - [Configuration](#configuration)
9 - [Simulator UI Server Configuration](#simulator-ui-server-configuration)
10 - [Web UI configuration](#web-ui-configuration)
11 - [Unique UI server](#unique-ui-server)
12 - [Multiple UI servers](#multiple-ui-servers)
13 - [Run](#run)
14 - [Compiles and run for production](#compiles-and-run-for-production)
15 - [Preview locally](#preview-locally)
16 - [Development](#development)
17 - [Compiles and run for development](#compiles-and-run-for-development)
18 - [Formats files](#formats-files)
19 - [Lints and fixes files](#lints-and-fixes-files)
20
32de5a57
LM
21## Project setup
22
217db058
JB
23### Configuration
24
25#### Simulator UI Server Configuration
26
27The simulator UI server must be enabled, use WebSocket transport type and have authentication disabled. The simulator main configuration file should have a `uiServer` section like this:
8228f972
JB
28
29```json
30 "uiServer": {
31 "enabled": true,
32 "type": "ws",
33 "authentication": {
329eab0e
JB
34 "enabled": true,
35 "type": "protocol-basic-auth",
8228f972
JB
36 "username": "admin",
37 "password": "admin"
38 }
39 },
40```
41
b4c9f3c1 42See [here](./../../README.md#charging-stations-simulator-configuration) for more details.
8228f972 43
217db058
JB
44#### Web UI configuration
45
f80e9e18 46Copy the configuration template [src/assets/config-template.json](./src/assets/config-template.json) to `public/config.json`.
217db058 47
a4337853 48##### Unique UI server
4b08c55e
JB
49
50```json
51{
52 "uiServer": {
53 "host": "localhost",
54 "port": 8080,
55 "protocol": "ui",
56 "version": "0.0.1",
57 "authentication": {
58 "enabled": true,
59 "type": "protocol-basic-auth",
60 "username": "admin",
61 "password": "admin"
62 }
63 }
64}
65```
66
a4337853 67##### Multiple UI servers
4b08c55e
JB
68
69```json
70{
71 "uiServer": [
72 {
73 "host": "server1.domain.tld",
74 "port": 8080,
75 "protocol": "ui",
76 "version": "0.0.1",
77 "authentication": {
78 "enabled": true,
79 "type": "protocol-basic-auth",
80 "username": "admin",
81 "password": "admin"
82 }
83 },
84 ...
85 {
86 "host": "serverN.domain.tld",
87 "port": 8080,
88 "protocol": "ui",
89 "version": "0.0.1",
90 "authentication": {
91 "enabled": true,
92 "type": "protocol-basic-auth",
93 "username": "admin",
94 "password": "admin"
95 }
96 }
97 ]
98}
99```
100
32de5a57
LM
101### Run
102
a4337853 103#### Compiles and run for production
217db058
JB
104
105```shell
106pnpm preview
107```
108
a4337853 109#### Preview locally
d07e35d2 110
0d7042e2 111You can now follow the link displayed in the terminal. The Web UI looks like the following:
d07e35d2 112
9d76f5ec 113![webui](./src/assets/webui.png)
d07e35d2 114
4b08c55e
JB
1151. With the buttons on the top you can change UI server, start/stop the simulator, add new charging stations and refresh the content.
1162. Each charging station is a row in the table with specific 'Actions' to execute on. Try 'Stop Charging Station' and refresh with the large blue button and see the status 'Started' turns from 'Yes' into 'No'.
32de5a57 117
217db058
JB
118### Development
119
120#### Compiles and run for development
32de5a57 121
d6b76da3 122```shell
217db058
JB
123pnpm dev
124```
125
126#### Formats files
127
128```shell
129pnpm format
32de5a57
LM
130```
131
217db058 132#### Lints and fixes files
32de5a57 133
d6b76da3 134```shell
217db058 135pnpm lint:fix
32de5a57 136```