mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 23:38:46 +00:00
rewrite minecraft server status widget to directly ping server
This commit is contained in:
parent
f418ee6327
commit
ad66637ff1
5 changed files with 54 additions and 17 deletions
|
@ -25,22 +25,15 @@ export default function Component({ service }) {
|
|||
const statusIndicator = serverData.online ?
|
||||
<span className="text-green-500">{t("minecraft.up")}</span>:
|
||||
<span className="text-red-500">{t("minecraft.down")}</span>;
|
||||
const players = serverData.players ? `${serverData.players.online} / ${serverData.players.max}` : "-";
|
||||
const version = serverData.version || "-";
|
||||
|
||||
if(serverData.players){
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block label="minecraft.status" value={statusIndicator} />
|
||||
<Block label="minecraft.players" value={`${serverData.players.online} / ${serverData.players.max}`} />
|
||||
<Block label="minecraft.version" value={serverData.version} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Container service={service}>
|
||||
<Block label="minecraft.status" value={statusIndicator} />
|
||||
<Block label="minecraft.players" value="-" />
|
||||
<Block label="minecraft.version" value="-" />
|
||||
</Container>
|
||||
<Block label="minecraft.players" value={players} />
|
||||
<Block label="minecraft.version" value={version} />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
import genericProxyHandler from "utils/proxy/handlers/generic";
|
||||
import minecraftProxyHandler from "utils/proxy/handlers/minecraft";
|
||||
import { asJson } from "utils/proxy/api-helpers";
|
||||
|
||||
const widget = {
|
||||
api: "{url}/{endpoint}/{domain}",
|
||||
proxyHandler: genericProxyHandler,
|
||||
proxyHandler: minecraftProxyHandler,
|
||||
mappings: {
|
||||
status: {
|
||||
endpoint: "2",
|
||||
endpoint: "_",
|
||||
map: (data) => {
|
||||
const jsonData = asJson(data);
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue