Skip to content

Commit

Permalink
fix JSONEditor config format
Browse files Browse the repository at this point in the history
 * remove css workaround
  • Loading branch information
a-sync committed Jan 6, 2024
1 parent 5cdfd32 commit 258ddfb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 43 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// list game id's from gamedig module and replace type text field with a dropdown

// move loop inside watcher instance
// flush game server specific (d/t) data
// response normalization: https://github.com/GameServerManagers/LinuxGSM/blob/master/lgsm/functions/query_gamedig.sh
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/game-server-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"type": {
"title": "GameDig type",
"description": "For more info check the <a href=\"https://github.com/gamedig/node-gamedig/blob/master/GAMES_LIST.md\">GameDig games list</a>.",
"description": "Check the <a href=\"https://github.com/gamedig/node-gamedig/blob/master/GAMES_LIST.md\">GameDig games list</a> for requirements.",
"type": "string",
"minLength": 1,
"options": {
Expand Down
6 changes: 0 additions & 6 deletions public/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@ body>nav {
padding-left: 5px !important;
}

/* fixes no_additional_properties not hiding inputs */
#config-form .property-selector-input,
#config-form .property-selector-input + button {
display: none;
}

#config-form td[data-schematype="boolean"] > div.form-group > input[type="checkbox"] {
transform: scale(2.5);
margin: 10px 0 0 10px;
Expand Down
38 changes: 19 additions & 19 deletions public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,27 @@ $(async () => {
"iconlib": "fontawesome5",
"object_layout": "normal",
"template": "mustache",
"compact": 0,
"compact": false,
"show_errors": "always",
"required_by_default": 0,
"required_by_default": false,
"no_additional_properties": true,
"display_required_only": 1,
"show_opt_in": 0,
"remove_empty_properties": 0,
"use_default_values": 1,
"ajax": 1,
"ajaxCredentials": 0,
"disable_edit_json": 0,
"disable_collapse": 1,
"disable_properties": 0,
"disable_array_add": 0,
"disable_array_delete": 0,
"disable_array_reorder": 1,
"enable_array_copy": 1,
"array_controls_top": 0,
"disable_array_delete_all_rows": 1,
"disable_array_delete_last_row": 1,
"prompt_before_delete": 1,
"display_required_only": true,
"show_opt_in": false,
"remove_empty_properties": false,
"use_default_values": true,
"ajax": true,
"ajaxCredentials": false,
"disable_edit_json": false,
"disable_collapse": true,
"disable_properties": false,
"disable_array_add": false,
"disable_array_delete": false,
"disable_array_reorder": true,
"enable_array_copy": true,
"array_controls_top": false,
"disable_array_delete_all_rows": true,
"disable_array_delete_last_row": true,
"prompt_before_delete": true,
"schema": {
"title": "Configuration",
"type": "array",
Expand Down
25 changes: 11 additions & 14 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import crypto from 'node:crypto';
import { createServer } from 'node:http';
import { URL } from 'node:url';
import { getInstance } from 'gamedig';
//import gamedigPjson from '../node_modules/gamedig/package.json' assert {type: 'json'};
const gamedigPjson = fs.readFileSync(path.resolve(__dirname, '../node_modules/gamedig/package.json'), 'utf-8');
const gamedigVersion = JSON.parse(gamedigPjson).version || 0;

import 'dotenv/config';

import { GameServerConfig, main, readConfig, updateConfig } from './watcher';

const gamedigPjson = fs.readFileSync(path.resolve(__dirname, '../node_modules/gamedig/package.json'), 'utf-8');
const gamedigVersion = JSON.parse(gamedigPjson).version || 0;

const HOST = process.env.HOST || '0.0.0.0';
const PORT = parseInt(process.env.PORT || '8080', 10);
const SECRET = process.env.SECRET || 'secret';
Expand Down Expand Up @@ -74,22 +72,21 @@ createServer(async (req, res) => {
if (DBG) console.log('ping');
res.end('pong');
} else if (p === 'gamedig-games') {
//re.version = gamedigPjson.version;
const gd = getInstance();
// @ts-ignore
const games: Map<string,{pretty: string}> = gd.queryRunner.gameResolver.gamesByKey || new Map();
let status = 200;
let re: SelectOptionsResponse = {

res.writeHead(200, {
'Content-Type': 'application/json',
'Cache-Control': 'max-age=0'
});

res.end(JSON.stringify({
enum: Array.from(games.keys()),
options: {
enum_titles: Array.from(games.values()).map(g=>g.pretty)
}
};
res.writeHead(status, {
'Content-Type': 'application/json',
'Cache-Control': 'max-age=0'
});
res.end(JSON.stringify(re, null, DBG ? 2 : 0));
} as SelectOptionsResponse, null, DBG ? 2 : 0));
} else if (SECRET !== '' && req.headers['x-btoken']) {
let status = 200;
let re: ApiResponse = {};
Expand Down

0 comments on commit 258ddfb

Please sign in to comment.