aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-06-21 11:00:42 +0200
committerHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-06-21 11:00:42 +0200
commitaac66099e68d635cbb5945366e00232abf868bdb (patch)
tree68d22601d2d71736b53a95652d40bbaef019ae4e
parent10d97b609b159fb4318c8f3681cf1f857fa34ede (diff)
FUNCT Basic support to launch apps
-rw-r--r--src/index.html4
-rw-r--r--src/index.js6
-rw-r--r--src/js/app.js31
-rw-r--r--src/styles/main.scss3
4 files changed, 36 insertions, 8 deletions
diff --git a/src/index.html b/src/index.html
index f280ebe..2821653 100644
--- a/src/index.html
+++ b/src/index.html
@@ -8,12 +8,12 @@
<body>
<div id="AppContainer" class="parent">
<script id="item-template" type="x-tmpl-mustache">
- <div class="item">
+ <a href="#" class="item" app-id="{{ id }}" onclick="window.launch(this);">
<img class="icon" src="{{ icon }}" onload="SVGInject(this);">
<div class="name">
{{ name }}
</div>
- </div>
+ </a>
</script>
</div>
<div class="log" id="log">
diff --git a/src/index.js b/src/index.js
index 7ffa614..007f72f 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,7 +1,11 @@
/* JS */
import '@iconfu/svg-inject';
import './js/AFB.js';
-import './js/app.js';
+import { init, launch } from './js/app.js';
/* CSS */
import './styles/app.scss';
+
+window.launch = launch;
+
+document.addEventListener('DOMContentLoaded', init); \ No newline at end of file
diff --git a/src/js/app.js b/src/js/app.js
index fccf04e..9c65e4f 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -46,14 +46,35 @@ function load_application_list() {
});
}
-function init() {
+export function launch(app) {
+ var appId = app.getAttribute('app-id');
+ var ws = new afb.ws(function() {
+ var api_verb = "afm-main/start";
+ var request = {id: appId};
+ ws.call(api_verb, request).then(
+ function(obj) {
+ log("success: " + obj.response);
+ },
+ function(obj) {
+ //TODO Manage errors
+ log("failure");
+ }
+ );
+ },
+ function() {
+ //TODO Manage errors
+ log("ws aborted");
+ });
+}
+
+export function init() {
template = document.getElementById('item-template').innerHTML;
Mustache.parse(template);
+
+ // host: "raspberrypi3.local:31022",
afb = new AFB({
- host: "raspberrypi3.local:31022",
+ host: host+":"+port,
token: token
});
load_application_list();
-}
-
-document.addEventListener('DOMContentLoaded', init); \ No newline at end of file
+} \ No newline at end of file
diff --git a/src/styles/main.scss b/src/styles/main.scss
index 1c6220e..a72b94b 100644
--- a/src/styles/main.scss
+++ b/src/styles/main.scss
@@ -23,6 +23,9 @@ body {
height: 100%;
.item {
+ color: map-get($colors, font);
+ text-decoration: none;
+
.icon {
width: 100%;
height: 100%;