From 29051c70c53999fa9beec83fbd09ec17fd244539 Mon Sep 17 00:00:00 2001 From: Humberto Alfonso Díaz Date: Thu, 5 Dec 2019 13:21:52 +0100 Subject: FUNCT Added wired connection information --- src/js/app.js | 4 ---- src/js/wired.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 src/js/wired.js (limited to 'src/js') diff --git a/src/js/app.js b/src/js/app.js index fb7f77f..6e5ab20 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -1,5 +1,3 @@ -import * as bluetooth from './bluetooth'; -import * as wifi from './wifi'; import { load as load_template } from './templates'; import Mustache from 'mustache'; @@ -19,8 +17,6 @@ export function init() { template = result; Mustache.parse(template); show(); - bluetooth.init(); - wifi.init(); }, function(error) { console.error('ERRROR loading main template', error); }); diff --git a/src/js/wired.js b/src/js/wired.js new file mode 100644 index 0000000..c5407c8 --- /dev/null +++ b/src/js/wired.js @@ -0,0 +1,47 @@ +import { network } from 'agl-js-api'; +import Mustache from 'mustache'; +import { load as load_template } from './templates'; +import * as app from './app'; + +var template; +var page = { + devices: [] +} + +function render(){ + document.body.innerHTML = Mustache.render(template, page); +} + +function update_devices(devices) { + console.log(devices); + page.devices = []; + devices.forEach(function(device) { + if( device.properties.type === 'ethernet' ) { + page.devices.push(device); + } + }); + render(); +} + +function refresh_devices() { + network.services().then(function(result) { + update_devices(result.values); + }); +} + +export function init() { + load_template('wired.template.html').then(function(result) { + template = result; + Mustache.parse(template); + }, function(error) { + console.error('ERROR Loading wired template', error); + }); +} + +export function show() { + refresh_devices(); +} + +export function hide() { + app.show(); +} \ No newline at end of file -- cgit 1.2.3-korg