From 46e86d2a3d76cf78178830dcfdf6048202c377eb Mon Sep 17 00:00:00 2001 From: 0xJacky Date: Wed, 23 Feb 2022 11:22:50 +0800 Subject: [PATCH] redesign Dashboard --- frontend/package.json | 2 + frontend/src/api/analytic.js | 4 +- frontend/src/components/Chart/CPUChart.vue | 83 +++++ frontend/src/components/Chart/DiskChart.vue | 82 +++++ frontend/src/components/Chart/NetChart.vue | 87 +++++ .../src/components/Chart/RadialBarChart.vue | 93 +++++ frontend/src/router/index.js | 19 +- frontend/src/views/config/ConfigEdit.vue | 4 +- frontend/src/views/dashboard/DashBoard.vue | 333 ++++++++++++------ frontend/src/views/domain/DomainEdit.vue | 4 +- frontend/yarn.lock | 72 ++++ main.go | 2 +- server/api/analytic.go | 42 ++- server/router/routers.go | 2 +- server/settings/settings.go | 2 + server/tool/analytic.go | 124 +++++++ server/tool/cpu_usage.go | 46 --- 17 files changed, 834 insertions(+), 167 deletions(-) create mode 100644 frontend/src/components/Chart/CPUChart.vue create mode 100644 frontend/src/components/Chart/DiskChart.vue create mode 100644 frontend/src/components/Chart/NetChart.vue create mode 100644 frontend/src/components/Chart/RadialBarChart.vue create mode 100644 server/tool/analytic.go delete mode 100644 server/tool/cpu_usage.go diff --git a/frontend/package.json b/frontend/package.json index 12eb42ac..11a26b94 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -9,11 +9,13 @@ }, "dependencies": { "ant-design-vue": "^1.7.3", + "apexcharts": "^3.33.1", "axios": "^0.21.1", "chart.js": "^2.9.4", "core-js": "^3.9.0", "reconnecting-websocket": "^4.4.0", "vue": "^2.6.11", + "vue-apexcharts": "^1.6.2", "vue-chartjs": "^3.5.1", "vue-codemirror": "^4.0.6", "vue-gettext": "^2.1.12", diff --git a/frontend/src/api/analytic.js b/frontend/src/api/analytic.js index 629641e2..9ca6edb4 100644 --- a/frontend/src/api/analytic.js +++ b/frontend/src/api/analytic.js @@ -1,8 +1,8 @@ import http from '@/lib/http' const analytic = { - cpu_usage() { - return http.get('/analytic/cpu') + init() { + return http.get('/analytic/init') } } diff --git a/frontend/src/components/Chart/CPUChart.vue b/frontend/src/components/Chart/CPUChart.vue new file mode 100644 index 00000000..0f9b7247 --- /dev/null +++ b/frontend/src/components/Chart/CPUChart.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/frontend/src/components/Chart/DiskChart.vue b/frontend/src/components/Chart/DiskChart.vue new file mode 100644 index 00000000..66a0f7b2 --- /dev/null +++ b/frontend/src/components/Chart/DiskChart.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/frontend/src/components/Chart/NetChart.vue b/frontend/src/components/Chart/NetChart.vue new file mode 100644 index 00000000..5f888f81 --- /dev/null +++ b/frontend/src/components/Chart/NetChart.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/frontend/src/components/Chart/RadialBarChart.vue b/frontend/src/components/Chart/RadialBarChart.vue new file mode 100644 index 00000000..39ed48e3 --- /dev/null +++ b/frontend/src/components/Chart/RadialBarChart.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 3aab8237..81fe9313 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -62,17 +62,16 @@ export const routes = [ meta: { icon: 'file', hideChildren: true - }, - children: [{ - path: 'config/:name', - name: $gettext('Edit Configuration'), - component: () => import('@/views/config/ConfigEdit.vue'), - meta: { - hiddenInSidebar: true - }, - },] + } + }, + { + path: 'config/:name', + name: $gettext('Edit Configuration'), + component: () => import('@/views/config/ConfigEdit.vue'), + meta: { + hiddenInSidebar: true + }, }, - { path: 'about', name: $gettext('About'), diff --git a/frontend/src/views/config/ConfigEdit.vue b/frontend/src/views/config/ConfigEdit.vue index 9b152120..e303c777 100644 --- a/frontend/src/views/config/ConfigEdit.vue +++ b/frontend/src/views/config/ConfigEdit.vue @@ -3,8 +3,8 @@ - Cancel - Save + Cancel + Save diff --git a/frontend/src/views/dashboard/DashBoard.vue b/frontend/src/views/dashboard/DashBoard.vue index 6b59541e..ad2e19aa 100644 --- a/frontend/src/views/dashboard/DashBoard.vue +++ b/frontend/src/views/dashboard/DashBoard.vue @@ -1,64 +1,148 @@