From 670e750257c4e97941fb36de98124b75e6a0766f Mon Sep 17 00:00:00 2001 From: naskya Date: Sun, 17 Sep 2023 08:56:51 +0900 Subject: [PATCH] fix: remove charts from client (close #76) --- packages/client/src/components/MkChart.vue | 644 +----------------- .../src/components/MkInstanceCardMini.vue | 18 - .../client/src/components/MkInstanceStats.vue | 68 +- .../client/src/components/MkNoteDetailed.vue | 1 - .../client/src/components/MkReactedUsers.vue | 7 +- .../client/src/components/MkUserCardMini.vue | 19 - .../src/pages/admin/overview.ap-requests.vue | 289 -------- .../src/pages/admin/overview.federation.vue | 34 - .../src/pages/admin/overview.heatmap.vue | 20 +- .../client/src/pages/admin/overview.stats.vue | 11 - .../client/src/pages/admin/overview.user.vue | 16 - packages/client/src/pages/admin/overview.vue | 10 - packages/client/src/pages/instance-info.vue | 89 +-- packages/client/src/pages/settings/drive.vue | 15 - packages/client/src/pages/user-info.vue | 52 -- packages/client/src/pages/user/home.vue | 11 - .../client/src/pages/user/index.activity.vue | 76 --- .../client/src/widgets/activity.calendar.vue | 102 --- .../client/src/widgets/activity.chart.vue | 136 ---- packages/client/src/widgets/activity.vue | 124 ---- packages/client/src/widgets/federation.vue | 16 - packages/client/src/widgets/index.ts | 5 - 22 files changed, 8 insertions(+), 1755 deletions(-) delete mode 100644 packages/client/src/pages/admin/overview.ap-requests.vue delete mode 100644 packages/client/src/pages/user/index.activity.vue delete mode 100644 packages/client/src/widgets/activity.calendar.vue delete mode 100644 packages/client/src/widgets/activity.chart.vue delete mode 100644 packages/client/src/widgets/activity.vue diff --git a/packages/client/src/components/MkChart.vue b/packages/client/src/components/MkChart.vue index c11c36e43..adfed3fb3 100644 --- a/packages/client/src/components/MkChart.vue +++ b/packages/client/src/components/MkChart.vue @@ -365,235 +365,6 @@ const exportData = () => { // TODO }; -const fetchFederationChart = async (): Promise => { - const raw = await os.apiGet("charts/federation", { - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Received", - type: "area", - data: format(raw.inboxInstances), - color: colors.blue, - }, - { - name: "Delivered", - type: "area", - data: format(raw.deliveredInstances), - color: colors.green, - }, - { - name: "Stalled", - type: "area", - data: format(raw.stalled), - color: colors.red, - }, - { - name: "Pub Active", - type: "line", - data: format(raw.pubActive), - color: colors.purple, - }, - { - name: "Sub Active", - type: "line", - data: format(raw.subActive), - color: colors.orange, - }, - { - name: "Pub & Sub", - type: "line", - data: format(raw.pubsub), - dashed: true, - color: colors.cyan, - }, - { - name: "Pub", - type: "line", - data: format(raw.pub), - dashed: true, - color: colors.purple, - }, - { - name: "Sub", - type: "line", - data: format(raw.sub), - dashed: true, - color: colors.orange, - }, - ], - }; -}; - -const fetchApRequestChart = async (): Promise => { - const raw = await os.apiGet("charts/ap-request", { - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "In", - type: "area", - color: "#31748f", - data: format(raw.inboxReceived), - }, - { - name: "Out (succ)", - type: "area", - color: "#c4a7e7", - data: format(raw.deliverSucceeded), - }, - { - name: "Out (fail)", - type: "area", - color: "#f6c177", - data: format(raw.deliverFailed), - }, - ], - }; -}; - -const fetchNotesChart = async (type: string): Promise => { - const raw = await os.apiGet("charts/notes", { - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "All", - type: "line", - data: format( - type === "combined" - ? sum( - raw.local.inc, - negate(raw.local.dec), - raw.remote.inc, - negate(raw.remote.dec), - ) - : sum(raw[type].inc, negate(raw[type].dec)), - ), - color: "#888888", - }, - { - name: "Renotes", - type: "area", - data: format( - type === "combined" - ? sum(raw.local.diffs.renote, raw.remote.diffs.renote) - : raw[type].diffs.renote, - ), - color: colors.green, - }, - { - name: "Replies", - type: "area", - data: format( - type === "combined" - ? sum(raw.local.diffs.reply, raw.remote.diffs.reply) - : raw[type].diffs.reply, - ), - color: colors.yellow, - }, - { - name: "Normal", - type: "area", - data: format( - type === "combined" - ? sum(raw.local.diffs.normal, raw.remote.diffs.normal) - : raw[type].diffs.normal, - ), - color: colors.blue, - }, - { - name: "With file", - type: "area", - data: format( - type === "combined" - ? sum( - raw.local.diffs.withFile, - raw.remote.diffs.withFile, - ) - : raw[type].diffs.withFile, - ), - color: colors.purple, - }, - ], - }; -}; - -const fetchNotesTotalChart = async (): Promise => { - const raw = await os.apiGet("charts/notes", { - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Combined", - type: "line", - data: format(sum(raw.local.total, raw.remote.total)), - }, - { - name: "Local", - type: "area", - data: format(raw.local.total), - }, - { - name: "Remote", - type: "area", - data: format(raw.remote.total), - }, - ], - }; -}; - -const fetchUsersChart = async (total: boolean): Promise => { - const raw = await os.apiGet("charts/users", { - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Combined", - type: "line", - data: format( - total - ? sum(raw.local.total, raw.remote.total) - : sum( - raw.local.inc, - negate(raw.local.dec), - raw.remote.inc, - negate(raw.remote.dec), - ), - ), - }, - { - name: "Local", - type: "area", - data: format( - total - ? raw.local.total - : sum(raw.local.inc, negate(raw.local.dec)), - ), - }, - { - name: "Remote", - type: "area", - data: format( - total - ? raw.remote.total - : sum(raw.remote.inc, negate(raw.remote.dec)), - ), - }, - ], - }; -}; - const fetchActiveUsersChart = async (): Promise => { const raw = await os.apiGet("charts/active-users", { limit: props.limit, @@ -659,424 +430,13 @@ const fetchActiveUsersChart = async (): Promise => { }; }; -const fetchDriveChart = async (): Promise => { - const raw = await os.apiGet("charts/drive", { - limit: props.limit, - span: props.span, - }); - return { - bytes: true, - series: [ - { - name: "All", - type: "line", - dashed: true, - data: format( - sum( - raw.local.incSize, - negate(raw.local.decSize), - raw.remote.incSize, - negate(raw.remote.decSize), - ), - ), - }, - { - name: "Local +", - type: "area", - data: format(raw.local.incSize), - }, - { - name: "Local -", - type: "area", - data: format(negate(raw.local.decSize)), - }, - { - name: "Remote +", - type: "area", - data: format(raw.remote.incSize), - }, - { - name: "Remote -", - type: "area", - data: format(negate(raw.remote.decSize)), - }, - ], - }; -}; - -const fetchDriveFilesChart = async (): Promise => { - const raw = await os.apiGet("charts/drive", { - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "All", - type: "line", - dashed: true, - data: format( - sum( - raw.local.incCount, - negate(raw.local.decCount), - raw.remote.incCount, - negate(raw.remote.decCount), - ), - ), - }, - { - name: "Local +", - type: "area", - data: format(raw.local.incCount), - }, - { - name: "Local -", - type: "area", - data: format(negate(raw.local.decCount)), - }, - { - name: "Remote +", - type: "area", - data: format(raw.remote.incCount), - }, - { - name: "Remote -", - type: "area", - data: format(negate(raw.remote.decCount)), - }, - ], - }; -}; - -const fetchInstanceRequestsChart = async (): Promise => { - const raw = await os.apiGet("charts/instance", { - host: props.args.host, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "In", - type: "area", - color: "#31748f", - data: format(raw.requests.received), - }, - { - name: "Out (succ)", - type: "area", - color: "#c4a7e7", - data: format(raw.requests.succeeded), - }, - { - name: "Out (fail)", - type: "area", - color: "#f6c177", - data: format(raw.requests.failed), - }, - ], - }; -}; - -const fetchInstanceUsersChart = async ( - total: boolean, -): Promise => { - const raw = await os.apiGet("charts/instance", { - host: props.args.host, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Users", - type: "area", - color: "#31748f", - data: format( - total - ? raw.users.total - : sum(raw.users.inc, negate(raw.users.dec)), - ), - }, - ], - }; -}; - -const fetchInstanceNotesChart = async ( - total: boolean, -): Promise => { - const raw = await os.apiGet("charts/instance", { - host: props.args.host, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Posts", - type: "area", - color: "#31748f", - data: format( - total - ? raw.notes.total - : sum(raw.notes.inc, negate(raw.notes.dec)), - ), - }, - ], - }; -}; - -const fetchInstanceFfChart = async ( - total: boolean, -): Promise => { - const raw = await os.apiGet("charts/instance", { - host: props.args.host, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Following", - type: "area", - color: "#31748f", - data: format( - total - ? raw.following.total - : sum(raw.following.inc, negate(raw.following.dec)), - ), - }, - { - name: "Followers", - type: "area", - color: "#c4a7e7", - data: format( - total - ? raw.followers.total - : sum(raw.followers.inc, negate(raw.followers.dec)), - ), - }, - ], - }; -}; - -const fetchInstanceDriveUsageChart = async ( - total: boolean, -): Promise => { - const raw = await os.apiGet("charts/instance", { - host: props.args.host, - limit: props.limit, - span: props.span, - }); - return { - bytes: true, - series: [ - { - name: "Drive usage", - type: "area", - color: "#31748f", - data: format( - total - ? raw.drive.totalUsage - : sum(raw.drive.incUsage, negate(raw.drive.decUsage)), - ), - }, - ], - }; -}; - -const fetchInstanceDriveFilesChart = async ( - total: boolean, -): Promise => { - const raw = await os.apiGet("charts/instance", { - host: props.args.host, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Drive files", - type: "area", - color: "#31748f", - data: format( - total - ? raw.drive.totalFiles - : sum(raw.drive.incFiles, negate(raw.drive.decFiles)), - ), - }, - ], - }; -}; - -const fetchPerUserNotesChart = async (): Promise => { - const raw = await os.apiGet("charts/user/notes", { - userId: props.args.user.id, - limit: props.limit, - span: props.span, - }); - return { - series: [ - ...(props.args.withoutAll - ? [] - : [ - { - name: "All", - type: "line", - data: format(sum(raw.inc, negate(raw.dec))), - color: "#888888", - }, - ]), - { - name: "With file", - type: "area", - data: format(raw.diffs.withFile), - color: colors.purple, - }, - { - name: "Renotes", - type: "area", - data: format(raw.diffs.renote), - color: colors.green, - }, - { - name: "Replies", - type: "area", - data: format(raw.diffs.reply), - color: colors.yellow, - }, - { - name: "Normal", - type: "area", - data: format(raw.diffs.normal), - color: colors.blue, - }, - ], - }; -}; - -const fetchPerUserFollowingChart = async (): Promise => { - const raw = await os.apiGet("charts/user/following", { - userId: props.args.user.id, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Local", - type: "area", - data: format(raw.local.followings.total), - }, - { - name: "Remote", - type: "area", - data: format(raw.remote.followings.total), - }, - ], - }; -}; - -const fetchPerUserFollowersChart = async (): Promise => { - const raw = await os.apiGet("charts/user/following", { - userId: props.args.user.id, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Local", - type: "area", - data: format(raw.local.followers.total), - }, - { - name: "Remote", - type: "area", - data: format(raw.remote.followers.total), - }, - ], - }; -}; - -const fetchPerUserDriveChart = async (): Promise => { - const raw = await os.apiGet("charts/user/drive", { - userId: props.args.user.id, - limit: props.limit, - span: props.span, - }); - return { - series: [ - { - name: "Inc", - type: "area", - data: format(raw.incSize), - }, - { - name: "Dec", - type: "area", - data: format(raw.decSize), - }, - ], - }; -}; - const fetchAndRender = async () => { const fetchData = () => { switch (props.src) { - case "federation": - return fetchFederationChart(); - case "ap-request": - return fetchApRequestChart(); - case "users": - return fetchUsersChart(false); - case "users-total": - return fetchUsersChart(true); case "active-users": return fetchActiveUsersChart(); - case "notes": - return fetchNotesChart("combined"); - case "local-notes": - return fetchNotesChart("local"); - case "remote-notes": - return fetchNotesChart("remote"); - case "notes-total": - return fetchNotesTotalChart(); - case "drive": - return fetchDriveChart(); - case "drive-files": - return fetchDriveFilesChart(); - case "instance-requests": - return fetchInstanceRequestsChart(); - case "instance-users": - return fetchInstanceUsersChart(false); - case "instance-users-total": - return fetchInstanceUsersChart(true); - case "instance-notes": - return fetchInstanceNotesChart(false); - case "instance-notes-total": - return fetchInstanceNotesChart(true); - case "instance-ff": - return fetchInstanceFfChart(false); - case "instance-ff-total": - return fetchInstanceFfChart(true); - case "instance-drive-usage": - return fetchInstanceDriveUsageChart(false); - case "instance-drive-usage-total": - return fetchInstanceDriveUsageChart(true); - case "instance-drive-files": - return fetchInstanceDriveFilesChart(false); - case "instance-drive-files-total": - return fetchInstanceDriveFilesChart(true); - - case "per-user-notes": - return fetchPerUserNotesChart(); - case "per-user-following": - return fetchPerUserFollowingChart(); - case "per-user-followers": - return fetchPerUserFollowersChart(); - case "per-user-drive": - return fetchPerUserDriveChart(); + default: + console.error(`${props.src} chart is disabled.`); } }; fetching.value = true; diff --git a/packages/client/src/components/MkInstanceCardMini.vue b/packages/client/src/components/MkInstanceCardMini.vue index 81aa52dc2..54b4b3197 100644 --- a/packages/client/src/components/MkInstanceCardMini.vue +++ b/packages/client/src/components/MkInstanceCardMini.vue @@ -19,7 +19,6 @@ {{ instance.softwareVersion }} - @@ -27,7 +26,6 @@ import { ref } from "vue"; import type * as firefish from "firefish-js"; -import MkMiniChart from "@/components/MkMiniChart.vue"; import * as os from "@/os"; import { getProxiedImageUrlNullable } from "@/scripts/media-proxy"; @@ -35,18 +33,6 @@ const props = defineProps<{ instance: firefish.entities.Instance; }>(); -const chartValues = ref(null); - -os.apiGet("charts/instance", { - host: props.instance.host, - limit: 16 + 1, - span: "day", -}).then((res) => { - // 今日のぶんの値はまだ途中の値であり、それも含めると大抵の場合前日よりも下降しているようなグラフになってしまうため今日は弾く - res.requests.received.splice(0, 1); - chartValues.value = res.requests.received; -}); - function getInstanceIcon(instance): string { return ( getProxiedImageUrlNullable(instance.iconUrl, "preview") ?? @@ -104,10 +90,6 @@ function getInstanceIcon(instance): string { } } - > :global(.chart) { - height: 30px; - } - &:global(.yellow) { --c: rgb(255 196 0 / 15%); background-image: linear-gradient( diff --git a/packages/client/src/components/MkInstanceStats.vue b/packages/client/src/components/MkInstanceStats.vue index 768c55344..9e4ff2b52 100644 --- a/packages/client/src/components/MkInstanceStats.vue +++ b/packages/client/src/components/MkInstanceStats.vue @@ -1,52 +1,9 @@ @@ -27,35 +26,17 @@ import { ref } from "vue"; import type * as misskey from "firefish-js"; -import MkMiniChart from "@/components/MkMiniChart.vue"; -import * as os from "@/os"; import { acct, userPage } from "@/filters/user"; const props = withDefaults( defineProps<{ user: misskey.entities.User; - withChart?: boolean; showAboutPage?: boolean; }>(), { - withChart: true, showAboutPage: false, }, ); - -const chartValues = ref(null); - -if (props.withChart) { - os.apiGet("charts/user/notes", { - userId: props.user.id, - limit: 16 + 1, - span: "day", - }).then((res) => { - // 今日のぶんの値はまだ途中の値であり、それも含めると大抵の場合前日よりも下降しているようなグラフになってしまうため今日は弾く - res.inc.splice(0, 1); - chartValues.value = res.inc; - }); -} diff --git a/packages/client/src/pages/admin/overview.federation.vue b/packages/client/src/pages/admin/overview.federation.vue index 9c25d81b4..d12af324e 100644 --- a/packages/client/src/pages/admin/overview.federation.vue +++ b/packages/client/src/pages/admin/overview.federation.vue @@ -17,40 +17,6 @@
Top 10
-
-
-
- -
-
-
- {{ number(federationSubActive) }} - -
-
Sub
-
-
-
-
- -
-
-
- {{ number(federationPubActive) }} - -
-
Pub
-
-
-
diff --git a/packages/client/src/pages/admin/overview.heatmap.vue b/packages/client/src/pages/admin/overview.heatmap.vue index 886e433ee..a62dbd327 100644 --- a/packages/client/src/pages/admin/overview.heatmap.vue +++ b/packages/client/src/pages/admin/overview.heatmap.vue @@ -1,29 +1,11 @@ diff --git a/packages/client/src/pages/admin/overview.vue b/packages/client/src/pages/admin/overview.vue index ed5dfa3ed..45a47a755 100644 --- a/packages/client/src/pages/admin/overview.vue +++ b/packages/client/src/pages/admin/overview.vue @@ -9,10 +9,6 @@ - - - - @@ -31,11 +27,6 @@ - - - - - @@ -71,7 +62,6 @@ import { import XFederation from "./overview.federation.vue"; import XInstances from "./overview.instances.vue"; import XQueue from "./overview.queue.vue"; -import XApRequests from "./overview.ap-requests.vue"; import XUsers from "./overview.users.vue"; import XActiveUsers from "./overview.active-users.vue"; import XStats from "./overview.stats.vue"; diff --git a/packages/client/src/pages/instance-info.vue b/packages/client/src/pages/instance-info.vue index 6a5e8c6e9..7eb45f243 100644 --- a/packages/client/src/pages/instance-info.vue +++ b/packages/client/src/pages/instance-info.vue @@ -223,79 +223,6 @@ - -
-
-
- - - - - - - - - - - - - -
-
-
- {{ i18n.t("recentNHours", { n: 90 }) }} -
- -
- {{ i18n.t("recentNDays", { n: 90 }) }} -
- -
-
-
-
(); const tabs = ["overview"]; -if (iAmAdmin) tabs.push("chart", "users", "raw"); +if (iAmAdmin) tabs.push("users", "raw"); const tab = ref(tabs[0]); watch(tab, () => syncSlide(tabs.indexOf(tab.value))); -const chartSrc = ref("instance-requests"); const meta = ref(null); const instance = ref(null); const suspended = ref(false); @@ -488,11 +413,6 @@ const theTabs = [ if (iAmAdmin) { theTabs.push( - { - key: "chart", - title: i18n.ts.charts, - icon: "ph-chart-bar ph-bold ph-lg", - }, { key: "users", title: i18n.ts.users, @@ -551,12 +471,5 @@ function syncSlide(index) { display: flex; margin: 0 0 16px 0; } - - > .charts { - > .label { - margin-bottom: 12px; - font-weight: bold; - } - } } diff --git a/packages/client/src/pages/settings/drive.vue b/packages/client/src/pages/settings/drive.vue index e06d530ed..63d20eea5 100644 --- a/packages/client/src/pages/settings/drive.vue +++ b/packages/client/src/pages/settings/drive.vue @@ -17,20 +17,6 @@ - - - - - {{ i18n.ts.uploadFolder }} @@ -82,7 +68,6 @@ import FormSplit from "@/components/form/split.vue"; import * as os from "@/os"; import bytes from "@/filters/bytes"; import { defaultStore } from "@/store"; -import MkChart from "@/components/MkChart.vue"; import { i18n } from "@/i18n"; import { definePageMetadata } from "@/scripts/page-metadata"; import { $i } from "@/account"; diff --git a/packages/client/src/pages/user-info.vue b/packages/client/src/pages/user-info.vue index 1914d5cff..da5794077 100644 --- a/packages/client/src/pages/user-info.vue +++ b/packages/client/src/pages/user-info.vue @@ -335,44 +335,6 @@
-
-
-
- - - -
-
-
- {{ i18n.t("recentNHours", { n: 90 }) }} -
- -
- {{ i18n.t("recentNDays", { n: 90 }) }} -
- -
-
-
@@ -387,7 +349,6 @@ diff --git a/packages/client/src/widgets/activity.calendar.vue b/packages/client/src/widgets/activity.calendar.vue deleted file mode 100644 index 4a6d3cf4a..000000000 --- a/packages/client/src/widgets/activity.calendar.vue +++ /dev/null @@ -1,102 +0,0 @@ - - - - - diff --git a/packages/client/src/widgets/activity.chart.vue b/packages/client/src/widgets/activity.chart.vue deleted file mode 100644 index b8d099a5a..000000000 --- a/packages/client/src/widgets/activity.chart.vue +++ /dev/null @@ -1,136 +0,0 @@ - - - - - diff --git a/packages/client/src/widgets/activity.vue b/packages/client/src/widgets/activity.vue deleted file mode 100644 index beeba81d7..000000000 --- a/packages/client/src/widgets/activity.vue +++ /dev/null @@ -1,124 +0,0 @@ - - - diff --git a/packages/client/src/widgets/federation.vue b/packages/client/src/widgets/federation.vue index a8e121519..5de99897d 100644 --- a/packages/client/src/widgets/federation.vue +++ b/packages/client/src/widgets/federation.vue @@ -37,10 +37,6 @@ {{ instance.softwareVersion }}

- @@ -57,7 +53,6 @@ import { } from "./widget"; import type { GetFormResultType } from "@/scripts/form"; import MkContainer from "@/components/MkContainer.vue"; -import MkMiniChart from "@/components/MkMiniChart.vue"; import * as os from "@/os"; import { useInterval } from "@/scripts/use-interval"; import { i18n } from "@/i18n"; @@ -92,7 +87,6 @@ const { widgetProps, configure } = useWidgetPropsManager( ); const instances = ref([]); -const charts = ref([]); const fetching = ref(true); const fetch = async () => { @@ -100,17 +94,7 @@ const fetch = async () => { sort: "+lastCommunicatedAt", limit: 5, }); - const fetchedCharts = await Promise.all( - fetchedInstances.map((i) => - os.apiGet("charts/instance", { - host: i.host, - limit: 16, - span: "hour", - }), - ), - ); instances.value = fetchedInstances; - charts.value = fetchedCharts; fetching.value = false; }; diff --git a/packages/client/src/widgets/index.ts b/packages/client/src/widgets/index.ts index b99f1b086..f171a7996 100644 --- a/packages/client/src/widgets/index.ts +++ b/packages/client/src/widgets/index.ts @@ -34,10 +34,6 @@ export default function (app: App) { "MkwClock", defineAsyncComponent(() => import("./clock.vue")), ); - app.component( - "MkwActivity", - defineAsyncComponent(() => import("./activity.vue")), - ); app.component( "MkwPhotos", defineAsyncComponent(() => import("./photos.vue")), @@ -110,7 +106,6 @@ export const widgets = [ "rssTicker", "trends", "clock", - "activity", "photos", "digitalClock", "unixClock",