Skip to content

Commit 7b8c631

Browse files
committed
feat: added active database
1 parent 3db3dcd commit 7b8c631

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

examples/gauge/Components/InterfaceSample.tsx

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,26 +78,6 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
7878
})
7979
}
8080

81-
public renderDatabaseInfo(): VNode | void {
82-
return (
83-
<>
84-
<div
85-
class={MappedSubject.create(([status]) => {
86-
return status ? "vertical" : "hidden"
87-
}, this.activeDatabase)}
88-
>
89-
<div>{this.activeDatabase.map(s => `Bundled: ${s?.is_bundled}`)}</div>
90-
<div>
91-
{this.activeDatabase.map(s => `Installed format: ${s?.cycle.format} revision ${s?.cycle.revision}`)}
92-
</div>
93-
<div>{this.activeDatabase.map(s => `Active path: ${s?.path}`)}</div>
94-
<div>{this.activeDatabase.map(s => `Active cycle: ${s?.cycle.cycle}`)}</div>
95-
<div>{this.activeDatabase.map(s => `Validity period: ${s?.cycle.validityPeriod}`)}</div>
96-
</div>
97-
</>
98-
)
99-
}
100-
10181
public render(): VNode {
10282
return (
10383
<>
@@ -122,7 +102,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
122102
class="bg-ng-background-400"
123103
active={this.mainPageIndex}
124104
pages={[
125-
[0, <Dashboard databases={this.databases} />],
105+
[0, <Dashboard activeDatabase={this.activeDatabase} databases={this.databases} />],
126106
[1, <TestPage />],
127107
[2, <AuthPage />],
128108
]}

examples/gauge/Components/Pages/Dashboard/Dashboard.tsx

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,55 @@
1-
import { ComponentProps, DisplayComponent, FSComponent, Subscribable, VNode } from "@microsoft/msfs-sdk"
1+
import { ComponentProps, DisplayComponent, FSComponent, MappedSubject, Subscribable, VNode } from "@microsoft/msfs-sdk"
22
import { PackageInfo } from "@navigraph/msfs-navigation-data-interface"
33

44
interface DashboardProps extends ComponentProps {
55
databases: Subscribable<PackageInfo[]>
6+
activeDatabase: Subscribable<PackageInfo | null>
67
}
78

89
export class Dashboard extends DisplayComponent<DashboardProps> {
10+
public renderDatabaseInfo(): VNode | void {
11+
return (
12+
<>
13+
<div
14+
class={this.props.activeDatabase.map(
15+
status =>
16+
`p-4 flex flex-col align-middle items-start flex-start space-y-6 ${status ? "vertical" : "hidden"}`,
17+
)}
18+
>
19+
<div class="flex flex-col space-y-2">
20+
<p class="text-3xl">Bundled</p>
21+
<p class="text-2xl text-gray-400">{this.props.activeDatabase.map(s => s?.is_bundled)}</p>
22+
</div>
23+
<div class="flex flex-col space-y-2">
24+
<p class="text-3xl">Installed format</p>
25+
<p class="text-2xl text-gray-400">
26+
{this.props.activeDatabase.map(s => `${s?.cycle.format} revision ${s?.cycle.revision}`)}
27+
</p>
28+
</div>
29+
<div class="flex flex-col space-y-2">
30+
<p class="text-3xl">Active path</p>
31+
<p class="text-2xl text-gray-400">{this.props.activeDatabase.map(s => s?.path)}</p>
32+
</div>
33+
<div class="flex flex-col space-y-2">
34+
<p class="text-3xl">Active cycle</p>
35+
<p class="text-2xl text-gray-400">{this.props.activeDatabase.map(s => s?.cycle.cycle)}</p>
36+
</div>
37+
<div class="flex flex-col space-y-2">
38+
<p class="text-3xl">Validity period</p>
39+
<p class="text-2xl text-gray-400">{this.props.activeDatabase.map(s => s?.cycle.validityPeriod)}</p>
40+
</div>
41+
</div>
42+
</>
43+
)
44+
}
45+
946
render(): VNode {
1047
return (
1148
<div class="size-full flex flex-col">
12-
<p class="mb-8 text-4xl">Dashboard</p>
49+
<p class="mb-8 text-6xl">Dashboard</p>
1350
<div class="flex flex-row flex-grow flex-auto space-x-4">
1451
<div class="w-1/3 flex flex-col">
15-
<p class="text-2xl mb-4">Databases</p>
52+
<p class="text-3xl mb-4">Databases</p>
1653
<div class="mt-2 flex-grow rounded-xl bg-ng-background-500">
1754
{this.props.databases.map(val =>
1855
val.map(pkgs => (
@@ -26,8 +63,8 @@ export class Dashboard extends DisplayComponent<DashboardProps> {
2663
</div>
2764
</div>
2865
<div class="flex flex-col flex-grow">
29-
<p class="text-2xl mb-4">Info</p>
30-
<div class="mt-2 flex-grow rounded-xl bg-ng-background-500"></div>
66+
<p class="text-3xl mb-4">Info</p>
67+
<div class="mt-2 flex-grow rounded-xl bg-ng-background-500">{this.renderDatabaseInfo()}</div>
3168
</div>
3269
</div>
3370
</div>

0 commit comments

Comments
 (0)