generated from rweich/streamdeck-ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPropertyinspector.ts
46 lines (36 loc) · 1.22 KB
/
Propertyinspector.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Streamdeck } from "@rweich/streamdeck-ts";
import { Settings } from "./Settings";
const pi = new Streamdeck().propertyinspector();
pi.on("didReceiveGlobalSettings", ({ settings }) => {
console.log("got settings", settings);
const pluginId = pi.pluginUUID ?? "";
if (!pluginId) {
console.log("pi has no uuid! is it registered already?");
return;
}
document.querySelectorAll<HTMLElement>("[data-url]").forEach((node) => {
node.onclick = () => {
if (node.dataset.url) {
pi.openUrl(node.dataset.url);
}
};
});
const button = document.querySelector<HTMLButtonElement>("#save")!;
const endpointInput =
document.querySelector<HTMLInputElement>("#apiEndpoint")!;
const apiKeyInput = document.querySelector<HTMLInputElement>("#apiKey")!;
button.disabled = false;
button.onclick = () => {
const payload: Settings = {
apiEndpoint: endpointInput.value ?? "",
apiKey: apiKeyInput.value,
};
pi.setGlobalSettings(pluginId, payload);
};
endpointInput.value = (settings as Settings).apiEndpoint ?? "";
apiKeyInput.value = (settings as Settings).apiKey ?? "";
});
pi.on("websocketOpen", ({ uuid }) => {
pi.getGlobalSettings(uuid);
});
export default pi;