summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.js10
-rw-r--r--src/js/app.js4
-rw-r--r--src/js/wired.js47
-rw-r--r--src/templates/main.template.html2
-rw-r--r--src/templates/wifi.template.html36
-rw-r--r--src/templates/wired.template.html33
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