misskey/src/client/app/common/views/widgets/server.memory.vue

77 lines
1.2 KiB
Vue
Raw Normal View History

2018-02-20 07:56:39 +09:00
<template>
<div class="memory">
<x-pie class="pie" :value="usage"/>
<div>
<p><fa icon="flask"/>Memory</p>
2018-02-20 07:56:39 +09:00
<p>Total: {{ total | bytes(1) }}</p>
<p>Used: {{ used | bytes(1) }}</p>
<p>Free: {{ free | bytes(1) }}</p>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
import XPie from './server.pie.vue';
export default Vue.extend({
components: {
2018-02-21 01:39:51 +09:00
XPie
2018-02-20 07:56:39 +09:00
},
props: ['connection'],
data() {
return {
usage: 0,
total: 0,
used: 0,
free: 0
};
},
mounted() {
this.connection.on('stats', this.onStats);
},
beforeDestroy() {
this.connection.off('stats', this.onStats);
},
methods: {
onStats(stats) {
2018-07-27 18:18:05 +09:00
stats.mem.free = stats.mem.total - stats.mem.used;
2018-02-20 07:56:39 +09:00
this.usage = stats.mem.used / stats.mem.total;
this.total = stats.mem.total;
this.used = stats.mem.used;
this.free = stats.mem.free;
}
}
});
</script>
<style lang="stylus" scoped>
2018-09-28 19:59:19 +09:00
.memory
2018-02-20 07:56:39 +09:00
> .pie
padding 10px
height 100px
float left
> div
float left
width calc(100% - 100px)
padding 10px 10px 10px 0
> p
margin 0
font-size 12px
2018-09-28 19:59:19 +09:00
color var(--chartCaption)
2018-02-20 07:56:39 +09:00
&:first-child
font-weight bold
> [data-icon]
2018-02-20 07:56:39 +09:00
margin-right 4px
&:after
content ""
display block
clear both
</style>