From 4dee7d91b17148c5c3ee12c3bee193fccaeb22b6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 24 Aug 2018 05:37:19 +0900 Subject: [PATCH] Better charts --- locales/ja-JP.yml | 28 +-- package.json | 2 + .../views/pages/admin/admin.chart.chart.ts | 40 ++++ .../desktop/views/pages/admin/admin.chart.vue | 195 ++++++++++++++++++ .../pages/admin/admin.drive-chart.chart.vue | 74 ------- .../views/pages/admin/admin.drive-chart.vue | 34 --- .../pages/admin/admin.notes-chart.chart.vue | 99 --------- .../views/pages/admin/admin.notes-chart.vue | 34 --- .../pages/admin/admin.users-chart.chart.vue | 74 ------- .../views/pages/admin/admin.users-chart.vue | 34 --- .../app/desktop/views/pages/admin/admin.vue | 12 +- src/server/api/endpoints/admin/chart.ts | 3 +- 12 files changed, 255 insertions(+), 374 deletions(-) create mode 100644 src/client/app/desktop/views/pages/admin/admin.chart.chart.ts create mode 100644 src/client/app/desktop/views/pages/admin/admin.chart.vue delete mode 100644 src/client/app/desktop/views/pages/admin/admin.drive-chart.chart.vue delete mode 100644 src/client/app/desktop/views/pages/admin/admin.drive-chart.vue delete mode 100644 src/client/app/desktop/views/pages/admin/admin.notes-chart.chart.vue delete mode 100644 src/client/app/desktop/views/pages/admin/admin.notes-chart.vue delete mode 100644 src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue delete mode 100644 src/client/app/desktop/views/pages/admin/admin.users-chart.vue diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index dfcdb59e1c..31b81f1d7e 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -939,20 +939,20 @@ desktop/views/pages/admin/admin.unverify-user.vue: unverify: "公式アカウントを解除する" unverified: "公式アカウントを解除しました" -desktop/views/pages/admin/admin.notes-chart.vue: - title: "投稿" - local: "ローカル" - remote: "リモート" - -desktop/views/pages/admin/admin.users-chart.vue: - title: "ユーザー" - local: "ローカル" - remote: "リモート" - -desktop/views/pages/admin/admin.drive-chart.vue: - title: "ドライブ" - local: "ローカル" - remote: "リモート" +desktop/views/pages/admin/admin.chart.vue: + title: "チャート" + local-notes: "ローカルの投稿" + remote-notes: "リモートの投稿" + local-notes-total: "ローカルの投稿 (累計)" + remote-notes-total: "リモートの投稿 (累計)" + local-users: "ローカルのユーザー" + remote-users: "リモートのユーザー" + local-users-total: "ローカルのユーザー (累計)" + remote-users-total: "リモートのユーザー (累計)" + local-drive: "ローカルのドライブ使用量" + remote-drive: "リモートのドライブ使用量" + local-drive-total: "ローカルのドライブ使用量 (累計)" + remote-drive-total: "リモートのドライブ使用量 (累計)" desktop/views/pages/deck/deck.tl-column.vue: is-media-only: "メディア投稿のみ" diff --git a/package.json b/package.json index e2c9283bf0..3c95d05416 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "bootstrap-vue": "2.0.0-rc.11", "cafy": "11.3.0", "chalk": "2.4.1", + "chart.js": "2.7.2", "commander": "2.17.1", "crc-32": "1.2.0", "css-loader": "1.0.0", @@ -206,6 +207,7 @@ "uuid": "3.3.2", "v-animate-css": "0.0.2", "vue": "2.5.17", + "vue-chartjs": "3.4.0", "vue-cropperjs": "2.2.1", "vue-js-modal": "1.3.18", "vue-json-tree-view": "2.1.4", diff --git a/src/client/app/desktop/views/pages/admin/admin.chart.chart.ts b/src/client/app/desktop/views/pages/admin/admin.chart.chart.ts new file mode 100644 index 0000000000..62043b21dc --- /dev/null +++ b/src/client/app/desktop/views/pages/admin/admin.chart.chart.ts @@ -0,0 +1,40 @@ +import Vue from 'vue'; +import { Line } from 'vue-chartjs'; + +export default Vue.extend({ + extends: Line, + props: { + data: { + required: true + }, + opts: { + required: false + } + }, + watch: { + data() { + this.render(); + } + }, + mounted() { + this.render(); + }, + methods: { + render() { + this.renderChart(this.data, Object.assign({ + responsive: false, + scales: { + xAxes: [{ + type: 'time', + time: { + displayFormats: { + quarter: 'YYYY/MM/D h:mm' + } + }, + distribution: 'series' + }] + } + }, this.opts || {})); + } + } +}); diff --git a/src/client/app/desktop/views/pages/admin/admin.chart.vue b/src/client/app/desktop/views/pages/admin/admin.chart.vue new file mode 100644 index 0000000000..c92caeb2f0 --- /dev/null +++ b/src/client/app/desktop/views/pages/admin/admin.chart.vue @@ -0,0 +1,195 @@ + + + + + diff --git a/src/client/app/desktop/views/pages/admin/admin.drive-chart.chart.vue b/src/client/app/desktop/views/pages/admin/admin.drive-chart.chart.vue deleted file mode 100644 index 97f05571c3..0000000000 --- a/src/client/app/desktop/views/pages/admin/admin.drive-chart.chart.vue +++ /dev/null @@ -1,74 +0,0 @@ - - - - - diff --git a/src/client/app/desktop/views/pages/admin/admin.drive-chart.vue b/src/client/app/desktop/views/pages/admin/admin.drive-chart.vue deleted file mode 100644 index 4f94fd2372..0000000000 --- a/src/client/app/desktop/views/pages/admin/admin.drive-chart.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - - - diff --git a/src/client/app/desktop/views/pages/admin/admin.notes-chart.chart.vue b/src/client/app/desktop/views/pages/admin/admin.notes-chart.chart.vue deleted file mode 100644 index fabb3f1bd1..0000000000 --- a/src/client/app/desktop/views/pages/admin/admin.notes-chart.chart.vue +++ /dev/null @@ -1,99 +0,0 @@ - - - - - diff --git a/src/client/app/desktop/views/pages/admin/admin.notes-chart.vue b/src/client/app/desktop/views/pages/admin/admin.notes-chart.vue deleted file mode 100644 index e4d396d9c6..0000000000 --- a/src/client/app/desktop/views/pages/admin/admin.notes-chart.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - - - diff --git a/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue b/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue deleted file mode 100644 index 45ecc13929..0000000000 --- a/src/client/app/desktop/views/pages/admin/admin.users-chart.chart.vue +++ /dev/null @@ -1,74 +0,0 @@ - - - - - diff --git a/src/client/app/desktop/views/pages/admin/admin.users-chart.vue b/src/client/app/desktop/views/pages/admin/admin.users-chart.vue deleted file mode 100644 index e620012702..0000000000 --- a/src/client/app/desktop/views/pages/admin/admin.users-chart.vue +++ /dev/null @@ -1,34 +0,0 @@ - - - - - diff --git a/src/client/app/desktop/views/pages/admin/admin.vue b/src/client/app/desktop/views/pages/admin/admin.vue index cbb1890cc3..066c1a4f4f 100644 --- a/src/client/app/desktop/views/pages/admin/admin.vue +++ b/src/client/app/desktop/views/pages/admin/admin.vue @@ -11,9 +11,7 @@
- - - +
@@ -34,9 +32,7 @@ import XSuspendUser from "./admin.suspend-user.vue"; import XUnsuspendUser from "./admin.unsuspend-user.vue"; import XVerifyUser from "./admin.verify-user.vue"; import XUnverifyUser from "./admin.unverify-user.vue"; -import XUsersChart from "./admin.users-chart.vue"; -import XNotesChart from "./admin.notes-chart.vue"; -import XDriveChart from "./admin.drive-chart.vue"; +import XChart from "./admin.chart.vue"; export default Vue.extend({ components: { @@ -45,9 +41,7 @@ export default Vue.extend({ XUnsuspendUser, XVerifyUser, XUnverifyUser, - XUsersChart, - XNotesChart, - XDriveChart + XChart }, data() { return { diff --git a/src/server/api/endpoints/admin/chart.ts b/src/server/api/endpoints/admin/chart.ts index 1897879d65..1b88af00bd 100644 --- a/src/server/api/endpoints/admin/chart.ts +++ b/src/server/api/endpoints/admin/chart.ts @@ -8,7 +8,7 @@ export const meta = { }; export default (params: any) => new Promise(async (res, rej) => { - const daysRange = 365; + const daysRange = 90; const hoursRange = 24; const now = new Date(); @@ -123,7 +123,6 @@ export default (params: any) => new Promise(async (res, rej) => { } chart.forEach(x => { - delete x.date; delete (x as any).span; });