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