-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Login): Add a Flight Director core for seeing which clients are …
…logged in. Closes #274
- Loading branch information
1 parent
a2dd5f4
commit 386a95f
Showing
6 changed files
with
54 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {DataContext} from "server/src/utils/DataContext"; | ||
|
||
export const subscriptions = { | ||
clients(context: DataContext) { | ||
if (!context.flight) return []; | ||
const serverClients = Object.values(context.server.clients); | ||
const flightClients = context.flight?.clients || {}; | ||
const clients = serverClients | ||
.map(client => { | ||
const flightClient = flightClients[client.id]; | ||
return { | ||
...client.toJSON(), | ||
...flightClient?.toJSON(), | ||
}; | ||
}) | ||
.filter(client => client.stationId); | ||
return clients; | ||
}, | ||
}; |
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,27 @@ | ||
import useCardData from "client/src/context/useCardData"; | ||
|
||
export function LoginCore() { | ||
const data = useCardData<"LoginCore">(); | ||
return ( | ||
<div className="prose prose-invert w-full mx-auto"> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Client</th> | ||
<th>Station</th> | ||
<th>Name</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{data.clients.map(client => ( | ||
<tr key={client.id}> | ||
<td>{client.name}</td> | ||
<td>{client.stationId}</td> | ||
<td>{client.loginName}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
} |
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 @@ | ||
export * as LoginCore from "./LoginCore/data"; |
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 @@ | ||
export {LoginCore} from "./LoginCore"; |
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