2018-11-03 03:00:23 +09:00
|
|
|
<template>
|
2020-10-17 20:12:00 +09:00
|
|
|
<div class="zbcjwnqg" v-size="{ max: [550, 1000] }">
|
2020-02-17 02:21:27 +09:00
|
|
|
<div class="stats" v-if="info">
|
|
|
|
<div class="_panel">
|
|
|
|
<div>
|
2020-12-26 10:47:36 +09:00
|
|
|
<b><Fa :icon="faUser"/>{{ $ts.users }}</b>
|
|
|
|
<small>{{ $ts.local }}</small>
|
2020-02-17 02:21:27 +09:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<dl class="total">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.total }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(info.originalUsersCount) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: usersLocalDoD > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.dayOverDayChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(usersLocalDoD) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: usersLocalWoW > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.weekOverWeekChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(usersLocalWoW) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="_panel">
|
|
|
|
<div>
|
2020-12-26 10:47:36 +09:00
|
|
|
<b><Fa :icon="faUser"/>{{ $ts.users }}</b>
|
|
|
|
<small>{{ $ts.remote }}</small>
|
2020-02-17 02:21:27 +09:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<dl class="total">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.total }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number((info.usersCount - info.originalUsersCount)) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: usersRemoteDoD > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.dayOverDayChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(usersRemoteDoD) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: usersRemoteWoW > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.weekOverWeekChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(usersRemoteWoW) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="_panel">
|
|
|
|
<div>
|
2020-12-26 10:47:36 +09:00
|
|
|
<b><Fa :icon="faPencilAlt"/>{{ $ts.notes }}</b>
|
|
|
|
<small>{{ $ts.local }}</small>
|
2020-02-17 02:21:27 +09:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<dl class="total">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.total }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(info.originalNotesCount) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: notesLocalDoD > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.dayOverDayChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(notesLocalDoD) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: notesLocalWoW > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.weekOverWeekChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(notesLocalWoW) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="_panel">
|
|
|
|
<div>
|
2020-12-26 10:47:36 +09:00
|
|
|
<b><Fa :icon="faPencilAlt"/>{{ $ts.notes }}</b>
|
|
|
|
<small>{{ $ts.remote }}</small>
|
2020-02-17 02:21:27 +09:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<dl class="total">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.total }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number((info.notesCount - info.originalNotesCount)) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: notesRemoteDoD > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.dayOverDayChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(notesRemoteDoD) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
<dl class="diff" :class="{ inc: notesRemoteWoW > 0 }">
|
2020-12-26 10:47:36 +09:00
|
|
|
<dt>{{ $ts.weekOverWeekChanges }}</dt>
|
2020-10-17 20:12:00 +09:00
|
|
|
<dd>{{ number(notesRemoteWoW) }}</dd>
|
2020-02-17 02:21:27 +09:00
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-01-30 11:10:42 +09:00
|
|
|
<section class="_card">
|
2020-12-26 10:47:36 +09:00
|
|
|
<div class="_title" style="position: relative;"><Fa :icon="faChartBar"/> {{ $ts.statistics }}<button @click="fetchChart" class="_button" style="position: absolute; right: 0; bottom: 0; top: 0; padding: inherit;"><Fa :icon="faSync"/></button></div>
|
2020-02-17 02:21:27 +09:00
|
|
|
<div class="_content" style="margin-top: -8px;">
|
2020-01-30 04:37:25 +09:00
|
|
|
<div class="selects" style="display: flex;">
|
2020-10-17 20:12:00 +09:00
|
|
|
<MkSelect v-model:value="chartSrc" style="margin: 0; flex: 1;">
|
2020-12-26 10:47:36 +09:00
|
|
|
<optgroup :label="$ts.federation">
|
|
|
|
<option value="federation-instances">{{ $ts._charts.federationInstancesIncDec }}</option>
|
|
|
|
<option value="federation-instances-total">{{ $ts._charts.federationInstancesTotal }}</option>
|
2020-01-30 04:37:25 +09:00
|
|
|
</optgroup>
|
2020-12-26 10:47:36 +09:00
|
|
|
<optgroup :label="$ts.users">
|
|
|
|
<option value="users">{{ $ts._charts.usersIncDec }}</option>
|
|
|
|
<option value="users-total">{{ $ts._charts.usersTotal }}</option>
|
|
|
|
<option value="active-users">{{ $ts._charts.activeUsers }}</option>
|
2020-01-30 04:37:25 +09:00
|
|
|
</optgroup>
|
2020-12-26 10:47:36 +09:00
|
|
|
<optgroup :label="$ts.notes">
|
|
|
|
<option value="notes">{{ $ts._charts.notesIncDec }}</option>
|
|
|
|
<option value="local-notes">{{ $ts._charts.localNotesIncDec }}</option>
|
|
|
|
<option value="remote-notes">{{ $ts._charts.remoteNotesIncDec }}</option>
|
|
|
|
<option value="notes-total">{{ $ts._charts.notesTotal }}</option>
|
2020-01-30 04:37:25 +09:00
|
|
|
</optgroup>
|
2020-12-26 10:47:36 +09:00
|
|
|
<optgroup :label="$ts.drive">
|
|
|
|
<option value="drive-files">{{ $ts._charts.filesIncDec }}</option>
|
|
|
|
<option value="drive-files-total">{{ $ts._charts.filesTotal }}</option>
|
|
|
|
<option value="drive">{{ $ts._charts.storageUsageIncDec }}</option>
|
|
|
|
<option value="drive-total">{{ $ts._charts.storageUsageTotal }}</option>
|
2020-01-30 04:37:25 +09:00
|
|
|
</optgroup>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
|
|
|
<MkSelect v-model:value="chartSpan" style="margin: 0;">
|
2020-12-26 10:47:36 +09:00
|
|
|
<option value="hour">{{ $ts.perHour }}</option>
|
|
|
|
<option value="day">{{ $ts.perDay }}</option>
|
2020-10-17 20:12:00 +09:00
|
|
|
</MkSelect>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
|
|
|
<canvas ref="chart"></canvas>
|
2018-11-03 03:00:23 +09:00
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</section>
|
2018-11-03 03:00:23 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { defineComponent, markRaw } from 'vue';
|
2020-08-13 23:02:43 +09:00
|
|
|
import { faChartBar, faUser, faPencilAlt, faSync } from '@fortawesome/free-solid-svg-icons';
|
2020-01-30 04:37:25 +09:00
|
|
|
import Chart from 'chart.js';
|
2020-02-17 02:21:27 +09:00
|
|
|
import MkSelect from './ui/select.vue';
|
2020-10-17 20:12:00 +09:00
|
|
|
import number from '@/filters/number';
|
2018-11-03 03:00:23 +09:00
|
|
|
|
|
|
|
const sum = (...arr) => arr.reduce((r, a) => r.map((b, i) => a[i] + b));
|
|
|
|
const negate = arr => arr.map(x => -x);
|
2020-01-30 04:37:25 +09:00
|
|
|
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})`;
|
|
|
|
};
|
2020-10-17 20:12:00 +09:00
|
|
|
import * as os from '@/os';
|
2018-11-03 03:00:23 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
|
|
|
MkSelect
|
|
|
|
},
|
|
|
|
|
2020-08-09 15:51:02 +09:00
|
|
|
props: {
|
|
|
|
chartLimit: {
|
|
|
|
type: Number,
|
|
|
|
required: false,
|
|
|
|
default: 90
|
|
|
|
},
|
|
|
|
detailed: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-11-03 03:00:23 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2020-02-17 02:21:27 +09:00
|
|
|
info: null,
|
|
|
|
notesLocalWoW: 0,
|
|
|
|
notesLocalDoD: 0,
|
|
|
|
notesRemoteWoW: 0,
|
|
|
|
notesRemoteDoD: 0,
|
|
|
|
usersLocalWoW: 0,
|
|
|
|
usersLocalDoD: 0,
|
|
|
|
usersRemoteWoW: 0,
|
|
|
|
usersRemoteDoD: 0,
|
2020-01-30 04:37:25 +09:00
|
|
|
now: null,
|
2018-11-03 03:00:23 +09:00
|
|
|
chart: null,
|
2020-01-30 04:37:25 +09:00
|
|
|
chartInstance: null,
|
|
|
|
chartSrc: 'notes',
|
|
|
|
chartSpan: 'hour',
|
2020-08-13 23:02:43 +09:00
|
|
|
faChartBar, faUser, faPencilAlt, faSync
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
2018-11-03 03:00:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
data(): any {
|
|
|
|
if (this.chart == null) return null;
|
2020-01-30 04:37:25 +09:00
|
|
|
switch (this.chartSrc) {
|
2018-11-03 03:00:23 +09:00
|
|
|
case 'federation-instances': return this.federationInstancesChart(false);
|
|
|
|
case 'federation-instances-total': return this.federationInstancesChart(true);
|
|
|
|
case 'users': return this.usersChart(false);
|
|
|
|
case 'users-total': return this.usersChart(true);
|
2019-01-17 17:16:08 +09:00
|
|
|
case 'active-users': return this.activeUsersChart();
|
2018-11-03 03:00:23 +09:00
|
|
|
case 'notes': return this.notesChart('combined');
|
|
|
|
case 'local-notes': return this.notesChart('local');
|
|
|
|
case 'remote-notes': return this.notesChart('remote');
|
|
|
|
case 'notes-total': return this.notesTotalChart();
|
|
|
|
case 'drive': return this.driveChart();
|
|
|
|
case 'drive-total': return this.driveTotalChart();
|
|
|
|
case 'drive-files': return this.driveFilesChart();
|
|
|
|
case 'drive-files-total': return this.driveFilesTotalChart();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
stats(): any[] {
|
|
|
|
const stats =
|
2020-01-30 04:37:25 +09:00
|
|
|
this.chartSpan == 'day' ? this.chart.perDay :
|
|
|
|
this.chartSpan == 'hour' ? this.chart.perHour :
|
2018-11-03 03:00:23 +09:00
|
|
|
null;
|
|
|
|
|
|
|
|
return stats;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2020-01-30 04:37:25 +09:00
|
|
|
chartSrc() {
|
|
|
|
this.renderChart();
|
2018-11-03 03:00:23 +09:00
|
|
|
},
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
chartSpan() {
|
|
|
|
this.renderChart();
|
2018-11-03 03:00:23 +09:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
async created() {
|
2020-10-17 20:12:00 +09:00
|
|
|
this.info = await os.api('stats');
|
2020-02-17 02:21:27 +09:00
|
|
|
|
2018-11-03 03:00:23 +09:00
|
|
|
this.now = new Date();
|
|
|
|
|
2020-08-13 23:02:43 +09:00
|
|
|
this.fetchChart();
|
|
|
|
},
|
2018-11-03 03:00:23 +09:00
|
|
|
|
2020-08-13 23:02:43 +09:00
|
|
|
methods: {
|
|
|
|
async fetchChart() {
|
|
|
|
const [perHour, perDay] = await Promise.all([Promise.all([
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('charts/federation', { limit: this.chartLimit, span: 'hour' }),
|
|
|
|
os.api('charts/users', { limit: this.chartLimit, span: 'hour' }),
|
|
|
|
os.api('charts/active-users', { limit: this.chartLimit, span: 'hour' }),
|
|
|
|
os.api('charts/notes', { limit: this.chartLimit, span: 'hour' }),
|
|
|
|
os.api('charts/drive', { limit: this.chartLimit, span: 'hour' }),
|
2020-08-13 23:02:43 +09:00
|
|
|
]), Promise.all([
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('charts/federation', { limit: this.chartLimit, span: 'day' }),
|
|
|
|
os.api('charts/users', { limit: this.chartLimit, span: 'day' }),
|
|
|
|
os.api('charts/active-users', { limit: this.chartLimit, span: 'day' }),
|
|
|
|
os.api('charts/notes', { limit: this.chartLimit, span: 'day' }),
|
|
|
|
os.api('charts/drive', { limit: this.chartLimit, span: 'day' }),
|
2020-08-13 23:02:43 +09:00
|
|
|
])]);
|
2018-11-03 03:00:23 +09:00
|
|
|
|
2020-08-13 23:02:43 +09:00
|
|
|
const chart = {
|
|
|
|
perHour: {
|
|
|
|
federation: perHour[0],
|
|
|
|
users: perHour[1],
|
|
|
|
activeUsers: perHour[2],
|
|
|
|
notes: perHour[3],
|
|
|
|
drive: perHour[4],
|
|
|
|
},
|
|
|
|
perDay: {
|
|
|
|
federation: perDay[0],
|
|
|
|
users: perDay[1],
|
|
|
|
activeUsers: perDay[2],
|
|
|
|
notes: perDay[3],
|
|
|
|
drive: perDay[4],
|
|
|
|
}
|
|
|
|
};
|
2020-02-17 02:21:27 +09:00
|
|
|
|
2020-08-13 23:02:43 +09:00
|
|
|
this.notesLocalWoW = this.info.originalNotesCount - chart.perDay.notes.local.total[7];
|
|
|
|
this.notesLocalDoD = this.info.originalNotesCount - chart.perDay.notes.local.total[1];
|
|
|
|
this.notesRemoteWoW = (this.info.notesCount - this.info.originalNotesCount) - chart.perDay.notes.remote.total[7];
|
|
|
|
this.notesRemoteDoD = (this.info.notesCount - this.info.originalNotesCount) - chart.perDay.notes.remote.total[1];
|
|
|
|
this.usersLocalWoW = this.info.originalUsersCount - chart.perDay.users.local.total[7];
|
|
|
|
this.usersLocalDoD = this.info.originalUsersCount - chart.perDay.users.local.total[1];
|
|
|
|
this.usersRemoteWoW = (this.info.usersCount - this.info.originalUsersCount) - chart.perDay.users.remote.total[7];
|
|
|
|
this.usersRemoteDoD = (this.info.usersCount - this.info.originalUsersCount) - chart.perDay.users.remote.total[1];
|
2018-11-03 03:00:23 +09:00
|
|
|
|
2020-08-13 23:02:43 +09:00
|
|
|
this.chart = chart;
|
|
|
|
|
|
|
|
this.renderChart();
|
|
|
|
},
|
2018-11-09 18:38:10 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
renderChart() {
|
2018-11-03 03:00:23 +09:00
|
|
|
if (this.chartInstance) {
|
|
|
|
this.chartInstance.destroy();
|
|
|
|
}
|
|
|
|
|
2020-08-09 15:51:02 +09:00
|
|
|
// TODO: var(--panel)の色が暗いか明るいかで判定する
|
2020-12-19 10:55:52 +09:00
|
|
|
const gridColor = this.$store.state.darkMode ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)';
|
2020-08-09 15:51:02 +09:00
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
Chart.defaults.global.defaultFontColor = getComputedStyle(document.documentElement).getPropertyValue('--fg');
|
2020-10-17 20:12:00 +09:00
|
|
|
this.chartInstance = markRaw(new Chart(this.$refs.chart, {
|
2020-01-30 04:37:25 +09:00
|
|
|
type: 'line',
|
|
|
|
data: {
|
2020-08-09 15:51:02 +09:00
|
|
|
labels: new Array(this.chartLimit).fill(0).map((_, i) => this.getDate(i).toLocaleString()).slice().reverse(),
|
2020-01-30 04:37:25 +09:00
|
|
|
datasets: this.data.series.map(x => ({
|
|
|
|
label: x.name,
|
|
|
|
data: x.data.slice().reverse(),
|
|
|
|
pointRadius: 0,
|
|
|
|
lineTension: 0,
|
|
|
|
borderWidth: 2,
|
|
|
|
borderColor: x.color,
|
2020-08-09 15:51:02 +09:00
|
|
|
borderDash: x.borderDash || [],
|
2020-01-30 04:37:25 +09:00
|
|
|
backgroundColor: alpha(x.color, 0.1),
|
2020-08-10 12:28:35 +09:00
|
|
|
fill: x.fill == null ? true : x.fill,
|
2020-01-30 04:37:25 +09:00
|
|
|
hidden: !!x.hidden
|
|
|
|
}))
|
2018-11-03 03:00:23 +09:00
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
options: {
|
|
|
|
aspectRatio: 2.5,
|
|
|
|
layout: {
|
|
|
|
padding: {
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
top: 16,
|
|
|
|
bottom: 0
|
2019-03-15 01:43:11 +09:00
|
|
|
}
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
legend: {
|
|
|
|
position: 'bottom',
|
|
|
|
labels: {
|
|
|
|
boxWidth: 16,
|
2018-11-04 11:08:03 +09:00
|
|
|
}
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
scales: {
|
|
|
|
xAxes: [{
|
2020-08-09 15:51:02 +09:00
|
|
|
type: 'time',
|
|
|
|
time: {
|
|
|
|
stepSize: 1,
|
|
|
|
unit: this.chartSpan == 'day' ? 'month' : 'day',
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
gridLines: {
|
2020-08-09 15:51:02 +09:00
|
|
|
display: this.detailed,
|
|
|
|
color: gridColor,
|
|
|
|
zeroLineColor: gridColor,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
ticks: {
|
2020-08-09 15:51:02 +09:00
|
|
|
display: this.detailed
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}],
|
|
|
|
yAxes: [{
|
2020-08-09 15:51:02 +09:00
|
|
|
position: 'left',
|
|
|
|
gridLines: {
|
|
|
|
color: gridColor,
|
|
|
|
zeroLineColor: gridColor,
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
ticks: {
|
2020-08-09 15:51:02 +09:00
|
|
|
display: this.detailed
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
}]
|
2018-11-04 11:08:03 +09:00
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
tooltips: {
|
|
|
|
intersect: false,
|
|
|
|
mode: 'index',
|
2018-11-04 11:08:03 +09:00
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
}));
|
2018-11-03 03:00:23 +09:00
|
|
|
},
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
getDate(ago: number) {
|
2018-11-03 03:00:23 +09:00
|
|
|
const y = this.now.getFullYear();
|
|
|
|
const m = this.now.getMonth();
|
|
|
|
const d = this.now.getDate();
|
|
|
|
const h = this.now.getHours();
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
return this.chartSpan == 'day' ? new Date(y, m, d - ago) : new Date(y, m, d, h - ago);
|
2018-11-03 03:00:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
format(arr) {
|
2020-08-09 15:51:02 +09:00
|
|
|
const now = Date.now();
|
|
|
|
return arr.map((v, i) => ({
|
|
|
|
x: new Date(now - ((this.chartSpan == 'day' ? 86400000 :3600000 ) * i)),
|
|
|
|
y: v
|
|
|
|
}));
|
2018-11-03 03:00:23 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
federationInstancesChart(total: boolean): any {
|
|
|
|
return {
|
|
|
|
series: [{
|
2019-03-22 14:57:09 +09:00
|
|
|
name: 'Instances',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(total
|
|
|
|
? this.stats.federation.instance.total
|
|
|
|
: sum(this.stats.federation.instance.inc, negate(this.stats.federation.instance.dec))
|
|
|
|
)
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
notesChart(type: string): any {
|
|
|
|
return {
|
|
|
|
series: [{
|
|
|
|
name: 'All',
|
2018-11-03 13:08:49 +09:00
|
|
|
type: 'line',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2020-08-09 15:51:02 +09:00
|
|
|
borderDash: [5, 5],
|
2020-08-10 11:51:43 +09:00
|
|
|
fill: false,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(type == 'combined'
|
|
|
|
? sum(this.stats.notes.local.inc, negate(this.stats.notes.local.dec), this.stats.notes.remote.inc, negate(this.stats.notes.remote.dec))
|
|
|
|
: sum(this.stats.notes[type].inc, negate(this.stats.notes[type].dec))
|
|
|
|
)
|
|
|
|
}, {
|
|
|
|
name: 'Renotes',
|
2018-11-03 13:08:49 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#00E396',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(type == 'combined'
|
|
|
|
? sum(this.stats.notes.local.diffs.renote, this.stats.notes.remote.diffs.renote)
|
|
|
|
: this.stats.notes[type].diffs.renote
|
|
|
|
)
|
|
|
|
}, {
|
|
|
|
name: 'Replies',
|
2018-11-03 13:08:49 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#FEB019',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(type == 'combined'
|
|
|
|
? sum(this.stats.notes.local.diffs.reply, this.stats.notes.remote.diffs.reply)
|
|
|
|
: this.stats.notes[type].diffs.reply
|
|
|
|
)
|
|
|
|
}, {
|
|
|
|
name: 'Normal',
|
2018-11-03 13:08:49 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#FF4560',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(type == 'combined'
|
|
|
|
? sum(this.stats.notes.local.diffs.normal, this.stats.notes.remote.diffs.normal)
|
|
|
|
: this.stats.notes[type].diffs.normal
|
|
|
|
)
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
notesTotalChart(): any {
|
|
|
|
return {
|
|
|
|
series: [{
|
|
|
|
name: 'Combined',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'line',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(sum(this.stats.notes.local.total, this.stats.notes.remote.total))
|
|
|
|
}, {
|
|
|
|
name: 'Local',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.notes.local.total)
|
|
|
|
}, {
|
|
|
|
name: 'Remote',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.notes.remote.total)
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
usersChart(total: boolean): any {
|
|
|
|
return {
|
|
|
|
series: [{
|
|
|
|
name: 'Combined',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'line',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(total
|
|
|
|
? sum(this.stats.users.local.total, this.stats.users.remote.total)
|
|
|
|
: sum(this.stats.users.local.inc, negate(this.stats.users.local.dec), this.stats.users.remote.inc, negate(this.stats.users.remote.dec))
|
|
|
|
)
|
|
|
|
}, {
|
|
|
|
name: 'Local',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(total
|
|
|
|
? this.stats.users.local.total
|
|
|
|
: sum(this.stats.users.local.inc, negate(this.stats.users.local.dec))
|
|
|
|
)
|
|
|
|
}, {
|
|
|
|
name: 'Remote',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(total
|
|
|
|
? this.stats.users.remote.total
|
|
|
|
: sum(this.stats.users.remote.inc, negate(this.stats.users.remote.dec))
|
|
|
|
)
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2019-01-17 17:16:08 +09:00
|
|
|
activeUsersChart(): any {
|
|
|
|
return {
|
|
|
|
series: [{
|
|
|
|
name: 'Combined',
|
|
|
|
type: 'line',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2019-01-17 17:16:08 +09:00
|
|
|
data: this.format(sum(this.stats.activeUsers.local.count, this.stats.activeUsers.remote.count))
|
|
|
|
}, {
|
|
|
|
name: 'Local',
|
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2019-01-17 17:16:08 +09:00
|
|
|
data: this.format(this.stats.activeUsers.local.count)
|
|
|
|
}, {
|
|
|
|
name: 'Remote',
|
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2019-01-17 17:16:08 +09:00
|
|
|
data: this.format(this.stats.activeUsers.remote.count)
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2018-11-03 03:00:23 +09:00
|
|
|
driveChart(): any {
|
|
|
|
return {
|
2018-11-04 11:08:03 +09:00
|
|
|
bytes: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
series: [{
|
|
|
|
name: 'All',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'line',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#09d8e2',
|
|
|
|
borderDash: [5, 5],
|
|
|
|
fill: false,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(
|
|
|
|
sum(
|
|
|
|
this.stats.drive.local.incSize,
|
|
|
|
negate(this.stats.drive.local.decSize),
|
|
|
|
this.stats.drive.remote.incSize,
|
|
|
|
negate(this.stats.drive.remote.decSize)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}, {
|
|
|
|
name: 'Local +',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.local.incSize)
|
|
|
|
}, {
|
|
|
|
name: 'Local -',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#FF4560',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(negate(this.stats.drive.local.decSize))
|
|
|
|
}, {
|
|
|
|
name: 'Remote +',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#00E396',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.remote.incSize)
|
|
|
|
}, {
|
|
|
|
name: 'Remote -',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#FEB019',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(negate(this.stats.drive.remote.decSize))
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
driveTotalChart(): any {
|
|
|
|
return {
|
2018-11-04 11:08:03 +09:00
|
|
|
bytes: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
series: [{
|
|
|
|
name: 'Combined',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'line',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(sum(this.stats.drive.local.totalSize, this.stats.drive.remote.totalSize))
|
|
|
|
}, {
|
|
|
|
name: 'Local',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.local.totalSize)
|
|
|
|
}, {
|
|
|
|
name: 'Remote',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.remote.totalSize)
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
driveFilesChart(): any {
|
|
|
|
return {
|
|
|
|
series: [{
|
|
|
|
name: 'All',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'line',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#09d8e2',
|
|
|
|
borderDash: [5, 5],
|
|
|
|
fill: false,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(
|
|
|
|
sum(
|
|
|
|
this.stats.drive.local.incCount,
|
|
|
|
negate(this.stats.drive.local.decCount),
|
|
|
|
this.stats.drive.remote.incCount,
|
|
|
|
negate(this.stats.drive.remote.decCount)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}, {
|
|
|
|
name: 'Local +',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.local.incCount)
|
|
|
|
}, {
|
|
|
|
name: 'Local -',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#FF4560',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(negate(this.stats.drive.local.decCount))
|
|
|
|
}, {
|
|
|
|
name: 'Remote +',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#00E396',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.remote.incCount)
|
|
|
|
}, {
|
|
|
|
name: 'Remote -',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-08-10 11:51:43 +09:00
|
|
|
color: '#FEB019',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(negate(this.stats.drive.remote.decCount))
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
driveFilesTotalChart(): any {
|
|
|
|
return {
|
|
|
|
series: [{
|
|
|
|
name: 'Combined',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'line',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(sum(this.stats.drive.local.totalCount, this.stats.drive.remote.totalCount))
|
|
|
|
}, {
|
|
|
|
name: 'Local',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.local.totalCount)
|
|
|
|
}, {
|
|
|
|
name: 'Remote',
|
2018-11-06 08:04:34 +09:00
|
|
|
type: 'area',
|
2020-01-30 04:37:25 +09:00
|
|
|
color: '#008FFB',
|
|
|
|
hidden: true,
|
2018-11-03 03:00:23 +09:00
|
|
|
data: this.format(this.stats.drive.remote.totalCount)
|
|
|
|
}]
|
|
|
|
};
|
|
|
|
},
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
number
|
2018-11-03 03:00:23 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-02-17 02:21:27 +09:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.zbcjwnqg {
|
2020-10-17 20:12:00 +09:00
|
|
|
&.max-width_1000px {
|
2020-08-09 15:51:02 +09:00
|
|
|
> .stats {
|
|
|
|
grid-template-columns: 1fr 1fr;
|
|
|
|
grid-template-rows: 1fr 1fr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.max-width_550px {
|
|
|
|
> .stats {
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
grid-template-rows: 1fr 1fr 1fr 1fr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-17 02:21:27 +09:00
|
|
|
> .stats {
|
2020-08-09 15:51:02 +09:00
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr 1fr 1fr;
|
|
|
|
grid-template-rows: 1fr;
|
|
|
|
gap: var(--margin);
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
font-size: 90%;
|
2020-02-17 02:21:27 +09:00
|
|
|
|
|
|
|
> div {
|
|
|
|
display: flex;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
|
|
|
> div {
|
|
|
|
width: 50%;
|
|
|
|
|
|
|
|
&:first-child {
|
|
|
|
> b {
|
|
|
|
display: block;
|
|
|
|
|
|
|
|
> [data-icon] {
|
|
|
|
width: 16px;
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> small {
|
|
|
|
margin-left: 16px + 8px;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:last-child {
|
|
|
|
> dl {
|
|
|
|
display: flex;
|
|
|
|
margin: 0;
|
|
|
|
line-height: 1.5em;
|
|
|
|
|
|
|
|
> dt,
|
|
|
|
> dd {
|
|
|
|
width: 50%;
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
|
2020-08-10 10:37:57 +09:00
|
|
|
> dd {
|
2020-02-17 02:21:27 +09:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.total {
|
|
|
|
> dt,
|
|
|
|
> dd {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&.diff.inc {
|
|
|
|
> dd {
|
|
|
|
color: #82c11c;
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: "+";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|