Skip to content

Commit

Permalink
Update notification.md Page (project-chip#1105)
Browse files Browse the repository at this point in the history
update docs (notification.md and ZAP_on_Windows.md)
  • Loading branch information
ethanzhouyc authored Aug 11, 2023
1 parent 80e2147 commit ba32890
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 31 deletions.
40 changes: 19 additions & 21 deletions docs/ZAP-on-Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

## Windows-specific Prerequisite Settings

**1. Windows Powershell:**
### 1. Windows Powershell:

In desktop search bar, input "Windows Powershell" and run as administrator. Run all the following commands inside Powershell.
In desktop search bar, input `Windows Powershell` and run as administrator. Run all the following commands inside Powershell.

**2. Chocolatey:**
### 2. Chocolatey:

Install from https://chocolatey.org/install

Expand All @@ -19,61 +19,59 @@ Install pkgconfiglite package:
choco install pkgconfiglite
```

**3. Install Node if you have not:**
### 3. Install Node if you have not:
```
choco install nodejs-lts
```
*the version has to be 18 to pass version check test, after install, check with "node -v"
*the version has to be 18 to pass version check test, after install, check with `node -v`

*if you install Node already, and fail some tests similar to "cannot find Node", reinstall Node with chocolatey again
*if you install Node already, and fail some tests similar to `cannot find Node`, reinstall Node with chocolatey again

**4. Follow the instruction page for other installation details**
### 4. Follow the instruction page for other installation details

https://github.com/project-chip/zap/blob/master/docs/development-instructions.md

## Fix Possible Error

**1. sqlite3**
### 1. sqlite3

When running ZAP (eg. 'npm run zap'), if you see an error about "sqlite3.node" in a pop up window, run:
When running ZAP (eg. `npm run zap`), if you see an error about `sqlite3.node` in a pop up window, run:
```
npm rebuild sqlite3
```

**2. electron-builder:**
### 2. electron-builder:

When doing npm install, in post-install, if there is an error on the following command, related to "electron-builder install-app-deps", "node_modules/canvas" or "node-pre-gyp", it is because the electron-builder is not completely compatible with Windows and the installation error will not cause a failure in running ZAP
When doing npm install, in post-install, if there is an error on the following command, related to `electron-builder install-app-deps`, `npx electron-rebuild canvas failed` or `node-pre-gyp`, it is because the current `canvas` version is not compatible with Windows, and the installation error will not cause a failure in running ZAP. node-canvas is working on the solution now and the issue will be solved in near future.
```
"postinstall": "electron-builder install-app-deps && husky install && npm rebuild canvas --update-binary && npm run version-stamp"
```

## Fix Failed Tests

**1. Exceed Timeout**
### 1. Exceed Timeout

If 'npm run test' fails due to "Exceeded timeout of 1500 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test.", set the following environment variables to increase timeouts for all tests.
If 'npm run test' fails due to `Exceeded timeout of 1500 ms for a test. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test.`, set the following environment variables to increase timeouts for all tests.
```
$env:ZAP_TEST_TIMEOUT = 50000000; $env:ZAP_TEST_TIMEOUT_SHORT = 50000000; $env:ZAP_TEST_TIMEOUT_MEDIUM = 50000000; $env:ZAP_TEST_TIMEOUT_LONG = 50000000
```

**2. Test Suite failed to run (Canvas not found)**
### 2. Test Suite failed to run (Canvas not found)

If 'npm run test' fails due to "Test suite failed to run. Cannot find module '../build/Release/canvas.node'" or "\zap\node_modules\canvas\build\Release\canvas.node is not a valid Win32 application.", rebuild canvas:
If 'npm run test' fails due to `Test suite failed to run. Cannot find module '../build/Release/canvas.node'` or `\zap\node_modules\canvas\build\Release\canvas.node is not a valid Win32 application.`, rebuild canvas:
```
npm rebuild canvas --update-binary
```

**3. get index.html or other server issue**
### 3. get index.html or other server issue

If 'npm run test" fails due to get index.html request failed with status code 404 in unit tests or having server connection issues in e2e-ci tests, run:
If `npm run test` fails due to `get index.html request failed with status code 404` in unit tests or having server connection issues in e2e-ci tests, run:
```
npm run build
```

**4. Other**
### 4. Other

Check if node version is v18, and try to install it with Chocolatey

Also, you can check the faq doc for other known issues: https://github.com/project-chip/zap/blob/master/docs/faq.md


Also, you can check the faq doc for other known issues: https://github.com/project-chip/zap/blob/master/docs/faq.md
Binary file added docs/config-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/display_notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 71 additions & 10 deletions docs/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,100 @@ The purpose of this document is to provide ZAP developers with simple instructio

## Adding a Notification:

In order to add a notification, call the setNotification function in zap/src-electron/query-session-notification.js. setNotification takes the following arguments:
### Adding a Session Notification

Session notifications are set after a session is created. To add a session notification, call the setNotification function in zap/src-electron/query-session-notification.js.
setNotification takes the following arguments:

- db => database object (object)
- type => the type of notification you wish to define (string)
- options
- UPGRADE
- WARNING
- ERROR
- WARNING
- UPGRADE
- status => the message of the notification (string)
- sessionId => the session Id (string)
- sessionId => the session Id (integer)
- severity => representation of importance (integer)
- options
- 1 => high
- 2 => medium (default)
- 1 => high (ERROR type)
- 2 => medium (default, WARNING type)
- 3 => low
- display => method to notify the user (integer)
- options
- 1 => display a pop-up message
- 0 => do not show a pop-up message

For example,

```
async function iscDataLoader(db, state, sessionId) {
let endpointTypes = state.endpointTypes
let promises = []
await notification.setNotification(
await querySessionNotification.setNotification(
db,
'UPGRADE',
'ISC FILE UPGRADED TO ZAP FILE. PLEASE SAVE AS TO SAVE OFF NEWLY CREATED ZAP FILE.',
sessionId,
1
1,
0,
)
}
```

- For testing you can navigate to **zap/src/NotificationPage.vue** which queries the SESSION_NOTICE table and returns all notifications with the same SESSION_REF.
- When calling the setNotification function, ensure a valid session Id is accessible within the current scope

- For testing you can navigate to **zap/src/pages/NotificationPage.vue**, which queries the SESSION_NOTICE table and returns all notifications with the same SESSION_REF.

For example, the picture below is the result of importing an isc file.
For example, the picture below is the result of importing an isc file in the notification page.

![display notification](display_notification.png)

### Adding a Package Notification

Package notifications are set when processing and loading a specific package. To add a package notification, call the setNotification function in zap/src-electron/query-package-notification.js.
setNotification takes the following arguments:

- db => database object (object)
- type => the type of notification you wish to define (string)
- options
- ERROR
- WARNING
- UPGRADE
- status => the message of the notification (string)
- packageId => the package Id (integer)
- severity => representation of importance (integer)
- options
- 1 => high (ERROR type)
- 2 => medium (default, WARNING type)
- 3 => low

For example,

```
function prepareEnumOrBitmap(db, packageId, a, dataType, typeMap) {
let message = 'Check type contradiction in XML metadata for ' +
a.$.name + ' with type ' + a.$.type
env.logWarning(message)
queryPackageNotification.setNotification(
db,
"WARNING",
message,
packageId,
2
)
}
```

- When calling the setNotification function, ensure a valid package Id is accessible within the current scope

- For testing you can navigate to **zap/src/pages/ZapConfig.vue** which queries the PACKAGE_NOTICE table and returns all notifications from packages referenced by the current session.

For example, in the pictures below, clicking the warning icon will lead you to a dialog showing all notifications for that package.

![package notification config page](config-page.png)

![warning dialog](warning-dialog.png)

**zap/src/pages/NotificationPage.vue** will display all notifications from packages chosen or imported by the user, like shown in the picture below

![package notis notification page](package-notification.png)
Binary file added docs/package-notification.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/warning-dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ba32890

Please sign in to comment.