Display settings with hacky solution to retain order

Python utility included to convert config-base.json into a new version
which includes lists that define the order settings should be displayed.
admin.js edited to recognize this.
This commit is contained in:
Harvey Tindall
2020-07-31 16:09:30 +01:00
parent ef4f2503c9
commit 024c0b56aa
9 changed files with 811 additions and 20 deletions
+94 -1
View File
@@ -1,5 +1,27 @@
{
"order": [
"jellyfin",
"ui",
"password_validation",
"email",
"password_resets",
"invite_emails",
"notifications",
"mailgun",
"smtp",
"files"
],
"jellyfin": {
"order": [
"username",
"password",
"server",
"public_server",
"client",
"version",
"device",
"device_id"
],
"meta": {
"name": "Jellyfin",
"description": "Settings for connecting to Jellyfin"
@@ -66,6 +88,21 @@
}
},
"ui": {
"order": [
"theme",
"host",
"port",
"jellyfin_login",
"admin_only",
"username",
"password",
"email",
"debug",
"contact_message",
"help_message",
"success_message",
"bs5"
],
"meta": {
"name": "General",
"description": "Settings related to the UI and program functionality."
@@ -183,6 +220,14 @@
}
},
"password_validation": {
"order": [
"enabled",
"min_length",
"upper",
"lower",
"number",
"special"
],
"meta": {
"name": "Password Validation",
"description": "Password validation (minimum length, etc.)"
@@ -231,6 +276,15 @@
}
},
"email": {
"order": [
"no_username",
"use_24h",
"date_format",
"message",
"method",
"address",
"from"
],
"meta": {
"name": "Email",
"description": "General email settings. Ignore if not using email features."
@@ -302,6 +356,13 @@
}
},
"password_resets": {
"order": [
"enabled",
"watch_directory",
"email_html",
"email_text",
"subject"
],
"meta": {
"name": "Password Resets",
"description": "Settings for the password reset handler."
@@ -352,6 +413,13 @@
}
},
"invite_emails": {
"order": [
"enabled",
"email_html",
"email_text",
"subject",
"url_base"
],
"meta": {
"name": "Invite emails",
"description": "Settings for sending invites directly to users."
@@ -401,6 +469,13 @@
}
},
"notifications": {
"order": [
"enabled",
"expiry_html",
"expiry_text",
"created_html",
"created_text"
],
"meta": {
"name": "Notifications",
"description": "Notification related settings."
@@ -451,6 +526,10 @@
}
},
"mailgun": {
"order": [
"api_url",
"api_key"
],
"meta": {
"name": "Mailgun (Email)",
"description": "Mailgun API connection settings"
@@ -471,6 +550,12 @@
}
},
"smtp": {
"order": [
"encryption",
"server",
"port",
"password"
],
"meta": {
"name": "SMTP (Email)",
"description": "SMTP Server connection settings."
@@ -511,6 +596,14 @@
}
},
"files": {
"order": [
"invites",
"emails",
"user_template",
"user_configuration",
"user_displayprefs",
"custom_css"
],
"meta": {
"name": "File Storage",
"description": "Optional settings for changing storage locations."
@@ -564,4 +657,4 @@
"description": "Location of custom bootstrap CSS."
}
}
}
}
+4 -4
View File
@@ -776,7 +776,7 @@ document.getElementById('openSettings').onclick = function () {
let settingsList = document.getElementById('settingsList');
settingsList.textContent = '';
config = this.response;
for (let section of Object.keys(config)) {
for (let section of config["order"]) {
let sectionCollapse = document.createElement('div');
sectionCollapse.classList.add('collapse');
sectionCollapse.id = section;
@@ -796,7 +796,7 @@ document.getElementById('openSettings').onclick = function () {
sectionCollapse.innerHTML = innerCollapse;
for (var entry of Object.keys(config[section])) {
for (var entry of config[section]["order"]) {
if (entry != 'meta') {
let entryName = config[section][entry]['name'];
let required = false;
@@ -923,8 +923,8 @@ document.getElementById('settingsSave').onclick = function() {
var restart_setting_changed = false;
var settings_changed = false;
for (let section of Object.keys(config)) {
for (let entry of Object.keys(config[section])) {
for (let section of config["order"]) {
for (let entry of config[section]["order"]) {
if (entry != 'meta') {
let entryID = section + '_' + entry;
let el = document.getElementById(entryID);