-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview2.component.ts
64 lines (59 loc) · 1.73 KB
/
view2.component.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { CommonModule } from "@angular/common";
import { ChangeDetectionStrategy, Component, type OnInit, signal } from "@angular/core";
@Component({
selector: "app-view2",
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [CommonModule],
template: `
<div class="col fill gap20">
<header class="row spread middle">
<div class="col">
<h1>OpenFin Angular View 2</h1>
<h1 class="tag">Angular app view in an OpenFin container</h1>
</div>
<div class="row middle gap10">
<img src="logo.svg" alt="OpenFin" height="40px" />
</div>
</header>
<main class="col gap10 left width-full">
@if (message()) {
<fieldset class="width-full">
<label htmlFor="message">Context Received</label>
<pre id="message" class="width-full" style="min-height: 110px">{{ message() }}</pre>
</fieldset>
<button (click)="clearMessage()">Clear</button>
}
</main>
</div>
`,
})
export class View2Component implements OnInit {
message = signal<string>("");
ngOnInit(): void {
this.listenForFDC3Context();
this.listenForFDC3ContextAppChannel();
}
listenForFDC3Context() {
if (fdc3) {
fdc3?.addContextListener("fdc3.instrument", (context) => {
console.log("ContextService: received message", context);
this.message.set(JSON.stringify(context, undefined, " "));
});
} else {
console.error("FDC3 is not available");
}
}
async listenForFDC3ContextAppChannel() {
if (fdc3) {
const appChannel = await fdc3.getOrCreateChannel("CUSTOM-APP-CHANNEL");
await appChannel.addContextListener((context) => {
this.message.set(JSON.stringify(context, undefined, " "));
});
} else {
console.error("FDC3 is not available");
}
}
clearMessage() {
this.message.set("");
}
}