Skip to content

Commit

Permalink
Fixed demo UI using new FDC3 UI Constants
Browse files Browse the repository at this point in the history
  • Loading branch information
robmoffat committed Nov 14, 2024
1 parent 84bab84 commit 3cbbb89
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class HeartbeatListener implements RegisterableListener {
heartbeatEventUuid: (_m as HeartbeatEvent).meta.eventUuid
}
} as HeartbeatAcknowledgementRequest)
console.log("Heartbeat acknowledged")
//console.log("Heartbeat acknowledged")
}

async register(): Promise<void> {
Expand Down
16 changes: 2 additions & 14 deletions toolbox/fdc3-for-web/demo/src/client/da/dummy-desktop-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DemoServerContext } from "./DemoServerContext";
import { FDC3_2_1_JSONDirectory } from "./FDC3_2_1_JSONDirectory";
import { AppRegistration, DefaultFDC3Server, DirectoryApp, ServerContext } from "@kite9/fdc3-web-impl";
import { ChannelState, ChannelType } from "@kite9/fdc3-web-impl/src/handlers/BroadcastHandler";
import { link } from "./util";
import { link, UI, UI_URLS } from "./util";
import { BrowserTypes } from "@kite9/fdc3-schema";

type WebConnectionProtocol2LoadURL = BrowserTypes.WebConnectionProtocol2LoadURL
Expand Down Expand Up @@ -36,19 +36,7 @@ function getApproach(): Approach {
return out;
}

export enum UI { DEFAULT, DEMO }

export const UI_URLS = {
[UI.DEMO]: {
intentResolverUrl: window.location.origin + "/static/da/intent-resolver.html",
channelSelectorUrl: window.location.origin + "/static/da/channel-selector.html",
},
[UI.DEFAULT]: {
// TODO: REPLACE WITH FDC3.FINOS.ORG URLS AFTER GO-LIVE
intentResolverUrl: "http://localhost:4002/intent-resolver.html",
channelSelectorUrl: "http://localhost:4002/channel-selector.html",
}
}


function getUIKey(): UI {
const cb = document.getElementById("ui") as HTMLInputElement;
Expand Down
3 changes: 1 addition & 2 deletions toolbox/fdc3-for-web/demo/src/client/da/embed.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { io } from "socket.io-client"
import { link } from "./util";
import { link, UI, UI_URLS } from "./util";
import { APP_HELLO } from "../../message-types";
import { UI, UI_URLS } from "./dummy-desktop-agent";

const appWindow = window.parent;

Expand Down
17 changes: 15 additions & 2 deletions toolbox/fdc3-for-web/demo/src/client/da/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ import { InstanceID } from "@kite9/fdc3-web-impl"
import { Socket } from "socket.io-client"
import { FDC3_APP_EVENT, FDC3_DA_EVENT } from "../../message-types"

export enum UI { DEFAULT, DEMO }

export const UI_URLS = {
[UI.DEMO]: {
intentResolverUrl: window.location.origin + "/static/da/intent-resolver.html",
channelSelectorUrl: window.location.origin + "/static/da/channel-selector.html",
},
[UI.DEFAULT]: {
// TODO: REPLACE WITH FDC3.FINOS.ORG URLS AFTER GO-LIVE
intentResolverUrl: "http://localhost:4002/intent-resolver.html",
channelSelectorUrl: "http://localhost:4002/channel-selector.html",
}
}

export function link(socket: Socket, channel: MessageChannel, source: InstanceID) {
socket.on(FDC3_DA_EVENT, (data: any, to: InstanceID) => {
console.log(`DA Sent ${JSON.stringify(data)} from socket`)
//console.log(`DA Sent ${JSON.stringify(data)} from socket`)
channel.port2.postMessage(data)
})

channel.port2.onmessage = function (event) {
console.log(`App Sent ${JSON.stringify(event.data)} from message port`)
//console.log(`App Sent ${JSON.stringify(event.data)} from message port`)
socket.emit(FDC3_APP_EVENT, event.data, source)
}
}
4 changes: 2 additions & 2 deletions toolbox/fdc3-for-web/demo/src/client/ui/intent-resolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppIdentifier } from "@kite9/fdc3-standard";
import { BrowserTypes } from "@kite9/fdc3-schema";
import { FDC3_USER_INTERFACE_HANDSHAKE_TYPE, FDC3_USER_INTERFACE_HELLO_TYPE, FDC3_USER_INTERFACE_RESOLVE_ACTION_TYPE, FDC3_USER_INTERFACE_RESTYLE_TYPE } from "@kite9/fdc3-schema/generated/api/BrowserTypes";
import { FDC3_USER_INTERFACE_HANDSHAKE_TYPE, FDC3_USER_INTERFACE_HELLO_TYPE, FDC3_USER_INTERFACE_RESOLVE_ACTION_TYPE, FDC3_USER_INTERFACE_RESOLVE_TYPE, FDC3_USER_INTERFACE_RESTYLE_TYPE } from "@kite9/fdc3-schema/generated/api/BrowserTypes";

type IframeResolveAction = BrowserTypes.Fdc3UserInterfaceResolveAction
type IframeResolvePayload = BrowserTypes.Fdc3UserInterfaceResolvePayload
Expand Down Expand Up @@ -67,7 +67,7 @@ window.addEventListener("load", () => {
myPort.addEventListener("message", (e) => {
if (e.data.type == FDC3_USER_INTERFACE_HANDSHAKE_TYPE) {
myPort.postMessage({ type: FDC3_USER_INTERFACE_RESTYLE_TYPE, payload: { updatedCSS: DEFAULT_COLLAPSED_CSS } } as IframeRestyle)
} else if (e.data.type == FDC3_USER_INTERFACE_RESTYLE_TYPE) {
} else if (e.data.type == FDC3_USER_INTERFACE_RESOLVE_TYPE) {
myPort.postMessage({ type: FDC3_USER_INTERFACE_RESTYLE_TYPE, payload: { updatedCSS: DEFAULT_EXPANDED_CSS } } as IframeRestyle)
Array.from(list.children).forEach(i => i.remove())
const details = e.data.payload as IframeResolvePayload
Expand Down
4 changes: 2 additions & 2 deletions toolbox/fdc3-for-web/demo/static/da/appd.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"appId": "workbench",
"name": "FDC3 Workbench",
"title": "FDC3 Workbench",
"description": "Part of the WebFDC3 Demo - Port of the FDC3 Workbench. Must be started separately on localhost:3000",
"description": "Part of the WebFDC3 Demo - Port of the FDC3 Workbench. Must be started separately on localhost:4001",
"type": "web",
"details": {
"url": "http://localhost:3000/toolbox/fdc3-workbench/"
"url": "http://localhost:4001/toolbox/fdc3-workbench/"
},
"hostManifests": {},
"version": "1.0.0",
Expand Down

0 comments on commit 3cbbb89

Please sign in to comment.