summaryrefslogtreecommitdiffstats
path: root/glances/outputs/static/js/components/plugin-folders.vue
blob: 69f9252624d50ef04dfb4688996a4e6a4d668358 (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
<template>
    <section>
        <div class="table-row" v-if="folders.length > 0">
            <div class="table-cell text-left title">FOLDERS</div>
            <div class="table-cell"></div>
            <div class="table-cell">Size</div>
        </div>
        <div class="table-row" v-for="(folder, folderId) in folders" :key="folderId">
            <div class="table-cell text-left">{{ folder.path }}</div>
            <div class="table-cell"></div>
            <div class="table-cell" :class="getDecoration(folder)">
                {{ $filters.bytes(folder.size) }}
            </div>
        </div>
    </section>
</template>

<script>
export default {
    props: {
        data: {
            type: Object
        }
    },
    computed: {
        stats() {
            return this.data.stats['folders'];
        },
        folders() {
            return this.stats.map((folderData) => {
                return {
                    path: folderData['path'],
                    size: folderData['size'],
                    careful: folderData['careful'],
                    warning: folderData['warning'],
                    critical: folderData['critical']
                };
            });
        }
    },
    methods: {
        getDecoration(folder) {
            if (!Number.isInteger(folder.size)) {
                return;
            }
            if (folder.critical !== null && folder.size > folder.critical * 1000000) {
                return 'critical';
            } else if (folder.warning !== null && folder.size > folder.warning * 1000000) {
                return 'warning';
            } else if (folder.careful !== null && folder.size > folder.careful * 1000000) {
                return 'careful';
            }
            return 'ok';
        }
    }
};
</script>