Add gauge lab + maintenance asset references with enable/disable toggles
Dedicated assets.gaugelabreference and assets.maintenancereference columns (distinct from assetnumber), surfaced on equipment. Add global per-identifier enable/disable settings (gauge/maintenance/FQDN) read via a shared composable and toggled in System Settings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
36
frontend/src/composables/identifierSettings.js
Normal file
36
frontend/src/composables/identifierSettings.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// Global enable/disable flags for optional asset identifiers, read from the
|
||||
// settings table. Loaded once and shared across components. Defaults to
|
||||
// enabled when a flag is missing so a fresh install shows the identifiers.
|
||||
import { reactive } from 'vue'
|
||||
import { settingsApi } from '../api'
|
||||
|
||||
const identifierflags = reactive({
|
||||
gaugelabreference: true,
|
||||
maintenancereference: true,
|
||||
fqdn: true,
|
||||
loaded: false
|
||||
})
|
||||
|
||||
let inflight = null
|
||||
|
||||
export function useIdentifierFlags() {
|
||||
if (!identifierflags.loaded && !inflight) {
|
||||
inflight = settingsApi.list()
|
||||
.then(({ data }) => {
|
||||
const map = {}
|
||||
;(data.data || []).forEach(s => { map[s.key] = s.value })
|
||||
if ('identifier_gaugelabreference_enabled' in map) {
|
||||
identifierflags.gaugelabreference = map.identifier_gaugelabreference_enabled !== false
|
||||
}
|
||||
if ('identifier_maintenancereference_enabled' in map) {
|
||||
identifierflags.maintenancereference = map.identifier_maintenancereference_enabled !== false
|
||||
}
|
||||
if ('identifier_fqdn_enabled' in map) {
|
||||
identifierflags.fqdn = map.identifier_fqdn_enabled !== false
|
||||
}
|
||||
identifierflags.loaded = true
|
||||
})
|
||||
.catch(() => { identifierflags.loaded = true })
|
||||
}
|
||||
return identifierflags
|
||||
}
|
||||
Reference in New Issue
Block a user