This repository has been archived by the owner on Oct 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa22c62
commit 28cd861
Showing
10 changed files
with
2,218 additions
and
112 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,46 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { | ||
ApplicationView, | ||
AsyncAPIApplication, | ||
SystemView, | ||
} from '@lagoni/edavisualiser'; | ||
import '@lagoni/edavisualiser/styles/default.css'; | ||
import '../App.css'; | ||
import '@asyncapi/parser/dist/bundle'; | ||
import { useParams } from 'react-router-dom'; | ||
import { apps } from './apps'; | ||
|
||
const parser = window['AsyncAPIParser']; | ||
function Asyncapi() { | ||
let { application } = useParams(); | ||
const [asyncapiDocument, setAsyncapiDocument] = useState(undefined); | ||
|
||
useEffect(() => { | ||
// declare the async data fetching function | ||
const fetchData = async () => { | ||
const appLink = apps[application]; | ||
if (appLink !== undefined) { | ||
const doc = await parser.parseFromUrl(appLink); | ||
setAsyncapiDocument(doc); | ||
} | ||
}; | ||
|
||
// call the function | ||
fetchData() | ||
// make sure to catch any error | ||
.catch(console.error); | ||
}, []); | ||
let something; | ||
if (asyncapiDocument !== undefined) { | ||
something = ( | ||
<ApplicationView> | ||
<AsyncAPIApplication document={asyncapiDocument} /> | ||
</ApplicationView> | ||
); | ||
} else { | ||
something = <h1>Not loaded</h1>; | ||
} | ||
return <div className="App">{something}</div>; | ||
} | ||
|
||
export default Asyncapi; |
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,6 @@ | ||
export const apps = { | ||
rust_public: | ||
'https://raw.githubusercontent.com/GamingAPI/definitions/main/bundled/rust_public.asyncapi.json', | ||
rust: | ||
'https://raw.githubusercontent.com/GamingAPI/definitions/main/bundled/rust.asyncapi.json', | ||
}; |
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,56 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { AsyncAPIApplication, SystemView } from '@lagoni/edavisualiser'; | ||
import '@lagoni/edavisualiser/styles/default.css'; | ||
import '../App.css'; | ||
import '@asyncapi/parser/dist/bundle'; | ||
import { apps } from './apps'; | ||
|
||
const parser = window['AsyncAPIParser']; | ||
function Asyncapi() { | ||
const [asyncapiDocuments, setAsyncapiDocuments] = useState([]); | ||
useEffect(() => { | ||
// declare the async data fetching function | ||
const fetchData = async () => { | ||
const data = []; | ||
for (const [name, asyncapiUrl] of Object.entries(apps)) { | ||
const parsedDoc = await parser.parseFromUrl(asyncapiUrl); | ||
data.push({ parsedDoc, name }); | ||
} | ||
setAsyncapiDocuments(data); | ||
}; | ||
|
||
// call the function | ||
fetchData() | ||
// make sure to catch any error | ||
.catch(console.error); | ||
}, []); | ||
let something; | ||
if (asyncapiDocuments.length > 0) { | ||
something = ( | ||
<SystemView> | ||
{asyncapiDocuments.map(({ parsedDoc, name }) => { | ||
return ( | ||
<AsyncAPIApplication | ||
document={parsedDoc} | ||
topExtended={ | ||
<div className="flex justify-between mb-4"> | ||
<a | ||
className="block leading-6 text-gray-900 uppercase text-xs font-light" | ||
href={'/gamingapi/application/' + name} | ||
> | ||
Go to application | ||
</a> | ||
</div> | ||
} | ||
/> | ||
); | ||
})} | ||
</SystemView> | ||
); | ||
} else { | ||
something = <h1>Not loaded</h1>; | ||
} | ||
return <div className="App">{something}</div>; | ||
} | ||
|
||
export default Asyncapi; |
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