Add more recommended settings

Also split expansions out into their own field.
This commit is contained in:
Corey 2024-05-07 12:07:26 +00:00
parent 1553b2606b
commit 814092a9f0
10 changed files with 122 additions and 68 deletions

View File

@ -21,7 +21,7 @@
"ghcr.io/devcontainers/features/docker-outside-of-docker:latest": {} "ghcr.io/devcontainers/features/docker-outside-of-docker:latest": {}
}, },
"mounts": [ "mounts": [
"source=vscode-extensions,target=/root/.vscode-server/extensions,type=volume", "source=vscode-extensions,target=/root/.vscode-server/extensions,type=volume"
], ],
"customizations": { "customizations": {
"vscode": { "vscode": {

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
python manage.py collectstatic --noinput python manage.py collectstatic --noinput
python manage.py makemigrations # python manage.py makemigrations
python manage.py migrate python manage.py migrate
exec "$@" exec "$@"

View File

@ -0,0 +1,23 @@
# Generated by Django 5.0.5 on 2024-05-07 11:42
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('v1', '0005_alter_server_url'),
]
operations = [
migrations.RenameField(
model_name='server',
old_name='customizations',
new_name='settings_summary',
),
migrations.AddField(
model_name='server',
name='expansions',
field=models.JSONField(editable=False, null=True),
),
]

View File

@ -17,15 +17,31 @@ required_settings = [
] ]
recommended_settings = [ recommended_settings = [
"LOGIN.CLIENT_VER",
"MAIN.ENABLE_TRUST_CASTING", "MAIN.ENABLE_TRUST_CASTING",
"MAIN.HOMEPOINT_TELEPORT",
"MAIN.ENABLE_SURVIVAL_GUIDE",
"MAP.LEVEL_SYNC_ENABLE", "MAP.LEVEL_SYNC_ENABLE",
"LOGIN.RISE_OF_ZILART", "MAIN.ENABLE_ROE",
"LOGIN.CHAINS_OF_PROMATHIA", "MAIN.ENABLE_FIELD_MANUALS",
"LOGIN.TREASURES_OF_AHT_URGHAN", "MAIN.ENABLE_GROUNDS_TOMES",
"LOGIN.WINGS_OF_THE_GODDESS",
"LOGIN.SEEKERS_OF_ADOULIN",
] ]
expansions_settings = {
"LOGIN.RISE_OF_ZILART": "rotz",
"LOGIN.CHAINS_OF_PROMATHIA": "cop",
"LOGIN.TREASURES_OF_AHT_URGHAN": "toau",
"LOGIN.WINGS_OF_THE_GODDESS": "wotg",
"LOGIN.SEEKERS_OF_ADOULIN": "soa",
"MAIN.ENABLE_ACP": "acp",
"MAIN.ENABLE_AMK": "amk",
"MAIN.ENABLE_ASA": "asa",
"MAIN.ENABLE_ABYSSEA": "abyssea",
"MAIN.ENABLE_VOIDWATCH": "voidwatch",
"MAIN.ENABLE_ROV": "rov",
"MAIN.ENABLE_TVR": "tvr",
}
class OptionalSchemeURLValidator(URLValidator): class OptionalSchemeURLValidator(URLValidator):
def __call__(self, value): def __call__(self, value):
@ -51,8 +67,9 @@ class Server(models.Model):
) )
location = models.CharField(max_length=255, null=True, editable=False) location = models.CharField(max_length=255, null=True, editable=False)
max_level = models.IntegerField(null=True, editable=False) max_level = models.IntegerField(null=True, editable=False)
expansions = models.JSONField(null=True, editable=False)
settings = models.JSONField(null=True, editable=False) settings = models.JSONField(null=True, editable=False)
customizations = models.JSONField(null=True, editable=False) settings_summary = models.JSONField(null=True, editable=False)
login_limit = models.IntegerField(null=True, editable=False) login_limit = models.IntegerField(null=True, editable=False)
active_sessions = models.IntegerField(null=True, editable=False) active_sessions = models.IntegerField(null=True, editable=False)
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField(auto_now_add=True)
@ -119,30 +136,39 @@ class Server(models.Model):
self.max_level = server_settings["MAIN.MAX_LEVEL"] self.max_level = server_settings["MAIN.MAX_LEVEL"]
self.login_limit = server_settings["LOGIN.LOGIN_LIMIT"] self.login_limit = server_settings["LOGIN.LOGIN_LIMIT"]
# Check customizations
with open("defaultLsbSettings.json", "r") as default_settings_file: with open("defaultLsbSettings.json", "r") as default_settings_file:
default_settings = json.load(default_settings_file) default_settings = json.load(default_settings_file)
customizations = {}
customizations["LOGIN.CLIENT_VER"] = server_settings["LOGIN.CLIENT_VER"] expansions = {}
for setting in expansions_settings:
expansions[expansions_settings[setting]] = (
True if server_settings[setting] else False
)
settings_summary = {}
for setting in recommended_settings:
if server_settings[setting]:
settings_summary[setting] = server_settings[setting]
# Check customizations
for key, value in server_settings.items(): for key, value in server_settings.items():
if key not in required_settings and ( if (
key in recommended_settings key not in required_settings
or key not in default_settings and key not in recommended_settings
or default_settings[key] != value and key not in expansions_settings
and (key not in default_settings or default_settings[key] != value)
): ):
customizations[key] = value settings_summary[key] = value
self.customizations = customizations self.expansions = expansions
self.settings = server_settings self.settings = server_settings
self.settings_summary = settings_summary
# Request the active session count from API # Request the active session count from API
response = requests.get(f"http://{self.url}/api/sessions") response = requests.get(f"http://{self.url}/api/sessions")
response.raise_for_status() response.raise_for_status()
session_count = response.text active_sessions = response.text
if session_count.isdigit(): if active_sessions.isdigit():
self.active_sessions = int(session_count) self.active_sessions = int(active_sessions)
# Test other server ports (you can actually change all of these?) # Test other server ports (you can actually change all of these?)
# ports_to_check = [ # ports_to_check = [

