Skip to content

Commit

Permalink
refactor(dashboard): ignore dashboard/proto/gen and gen them during…
Browse files Browse the repository at this point in the history
… `npm i` (#8695)

Signed-off-by: TennyZhuang <[email protected]>
  • Loading branch information
TennyZhuang authored Mar 22, 2023
1 parent 3a06226 commit 6313c42
Show file tree
Hide file tree
Showing 27 changed files with 41 additions and 26,001 deletions.
2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
src/tests/regress/data/** linguist-vendored
# source test data
scripts/source/test_data/** linguist-vendored
# generated proto for dashboard
dashboard/proto/gen/** linguist-generated
# generated grafana dashboard
grafana/risingwave-dashboard.json linguist-generated
3 changes: 3 additions & 0 deletions dashboard/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# generated proto
proto/gen
38 changes: 31 additions & 7 deletions dashboard/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Dashboard

The framework: [Next.js](https://nextjs.org).

Next.js supports SPA, SSG and SSR. With this feature, the dashboard ui can be deployed in

1. Standalone machine serving only dashboard UI with a backend. (e.g. Dashboard for cloud product)
2. Meta service node. (e.g. Static HTML files integrated in meta service without any other dependencies like node.js)

## Files
```

```plain
dashboard/
--.next/ (generated by nextjs)
--node_modules/ (development dependencies)
Expand All @@ -19,47 +23,67 @@ dashboard/
```

## Testing

TODO: Find a suitable testing framework

## Development

Start the RisingWave database, remove drop tables from `tpch_snapshot.slt`

```bash
./risedev d
sqllogictest -p 4566 -d dev './e2e_test/streaming/tpch_snapshot.slt'
```

Install Dependencies.

```bash
npm i
```

The website will be served at port 3000.

```bash
npm run dev
```

You should also run:
```

```bash
node mock-server.js
```

To start a mock API server when developing. You can use `fetch.sh` to update the mock APIs.

## Test with RisingWave meta node
To replace the built static files in RisingWave with your newest code,

To replace the built static files in RisingWave with your newest code,
run the following scripts in the root directory.
```

```bash
./risedev export-dashboard-v2
```


## Deployment
#### Static HTML files

### Generate the protos

Running `npm i` will generate the proto files under `proto/gen` automatically. In case there are modifications to the protos, you can regenerate them using the command npm run gen-proto.

### Static HTML files

Build static files for standalone deployment without node.js. The built files are generated at `./out`.
Check more details at [Static HTML Export](https://nextjs.org/docs/advanced-features/static-html-export).

```bash
npm run build-static
```

#### Next.js app

The built files are generated at `./.next`.

```bash
npm run build
npm run start
```
```
1 change: 1 addition & 0 deletions dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"gen-proto": "./scripts/generate_proto.sh",
"lint": "prettier --check . && next lint",
"format": "prettier --write . && next lint --fix",
"mock-server": "node ./mock-server.js"
"mock-server": "node ./mock-server.js",
"postinstall": "npm run gen-proto"
},
"dependencies": {
"@chakra-ui/react": "^2.3.1",
Expand Down
Loading

0 comments on commit 6313c42

Please sign in to comment.