Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: GameDig widget missing lib #1811

Merged
merged 19 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added status field for GameDig widget
  • Loading branch information
fredodiable committed Aug 12, 2023
commit ee308c844093cb780f39f17cd498dc6df19a05d6
3 changes: 3 additions & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,9 @@
"inProgress": "In Progress"
},
"gamedig": {
"status": "Status",
"online": "Online",
"offline": "Offline",
"name": "Name",
"map": "Map",
"currentPlayers": "Current players",
Expand Down
7 changes: 5 additions & 2 deletions src/widgets/gamedig/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function Component({ service }) {
if (!serverData) {
return (
<Container service={service}>
<Block label="gamedig.status"/>
<Block label="gamedig.name"/>
<Block label="gamedig.map"/>
<Block label="gamedig.currentPlayers" />
Expand All @@ -37,23 +38,25 @@ export default function Component({ service }) {
);
}

const status = serverData.online ? <span className="text-green-500">{t("gamedig.online")}</span> : <span className="text-red-500">{t("gamedig.offline")}</span>;
const name = serverData.online ? serverData.name : "-";
const map = serverData.online ? serverData.map : "-";
const currentPlayers = serverData.online ? `${serverData.players} / ${serverData.maxplayers}` : "-";
const players = serverData.online ? `${serverData.players}` : "-";
const maxPlayers = serverData.online ? `${serverData.maxplayers}` : "-";
const bots = serverData.online ? `${serverData.bots}` : "-";
const ping = serverData.online ? `${serverData.ping}` : 0;
const ping = serverData.online ? `${t("common.ms", { value: serverData.ping, style: "unit", unit: "millisecond" })}` : "-";

return (
<Container service={service}>
<Block label="gamedig.status" value={status} />
<Block label="gamedig.name" value={name} />
<Block label="gamedig.map" value={map} />
<Block label="gamedig.currentPlayers" value={currentPlayers} />
<Block label="gamedig.players" value={players} />
<Block label="gamedig.maxPlayers" value={maxPlayers} />
<Block label="gamedig.bots" value={bots} />
<Block label="gamedig.ping" value={t("common.ms", { value: ping, style: "unit", unit: "millisecond" })} />
<Block label="gamedig.ping" value={ping} />
</Container>
);
}