summaryrefslogtreecommitdiffstats
path: root/src/js/network.js
blob: bb60a1dfd5aed9ea796a6aa1a2054f639ec0e831 (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
import { network } from 'agl-js-api';
import Mustache from 'mustache';

var configjson = require('../config.json');
var template;

function render_network_item(networkItem) {
    document.getElementById('networkStatusContainer').innerHTML += Mustache.render(template, networkItem);
}

function load_network_state() {
    network.technologies().then(function(result) {
        result.values.forEach(function(networkItem) {
            networkItem.icon = configjson.network[networkItem.technology];
            render_network_item(networkItem);
        });
    });

}

export function init() {
    template = document.getElementById('network-status-template').innerHTML;
    Mustache.parse(template);
    load_network_state();

    network.on_global_state(function(result) {
        console.log('GLOBAL SATATE', result);
    });
}