Add config editor and dump viewer (#1)
* Begin working on config editor * Finish working on config editor * Add dump viewer * Fix online mode not showing in dump viewer * remove debug logging * Replace " with ' * Fix syntax error * Add more functionality to dump viewer * Improve style of plugin popover * Change card header colour * Use crypto api for generating uuids * Fix broken regex * Add german translations from @onebeastchris Co-authored-by: chris <github@onechris.mozmail.com> * Move pretty much all hardcoded text on dump and config viewer pages to translations * Use old yarn.lock * Add indicator to show if a plugin is enabled --------- Co-authored-by: chris <github@onechris.mozmail.com>
This commit is contained in:
1 parent
be8823e189
commit
aa3f447873
12 files changed
+1542
-2
No files matched your search
+115
-1
@@ -21,6 +21,7 @@
|
||||
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
|
||||
--ifm-font-family-base: 'Montserrat', sans-serif;
|
||||
--ifm-heading-font-family: 'Montserrat', sans-serif;
|
||||
--switch-background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
/* For readability concerns, you should choose a lighter palette in dark mode. */
|
||||
@@ -39,6 +40,7 @@
|
||||
--ifm-background-surface-color: #1a2a3a;
|
||||
--ifm-horizontal-line-color: rgba(227, 227, 227, 0.2);
|
||||
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
|
||||
--switch-background-color: rgb(135, 129, 129);
|
||||
}
|
||||
|
||||
html[data-theme='dark'] {
|
||||
@@ -96,6 +98,26 @@ html[data-theme='dark'] {
|
||||
background-color: var(--ifm-navbar-link-hover-color);
|
||||
}
|
||||
|
||||
.header-utilities-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.header-utilities-link::before {
|
||||
content: '';
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: inline-block;
|
||||
background-color: var(--ifm-navbar-link-color);
|
||||
mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> <path d="M78.6 5C69.1-2.4 55.6-1.5 47 7L7 47c-8.5 8.5-9.4 22-2.1 31.6l80 104c4.5 5.9 11.6 9.4 19 9.4h54.1l109 109c-14.7 29-10 65.4 14.3 89.6l112 112c12.5 12.5 32.8 12.5 45.3 0l64-64c12.5-12.5 12.5-32.8 0-45.3l-112-112c-24.2-24.2-60.6-29-89.6-14.3l-109-109V104c0-7.5-3.5-14.5-9.4-19L78.6 5zM19.9 396.1C7.2 408.8 0 426.1 0 444.1C0 481.6 30.4 512 67.9 512c18 0 35.3-7.2 48-19.9L233.7 374.3c-7.8-20.9-9-43.6-3.6-65.1l-61.7-61.7L19.9 396.1zM512 144c0-10.5-1.1-20.7-3.2-30.5c-2.4-11.2-16.1-14.1-24.2-6l-63.9 63.9c-3 3-7.1 4.7-11.3 4.7H352c-8.8 0-16-7.2-16-16V102.6c0-4.2 1.7-8.3 4.7-11.3l63.9-63.9c8.1-8.1 5.2-21.8-6-24.2C388.7 1.1 378.5 0 368 0C288.5 0 224 64.5 224 144l0 .8 85.3 85.3c36-9.1 75.8 .5 104 28.7L429 274.5c49-23 83-72.8 83-130.5zM56 432a24 24 0 1 1 48 0 24 24 0 1 1 -48 0z"/> </svg>');
|
||||
transition: background-color var(--ifm-transition-fast) var(--ifm-transition-timing-default);
|
||||
}
|
||||
|
||||
.header-download-link:hover::before {
|
||||
background-color: var(--ifm-navbar-link-hover-color);
|
||||
}
|
||||
|
||||
.header-download-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -366,7 +388,8 @@ html[data-theme='dark'] {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.openapi-tabs__code-list-container, .tabs-host-type {
|
||||
.openapi-tabs__code-list-container,
|
||||
.tabs-host-type {
|
||||
display: flex !important;
|
||||
}
|
||||
}
|
||||
@@ -392,3 +415,94 @@ html[data-theme='dark'] {
|
||||
border-radius: var(--ifm-global-radius);
|
||||
color: #fff
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.font-normal {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: 150px;
|
||||
outline: 3px solid var(--ifm-tabs-color-active);
|
||||
outline-offset: -3px;
|
||||
border: 0;
|
||||
border-radius: var(--ifm-global-radius);
|
||||
background-color: transparent;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
transition: background-color 0.5s ease, color 0.5s ease;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
color: var(--ifm-tabs-color-active);
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: var(--ifm-color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.button-secondary {
|
||||
outline: 3px solid var(--ifm-color-secondary);
|
||||
}
|
||||
|
||||
.button-secondary:hover {
|
||||
background-color: var(--ifm-color-secondary);
|
||||
}
|
||||
|
||||
.form-input {
|
||||
border-radius: var(--ifm-global-radius);
|
||||
outline: 1px solid var(--ifm-color-secondary);
|
||||
outline-offset: -1px;
|
||||
padding: 10px;
|
||||
min-width: 50%;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.no-outline {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 768px) {
|
||||
.form-input {
|
||||
min-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* https://codepen.io/JAGATHISH1123/pen/PvayMB */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
background-color: var(--switch-background-color);
|
||||
border-radius: 20px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.switch::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
border-radius: 50%;
|
||||
background-color: white;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.checkbox:checked+.switch::after {
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.checkbox:checked+.switch {
|
||||
background-color: var(--ifm-color-secondary);
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
import Translate from '@docusaurus/Translate';
|
||||
import HeroBanner from '@site/src/components/HeroBanner';
|
||||
import HeroBackground from '@site/static/img/site/split-background.jpg';
|
||||
import Layout from '@theme/Layout';
|
||||
import styles from './utilities.module.css';
|
||||
import { useRef, useState } from 'react';
|
||||
|
||||
const ConfigEditorPage: React.FC = () => {
|
||||
const [config, setConfig] = useState('');
|
||||
const [parsedConfig, setParsedConfig] = useState<any>({});
|
||||
|
||||
const editedConfig = useRef<any>({});
|
||||
const uploadRef = useRef<any>(null);
|
||||
|
||||
const loadDefault = async () => {
|
||||
try {
|
||||
const response = await fetch('https://raw.githubusercontent.com/GeyserMC/Geyser/master/core/src/main/resources/config.yml');
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
const text = await response.text();
|
||||
handleConfigLoad(text);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch default config:', error);
|
||||
}
|
||||
}
|
||||
|
||||
const handleUpload = async (e) => {
|
||||
const fileName = e.target.files[0];
|
||||
|
||||
// Makse sure the file is a .yml file
|
||||
if (!fileName.name.endsWith('.yml')) {
|
||||
alert('Please select a .yml config file!');
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the file
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = (e) => {
|
||||
handleConfigLoad(e.target.result as string);
|
||||
}
|
||||
fileReader.readAsText(fileName);
|
||||
}
|
||||
|
||||
const handleConfigLoad = (config: string) => {
|
||||
setConfig(config);
|
||||
setParsedConfig(loadConfig(config));
|
||||
}
|
||||
|
||||
const loadConfig = (config: string) => {
|
||||
const lines = config.split('\n');
|
||||
let currentSection = '';
|
||||
let currentComment = '';
|
||||
|
||||
const newConfig = {};
|
||||
|
||||
// Parse each line of the config
|
||||
lines.forEach(line => {
|
||||
// Reset the section if we are no indented
|
||||
if (!line.startsWith(' ')) {
|
||||
currentSection = '';
|
||||
}
|
||||
|
||||
// Ignore any empty lines
|
||||
line = line.trim()
|
||||
if (line === '') {
|
||||
currentComment = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we are in a comment
|
||||
if (line.startsWith('#')) {
|
||||
currentComment += line.replace(/^# ?/i, '') + '<br>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore these lines since they will fail to parse
|
||||
if (!line.includes(':')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the key and value
|
||||
const splitLine = line.split(':');
|
||||
splitLine[0] = splitLine[0].trim();
|
||||
splitLine[1] = splitLine[1].trim();
|
||||
|
||||
// Check if we are in a new section
|
||||
if (line.endsWith(':')) {
|
||||
currentSection = splitLine[0];
|
||||
currentComment = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore user auths section
|
||||
if (currentSection === 'userAuths' || currentSection === 'saved-user-logins') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the config option to the config object
|
||||
newConfig[currentSection] = newConfig[currentSection] || {};
|
||||
newConfig[currentSection][splitLine[0]] = {
|
||||
desc: currentComment,
|
||||
value: splitLine[1]
|
||||
};
|
||||
|
||||
// Reset the comment
|
||||
currentComment = '';
|
||||
})
|
||||
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
const generateHTML = (config: any) => {
|
||||
return Object.keys(config).map(configKey => (
|
||||
<div key={configKey} className={styles.card}>
|
||||
<div className={styles.cardHeader}>{configKey === '' ? '.' : configKey}</div>
|
||||
<div className={styles.cardBody}>
|
||||
{Object.keys(config[configKey]).map(configOption => {
|
||||
const configOptionInfo = config[configKey][configOption];
|
||||
const configOptionKey = configKey === '' ? configOption : `${configKey}.${configOption}`;
|
||||
|
||||
return (
|
||||
<div key={configOptionKey} className={styles.configOption}>
|
||||
<h3>{configOption}</h3>
|
||||
<p dangerouslySetInnerHTML={{ __html: configOptionInfo.desc }} />
|
||||
{getInput(configOptionKey, configOptionInfo.value)}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
|
||||
const handleExport = () => {
|
||||
let newConfig = config;
|
||||
|
||||
Object.entries(editedConfig.current).forEach(([key, value]) => {
|
||||
const keys = key.split('.');
|
||||
let currentObj = parsedConfig;
|
||||
|
||||
keys.forEach((nestedKey, index) => {
|
||||
if (currentObj.hasOwnProperty(nestedKey)) {
|
||||
if (index === keys.length - 1) {
|
||||
const oldValue = currentObj[nestedKey].value;
|
||||
newConfig = newConfig.replace(` ${nestedKey}: ${oldValue}`, ` ${nestedKey}: ${value}`);
|
||||
} else {
|
||||
currentObj = currentObj[nestedKey];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Trigger a download of the final config
|
||||
downloadString(newConfig, 'text/plain', 'config.yml');
|
||||
}
|
||||
|
||||
function getInput(name, value) {
|
||||
const handleChange = (event) => {
|
||||
const { id, value, type, checked } = event.target;
|
||||
|
||||
editedConfig.current = {
|
||||
...editedConfig.current,
|
||||
[id]: type === 'checkbox' ? checked.toString() : value
|
||||
};
|
||||
}
|
||||
|
||||
switch (name) {
|
||||
// Handle all the dropdowns
|
||||
case 'remote.auth-type':
|
||||
return (
|
||||
<select key={name} className='form-input' id={name} defaultValue={value} onChange={handleChange}>
|
||||
<option value='offline'>offline</option>
|
||||
<option value='online'>online</option>
|
||||
<option value='floodgate'>floodgate</option>
|
||||
</select>
|
||||
);
|
||||
case 'show-cooldown':
|
||||
return (
|
||||
<select key={name} className='form-input' id={name} defaultValue={value} onChange={handleChange}>
|
||||
<option value='title'>title</option>
|
||||
<option value='actionbar'>actionbar</option>
|
||||
<option value='false'>false</option>
|
||||
</select>
|
||||
);
|
||||
case 'emote-offhand-workaround':
|
||||
return (
|
||||
<select key={name} className='form-input' id={name} defaultValue={value} onChange={handleChange}>
|
||||
<option value='disabled'>disabled</option>
|
||||
<option value='no-emotes'>no-emotes</option>
|
||||
<option value='emotes-and-offhand'>emotes-and-offhand</option>
|
||||
</select>
|
||||
);
|
||||
case 'config-version':
|
||||
return <input key={name} className='form-input' type='text' disabled defaultValue={value.replace(/"/g, '')} />;
|
||||
case 'metrics.uuid':
|
||||
return <input key={name} className='form-input' id={name} type='text' disabled defaultValue={value === 'generateduuid' ? crypto.randomUUID() : value} />;
|
||||
|
||||
default:
|
||||
// Handle all the other inputs
|
||||
if (value.toLowerCase() === 'true' || value.toLowerCase() === 'false') {
|
||||
// Boolean
|
||||
return (
|
||||
<div key={name}>
|
||||
<input className='checkbox' type='checkbox' id={name} defaultChecked={value.toLowerCase() === 'true'} onChange={handleChange} />
|
||||
<label htmlFor={name} className='switch'></label>
|
||||
</div>
|
||||
);
|
||||
} else if (!isNaN(value)) {
|
||||
// Number
|
||||
return <input key={name} className='form-input' type='number' defaultValue={value} id={name} onChange={handleChange} />;
|
||||
} else {
|
||||
// String
|
||||
return <input key={name} className='form-input' type='text' defaultValue={value.replace(/"/g, '')} id={name} onChange={handleChange} />;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// From https://gist.github.com/danallison/3ec9d5314788b337b682
|
||||
function downloadString(text, fileType, fileName) {
|
||||
const blob = new Blob([text], { type: fileType })
|
||||
|
||||
const a = document.createElement('a')
|
||||
a.download = fileName
|
||||
a.href = URL.createObjectURL(blob)
|
||||
a.dataset.downloadurl = [fileType, a.download, a.href].join(':')
|
||||
a.style.display = 'none'
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
document.body.removeChild(a)
|
||||
|
||||
setTimeout(() => { URL.revokeObjectURL(a.href) }, 1500)
|
||||
}
|
||||
|
||||
const NoConfigSection = () => (
|
||||
<>
|
||||
<h1><Translate id='pages.configeditor.noconfigselected.heading'>No config selected.</Translate></h1>
|
||||
<h3 className='font-normal'><Translate id='pages.configeditor.noconfigselected.subheading'>Upload a file or get started with the default config!</Translate></h3>
|
||||
|
||||
<div className={styles.buttonsContainer}>
|
||||
<button className='button' onClick={loadDefault}>
|
||||
<Translate id='pages.configeditor.button.defaultconfig'>Default</Translate>
|
||||
</button>
|
||||
|
||||
<button className='button' onClick={() => uploadRef.current.click()}>
|
||||
<input
|
||||
ref={uploadRef}
|
||||
type='file'
|
||||
className='hidden'
|
||||
accept='.yml'
|
||||
onChange={handleUpload}
|
||||
/>
|
||||
<Translate id='pages.configeditor.button.upload'>Upload</Translate>
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
|
||||
const EditorView = () => (
|
||||
<>
|
||||
<div className={styles.buttonsContainer} style={{ marginBottom: '30px' }}>
|
||||
<button className='button' onClick={handleExport}>
|
||||
<Translate id='pages.configeditor.button.export'>Export</Translate>
|
||||
</button>
|
||||
</div>
|
||||
{generateHTML(parsedConfig)}
|
||||
</>
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeroBanner
|
||||
title={<Translate id='pages.configeditor.title'>Config Editor</Translate>}
|
||||
subheading={<Translate id='pages.configeditor.subheading'>Edit your Geyser configuration.</Translate>}
|
||||
backgroundImage={HeroBackground}
|
||||
/>
|
||||
|
||||
<div className='container' style={{ marginTop: '30px' }}>
|
||||
{Object.keys(parsedConfig).length === 0 ? <NoConfigSection /> : <EditorView />}
|
||||
</div>
|
||||
|
||||
|
||||
<section id='config-options'></section>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default function ConfigEditor(): JSX.Element {
|
||||
return (
|
||||
<Layout
|
||||
title={`Config Editor`}
|
||||
description='Edit your Geyser configuration.'
|
||||
>
|
||||
<main>
|
||||
<div className='container container--fluid margin-vert--lg'>
|
||||
<ConfigEditorPage />
|
||||
</div>
|
||||
</main>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
import Translate from '@docusaurus/Translate';
|
||||
import HeroBanner from '@site/src/components/HeroBanner';
|
||||
import HeroBackground from '@site/static/img/site/split-background.jpg';
|
||||
import Layout from '@theme/Layout';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import styles from './utilities.module.css';
|
||||
import { Grid } from '@site/src/components/Grid';
|
||||
import CodeBlock from '@theme/CodeBlock';
|
||||
|
||||
const DumpViewerPage: React.FC = () => {
|
||||
const [dumpId, setDumpId] = useState('');
|
||||
const [data, setData] = useState<any>({});
|
||||
const [statusMessage, setStatusMessage] = useState('');
|
||||
const [activePlugin, setActivePlugin] = useState<any>({});
|
||||
|
||||
const pluginPopoverRef = useRef<any>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (event) => setActivePlugin({});
|
||||
document.addEventListener("mousedown", handleClickOutside);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener("mousedown", handleClickOutside);
|
||||
};
|
||||
}, [pluginPopoverRef]);
|
||||
|
||||
useEffect(() => {
|
||||
// Get the ID from the URL
|
||||
let id = window.location.href.includes('?') ? window.location.href.split('?').pop() : '';
|
||||
if (id === '' || id === undefined) {
|
||||
id = window.location.hash.slice(1);
|
||||
}
|
||||
if (id !== undefined && id !== '') {
|
||||
setDumpId(id);
|
||||
handleLoad(id);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleLoadClick = () => {
|
||||
if (dumpId === '') {
|
||||
setStatusMessage('You haven\'t entered an ID or URL!');
|
||||
return;
|
||||
}
|
||||
let id = dumpId;
|
||||
|
||||
if (dumpId.startsWith('https://dump.geysermc.org/')) {
|
||||
id = dumpId.split('/').pop();
|
||||
}
|
||||
setDumpId(id);
|
||||
handleLoad(id);
|
||||
}
|
||||
|
||||
const handleLoad = async (dumpId) => {
|
||||
try {
|
||||
// Construct the raw dump URL
|
||||
const url = 'https://dump.geysermc.org/raw/' + dumpId;
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
||||
// Check for error
|
||||
if (data.message) {
|
||||
throw new Error(data.message)
|
||||
}
|
||||
|
||||
window.location.hash = '#' + dumpId;
|
||||
setData(data);
|
||||
} catch (error) {
|
||||
setStatusMessage('An error occurred while loading the dump. Please try again later.<br><br>' + error);
|
||||
}
|
||||
}
|
||||
|
||||
const capitalizeFirstLetter = (string) => {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1)
|
||||
}
|
||||
|
||||
const handlePluginClick = (plugin) => {
|
||||
setActivePlugin(plugin);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeroBanner
|
||||
title={<Translate id='pages.dumpviewer.title'>Dump Viewer</Translate>}
|
||||
subheading={<Translate id='pages.dumpviewer.subheading'>View the breakdown of your Geyser dump.</Translate>}
|
||||
backgroundImage={HeroBackground}
|
||||
/>
|
||||
|
||||
<div className='container' style={{ marginTop: '30px' }}>
|
||||
{Object.keys(data).length === 0 ? (
|
||||
<>
|
||||
<h2><Translate id='pages.dumpviewer.enterdumpid'>Enter Dump ID or URL below and click load.</Translate></h2>
|
||||
<input id='dump-url' className='form-input no-outline' value={dumpId} onChange={(e) => setDumpId(e.target.value)} placeholder='Dump ID/URL' />
|
||||
<button className={styles.loadButton} onClick={handleLoadClick}>
|
||||
<Translate id='pages.dumpviewer.button.load'>Load</Translate>
|
||||
</button>
|
||||
|
||||
{statusMessage !== '' ? (
|
||||
<div className={styles.statusMessage}>
|
||||
<p dangerouslySetInnerHTML={{ __html: statusMessage }} />
|
||||
</div>
|
||||
) : undefined}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<div className={styles.card}>
|
||||
<div className={styles.cardHeader}>
|
||||
<Translate id='pages.dumpviewer.versions'>Versions</Translate>
|
||||
</div>
|
||||
<div className={styles.cardBody}>
|
||||
<Grid elementsPerRow={3} gap='8px'>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.versions.geyserver'>Geyser Version</Translate></b><br />
|
||||
<p id='geyserVersion'>{data.versionInfo.version}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.versions.javaver'>Java Version</Translate></b><br />
|
||||
<p id='javaVersion'>{data.versionInfo.javaVersion} ({data.versionInfo.architecture})</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.versions.os'>Operating System</Translate></b><br />
|
||||
<p id='osVersion'>{data.versionInfo.operatingSystem} ({data.versionInfo.operatingSystemVersion})</p>
|
||||
</div>
|
||||
</Grid>
|
||||
</div>
|
||||
<div className={styles.card}>
|
||||
<div className={styles.cardHeader}>
|
||||
<Translate id='pages.dumpviewer.geyserver'>Geyser Version</Translate>
|
||||
</div>
|
||||
<div className={styles.cardBody}>
|
||||
<Grid elementsPerRow={3} gap='8px'>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.geyserver.build'>Build</Translate></b><br />
|
||||
<p id='buildNumber'>{data.gitInfo['git.build.number'] ?? data.gitInfo.buildNumber}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.geyserver.commit'>Commit Hash</Translate></b><br />
|
||||
<a id='commit' target='_blank' href={'https://github.com/GeyserMC/Geyser/commit/' + data.gitInfo['git.commit.id']}>{data.gitInfo['git.commit.id.abbrev']}</a>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.geyserver.branch'>Branch</Translate></b><br />
|
||||
<p id='branch'>{data.gitInfo['git.branch']}</p>
|
||||
</div>
|
||||
</Grid>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.card}>
|
||||
<div className={styles.cardHeader}>
|
||||
<Translate id='pages.dumpviewer.platform'>Platform Info</Translate>
|
||||
</div>
|
||||
<div className={styles.cardBody}>
|
||||
<Grid elementsPerRow={5} gap='8px'>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.platform.id'>Platform Identifier</Translate></b><br />
|
||||
<p id='platformIdentifier'>{data.bootstrapInfo.platform.platformName || data.bootstrapInfo.platform}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.platform.name'>Platform Name</Translate></b><br />
|
||||
<p id='platformName'>{data.bootstrapInfo.platformName ?? capitalizeFirstLetter(data.bootstrapInfo.platform.toLowerCase())}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.platform.version'>Platform Version</Translate></b><br />
|
||||
<p id='platformVersion'>{data.bootstrapInfo.platformVersion ?? 'N/A'}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.platform.apiver'>Platform API Version</Translate></b><br />
|
||||
<p id='platformAPIVersion'>{data.bootstrapInfo.platformAPIVersion ?? 'N/A'}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.platform.onlinemode'>Online Mode</Translate></b><br />
|
||||
<p id='onlineMode'>{data.bootstrapInfo.onlineMode !== null ? data.bootstrapInfo.onlineMode ? 'true' : 'false' : 'N/A'}</p>
|
||||
</div>
|
||||
</Grid>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.card}>
|
||||
<div className={styles.cardHeader}>
|
||||
<Translate id='pages.dumpviewer.sysinfo'>System Info</Translate>
|
||||
</div>
|
||||
<div className={styles.cardBody}>
|
||||
<Grid elementsPerRow={3} gap='8px'>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.cpucount'>CPU Count</Translate></b><br />
|
||||
<p id='cpuCount'>{data.cpuCount}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.cpuname'>CPU Name</Translate></b><br />
|
||||
<p id='cpuName'>{data.cpuName}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.ram'>RAM</Translate></b><br />
|
||||
<p id='ram'>{data.ramInfo.total} MB ({data.ramInfo.free} MB free)</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.javaname'>Java Name</Translate></b><br />
|
||||
<p id='javaName'>{data.versionInfo.javaName}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.javavendor'>Java Vendor</Translate></b><br />
|
||||
<p id='javaVendor'>{data.versionInfo.javaVendor}</p>
|
||||
</div>
|
||||
<div>
|
||||
<b><Translate id='pages.dumpviewer.dockercheck'>Uses Docker?</Translate></b><br />
|
||||
<p id='dockerCheck'>{data.versionInfo.network.dockerCheck ? "true" : "false"}</p>
|
||||
</div>
|
||||
</Grid>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.card}>
|
||||
<div className={styles.cardHeader}>
|
||||
<Translate id='pages.dumpviewer.plugins'>Plugins</Translate> ({data.bootstrapInfo.plugins.length})
|
||||
</div>
|
||||
<div className={styles.cardBody}>
|
||||
{data.bootstrapInfo.plugins.length === 0 ? <p><Translate id='pages.dumpviewer.plugins.noplugins'>No plugins to show.</Translate></p> : (
|
||||
<>
|
||||
<p><Translate id='pages.dumpviewer.plugins.helptext'>Click on a plugin to view more information.</Translate></p>
|
||||
|
||||
<Grid elementsPerRow={5}>
|
||||
{data.bootstrapInfo.plugins.map(plugin => (
|
||||
<div>
|
||||
<b onClick={() => handlePluginClick(plugin)} className={styles.pluginName}>
|
||||
{plugin.name} <div className={styles.pluginEnabledIndicator} style={{ backgroundColor: plugin.enabled ? "green" : "red" }} />
|
||||
</b>
|
||||
|
||||
{activePlugin?.main === plugin.main ? (
|
||||
<div ref={pluginPopoverRef} className={styles.pluginInfoPopover}>
|
||||
<p className={styles.pluginNamePopover}>{plugin.name}</p>
|
||||
<p>{plugin.version}</p>
|
||||
<p className={styles.pluginEnabled} style={{ backgroundColor: plugin.enabled ? "green" : "red" }}>{plugin.enabled ? "Enabled" : "Disabled"}</p>
|
||||
|
||||
<p className={styles.pluginAuthorsLabel}>Authors:</p>
|
||||
<ul>
|
||||
{plugin.authors.map(author => <li>{author}</li>)}
|
||||
</ul>
|
||||
</div>
|
||||
) : undefined}
|
||||
</div>
|
||||
))}
|
||||
</Grid>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles.card}>
|
||||
<div className={styles.cardHeader}>
|
||||
<Translate id='pages.dumpviewer.config'>Config</Translate>
|
||||
</div>
|
||||
<div className={styles.cardBody}>
|
||||
<CodeBlock
|
||||
language='json'
|
||||
showLineNumbers
|
||||
>
|
||||
{JSON.stringify(data.config, null, 2)}
|
||||
</CodeBlock>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a target="_blank" href={`https://dump.geysermc.org/${dumpId}`} className={styles.viewDumpSource}><Translate id="pages.dumpviewer.viewsource">View dump source</Translate> {'>'}</a>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default function DumpViewer(): JSX.Element {
|
||||
return (
|
||||
<Layout
|
||||
title={`Dump Viewer`}
|
||||
description='View the breakdown of your Geyser dump.'
|
||||
>
|
||||
<main>
|
||||
<div className='container container--fluid margin-vert--lg'>
|
||||
<DumpViewerPage />
|
||||
</div>
|
||||
</main>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
:root {
|
||||
--card-bg-color: #f7f5f5;
|
||||
}
|
||||
|
||||
[data-theme='dark'] {
|
||||
--card-bg-color: #0b1215 !important;
|
||||
}
|
||||
|
||||
.buttonsContainer {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin-bottom: 30px;
|
||||
background-color: var(--card-bg-color);
|
||||
}
|
||||
|
||||
.cardHeader {
|
||||
background-color: var(--ifm-color-primary);
|
||||
color: white;
|
||||
padding-left: 16px;
|
||||
font-size: 22px;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.cardBody {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.configOption {
|
||||
padding-bottom: 20px;
|
||||
padding-top: 20px;
|
||||
border-bottom: 1px solid gray;
|
||||
}
|
||||
|
||||
.configOption:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.loadButton {
|
||||
width: 150px;
|
||||
outline: 3px solid var(--ifm-tabs-color-active);
|
||||
outline-offset: -3px;
|
||||
border: 0;
|
||||
border-radius: var(--ifm-global-radius);
|
||||
background-color: transparent;
|
||||
text-align: center;
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
transition: background-color 0.5s ease, color 0.5s ease;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
color: var(--ifm-tabs-color-active);
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.loadButton:hover {
|
||||
background-color: var(--ifm-color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.statusMessage {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.pluginName:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.pluginInfoPopover {
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
color: black;
|
||||
padding: 16px;
|
||||
z-index: 1000;
|
||||
min-width: 300px;
|
||||
box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
|
||||
}
|
||||
|
||||
.pluginInfoPopover p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.pluginNamePopover {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pluginEnabled {
|
||||
border-radius: 10px;
|
||||
padding: 0 10px;
|
||||
width: fit-content;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.pluginAuthorsLabel {
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
.viewDumpSource {
|
||||
|
||||
}
|
||||
|
||||
.pluginEnabledIndicator {
|
||||
display: inline-block;
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
Reference in new issue
Block a user