2021-01-04 10:36:50 +02:00
|
|
|
<template>
|
|
|
|
<div class="mkw-jobQueue _monospace" :class="{ _panel: !props.transparent }">
|
|
|
|
<div class="inbox">
|
2021-04-20 17:22:59 +03:00
|
|
|
<div class="label">Inbox queue<i v-if="inbox.waiting > 0" class="fas fa-exclamation-triangle icon"></i></div>
|
2021-01-04 10:36:50 +02:00
|
|
|
<div class="values">
|
|
|
|
<div>
|
|
|
|
<div>Process</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: inbox.activeSincePrevTick > prev.inbox.activeSincePrevTick, dec: inbox.activeSincePrevTick < prev.inbox.activeSincePrevTick }">{{ number(inbox.activeSincePrevTick) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Active</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: inbox.active > prev.inbox.active, dec: inbox.active < prev.inbox.active }">{{ number(inbox.active) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Delayed</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: inbox.delayed > prev.inbox.delayed, dec: inbox.delayed < prev.inbox.delayed }">{{ number(inbox.delayed) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Waiting</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: inbox.waiting > prev.inbox.waiting, dec: inbox.waiting < prev.inbox.waiting }">{{ number(inbox.waiting) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="deliver">
|
2021-04-20 17:22:59 +03:00
|
|
|
<div class="label">Deliver queue<i v-if="deliver.waiting > 0" class="fas fa-exclamation-triangle icon"></i></div>
|
2021-01-04 10:36:50 +02:00
|
|
|
<div class="values">
|
|
|
|
<div>
|
|
|
|
<div>Process</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: deliver.activeSincePrevTick > prev.deliver.activeSincePrevTick, dec: deliver.activeSincePrevTick < prev.deliver.activeSincePrevTick }">{{ number(deliver.activeSincePrevTick) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Active</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: deliver.active > prev.deliver.active, dec: deliver.active < prev.deliver.active }">{{ number(deliver.active) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Delayed</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: deliver.delayed > prev.deliver.delayed, dec: deliver.delayed < prev.deliver.delayed }">{{ number(deliver.delayed) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Waiting</div>
|
2021-02-20 04:05:46 +02:00
|
|
|
<div :class="{ inc: deliver.waiting > prev.deliver.waiting, dec: deliver.waiting < prev.deliver.waiting }">{{ number(deliver.waiting) }}</div>
|
2021-01-04 10:36:50 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-07-26 05:12:06 +03:00
|
|
|
import { defineComponent, markRaw } from 'vue';
|
2021-01-04 10:36:50 +02:00
|
|
|
import define from './define';
|
2021-03-23 10:30:14 +02:00
|
|
|
import * as os from '@client/os';
|
|
|
|
import number from '@client/filters/number';
|
2021-01-04 10:36:50 +02:00
|
|
|
|
|
|
|
const widget = define({
|
|
|
|
name: 'jobQueue',
|
|
|
|
props: () => ({
|
|
|
|
transparent: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
extends: widget,
|
|
|
|
data() {
|
|
|
|
return {
|
2021-07-26 05:12:06 +03:00
|
|
|
connection: markRaw(os.stream.useChannel('queueStats')),
|
2021-01-04 10:36:50 +02:00
|
|
|
inbox: {
|
|
|
|
activeSincePrevTick: 0,
|
|
|
|
active: 0,
|
|
|
|
waiting: 0,
|
|
|
|
delayed: 0,
|
|
|
|
},
|
|
|
|
deliver: {
|
|
|
|
activeSincePrevTick: 0,
|
|
|
|
active: 0,
|
|
|
|
waiting: 0,
|
|
|
|
delayed: 0,
|
|
|
|
},
|
2021-02-20 04:05:46 +02:00
|
|
|
prev: {},
|
2021-01-04 10:36:50 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
2021-02-20 04:05:46 +02:00
|
|
|
for (const domain of ['inbox', 'deliver']) {
|
|
|
|
this.prev[domain] = JSON.parse(JSON.stringify(this[domain]));
|
|
|
|
}
|
|
|
|
|
2021-01-04 10:36:50 +02:00
|
|
|
this.connection.on('stats', this.onStats);
|
|
|
|
this.connection.on('statsLog', this.onStatsLog);
|
|
|
|
|
|
|
|
this.connection.send('requestLog', {
|
|
|
|
id: Math.random().toString().substr(2, 8),
|
|
|
|
length: 1
|
|
|
|
});
|
|
|
|
},
|
|
|
|
beforeUnmount() {
|
|
|
|
this.connection.off('stats', this.onStats);
|
|
|
|
this.connection.off('statsLog', this.onStatsLog);
|
|
|
|
this.connection.dispose();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onStats(stats) {
|
|
|
|
for (const domain of ['inbox', 'deliver']) {
|
2021-02-20 04:05:46 +02:00
|
|
|
this.prev[domain] = JSON.parse(JSON.stringify(this[domain]));
|
2021-01-04 10:36:50 +02:00
|
|
|
this[domain].activeSincePrevTick = stats[domain].activeSincePrevTick;
|
|
|
|
this[domain].active = stats[domain].active;
|
|
|
|
this[domain].waiting = stats[domain].waiting;
|
|
|
|
this[domain].delayed = stats[domain].delayed;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onStatsLog(statsLog) {
|
|
|
|
for (const stats of [...statsLog].reverse()) {
|
|
|
|
this.onStats(stats);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
number
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@keyframes warnBlink {
|
|
|
|
0% { opacity: 1; }
|
|
|
|
50% { opacity: 0; }
|
|
|
|
}
|
|
|
|
|
|
|
|
.mkw-jobQueue {
|
2021-01-08 14:44:02 +02:00
|
|
|
font-size: 0.9em;
|
|
|
|
|
2021-01-04 10:36:50 +02:00
|
|
|
> div {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
&:not(:first-child) {
|
2021-04-10 06:40:50 +03:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2021-01-04 10:36:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
> .label {
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
> .icon {
|
|
|
|
color: var(--warn);
|
|
|
|
margin-left: auto;
|
|
|
|
animation: warnBlink 1s infinite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .values {
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
> div {
|
|
|
|
flex: 1;
|
|
|
|
|
|
|
|
> div:first-child {
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
2021-02-20 04:05:46 +02:00
|
|
|
|
|
|
|
> div:last-child {
|
|
|
|
&.inc {
|
|
|
|
color: var(--warn);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.dec {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 10:36:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|