-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement Elektro module with initial components, actions, and …
…GraphQL client setup
- Loading branch information
Showing
24 changed files
with
3,647 additions
and
5 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Guard } from "@/arkitekt/Arkitekt"; | ||
import { ModuleLayout } from "@/components/layout/ModuleLayout"; | ||
import React from "react"; | ||
import { Route, Routes } from "react-router"; | ||
import HomePage from "./pages/HomePage"; | ||
import RoomPage from "./pages/RoomPage"; | ||
import StandardPane from "./panes/StandardPane"; | ||
interface Props {} | ||
|
||
export const ElektroModule: React.FC<Props> = (props) => { | ||
return ( | ||
<Guard.Elektro fallback={<>Loading</>}> | ||
<ModuleLayout pane={<StandardPane />}> | ||
<Routes> | ||
<Route path="rooms/:id" element={<RoomPage />} /> | ||
<Route path="*" element={<HomePage />} /> | ||
</Routes> | ||
</ModuleLayout> | ||
</Guard.Elektro> | ||
); | ||
}; | ||
|
||
export default ElektroModule; |
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,35 @@ | ||
import { useAlpaka } from "@/arkitekt/Arkitekt"; | ||
import { useWidgetRegistry } from "@/rekuest/widgets/WidgetsContext"; | ||
import { gql } from "@apollo/client"; | ||
import { useEffect } from "react"; | ||
|
||
export const ElektroWard: React.FC<{ | ||
fallback?: React.ReactNode; | ||
key: string; | ||
}> = ({ key, fallback }) => { | ||
const client = useAlpaka(); | ||
const { registry } = useWidgetRegistry(); | ||
|
||
useEffect(() => { | ||
if (client) { | ||
const runFunc = (options: { query: string; variables: any }) => { | ||
let document = gql(options.query); | ||
return client | ||
.query({ | ||
query: document, | ||
variables: options.variables, | ||
}) | ||
.then((result: any) => { | ||
console.log(result.data); | ||
return result.data.options; | ||
}); | ||
}; | ||
|
||
registry?.registerWard(key, { | ||
search: runFunc, | ||
}); | ||
} | ||
}, [client, registry]); | ||
|
||
return <>{fallback}</>; | ||
}; |
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,40 @@ | ||
import { Button } from "@/components/ui/button"; | ||
import { | ||
useAcknowledgeMessageMutation, | ||
useMyActiveMessagesQuery, | ||
} from "./api/graphql"; | ||
|
||
export const SystemMessageDisplay = (props: {}) => { | ||
const { data, error } = useMyActiveMessagesQuery(); | ||
const [ack] = useAcknowledgeMessageMutation({ | ||
refetchQueries: ["MyActiveMessages"], | ||
}); | ||
|
||
console.log("yyst", data, error); | ||
return ( | ||
<> | ||
{(data?.myActiveMessages?.length || 0) > 0 && ( | ||
<div className="absolute top-0 right-0 h-screen w-screen "> | ||
{data?.myActiveMessages.map((message) => ( | ||
<div | ||
key={message.id} | ||
className="p-2 rounded shadow-md bg-black opacity-99 p-2 text-white absolute w-full h-full z-100" | ||
> | ||
<div className="top-[50%] left-[50%] translate-x-[-50%] translate-y-[50%] text-white w-100 "> | ||
<div className="font-bold">{message.title}</div> | ||
<div>{message.message}</div> | ||
<Button | ||
onClick={() => | ||
ack({ variables: { id: message.id, ack: true } }) | ||
} | ||
> | ||
Acknowledge | ||
</Button> | ||
</div> | ||
</div> | ||
))} | ||
</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,21 @@ | ||
|
||
export interface PossibleTypesResultData { | ||
possibleTypes: { | ||
[key: string]: string[] | ||
} | ||
} | ||
const result: PossibleTypesResultData = { | ||
"possibleTypes": { | ||
"Descendant": [ | ||
"LeafDescendant", | ||
"MentionDescendant", | ||
"ParagraphDescendant" | ||
], | ||
"SocialAccount": [ | ||
"GenericAccount", | ||
"OrcidAccount" | ||
] | ||
} | ||
}; | ||
export default result; | ||
|
Oops, something went wrong.