-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
104 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { AppIdentifier } from "@finos/fdc3"; | ||
import { io } from "socket.io-client" | ||
import { FDC3_APP_EVENT } from "../../message-types"; | ||
import { ChannelSelectionChoiceAgentRequest } from "fdc3-common"; | ||
import { v4 as uuid } from 'uuid' | ||
|
||
function getQueryVariable(variable: string): string { | ||
var query = window.location.search.substring(1); | ||
var vars = query.split("&"); | ||
for (var i = 0; i < vars.length; i++) { | ||
var pair = vars[i].split("="); | ||
if (pair[0] == variable) { | ||
return pair[1]; | ||
} | ||
} | ||
|
||
return "" | ||
} | ||
|
||
function getAvailableChannels(): any[] { | ||
const intentDetails = getQueryVariable("availableChannels") | ||
const decoded = decodeURIComponent(intentDetails) | ||
const object: any[] = JSON.parse(decoded) | ||
return object | ||
} | ||
|
||
function getCurrentChannel(): string { | ||
const source = getQueryVariable("currentId") | ||
const decoded = decodeURIComponent(source) | ||
const object: string = JSON.parse(decoded) | ||
return object | ||
} | ||
|
||
function getSource(): AppIdentifier { | ||
const source = getQueryVariable("source") | ||
const decoded = decodeURIComponent(source) | ||
const object: AppIdentifier = JSON.parse(decoded) | ||
return object | ||
} | ||
|
||
const socket = io() | ||
|
||
socket.on("connect", async () => { | ||
|
||
const currentChannelId = getCurrentChannel() | ||
const channels = getAvailableChannels() | ||
const source = getSource() | ||
|
||
const list = document.getElementById("channel-list")!! | ||
|
||
function sendChosenChannel(channelId: string, cancel: boolean) { | ||
const out: ChannelSelectionChoiceAgentRequest = { | ||
type: "channelSelectionChoice", | ||
payload: { | ||
cancel, | ||
channelId | ||
}, | ||
meta: { | ||
requestUuid: uuid(), | ||
timestamp: new Date(), | ||
source | ||
}, | ||
} | ||
|
||
socket.emit(FDC3_APP_EVENT, out, source) | ||
} | ||
|
||
const debug = document.createElement("p") | ||
debug.textContent = JSON.stringify(source) | ||
document.body.appendChild(debug) | ||
|
||
channels.forEach(channel => { | ||
|
||
const li = document.createElement("li") | ||
li.style.backgroundColor = channel.displayMetadata.color | ||
const a = document.createElement("a") | ||
const description = document.createElement("em") | ||
description.textContent = channel.displayMetadata.name | ||
a.textContent = channel.id | ||
|
||
li.appendChild(a) | ||
li.appendChild(description) | ||
list.appendChild(li) | ||
a.setAttribute("href", "#") | ||
a.onclick = () => sendChosenChannel(channel.id, false) | ||
}) | ||
|
||
}) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters