diff --git a/bible-local/02-architecture.md b/bible-local/02-architecture.md index 19dac45..e6f693a 100644 --- a/bible-local/02-architecture.md +++ b/bible-local/02-architecture.md @@ -233,7 +233,9 @@ Rules: - sync runs in the background sync worker (after the pricelist pull) and in the manual full sync (`POST /api/sync/all`); failure is non-fatal (Warn log only); - `local_qt_settings` is a read-only cache — never written by user actions; -- absent or unparseable settings: QF uses hardcoded fallbacks for that key only; +- absent or unparseable settings: `GET /api/configurator-settings` serves the Go-side default for that + key only (`internal/handlers/component.go`); this is the single fallback — the configurator page + holds no copy of tabs/categories and builds its tab buttons from the served `tab_config`; - `config_types[].categories` is an allowlist: a category absent from all types is shown everywhere; - `qt_categories.name` and `qt_categories.name_ru` are not used by QF runtime; do not depend on them. diff --git a/bible-local/server-contract-qt-settings.md b/bible-local/server-contract-qt-settings.md index 2b272e8..3784a28 100644 --- a/bible-local/server-contract-qt-settings.md +++ b/bible-local/server-contract-qt-settings.md @@ -43,7 +43,7 @@ category codes that are allowed for each type. QF uses this for: "MB","CPU","MEM","RAID", "SSD","HDD","M2","EDSFF","HHHL", "GPU","NIC","HCA","DPU","HBA", - "PSU","PS","ACC","RISERS","CARD","BB" + "PSU","PS","ACC","RISERS","CARD","BB","SFP" ] }, { @@ -53,7 +53,7 @@ category codes that are allowed for each type. QF uses this for: "categories": [ "DKC","CPU","MEM","PS", "SSD","HDD","M2","EDSFF","HHHL", - "NIC","HBA","HCA","ACC","CARD" + "NIC","HBA","HCA","ACC","CARD","SFP" ] } ] @@ -109,7 +109,16 @@ single-select mode. ] }, { "key": "power", "label": "Power", "single_select": false, "categories": ["PS","PSU"] }, - { "key": "accessories", "label": "Accessories", "single_select": false, "categories": ["ACC","CARD"] }, + { + "key": "accessories", + "label": "Accessories", + "single_select": false, + "categories": ["ACC","CARD","SFP"], + "sections": [ + { "title": "Аксессуары", "categories": ["ACC","CARD"] }, + { "title": "Трансиверы", "categories": ["SFP"] } + ] + }, { "key": "sw", "label": "SW", "single_select": false, "categories": ["SW"] } ] ``` @@ -126,9 +135,15 @@ contain any items. Other tabs are hidden when empty. **Value format:** JSON string array. ```json -["base", "storage", "pci"] +["base"] ``` +"Empty" is evaluated after the per-`config_type` category filter, so with only +`base` listed a tab such as Storage/PCI shows for a server configuration (its +categories have components) and hides for a type whose allowlist excludes all of +its categories (e.g. networking). Listing a tab here forces it visible for every +config type. + --- ### `required_categories` @@ -200,10 +215,15 @@ current as the regulation evolves. ## Backward compatibility - If `qt_settings` does not exist (old server): QF logs `Warn` during sync and - leaves `local_qt_settings` empty. The frontend falls back to hardcoded defaults - for all four settings. No crash, no data loss. -- If a specific key is absent from `qt_settings`: QF falls back to the hardcoded - default for that key only. + leaves `local_qt_settings` empty. `GET /api/configurator-settings` then serves + the Go-side defaults (`internal/handlers/component.go`, `default*()`) for every + setting. No crash, no data loss. +- If a specific key is absent from `qt_settings`: the same Go-side default is served + for that key only. +- The Go-side defaults are the **only** fallback and are not kept in step with the + server — change tabs/categories in `qt_settings`, not in code. The configurator page + has no JS copy: `TAB_CONFIG` (except "Other") and the tab buttons are built from the + served `tab_config`; a config type with no `config_types` allowlist sees all categories. - Old QF clients that do not know about `local_qt_settings` continue to use their hardcoded JS constants unchanged. diff --git a/internal/handlers/component.go b/internal/handlers/component.go index aaecd1c..ad10100 100644 --- a/internal/handlers/component.go +++ b/internal/handlers/component.go @@ -118,6 +118,11 @@ func (h *ComponentHandler) GetCategories(c *gin.Context) { c.JSON(http.StatusOK, models.DefaultCategories) } +// GetConfiguratorSettings serves the synced qt_settings. The default*() values +// below are the only client-side fallback, used per key when the local cache has +// no such setting (e.g. before the first sync); they are not kept in step with +// the server — edit qt_settings in MariaDB, not these. The configurator page has +// no fallback of its own. func (h *ComponentHandler) GetConfiguratorSettings(c *gin.Context) { s, _ := h.localDB.GetConfiguratorSettings() if s == nil { @@ -131,7 +136,7 @@ func (h *ComponentHandler) GetConfiguratorSettings(c *gin.Context) { s.TabConfig = defaultTabConfig() } if len(s.AlwaysVisibleTabs) == 0 { - s.AlwaysVisibleTabs = []string{"base", "storage", "pci"} + s.AlwaysVisibleTabs = []string{"base"} } if len(s.RequiredCategories) == 0 { s.RequiredCategories = map[string][]string{"server": {"CPU", "MEM", "BB"}} diff --git a/web/templates/index.html b/web/templates/index.html index 4dcc8be..109e42d 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -103,34 +103,7 @@
@@ -431,48 +404,10 @@