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
|
||||
}
|
||||
@@ -375,6 +375,60 @@
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Asset Identifiers Section -->
|
||||
<div class="section-card">
|
||||
<h2 class="section-title">Asset Identifiers</h2>
|
||||
|
||||
<div class="setting-group">
|
||||
<p class="setting-description">
|
||||
Enable or disable optional asset identifiers. When disabled, the identifier
|
||||
is hidden from asset forms and detail pages across the system.
|
||||
</p>
|
||||
|
||||
<div class="setting-row">
|
||||
<label class="toggle-label">
|
||||
<span>Gauge Lab Reference</span>
|
||||
<button
|
||||
class="toggle-btn"
|
||||
:class="{ active: settings.identifier_gaugelabreference_enabled }"
|
||||
@click="toggleSetting('identifier_gaugelabreference_enabled')"
|
||||
:disabled="saving"
|
||||
>
|
||||
<span class="toggle-slider"></span>
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<label class="toggle-label">
|
||||
<span>Maintenance Reference</span>
|
||||
<button
|
||||
class="toggle-btn"
|
||||
:class="{ active: settings.identifier_maintenancereference_enabled }"
|
||||
@click="toggleSetting('identifier_maintenancereference_enabled')"
|
||||
:disabled="saving"
|
||||
>
|
||||
<span class="toggle-slider"></span>
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="setting-row">
|
||||
<label class="toggle-label">
|
||||
<span>FQDN / Hostname</span>
|
||||
<button
|
||||
class="toggle-btn"
|
||||
:class="{ active: settings.identifier_fqdn_enabled }"
|
||||
@click="toggleSetting('identifier_fqdn_enabled')"
|
||||
:disabled="saving"
|
||||
>
|
||||
<span class="toggle-slider"></span>
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="error-message">{{ error }}</div>
|
||||
@@ -409,7 +463,11 @@ const settings = reactive({
|
||||
saml_acs_url: '',
|
||||
saml_allow_local_login: true,
|
||||
saml_auto_create_users: true,
|
||||
saml_admin_group: ''
|
||||
saml_admin_group: '',
|
||||
// Asset identifiers
|
||||
identifier_gaugelabreference_enabled: true,
|
||||
identifier_maintenancereference_enabled: true,
|
||||
identifier_fqdn_enabled: true
|
||||
})
|
||||
|
||||
const loading = ref(true)
|
||||
|
||||
Reference in New Issue
Block a user