2021-01-04 09:36:50 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div
|
|
|
|
class="mkw-jobQueue _monospace"
|
|
|
|
:class="{ _panel: !widgetProps.transparent }"
|
|
|
|
>
|
|
|
|
<div class="inbox">
|
|
|
|
<div class="label">
|
|
|
|
Inbox queue<i
|
|
|
|
v-if="current.inbox.waiting > 0"
|
|
|
|
class="ph-warning ph-bold ph-lg icon"
|
|
|
|
></i>
|
2021-01-04 09:36:50 +01:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="values">
|
|
|
|
<div>
|
|
|
|
<div>Process</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc:
|
|
|
|
current.inbox.activeSincePrevTick >
|
|
|
|
prev.inbox.activeSincePrevTick,
|
|
|
|
dec:
|
|
|
|
current.inbox.activeSincePrevTick <
|
|
|
|
prev.inbox.activeSincePrevTick,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.inbox.activeSincePrevTick) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Active</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc: current.inbox.active > prev.inbox.active,
|
|
|
|
dec: current.inbox.active < prev.inbox.active,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.inbox.active) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Delayed</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc: current.inbox.delayed > prev.inbox.delayed,
|
|
|
|
dec: current.inbox.delayed < prev.inbox.delayed,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.inbox.delayed) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Waiting</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc: current.inbox.waiting > prev.inbox.waiting,
|
|
|
|
dec: current.inbox.waiting < prev.inbox.waiting,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.inbox.waiting) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-04 09:36:50 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="deliver">
|
|
|
|
<div class="label">
|
|
|
|
Deliver queue<i
|
|
|
|
v-if="current.deliver.waiting > 0"
|
|
|
|
class="ph-warning ph-bold ph-lg icon"
|
|
|
|
></i>
|
2021-01-04 09:36:50 +01:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="values">
|
|
|
|
<div>
|
|
|
|
<div>Process</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc:
|
|
|
|
current.deliver.activeSincePrevTick >
|
|
|
|
prev.deliver.activeSincePrevTick,
|
|
|
|
dec:
|
|
|
|
current.deliver.activeSincePrevTick <
|
|
|
|
prev.deliver.activeSincePrevTick,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.deliver.activeSincePrevTick) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Active</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc: current.deliver.active > prev.deliver.active,
|
|
|
|
dec: current.deliver.active < prev.deliver.active,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.deliver.active) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Delayed</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc: current.deliver.delayed > prev.deliver.delayed,
|
|
|
|
dec: current.deliver.delayed < prev.deliver.delayed,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.deliver.delayed) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<div>Waiting</div>
|
|
|
|
<div
|
|
|
|
:class="{
|
|
|
|
inc: current.deliver.waiting > prev.deliver.waiting,
|
|
|
|
dec: current.deliver.waiting < prev.deliver.waiting,
|
|
|
|
}"
|
|
|
|
>
|
|
|
|
{{ number(current.deliver.waiting) }}
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-04 09:36:50 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-01-08 12:30:01 +01:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { onMounted, onUnmounted, reactive, ref } from "vue";
|
|
|
|
import {
|
|
|
|
useWidgetPropsManager,
|
|
|
|
Widget,
|
|
|
|
WidgetComponentEmits,
|
|
|
|
WidgetComponentExpose,
|
|
|
|
WidgetComponentProps,
|
|
|
|
} from "./widget";
|
|
|
|
import { GetFormResultType } from "@/scripts/form";
|
|
|
|
import { stream } from "@/stream";
|
|
|
|
import number from "@/filters/number";
|
|
|
|
import * as sound from "@/scripts/sound";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { deepClone } from "@/scripts/clone";
|
2021-01-04 09:36:50 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const name = "jobQueue";
|
2021-01-04 09:36:50 +01:00
|
|
|
|
2022-01-08 12:30:01 +01:00
|
|
|
const widgetPropsDef = {
|
|
|
|
transparent: {
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "boolean" as const,
|
2022-01-08 12:30:01 +01:00
|
|
|
default: false,
|
2021-01-04 09:36:50 +01:00
|
|
|
},
|
2022-01-08 12:30:01 +01:00
|
|
|
sound: {
|
2023-04-08 02:01:42 +02:00
|
|
|
type: "boolean" as const,
|
2022-01-08 12:30:01 +01:00
|
|
|
default: false,
|
2021-01-04 09:36:50 +01:00
|
|
|
},
|
2022-01-08 12:30:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
|
|
|
|
|
|
|
|
// 現時点ではvueの制限によりimportしたtypeをジェネリックに渡せない
|
|
|
|
//const props = defineProps<WidgetComponentProps<WidgetProps>>();
|
|
|
|
//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
|
2023-04-08 02:01:42 +02:00
|
|
|
const props = defineProps<{ widget?: Widget<WidgetProps> }>();
|
|
|
|
const emit = defineEmits<{ (ev: "updateProps", props: WidgetProps) }>();
|
2022-01-08 12:30:01 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const { widgetProps, configure } = useWidgetPropsManager(
|
|
|
|
name,
|
2022-01-08 12:30:01 +01:00
|
|
|
widgetPropsDef,
|
|
|
|
props,
|
2023-04-08 02:01:42 +02:00
|
|
|
emit
|
2022-01-08 12:30:01 +01:00
|
|
|
);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const connection = stream.useChannel("queueStats");
|
2022-01-08 12:30:01 +01:00
|
|
|
const current = reactive({
|
|
|
|
inbox: {
|
|
|
|
activeSincePrevTick: 0,
|
|
|
|
active: 0,
|
|
|
|
waiting: 0,
|
|
|
|
delayed: 0,
|
2021-01-04 09:36:50 +01:00
|
|
|
},
|
2022-01-08 12:30:01 +01:00
|
|
|
deliver: {
|
|
|
|
activeSincePrevTick: 0,
|
|
|
|
active: 0,
|
|
|
|
waiting: 0,
|
|
|
|
delayed: 0,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const prev = reactive({} as typeof current);
|
2023-04-08 02:01:42 +02:00
|
|
|
const jammedSound = sound.setVolume(sound.getAudio("syuilo/queue-jammed"), 1);
|
2021-01-04 09:36:50 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
for (const domain of ["inbox", "deliver"]) {
|
2022-11-17 01:31:07 +01:00
|
|
|
prev[domain] = deepClone(current[domain]);
|
2022-01-08 12:30:01 +01:00
|
|
|
}
|
2021-01-04 09:36:50 +01:00
|
|
|
|
2022-01-08 12:30:01 +01:00
|
|
|
const onStats = (stats) => {
|
2023-04-08 02:01:42 +02:00
|
|
|
for (const domain of ["inbox", "deliver"]) {
|
2022-11-17 01:31:07 +01:00
|
|
|
prev[domain] = deepClone(current[domain]);
|
2022-01-08 12:30:01 +01:00
|
|
|
current[domain].activeSincePrevTick = stats[domain].activeSincePrevTick;
|
|
|
|
current[domain].active = stats[domain].active;
|
|
|
|
current[domain].waiting = stats[domain].waiting;
|
|
|
|
current[domain].delayed = stats[domain].delayed;
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
if (
|
|
|
|
current[domain].waiting > 0 &&
|
|
|
|
widgetProps.sound &&
|
|
|
|
jammedSound.paused
|
|
|
|
) {
|
2022-01-08 12:30:01 +01:00
|
|
|
jammedSound.play();
|
|
|
|
}
|
2021-01-04 09:36:50 +01:00
|
|
|
}
|
2022-01-08 12:30:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const onStatsLog = (statsLog) => {
|
|
|
|
for (const stats of [...statsLog].reverse()) {
|
|
|
|
onStats(stats);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.on("stats", onStats);
|
|
|
|
connection.on("statsLog", onStatsLog);
|
2022-01-08 12:30:01 +01:00
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.send("requestLog", {
|
2022-01-08 12:30:01 +01:00
|
|
|
id: Math.random().toString().substr(2, 8),
|
|
|
|
length: 1,
|
|
|
|
});
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
2023-04-08 02:01:42 +02:00
|
|
|
connection.off("stats", onStats);
|
|
|
|
connection.off("statsLog", onStatsLog);
|
2022-01-08 12:30:01 +01:00
|
|
|
connection.dispose();
|
|
|
|
});
|
|
|
|
|
|
|
|
defineExpose<WidgetComponentExpose>({
|
|
|
|
name,
|
|
|
|
configure,
|
|
|
|
id: props.widget ? props.widget.id : null,
|
2021-01-04 09:36:50 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@keyframes warnBlink {
|
2023-04-08 02:01:42 +02:00
|
|
|
0% {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
2021-01-04 09:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.mkw-jobQueue {
|
2021-01-08 13:44:02 +01:00
|
|
|
font-size: 0.9em;
|
|
|
|
|
2021-01-04 09:36:50 +01:00
|
|
|
> div {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
&:not(:first-child) {
|
2021-04-10 05:40:50 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
2021-01-04 09:36:50 +01: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 03:05:46 +01:00
|
|
|
|
|
|
|
> div:last-child {
|
|
|
|
&.inc {
|
|
|
|
color: var(--warn);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.dec {
|
|
|
|
color: var(--success);
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 09:36:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|