summaryrefslogtreecommitdiffstats
path: root/src/js/apps.js
diff options
context:
space:
mode:
authorHumberto Alfonso Díaz <humberto.alfonso@asvito.es>2019-10-08 12:25:16 +0200
committerLorenzo Tilve <ltilve@igalia.com>2020-02-04 19:12:47 +0100
commit168f29231cd8fa3b3c8f69f287c9523e67af0ef9 (patch)
treefcea6299c7a889bc0e1ead18f6d3907b2ff68aac /src/js/apps.js
parent45df4d06ae64af40501dcec5a0424fab4490ab5c (diff)
FUNCT Integrate header apps
Diffstat (limited to 'src/js/apps.js')
-rw-r--r--src/js/apps.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/js/apps.js b/src/js/apps.js
new file mode 100644
index 0000000..73d926e
--- /dev/null
+++ b/src/js/apps.js
@@ -0,0 +1,44 @@
+import { afmMain } from 'agl-js-api';
+import Mustache from 'mustache';
+
+var configjson = require('../config.json');
+var template;
+var parent;
+
+function renderApp(app) {
+ parent.innerHTML = Mustache.render(template, app) + parent.innerHTML;
+}
+
+function locateApp(appId, appList) {
+ return appList.find(function(app){
+ return app.id.split('@')[0] === appId
+ });
+}
+
+function load_application_list() {
+ afmMain.runnables().then(function(result) {
+ configjson.apps.forEach(function(app) {
+ var internalApp = locateApp(app.id, result);
+
+ renderApp({
+ id: internalApp.id,
+ name: internalApp.name,
+ icon: app.icon
+ });
+ });
+ });
+}
+
+export function start(node) {
+ var appId = node.getAttribute('app-id');
+ afmMain.start(appId).then(function(result) {
+ console.log("success: " + result);
+ });
+}
+
+export function init() {
+ template = document.getElementById('app-template').innerHTML;
+ parent = document.getElementById('app-template').parentNode
+ Mustache.parse(template);
+ load_application_list();
+} \ No newline at end of file