diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-03-10 19:16:33 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-03-10 19:16:33 +0900 |
| commit | 80a2172715b6dd225a331d8f2cbccc78dcbd1302 (patch) | |
| tree | 83915294feef374ae5a9baaa6754a50d549b386f /src/client | |
| parent | Improve redis config (diff) | |
| download | misskey-80a2172715b6dd225a331d8f2cbccc78dcbd1302.tar.gz misskey-80a2172715b6dd225a331d8f2cbccc78dcbd1302.tar.bz2 misskey-80a2172715b6dd225a331d8f2cbccc78dcbd1302.zip | |
Resolve #4462
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/app/common/views/deck/deck.widgets-column.vue | 1 | ||||
| -rw-r--r-- | src/client/app/common/views/widgets/index.ts | 1 | ||||
| -rw-r--r-- | src/client/app/common/views/widgets/queue.vue | 157 | ||||
| -rw-r--r-- | src/client/app/desktop/views/home/home.vue | 1 | ||||
| -rw-r--r-- | src/client/app/mobile/views/pages/widgets.vue | 1 |
5 files changed, 161 insertions, 0 deletions
diff --git a/src/client/app/common/views/deck/deck.widgets-column.vue b/src/client/app/common/views/deck/deck.widgets-column.vue index 47a584a53a..fcf3afd3f7 100644 --- a/src/client/app/common/views/deck/deck.widgets-column.vue +++ b/src/client/app/common/views/deck/deck.widgets-column.vue @@ -26,6 +26,7 @@ <option value="hashtags">{{ $t('@.widgets.hashtags') }}</option> <option value="posts-monitor">{{ $t('@.widgets.posts-monitor') }}</option> <option value="server">{{ $t('@.widgets.server') }}</option> + <option value="queue">{{ $t('@.widgets.queue') }}</option> <option value="nav">{{ $t('@.widgets.nav') }}</option> <option value="tips">{{ $t('@.widgets.tips') }}</option> </select> diff --git a/src/client/app/common/views/widgets/index.ts b/src/client/app/common/views/widgets/index.ts index 05aa08375b..d923a01941 100644 --- a/src/client/app/common/views/widgets/index.ts +++ b/src/client/app/common/views/widgets/index.ts @@ -31,3 +31,4 @@ Vue.component('mkw-version', wVersion); Vue.component('mkw-hashtags', wHashtags); Vue.component('mkw-instance', wInstance); Vue.component('mkw-post-form', wPostForm); +Vue.component('mkw-queue', () => import('./queue.vue').then(m => m.default)); diff --git a/src/client/app/common/views/widgets/queue.vue b/src/client/app/common/views/widgets/queue.vue new file mode 100644 index 0000000000..18bfeb3ba9 --- /dev/null +++ b/src/client/app/common/views/widgets/queue.vue @@ -0,0 +1,157 @@ +<template> +<div> + <ui-container :show-header="!props.compact"> + <template #header><fa :icon="faTasks"/>Queue</template> + + <div class="mntrproz"> + <div> + <b>In</b> + <span v-if="latestStats">{{ latestStats.inbox.active | number }} / {{ latestStats.inbox.delayed | number }}</span> + <div ref="in"></div> + </div> + <div> + <b>Out</b> + <span v-if="latestStats">{{ latestStats.deliver.active | number }} / {{ latestStats.deliver.delayed | number }}</span> + <div ref="out"></div> + </div> + </div> + </ui-container> +</div> +</template> + +<script lang="ts"> +import define from '../../define-widget'; +import { faTasks } from '@fortawesome/free-solid-svg-icons'; +import ApexCharts from 'apexcharts'; + +export default define({ + name: 'queue', + props: () => ({ + compact: false + }) +}).extend({ + data() { + return { + stats: [], + inChart: null, + outChart: null, + faTasks + }; + }, + + watch: { + stats(stats) { + this.inChart.updateSeries([{ + data: stats.map((x, i) => ({ x: i, y: x.inbox.active })) + }, { + data: stats.map((x, i) => ({ x: i, y: x.inbox.delayed })) + }]); + this.outChart.updateSeries([{ + data: stats.map((x, i) => ({ x: i, y: x.deliver.active })) + }, { + data: stats.map((x, i) => ({ x: i, y: x.deliver.delayed })) + }]); + } + }, + + computed: { + latestStats(): any { + return this.stats[this.stats.length - 1]; + } + }, + + mounted() { + const chartOpts = { + chart: { + type: 'area', + height: 70, + animations: { + dynamicAnimation: { + enabled: false + } + }, + sparkline: { + enabled: true, + } + }, + tooltip: { + enabled: false + }, + stroke: { + curve: 'straight', + width: 1 + }, + series: [{ + data: [] as any + }, { + data: [] as any + }], + yaxis: { + min: 0, + } + }; + + this.inChart = new ApexCharts(this.$refs.in, chartOpts); + this.outChart = new ApexCharts(this.$refs.out, chartOpts); + + this.inChart.render(); + this.outChart.render(); + + const connection = this.$root.stream.useSharedConnection('queueStats'); + connection.on('stats', this.onStats); + connection.on('statsLog', this.onStatsLog); + connection.send('requestLog', { + id: Math.random().toString().substr(2, 8), + length: 50 + }); + + this.$once('hook:beforeDestroy', () => { + connection.dispose(); + this.inChart.destroy(); + this.outChart.destroy(); + }); + }, + + methods: { + func() { + this.props.compact = !this.props.compact; + this.save(); + }, + + onStats(stats) { + this.stats.push(stats); + if (this.stats.length > 50) this.stats.shift(); + }, + + onStatsLog(statsLog) { + for (const stats of statsLog.reverse()) { + this.onStats(stats); + } + } + } +}); +</script> + +<style lang="stylus" scoped> +.mntrproz + display flex + padding 4px + + > div + width 50% + padding 4px + + > b + display block + font-size 12px + color var(--text) + + > span + position absolute + top 4px + right 4px + opacity 0.7 + font-size 12px + color var(--text) + +</style> diff --git a/src/client/app/desktop/views/home/home.vue b/src/client/app/desktop/views/home/home.vue index 740aa1289d..fb7af5a9ad 100644 --- a/src/client/app/desktop/views/home/home.vue +++ b/src/client/app/desktop/views/home/home.vue @@ -27,6 +27,7 @@ <option value="hashtags">{{ $t('@.widgets.hashtags') }}</option> <option value="posts-monitor">{{ $t('@.widgets.posts-monitor') }}</option> <option value="server">{{ $t('@.widgets.server') }}</option> + <option value="queue">{{ $t('@.widgets.queue') }}</option> <option value="nav">{{ $t('@.widgets.nav') }}</option> <option value="tips">{{ $t('@.widgets.tips') }}</option> </select> diff --git a/src/client/app/mobile/views/pages/widgets.vue b/src/client/app/mobile/views/pages/widgets.vue index 7722104aff..96dcb977fa 100644 --- a/src/client/app/mobile/views/pages/widgets.vue +++ b/src/client/app/mobile/views/pages/widgets.vue @@ -19,6 +19,7 @@ <option value="posts-monitor">{{ $t('@.widgets.posts-monitor') }}</option> <option value="version">{{ $t('@.widgets.version') }}</option> <option value="server">{{ $t('@.widgets.server') }}</option> + <option value="queue">{{ $t('@.widgets.queue') }}</option> <option value="memo">{{ $t('@.widgets.memo') }}</option> <option value="nav">{{ $t('@.widgets.nav') }}</option> <option value="tips">{{ $t('@.widgets.tips') }}</option> |