diff --git a/src/api/data-collect/dashboard.ts b/src/api/data-collect/dashboard.ts new file mode 100644 index 00000000..ceb68ca0 --- /dev/null +++ b/src/api/data-collect/dashboard.ts @@ -0,0 +1,6 @@ +import server from '@/utils/request'; + +export const queryCount = (type: string, data: any) => + server.post(`/data-collect/${type}/_count`, data); + +export const dashboard = (data: any) => server.post(`/dashboard/_multi`, data); diff --git a/src/views/DataCollect/Dashboard/components/Card.vue b/src/views/DataCollect/Dashboard/components/Card.vue new file mode 100644 index 00000000..57448ee1 --- /dev/null +++ b/src/views/DataCollect/Dashboard/components/Card.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/src/views/DataCollect/Dashboard/components/TopCard.vue b/src/views/DataCollect/Dashboard/components/TopCard.vue new file mode 100644 index 00000000..1138eae1 --- /dev/null +++ b/src/views/DataCollect/Dashboard/components/TopCard.vue @@ -0,0 +1,98 @@ + + + + + diff --git a/src/views/DataCollect/Dashboard/index.less b/src/views/DataCollect/Dashboard/index.less new file mode 100644 index 00000000..9709ead9 --- /dev/null +++ b/src/views/DataCollect/Dashboard/index.less @@ -0,0 +1,38 @@ +.media-dash-board { + .top-card-items { + margin-bottom: 12px; + height: 100px; + .top-card-item { + width: 25%; + padding: 6px 24px; + border: 1px solid #e3e3e3; + + .top-card-top { + display: flex; + padding: 12px 0; + + .top-card-top-left { + width: 80px; + } + + .top-card-top-right { + .top-card-total { + font-weight: bold; + font-size: 20px; + } + } + } + + .top-card-bottom { + display: flex; + justify-content: space-between; + padding: 12px 0; + border-top: 1px solid #e3e3e3; + } + } + } + + .media-dash-board-body { + border: 1px solid #f0f0f0; + } +} diff --git a/src/views/DataCollect/Dashboard/index.vue b/src/views/DataCollect/Dashboard/index.vue new file mode 100644 index 00000000..adacc21f --- /dev/null +++ b/src/views/DataCollect/Dashboard/index.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/views/DataCollect/Dashboard/tool.ts b/src/views/DataCollect/Dashboard/tool.ts new file mode 100644 index 00000000..076c6947 --- /dev/null +++ b/src/views/DataCollect/Dashboard/tool.ts @@ -0,0 +1,155 @@ +import moment from 'moment'; +import * as echarts from 'echarts'; + +const getParams = (dt: any) => { + switch (dt.type) { + case 'today': + return { + limit: 24, + interval: '1h', + format: 'HH:mm', + }; + case 'week': + return { + limit: 7, + interval: '1d', + format: 'MM-dd', + }; + case 'hour': + return { + limit: 60, + interval: '1m', + format: 'HH:mm', + }; + default: + const time = dt.end - dt.start; + const hour = 60 * 60 * 1000; + const days = hour * 24; + const year = days * 365; + if (time <= hour) { + return { + limit: Math.abs(Math.ceil(time / (60 * 60))), + interval: '1m', + format: 'HH:mm', + }; + } else if (time > hour && time <= days) { + return { + limit: Math.abs(Math.ceil(time / hour)), + interval: '1h', + format: 'HH:mm', + }; + } else if (time >= year) { + return { + limit: Math.abs(Math.ceil(time / days / 31)) + 1, + interval: '1M', + format: 'yyyy年-M月', + }; + } else { + return { + limit: Math.abs(Math.ceil(time / days)) + 1, + interval: '1d', + format: 'MM-dd', + }; + } + } +}; + +export const getTimeByType = (type) => { + switch (type) { + case 'hour': + return moment().subtract(1, 'hours'); + case 'week': + return moment().subtract(6, 'days'); + case 'month': + return moment().subtract(29, 'days'); + case 'year': + return moment().subtract(365, 'days'); + default: + return moment().startOf('day'); + } +}; + +export const pointParams = (data) => [ + { + dashboard: 'collector', + object: 'pointData', + measurement: 'quantity', + dimension: 'agg', + params: { + limit: getParams(data.time).limit, + from: data.time.start, + to: data.time.end, + interval: getParams(data.time).interval, + format: getParams(data.time).format, + }, + }, +]; + +export const pointOptionsSeries = { + type: 'line', + smooth: true, + color: '#60DFC7', + areaStyle: { + color: { + type: 'linear', + x: 0, + y: 0, + x2: 0, + y2: 1, + colorStops: [ + { + offset: 0, + color: '#60DFC7', // 100% 处的颜色 + }, + { + offset: 1, + color: '#FFFFFF', // 0% 处的颜色 + }, + ], + global: false, // 缺省为 false + }, + }, +}; + +export const defaultParams = { + terms: [ + { + column: 'runningState', + termType: 'not', + value: 'running', + }, + ], +}; + +export const statusData = ref([ + [ + { + type: 'channel', + title: '异常通道', + status: 'error', + label: '通道数量', + value: 0, + total: 0, + }, + ], + [ + { + type: 'collector', + title: '异常采集器', + status: 'error', + label: '采集器数量', + value: 0, + total: 0, + }, + ], + [ + { + type: 'point', + title: '异常点位', + status: 'error', + label: '采集点位', + value: 0, + total: 0, + }, + ], +]); diff --git a/src/views/DataCollect/Dashboard/typings.d.ts b/src/views/DataCollect/Dashboard/typings.d.ts new file mode 100644 index 00000000..dd0a9484 --- /dev/null +++ b/src/views/DataCollect/Dashboard/typings.d.ts @@ -0,0 +1,18 @@ +export type Agg = { + duration: number; + total: number; +}; + +export type AggPlaying = { + playerTotal: number; + playingTotal: number; +}; + +export type Footer = { + title: string; + value: number | string; + total: number | string; + status?: 'default' | 'error' | 'success' | 'warning' | 'processing' | ''; + type: string; + label: string; +}; diff --git a/src/views/link/AccessConfig/index.vue b/src/views/link/AccessConfig/index.vue index 0f75d961..aaa46df1 100644 --- a/src/views/link/AccessConfig/index.vue +++ b/src/views/link/AccessConfig/index.vue @@ -316,7 +316,7 @@ const getActions = (data: Partial>): ActionsType[] => { const getProvidersList = async () => { const res = await getProviders(); - providersList = res.result; + providersList.value = res.result; }; getProvidersList(); @@ -337,7 +337,7 @@ const handlEye = (id: string) => { const getDescription = (slotProps: Record) => slotProps.description ? slotProps.description - : providersList?.find( + : providersList.value?.find( (item: Record) => item.id === slotProps.provider, )?.description; diff --git a/src/views/link/DashBoard/components/Cpu.vue b/src/views/link/DashBoard/components/Cpu.vue index 6f62f3e5..995ea05f 100644 --- a/src/views/link/DashBoard/components/Cpu.vue +++ b/src/views/link/DashBoard/components/Cpu.vue @@ -33,8 +33,7 @@ > - -
+
@@ -54,7 +53,6 @@ import { const chartRef = ref>({}); const loading = ref(false); -const empty = ref(false); const data = ref({ type: 'hour', time: [null, null], @@ -108,7 +106,6 @@ const handleCpuOptions = (optionsData, xAxis) => { if (chart) { const myChart = echarts.init(chart); const dataKeys = Object.keys(optionsData); - const options = { xAxis: { type: 'category', @@ -143,7 +140,6 @@ const handleCpuOptions = (optionsData, xAxis) => { : typeDataLine, }; myChart.setOption(options); - xAxis.length === 0 && (empty.value = true); window.addEventListener('resize', function () { myChart.resize(); }); @@ -190,7 +186,4 @@ watch( margin-top: 8px; } } -.empty { - height: 300px; -} diff --git a/src/views/link/DashBoard/components/Jvm.vue b/src/views/link/DashBoard/components/Jvm.vue index 44671b76..d4538c59 100644 --- a/src/views/link/DashBoard/components/Jvm.vue +++ b/src/views/link/DashBoard/components/Jvm.vue @@ -33,8 +33,7 @@ > - -
+
@@ -53,7 +52,6 @@ import { } from './tool.ts'; const chartRef = ref>({}); -const empty = ref(false); const loading = ref(false); const data = ref({ type: 'hour', @@ -147,7 +145,6 @@ const handleJVMOptions = (optionsData, xAxis) => { : typeDataLine, }; myChart.setOption(options); - xAxis.length === 0 && (empty.value = true); window.addEventListener('resize', function () { myChart.resize(); }); @@ -194,7 +191,4 @@ watch( margin-top: 8px; } } -.empty { - height: 300px; -} diff --git a/src/views/link/DashBoard/components/Network.vue b/src/views/link/DashBoard/components/Network.vue index 46188f4f..625c1de5 100644 --- a/src/views/link/DashBoard/components/Network.vue +++ b/src/views/link/DashBoard/components/Network.vue @@ -37,18 +37,13 @@ @change="pickerTimeChange" >
- -
+
@@ -61,13 +56,11 @@ import { typeDataLine, areaStyle, networkParams, - arrayReverse, } from './tool.ts'; import moment from 'moment'; import * as echarts from 'echarts'; const chartRef = ref>({}); -const empty = ref(false); const loading = ref(false); const data = ref({ type: 'bytesRead', @@ -134,7 +127,6 @@ const setOptions = (data, key) => ({ const handleNetworkOptions = (optionsData, xAxis) => { const chart = chartRef.value; - if (chart) { const myChart = echarts.init(chart); const dataKeys = Object.keys(optionsData); @@ -148,7 +140,7 @@ const handleNetworkOptions = (optionsData, xAxis) => { type: 'value', }, grid: { - left: '80px', + left: '100px', right: '50px', }, tooltip: { @@ -161,7 +153,6 @@ const handleNetworkOptions = (optionsData, xAxis) => { : typeDataLine, }; myChart.setOption(options); - // xAxis.length === 0 && (empty.value = true); window.addEventListener('resize', function () { myChart.resize(); }); @@ -215,7 +206,4 @@ watch( display: flex; align-items: center; } -.empty { - height: 300px; -}