From 69af4d9b9b209fcb33ef9071ddfa8561106044c2 Mon Sep 17 00:00:00 2001 From: Jose Dapena Paz Date: Tue, 31 May 2022 18:40:52 +0200 Subject: Adapt to new application framework Drop usage of agl-js-api, and just provide a mock for bluetooth and network calls. Bug-AGL: SPEC-4248 Signed-off-by: Jose Dapena Paz Change-Id: I9265a44f810012dd68ccfdd675de157156a73f79 --- package.json | 4 ++-- src/index.js | 2 -- src/js/agl_stubs_bluetooth.js | 29 +++++++++++++++++++++++++++++ src/js/agl_stubs_network.js | 7 +++++++ src/js/bluetooth.js | 2 +- src/js/templates.js | 4 ++-- src/js/wifi.js | 2 +- src/js/wired.js | 2 +- 8 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 src/js/agl_stubs_bluetooth.js create mode 100644 src/js/agl_stubs_network.js diff --git a/package.json b/package.json index b4840fb..9a81586 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,10 @@ "build": "webpack", "start": "webpack-dev-server" }, - "homepage": "https://github.com/AGL-web-applications/settings", + "homepage": "https://git.automotivelinux.org/apps/html5-settings", "repository": { "type": "git", - "url": "git@github.com:AGL-web-applications/agl-js-api.git" + "url": "https://gerrit.automotivelinux.org/gerrit/apps/html5-settings" }, "keywords": [ "agl", diff --git a/src/index.js b/src/index.js index 5f640a8..c1de9fc 100644 --- a/src/index.js +++ b/src/index.js @@ -16,7 +16,6 @@ /* JS */ import * as app from './js/app'; -import { api } from 'agl-js-api'; import * as bluetooth from './js/bluetooth'; import * as wifi from './js/wifi'; import * as wired from './js/wired'; @@ -30,7 +29,6 @@ window.wifi = wifi; window.wired = wired; window.date = date; -api.init(); app.init(); bluetooth.init(); wifi.init(); diff --git a/src/js/agl_stubs_bluetooth.js b/src/js/agl_stubs_bluetooth.js new file mode 100644 index 0000000..34b92e0 --- /dev/null +++ b/src/js/agl_stubs_bluetooth.js @@ -0,0 +1,29 @@ +export function managed_objects() { + return new Promise((resolve, reject) => { + resolve({ + devices: [] + }) + }); +} + + +let _powered = false + +export function adapter_state(new_state) { + return new Promise((resolve, reject) => { + if (typeof new_state !== undefined) + _powered = new_state.powered; + resolve({ + powered: _powered + }); + }); +} + +export function pair() { +} + +export function connect() { +} + +export function disconnect() { +} \ No newline at end of file diff --git a/src/js/agl_stubs_network.js b/src/js/agl_stubs_network.js new file mode 100644 index 0000000..b0e6823 --- /dev/null +++ b/src/js/agl_stubs_network.js @@ -0,0 +1,7 @@ +export function services() { + return new Promise((resolve, reject) => { + resolve({ + values: [] + }); + }); +} diff --git a/src/js/bluetooth.js b/src/js/bluetooth.js index 258a8a7..6793feb 100644 --- a/src/js/bluetooth.js +++ b/src/js/bluetooth.js @@ -1,4 +1,4 @@ -import { bluetooth } from 'agl-js-api'; +import * as bluetooth from './agl_stubs_bluetooth'; import Mustache from 'mustache'; import { load as load_template } from './templates'; import * as app from './app'; diff --git a/src/js/templates.js b/src/js/templates.js index 2513722..4b71638 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 != 200 && xhr.status != 0) { console.error('Error loading template', xhr.status, xhr.statusText); reject(xhr.status); } else { diff --git a/src/js/wifi.js b/src/js/wifi.js index 15d9173..49a2543 100644 --- a/src/js/wifi.js +++ b/src/js/wifi.js @@ -1,4 +1,4 @@ -import { network } from 'agl-js-api'; +import * as network from './agl_stubs_network'; import Mustache from 'mustache'; import { load as load_template } from './templates'; import * as app from './app'; diff --git a/src/js/wired.js b/src/js/wired.js index c5407c8..c2e137e 100644 --- a/src/js/wired.js +++ b/src/js/wired.js @@ -1,4 +1,4 @@ -import { network } from 'agl-js-api'; +import * as network from './agl_stubs_network'; import Mustache from 'mustache'; import { load as load_template } from './templates'; import * as app from './app'; -- cgit 1.2.3-korg