2019-02-06 06:24:59 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<ui-card>
|
2019-03-12 08:20:40 +00:00
|
|
|
<template #title><fa :icon="faTasks"/> {{ $t('title') }}</template>
|
2019-03-12 08:11:06 +00:00
|
|
|
<section class="wptihjuy">
|
2019-03-12 08:20:40 +00:00
|
|
|
<header><fa :icon="faPaperPlane"/> Deliver</header>
|
2019-03-12 08:11:06 +00:00
|
|
|
<ui-horizon-group inputs v-if="latestStats" class="fit-bottom">
|
|
|
|
<ui-input :value="latestStats.deliver.waiting | number" type="text" readonly>
|
2019-03-08 04:03:38 +00:00
|
|
|
<span>Waiting</span>
|
|
|
|
</ui-input>
|
2019-03-12 08:11:06 +00:00
|
|
|
<ui-input :value="latestStats.deliver.delayed | number" type="text" readonly>
|
2019-03-08 04:03:38 +00:00
|
|
|
<span>Delayed</span>
|
|
|
|
</ui-input>
|
2019-03-12 08:11:06 +00:00
|
|
|
<ui-input :value="latestStats.deliver.active | number" type="text" readonly>
|
2019-03-08 06:27:06 +00:00
|
|
|
<span>Active</span>
|
|
|
|
</ui-input>
|
2019-03-08 04:03:38 +00:00
|
|
|
</ui-horizon-group>
|
2019-03-12 08:11:06 +00:00
|
|
|
<div ref="deliverChart" class="chart"></div>
|
2019-03-08 04:03:38 +00:00
|
|
|
</section>
|
2019-03-12 08:11:06 +00:00
|
|
|
<section class="wptihjuy">
|
2019-03-12 08:20:40 +00:00
|
|
|
<header><fa :icon="faInbox"/> Inbox</header>
|
2019-03-12 08:11:06 +00:00
|
|
|
<ui-horizon-group inputs v-if="latestStats" class="fit-bottom">
|
|
|
|
<ui-input :value="latestStats.inbox.waiting | number" type="text" readonly>
|
2019-03-08 04:03:38 +00:00
|
|
|
<span>Waiting</span>
|
|
|
|
</ui-input>
|
2019-03-12 08:11:06 +00:00
|
|
|
<ui-input :value="latestStats.inbox.delayed | number" type="text" readonly>
|
2019-03-08 04:03:38 +00:00
|
|
|
<span>Delayed</span>
|
|
|
|
</ui-input>
|
2019-03-12 08:11:06 +00:00
|
|
|
<ui-input :value="latestStats.inbox.active | number" type="text" readonly>
|
2019-03-08 06:27:06 +00:00
|
|
|
<span>Active</span>
|
|
|
|
</ui-input>
|
2019-03-08 04:03:38 +00:00
|
|
|
</ui-horizon-group>
|
2019-03-12 08:11:06 +00:00
|
|
|
<div ref="inboxChart" class="chart"></div>
|
2019-03-08 04:03:38 +00:00
|
|
|
</section>
|
2019-02-06 06:24:59 +00:00
|
|
|
<section>
|
|
|
|
<ui-button @click="removeAllJobs">{{ $t('remove-all-jobs') }}</ui-button>
|
|
|
|
</section>
|
|
|
|
</ui-card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import i18n from '../../i18n';
|
2019-03-12 08:11:06 +00:00
|
|
|
import ApexCharts from 'apexcharts';
|
|
|
|
import * as tinycolor from 'tinycolor2';
|
2019-03-12 08:20:40 +00:00
|
|
|
import { faTasks, faInbox } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faPaperPlane } from '@fortawesome/free-regular-svg-icons';
|
2019-02-06 06:24:59 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
i18n: i18n('admin/views/queue.vue'),
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2019-03-12 08:11:06 +00:00
|
|
|
stats: [],
|
|
|
|
deliverChart: null,
|
|
|
|
inboxChart: null,
|
2019-03-12 08:20:40 +00:00
|
|
|
faTasks, faPaperPlane, faInbox
|
2019-02-06 06:24:59 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2019-03-12 08:11:06 +00:00
|
|
|
computed: {
|
|
|
|
latestStats(): any {
|
|
|
|
return this.stats[this.stats.length - 1];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
stats(stats) {
|
|
|
|
this.inboxChart.updateSeries([{
|
|
|
|
name: 'Active',
|
|
|
|
data: stats.map((x, i) => ({ x: i, y: x.inbox.activeSincePrevTick }))
|
|
|
|
}, {
|
|
|
|
name: 'Waiting',
|
|
|
|
data: stats.map((x, i) => ({ x: i, y: x.inbox.waiting }))
|
|
|
|
}, {
|
|
|
|
name: 'Delayed',
|
|
|
|
data: stats.map((x, i) => ({ x: i, y: x.inbox.delayed }))
|
|
|
|
}]);
|
|
|
|
this.deliverChart.updateSeries([{
|
|
|
|
name: 'Active',
|
|
|
|
data: stats.map((x, i) => ({ x: i, y: x.deliver.activeSincePrevTick }))
|
|
|
|
}, {
|
|
|
|
name: 'Waiting',
|
|
|
|
data: stats.map((x, i) => ({ x: i, y: x.deliver.waiting }))
|
|
|
|
}, {
|
|
|
|
name: 'Delayed',
|
|
|
|
data: stats.map((x, i) => ({ x: i, y: x.deliver.delayed }))
|
|
|
|
}]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
const chartOpts = {
|
|
|
|
chart: {
|
|
|
|
type: 'area',
|
|
|
|
height: 200,
|
|
|
|
animations: {
|
|
|
|
dynamicAnimation: {
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
toolbar: {
|
|
|
|
show: false
|
|
|
|
},
|
|
|
|
zoom: {
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
dataLabels: {
|
|
|
|
enabled: false
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
clipMarkers: false,
|
|
|
|
borderColor: 'rgba(0, 0, 0, 0.1)'
|
|
|
|
},
|
|
|
|
stroke: {
|
|
|
|
curve: 'straight',
|
|
|
|
width: 2
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
enabled: false
|
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
labels: {
|
|
|
|
colors: tinycolor(getComputedStyle(document.documentElement).getPropertyValue('--text')).toRgbString()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
series: [] as any,
|
|
|
|
colors: ['#00BCD4', '#FFEB3B', '#e53935'],
|
|
|
|
xaxis: {
|
|
|
|
type: 'numeric',
|
|
|
|
labels: {
|
|
|
|
show: false
|
|
|
|
},
|
|
|
|
tooltip: {
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
yaxis: {
|
|
|
|
show: false,
|
|
|
|
min: 0,
|
|
|
|
}
|
2019-03-08 04:10:38 +00:00
|
|
|
};
|
|
|
|
|
2019-03-12 08:11:06 +00:00
|
|
|
this.inboxChart = new ApexCharts(this.$refs.inboxChart, chartOpts);
|
|
|
|
this.deliverChart = new ApexCharts(this.$refs.deliverChart, chartOpts);
|
2019-03-08 04:10:38 +00:00
|
|
|
|
2019-03-12 08:11:06 +00:00
|
|
|
this.inboxChart.render();
|
|
|
|
this.deliverChart.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: 100
|
|
|
|
});
|
2019-03-08 04:10:38 +00:00
|
|
|
|
|
|
|
this.$once('hook:beforeDestroy', () => {
|
2019-03-12 08:11:06 +00:00
|
|
|
connection.dispose();
|
|
|
|
this.inboxChart.destroy();
|
|
|
|
this.deliverChart.destroy();
|
2019-03-08 04:03:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-02-06 06:24:59 +00:00
|
|
|
methods: {
|
|
|
|
async removeAllJobs() {
|
|
|
|
const process = async () => {
|
|
|
|
await this.$root.api('admin/queue/clear');
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
splash: true
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
await process().catch(e => {
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e.toString()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2019-03-12 08:11:06 +00:00
|
|
|
|
|
|
|
onStats(stats) {
|
|
|
|
this.stats.push(stats);
|
|
|
|
if (this.stats.length > 100) this.stats.shift();
|
|
|
|
},
|
|
|
|
|
|
|
|
onStatsLog(statsLog) {
|
|
|
|
for (const stats of statsLog.reverse()) {
|
|
|
|
this.onStats(stats);
|
|
|
|
}
|
|
|
|
}
|
2019-02-06 06:24:59 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2019-03-12 08:11:06 +00:00
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
|
|
|
.wptihjuy
|
|
|
|
> .chart
|
|
|
|
min-height 200px !important
|
|
|
|
|
|
|
|
</style>
|