Bring the wilm branch into main: endpoints plugin, agent, policies, CSV import
Ports the corporate-GitHub wilm branch onto main, keeping the two branches
separate. Thirteen upstream commits arrive with their authorship intact; the
review fixes and the portability work below are on top.
What arrives:
endpoints plugin - a ShopDB agent reporting endpoint state, telemetry,
services and interfaces, with a command channel the agent
long-polls. Ingest stays on the generic collector route
(ADR-006); the agent key is a UI-managed single-scope
token whose revocation is an instant kill switch.
computers policies - Configuration and Business Policies (RMM-style), scope
trees validated at write time, actions checked against
the endpoints command allowlist. Feature-gated: every
route 404s while the setting is off, so enabling it can
never half-expose the surface.
asset CSV import - templates, a collector script carrying the site path, and
a validate-then-commit import. A plugin can own a virtual
column plus a post-write row hook, which is how a PC's
machine number becomes a controls link without a
hand-built relationships sheet.
agent/ - the Windows agent and its installer.
Contract 0.21.0 -> 0.24.0, additive throughout: register_import_hook (0.22),
mint/list/revoke_service_token (0.23), collector_authorized (0.24). The stability
table had no rows for any of them and now does.
MySQL 5.6 portability. The branch stored three policy columns as sa.JSON, the
only JSON columns in the product, and 5.6 has no JSON type: the migration failed
with a bare syntax error near the word JSON. They are TEXT now, through a
JSONText type decorator, so all seventeen call sites still read and write dicts.
The convention elsewhere is already TEXT (guides.blocksjson,
geenforce.manifestjson).
Review fixes carried on top:
- six policy GETs were jwt_required(optional=True), which authenticates a
caller without checking anything; they require computers.view now, and six
redundant jwt_required decorators are gone
- the agent installer took a default BaseUrl and CollectorKey, so a mistyped
run silently pointed an endpoint at the wrong instance; both are mandatory
and a non-https BaseUrl throws unless -AllowInsecureHttp is passed
- a committing CSV import wrote no audit row
Documentation: the 34 new routes are described in docs/api-inventory.json, which
is hand-maintained on purpose, and the generated spec now covers 331 paths and
477 operations across 22 surfaces. DEVELOPMENT-SETUP's 1071 troubleshooting row
said "use MySQL 8 for dev" and now gives the actual fix, including the trap that
5.6 downgrades ROW_FORMAT=DYNAMIC to Compact with a warning instead of an error.
Full suite 2123 passed, vitest 260 passed, all seventeen plugin chains migrate
clean on MySQL 5.6 and the naming, docs, parity and read-surface gates are green.
This commit is contained in:
@@ -123,7 +123,7 @@
|
||||
>
|
||||
<option value="">Select vendor...</option>
|
||||
<option
|
||||
v-for="v in vendors"
|
||||
v-for="v in filteredVendors"
|
||||
:key="v.vendorid"
|
||||
:value="v.vendorid"
|
||||
>
|
||||
@@ -168,7 +168,7 @@
|
||||
>
|
||||
<option value="">Select vendor...</option>
|
||||
<option
|
||||
v-for="v in vendors"
|
||||
v-for="v in filteredControllerVendors"
|
||||
:key="v.vendorid"
|
||||
:value="v.vendorid"
|
||||
>
|
||||
@@ -446,16 +446,67 @@ const existingRelationshipId = ref(null)
|
||||
const loadedControllingPcId = ref(null)
|
||||
const currentMachine = ref(null)
|
||||
|
||||
// Filter models by selected machine vendor
|
||||
// Ensure a saved model id is present in models.value even when the filtered
|
||||
// list (category Equipment) excluded it because it has no modeltype. Fetches
|
||||
// the single row by id and appends it; a no-op when already present or blank.
|
||||
async function ensureModelLoaded(modelId) {
|
||||
if (!modelId) return
|
||||
if (models.value.some(m => m.modelnumberid === modelId)) return
|
||||
try {
|
||||
const response = await modelsApi.get(modelId)
|
||||
const model = response.data.data
|
||||
if (model) models.value = [...models.value, model]
|
||||
} catch (e) {
|
||||
// Leave it absent; the select shows blank but we did not invent a value.
|
||||
}
|
||||
}
|
||||
|
||||
// Filter models by selected machine vendor.
|
||||
// only in the controller dropdown, so keep them out of the machine list. Keep
|
||||
// the record's own saved model even if it is untyped or a different vendor, so
|
||||
// editing a machine never renders a blank select that clears the field on save.
|
||||
const filteredModels = computed(() => {
|
||||
if (!form.value.vendorid) return models.value
|
||||
return models.value.filter(m => m.vendorid === form.value.vendorid)
|
||||
const savedId = form.value.modelnumberid
|
||||
const machineModels = models.value.filter(
|
||||
m => m.modeltype !== 'Controller' || m.modelnumberid === savedId)
|
||||
if (!form.value.vendorid) return machineModels
|
||||
return machineModels.filter(
|
||||
m => m.vendorid === form.value.vendorid || m.modelnumberid === savedId)
|
||||
})
|
||||
|
||||
// Filter models by selected controller vendor
|
||||
// Filter models by selected controller vendor. Only Controller-type models are
|
||||
// valid here. Keep the record's own saved controller model even if it is untyped
|
||||
// or a different vendor, for the same reason as filteredModels above.
|
||||
const filteredControllerModels = computed(() => {
|
||||
if (!form.value.controllervendorid) return models.value
|
||||
return models.value.filter(m => m.vendorid === form.value.controllervendorid)
|
||||
const savedId = form.value.controllermodelid
|
||||
const controllerModels = models.value.filter(
|
||||
m => m.modeltype === 'Controller' || m.modelnumberid === savedId)
|
||||
if (!form.value.controllervendorid) return controllerModels
|
||||
return controllerModels.filter(
|
||||
m => m.vendorid === form.value.controllervendorid || m.modelnumberid === savedId)
|
||||
})
|
||||
|
||||
// Only offer vendors that have machine (non-controller Equipment) models. Keep
|
||||
// the record's own vendor even if it falls outside that set, so editing an
|
||||
// existing machine never silently drops its saved vendor.
|
||||
const filteredVendors = computed(() => {
|
||||
const machineVendorIds = new Set(
|
||||
models.value.filter(m => m.modeltype !== 'Controller').map(m => m.vendorid)
|
||||
)
|
||||
return vendors.value.filter(
|
||||
v => machineVendorIds.has(v.vendorid) || v.vendorid === form.value.vendorid
|
||||
)
|
||||
})
|
||||
|
||||
// Only offer controller vendors that have Controller-type models. Keep the
|
||||
// record's own controller vendor even if it falls outside that set.
|
||||
const filteredControllerVendors = computed(() => {
|
||||
const controllerVendorIds = new Set(
|
||||
models.value.filter(m => m.modeltype === 'Controller').map(m => m.vendorid)
|
||||
)
|
||||
return vendors.value.filter(
|
||||
v => controllerVendorIds.has(v.vendorid) || v.vendorid === form.value.controllervendorid
|
||||
)
|
||||
})
|
||||
|
||||
// Clear model selection when vendor changes
|
||||
@@ -485,8 +536,8 @@ onMounted(async () => {
|
||||
machinesApi.types.list(),
|
||||
assetsApi.statuses.list(),
|
||||
vendorsApi.list({ perpage: 500 }),
|
||||
locationsApi.list({ perpage: 500 }),
|
||||
modelsApi.listAll(), // backend caps perpage at 100; page through all
|
||||
locationsApi.listAll(), // backend caps perpage at 100; page through all
|
||||
modelsApi.listAll({ category: 'Equipment' }), // backend caps perpage at 100; page through all
|
||||
businessunitsApi.list({ perpage: 500 }),
|
||||
computersApi.listAll(), // backend caps perpage at 100; page through all
|
||||
assetsApi.types.list() // Used for relationship types, will fix below
|
||||
@@ -495,7 +546,7 @@ onMounted(async () => {
|
||||
machineTypes.value = typesRes.data.data || []
|
||||
statuses.value = statusRes.data.data || []
|
||||
vendors.value = vendorRes.data.data || []
|
||||
locations.value = locRes.data.data || []
|
||||
locations.value = locRes || []
|
||||
models.value = allModels
|
||||
businessunits.value = buRes.data.data || []
|
||||
// listAll resolves to the ARRAY, not a response: fetchAllPages already
|
||||
@@ -568,6 +619,14 @@ onMounted(async () => {
|
||||
levelid: data.levelid ?? null,
|
||||
}
|
||||
|
||||
// The model list is loaded filtered to category Equipment, which the
|
||||
// backend inner-joins against ModelType - so a model with no modeltype is
|
||||
// absent from models.value. If this machine's saved model or controller
|
||||
// model is one of those untyped rows, fetch it by id and merge it in, or
|
||||
// its dropdown would render blank and saving would clear the field.
|
||||
await ensureModelLoaded(form.value.modelnumberid)
|
||||
await ensureModelLoaded(form.value.controllermodelid)
|
||||
|
||||
// Load existing relationships to find controlling PC
|
||||
if (data.assetid) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user