-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add integration options for other projects (#137)
* feat(view): add fullscreen graph mode * feat(view): add theme options to fullscreen graph * docs: add basic widget creation doc * feat: add api endpoint for config * docs: add api docs; fix widget docs * feat: add option to disable integrations * fix: mantine theme provider
- Loading branch information
1 parent
8987256
commit 422662d
Showing
66 changed files
with
1,753 additions
and
583 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+7.62 KB
.yarn/cache/@emotion-weak-memoize-npm-0.2.5-9f2e49e7c8-27d402b0c6.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.31 KB
.yarn/cache/@radix-ui-react-compose-refs-npm-0.1.0-a16c93a4d0-d1455577b2.zip
Binary file not shown.
Binary file added
BIN
+9.39 KB
.yarn/cache/@radix-ui-react-context-npm-0.1.1-f6f528ee12-85ed35b6e3.zip
Binary file not shown.
Binary file added
BIN
+11 KB
.yarn/cache/@radix-ui-react-presence-npm-0.1.2-52b34dc77a-7a189e24a3.zip
Binary file not shown.
Binary file added
BIN
+7.06 KB
.yarn/cache/@radix-ui-react-primitive-npm-0.1.4-115fd5c8b4-e7b83dc515.zip
Binary file not shown.
Binary file added
BIN
+41.2 KB
.yarn/cache/@radix-ui-react-scroll-area-npm-0.1.4-19823dbb34-b926e3087f.zip
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+5.16 KB
.yarn/cache/@radix-ui-react-use-callback-ref-npm-0.1.0-838ec38d13-5356971123.zip
Binary file not shown.
Binary file added
BIN
+5.96 KB
.yarn/cache/@radix-ui-react-use-direction-npm-0.1.0-afd759f72a-1553c05665.zip
Binary file not shown.
Binary file added
BIN
+4.87 KB
.yarn/cache/@radix-ui-react-use-layout-effect-npm-0.1.0-d80d7efedb-d8be1f9770.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+3.59 KB
.yarn/cache/@types-throttle-debounce-npm-5.0.0-c27fac6e7d-f0b1f62681.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,4 @@ | ||
{ | ||
"label": "Integrations", | ||
"position": 3 | ||
} |
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,130 @@ | ||
import { useColorMode } from '@docusaurus/theme-common'; | ||
import { Input, InputWrapper, MantineProvider, Select } from '@mantine/core'; | ||
import CodeBlock from '@theme/CodeBlock'; | ||
import React, { useEffect, useMemo, useRef, useState } from 'react'; | ||
import { debounce } from 'throttle-debounce'; | ||
|
||
const getDataFromUrl = url => { | ||
const [data, setData] = useState({ | ||
error: null, | ||
data: null, | ||
loading: false, | ||
}); | ||
|
||
const requestCallback = useRef(); | ||
const doRequest = useMemo( | ||
() => debounce(400, () => requestCallback.current()), | ||
[] | ||
); | ||
|
||
useEffect(() => { | ||
requestCallback.current = async () => { | ||
setData({ | ||
loading: true, | ||
}); | ||
|
||
try { | ||
const fetched = await fetch(url); | ||
if (!fetched.ok) { | ||
throw Error('Request failed'); | ||
} | ||
|
||
const json = await fetched.json(); | ||
|
||
setData({ | ||
error: null, | ||
data: json, | ||
loading: false, | ||
}); | ||
} catch (e) { | ||
setData({ | ||
error: e, | ||
loading: false, | ||
}); | ||
} | ||
}; | ||
|
||
doRequest(); | ||
}, [url]); | ||
|
||
return data; | ||
}; | ||
|
||
export const ApiPreview = () => { | ||
const { colorMode } = useColorMode(); | ||
|
||
const [protocol, setProtocol] = useState('https'); | ||
const [url, setUrl] = useState('dash.mauz.io'); | ||
|
||
const baseUrl = `${protocol}://${url}`; | ||
const info = getDataFromUrl(baseUrl + '/info'); | ||
const config = getDataFromUrl(baseUrl + '/config'); | ||
|
||
return ( | ||
<MantineProvider | ||
theme={{ | ||
colorScheme: colorMode === 'dark' ? 'dark' : 'light', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexFlow: 'column nowrap', | ||
gap: '20px', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexFlow: 'row wrap', | ||
columnGap: '20px', | ||
rowGap: '10px', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<InputWrapper label='URL'> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexFlow: 'row nowrap', | ||
}} | ||
> | ||
<Select | ||
style={{ width: '100px' }} | ||
value={protocol} | ||
onChange={e => setProtocol(e)} | ||
data={[ | ||
{ value: 'https', label: 'https://' }, | ||
{ value: 'http', label: 'http://' }, | ||
]} | ||
/> | ||
<Input value={url} onChange={e => setUrl(e.target.value)} /> | ||
</div> | ||
</InputWrapper> | ||
</div> | ||
|
||
<h3>Info</h3> | ||
<CodeBlock className={`language-http`}>{`${baseUrl}/info`}</CodeBlock> | ||
|
||
<CodeBlock className={`language-json`}> | ||
{!info.loading | ||
? !info.error | ||
? JSON.stringify(info.data, null, 2) | ||
: info.error.message ?? 'Error' | ||
: 'Loading ...'} | ||
</CodeBlock> | ||
|
||
<h3>Config</h3> | ||
<CodeBlock className={`language-http`}>{`${baseUrl}/config`}</CodeBlock> | ||
|
||
<CodeBlock className={`language-json`}> | ||
{!config.loading | ||
? !config.error | ||
? JSON.stringify(config.data, null, 2) | ||
: config.error.message ?? 'Error' | ||
: 'Loading ...'} | ||
</CodeBlock> | ||
</div> | ||
</MantineProvider> | ||
); | ||
}; |
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,18 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# API Endpoints | ||
|
||
## Basic | ||
|
||
There are two endpoints which can be used to retrieve data about the running dash. instance: | ||
|
||
- `https://<YOUR_SERVER_URL>/info` - gives information about the static data (e.g. cpu cores, speedtest results) | ||
- `https://<YOUR_SERVER_URL>/config` - gives information about server config and versions | ||
|
||
## URL Preview | ||
|
||
import { ApiPreview } from './api-preview'; | ||
|
||
<ApiPreview /> |
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 @@ | ||
# Integrations | ||
|
||
import DocCardList from '@theme/DocCardList'; | ||
import { useCurrentSidebarCategory } from '@docusaurus/theme-common'; | ||
|
||
<DocCardList items={useCurrentSidebarCategory().items} /> |
Oops, something went wrong.