diff --git a/README.md b/README.md index 0d5433e..40b3da3 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,11 @@ [Demo](https://oa.veypi.com) + + +### 依赖库 + +```bash +docker run -dit --name=tsdb -v /Users/veypi/test/vdb:/victoria-metrics-data -p 8428:8428 victoriametrics/victoria-metrics -search.latencyOffset=1s +nats-server -c ./script/nats.cfg +``` diff --git a/oab/cfg-demo.yml b/oab/cfg-demo.yml index e147c44..a1a34fb 100644 --- a/oab/cfg-demo.yml +++ b/oab/cfg-demo.yml @@ -21,9 +21,10 @@ nats_sys: - UCOKXBGDAXXQOR4XUPUJ4O22HZ2A3KQN3JLCCYM3ISSKHLBZJXXQ3NLF - SUAEILQZDD2UT2ZNR6DCA44YCRKAZDYDOJRUPAUA7AOWFVGSSPFPCLXF24 info: - ws_url: 198.19.249.3:4221 - nats_url: 198.19.249.3:4222 - api_url: 198.19.249.3:4001 + ws_url: 127.0.0.1:4221 + nats_url: 127.0.0.1:4222 + api_url: 127.0.0.1:4001 + ts_url: 127.0.0.1:8428 user_init_space: 300 diff --git a/oab/dist/index.html b/oab/dist/index.html index a262394..a53749a 100644 --- a/oab/dist/index.html +++ b/oab/dist/index.html @@ -1,3 +1,3 @@ -OA - +OA +
\ No newline at end of file diff --git a/oab/src/cfg.rs b/oab/src/cfg.rs index e7c3f20..89b8cc7 100644 --- a/oab/src/cfg.rs +++ b/oab/src/cfg.rs @@ -114,6 +114,7 @@ pub struct InfoOpt { pub nats_url: String, pub ws_url: String, pub api_url: String, + pub ts_url: String, pub token: Option, } @@ -193,9 +194,10 @@ impl AppState { ], user_init_space: 300, info: InfoOpt { - ws_url: "http://127.0.0.1:4221".to_string(), - nats_url: "http://127.0.0.1:4222".to_string(), - api_url: "http://127.0.0.1:4001".to_string(), + ws_url: "127.0.0.1:4221".to_string(), + nats_url: "127.0.0.1:4222".to_string(), + api_url: "127.0.0.1:4001".to_string(), + ts_url: "127.0.0.1:8428".to_string(), token: None, }, } diff --git a/oab/src/libs/task.rs b/oab/src/libs/task.rs index f8c32c5..2e205f0 100644 --- a/oab/src/libs/task.rs +++ b/oab/src/libs/task.rs @@ -13,20 +13,20 @@ use std::sync::{Arc, Mutex}; use tracing::{info, warn}; #[derive(Debug, Clone, Deserialize, Serialize)] -struct sysInfo { - client: clientInfo, +struct SysInfo { + client: ClientInfo, id: String, // server: String, } #[derive(Debug, Clone, Deserialize, Serialize)] -struct clientInfo { +struct ClientInfo { id: i64, acc: String, name: String, host: String, } pub fn start_nats_online(client: async_nats::client::Client) { - let db: Arc>> = Arc::new(Mutex::new(HashMap::new())); + let db: Arc>> = Arc::new(Mutex::new(HashMap::new())); { let db = db.clone(); let client = client.clone(); @@ -38,7 +38,7 @@ pub fn start_nats_online(client: async_nats::client::Client) { while let Some(msg) = sub.next().await { let s = String::from_utf8(msg.payload.to_vec()).unwrap(); info!("{}", s); - let inf: sysInfo = serde_json::from_slice(&msg.payload.to_vec()).unwrap(); + let inf: SysInfo = serde_json::from_slice(&msg.payload.to_vec()).unwrap(); info!("add {} {}", inf.client.id, inf.client.name); let mut db = db.lock().unwrap(); db.insert(inf.client.id, inf.client); @@ -55,7 +55,7 @@ pub fn start_nats_online(client: async_nats::client::Client) { .unwrap(); while let Some(msg) = sub.next().await { // let s = String::from_utf8(msg.payload.to_vec()).unwrap(); - let inf: sysInfo = serde_json::from_slice(&msg.payload.to_vec()).unwrap(); + let inf: SysInfo = serde_json::from_slice(&msg.payload.to_vec()).unwrap(); info!("remove {} {}", inf.client.id, inf.client.name); let mut db = db.lock().unwrap(); db.remove(&inf.client.id); @@ -66,14 +66,14 @@ pub fn start_nats_online(client: async_nats::client::Client) { let mut sub = client.subscribe("sys.online".to_string()).await.unwrap(); while let Some(msg) = sub.next().await { // // let s = String::from_utf8(msg.payload.to_vec()).unwrap(); - // let inf: sysInfo = serde_json::from_slice(&msg.payload.to_vec()).unwrap(); + // let inf: SysInfo = serde_json::from_slice(&msg.payload.to_vec()).unwrap(); // info!("remove {} {}", inf.client.id, inf.client.name); // let mut db = db.lock().unwrap(); // db.remove(&inf.client.id); if let Some(t) = msg.reply { let d = { let tmp = db.lock().unwrap(); - let payload: Vec = tmp.iter().map(|(_, c)| c.clone()).collect(); + let payload: Vec = tmp.iter().map(|(_, c)| c.clone()).collect(); serde_json::to_string(&payload).unwrap() }; match client.publish(t, d.into()).await { diff --git a/oab/src/main.rs b/oab/src/main.rs index 7a77846..e868a0b 100644 --- a/oab/src/main.rs +++ b/oab/src/main.rs @@ -5,12 +5,9 @@ // Distributed under terms of the Apache license. // -use bytes::Bytes; - use actix_files as fs; use actix_web::{ dev::{self, Service}, - get, http::StatusCode, middleware::{self, ErrorHandlerResponse, ErrorHandlers}, web::{self}, @@ -53,22 +50,7 @@ async fn main() -> Result<()> { Ok(()) } async fn web(data: AppState) -> Result<()> { - let client = match async_nats::ConnectOptions::new() - .nkey(data.nats_usr[1].clone()) - .connect(data.info.nats_url.clone()) - .await - { - Ok(r) => r, - Err(e) => { - info!("{}", e); - return Err(oab::Error::Unknown); - } - }; // libs::task::start_nats_online(client.clone()); - client - .publish("msg".to_string(), Bytes::from("asd")) - .await - .unwrap(); let url = data.server_url.clone(); let dav = libs::fs::core(); let serv = HttpServer::new(move || { diff --git a/oaweb/quasar.config.js b/oaweb/quasar.config.js index ccaa090..d5170bc 100644 --- a/oaweb/quasar.config.js +++ b/oaweb/quasar.config.js @@ -40,7 +40,6 @@ module.exports = configure(function(/* ctx */) { 'i18n', 'api', 'pack', - 'oaer', ], // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css diff --git a/oaweb/src/assets/icon.js b/oaweb/src/assets/icon.js index d7eb001..60a18e7 100644 --- a/oaweb/src/assets/icon.js +++ b/oaweb/src/assets/icon.js @@ -1 +1 @@ -window._iconfont_svg_string_3335115='',function(l){var c=(c=document.getElementsByTagName("script"))[c.length-1],h=c.getAttribute("data-injectcss"),c=c.getAttribute("data-disable-injectsvg");if(!c){var t,a,o,i,v,e=function(c,h){h.parentNode.insertBefore(c,h)};if(h&&!l.__iconfont__svg__cssinject__){l.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(c){console&&console.log(c)}}t=function(){var c,h=document.createElement("div");h.innerHTML=l._iconfont_svg_string_3335115,(h=h.getElementsByTagName("svg")[0])&&(h.setAttribute("aria-hidden","true"),h.style.position="absolute",h.style.width=0,h.style.height=0,h.style.overflow="hidden",h=h,(c=document.body).firstChild?e(h,c.firstChild):c.appendChild(h))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(t,0):(a=function(){document.removeEventListener("DOMContentLoaded",a,!1),t()},document.addEventListener("DOMContentLoaded",a,!1)):document.attachEvent&&(o=t,i=l.document,v=!1,s(),i.onreadystatechange=function(){"complete"==i.readyState&&(i.onreadystatechange=null,d())})}function d(){v||(v=!0,o())}function s(){try{i.documentElement.doScroll("left")}catch(c){return void setTimeout(s,50)}d()}}(window); \ No newline at end of file +window._iconfont_svg_string_3335115='',function(h){var c=(c=document.getElementsByTagName("script"))[c.length-1],l=c.getAttribute("data-injectcss"),c=c.getAttribute("data-disable-injectsvg");if(!c){var a,t,o,s,i,v=function(c,l){l.parentNode.insertBefore(c,l)};if(l&&!h.__iconfont__svg__cssinject__){h.__iconfont__svg__cssinject__=!0;try{document.write("")}catch(c){console&&console.log(c)}}a=function(){var c,l=document.createElement("div");l.innerHTML=h._iconfont_svg_string_3335115,(l=l.getElementsByTagName("svg")[0])&&(l.setAttribute("aria-hidden","true"),l.style.position="absolute",l.style.width=0,l.style.height=0,l.style.overflow="hidden",l=l,(c=document.body).firstChild?v(l,c.firstChild):c.appendChild(l))},document.addEventListener?~["complete","loaded","interactive"].indexOf(document.readyState)?setTimeout(a,0):(t=function(){document.removeEventListener("DOMContentLoaded",t,!1),a()},document.addEventListener("DOMContentLoaded",t,!1)):document.attachEvent&&(o=a,s=h.document,i=!1,z(),s.onreadystatechange=function(){"complete"==s.readyState&&(s.onreadystatechange=null,d())})}function d(){i||(i=!0,o())}function z(){try{s.documentElement.doScroll("left")}catch(c){return void setTimeout(z,50)}d()}}(window); \ No newline at end of file diff --git a/oaweb/src/boot/oaer.ts b/oaweb/src/boot/oaer.ts deleted file mode 100644 index 6edcfcf..0000000 --- a/oaweb/src/boot/oaer.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * oaer.ts - * Copyright (C) 2023 veypi - * 2023-10-16 21:20 - * Distributed under terms of the MIT license. - */ - - -// import '@veypi/oaer' -import oaer from '@veypi/oaer' -import '@veypi/oaer/dist/index.css' -import cfg from 'src/cfg' -import bus from 'src/libs/bus' -import util from 'src/libs/util' - -oaer.set({ - token: util.getToken(), - host: cfg.host, - uuid: cfg.id, -}) - -bus.on('token', (t: any) => { - oaer.set({ token: t }) -}) diff --git a/oaweb/src/components/EssentialLink.vue b/oaweb/src/components/EssentialLink.vue deleted file mode 100644 index c27cd87..0000000 --- a/oaweb/src/components/EssentialLink.vue +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/oaweb/src/components/ExampleComponent.vue b/oaweb/src/components/ExampleComponent.vue deleted file mode 100644 index bc03c3d..0000000 --- a/oaweb/src/components/ExampleComponent.vue +++ /dev/null @@ -1,37 +0,0 @@ - - - diff --git a/oaweb/src/components/FsTree.vue b/oaweb/src/components/FsTree.vue index 93929eb..980166e 100644 --- a/oaweb/src/components/FsTree.vue +++ b/oaweb/src/components/FsTree.vue @@ -10,7 +10,7 @@ class="cursor-pointer rounded-full h-8 pr-4 flex items-center hover:bg-gray-100" @click="toggle"> + 'directory' ? 'v-right' : 'v-file'">
{{ root.basename || '/' }}
diff --git a/oaweb/src/components/tooltip.vue b/oaweb/src/components/tooltip.vue new file mode 100644 index 0000000..e5c25af --- /dev/null +++ b/oaweb/src/components/tooltip.vue @@ -0,0 +1,48 @@ + + + + + + diff --git a/oaweb/src/components/tschart/index.ts b/oaweb/src/components/tschart/index.ts new file mode 100644 index 0000000..c569865 --- /dev/null +++ b/oaweb/src/components/tschart/index.ts @@ -0,0 +1,11 @@ +/* + * index.ts + * Copyright (C) 2023 veypi + * 2023-10-22 05:11 + * Distributed under terms of the MIT license. + */ + + +import tschart from './tschart.vue' + +export default tschart diff --git a/oaweb/src/components/tschart/params.ts b/oaweb/src/components/tschart/params.ts new file mode 100644 index 0000000..7d33840 --- /dev/null +++ b/oaweb/src/components/tschart/params.ts @@ -0,0 +1,71 @@ +/* + * params.ts + * Copyright (C) 2023 veypi + * 2023-10-22 05:13 + * Distributed under terms of the MIT license. + */ +import { ref } from 'vue' + + +let mode = ref(0) +let mode_label = ['近5分钟', '近1小时', '近24小时', '近7天', '近30天'] +let change_mode = (m: number) => { + mode.value = m + let now = new Date() + switch (m) { + case 0: { + now.setMinutes(now.getMinutes() - 5) + params.value.start = now + params.value.step = "2s" + break + } + case 1: { + now.setHours(now.getHours() - 1) + params.value.start = now + params.value.step = "10s" + break + } + case 2: { + now.setHours(now.getHours() - 24) + params.value.start = now + params.value.step = "20s" + break + } + case 3: { + now.setHours(now.getHours() - 24 * 7) + params.value.start = now + params.value.step = "30s" + break + } + case 4: { + now.setHours(now.getHours() - 24 * 29) + params.value.start = now + params.value.step = "1h" + break + } + case 5: { + break + } + } +} +let params = ref<{ start: Date, end: Date, step: string }>({ + start: new Date(), + end: new Date(), + step: '2s' +}) + +change_mode(0) + +const set_delta = (start?: Date, end?: Date) => { + if (start) { + params.value.start = start + } + if (end) { + params.value.end = end + } + let delta = params.value.end.getTime() - + params.value.start.getTime() + console.log(delta) +} + +export { params, change_mode, mode, mode_label } diff --git a/oaweb/src/components/tschart.vue b/oaweb/src/components/tschart/tschart.vue similarity index 59% rename from oaweb/src/components/tschart.vue rename to oaweb/src/components/tschart/tschart.vue index d15dfb9..12fced8 100644 --- a/oaweb/src/components/tschart.vue +++ b/oaweb/src/components/tschart/tschart.vue @@ -6,13 +6,22 @@ --> diff --git a/oaweb/src/pages/stats.vue b/oaweb/src/pages/stats.vue index b78432a..b4f627e 100644 --- a/oaweb/src/pages/stats.vue +++ b/oaweb/src/pages/stats.vue @@ -5,28 +5,118 @@ * Distributed under terms of the MIT license. -->