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)
|
||||
|
||||
44
migrations/versions/7b02_gaugelabreference.py
Normal file
44
migrations/versions/7b02_gaugelabreference.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""Add Asset.gaugelabreference and Asset.maintenancereference
|
||||
|
||||
Adds dedicated external-reference columns to assets, distinct from
|
||||
assetnumber. Equipment commonly carries an authoritative gauge lab reference
|
||||
and a maintenance system reference; assetnumber stays the generic asset tag
|
||||
and name the layperson label.
|
||||
|
||||
Revision ID: 7b02_gaugelabref
|
||||
Revises: 7a01_adr001_position
|
||||
Create Date: 2026-06-25
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '7b02_gaugelabref'
|
||||
down_revision = '7a01_adr001_position'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
with op.batch_alter_table('assets') as batch_op:
|
||||
batch_op.add_column(sa.Column(
|
||||
'gaugelabreference', sa.String(length=50), nullable=True,
|
||||
comment='Gauge lab asset reference (authoritative tag the gauge '
|
||||
'lab assigns to equipment); distinct from assetnumber'))
|
||||
batch_op.add_column(sa.Column(
|
||||
'maintenancereference', sa.String(length=50), nullable=True,
|
||||
comment='Maintenance system asset reference; distinct from '
|
||||
'assetnumber'))
|
||||
batch_op.create_index('ix_assets_gaugelabreference',
|
||||
['gaugelabreference'])
|
||||
batch_op.create_index('ix_assets_maintenancereference',
|
||||
['maintenancereference'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
with op.batch_alter_table('assets') as batch_op:
|
||||
batch_op.drop_index('ix_assets_maintenancereference')
|
||||
batch_op.drop_index('ix_assets_gaugelabreference')
|
||||
batch_op.drop_column('maintenancereference')
|
||||
batch_op.drop_column('gaugelabreference')
|
||||
@@ -134,6 +134,28 @@ def create_setting():
|
||||
def seed_default_settings():
|
||||
"""Seed default settings if they don't exist."""
|
||||
defaults = [
|
||||
# Asset identifier feature toggles (global, per identifier)
|
||||
{
|
||||
'key': 'identifier_gaugelabreference_enabled',
|
||||
'value': 'true',
|
||||
'valuetype': 'boolean',
|
||||
'category': 'identifiers',
|
||||
'description': 'Show the Gauge Lab Reference identifier on assets'
|
||||
},
|
||||
{
|
||||
'key': 'identifier_maintenancereference_enabled',
|
||||
'value': 'true',
|
||||
'valuetype': 'boolean',
|
||||
'category': 'identifiers',
|
||||
'description': 'Show the Maintenance Reference identifier on assets'
|
||||
},
|
||||
{
|
||||
'key': 'identifier_fqdn_enabled',
|
||||
'value': 'true',
|
||||
'valuetype': 'boolean',
|
||||
'category': 'identifiers',
|
||||
'description': 'Show the FQDN / hostname identifier on assets'
|
||||
},
|
||||
# Zabbix integration
|
||||
{
|
||||
'key': 'zabbix_enabled',
|
||||
|
||||
@@ -74,6 +74,17 @@ class Asset(BaseModel, SoftDeleteMixin, AuditMixin):
|
||||
db.String(100),
|
||||
comment='Display name/alias'
|
||||
)
|
||||
gaugelabreference = db.Column(
|
||||
db.String(50),
|
||||
index=True,
|
||||
comment='Gauge lab asset reference (authoritative tag the gauge lab '
|
||||
'assigns to equipment); distinct from assetnumber'
|
||||
)
|
||||
maintenancereference = db.Column(
|
||||
db.String(50),
|
||||
index=True,
|
||||
comment='Maintenance system asset reference; distinct from assetnumber'
|
||||
)
|
||||
serialnumber = db.Column(
|
||||
db.String(100),
|
||||
index=True,
|
||||
|
||||
Reference in New Issue
Block a user