Merge branch 'develop' of gitee.com:myems/myems into develop
commit
1488fcb646
|
@ -9,16 +9,14 @@
|
||||||
|
|
||||||
### 配置
|
### 配置
|
||||||
|
|
||||||
注一:这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的,用来展示说明,实际情况中用户需要根据自己的配置改为自己的,具体的修改步骤会在“安装”中讲述。
|
**注**:这里的主机指的是安装Docker的主机, 这里的IP和账号密码都为假定的,用来展示说明,请酌情修改。
|
||||||
|
|
||||||
注二:这里如果**安装数据库和安装Docker的主机为同一个主机,那么数据库IP和主机IP修改为一个实际IP**即可,这里是以数据库,和安装Docker的主机不在同一个上举例的。
|
| -- | -- |
|
||||||
|
| ---------- | ----------- |
|
||||||
| -- | -- |
|
| Host IP | 192.168.0.1 |
|
||||||
| ---------- | ----------- |
|
| Database IP | 192.168.0.2 |
|
||||||
| 主机IP | 192.168.0.1 |
|
| Database User | root |
|
||||||
| 数据库IP | 192.168.0.2 |
|
| Database Password | !MyEMS1 |
|
||||||
| 数据库账号 | root |
|
|
||||||
| 数据库密码 | !MyEMS1 |
|
|
||||||
|
|
||||||
### 安装
|
### 安装
|
||||||
|
|
||||||
|
@ -33,8 +31,10 @@ git clone https://gitee.com/myems/myems.git
|
||||||
cd myems/database/install
|
cd myems/database/install
|
||||||
mysql -u root -p < myems_billing_baseline_db.sql
|
mysql -u root -p < myems_billing_baseline_db.sql
|
||||||
mysql -u root -p < myems_billing_db.sql
|
mysql -u root -p < myems_billing_db.sql
|
||||||
|
mysql -u root -p < myems_carbon_db.sql
|
||||||
mysql -u root -p < myems_energy_baseline_db.sql
|
mysql -u root -p < myems_energy_baseline_db.sql
|
||||||
mysql -u root -p < myems_energy_db.sql
|
mysql -u root -p < myems_energy_db.sql
|
||||||
|
mysql -u root -p < myems_energy_model_db.sql
|
||||||
mysql -u root -p < myems_fdd_db.sql
|
mysql -u root -p < myems_fdd_db.sql
|
||||||
mysql -u root -p < myems_historical_db.sql
|
mysql -u root -p < myems_historical_db.sql
|
||||||
mysql -u root -p < myems_reporting_db.sql
|
mysql -u root -p < myems_reporting_db.sql
|
||||||
|
@ -57,12 +57,11 @@ sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/nginx.conf
|
||||||
|
|
||||||
3.2 复制example.env为.env并修改.env里的数据库IP,账号,密码
|
3.2 复制example.env为.env并修改.env里的数据库IP,账号,密码
|
||||||
```
|
```
|
||||||
# 这里以修改数据库IP为例,如果数据库账号密码也不同,请根据自己需求替换.env里的账号密码
|
|
||||||
cd myems
|
cd myems
|
||||||
cp myems-api/example.env myems-api/.env
|
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
|
|
||||||
cp myems-aggregation/example.env myems-aggregation/.env
|
cp myems-aggregation/example.env myems-aggregation/.env
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
|
||||||
|
cp myems-api/example.env myems-api/.env
|
||||||
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
|
||||||
cp myems-cleaning/example.env myems-cleaning/.env
|
cp myems-cleaning/example.env myems-cleaning/.env
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
|
||||||
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
|
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
|
||||||
|
@ -76,12 +75,6 @@ sed -i 's/127.0.0.1/192.168.0.2/g' myems-normalization/.env
|
||||||
如果是Linux主机,在api和admin服务中,volumes/source使用 /upload
|
如果是Linux主机,在api和admin服务中,volumes/source使用 /upload
|
||||||
应确保api和admin共享同一主机文件夹。
|
应确保api和admin共享同一主机文件夹。
|
||||||
|
|
||||||
3.4 验证数据库连接
|
|
||||||
```
|
|
||||||
cd myems
|
|
||||||
python3 myems-api/test_mysql.py
|
|
||||||
```
|
|
||||||
|
|
||||||
4. 编译Web UI
|
4. 编译Web UI
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -99,12 +92,14 @@ docker-compose up -d
|
||||||
|
|
||||||
6. 验证
|
6. 验证
|
||||||
|
|
||||||
| | 网址 | 结果 |
|
| | 网址 | 期望结果 |
|
||||||
| ----- | ----------------------- | ---------------- |
|
| ----- | ----------------------- | ---------------- |
|
||||||
| web | 192.168.0.1:80 | 输入账号密码登录成功 |
|
| web | 192.168.0.1:80 | 输入账号密码登录成功 |
|
||||||
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 |
|
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 |
|
||||||
| api | 192.168.0.1:8000/version| 返回版本信息 |
|
| api | 192.168.0.1:8000/version| 返回版本信息 |
|
||||||
注:如果api报错,请确认.env里的数据库IP,数据库账号,数据库密码是否正确,如果不正确,请修改.env后执行:
|
|
||||||
|
**注**:如果api报错,请确认.env里的数据库IP,数据库账号,数据库密码是否正确,如果不正确,请修改后执行:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose up --build -d
|
docker-compose up --build -d
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,67 +1,67 @@
|
||||||
## Docker Compose
|
## Docker Compose
|
||||||
Create and start all the services with a single command
|
Erstellen und starten Sie alle Dienste mit einem einzigen Befehl
|
||||||
|
|
||||||
### Prerequisite
|
### Voraussetzung
|
||||||
|
|
||||||
- Installed docker、docker-compose、npm on a host.
|
- Installed docker, docker-compose, npm on a host.
|
||||||
- Installed MySQL database with username 'root' and password '!MyEMS1'.
|
- Installed MySQL database with username 'root' and password '!MyEMS1'.
|
||||||
- The MySQL database can be connected from the host where Docker is installed.
|
- The MySQL database can be connected from the host where Docker is installed.
|
||||||
|
|
||||||
### Configuration
|
### Konfiguration
|
||||||
|
|
||||||
Note 1: 这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的,用来展示说明,实际情况中用户需要根据自己的配置改为自己的,具体的修改步骤会在“安装”中讲述。
|
**Anmerkung**: Der Host hier bezieht sich auf den Host, auf dem Docker installiert ist. Die IP und das Account-Passwort werden hier angenommen und verwendet, um Anweisungen anzuzeigen. Bitte ändern Sie sie entsprechend.
|
||||||
|
|
||||||
Note 2: 这里如果**安装数据库和安装Docker的主机为同一个主机,那么数据库IP和主机IP修改为一个实际IP**即可,这里是以数据库,和安装Docker的主机不在同一个上举例的。
|
| -- | -- |
|
||||||
|
| ---------- | ----------- |
|
||||||
| -- | -- |
|
| Host IP | 192.168.0.1 |
|
||||||
| ---------- | ----------- |
|
| Database IP | 192.168.0.2 |
|
||||||
| Host IP | 192.168.0.1 |
|
| Database User | root |
|
||||||
| Database IP | 192.168.0.2 |
|
| Database Password | !MyEMS1 |
|
||||||
| Database User | root |
|
|
||||||
| Database Password | !MyEMS1 |
|
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
1. Clone repository
|
1. Repository klonen
|
||||||
```
|
```
|
||||||
git clone https://gitee.com/myems/myems.git
|
git clone https://gitee.com/myems/myems.git
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Import database schema
|
2. Datenbankschema importieren
|
||||||
|
|
||||||
```
|
```
|
||||||
cd myems/database/install
|
cd myems/database/install
|
||||||
mysql -u root -p < myems_billing_baseline_db.sql
|
mysql -u root -p < myems_billing_baseline_db.sql
|
||||||
mysql -u root -p < myems_billing_db.sql
|
mysql -u root -p < myems_billing_db.sql
|
||||||
|
mysql -u root -p < myems_carbon_db.sql
|
||||||
mysql -u root -p < myems_energy_baseline_db.sql
|
mysql -u root -p < myems_energy_baseline_db.sql
|
||||||
mysql -u root -p < myems_energy_db.sql
|
mysql -u root -p < myems_energy_db.sql
|
||||||
|
mysql -u root -p < myems_energy_model_db.sql
|
||||||
mysql -u root -p < myems_fdd_db.sql
|
mysql -u root -p < myems_fdd_db.sql
|
||||||
mysql -u root -p < myems_historical_db.sql
|
mysql -u root -p < myems_historical_db.sql
|
||||||
mysql -u root -p < myems_reporting_db.sql
|
mysql -u root -p < myems_reporting_db.sql
|
||||||
mysql -u root -p < myems_system_db.sql
|
mysql -u root -p < myems_system_db.sql
|
||||||
mysql -u root -p < myems_user_db.sql
|
mysql -u root -p < myems_user_db.sql
|
||||||
```
|
```
|
||||||
Note: Refer to [database/README.md](./database/README.md)
|
Anmerkung: Siehe unter [database/README.md](./database/README.md)
|
||||||
|
|
||||||
|
|
||||||
3. Modify Config
|
3. Konfiguration ändern
|
||||||
|
|
||||||
注:如“配置”所述,这里假定的**主机IP为 192.168.0.1,数据库IP为 192.168.0.2,数据库账号为:root,数据库密码:!MyEMS1,用户应该修改为自己对应的主机IP,数据库IP,数据库账号,数据库密码**
|
**Anmerkungen**:Die Host-IP hier angenommen ist 192.168.0.1, die Datenbank-IP ist 192.168.0.2, das Datenbank-Konto ist: root und das Datenbank-Passwort ist: !MyEMS1, bitte ändern Sie dies entsprechend
|
||||||
|
|
||||||
3.1 Modify api address in nginx.conf
|
3.1 API-Adresse ändern in nginx.conf
|
||||||
```
|
```
|
||||||
cd myems
|
cd myems
|
||||||
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' admin/nginx.conf
|
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' admin/nginx.conf
|
||||||
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/nginx.conf
|
sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/nginx.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
3.2 Copy example.env to .env and modify database IP, username and password in .env
|
3.2 Beispiel example.env bis .env und Datenbank-IP, Benutzername und Passwort in .env
|
||||||
```
|
```
|
||||||
cd myems
|
cd myems
|
||||||
cp myems-api/example.env myems-api/.env
|
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
|
|
||||||
cp myems-aggregation/example.env myems-aggregation/.env
|
cp myems-aggregation/example.env myems-aggregation/.env
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
|
||||||
|
cp myems-api/example.env myems-api/.env
|
||||||
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
|
||||||
cp myems-cleaning/example.env myems-cleaning/.env
|
cp myems-cleaning/example.env myems-cleaning/.env
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
|
||||||
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
|
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
|
||||||
|
@ -70,18 +70,12 @@ cp myems-normalization/example.env myems-normalization/.env
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-normalization/.env
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-normalization/.env
|
||||||
```
|
```
|
||||||
|
|
||||||
3.3 Modify upload folder in docker-compose.yml
|
3.3 Upload-Ordner ändern in docker-compose.yml
|
||||||
If Windows host, use c:\upload for volumes/source in api and admin services.
|
If Windows host, use c:\upload for volumes/source in api and admin services.
|
||||||
If Linux host, use /upload for volumes/source in api and admin services.
|
If Linux host, use /upload for volumes/source in api and admin services.
|
||||||
Make sure the upload folders in api and admin are same folder on host.
|
Make sure the upload folders in api and admin are same folder on host.
|
||||||
|
|
||||||
3.4 Validate database connection
|
4. Web UI erstellen
|
||||||
```
|
|
||||||
cd myems
|
|
||||||
python3 myems-api/test_mysql.py
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Build Web UI
|
|
||||||
|
|
||||||
```
|
```
|
||||||
cd myems/web
|
cd myems/web
|
||||||
|
@ -89,7 +83,7 @@ npm i --unsafe-perm=true --allow-root --legacy-peer-deps
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Run docker-compose command
|
5. Befehl Docker-compose ausführen
|
||||||
|
|
||||||
```
|
```
|
||||||
cd myems
|
cd myems
|
||||||
|
@ -98,12 +92,13 @@ docker-compose up -d
|
||||||
|
|
||||||
6. Verification
|
6. Verification
|
||||||
|
|
||||||
| | Address | Result |
|
| | Address | Erwartetes Ergebnis |
|
||||||
| ----- | ----------------------- | ---------------- |
|
| ----- | ----------------------- | ---------------- |
|
||||||
| web | 192.168.0.1:80 | 输入账号密码登录成功 |
|
| web | 192.168.0.1:80 | Login erfolgreich durch Eingabe von Konto und Passwort |
|
||||||
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 |
|
| admin | 192.168.0.1:8001 | Login erfolgreich durch Eingabe von Konto und Passwort |
|
||||||
| api | 192.168.0.1:8000/version| 返回版本信息 |
|
| api | 192.168.0.1:8000/version| Versionsinformationen zurückgeben |
|
||||||
注:如果api报错,请确认.env里的数据库IP,数据库账号,数据库密码是否正确,如果不正确,请修改.env后执行:
|
|
||||||
|
**注**:Wenn die API einen Fehler meldet, bestätigen Sie bitte, ob die Datenbank-IP, das Datenbankkonto und das Datenbankkennwort in .env sind korrekt. Wenn nicht, ändern Sie sie bitte und führen Sie:
|
||||||
```
|
```
|
||||||
docker-compose up --build -d
|
docker-compose up --build -d
|
||||||
```
|
```
|
||||||
|
|
|
@ -3,22 +3,20 @@ Create and start all the services with a single command
|
||||||
|
|
||||||
### Prerequisite
|
### Prerequisite
|
||||||
|
|
||||||
- Installed docker、docker-compose、npm on a host.
|
- Installed docker, docker-compose, npm on a host.
|
||||||
- Installed MySQL database with username 'root' and password '!MyEMS1'.
|
- Installed MySQL database with username 'root' and password '!MyEMS1'.
|
||||||
- The MySQL database can be connected from the host where Docker is installed.
|
- The MySQL database can be connected from the host where Docker is installed.
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
Note 1: 这里的主机指的是**安装Docker的主机**, 这里的IP和账号密码都为假定的,用来展示说明,实际情况中用户需要根据自己的配置改为自己的,具体的修改步骤会在“安装”中讲述。
|
**Note**: The host here refers to the host where docker is installed. The IP and account password here are assumed and used to show instructions. Please modify them as appropriate.
|
||||||
|
|
||||||
Note 2: 这里如果**安装数据库和安装Docker的主机为同一个主机,那么数据库IP和主机IP修改为一个实际IP**即可,这里是以数据库,和安装Docker的主机不在同一个上举例的。
|
| -- | -- |
|
||||||
|
| ---------- | ----------- |
|
||||||
| -- | -- |
|
| Host IP | 192.168.0.1 |
|
||||||
| ---------- | ----------- |
|
| Database IP | 192.168.0.2 |
|
||||||
| Host IP | 192.168.0.1 |
|
| Database User | root |
|
||||||
| Database IP | 192.168.0.2 |
|
| Database Password | !MyEMS1 |
|
||||||
| Database User | root |
|
|
||||||
| Database Password | !MyEMS1 |
|
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
|
@ -33,8 +31,10 @@ git clone https://gitee.com/myems/myems.git
|
||||||
cd myems/database/install
|
cd myems/database/install
|
||||||
mysql -u root -p < myems_billing_baseline_db.sql
|
mysql -u root -p < myems_billing_baseline_db.sql
|
||||||
mysql -u root -p < myems_billing_db.sql
|
mysql -u root -p < myems_billing_db.sql
|
||||||
|
mysql -u root -p < myems_carbon_db.sql
|
||||||
mysql -u root -p < myems_energy_baseline_db.sql
|
mysql -u root -p < myems_energy_baseline_db.sql
|
||||||
mysql -u root -p < myems_energy_db.sql
|
mysql -u root -p < myems_energy_db.sql
|
||||||
|
mysql -u root -p < myems_energy_model_db.sql
|
||||||
mysql -u root -p < myems_fdd_db.sql
|
mysql -u root -p < myems_fdd_db.sql
|
||||||
mysql -u root -p < myems_historical_db.sql
|
mysql -u root -p < myems_historical_db.sql
|
||||||
mysql -u root -p < myems_reporting_db.sql
|
mysql -u root -p < myems_reporting_db.sql
|
||||||
|
@ -46,7 +46,7 @@ Note: Refer to [database/README.md](./database/README.md)
|
||||||
|
|
||||||
3. Modify Config
|
3. Modify Config
|
||||||
|
|
||||||
注:如“配置”所述,这里假定的**主机IP为 192.168.0.1,数据库IP为 192.168.0.2,数据库账号为:root,数据库密码:!MyEMS1,用户应该修改为自己对应的主机IP,数据库IP,数据库账号,数据库密码**
|
**Note**:The host IP assumed here is 192.168.0.1, the database IP is 192.168.0.2, the database account is: root, and the database password is: !MyEMS1, please modify as appropriate
|
||||||
|
|
||||||
3.1 Modify api address in nginx.conf
|
3.1 Modify api address in nginx.conf
|
||||||
```
|
```
|
||||||
|
@ -58,10 +58,10 @@ sed -i 's/127.0.0.1:8000/192.168.0.1:8000/g' web/nginx.conf
|
||||||
3.2 Copy example.env to .env and modify database IP, username and password in .env
|
3.2 Copy example.env to .env and modify database IP, username and password in .env
|
||||||
```
|
```
|
||||||
cd myems
|
cd myems
|
||||||
cp myems-api/example.env myems-api/.env
|
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
|
|
||||||
cp myems-aggregation/example.env myems-aggregation/.env
|
cp myems-aggregation/example.env myems-aggregation/.env
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-aggregation/.env
|
||||||
|
cp myems-api/example.env myems-api/.env
|
||||||
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-api/.env
|
||||||
cp myems-cleaning/example.env myems-cleaning/.env
|
cp myems-cleaning/example.env myems-cleaning/.env
|
||||||
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
|
sed -i 's/127.0.0.1/192.168.0.2/g' myems-cleaning/.env
|
||||||
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
|
cp myems-modbus-tcp/example.env myems-modbus-tcp/.env
|
||||||
|
@ -75,12 +75,6 @@ If Windows host, use c:\upload for volumes/source in api and admin services.
|
||||||
If Linux host, use /upload for volumes/source in api and admin services.
|
If Linux host, use /upload for volumes/source in api and admin services.
|
||||||
Make sure the upload folders in api and admin are same folder on host.
|
Make sure the upload folders in api and admin are same folder on host.
|
||||||
|
|
||||||
3.4 Validate database connection
|
|
||||||
```
|
|
||||||
cd myems
|
|
||||||
python3 myems-api/test_mysql.py
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Build Web UI
|
4. Build Web UI
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -98,12 +92,13 @@ docker-compose up -d
|
||||||
|
|
||||||
6. Verification
|
6. Verification
|
||||||
|
|
||||||
| | Address | Result |
|
| | Address | Expected Result |
|
||||||
| ----- | ----------------------- | ---------------- |
|
| ----- | ----------------------- | ---------------- |
|
||||||
| web | 192.168.0.1:80 | 输入账号密码登录成功 |
|
| web | 192.168.0.1:80 | Login succeeded by entering account and password |
|
||||||
| admin | 192.168.0.1:8001 | 输入账号密码登录成功 |
|
| admin | 192.168.0.1:8001 | Login succeeded by entering account and password |
|
||||||
| api | 192.168.0.1:8000/version| 返回版本信息 |
|
| api | 192.168.0.1:8000/version| Return version information |
|
||||||
注:如果api报错,请确认.env里的数据库IP,数据库账号,数据库密码是否正确,如果不正确,请修改.env后执行:
|
|
||||||
|
**Note**:If the API reports an error, please confirm Whether the database IP, database account and database password in .env are correct. If not, please modify them then execute:
|
||||||
```
|
```
|
||||||
docker-compose up --build -d
|
docker-compose up --build -d
|
||||||
```
|
```
|
||||||
|
|
|
@ -9655,6 +9655,74 @@
|
||||||
},
|
},
|
||||||
"response": []
|
"response": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "PUT Update All New Web Messages (Mark All As Read)",
|
||||||
|
"request": {
|
||||||
|
"method": "PUT",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "User-UUID",
|
||||||
|
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||||
|
"type": "text",
|
||||||
|
"description": "Any admin users' UUID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Token",
|
||||||
|
"value": "597881540b33791a032b95aa48e0de098dc95ec0b813edd8a92cee87ee5eed1b8db7856a047ed06324c333bf2c98f0c7613e346ae25d1bcae3994f30b4562dfb",
|
||||||
|
"type": "text",
|
||||||
|
"description": "Login to get a valid token"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\"data\":{\"status\":\"read\"}}"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"raw": "{{base_url}}/webmessagesnew",
|
||||||
|
"host": [
|
||||||
|
"{{base_url}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"webmessagesnew"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "PUT Update All New Web Messages (Acknowledge All)",
|
||||||
|
"request": {
|
||||||
|
"method": "PUT",
|
||||||
|
"header": [
|
||||||
|
{
|
||||||
|
"key": "User-UUID",
|
||||||
|
"value": "dcdb67d1-6116-4987-916f-6fc6cf2bc0e4",
|
||||||
|
"type": "text",
|
||||||
|
"description": "Any admin users' UUID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "Token",
|
||||||
|
"value": "597881540b33791a032b95aa48e0de098dc95ec0b813edd8a92cee87ee5eed1b8db7856a047ed06324c333bf2c98f0c7613e346ae25d1bcae3994f30b4562dfb",
|
||||||
|
"type": "text",
|
||||||
|
"description": "Login to get a valid token"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"body": {
|
||||||
|
"mode": "raw",
|
||||||
|
"raw": "{\"data\":{\"status\":\"acknowledged\", \"reply\":\"OK\"}}"
|
||||||
|
},
|
||||||
|
"url": {
|
||||||
|
"raw": "{{base_url}}/webmessagesnew",
|
||||||
|
"host": [
|
||||||
|
"{{base_url}}"
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"webmessagesnew"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"response": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "GET a Web Message by ID",
|
"name": "GET a Web Message by ID",
|
||||||
"request": {
|
"request": {
|
||||||
|
|
|
@ -245,6 +245,118 @@ class WebMessageStatusNewCollection:
|
||||||
|
|
||||||
resp.text = json.dumps(result)
|
resp.text = json.dumps(result)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
@user_logger
|
||||||
|
def on_put(req, resp):
|
||||||
|
"""Handles PUT requests"""
|
||||||
|
try:
|
||||||
|
raw_json = req.stream.read().decode('utf-8')
|
||||||
|
except Exception as ex:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.EXCEPTION', description=ex)
|
||||||
|
|
||||||
|
new_values = json.loads(raw_json)
|
||||||
|
|
||||||
|
if 'status' not in new_values['data'].keys() or \
|
||||||
|
not isinstance(new_values['data']['status'], str) or \
|
||||||
|
len(str.strip(new_values['data']['status'])) == 0 or \
|
||||||
|
str.strip(new_values['data']['status']) not in ('new', 'acknowledged', 'read'):
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description='API.INVALID_STATUS')
|
||||||
|
status = str.strip(new_values['data']['status'])
|
||||||
|
|
||||||
|
# reply is required for 'acknowledged' status
|
||||||
|
if status == 'acknowledged':
|
||||||
|
if 'reply' not in new_values['data'].keys() or \
|
||||||
|
not isinstance(new_values['data']['reply'], str) or \
|
||||||
|
len(str.strip(new_values['data']['reply'])) == 0:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_REPLY')
|
||||||
|
else:
|
||||||
|
reply = str.strip(new_values['data']['reply'])
|
||||||
|
else:
|
||||||
|
reply = None
|
||||||
|
|
||||||
|
# Verify User Session
|
||||||
|
token = req.headers.get('TOKEN')
|
||||||
|
user_uuid = req.headers.get('USER-UUID')
|
||||||
|
if token is None:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description='API.TOKEN_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||||
|
if user_uuid is None:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description='API.USER_UUID_NOT_FOUND_IN_HEADERS_PLEASE_LOGIN')
|
||||||
|
|
||||||
|
cnx = mysql.connector.connect(**config.myems_user_db)
|
||||||
|
cursor = cnx.cursor(dictionary=True)
|
||||||
|
|
||||||
|
query = (" SELECT utc_expires "
|
||||||
|
" FROM tbl_sessions "
|
||||||
|
" WHERE user_uuid = %s AND token = %s")
|
||||||
|
cursor.execute(query, (user_uuid, token,))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
|
||||||
|
if row is None:
|
||||||
|
if cursor:
|
||||||
|
cursor.close()
|
||||||
|
if cnx:
|
||||||
|
cnx.disconnect()
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description='API.INVALID_SESSION_PLEASE_RE_LOGIN')
|
||||||
|
else:
|
||||||
|
utc_expires = row['utc_expires']
|
||||||
|
if datetime.utcnow() > utc_expires:
|
||||||
|
if cursor:
|
||||||
|
cursor.close()
|
||||||
|
if cnx:
|
||||||
|
cnx.disconnect()
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description='API.USER_SESSION_TIMEOUT')
|
||||||
|
|
||||||
|
cursor.execute(" SELECT id "
|
||||||
|
" FROM tbl_users "
|
||||||
|
" WHERE uuid = %s ",
|
||||||
|
(user_uuid,))
|
||||||
|
row = cursor.fetchone()
|
||||||
|
if row is None:
|
||||||
|
if cursor:
|
||||||
|
cursor.close()
|
||||||
|
if cnx:
|
||||||
|
cnx.disconnect()
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description='API.INVALID_USER_PLEASE_RE_LOGIN')
|
||||||
|
else:
|
||||||
|
user_id = row['id']
|
||||||
|
|
||||||
|
if cursor:
|
||||||
|
cursor.close()
|
||||||
|
if cnx:
|
||||||
|
cnx.disconnect()
|
||||||
|
|
||||||
|
cnx = mysql.connector.connect(**config.myems_fdd_db)
|
||||||
|
cursor = cnx.cursor()
|
||||||
|
|
||||||
|
cursor.execute(" SELECT user_id "
|
||||||
|
" FROM tbl_web_messages "
|
||||||
|
" WHERE status = %s AND user_id = %s ", ('new', user_id))
|
||||||
|
if cursor.fetchall() is None:
|
||||||
|
cursor.close()
|
||||||
|
cnx.disconnect()
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_404, title='API.NOT_FOUND',
|
||||||
|
description='API.WEB_MESSAGE_NOT_FOUND')
|
||||||
|
|
||||||
|
update_row = (" UPDATE tbl_web_messages "
|
||||||
|
" SET status = %s, reply = %s "
|
||||||
|
" WHERE status = %s AND user_id = %s ")
|
||||||
|
cursor.execute(update_row, (status,
|
||||||
|
reply,
|
||||||
|
'new',
|
||||||
|
user_id,))
|
||||||
|
cnx.commit()
|
||||||
|
|
||||||
|
cursor.close()
|
||||||
|
cnx.disconnect()
|
||||||
|
|
||||||
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
|
|
||||||
class WebMessageItem:
|
class WebMessageItem:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -373,13 +485,13 @@ class WebMessageItem:
|
||||||
status = str.strip(new_values['data']['status'])
|
status = str.strip(new_values['data']['status'])
|
||||||
|
|
||||||
# reply is required for 'acknowledged' status
|
# reply is required for 'acknowledged' status
|
||||||
if status == 'acknowledged' and \
|
if status == 'acknowledged':
|
||||||
('reply' not in new_values['data'].keys() or
|
if 'reply' not in new_values['data'].keys() or \
|
||||||
not isinstance(new_values['data']['reply'], str) or
|
not isinstance(new_values['data']['reply'], str) or \
|
||||||
len(str.strip(new_values['data']['reply'])) == 0):
|
len(str.strip(new_values['data']['reply'])) == 0:
|
||||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST', description='API.INVALID_REPLY')
|
||||||
description='API.INVALID_REPLY')
|
else:
|
||||||
reply = str.strip(new_values['data']['reply'])
|
reply = str.strip(new_values['data']['reply'])
|
||||||
else:
|
else:
|
||||||
reply = None
|
reply = None
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,49 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
}).then(json => {
|
}).then(json => {
|
||||||
console.log(isResponseOK);
|
console.log(isResponseOK);
|
||||||
if (isResponseOK) {
|
if (isResponseOK) {
|
||||||
|
let isResponseOK = false;
|
||||||
|
fetch(APIBaseURL + '/webmessages?' +
|
||||||
|
'startdatetime=' + startDatetime.format('YYYY-MM-DDTHH:mm:ss') +
|
||||||
|
'&enddatetime=' + endDatetime.format('YYYY-MM-DDTHH:mm:ss'), {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json",
|
||||||
|
"User-UUID": getCookieValue('user_uuid'),
|
||||||
|
"Token": getCookieValue('token')
|
||||||
|
},
|
||||||
|
body: null,
|
||||||
|
|
||||||
|
}).then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
isResponseOK = true;
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
}).then(json => {
|
||||||
|
if (isResponseOK) {
|
||||||
|
console.log(json);
|
||||||
|
setFetchSuccess(true);
|
||||||
|
|
||||||
|
let notificationList = []
|
||||||
|
|
||||||
|
if (json.length > 0) {
|
||||||
|
json.forEach((currentValue, index) => {
|
||||||
|
let notification = {}
|
||||||
|
notification['id'] = json[index]['id'];
|
||||||
|
notification['subject'] = json[index]['subject'];
|
||||||
|
notification['created_datetime'] = moment(parseInt(json[index]['created_datetime']))
|
||||||
|
.format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
notification['message'] = json[index]['message'];
|
||||||
|
notification['status'] = json[index]['status'];
|
||||||
|
notification['url'] = json[index]['url'];
|
||||||
|
|
||||||
|
notificationList.push(notification);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setNotifications(notificationList);
|
||||||
|
setSpinnerHidden(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error(json.description)
|
toast.error(json.description)
|
||||||
}
|
}
|
||||||
|
@ -308,7 +350,49 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
}).then(json => {
|
}).then(json => {
|
||||||
console.log(isResponseOK);
|
console.log(isResponseOK);
|
||||||
if (isResponseOK) {
|
if (isResponseOK) {
|
||||||
|
let isResponseOK = false;
|
||||||
|
fetch(APIBaseURL + '/webmessages?' +
|
||||||
|
'startdatetime=' + startDatetime.format('YYYY-MM-DDTHH:mm:ss') +
|
||||||
|
'&enddatetime=' + endDatetime.format('YYYY-MM-DDTHH:mm:ss'), {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json",
|
||||||
|
"User-UUID": getCookieValue('user_uuid'),
|
||||||
|
"Token": getCookieValue('token')
|
||||||
|
},
|
||||||
|
body: null,
|
||||||
|
|
||||||
|
}).then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
isResponseOK = true;
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
}).then(json => {
|
||||||
|
if (isResponseOK) {
|
||||||
|
console.log(json);
|
||||||
|
setFetchSuccess(true);
|
||||||
|
|
||||||
|
let notificationList = []
|
||||||
|
|
||||||
|
if (json.length > 0) {
|
||||||
|
json.forEach((currentValue, index) => {
|
||||||
|
let notification = {}
|
||||||
|
notification['id'] = json[index]['id'];
|
||||||
|
notification['subject'] = json[index]['subject'];
|
||||||
|
notification['created_datetime'] = moment(parseInt(json[index]['created_datetime']))
|
||||||
|
.format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
notification['message'] = json[index]['message'];
|
||||||
|
notification['status'] = json[index]['status'];
|
||||||
|
notification['url'] = json[index]['url'];
|
||||||
|
|
||||||
|
notificationList.push(notification);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setNotifications(notificationList);
|
||||||
|
setSpinnerHidden(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error(json.description)
|
toast.error(json.description)
|
||||||
}
|
}
|
||||||
|
@ -338,7 +422,49 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
}).then(json => {
|
}).then(json => {
|
||||||
console.log(isResponseOK);
|
console.log(isResponseOK);
|
||||||
if (isResponseOK) {
|
if (isResponseOK) {
|
||||||
|
let isResponseOK = false;
|
||||||
|
fetch(APIBaseURL + '/webmessages?' +
|
||||||
|
'startdatetime=' + startDatetime.format('YYYY-MM-DDTHH:mm:ss') +
|
||||||
|
'&enddatetime=' + endDatetime.format('YYYY-MM-DDTHH:mm:ss'), {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json",
|
||||||
|
"User-UUID": getCookieValue('user_uuid'),
|
||||||
|
"Token": getCookieValue('token')
|
||||||
|
},
|
||||||
|
body: null,
|
||||||
|
|
||||||
|
}).then(response => {
|
||||||
|
if (response.ok) {
|
||||||
|
isResponseOK = true;
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
}).then(json => {
|
||||||
|
if (isResponseOK) {
|
||||||
|
console.log(json);
|
||||||
|
setFetchSuccess(true);
|
||||||
|
|
||||||
|
let notificationList = []
|
||||||
|
|
||||||
|
if (json.length > 0) {
|
||||||
|
json.forEach((currentValue, index) => {
|
||||||
|
let notification = {}
|
||||||
|
notification['id'] = json[index]['id'];
|
||||||
|
notification['subject'] = json[index]['subject'];
|
||||||
|
notification['created_datetime'] = moment(parseInt(json[index]['created_datetime']))
|
||||||
|
.format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
notification['message'] = json[index]['message'];
|
||||||
|
notification['status'] = json[index]['status'];
|
||||||
|
notification['url'] = json[index]['url'];
|
||||||
|
|
||||||
|
notificationList.push(notification);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setNotifications(notificationList);
|
||||||
|
setSpinnerHidden(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error(json.description)
|
toast.error(json.description)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ const NotificationDropdown = ({ t }) => {
|
||||||
}).then(json => {
|
}).then(json => {
|
||||||
console.log(json)
|
console.log(json)
|
||||||
if (isResponseOK) {
|
if (isResponseOK) {
|
||||||
let NewnotificationList = []
|
let NewNotificationList = []
|
||||||
if (json.length > 0) {
|
if (json.length > 0) {
|
||||||
json.forEach((currentValue, index) => {
|
json.forEach((currentValue, index) => {
|
||||||
let notification = {}
|
let notification = {}
|
||||||
|
@ -52,19 +52,21 @@ const NotificationDropdown = ({ t }) => {
|
||||||
notification['message'] = json[index]['message'];
|
notification['message'] = json[index]['message'];
|
||||||
notification['created_datetime'] = moment(parseInt(json[index]['created_datetime']))
|
notification['created_datetime'] = moment(parseInt(json[index]['created_datetime']))
|
||||||
.format("YYYY-MM-DD HH:mm:ss");
|
.format("YYYY-MM-DD HH:mm:ss");
|
||||||
if (NewnotificationList.length > 3 ){
|
if (NewNotificationList.length > 3 ){
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (notification['message'].length > 40){
|
if (notification['message'].length > 40){
|
||||||
notification['message'] = notification['message'].substring(0,30) + "...";
|
notification['message'] = notification['message'].substring(0,30) + "...";
|
||||||
}
|
}
|
||||||
if (notification["status"] === "new"){
|
if (notification["status"] === "new"){
|
||||||
NewnotificationList.push(notification);
|
NewNotificationList.push(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}else {
|
||||||
setRawNewNotificationschild(NewnotificationList);
|
setIsAllRead(true);
|
||||||
|
}
|
||||||
|
setRawNewNotificationschild(NewNotificationList);
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -83,10 +85,9 @@ const NotificationDropdown = ({ t }) => {
|
||||||
|
|
||||||
const markAsRead = e => {
|
const markAsRead = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
rawNewNotificationschild.map((notification,index) => {
|
|
||||||
console.log('Mark As Read: ', notification["id"])
|
let isResponseOK = false;
|
||||||
let isResponseOK = false;
|
fetch(APIBaseURL + '/webmessagesnew', {
|
||||||
fetch(APIBaseURL + '/webmessages/' + notification["id"], {
|
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
"Content-type": "application/json",
|
"Content-type": "application/json",
|
||||||
|
@ -108,14 +109,60 @@ const NotificationDropdown = ({ t }) => {
|
||||||
}).then(json => {
|
}).then(json => {
|
||||||
console.log(isResponseOK);
|
console.log(isResponseOK);
|
||||||
if (isResponseOK) {
|
if (isResponseOK) {
|
||||||
|
let isResponseOK = false;
|
||||||
|
fetch(APIBaseURL + '/webmessagesnew', {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json",
|
||||||
|
"User-UUID": getCookieValue('user_uuid'),
|
||||||
|
"Token": getCookieValue('token')
|
||||||
|
},
|
||||||
|
body: null,
|
||||||
|
|
||||||
|
}).then(response => {
|
||||||
|
console.log(response);
|
||||||
|
if (response.ok) {
|
||||||
|
isResponseOK = true;
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
}).then(json => {
|
||||||
|
console.log(json)
|
||||||
|
if (isResponseOK) {
|
||||||
|
let NewNotificationList = []
|
||||||
|
if (json.length > 0) {
|
||||||
|
json.forEach((currentValue, index) => {
|
||||||
|
let notification = {}
|
||||||
|
notification['id'] = json[index]['id'];
|
||||||
|
notification['status'] = json[index]['status'];
|
||||||
|
notification['subject'] = json[index]['subject']
|
||||||
|
notification['message'] = json[index]['message'];
|
||||||
|
notification['created_datetime'] = moment(parseInt(json[index]['created_datetime']))
|
||||||
|
.format("YYYY-MM-DD HH:mm:ss");
|
||||||
|
if (NewNotificationList.length > 3 ){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (notification['message'].length > 40){
|
||||||
|
notification['message'] = notification['message'].substring(0,30) + "...";
|
||||||
|
}
|
||||||
|
if (notification["status"] === "new"){
|
||||||
|
NewNotificationList.push(notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
setIsAllRead(true);
|
||||||
|
}
|
||||||
|
setRawNewNotificationschild(NewNotificationList);
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error(json.description)
|
toast.error(json.description)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue