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/index.js | 10 +++++++-- src/js/app.js | 4 ---- src/js/wired.js | 47 +++++++++++++++++++++++++++++++++++++++ src/templates/main.template.html | 2 +- src/templates/wifi.template.html | 36 +++++++++++++++--------------- src/templates/wired.template.html | 33 +++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 25 deletions(-) create mode 100644 src/js/wired.js create mode 100644 src/templates/wired.template.html diff --git a/src/index.js b/src/index.js index 879e10e..0c34be4 100644 --- a/src/index.js +++ b/src/index.js @@ -14,16 +14,22 @@ * limitations under the License. */ /* JS */ -import { init } from './js/app'; +import * as app from './js/app'; import { api } from 'agl-js-api'; import * as bluetooth from './js/bluetooth'; import * as wifi from './js/wifi'; +import * as wired from './js/wired'; /* CSS */ import './styles/app.scss'; window.bluetooth = bluetooth; window.wifi = wifi; +window.wired = wired; + api.init(); -init(); +app.init(); +bluetooth.init(); +wifi.init(); +wired.init(); 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 diff --git a/src/templates/main.template.html b/src/templates/main.template.html index e37c935..f121092 100644 --- a/src/templates/main.template.html +++ b/src/templates/main.template.html @@ -49,7 +49,7 @@
-
+
Wired
diff --git a/src/templates/wifi.template.html b/src/templates/wifi.template.html index 72b93b4..e36c56c 100644 --- a/src/templates/wifi.template.html +++ b/src/templates/wifi.template.html @@ -13,25 +13,25 @@
- {{ #devices }} -
-
- + {{ #devices }} +
+
+ +
+
+
+ {{ properties.name }}
-
-
- {{ properties.name }} -
-
- {{ properties.ethernet.address}} -
+
+ {{ properties.ethernet.address}}
-
-
-
-
+
+
+
+
- {{ /devices }} -
-
\ No newline at end of file +
+ {{ /devices }} +
+
\ No newline at end of file diff --git a/src/templates/wired.template.html b/src/templates/wired.template.html new file mode 100644 index 0000000..23f1d80 --- /dev/null +++ b/src/templates/wired.template.html @@ -0,0 +1,33 @@ +
+

+
+
+ +
+
+ Wired +
+
+

+
+ {{ #devices }} +
+
+ +
+
+
+ {{ properties.name }} +
+
+ {{ properties.ipv4.address}} +
+
+
+ +
+
+ {{ /devices }} +
+
+
\ No newline at end of file -- cgit 1.2.3-korg