Launch Playlet from web app
This commit is contained in:
1 parent
d65f930247
commit
2a57cc99c7
4 files changed
+35
-7
No files matched your search
@@ -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
|
||||
|
||||
@@ -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: '',
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,9 @@ function getHost() {
|
||||
return urlSearchParams.get('host') ?? window.location.host
|
||||
}
|
||||
|
||||
export { getHost }
|
||||
function getIp() {
|
||||
const host = getHost()
|
||||
return host.split(':')[0]
|
||||
}
|
||||
|
||||
export { getHost, getIp }
|
||||
@@ -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 @@
|
||||
|
||||
<div class="navbar bg-base-100 sticky top-0 z-40">
|
||||
<div class="flex-1">
|
||||
<img
|
||||
src={$appThemeStore === "dark" ? playletLogoDark : playletLogoLight}
|
||||
class="h-8"
|
||||
alt="Playlet Logo"
|
||||
/>
|
||||
<button on:click={() => ExternalControlProtocol.launchApp(appId)}>
|
||||
<img
|
||||
src={$appThemeStore === "dark" ? playletLogoDark : playletLogoLight}
|
||||
class="h-8"
|
||||
alt="Playlet Logo"
|
||||
/>
|
||||
</button>
|
||||
<h4 class="label brightness-75">{version}</h4>
|
||||
</div>
|
||||
<div class="flex-none">
|
||||
|
||||
Reference in new issue
Block a user