-
-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--------- Co-authored-by: shamoon <[email protected]>
- Loading branch information
Showing
8 changed files
with
100 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: MySpeed | ||
description: MySpeed Widget Configuration | ||
--- | ||
|
||
Learn more about [MySpeed](https://myspeed.dev/). | ||
|
||
Allowed fields: `["ping", "download", "upload"]`. | ||
|
||
```yaml | ||
widget: | ||
type: myspeed | ||
url: http:https://myspeed.host.or.ip:port | ||
password: password # only required if password is set | ||
``` |
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,60 @@ | ||
import { useTranslation } from "next-i18next"; | ||
|
||
import Container from "components/services/widget/container"; | ||
import Block from "components/services/widget/block"; | ||
import useWidgetAPI from "utils/proxy/use-widget-api"; | ||
|
||
export default function Component({ service }) { | ||
const { t } = useTranslation(); | ||
const { widget } = service; | ||
const { data, error } = useWidgetAPI(widget, "info"); | ||
|
||
if (error || (data && data.message) || (data && data[0] && data[0].error)) { | ||
let finalError = error ?? data; | ||
if (data && data[0] && data[0].error) { | ||
try { | ||
finalError = JSON.parse(data[0].error); | ||
} catch (e) { | ||
finalError = data[0].error; | ||
} | ||
} | ||
return <Container service={service} error={finalError} />; | ||
} | ||
|
||
if (!data || (data && data.length === 0)) { | ||
return ( | ||
<Container service={service}> | ||
<Block label="myspeed.ping" /> | ||
<Block label="myspeed.download" /> | ||
<Block label="myspeed.upload" /> | ||
</Container> | ||
); | ||
} | ||
|
||
return ( | ||
<Container service={service}> | ||
<Block | ||
label="myspeed.ping" | ||
value={t("common.ms", { | ||
value: data[0].ping, | ||
style: "unit", | ||
unit: "millisecond", | ||
})} | ||
/> | ||
<Block | ||
label="myspeed.download" | ||
value={t("common.bitrate", { | ||
value: data[0].download * 1000 * 1000, | ||
decimals: 2, | ||
})} | ||
/> | ||
<Block | ||
label="myspeed.upload" | ||
value={t("common.bitrate", { | ||
value: data[0].upload * 1000 * 1000, | ||
decimals: 2, | ||
})} | ||
/> | ||
</Container> | ||
); | ||
} |
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,14 @@ | ||
import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; | ||
|
||
const widget = { | ||
api: "{url}/api/{endpoint}", | ||
proxyHandler: credentialedProxyHandler, | ||
|
||
mappings: { | ||
info: { | ||
endpoint: "speedtests?limit=1", | ||
}, | ||
}, | ||
}; | ||
|
||
export default widget; |
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