View File

@ -11,7 +11,8 @@ class ServerSerializer(serializers.ModelSerializer):
"url", "url",
"location", "location",
"max_level", "max_level",
"customizations", "expansions",
"settings_summary",
"login_limit", "login_limit",
"active_sessions", "active_sessions",
"updated", "updated",

View File

@ -55,13 +55,15 @@ export default function ExpansionBar({ server }: ExpansionBarProps) {
return ( return (
<ToggleButtonGroup <ToggleButtonGroup
size="small" size="small"
value={[ value={
server.customizations['LOGIN.RISE_OF_ZILART'] && 'rotz', server.expansions && [
server.customizations['LOGIN.CHAINS_OF_PROMATHIA'] && 'cop', server.expansions.rotz && 'rotz',
server.customizations['LOGIN.TREASURES_OF_AHT_URGHAN'] && 'toau', server.expansions.cop && 'cop',
server.customizations['LOGIN.WINGS_OF_THE_GODDESS'] && 'wotg', server.expansions.toau && 'toau',
server.customizations['LOGIN.SEEKERS_OF_ADOULIN'] && 'soa', server.expansions.wotg && 'wotg',
]} server.expansions.soa && 'soa',
]
}
sx={{ '& button': { lineHeight: 1.0 } }} sx={{ '& button': { lineHeight: 1.0 } }}
> >
{expansions} {expansions}

View File

@ -80,7 +80,7 @@ export default function SettingsChipCloud({ server }: SettingsChipCloudProps) {
maxWidth: '100%', maxWidth: '100%',
}} }}
> >
{Object.entries(server.customizations).map(renderSettingsChip)} {Object.entries(server.settings_summary).map(renderSettingsChip)}
</Box> </Box>
); );
} }

