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

var configjson = require('../config.json');
var template;
var root;
var page = {
    items: [],
    icon: function() {
        return configjson.network[this.technology];
    }
};

function show() {
    root.innerHTML = Mustache.render(template, page);
}

function load_network_state() {
    network.technologies().then(function(result) {
        page.items = result.values;
        show();
    });

}

export function init(node) {
    load_template('network.template.html').then(function(result) {
        template = result;
        root = node;
        Mustache.parse(template);
        load_network_state();
    }, function(error) {
        console.error('ERRROR loading main template', error);
    });

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