aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Dapena Paz <jdapena@igalia.com>2022-02-26 12:16:16 +0100
committerJose Dapena Paz <jdapena@igalia.com>2022-03-01 18:04:03 +0100
commit8ad6b022196ec689eed08c0f3315a53723d4af0c (patch)
treead749ca05d0c3948beec81d4f0c3f3a852e8456a
parent48970567f1943fb70ef1526827c21548d23695e7 (diff)
Migrate to new application framework
First, move to use the appService API added as injection in AGL chromium. Then, added stubs for the network and weather APIs as there is no API available right now for them. Bug-AGL: SPEC-4250 Signed-off-by: Jose Dapena Paz <jdapena@igalia.com> Change-Id: I974097edcef6318585e4e79360dbec6fea7cf480
-rw-r--r--package.json1
-rw-r--r--src/config.json2
-rw-r--r--src/config.xml17
-rw-r--r--src/index.js3
-rw-r--r--src/js/agl_stubs_network.js13
-rw-r--r--src/js/agl_stubs_weather.js20
-rw-r--r--src/js/apps.js17
-rw-r--r--src/js/background.js6
-rw-r--r--src/js/network.js4
-rw-r--r--src/js/templates.js4
-rw-r--r--src/js/time.js2
11 files changed, 48 insertions, 41 deletions
diff --git a/package.json b/package.json
index 2f4772a..755256a 100644
--- a/package.json
+++ b/package.json
@@ -37,7 +37,6 @@
},
"dependencies": {
"bootstrap": "4.4.1",
- "agl-js-api": "https://github.com/AGL-web-applications/agl-js-api.git#master",
"mustache": "^3.1.0"
}
}
diff --git a/src/config.json b/src/config.json
index 89eb0c8..5001551 100644
--- a/src/config.json
+++ b/src/config.json
@@ -18,7 +18,7 @@
}
],
"background": "webapps-html5-background",
- "launch": "webapps-html5-launcher",
+ "launch": "launcher",
"network": {
"bluetooth": "fab fa-bluetooth-b",
"ethernet": "fas fa-network-wired",
diff --git a/src/config.xml b/src/config.xml
index fd74ca5..c882d1f 100644
--- a/src/config.xml
+++ b/src/config.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="webapps-html5-homescreen" version="1.0.0">
+<widget xmlns="http://www.w3.org/ns/widgets" id="homescreen" version="1.0.0">
<name>Homescreen</name>
<icon src="icon.svg"/>
<content src="index.html" type="text/html"/>
@@ -8,20 +8,7 @@
<license>APL 2.0</license>
<surface role="panel" panel="left"/>
<window width="218"/>
- <feature name="urn:AGL:widget:required-permission">
- <param name="urn:AGL:permission::system:run-by-default" value="required" />
- <param name="urn:AGL:permission::public:no-htdocs" value="required" />
- <param name="urn:AGL:permission::public:display" value="required" />
- <param name="urn:AGL:permission::public:audio" value="required" />
- <param name="urn:AGL:permission:afm:system:widget" value="required" /> <!-- list available apps -->
- <param name="urn:AGL:permission:afm:system:runner" value="required" /> <!-- run other apps -->
- <param name="urn:AGL:permission::public:applications:read" value="required" /> <!-- get app icons -->
- </feature>
<feature name="urn:AGL:widget:required-api">
- <param name="homescreen" value="ws" />
- <param name="network-manager" value="ws" />
- <param name="weather" value="ws" />
- <param name="Bluetooth-Manager" value="ws" />
- <param name="afm-main" value="ws" />
+ <param name="agl_appservice" value="injection" />
</feature>
</widget>
diff --git a/src/index.js b/src/index.js
index 8198355..aac4372 100644
--- a/src/index.js
+++ b/src/index.js
@@ -17,8 +17,6 @@
/* CSS */
import './styles/app.scss';
-import { api } from 'agl-js-api';
-
import * as app from './js/app';
import * as apps from './js/apps';
import * as time from './js/time';
@@ -26,6 +24,5 @@ import * as background from './js/background';
window.apps = apps;
window.time = time;
-api.init();
background.load();
app.init();
diff --git a/src/js/agl_stubs_network.js b/src/js/agl_stubs_network.js
new file mode 100644
index 0000000..2b84daf
--- /dev/null
+++ b/src/js/agl_stubs_network.js
@@ -0,0 +1,13 @@
+export function technologies() {
+ return new Promise((resolve, reject) => {
+ resolve({
+ values: []
+ });
+ });
+}
+
+export function on_global_state() {
+ return new Promise((resolve, reject) => {
+ resolve("stub");
+ });
+}
diff --git a/src/js/agl_stubs_weather.js b/src/js/agl_stubs_weather.js
new file mode 100644
index 0000000..45d5f1c
--- /dev/null
+++ b/src/js/agl_stubs_weather.js
@@ -0,0 +1,20 @@
+export function current_weather() {
+ return new Promise((resolve, reject) => {
+ resolve({
+ weather: [
+ {
+ icon: "01d",
+ description: "clear sky"
+ },
+ ],
+ wind: {
+ speed: 7.56
+ },
+ main: {
+ temp: 46,
+ humidity: 53
+ },
+ name: "Mountain View",
+ });
+ });
+} \ No newline at end of file
diff --git a/src/js/apps.js b/src/js/apps.js
index 9fe7107..e3e0158 100644
--- a/src/js/apps.js
+++ b/src/js/apps.js
@@ -1,5 +1,4 @@
import { load as load_template } from './templates';
-import { homescreen, afmMain } from 'agl-js-api';
import Mustache from 'mustache';
var configjson = require('../config.json');
@@ -15,26 +14,24 @@ function show() {
function locateApp(appId, appList) {
return appList.find(function(app){
- return app.id.split('@')[0] === appId
+ return app[0].split('@')[0] === appId
});
}
function load_application_list() {
- afmMain.runnables().then(function(result) {
+ navigator.appService.getApplications(true, result => {
configjson.apps.forEach(function(app) {
var internalApp = locateApp(app.id, result);
if( internalApp ) {
page.apps.push({
- id: internalApp.id,
- name: internalApp.name,
+ id: internalApp[0],
+ name: internalApp[1],
icon: app.icon
});
if( app.id === configjson.launch ) {
- afmMain.start(internalApp.id).then(function(result) {
- console.log("success: " + result);
- });
+ navigator.appService.start(internalApp[0]);
}
}
@@ -45,9 +42,7 @@ function load_application_list() {
}
export function start(appId) {
- homescreen.showWindow(appId.split('@')[0]).then(function(result) {
- console.log("success: " + result);
- });
+ navigator.appService.start(appId.split('@')[0]);
}
export function init(node) {
diff --git a/src/js/background.js b/src/js/background.js
index 38408ed..4a9bd69 100644
--- a/src/js/background.js
+++ b/src/js/background.js
@@ -1,11 +1,7 @@
-import { homescreen, afmMain } from 'agl-js-api';
-
var configjson = require('../config.json');
export function load() {
- afmMain.start(configjson.background).then(function(result) {
- console.log("loading background: " + result);
- });
+ navigator.appService.start(configjson.background);
}
diff --git a/src/js/network.js b/src/js/network.js
index 3e1caad..054309e 100644
--- a/src/js/network.js
+++ b/src/js/network.js
@@ -1,5 +1,5 @@
import { load as load_template } from './templates';
-import { network } from 'agl-js-api';
+import * as network from './agl_stubs_network';
import Mustache from 'mustache';
var configjson = require('../config.json');
@@ -37,4 +37,4 @@ export function init(node) {
network.on_global_state(function(result) {
console.log('GLOBAL SATATE', result);
});
-} \ No newline at end of file
+}
diff --git a/src/js/templates.js b/src/js/templates.js
index 2513722..49b541c 100644
--- a/src/js/templates.js
+++ b/src/js/templates.js
@@ -2,12 +2,12 @@ export function load(template) {
return new Promise(function(resolve, reject){
var xhr = new XMLHttpRequest();
- xhr.open('GET', '/templates/'+template);
+ xhr.open('GET', './templates/'+template);
xhr.send();
xhr.onload = function() {
- if (xhr.status != 200) {
+ if (xhr.status != 0 && xhr.status != 200) {
console.error('Error loading template', xhr.status, xhr.statusText);
reject(xhr.status);
} else {
diff --git a/src/js/time.js b/src/js/time.js
index 3c22419..070ff97 100644
--- a/src/js/time.js
+++ b/src/js/time.js
@@ -1,6 +1,6 @@
import { load as load_template } from './templates';
import Mustache from 'mustache';
-import { weather } from 'agl-js-api';
+import * as weather from './agl_stubs_weather';
var template;
var root;