View File

@ -124,7 +124,7 @@ export default function ServerCard({ server, children }: ServerCardProps) {
> >
<Box className="flex flex-col items-center justify-center"> <Box className="flex flex-col items-center justify-center">
<Box className="flex content-center"> <Box className="flex content-center">
{server.customizations['LOGIN.MAINT_MODE'] === 1 ? ( {server.settings_summary['LOGIN.MAINT_MODE'] === 1 ? (
<Tooltip <Tooltip
arrow arrow
disableInteractive disableInteractive
@ -183,13 +183,13 @@ export default function ServerCard({ server, children }: ServerCardProps) {
> >
{server.name} {server.name}
</Typography> </Typography>
{typeof server.customizations['API.WEBSITE'] === 'string' && {typeof server.settings_summary['API.WEBSITE'] === 'string' &&
server.customizations['API.WEBSITE'] !== '' && ( server.settings_summary['API.WEBSITE'] !== '' && (
<Tooltip arrow disableInteractive title="Visit website."> <Tooltip arrow disableInteractive title="Visit website.">
<IconButton <IconButton
component={Link} component={Link}
to={formatExternalUrl( to={formatExternalUrl(
server.customizations['API.WEBSITE'] server.settings_summary['API.WEBSITE']
)} )}
target="_blank" target="_blank"
rel="noopener" rel="noopener"
@ -259,11 +259,11 @@ export default function ServerCard({ server, children }: ServerCardProps) {
</Box> </Box>
</AccordionSummary> </AccordionSummary>
<AccordionDetails className="p-2"> <AccordionDetails className="p-2">
{server.customizations['MAIN.SERVER_MESSAGE'] && ( {server.settings_summary['MAIN.SERVER_MESSAGE'] && (
<> <>
<Box className="flex justify-center"> <Box className="flex justify-center">
<Typography variant="body2"> <Typography variant="body2">
{server.customizations['MAIN.SERVER_MESSAGE']} {server.settings_summary['MAIN.SERVER_MESSAGE']}
</Typography> </Typography>
</Box> </Box>
<Divider sx={{ marginY: 1 }} /> <Divider sx={{ marginY: 1 }} />

View File

@ -16,8 +16,9 @@ export type ServerData = {
url: string; url: string;
location: string; location: string;
max_level: number; max_level: number;
expansions: ServerSettings;
settings?: ServerSettings; settings?: ServerSettings;
customizations: ServerSettings; settings_summary: ServerSettings;
login_limit: number; login_limit: number;
active_sessions: number; active_sessions: number;
updated: string; updated: string;
@ -29,8 +30,22 @@ export const DemoServerData: ServerData = {
url: 'github.com/LandSandBoat/server', url: 'github.com/LandSandBoat/server',
location: 'NA', location: 'NA',
max_level: 99, max_level: 99,
expansions: {
rotz: true,
cop: true,
toau: true,
wotg: true,
soa: true,
acp: true,
amk: true,
asa: true,
abyssea: true,
voidwatch: true,
rov: true,
tvr: true,
},
settings: LsbDefaults, settings: LsbDefaults,
customizations: { settings_summary: {
'API.WEBSITE': 'https://landsandboat.github.io/server/', 'API.WEBSITE': 'https://landsandboat.github.io/server/',
'MAIN.ENABLE_TRUST_CASTING': 1, 'MAIN.ENABLE_TRUST_CASTING': 1,
'MAP.LEVEL_SYNC_ENABLE': true, 'MAP.LEVEL_SYNC_ENABLE': true,

View File

@ -29,10 +29,10 @@ export default function Home({
if ( if (
searchState.trusts && searchState.trusts &&
typeof server.customizations['MAIN.ENABLE_TRUST_CASTING'] === 'number' typeof server.settings_summary['MAIN.ENABLE_TRUST_CASTING'] === 'number'
) { ) {
const serverTrusts = const serverTrusts =
server.customizations['MAIN.ENABLE_TRUST_CASTING'] === 1; server.settings_summary['MAIN.ENABLE_TRUST_CASTING'] === 1;
const searchEnabled = searchState.trusts.includes('enabled'); const searchEnabled = searchState.trusts.includes('enabled');
const searchDisabled = searchState.trusts.includes('disabled'); const searchDisabled = searchState.trusts.includes('disabled');
if (serverTrusts && searchDisabled && !searchEnabled) { if (serverTrusts && searchDisabled && !searchEnabled) {
@ -45,9 +45,9 @@ export default function Home({
if ( if (
searchState.levelSync && searchState.levelSync &&
typeof server.customizations['MAP.LEVEL_SYNC_ENABLE'] === 'boolean' typeof server.settings_summary['MAP.LEVEL_SYNC_ENABLE'] === 'boolean'
) { ) {
const serverLevelSync = server.customizations['MAP.LEVEL_SYNC_ENABLE']; const serverLevelSync = server.settings_summary['MAP.LEVEL_SYNC_ENABLE'];
const searchEnabled = searchState.levelSync.includes('enabled'); const searchEnabled = searchState.levelSync.includes('enabled');
const searchDisabled = searchState.levelSync.includes('disabled'); const searchDisabled = searchState.levelSync.includes('disabled');
if (serverLevelSync && searchDisabled && !searchEnabled) { if (serverLevelSync && searchDisabled && !searchEnabled) {
@ -59,45 +59,32 @@ export default function Home({
} }
if (searchState.expansions) { if (searchState.expansions) {
const searchNoneEnabled = searchState.expansions.includes('none'); if (!server.expansions) {
const searchRotzEnabled = searchState.expansions.includes('rotz'); return false;
const serverRotzEnabled = }
server.customizations['LOGIN.RISE_OF_ZILART'] === true;
const searchCopEnabled = searchState.expansions.includes('cop');
const serverCopEnabled =
server.customizations['LOGIN.CHAINS_OF_PROMATHIA'] === true;
const searchToauEnabled = searchState.expansions.includes('toau');
const serverToauEnabled =
server.customizations['LOGIN.TREASURES_OF_AHT_URGHAN'] === true;
const searchWotgEnabled = searchState.expansions.includes('wotg');
const serverWotgEnabled =
server.customizations['LOGIN.WINGS_OF_THE_GODDESS'] === true;
const searchSoaEnabled = searchState.expansions.includes('soa');
const serverSoaEnabled =
server.customizations['LOGIN.SEEKERS_OF_ADOULIN'] === true;
if ( if (
searchNoneEnabled && searchState.expansions.includes('none') &&
(serverRotzEnabled || (server.expansions.rotz ||
serverCopEnabled || server.expansions.cop ||
serverToauEnabled || server.expansions.toau ||
serverWotgEnabled || server.expansions.wotg ||
serverSoaEnabled) server.expansions.soa)
) { ) {
return false; return false;
} }
if (searchRotzEnabled !== serverRotzEnabled) { if (searchState.expansions.includes('rotz') && server.expansions.rotz) {
return false; return false;
} }
if (searchCopEnabled !== serverCopEnabled) { if (searchState.expansions.includes('cop') && server.expansions.cop) {
return false; return false;
} }
if (searchToauEnabled !== serverToauEnabled) { if (searchState.expansions.includes('toau') && server.expansions.toau) {
return false; return false;
} }
if (searchWotgEnabled !== serverWotgEnabled) { if (searchState.expansions.includes('wotg') && server.expansions.wotg) {
return false; return false;
} }
if (searchSoaEnabled !== serverSoaEnabled) { if (searchState.expansions.includes('soa') && server.expansions.soa) {
return false; return false;
} }
} }