summaryrefslogtreecommitdiffstats
path: root/src/js/network.js
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-12-11 08:39:27 +0100
committerLorenzo Tilve <ltilve@igalia.com>2020-02-04 19:12:47 +0100
commit6d8916c58d823b13b89477f59bf05373e87f3a98 (patch)
tree97142e38adc872fe58999b7d01f806d66153be3e /src/js/network.js
parentfb39b8f31f9323f5e56670de2f382f7b19daed08 (diff)
RESTRUCT Upadate homescreen layout
Diffstat (limited to 'src/js/network.js')
-rw-r--r--src/js/network.js31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/js/network.js b/src/js/network.js
index bb60a1d..3e1caad 100644
--- a/src/js/network.js
+++ b/src/js/network.js
@@ -1,27 +1,38 @@
+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 render_network_item(networkItem) {
- document.getElementById('networkStatusContainer').innerHTML += Mustache.render(template, networkItem);
+function show() {
+ root.innerHTML = Mustache.render(template, page);
}
function load_network_state() {
network.technologies().then(function(result) {
- result.values.forEach(function(networkItem) {
- networkItem.icon = configjson.network[networkItem.technology];
- render_network_item(networkItem);
- });
+ page.items = result.values;
+ show();
});
}
-export function init() {
- template = document.getElementById('network-status-template').innerHTML;
- Mustache.parse(template);
- load_network_state();
+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);