Limited widget displayed fields to 4

This commit is contained in:
fredodiable 2023-07-27 00:43:26 +02:00
parent 3fb9ad8695
commit 0fcfaea47e
2 changed files with 12 additions and 0 deletions

View File

@ -296,6 +296,13 @@ export function cleanServiceGroups(groups) {
} = cleanedService.widget;
let fieldsList = fields;
const MAX_ALLOWED_FIELDS = 4;
// Limits max number of displayed fields
if (fieldsList != null && fieldsList.length > MAX_ALLOWED_FIELDS) {
fieldsList = fieldsList.slice(0, MAX_ALLOWED_FIELDS);
}
if (typeof fields === 'string') {
try { JSON.parse(fields) }
catch (e) {

View File

@ -13,6 +13,11 @@ export default function Component({ service }) {
return <Container service={service} error={serverError} />;
}
// Default fields
if (widget.fields == null || widget.fields.length === 0) {
widget.fields = ["map", "currentPlayers", "ping"];
}
if (!serverData) {
return (
<Container service={service}>