diff options
author | Humberto Alfonso Díaz <humberto.alfonso@asvito.es> | 2019-12-05 13:21:52 +0100 |
---|---|---|
committer | Lorenzo Tilve <ltilve@igalia.com> | 2020-02-04 19:20:13 +0100 |
commit | 29051c70c53999fa9beec83fbd09ec17fd244539 (patch) | |
tree | bc415bcd242f1d4add1a598a8f0d18070a8d2467 | |
parent | adf54e211279a4efd6231b3396fbb28c7267258c (diff) |
FUNCT Added wired connection information
-rw-r--r-- | src/index.js | 10 | ||||
-rw-r--r-- | src/js/app.js | 4 | ||||
-rw-r--r-- | src/js/wired.js | 47 | ||||
-rw-r--r-- | src/templates/main.template.html | 2 | ||||
-rw-r--r-- | src/templates/wifi.template.html | 36 | ||||
-rw-r--r-- | src/templates/wired.template.html | 33 |
6 files changed, 107 insertions, 25 deletions
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 @@ <div class="col-1"> <i class="fas fa-network-wired"></i> </div> - <div class="col-9"> + <div class="col-9" onclick="window.wired.show()"> Wired </div> <div class="col-2 text-right"> 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 @@ </div> </h2> <div class="list-group scrollable"> - {{ #devices }} - <div class="row border-bottom py-3 list-group-action"> - <div class="col-1"> - <i class="fas fa-wifi"></i> + {{ #devices }} + <div class="row border-bottom py-3 list-group-action"> + <div class="col-1"> + <i class="fas fa-wifi"></i> + </div> + <div class="col-6"> + <div> + {{ properties.name }} </div> - <div class="col-6"> - <div> - {{ properties.name }} - </div> - <div class="badge badge-secondary"> - {{ properties.ethernet.address}} - </div> + <div class="badge badge-secondary"> + {{ properties.ethernet.address}} </div> - <div class="col-5 text-right"> - <div class="progress"> - <div class="progress-bar" role="progressbar" style="width: {{properties.strength}}%;" aria-valuenow="{{properties.strength}}" aria-valuemin="0" aria-valuemax="100"></div> - </div> + </div> + <div class="col-5 text-right"> + <div class="progress"> + <div class="progress-bar" role="progressbar" style="width: {{properties.strength}}%;" aria-valuenow="{{properties.strength}}" aria-valuemin="0" aria-valuemax="100"></div> </div> </div> - {{ /devices }} - </div> - </div>
\ No newline at end of file + </div> + {{ /devices }} + </div> +</div>
\ 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 @@ +<div class="container"> + <h2 class="my-5"> + <div class="row"> + <div class="col-1" onclick="wired.hide()"> + <i class="fas fa-chevron-left"></i> + </div> + <div class="col-10"> + Wired + </div> + </div> + </h2> + <div class="list-group scrollable"> + {{ #devices }} + <div class="row border-bottom py-3 list-group-action"> + <div class="col-1"> + <i class="fas fa-network-wired"></i> + </div> + <div class="col-9"> + <div> + {{ properties.name }} + </div> + <div class="badge badge-secondary"> + {{ properties.ipv4.address}} + </div> + </div> + <div class="col-2 text-right"> + + </div> + </div> + {{ /devices }} + </div> +</div> +</div>
\ No newline at end of file |