summaryrefslogtreecommitdiffstats
path: root/glances/outputs/static/js/components/plugin-memswap.vue
blob: da1da618f1f186930baa1f60861c1485e634c602 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<template>
    <section id="memswap" class="plugin">
        <div class="table">
            <div class="table-row">
                <div class="table-cell text-left title">SWAP</div>
                <div class="table-cell">{{ percent }}%</div>
            </div>
            <div class="table-row">
                <div class="table-cell text-left">total:</div>
                <div class="table-cell">{{ $filters.bytes(total) }}</div>
            </div>
            <div class="table-row">
                <div class="table-cell text-left">used:</div>
                <div class="table-cell" :class="getDecoration('used')">
                    {{ $filters.bytes(used) }}
                </div>
            </div>
            <div class="table-row">
                <div class="table-cell text-left">free:</div>
                <div class="table-cell">{{ $filters.bytes(free) }}</div>
            </div>
        </div>
    </section>
</template>

<script>
export default {
    props: {
        data: {
            type: Object
        }
    },
    computed: {
        stats() {
            return this.data.stats['memswap'];
        },
        view() {
            return this.data.views['memswap'];
        },
        percent() {
            return this.stats['percent'];
        },
        total() {
            return this.stats['total'];
        },
        used() {
            return this.stats['used'];
        },
        free() {
            return this.stats['free'];
        }
    },
    methods: {
        getDecoration(value) {
            if (this.view[value] === undefined) {
                return;
            }
            return this.view[value].decoration.toLowerCase();
        }
    }
};
</script>