Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit ba8140c

Browse files
adzukimamezyoshokasyuilo
authored
cherry-pick: fix weird AP delivered chart in control panel (#231)
fix(frontend): weird AP delivered chart in control panel (# 14481) * fix(frontend): `Out: Fail` was negative number * fix(frontend): don't stack AP delivered chart * test(misskey-dev#10336): add `pages/admin/overview.ap-requests.vue` story * Update CHANGELOG.md --------- Co-authored-by: zyoshoka <[email protected]> Co-authored-by: syuilo <[email protected]>
1 parent fd9fe56 commit ba8140c

File tree

4 files changed

+51
-7
lines changed

4 files changed

+51
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- サイズ制限を超過するファイルをアップロードしようとした際にエラーを出すように
99
- Enhance: アイコンデコレーション管理画面にプレビューを追加
1010
- Fix: サーバーメトリクスが2つ以上あるとリロード直後の表示がおかしくなる問題を修正
11+
- Fix: コントロールパネル内のAp requests内のチャートの表示がおかしかった問題を修正
1112
- Fix: 月の違う同じ日はセパレータが表示されないのを修正
1213
- Fix: タッチ画面でレンジスライダーを操作するとツールチップが複数表示される問題を修正
1314
(Cherry-picked from https://github.com/taiyme/misskey/pull/265)

packages/frontend/.storybook/generate.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,9 @@ function toStories(component: string): Promise<string> {
402402
glob('src/components/MkSignupServerRules.vue'),
403403
glob('src/components/MkInstanceCardMini.vue'),
404404
glob('src/components/MkInviteCode.vue'),
405-
glob('src/pages/search.vue'),
405+
glob('src/pages/admin/overview.ap-requests.vue'),
406406
glob('src/pages/user/home.vue'),
407+
glob('src/pages/search.vue'),
407408
]);
408409
const components = globs.flat();
409410
await Promise.all(components.map(async (component) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* SPDX-FileCopyrightText: syuilo and misskey-project
3+
* SPDX-License-Identifier: AGPL-3.0-only
4+
*/
5+
6+
import { StoryObj } from '@storybook/vue3';
7+
import { http, HttpResponse } from 'msw';
8+
import { action } from '@storybook/addon-actions';
9+
import { commonHandlers } from '../../../.storybook/mocks.js';
10+
import overview_ap_requests from './overview.ap-requests.vue';
11+
export const Default = {
12+
render(args) {
13+
return {
14+
components: {
15+
overview_ap_requests,
16+
},
17+
setup() {
18+
return {
19+
args,
20+
};
21+
},
22+
template: '<overview_ap_requests />',
23+
};
24+
},
25+
parameters: {
26+
layout: 'fullscreen',
27+
msw: {
28+
handlers: [
29+
...commonHandlers,
30+
http.post('/api/charts/ap-request', async ({ request }) => {
31+
action('POST /api/charts/ap-request')(await request.json());
32+
return HttpResponse.json({
33+
deliverFailed: [0, 0, 0, 2, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 0, 0, 0, 3, 1, 1, 2, 0, 0],
34+
deliverSucceeded: [0, 1, 51, 34, 136, 189, 51, 17, 17, 34, 1, 17, 18, 51, 34, 68, 287, 0, 17, 33, 32, 96, 96, 0, 49, 64, 0, 32, 0, 32, 81, 48, 65, 1, 16, 50, 90, 148, 33, 43, 72, 127, 17, 138, 78, 91, 78, 91, 13, 52],
35+
inboxReceived: [507, 1173, 1096, 871, 958, 937, 908, 1026, 956, 909, 807, 1002, 832, 995, 1039, 1047, 1109, 930, 711, 835, 764, 679, 835, 958, 634, 654, 691, 895, 811, 676, 1044, 1389, 1318, 863, 887, 952, 1011, 1061, 592, 900, 611, 595, 604, 562, 607, 621, 854, 666, 1197, 644],
36+
});
37+
}),
38+
],
39+
},
40+
},
41+
} satisfies StoryObj<typeof overview_ap_requests>;

packages/frontend/src/pages/admin/overview.ap-requests.vue

+7-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
2323
import { onMounted, shallowRef, ref } from 'vue';
2424
import { Chart } from 'chart.js';
2525
import gradient from 'chartjs-plugin-gradient';
26+
import isChromatic from 'chromatic';
2627
import { misskeyApi } from '@/scripts/misskey-api.js';
2728
import { useChartTooltip } from '@/scripts/use-chart-tooltip.js';
2829
import { chartVLine } from '@/scripts/chart-vline.js';
@@ -41,7 +42,7 @@ const { handler: externalTooltipHandler } = useChartTooltip();
4142
const { handler: externalTooltipHandler2 } = useChartTooltip();
4243

4344
onMounted(async () => {
44-
const now = new Date();
45+
const now = isChromatic() ? new Date('2024-08-31T10:00:00Z') : new Date();
4546

4647
const getDate = (ago: number) => {
4748
const y = now.getFullYear();
@@ -51,14 +52,14 @@ onMounted(async () => {
5152
return new Date(y, m, d - ago);
5253
};
5354

54-
const format = (arr) => {
55+
const format = (arr: number[]) => {
5556
return arr.map((v, i) => ({
5657
x: getDate(i).getTime(),
5758
y: v,
5859
}));
5960
};
6061

61-
const formatMinus = (arr) => {
62+
const formatMinus = (arr: number[]) => {
6263
return arr.map((v, i) => ({
6364
x: getDate(i).getTime(),
6465
y: -v,
@@ -75,7 +76,6 @@ onMounted(async () => {
7576
type: 'line',
7677
data: {
7778
datasets: [{
78-
stack: 'a',
7979
parsing: false,
8080
label: 'Out: Succ',
8181
data: format(raw.deliverSucceeded).slice().reverse(),
@@ -89,7 +89,6 @@ onMounted(async () => {
8989
fill: true,
9090
clip: 8,
9191
}, {
92-
stack: 'a',
9392
parsing: false,
9493
label: 'Out: Fail',
9594
data: formatMinus(raw.deliverFailed).slice().reverse(),
@@ -133,7 +132,6 @@ onMounted(async () => {
133132
min: getDate(chartLimit).getTime(),
134133
},
135134
y: {
136-
stacked: true,
137135
position: 'left',
138136
suggestedMax: 10,
139137
grid: {
@@ -167,6 +165,9 @@ onMounted(async () => {
167165
duration: 0,
168166
},
169167
external: externalTooltipHandler,
168+
callbacks: {
169+
label: context => `${context.dataset.label}: ${Math.abs(context.parsed.y)}`,
170+
},
170171
},
171172
// @ts-expect-error 問題ない
172173
gradient,

0 commit comments

Comments
 (0)