summaryrefslogtreecommitdiffstats
path: root/glances/outputs/static/js/components/plugin-wifi.vue
blob: 9fa0aa521879c271ed14d559c84642f141abf496 (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
<template>
    <section class="plugin" id="wifi">
        <div class="table-row" v-if="hotspots.length > 0">
            <div class="table-cell text-left title">WIFI</div>
            <div class="table-cell"></div>
            <div class="table-cell">dBm</div>
        </div>
        <div class="table-row" v-for="(hotspot, hotspotId) in hotspots" :key="hotspotId">
            <div class="table-cell text-left">
                {{ $filters.limitTo(hotspot.ssid, 20) }}
                <span>
                    {{ hotspot.security }}
                </span>
            </div>
            <div class="table-cell"></div>
            <div class="table-cell" :class="getDecoration(hotspot, 'signal')">
                {{ hotspot.signal }}
            </div>
        </div>
    </section>
</template>

<script>
import { orderBy } from 'lodash';

export default {
    props: {
        data: {
            type: Object
        }
    },
    computed: {
        stats() {
            return this.data.stats['wifi'];
        },
        view() {
            return this.data.views['wifi'];
        },
        hotspots() {
            const hotspots = this.stats
                .map((hotspotData) => {
                    if (hotspotData['ssid'] === '') {
                        return;
                    }
                    return {
                        ssid: hotspotData['ssid'],
                        signal: hotspotData['signal'],
                        security: hotspotData['security']
                    };
                })
                .filter(Boolean);
            return orderBy(hotspots, ['ssid']);
        }
    },
    methods: {
        getDecoration(hotpost, field) {
            if (this.view[hotpost.ssid][field] === undefined) {
                return;
            }
            return this.view[hotpost.ssid][field].decoration.toLowerCase();
        }
    }
};
</script>