barkey/src/client/components/taskmanager.vue

134 lines
3.4 KiB
Vue
Raw Normal View History

2020-11-01 02:39:38 +00:00
<template>
<XWindow ref="window" :initial-width="650" :initial-height="420" :can-resize="true" @closed="$emit('closed')">
<template #header>
<Fa :icon="faTerminal" style="margin-right: 0.5em;"/>Task Manager
</template>
<div class="qljqmnzj">
2020-11-01 04:38:48 +00:00
<MkTab v-model:value="tab" :items="[{ label: 'Windows', value: 'windows', }, { label: 'Stream', value: 'stream', }, { label: 'Stream (Pool)', value: 'streamPool', }, { label: 'API', value: 'api', }]" style="border-bottom: solid 1px var(--divider);"/>
<div v-if="tab === 'windows'" class="windows">
<div class="header">
<div>#ID</div>
<div>Component</div>
<div>Action</div>
</div>
<div v-for="p in popups">
<div>#{{ p.id }}</div>
<div>{{ p.component.name ? p.component.name : '<anonymous>' }}</div>
<div><button class="_textButton" @click="killPopup(p)">Kill</button></div>
</div>
</div>
2020-11-01 02:39:38 +00:00
<div v-if="tab === 'stream'" class="stream">
<div class="header">
<div>#ID</div>
<div>Ch</div>
<div>Handle</div>
<div>In</div>
<div>Out</div>
</div>
<div v-for="c in connections">
<div>#{{ c.id }}</div>
<div>{{ c.channel }}</div>
<div v-if="c.users !== null">(shared)<span v-if="c.name">{{ ' ' + c.name }}</span></div>
<div v-else>{{ c.name ? c.name : '<anonymous>' }}</div>
<div>{{ c.in }}</div>
<div>{{ c.out }}</div>
</div>
</div>
2020-11-01 04:38:48 +00:00
<div v-if="tab === 'streamPool'" class="streamPool">
<div class="header">
<div>#ID</div>
<div>Ch</div>
<div>Users</div>
</div>
<div v-for="p in pools">
<div>#{{ p.id }}</div>
<div>{{ p.channel }}</div>
<div>{{ p.users }}</div>
</div>
</div>
2020-11-01 02:39:38 +00:00
</div>
</XWindow>
</template>
<script lang="ts">
2020-11-01 04:38:48 +00:00
import { defineComponent, markRaw, onBeforeUnmount, ref, shallowRef } from 'vue';
2020-11-01 02:39:38 +00:00
import { faTerminal } from '@fortawesome/free-solid-svg-icons';
import XWindow from '@/components/ui/window.vue';
import MkTab from '@/components/tab.vue';
import MkButton from '@/components/ui/button.vue';
import * as os from '@/os';
export default defineComponent({
components: {
XWindow,
MkTab,
MkButton,
},
props: {
},
emits: ['closed'],
setup() {
2020-11-01 04:38:48 +00:00
const connections = shallowRef([]);
const pools = shallowRef([]);
2020-11-01 02:39:38 +00:00
const refreshStreamInfo = () => {
2020-11-01 04:38:48 +00:00
console.log(os.stream.sharedConnectionPools, os.stream.sharedConnections, os.stream.nonSharedConnections);
const conn = os.stream.sharedConnections.map(c => ({
2020-11-01 02:39:38 +00:00
id: c.id, name: c.name, channel: c.channel, users: c.pool.users, in: c.inCount, out: c.outCount,
})).concat(os.stream.nonSharedConnections.map(c => ({
id: c.id, name: c.name, channel: c.channel, users: null, in: c.inCount, out: c.outCount,
2020-11-01 04:38:48 +00:00
})));
conn.sort((a, b) => (a.id > b.id) ? 1 : -1);
connections.value = conn;
pools.value = os.stream.sharedConnectionPools;
2020-11-01 02:39:38 +00:00
};
const interval = setInterval(refreshStreamInfo, 1000);
onBeforeUnmount(() => {
clearInterval(interval);
});
2020-11-01 04:38:48 +00:00
const killPopup = p => {
os.popups.value = os.popups.value.filter(x => x !== p);
};
2020-11-01 02:39:38 +00:00
return {
2020-11-01 04:38:48 +00:00
tab: ref('stream'),
popups: os.popups,
2020-11-01 02:39:38 +00:00
connections,
2020-11-01 04:38:48 +00:00
pools,
killPopup,
2020-11-01 02:39:38 +00:00
faTerminal,
};
},
});
</script>
<style lang="scss" scoped>
.qljqmnzj {
2020-11-01 04:38:48 +00:00
> .windows,
> .stream,
> .streamPool {
2020-11-01 02:39:38 +00:00
display: table;
width: 100%;
2020-11-01 03:26:46 +00:00
padding: 16px;
2020-11-01 02:39:38 +00:00
box-sizing: border-box;
> div {
display: table-row;
font-family: Fira code, Fira Mono, Consolas, Menlo, Courier, monospace;
&.header {
opacity: 0.7;
}
> * {
display: table-cell;
}
}
}
}
</style>