Ports 37 of Benjamin Baker's commits from the wilm branch, mirrored from the
corporate GitHub at 7905917c. wilm rides the publication lineage and shares no
ancestor with wj, so this is a filtered tree patch rather than a merge:
94 files, and every path the publication export strips (docs/, tools/, mcp/,
CLAUDE.md, start-*.sh, .gitea/, the three excluded tests) is held back, because
a raw diff would delete each of them from this tree.
What comes across:
* Endpoint telemetry, phase 2. Physical disk health from two sources, NIC link
state, boot type, Defender health, processor/memory/chassis inventory, the
listening TCP set, mapped network drives and Windows Update history. Five
additive migrations, 0012 through 0016, off the 0011 head.
* Mapped drives are collected by a probe running in the interactive user's
session, because they do not exist in the agent's session 0. Two Windows
sources can disagree about one drive and the worse status wins, so a
half-broken share is never rendered as healthy.
* Windows events are reported once each, keyed on the channel's own record id,
instead of being re-sent whenever a report overlapped the last one.
* PC Detail rework: Details cards flow, the hand-written Network card gives way
to a full address history, Storage and disk health merge into one card with
two sections, Operator Reports and Corporate Tools get their own tabs.
* An opt-in restic backup overlay with a third container, restore gated on the
dump's own data revision rather than the code head, and backup/restore history.
* The agent's version is read from the binary's PE version rather than trusted
from the csproj, and the Fleet view gains an Agent Version column.
* The enqueue route now asks caller_holds instead of the owner's permissions,
which closes the scoped-token elevation on run_script, update_app and
system_restart.
Held back deliberately:
* agent/installer/install-shopdbagent.ps1 stays deleted, as upstream deleted it.
The installer that reaches a bay is generated by _install_script() in
plugins/endpoints/api/siteagent.py; the standalone script had stopped being
shipped and was collecting fixes no endpoint ever ran.
* The .gitignore hunk adding docs/*.md. Correct on the publication lineage,
where docs/ becomes the wiki and its absence is how the gates detect a
published checkout. Here it would silently ignore every new doc.
* Their deletions of docs/DEV-BUILD-TEST.md and docs/PLUGIN-HOOKS.md. Upstream
those were stubs; here PLUGIN-HOOKS.md is the 31KB document CLAUDE.md points
readers at.
* Five zero-byte files committed by an accidental `git add -A`, a run log from
the author's own machine, and docs/notes/, which is working scratch that says
so in its own header and belongs in devnotes/ on this side.
Carried with the import so it lands green: the 17 new routes are described in
docs/api-inventory.json with the spec and project map regenerated, and two new
frontend specs read fixtures through fileURLToPath(URL) which node rejects under
jsdom's own URL global.
Suite 2591 passed / 9 skipped; frontend 391 passed; naming, style and doc gates
clean.
Scope: product
299 lines
11 KiB
Vue
299 lines
11 KiB
Vue
<template>
|
|
<div>
|
|
<div class="page-header">
|
|
<h2>{{ isEdit ? 'Edit Measuring Tool' : 'New Measuring Tool' }}</h2>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div v-if="loading" class="loading">Loading...</div>
|
|
|
|
<form v-else @submit.prevent="saveTool">
|
|
<!-- Identity Section -->
|
|
<h3 class="form-section-title">Identity</h3>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="assetnumber">Asset Number (Gage Tag) *</label>
|
|
<input id="assetnumber" v-model="form.assetnumber" type="text" class="form-control" required />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="name">Name / Alias</label>
|
|
<input id="name" v-model="form.name" type="text" class="form-control" />
|
|
<small class="form-help">Layperson-friendly label</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="serialnumber">Serial Number (vendor)</label>
|
|
<input id="serialnumber" v-model="form.serialnumber" type="text" class="form-control" />
|
|
</div>
|
|
<div class="form-group" v-if="isEnabled('gaugelabreference', 'measuring_tool')">
|
|
<label for="gaugelabreference">Gauge Lab Reference</label>
|
|
<input id="gaugelabreference" v-model="form.gaugelabreference" type="text" class="form-control" />
|
|
<small class="form-help">Authoritative gauge lab asset reference (if tracked)</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row" v-if="isEnabled('maintenancereference', 'measuring_tool')">
|
|
<div class="form-group">
|
|
<label for="maintenancereference">Maintenance Reference</label>
|
|
<input id="maintenancereference" v-model="form.maintenancereference" type="text" class="form-control" />
|
|
<small class="form-help">Maintenance system asset reference (if tracked)</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="measuringtooltypeid">Type</label>
|
|
<select id="measuringtooltypeid" v-model="form.measuringtooltypeid" class="form-control">
|
|
<option value="">Select type...</option>
|
|
<option v-for="t in types" :key="t.measuringtooltypeid" :value="t.measuringtooltypeid">
|
|
{{ t.name }}
|
|
</option>
|
|
</select>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="statusid">Status</label>
|
|
<select id="statusid" v-model="form.statusid" class="form-control">
|
|
<option value="">Select status...</option>
|
|
<option v-for="s in statuses" :key="s.statusid" :value="s.statusid">{{ s.status }}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Calibration Section -->
|
|
<h3 class="form-section-title">Calibration</h3>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="lastcalibrationdate">Last Calibration</label>
|
|
<input id="lastcalibrationdate" v-model="form.lastcalibrationdate" type="date" class="form-control" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="nextcalibrationdate">Next Calibration</label>
|
|
<input id="nextcalibrationdate" v-model="form.nextcalibrationdate" type="date" class="form-control" />
|
|
<small class="form-help">Drives the derived calibration status (overdue / due soon / current)</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="calibrationintervaldays">Interval (days)</label>
|
|
<input id="calibrationintervaldays" v-model.number="form.calibrationintervaldays" type="number" min="0" class="form-control" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="calibrationprovider">Calibration Provider</label>
|
|
<input id="calibrationprovider" v-model="form.calibrationprovider" type="text" class="form-control" />
|
|
<small class="form-help">Lab or in-house team that performs the calibration</small>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Location Section -->
|
|
<h3 class="form-section-title">Location & Organization</h3>
|
|
<div class="form-row">
|
|
<div class="form-group">
|
|
<label for="locationid">Location</label>
|
|
<select id="locationid" v-model="form.locationid" class="form-control">
|
|
<option value="">Select location...</option>
|
|
<option v-for="l in locations" :key="l.locationid" :value="l.locationid">{{ l.locationname }}</option>
|
|
</select>
|
|
<small class="form-help">Operation locations (e.g. "0615 Blisk Inspection") hold measuring tools</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="businessunitid">Business Unit</label>
|
|
<select id="businessunitid" v-model="form.businessunitid" class="form-control">
|
|
<option value="">Select business unit...</option>
|
|
<option v-for="bu in businessunits" :key="bu.businessunitid" :value="bu.businessunitid">{{ bu.businessunit }}</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Notes Section -->
|
|
<h3 class="form-section-title">Notes</h3>
|
|
<div class="form-group">
|
|
<textarea id="notes" v-model="form.notes" class="form-control" rows="3" placeholder="Additional notes..."></textarea>
|
|
</div>
|
|
|
|
<!-- Site-defined custom fields for measuring tools -->
|
|
<CustomFieldsInputs ref="customFieldsRef" :assettypeid="assettypeid" :assetid="currentAssetId" />
|
|
|
|
<div v-if="error" class="error-message">{{ error }}</div>
|
|
|
|
<div style="display: flex; gap: 0.5rem; margin-top: 1.5rem;">
|
|
<button type="submit" class="btn btn-primary" :disabled="saving">
|
|
{{ saving ? 'Saving...' : 'Save Measuring Tool' }}
|
|
</button>
|
|
<router-link to="/measuringtools" class="btn btn-secondary">Cancel</router-link>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, onMounted, computed } from 'vue'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { measuringtoolsApi, assetsApi, locationsApi, businessunitsApi } from '@/api'
|
|
import CustomFieldsInputs from '@/components/CustomFieldsInputs.vue'
|
|
import { useIdentifierFlags } from '@/composables/identifierSettings'
|
|
import { apiError } from '@/utils/apiError'
|
|
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
|
|
const { isEnabled } = useIdentifierFlags()
|
|
|
|
const isEdit = computed(() => !!route.params.id)
|
|
|
|
// Resolved dynamically from /api/assets/types (no hardcoded id) so custom
|
|
// fields load for the measuring_tool asset type.
|
|
const assettypeid = ref(null)
|
|
const customFieldsRef = ref(null)
|
|
const currentAssetId = ref(null)
|
|
|
|
const loading = ref(true)
|
|
const saving = ref(false)
|
|
const error = ref('')
|
|
|
|
const form = ref({
|
|
assetnumber: '',
|
|
name: '',
|
|
gaugelabreference: '',
|
|
maintenancereference: '',
|
|
serialnumber: '',
|
|
statusid: '',
|
|
measuringtooltypeid: '',
|
|
lastcalibrationdate: '',
|
|
nextcalibrationdate: '',
|
|
calibrationintervaldays: null,
|
|
calibrationprovider: '',
|
|
locationid: '',
|
|
businessunitid: '',
|
|
notes: '',
|
|
})
|
|
|
|
const types = ref([])
|
|
const statuses = ref([])
|
|
const locations = ref([])
|
|
const businessunits = ref([])
|
|
|
|
onMounted(async () => {
|
|
try {
|
|
const [typesResponse, statusResponse, locResponse, buResponse, assetTypesResponse] = await Promise.all([
|
|
measuringtoolsApi.types.list({ perpage: 100 }),
|
|
assetsApi.statuses.list(),
|
|
locationsApi.listAll(), // backend caps perpage at 100; page through all
|
|
businessunitsApi.listAll(),
|
|
assetsApi.types.list(),
|
|
])
|
|
types.value = typesResponse.data.data || []
|
|
statuses.value = statusResponse.data.data || []
|
|
// listAll resolves to the ARRAY, not a response: fetchAllPages already
|
|
// unwrapped every page. Reading .data.data off it throws and takes the
|
|
// whole parallel load into the catch.
|
|
locations.value = locResponse || []
|
|
businessunits.value = buResponse || []
|
|
|
|
const assetType = (assetTypesResponse.data.data || []).find(a => a.assettype === 'measuring_tool')
|
|
assettypeid.value = assetType ? assetType.assettypeid : null
|
|
|
|
if (isEdit.value) {
|
|
const response = await measuringtoolsApi.get(route.params.id)
|
|
const data = response.data.data
|
|
currentAssetId.value = data.assetid || null
|
|
const ext = data.measuringtool || {}
|
|
form.value = {
|
|
assetnumber: data.assetnumber || '',
|
|
name: data.name || '',
|
|
gaugelabreference: data.gaugelabreference || '',
|
|
maintenancereference: data.maintenancereference || '',
|
|
serialnumber: data.serialnumber || '',
|
|
statusid: data.statusid || '',
|
|
measuringtooltypeid: ext.measuringtooltypeid || '',
|
|
lastcalibrationdate: ext.lastcalibrationdate || '',
|
|
nextcalibrationdate: ext.nextcalibrationdate || '',
|
|
calibrationintervaldays: ext.calibrationintervaldays ?? null,
|
|
calibrationprovider: ext.calibrationprovider || '',
|
|
locationid: data.locationid || '',
|
|
businessunitid: data.businessunitid || '',
|
|
notes: data.notes || '',
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.error('Error loading data:', err)
|
|
error.value = 'Failed to load data'
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
})
|
|
|
|
async function saveTool() {
|
|
error.value = ''
|
|
saving.value = true
|
|
try {
|
|
const data = {
|
|
assetnumber: form.value.assetnumber,
|
|
name: form.value.name || null,
|
|
gaugelabreference: form.value.gaugelabreference || null,
|
|
maintenancereference: form.value.maintenancereference || null,
|
|
serialnumber: form.value.serialnumber || null,
|
|
statusid: form.value.statusid || null,
|
|
measuringtooltypeid: form.value.measuringtooltypeid || null,
|
|
lastcalibrationdate: form.value.lastcalibrationdate || null,
|
|
nextcalibrationdate: form.value.nextcalibrationdate || null,
|
|
calibrationintervaldays: form.value.calibrationintervaldays ?? null,
|
|
calibrationprovider: form.value.calibrationprovider || null,
|
|
locationid: form.value.locationid || null,
|
|
businessunitid: form.value.businessunitid || null,
|
|
notes: form.value.notes || null,
|
|
}
|
|
|
|
let saved
|
|
if (isEdit.value) {
|
|
const response = await measuringtoolsApi.update(route.params.id, data)
|
|
saved = response.data.data
|
|
} else {
|
|
const response = await measuringtoolsApi.create(data)
|
|
saved = response.data.data
|
|
}
|
|
|
|
const assetId = saved.assetid
|
|
if (assetId && customFieldsRef.value) {
|
|
try {
|
|
await customFieldsRef.value.save(assetId)
|
|
} catch (customFieldsErr) {
|
|
console.error('Error saving custom fields:', customFieldsErr)
|
|
}
|
|
}
|
|
|
|
router.push(`/measuringtools/${saved.measuringtool?.measuringtoolid || route.params.id}`)
|
|
} catch (err) {
|
|
console.error('Error saving measuring tool:', err)
|
|
error.value = apiError(err, 'Failed to save measuring tool')
|
|
} finally {
|
|
saving.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.form-section-title {
|
|
font-size: 1rem;
|
|
font-weight: 600;
|
|
color: var(--text);
|
|
margin: 1.5rem 0 0.75rem 0;
|
|
padding-bottom: 0.5rem;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
|
|
.form-section-title:first-of-type {
|
|
margin-top: 0;
|
|
}
|
|
|
|
.form-help {
|
|
display: block;
|
|
margin-top: 0.25rem;
|
|
font-size: 0.8rem;
|
|
color: var(--text-light);
|
|
}
|
|
</style>
|