Merge claude/2

This commit is contained in:
librelad 2026-05-22 23:46:12 +01:00
commit 4078ad5092
2 changed files with 33 additions and 46 deletions

View File

@ -997,72 +997,52 @@ class AppsManager {
let tabsHTML = '';
let contentHTML = '';
let firstTab = null;
// Sort categories by order
const sortedCategories = Object.entries(categories)
.sort(([,a], [,b]) => a.order - b.order);
// Find first tab with fields
// Render each category's fields up front and keep only the ones that
// actually produced fields. A "hasFields" heuristic used to gate the tabs
// separately, but it drifted from what generateConfigFields really emits —
// so a category like Network could pass the check yet render empty, leaving
// a blank tab whose body just reads "No configuration options available".
// Trusting the rendered output keeps tabs and content in lockstep.
const renderedCategories = [];
for (const [key, category] of sortedCategories) {
const hasFields = Object.entries(fieldMappings).some(([fieldKey, fieldConfig]) => {
if (fieldConfig.category === key) {
const cfgKey = this.findMatchingCFGKey(fieldKey, appConfig);
return cfgKey && appConfig.hasOwnProperty(cfgKey);
}
return false;
});
if (hasFields) {
firstTab = key;
break;
}
const content = await this.generateConfigFields(key, appData);
if (!content || content.includes('class="no-fields"')) continue;
renderedCategories.push({ key, category, content });
}
// Use preferred category if available and valid, otherwise use firstTab
const activeTab = preferredCategory && categories[preferredCategory] ? preferredCategory : firstTab;
// Use the preferred category if it's one that has fields, else the first.
const activeTab = (preferredCategory && renderedCategories.some(c => c.key === preferredCategory))
? preferredCategory
: (renderedCategories[0] ? renderedCategories[0].key : null);
// Generate tabs and content together
for (const [key, category] of sortedCategories) {
const hasFields = Object.entries(fieldMappings).some(([fieldKey, fieldConfig]) => {
if (fieldConfig.category === key) {
const cfgKey = this.findMatchingCFGKey(fieldKey, appConfig);
return cfgKey && appConfig.hasOwnProperty(cfgKey);
}
return false;
});
for (const { key, category, content } of renderedCategories) {
const isActive = key === activeTab ? 'active' : '';
if (hasFields) {
const isActive = key === activeTab ? 'active' : '';
// Generate tab button
tabsHTML += `
tabsHTML += `
<button class="tab-button ${isActive}" data-tab="${key}" onclick="appsManager.showTab('${key}')">
<span class="tab-emoji">${category.icon}</span>
<span class="tab-name">${category.name}</span>
</button>
`;
// Generate content panel
//// // console.log(`🔧 Generating content for category: ${key}`);
const categoryContent = await this.generateConfigFields(key, appData);
contentHTML += `
contentHTML += `
<div class="tab-panel ${isActive}" id="panel-${key}">
<div class="panel-header">
<h4>${category.icon} ${category.name}</h4>
<p>${category.description}</p>
</div>
<div class="panel-fields app-config">
${categoryContent}
${content}
</div>
</div>
`;
}
}
//// // console.log('✅ Tabs and content generated successfully');
return { tabsHTML, contentHTML };
}

View File

@ -5,6 +5,13 @@ class ConfigUtils {
}
formatSubcategoryName(subcategoryName) {
// Display-name overrides where the derived title isn't specific enough.
// The underlying file/key names (e.g. backup_advanced, CFG_BACKUP_*) are
// untouched, so saved values are unaffected.
const overrides = {
backup_advanced: 'Engine'
};
if (overrides[subcategoryName]) return overrides[subcategoryName];
return subcategoryName.replace(/_/g, ' ').replace(/\b\w/g, function(l) { return l.toUpperCase(); });
}