diff options
author | Humberto Alfonso Díaz <humberto.alfonso@asvito.es> | 2019-10-08 11:37:42 +0200 |
---|---|---|
committer | Lorenzo Tilve <ltilve@igalia.com> | 2020-02-04 20:02:02 +0100 |
commit | 020825740296db5a74864e1cd62978c732b079f3 (patch) | |
tree | 435671af362f044f12f4df9297b63dceeaa12afc /src/js/app.js | |
parent | 74d935c6a3a4cc130000f23e84a7362fbb8db1bd (diff) |
FUNCT Integrate agl-js-api
Change-Id: I04ba92c055b761c84bbfb8382921628fd3c5b262
Diffstat (limited to 'src/js/app.js')
-rw-r--r-- | src/js/app.js | 72 |
1 files changed, 6 insertions, 66 deletions
diff --git a/src/js/app.js b/src/js/app.js index 7f92d4f..08ae599 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -15,13 +15,9 @@ */ import Mustache from 'mustache'; -var configjson = require('../config.json'); +import { afmMain } from 'agl-js-api'; -var host = document.location.hostname; -var port = document.location.port; -var args = new URLSearchParams(document.location.search.substring(1)); -var token = args.get("x-afb-token") || args.get("token") || "HELLO"; -var afb; +var configjson = require('../config.json'); var template; function log(smgs) { @@ -69,76 +65,20 @@ function render_applications(apps) { } function load_application_list() { - var ws = new afb.ws(function() { - var api_verb = "afm-main/runnables"; - ws.call(api_verb, {}).then( - function(obj) { - render_applications(obj.response); - }, - function(obj) { - //TODO Manage errors - log("failure"); - } - ); - }, - function() { - //TODO manage errors - log("ws aborted"); - }); -} - -export function display(app) { - var appId = app.getAttribute('app-id'); - var ws = new afb.ws(function() { - var api_verb = "homescreen/showWindow"; - var split_id = appId.split('@'); - var request = {application_id: split_id[0], parameter: {area: "normal.full"}}; - ws.call(api_verb, request).then( - function(obj) { - log("success: " + obj.response); - }, - function(obj) { - //TODO Manage errors - log("failure on display"); - } - ); - }, - function() { - //TODO Manage errors - log("ws aborted"); + afmMain.runnables().then(function(result) { + render_applications(result); }); } 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); - display(app); - }, - function(obj) { - //TODO Manage errors - log("failure on launch"); - } - ); - }, - function() { - //TODO Manage errors - log("ws aborted"); + afmMain.start(appId).then(function(result) { + log("success: " + result); }); } export function init() { template = document.getElementById('item-template').innerHTML; Mustache.parse(template); - - // host: "raspberrypi3.local:31022", - afb = new AFB({ - host: host+":"+port, - token: token - }); load_application_list(); }
\ No newline at end of file |