2018-02-23 18:46:09 +01:00
|
|
|
<template>
|
|
|
|
<div class="mkw-server">
|
2019-02-15 07:35:52 +01:00
|
|
|
<ui-container :show-header="props.design == 0" :naked="props.design == 2">
|
2019-02-18 01:48:00 +01:00
|
|
|
<template v-slot:header><fa icon="server"/>{{ $t('title') }}</template>
|
|
|
|
<template v-slot:func><button @click="toggle" :title="$t('toggle')"><fa icon="sort"/></button></template>
|
2018-02-23 18:46:09 +01:00
|
|
|
|
2018-11-13 14:45:28 +01:00
|
|
|
<p :class="$style.fetching" v-if="fetching"><fa icon="spinner" pulse fixed-width/>{{ $t('@.loading') }}<mk-ellipsis/></p>
|
2018-02-23 18:46:09 +01:00
|
|
|
<template v-if="!fetching">
|
|
|
|
<x-cpu-memory v-show="props.view == 0" :connection="connection"/>
|
|
|
|
<x-cpu v-show="props.view == 1" :connection="connection" :meta="meta"/>
|
|
|
|
<x-memory v-show="props.view == 2" :connection="connection"/>
|
|
|
|
<x-disk v-show="props.view == 3" :connection="connection"/>
|
|
|
|
<x-uptimes v-show="props.view == 4" :connection="connection"/>
|
|
|
|
<x-info v-show="props.view == 5" :connection="connection" :meta="meta"/>
|
|
|
|
</template>
|
2019-02-15 07:35:52 +01:00
|
|
|
</ui-container>
|
2018-02-23 18:46:09 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2018-02-24 16:18:09 +01:00
|
|
|
import define from '../../../common/define-widget';
|
2018-11-08 19:44:35 +01:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-23 18:46:09 +01:00
|
|
|
import XCpuMemory from './server.cpu-memory.vue';
|
|
|
|
import XCpu from './server.cpu.vue';
|
|
|
|
import XMemory from './server.memory.vue';
|
|
|
|
import XDisk from './server.disk.vue';
|
|
|
|
import XUptimes from './server.uptimes.vue';
|
|
|
|
import XInfo from './server.info.vue';
|
|
|
|
|
|
|
|
export default define({
|
|
|
|
name: 'server',
|
|
|
|
props: () => ({
|
|
|
|
design: 0,
|
|
|
|
view: 0
|
|
|
|
})
|
|
|
|
}).extend({
|
2018-11-08 19:44:35 +01:00
|
|
|
i18n: i18n('common/views/widgets/server.vue'),
|
|
|
|
|
2018-02-23 18:46:09 +01:00
|
|
|
components: {
|
|
|
|
XCpuMemory,
|
|
|
|
XCpu,
|
|
|
|
XMemory,
|
|
|
|
XDisk,
|
|
|
|
XUptimes,
|
|
|
|
XInfo
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fetching: true,
|
|
|
|
meta: null,
|
2018-10-07 04:06:17 +02:00
|
|
|
connection: null
|
2018-02-23 18:46:09 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
2018-11-09 00:13:34 +01:00
|
|
|
this.$root.getMeta().then(meta => {
|
2018-02-23 18:46:09 +01:00
|
|
|
this.meta = meta;
|
|
|
|
this.fetching = false;
|
|
|
|
});
|
|
|
|
|
2018-11-09 00:13:34 +01:00
|
|
|
this.connection = this.$root.stream.useSharedConnection('serverStats');
|
2018-02-23 18:46:09 +01:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2018-10-07 04:06:17 +02:00
|
|
|
this.connection.dispose();
|
2018-02-23 18:46:09 +01:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggle() {
|
|
|
|
if (this.props.view == 5) {
|
|
|
|
this.props.view = 0;
|
|
|
|
} else {
|
|
|
|
this.props.view++;
|
|
|
|
}
|
2018-04-29 10:17:15 +02:00
|
|
|
this.save();
|
2018-02-23 18:46:09 +01:00
|
|
|
},
|
|
|
|
func() {
|
|
|
|
if (this.props.design == 2) {
|
|
|
|
this.props.design = 0;
|
|
|
|
} else {
|
|
|
|
this.props.design++;
|
|
|
|
}
|
2018-04-29 10:17:15 +02:00
|
|
|
this.save();
|
2018-02-23 18:46:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" module>
|
|
|
|
.fetching
|
|
|
|
margin 0
|
|
|
|
padding 16px
|
|
|
|
text-align center
|
2019-02-06 09:51:33 +01:00
|
|
|
color var(--text)
|
2018-02-23 18:46:09 +01:00
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> [data-icon]
|
2018-02-23 18:46:09 +01:00
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
</style>
|