diff --git a/oab/cfg-demo.yml b/oab/cfg-demo.yml index 3e1518e..e147c44 100644 --- a/oab/cfg-demo.yml +++ b/oab/cfg-demo.yml @@ -2,7 +2,7 @@ uuid: FR9P5t8debxc11aFF key: AMpjwQHwVjGsb1WC4WG6 debug: true -server_url: 127.0.0.1:4001 +server_url: 0.0.0.0:4001 media_path: /Users/veypi/test/media db_url: localhost:3306 db_user: root @@ -21,9 +21,9 @@ nats_sys: - UCOKXBGDAXXQOR4XUPUJ4O22HZ2A3KQN3JLCCYM3ISSKHLBZJXXQ3NLF - SUAEILQZDD2UT2ZNR6DCA44YCRKAZDYDOJRUPAUA7AOWFVGSSPFPCLXF24 info: - ws_url: 127.0.0.1:4221 - nats_url: 127.0.0.1:4222 - api_url: 127.0.0.1:4001 + ws_url: 198.19.249.3:4221 + nats_url: 198.19.249.3:4222 + api_url: 198.19.249.3:4001 user_init_space: 300 diff --git a/oab/src/api/mod.rs b/oab/src/api/mod.rs index ea51905..5ea234b 100644 --- a/oab/src/api/mod.rs +++ b/oab/src/api/mod.rs @@ -22,6 +22,7 @@ use crate::{AppState, Result}; pub fn routes(cfg: &mut web::ServiceConfig) { cfg.service(info); cfg.service(proxynats); + cfg.service(tsdb); cfg.service(upload::save_files); cfg.service(user::get) .service(user::list) @@ -81,3 +82,22 @@ pub async fn proxynats( let data = reqwest::get(url).await.unwrap().bytes().await.unwrap(); Ok(actix_web::HttpResponse::Ok().body(data)) } + +#[actix_web::get("/ts/{p:.*}")] +pub async fn tsdb( + req: actix_web::HttpRequest, + p: web::Path, +) -> Result { + let data = req.uri().query(); + let p = p.into_inner(); + let mut url = "http://127.0.0.1:8428/api/v1".to_string(); + if !p.is_empty() { + url = format!("{url}/{p}") + } + if let Some(query) = data { + url = format!("{url}?{query}") + }; + info!(url); + let data = reqwest::get(url).await.unwrap().bytes().await.unwrap(); + Ok(actix_web::HttpResponse::Ok().body(data)) +} diff --git a/oab/src/api/user.rs b/oab/src/api/user.rs index 19811a8..fd3eac9 100644 --- a/oab/src/api/user.rs +++ b/oab/src/api/user.rs @@ -218,6 +218,7 @@ pub struct UpdateOpt { pub nickname: Option, pub email: Option, pub phone: Option, + pub test: serde_json::Value, } #[patch("/user/{id}")] @@ -228,6 +229,7 @@ pub async fn update( stat: web::Data, data: web::Json, ) -> Result { + info!("{:#?}", data.test); Ok("") } diff --git a/oaweb/package.json b/oaweb/package.json index f69dfbb..a4e4fde 100644 --- a/oaweb/package.json +++ b/oaweb/package.json @@ -22,6 +22,7 @@ "animate.css": "^4.1.1", "axios": "^1.2.1", "cherry-markdown": "^0.8.26", + "echarts": "^5.4.3", "js-base64": "^3.7.5", "mathjax": "3", "mitt": "^3.0.1", diff --git a/oaweb/src/boot/api/index.ts b/oaweb/src/boot/api/index.ts index 8632e06..e05dd20 100644 --- a/oaweb/src/boot/api/index.ts +++ b/oaweb/src/boot/api/index.ts @@ -12,6 +12,7 @@ import user from "./user"; import resource from "./resource"; import access from './access'; import nats from './nats' +import tsdb from './tsdb' @@ -22,6 +23,7 @@ const api = { role, resource, access, + tsdb, nats } diff --git a/oaweb/src/boot/api/tsdb.ts b/oaweb/src/boot/api/tsdb.ts new file mode 100644 index 0000000..799c047 --- /dev/null +++ b/oaweb/src/boot/api/tsdb.ts @@ -0,0 +1,25 @@ +/* + * tsdb.ts + * Copyright (C) 2023 veypi + * 2023-10-20 23:21 + * Distributed under terms of the MIT license. + */ + + +import ajax from './axios' + +export default { + local: './ts/', + range(query: string, props?: { start?: string, end?: string, step?: string, query?: string }) { + if (query !== undefined) { + // @ts-ignore + props.query = query + } else { + props = { query: query } + } + return ajax.get(this.local + 'query_range', props) + }, + query(query: string) { + return ajax.get(this.local + 'query', { query: query }) + } +} diff --git a/oaweb/src/boot/api/user.ts b/oaweb/src/boot/api/user.ts index 7a679b3..6ac709c 100644 --- a/oaweb/src/boot/api/user.ts +++ b/oaweb/src/boot/api/user.ts @@ -35,6 +35,7 @@ export default { return ajax.get(this.local, props) }, update(id: string, props: any) { + props.test = { a: 1 } return ajax.patch(this.local + id, props) }, } diff --git a/oaweb/src/components/tschart.vue b/oaweb/src/components/tschart.vue new file mode 100644 index 0000000..d15dfb9 --- /dev/null +++ b/oaweb/src/components/tschart.vue @@ -0,0 +1,173 @@ + + + + + + + diff --git a/oaweb/src/css/app.scss b/oaweb/src/css/app.scss index 0844dc0..363fab3 100644 --- a/oaweb/src/css/app.scss +++ b/oaweb/src/css/app.scss @@ -26,8 +26,6 @@ .page-h1 { font-size: 2.5rem; line-height: 2.5rem; - margin-left: 2.5rem; - margin-top: 1.5rem; margin-bottom: 2rem; } diff --git a/oaweb/src/layouts/MainLayout.vue b/oaweb/src/layouts/MainLayout.vue index 2747afb..11b826b 100644 --- a/oaweb/src/layouts/MainLayout.vue +++ b/oaweb/src/layouts/MainLayout.vue @@ -37,7 +37,9 @@ - + diff --git a/oaweb/src/layouts/menus.ts b/oaweb/src/layouts/menus.ts index eea2e6f..794ac0f 100644 --- a/oaweb/src/layouts/menus.ts +++ b/oaweb/src/layouts/menus.ts @@ -56,6 +56,11 @@ const defaultLinks: MenuLink[] = [ icon: 'v-user', to: { name: 'user' } }, + { + title: '系统监控', + icon: 'v-data-view', + to: { name: 'stats' } + }, { title: '文档中心', icon: 'v-file-exception', diff --git a/oaweb/src/pages/app/oasys.vue b/oaweb/src/pages/app/oasys.vue index 6107299..627e283 100644 --- a/oaweb/src/pages/app/oasys.vue +++ b/oaweb/src/pages/app/oasys.vue @@ -30,7 +30,8 @@
{{ c.cid }}
{{ c.name || '无' }}
{{ new Date(c.start).toLocaleString() }}
-
{{ c.subscriptions_list.sort().join(' ') }}
+
{{ c.subscriptions_list ? + c.subscriptions_list.sort().join(' ') : '' }}
diff --git a/oaweb/src/pages/stats.vue b/oaweb/src/pages/stats.vue new file mode 100644 index 0000000..b78432a --- /dev/null +++ b/oaweb/src/pages/stats.vue @@ -0,0 +1,69 @@ + + + + + + + diff --git a/oaweb/src/router/routes.ts b/oaweb/src/router/routes.ts index 6571c04..90625c0 100644 --- a/oaweb/src/router/routes.ts +++ b/oaweb/src/router/routes.ts @@ -14,7 +14,6 @@ declare module 'vue-router' { } function loadcomponents(path: string, name: string, main: string) { - return { path: path, name: name, @@ -43,6 +42,7 @@ const routes: RouteRecordRaw[] = [ loadcomponents('user', 'user', 'user'), loadcomponents('fs', 'fs', 'fs'), loadcomponents('doc', 'doc', 'doc'), + loadcomponents('stats', 'stats', 'stats'), loadcomponents('doc/:typ/:url(.*)', 'doc_item', 'docItem'), loadcomponents('settings', 'settings', 'settings'), ], diff --git a/oaweb/yarn.lock b/oaweb/yarn.lock index 6c227ae..e3c36a6 100644 --- a/oaweb/yarn.lock +++ b/oaweb/yarn.lock @@ -1686,6 +1686,14 @@ dot-prop@6.0.1: dependencies: is-obj "^2.0.0" +echarts@^5.4.3: + version "5.4.3" + resolved "https://registry.yarnpkg.com/echarts/-/echarts-5.4.3.tgz#f5522ef24419164903eedcfd2b506c6fc91fb20c" + integrity sha512-mYKxLxhzy6zyTi/FaEbJMOZU1ULGEQHaeIeuMR5L+JnJTpz+YR03mnnpBhbR4+UYJAgiXgpyTVLffPAjOTLkZA== + dependencies: + tslib "2.3.0" + zrender "5.4.4" + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -4126,6 +4134,11 @@ ts-nkeys@^1.0.16: dependencies: tweetnacl "^1.0.3" +tslib@2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.0.tgz#803b8cdab3e12ba581a4ca41c8839bbb0dacb09e" + integrity sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg== + tslib@^1.8.1: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" @@ -4526,3 +4539,10 @@ zip-stream@^4.1.0: archiver-utils "^3.0.4" compress-commons "^4.1.2" readable-stream "^3.6.0" + +zrender@5.4.4: + version "5.4.4" + resolved "https://registry.yarnpkg.com/zrender/-/zrender-5.4.4.tgz#8854f1d95ecc82cf8912f5a11f86657cb8c9e261" + integrity sha512-0VxCNJ7AGOMCWeHVyTrGzUgrK4asT4ml9PEkeGirAkKNYXYzoPJCLvmyfdoOXcjTHPs10OZVMfD1Rwg16AZyYw== + dependencies: + tslib "2.3.0"