From 2547c8c11799ee9bc997185d4472b7403986d6d7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 28 Dec 2022 13:42:30 +0900 Subject: [PATCH] refactor --- .../src/components/MkActiveUsersHeatmap.vue | 9 +-- packages/frontend/src/pages/admin/metrics.vue | 67 +++++++++---------- .../src/pages/admin/overview.active-users.vue | 9 +-- .../src/pages/admin/overview.ap-requests.vue | 9 +-- .../src/pages/admin/overview.queue.chart.vue | 9 +-- .../src/pages/admin/queue.chart.chart.vue | 9 +-- packages/frontend/src/scripts/color.ts | 7 ++ 7 files changed, 42 insertions(+), 77 deletions(-) create mode 100644 packages/frontend/src/scripts/color.ts diff --git a/packages/frontend/src/components/MkActiveUsersHeatmap.vue b/packages/frontend/src/components/MkActiveUsersHeatmap.vue index 9204c7312a..6b89a012f2 100644 --- a/packages/frontend/src/components/MkActiveUsersHeatmap.vue +++ b/packages/frontend/src/components/MkActiveUsersHeatmap.vue @@ -34,6 +34,7 @@ import { defaultStore } from '@/store'; import { useChartTooltip } from '@/scripts/use-chart-tooltip'; import { MatrixController, MatrixElement } from 'chartjs-chart-matrix'; import { chartVLine } from '@/scripts/chart-vline'; +import { alpha } from '@/scripts/color'; Chart.register( ArcElement, @@ -53,14 +54,6 @@ Chart.register( MatrixController, MatrixElement, ); -const alpha = (hex, a) => { - const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)!; - const r = parseInt(result[1], 16); - const g = parseInt(result[2], 16); - const b = parseInt(result[3], 16); - return `rgba(${r}, ${g}, ${b}, ${a})`; -}; - const rootEl = $ref(null); const chartEl = $ref(null); const now = new Date(); diff --git a/packages/frontend/src/pages/admin/metrics.vue b/packages/frontend/src/pages/admin/metrics.vue index db8e448639..6c4803fe0b 100644 --- a/packages/frontend/src/pages/admin/metrics.vue +++ b/packages/frontend/src/pages/admin/metrics.vue @@ -53,54 +53,47 @@