summaryrefslogtreecommitdiffstats
path: root/glances/outputs/static/js/components/plugin-fs.vue
blob: b12252871b16e69ee84fcb5a6bc822a52d98f189 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<template>
    <section class="plugin" id="fs">
        <div class="table-row">
            <div class="table-cell text-left title">FILE SYS</div>
            <div class="table-cell">
                <span v-show="!args.fs_free_space">Used</span>
                <span v-show="args.fs_free_space">Free</span>
            </div>
            <div class="table-cell">Total</div>
        </div>
        <div class="table-row" v-for="(fs, fsId) in fileSystems" :key="fsId">
            <div class="table-cell text-left">
                {{ $filters.minSize(fs.alias ? fs.alias : fs.mountPoint, 36) }}
                <span v-if="(fs.alias ? fs.alias : fs.mountPoint).length + fs.name.length <= 34" class="visible-lg-inline">
                    ({{ fs.name }})
                </span>
            </div>
            <div class="table-cell" :class="getDecoration(fs.mountPoint, 'used')">
                <span v-show="!args.fs_free_space">
                    {{ $filters.bytes(fs.used) }}
                </span>
                <span v-show="args.fs_free_space">
                    {{ $filters.bytes(fs.free) }}
                </span>
            </div>
            <div class="table-cell">{{ $filters.bytes(fs.size) }}</div>
        </div>
    </section>
</template>

<script>
import { orderBy } from 'lodash';
import { store } from '../store.js';

export default {
    props: {
        data: {
            type: Object
        }
    },
    data() {
        return {
            store
        };
    },
    computed: {
        args() {
            return this.store.args || {};
        },
        stats() {
            return this.data.stats['fs'];
        },
        view() {
            return this.data.views['fs'];
        },
        fileSystems() {
            const fileSystems = this.stats.map((fsData) => {
                return {
                    name: fsData['device_name'],
                    mountPoint: fsData['mnt_point'],
                    percent: fsData['percent'],
                    size: fsData['size'],
                    used: fsData['used'],
                    free: fsData['free'],
                    alias: fsData['alias'] !== undefined ? fsData['alias'] : null
                };
            });
            return orderBy(fileSystems, ['mnt_point']);
        }
    },
    methods: {
        getDecoration(mountPoint, field) {
            if (this.view[mountPoint][field] == undefined) {
                return;
            }
            return this.view[mountPoint][field].decoration.toLowerCase();
        }
    }
};
</script>