1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-27 06:23:53 +01:00

plugins list hotfix

This commit is contained in:
Marek Farkaš
2025-02-09 18:27:12 +01:00
parent ceb6e1bd11
commit 05addcf82d
2 changed files with 22 additions and 29 deletions

View File

@@ -45,9 +45,25 @@ function populateFields(data, prefix = "") {
let id = `${prefix}${prefix ? "-" : ""}${key}`; let id = `${prefix}${prefix ? "-" : ""}${key}`;
const $element = $(`#${id}`); const $element = $(`#${id}`);
if (key === "plugins" && $element.is('select[multiple]')) {
if (Array.isArray(value)) {
$element.find('option').each(function() {
const $option = $(this);
const dataName = $option.data('name');
if (value.includes(dataName)) {
$option.prop('selected', true);
} else {
$option.prop('selected', false);
}
});
$element.trigger('change');
}
return;
}
if (typeof value === "object" && value !== null) { if (typeof value === "object" && value !== null) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
// Handle arrays correctly
value.forEach((item, index) => { value.forEach((item, index) => {
const arrayId = `${id}-${index + 1}`; const arrayId = `${id}-${index + 1}`;
const $arrayElement = $(`#${arrayId}`); const $arrayElement = $(`#${arrayId}`);
@@ -60,7 +76,6 @@ function populateFields(data, prefix = "") {
}); });
return; return;
} else { } else {
// Handle nested objects
populateFields(value, id); populateFields(value, id);
return; return;
} }
@@ -107,7 +122,7 @@ function updateConfigData(data, prefix = "") {
data[key] = []; data[key] = [];
const $selectedOptions = $element.find('option:selected'); const $selectedOptions = $element.find('option:selected');
$selectedOptions.each(function() { $selectedOptions.each(function() {
const dataName = $(this).data('name'); const dataName = $(this).attr('data-name');
if (dataName) { if (dataName) {
data[key].push(dataName); data[key].push(dataName);
} }

View File

@@ -33,8 +33,8 @@
<li role="tab" data-panel="identification" tabindex="0"> <li role="tab" data-panel="identification" tabindex="0">
<a href="#" role="tab" tabindex="-1" aria-controls="identification"><i class="fa-solid fa-fw fa-circle-info"></i> Identification & Map</a> <a href="#" role="tab" tabindex="-1" aria-controls="identification"><i class="fa-solid fa-fw fa-circle-info"></i> Identification & Map</a>
</li> </li>
<li role="tab" data-panel="plugins" tabindex="0"> <li role="tab" data-panel="plugins-tab" tabindex="0">
<a href="#" role="tab" tabindex="-1" aria-controls="plugins"><i class="fa-solid fa-fw fa-puzzle-piece"></i> Plugins</a> <a href="#" role="tab" tabindex="-1" aria-controls="plugins-tab"><i class="fa-solid fa-fw fa-puzzle-piece"></i> Plugins</a>
</li> </li>
<li role="tab" data-panel="users" tabindex="0"> <li role="tab" data-panel="users" tabindex="0">
<a href="#" role="tab" tabindex="-1" aria-controls="users"><i class="fa-solid fa-fw fa-user"></i> User management</a> <a href="#" role="tab" tabindex="-1" aria-controls="users"><i class="fa-solid fa-fw fa-user"></i> User management</a>
@@ -297,28 +297,6 @@
</div> </div>
<div class="panel-full m-0 tab-content no-bg" id="plugins" role="tabpanel">
<h2>Plugins</h2>
<div class="panel-100 p-bottom-20">
<h3>Plugin list</h3>
<p>Any compatible <strong>.js</strong> plugin, which is in the "plugins" folder, will be listed here.<br>
Click on the individual plugins to enable/disable them.</p>
<select id="plugin-list" class="multiselect" multiple>
<% plugins.forEach(function(plugin) { %>
<option data-name="<%= plugin.frontEndPath %>" title="<%= plugin.name %> by <%= plugin.author %> [v<%= plugin.version %>]">
<%= plugin.name %> by <%= plugin.author %> [v<%= plugin.version %>]
</option>
<% }); %>
</select><br><br>
<a href="https://github.com/NoobishSVK/fm-dx-webserver/wiki/Plugin-List" target="_blank">Download new plugins here!</a>
</div>
<div class="panel-100 p-bottom-20">
<h3>Plugin settings</h3>
<div id="plugin-settings">No plugin settings are available.</div>
</div>
</div>
<div class="panel-full m-0 tab-content no-bg" id="tuner" role="tabpanel"> <div class="panel-full m-0 tab-content no-bg" id="tuner" role="tabpanel">
<h2>Tuner settings</h2> <h2>Tuner settings</h2>
<div class="flex-container contains-dropdown"> <div class="flex-container contains-dropdown">
@@ -408,13 +386,13 @@
</div> </div>
</div> </div>
<div class="panel-full m-0 tab-content no-bg" id="plugins" role="tabpanel"> <div class="panel-full m-0 tab-content no-bg" id="plugins-tab" role="tabpanel">
<h2>Plugins</h2> <h2>Plugins</h2>
<div class="panel-100 p-bottom-20"> <div class="panel-100 p-bottom-20">
<h3>Plugin list</h3> <h3>Plugin list</h3>
<p>Any compatible <strong>.js</strong> plugin, which is in the "plugins" folder, will be listed here.<br> <p>Any compatible <strong>.js</strong> plugin, which is in the "plugins" folder, will be listed here.<br>
Click on the individual plugins to enable/disable them.</p> Click on the individual plugins to enable/disable them.</p>
<select id="plugin-list" class="multiselect" multiple> <select id="plugins" class="multiselect" multiple>
<% plugins.forEach(function(plugin) { %> <% plugins.forEach(function(plugin) { %>
<option data-name="<%= plugin.frontEndPath %>" title="<%= plugin.name %> by <%= plugin.author %> [v<%= plugin.version %>]"> <option data-name="<%= plugin.frontEndPath %>" title="<%= plugin.name %> by <%= plugin.author %> [v<%= plugin.version %>]">
<%= plugin.name %> by <%= plugin.author %> [v<%= plugin.version %>] <%= plugin.name %> by <%= plugin.author %> [v<%= plugin.version %>]