Skip to content

Commit 46009c8

Browse files
authored
feat: perses dashboard (#609)
* feat: perses dashboard * style: sidebar * feat: create * chore: name,style color * style: height * fix: scroll * fix: form model * chore: remote strict * feat: url sync * build: fix build
1 parent 4cebecb commit 46009c8

25 files changed

Lines changed: 5584 additions & 32 deletions

config/vite.config.base.ts

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,42 @@ import { resolve } from 'path'
22
import { defineConfig } from 'vite'
33
import vue from '@vitejs/plugin-vue'
44
import vueJsx from '@vitejs/plugin-vue-jsx'
5+
import react from '@vitejs/plugin-react'
56
import svgLoader from 'vite-svg-loader'
67
import Components from 'unplugin-vue-components/vite'
78
import AutoImport from 'unplugin-auto-import/vite'
9+
import { createHtmlPlugin } from 'vite-plugin-html'
10+
import { transformSync } from 'esbuild'
11+
12+
const tsxTransformer = () => ({
13+
name: 'tsx-transformer',
14+
enforce: 'pre' as const,
15+
transform(code: string, id: string) {
16+
if (id.includes('.tsx') && !id.includes('node_modules')) {
17+
const result = transformSync(code, {
18+
loader: 'tsx',
19+
jsx: 'automatic',
20+
target: 'esnext',
21+
format: 'esm',
22+
sourcemap: false,
23+
})
24+
let sourceMap: string | null = null
25+
if (result.map && typeof result.map === 'string' && result.map.trim().length > 0) {
26+
try {
27+
JSON.parse(result.map)
28+
sourceMap = result.map
29+
} catch {
30+
sourceMap = null
31+
}
32+
}
33+
return {
34+
code: result.code,
35+
map: sourceMap,
36+
}
37+
}
38+
return null
39+
},
40+
})
841

942
const useDevMode = true
1043
export default defineConfig({
@@ -43,8 +76,27 @@ export default defineConfig({
4376
},
4477
},
4578
plugins: [
79+
tsxTransformer(),
4680
vue(),
4781
vueJsx(),
82+
react({
83+
include: [/\.tsx$/],
84+
}),
85+
createHtmlPlugin({
86+
minify: true,
87+
pages: [
88+
{
89+
entry: '/src/main.ts',
90+
filename: 'index.html',
91+
template: 'index.html',
92+
},
93+
{
94+
entry: '/src/dashboard-main.tsx',
95+
filename: 'dashboard.html',
96+
template: 'dashboard.html',
97+
},
98+
],
99+
}),
48100
svgLoader({ svgoConfig: {} }),
49101
AutoImport({
50102
dts: true,
@@ -53,11 +105,13 @@ export default defineConfig({
53105
},
54106
imports: ['vue', 'pinia', 'vue-router'],
55107
dirs: ['src/store', 'src/hooks'],
108+
exclude: [/src\/perses-dashboard\/react\//, /src\/dashboard-main\.tsx/],
56109
}),
57110
Components({
58111
dts: true,
59112
dirs: ['src/components', 'src/views'],
60113
extensions: ['vue', 'arco-design'],
114+
exclude: [/src\/perses-dashboard\/react\//, /src\/dashboard-main\.tsx/],
61115
}),
62116
],
63117
resolve: {
@@ -74,16 +128,39 @@ export default defineConfig({
74128
find: 'vue-i18n',
75129
replacement: 'vue-i18n/dist/vue-i18n.cjs.js', // Resolve the i18n warning issue
76130
},
131+
{
132+
find: 'hoist-non-react-statics',
133+
replacement: resolve(__dirname, '../src/perses-dashboard/vendor/hoist-non-react-statics'),
134+
},
135+
{
136+
find: 'react-is',
137+
replacement: resolve(__dirname, '../src/perses-dashboard/vendor/react-is'),
138+
},
77139
{
78140
find: 'vue',
79141
replacement: 'vue/dist/vue.esm-bundler.js', // compile template
80142
},
81143
],
82-
extensions: ['.ts', '.js'],
144+
extensions: ['.ts', '.js', '.tsx', '.jsx'],
83145
},
84146
define: {
85147
'process.env': {},
86148
},
149+
optimizeDeps: {
150+
include: [
151+
'react',
152+
'react-dom',
153+
'react-router-dom',
154+
'@mui/material',
155+
'@emotion/react',
156+
'@emotion/styled',
157+
'@perses-dev/components',
158+
'@perses-dev/core',
159+
],
160+
esbuildOptions: {
161+
target: 'esnext',
162+
},
163+
},
87164
css: {
88165
preprocessorOptions: {
89166
less: {

config/vite.config.prod.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ export default mergeConfig(
3737
},
3838
imports: ['vue', 'pinia', 'vue-router'],
3939
dirs: ['src/store', 'src/hooks'],
40+
exclude: [/src\/perses-dashboard\/react\//, /src\/dashboard-main\.tsx/],
4041
}),
4142
Components({
4243
dts: true,
4344
dirs: ['src/components', 'src/views'],
4445
extensions: ['vue', 'arco-design'],
46+
exclude: [/src\/perses-dashboard\/react\//, /src\/dashboard-main\.tsx/],
4547
}),
4648
],
4749
},

dashboard.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" href="/src/assets/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Dashboard | Greptime</title>
8+
</head>
9+
<body>
10+
<div id="react-root"></div>
11+
<script type="module" src="/src/dashboard-main.tsx"></script>
12+
</body>
13+
</html>

package.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,29 @@
4747
"@codemirror/state": "6.4.1",
4848
"@codemirror/theme-one-dark": "6.1.2",
4949
"@codemirror/view": "6.18.0",
50+
"@emotion/react": "^11.9.3",
51+
"@emotion/styled": "^11.14.0",
52+
"@hookform/resolvers": "^4.1.0",
5053
"@lezer/common": "^1.0.2",
5154
"@lezer/highlight": "^1.1.2",
5255
"@lezer/lr": "^1.2.3",
56+
"@mui/material": "^6.1.10",
57+
"@perses-dev/clickhouse-plugin": "0.5.0-beta.0",
58+
"@perses-dev/components": "0.53.0-beta.4",
59+
"@perses-dev/core": "0.53.0-beta.4",
60+
"@perses-dev/dashboards": "0.53.0-beta.4",
61+
"@perses-dev/gauge-chart-plugin": "0.12.0-beta.0",
62+
"@perses-dev/plugin-system": "0.53.0-beta.4",
63+
"@perses-dev/prometheus-plugin": "0.57.0-beta.0",
64+
"@perses-dev/stat-chart-plugin": "0.12.0-beta.0",
65+
"@perses-dev/table-plugin": "0.11.0-beta.0",
66+
"@perses-dev/timeseries-chart-plugin": "0.12.0-beta.0",
5367
"@prometheus-io/codemirror-promql": "0.305.0",
5468
"@tauri-apps/api": "^2.*",
5569
"@tauri-apps/plugin-dialog": "^2.2.0",
5670
"@tauri-apps/plugin-process": "^2.2.0",
5771
"@tauri-apps/plugin-updater": "~2.5.0",
72+
"@tanstack/react-query": "^5.66.7",
5873
"@types/d3": "^7.4.3",
5974
"@types/d3-flextree": "^2.1.4",
6075
"@types/json-bigint": "^1.0.1",
@@ -84,13 +99,18 @@
8499
"pinia": "^2.1.6",
85100
"qs": "^6.11.0",
86101
"query-string": "^8.1.0",
102+
"react": "^18.3.1",
103+
"react-dom": "^18.3.1",
104+
"react-router-dom": "^6.26.2",
105+
"react-is": "^18.3.1",
87106
"sortablejs": "^1.15.0",
88107
"sql-formatter": "^12.1.3",
89108
"stylelint-config-rational-order-fix": "^0.1.9",
90109
"stylelint-config-recommended-less": "^1.0.4",
91110
"stylelint-config-recommended-vue": "^1.4.0",
92111
"stylelint-stylus": "^0.18.0",
93112
"ts-md5": "^1.3.1",
113+
"use-query-params": "^2.2.1",
94114
"vue": "^3.5.20",
95115
"vue-codemirror": "^6.1.1",
96116
"vue-echarts": "^6.5.0",
@@ -111,14 +131,18 @@
111131
"@types/nprogress": "^0.2.0",
112132
"@types/numeral": "^2.0.2",
113133
"@types/qs": "^6.9.7",
134+
"@types/react": "^18.3.11",
135+
"@types/react-dom": "^18.3.1",
114136
"@types/sortablejs": "^1.15.0",
115137
"@typescript-eslint/eslint-plugin": "^5.59.11",
116138
"@typescript-eslint/parser": "^5.53.0",
117139
"@vitejs/plugin-vue": "^3.1.2",
118140
"@vitejs/plugin-vue-jsx": "^2.1.1",
141+
"@vitejs/plugin-react": "^4.3.2",
119142
"@vue/babel-plugin-jsx": "^1.1.1",
120143
"@vue/language-plugin-pug": "^2.2.10",
121144
"cross-env": "^7.0.3",
145+
"esbuild": "0.18.20",
122146
"eslint": "^8.40.0",
123147
"eslint-config-airbnb-base": "^15.0.0",
124148
"eslint-config-prettier": "^8.7.0",
@@ -145,6 +169,7 @@
145169
"vite": "^4.5.14",
146170
"vite-plugin-compression": "^0.5.1",
147171
"vite-plugin-eslint": "^1.8.1",
172+
"vite-plugin-html": "^3.2.0",
148173
"vite-plugin-markdown": "2.2.0-2",
149174
"vite-plugin-style-import": "2.0.0",
150175
"vite-svg-loader": "^4.0.0",
@@ -180,4 +205,4 @@
180205
"braces": "^3.0.3"
181206
}
182207
}
183-
}
208+
}

0 commit comments

Comments
 (0)