summaryrefslogtreecommitdiffstats
path: root/src/js
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 /src/js
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
Diffstat (limited to 'src/js')
-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
7 files changed, 45 insertions, 21 deletions
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;