diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f7d699b..ea8a869c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Playlet logo in web app is clickable, and launches app if not already on + ## [0.16.0] - 2023-11-13 ### Added diff --git a/playlet-web/src/lib/Api/ExternalControlProtocol.ts b/playlet-web/src/lib/Api/ExternalControlProtocol.ts new file mode 100644 index 00000000..8cd51ac9 --- /dev/null +++ b/playlet-web/src/lib/Api/ExternalControlProtocol.ts @@ -0,0 +1,10 @@ +import { getIp } from "./Host"; + +export class ExternalControlProtocol { + static async launchApp(appId) { + return fetch(`http://${getIp()}:8060/launch/${appId}`, { + method: 'POST', + body: '', + }) + } +} diff --git a/playlet-web/src/lib/Api/Host.ts b/playlet-web/src/lib/Api/Host.ts index 8b2474b6..9646437f 100644 --- a/playlet-web/src/lib/Api/Host.ts +++ b/playlet-web/src/lib/Api/Host.ts @@ -3,4 +3,9 @@ function getHost() { return urlSearchParams.get('host') ?? window.location.host } -export { getHost } \ No newline at end of file +function getIp() { + const host = getHost() + return host.split(':')[0] +} + +export { getHost, getIp } \ No newline at end of file diff --git a/playlet-web/src/lib/NavBar.svelte b/playlet-web/src/lib/NavBar.svelte index de80aa89..61d14053 100644 --- a/playlet-web/src/lib/NavBar.svelte +++ b/playlet-web/src/lib/NavBar.svelte @@ -3,6 +3,7 @@ import playletLogoLight from "assets/logo-light.svg"; import UserIcon from "assets/user.svg.svelte"; import { PlayletApi } from "lib/Api/PlayletApi"; + import { ExternalControlProtocol } from "lib/Api/ExternalControlProtocol"; import { appThemeStore, playletStateStore } from "lib/Stores"; import ThemeSelect from "lib/ThemeToggle.svelte"; @@ -12,10 +13,14 @@ let currentInstance; let loggedInInstance; let username; + let appId = "693751"; playletStateStore.subscribe((value) => { version = value?.app?.lib_version ?? ""; - if (value?.app?.id === "dev") { + if (value?.app?.id) { + appId = value?.app?.id; + } + if (appId === "dev") { version += "-dev"; } if ( @@ -49,11 +54,13 @@