forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.component.ts
More file actions
60 lines (56 loc) · 1.47 KB
/
Copy pathapp.component.ts
File metadata and controls
60 lines (56 loc) · 1.47 KB
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
import { Component, inject } from "@angular/core";
import { toSignal } from "@angular/core/rxjs-interop";
import {
ActivatedRoute,
NavigationEnd,
Router,
RouterOutlet,
} from "@angular/router";
import { filter, map, startWith } from "rxjs";
import { DemoWebInspectorComponent } from "./components/demo-web-inspector.component";
@Component({
selector: "app-root",
standalone: true,
imports: [RouterOutlet, DemoWebInspectorComponent],
template: `
<div class="demo-shell">
<router-outlet />
@if (showInspector()) {
<angular-demo-web-inspector />
}
</div>
`,
styles: `
.demo-shell {
height: 100vh;
width: 100vw;
margin: 0;
padding: 0;
overflow: hidden;
display: block;
}
`,
})
export class AppComponent {
private readonly router = inject(Router);
private readonly route = inject(ActivatedRoute);
/**
* The web inspector is shown on every route except those that opt out via
* `data: { inspector: false }` (currently the headless route).
*/
protected readonly showInspector = toSignal(
this.router.events.pipe(
filter((event) => event instanceof NavigationEnd),
map(() => this.inspectorEnabled()),
startWith(this.inspectorEnabled()),
),
{ initialValue: true },
);
private inspectorEnabled(): boolean {
let route = this.route;
while (route.firstChild) {
route = route.firstChild;
}
return route.snapshot.data["inspector"] !== false;
}
}