2018-02-19 23:56:39 +01:00
|
|
|
<template>
|
|
|
|
<div class="disk">
|
|
|
|
<x-pie class="pie" :value="usage"/>
|
|
|
|
<div>
|
2018-11-05 17:40:11 +01:00
|
|
|
<p><fa :icon="['far', 'hdd']"/>Storage</p>
|
2018-02-19 23:56:39 +01:00
|
|
|
<p>Total: {{ total | bytes(1) }}</p>
|
2018-08-07 05:37:17 +02:00
|
|
|
<p>Free: {{ available | bytes(1) }}</p>
|
2018-02-19 23:56:39 +01:00
|
|
|
<p>Used: {{ used | 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-20 17:39:51 +01:00
|
|
|
XPie
|
2018-02-19 23:56:39 +01:00
|
|
|
},
|
|
|
|
props: ['connection'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
usage: 0,
|
|
|
|
total: 0,
|
|
|
|
used: 0,
|
|
|
|
available: 0
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.connection.on('stats', this.onStats);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
this.connection.off('stats', this.onStats);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onStats(stats) {
|
|
|
|
stats.disk.used = stats.disk.total - stats.disk.free;
|
|
|
|
this.usage = stats.disk.used / stats.disk.total;
|
|
|
|
this.total = stats.disk.total;
|
|
|
|
this.used = stats.disk.used;
|
|
|
|
this.available = stats.disk.available;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="stylus" scoped>
|
2018-09-28 12:59:19 +02:00
|
|
|
.disk
|
2018-02-19 23:56:39 +01: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 12:59:19 +02:00
|
|
|
color var(--chartCaption)
|
2018-02-19 23:56:39 +01:00
|
|
|
|
|
|
|
&:first-child
|
|
|
|
font-weight bold
|
|
|
|
|
2018-11-05 17:40:11 +01:00
|
|
|
> [data-icon]
|
2018-02-19 23:56:39 +01:00
|
|
|
margin-right 4px
|
|
|
|
|
|
|
|
&:after
|
|
|
|
content ""
|
|
|
|
display block
|
|
|
|
clear both
|
|
|
|
|
|
|
|
</style>
|