jormungandr-bite/src/client/app/admin/views/queue.vue

156 lines
4 KiB
Vue
Raw Normal View History

2019-02-05 23:24:59 -07:00
<template>
<div>
<ui-card>
2019-03-14 22:48:17 -06:00
<template #title><fa :icon="faChartBar"/> {{ $t('title') }}</template>
2019-05-27 02:44:51 -06:00
<section>
<header><fa :icon="faPaperPlane"/> {{ $t('domains.deliver') }}</header>
2019-05-27 02:23:05 -06:00
<x-chart v-if="connection" :connection="connection" :limit="chartLimit" type="deliver"/>
</section>
2019-05-27 02:44:51 -06:00
<section>
<header><fa :icon="faInbox"/> {{ $t('domains.inbox') }}</header>
2019-05-27 02:23:05 -06:00
<x-chart v-if="connection" :connection="connection" :limit="chartLimit" type="inbox"/>
</section>
2019-05-27 02:44:51 -06:00
<section>
<details>
<summary>{{ $t('other-queues') }}</summary>
<section>
<header><fa :icon="faDatabase"/> {{ $t('domains.db') }}</header>
<x-chart v-if="connection" :connection="connection" :limit="chartLimit" type="db"/>
</section>
<ui-hr/>
<section>
<header><fa :icon="faCloud"/> {{ $t('domains.objectStorage') }}</header>
<x-chart v-if="connection" :connection="connection" :limit="chartLimit" type="objectStorage"/>
</section>
</details>
</section>
2019-02-05 23:24:59 -07:00
<section>
<ui-button @click="removeAllJobs">{{ $t('remove-all-jobs') }}</ui-button>
</section>
</ui-card>
2019-03-14 22:48:17 -06:00
<ui-card>
<template #title><fa :icon="faTasks"/> {{ $t('jobs') }}</template>
<section class="fit-top">
<ui-horizon-group inputs>
<ui-select v-model="domain">
<template #label>{{ $t('queue') }}</template>
<option value="deliver">{{ $t('domains.deliver') }}</option>
<option value="inbox">{{ $t('domains.inbox') }}</option>
2019-05-27 02:44:51 -06:00
<option value="db">{{ $t('domains.db') }}</option>
<option value="objectStorage">{{ $t('domains.objectStorage') }}</option>
2019-03-14 22:48:17 -06:00
</ui-select>
<ui-select v-model="state">
<template #label>{{ $t('state') }}</template>
2019-05-27 02:44:51 -06:00
<option value="active">{{ $t('states.active') }}</option>
<option value="waiting">{{ $t('states.waiting') }}</option>
2019-03-14 22:48:17 -06:00
<option value="delayed">{{ $t('states.delayed') }}</option>
</ui-select>
</ui-horizon-group>
<sequential-entrance animation="entranceFromTop" delay="25">
<div class="xvvuvgsv" v-for="job in jobs">
<b>{{ job.id }}</b>
<template v-if="domain === 'deliver'">
<span>{{ job.data.to }}</span>
</template>
<template v-if="domain === 'inbox'">
<span>{{ job.activity.id }}</span>
</template>
</div>
</sequential-entrance>
<ui-info v-if="jobs.length == jobsLimit">{{ $t('result-is-truncated', { n: jobsLimit }) }}</ui-info>
</section>
</ui-card>
2019-02-05 23:24:59 -07:00
</div>
</template>
<script lang="ts">
import Vue from 'vue';
2019-05-27 02:44:51 -06:00
import { faTasks, faInbox, faDatabase, faCloud } from '@fortawesome/free-solid-svg-icons';
2019-05-27 02:23:05 -06:00
import { faPaperPlane, faChartBar } from '@fortawesome/free-regular-svg-icons';
2019-02-05 23:24:59 -07:00
import i18n from '../../i18n';
2019-05-27 02:23:05 -06:00
import XChart from './queue.chart.vue';
2019-03-13 08:27:11 -06:00
2019-02-05 23:24:59 -07:00
export default Vue.extend({
i18n: i18n('admin/views/queue.vue'),
2019-05-27 02:23:05 -06:00
components: {
XChart
},
2019-02-05 23:24:59 -07:00
data() {
return {
2019-05-27 02:23:05 -06:00
connection: null,
chartLimit: 200,
2019-03-14 22:48:17 -06:00
jobs: [],
jobsLimit: 50,
domain: 'deliver',
state: 'delayed',
2019-05-27 02:44:51 -06:00
faTasks, faPaperPlane, faInbox, faChartBar, faDatabase, faCloud
2019-02-05 23:24:59 -07:00
};
},
2019-03-12 02:11:06 -06:00
watch: {
2019-03-14 22:48:17 -06:00
domain() {
this.jobs = [];
this.fetchJobs();
},
state() {
this.jobs = [];
this.fetchJobs();
},
2019-03-12 02:11:06 -06:00
},
mounted() {
2019-03-14 22:48:17 -06:00
this.fetchJobs();
2019-05-27 02:23:05 -06:00
this.connection = this.$root.stream.useSharedConnection('queueStats');
this.connection.send('requestLog', {
2019-03-12 02:11:06 -06:00
id: Math.random().toString().substr(2, 8),
2019-05-27 02:23:05 -06:00
length: this.chartLimit
2019-03-12 02:11:06 -06:00
});
2019-03-07 21:10:38 -07:00
this.$once('hook:beforeDestroy', () => {
2019-05-27 02:23:05 -06:00
this.connection.dispose();
});
},
2019-02-05 23:24:59 -07: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 02:11:06 -06:00
2019-03-14 22:48:17 -06:00
fetchJobs() {
this.$root.api('admin/queue/jobs', {
domain: this.domain,
state: this.state,
limit: this.jobsLimit
}).then(jobs => {
this.jobs = jobs;
});
},
2019-02-05 23:24:59 -07:00
}
});
</script>
2019-03-12 02:11:06 -06:00
<style lang="stylus" scoped>
2019-03-14 22:48:17 -06:00
.xvvuvgsv
> b
margin-right 16px
2019-03-12 02:11:06 -06:00
</style>