Add drive chart

This commit is contained in:
syuilo 2018-08-19 00:45:54 +09:00
parent f59c68022f
commit 8ecf3db608
4 changed files with 94 additions and 1 deletions

View File

@ -946,6 +946,11 @@ desktop/views/pages/admin/admin.users-chart.vue:
local: "ローカル" local: "ローカル"
remote: "リモート" remote: "リモート"
desktop/views/pages/admin/admin.drive-chart.vue:
title: "ドライブ"
local: "ローカル"
remote: "リモート"
desktop/views/pages/deck/deck.tl-column.vue: desktop/views/pages/deck/deck.tl-column.vue:
is-media-only: "メディア投稿のみ" is-media-only: "メディア投稿のみ"
is-media-view: "メディアビュー" is-media-view: "メディアビュー"

View File

@ -0,0 +1,51 @@
<template>
<svg :viewBox="`0 0 ${ viewBoxX } ${ viewBoxY }`">
<polyline
:points="points"
fill="none"
stroke-width="1"
stroke="#555"/>
</svg>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: {
chart: {
required: true
},
type: {
type: String,
required: true
}
},
data() {
return {
viewBoxX: 365,
viewBoxY: 70,
points: null
};
},
created() {
const peak = Math.max.apply(null, this.chart.map(d => this.type == 'local' ? d.drive.local.totalSize : d.drive.remote.totalSize));
if (peak != 0) {
const data = this.chart.slice().reverse().map(x => ({
size: this.type == 'local' ? x.drive.local.totalSize : x.drive.remote.totalSize
}));
this.points = data.map((d, i) => `${i},${(1 - (d.size / peak)) * this.viewBoxY}`).join(' ');
}
}
});
</script>
<style lang="stylus" scoped>
svg
display block
padding 10px
width 100%
</style>

View File

@ -0,0 +1,34 @@
<template>
<div class="card">
<header>%i18n:@title%</header>
<div class="card">
<header>%i18n:@local%</header>
<x-chart v-if="chart" :chart="chart" type="local"/>
</div>
<div class="card">
<header>%i18n:@remote%</header>
<x-chart v-if="chart" :chart="chart" type="remote"/>
</div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import XChart from "./admin.drive-chart.chart.vue";
export default Vue.extend({
components: {
XChart
},
props: {
chart: {
required: true
}
}
});
</script>
<style lang="stylus" scoped>
@import '~const.styl'
</style>

View File

@ -13,6 +13,7 @@
<x-dashboard/> <x-dashboard/>
<x-users-chart :chart="chart"/> <x-users-chart :chart="chart"/>
<x-notes-chart :chart="chart"/> <x-notes-chart :chart="chart"/>
<x-drive-chart :chart="chart"/>
</div> </div>
<div v-if="page == 'users'"> <div v-if="page == 'users'">
<x-suspend-user/> <x-suspend-user/>
@ -35,6 +36,7 @@ import XVerifyUser from "./admin.verify-user.vue";
import XUnverifyUser from "./admin.unverify-user.vue"; import XUnverifyUser from "./admin.unverify-user.vue";
import XUsersChart from "./admin.users-chart.vue"; import XUsersChart from "./admin.users-chart.vue";
import XNotesChart from "./admin.notes-chart.vue"; import XNotesChart from "./admin.notes-chart.vue";
import XDriveChart from "./admin.drive-chart.vue";
export default Vue.extend({ export default Vue.extend({
components: { components: {
@ -44,7 +46,8 @@ export default Vue.extend({
XVerifyUser, XVerifyUser,
XUnverifyUser, XUnverifyUser,
XUsersChart, XUsersChart,
XNotesChart XNotesChart,
XDriveChart
}, },
data() { data() {
return { return {