updates for asset registration
This commit is contained in:
@@ -221,11 +221,50 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"assetRegistration": {
|
"assetRegistration": {
|
||||||
"profileId": 1,
|
"default": {
|
||||||
"locationId": 1,
|
"profileId": 1,
|
||||||
"processId": 1,
|
"locationId": 1,
|
||||||
"status": "actief",
|
"processId": 1,
|
||||||
"childAssets": []
|
"status": "actief",
|
||||||
|
"childAssets": []
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"type": "object",
|
||||||
|
"schema": {
|
||||||
|
"profileId": {
|
||||||
|
"default": 1,
|
||||||
|
"rules": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"locationId": {
|
||||||
|
"default": 1,
|
||||||
|
"rules": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"processId": {
|
||||||
|
"default": 1,
|
||||||
|
"rules": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
"default": "actief",
|
||||||
|
"rules": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"childAssets": {
|
||||||
|
"default": [],
|
||||||
|
"rules": {
|
||||||
|
"type": "array",
|
||||||
|
"itemType": "string",
|
||||||
|
"minLength": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"scaling": {
|
"scaling": {
|
||||||
"enabled": {
|
"enabled": {
|
||||||
|
|||||||
@@ -459,6 +459,10 @@ class AssetMenu {
|
|||||||
const normalized = tag ? tag.toString() : '';
|
const normalized = tag ? tag.toString() : '';
|
||||||
const input = document.getElementById('node-input-assetTagNumber');
|
const input = document.getElementById('node-input-assetTagNumber');
|
||||||
const hint = document.getElementById('node-input-assetTagNumber-hint');
|
const hint = document.getElementById('node-input-assetTagNumber-hint');
|
||||||
|
console.info('[AssetMenu] tag number update', {
|
||||||
|
nodeId: node && node.id ? node.id : null,
|
||||||
|
tag: normalized
|
||||||
|
});
|
||||||
if (input) {
|
if (input) {
|
||||||
input.value = normalized;
|
input.value = normalized;
|
||||||
}
|
}
|
||||||
@@ -475,8 +479,14 @@ class AssetMenu {
|
|||||||
const candidateTag = tagInput && tagInput.value ? tagInput.value.trim() : '';
|
const candidateTag = tagInput && tagInput.value ? tagInput.value.trim() : '';
|
||||||
const fallbackTag = node && node.assetTagNumber ? node.assetTagNumber : '';
|
const fallbackTag = node && node.assetTagNumber ? node.assetTagNumber : '';
|
||||||
const registrationDefaults =
|
const registrationDefaults =
|
||||||
(window.EVOLV.nodes.${nodeName}.config && window.EVOLV.nodes.${nodeName}.config.assetRegistration) || {};
|
(window.EVOLV.nodes.${nodeName}.config && window.EVOLV.nodes.${nodeName}.config.assetRegistration && window.EVOLV.nodes.${nodeName}.config.assetRegistration.default) || {};
|
||||||
const displayName = node && node.name ? node.name : node && node.id ? node.id : '${nodeName}';
|
const displayName = node && node.name ? node.name : node && node.id ? node.id : '${nodeName}';
|
||||||
|
console.info('[AssetMenu] build sync payload', {
|
||||||
|
nodeId: node && node.id ? node.id : null,
|
||||||
|
candidateTag,
|
||||||
|
fallbackTag,
|
||||||
|
status: registrationDefaults.status || 'actief'
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
asset: {
|
asset: {
|
||||||
tagNumber: candidateTag || fallbackTag,
|
tagNumber: candidateTag || fallbackTag,
|
||||||
@@ -501,6 +511,11 @@ class AssetMenu {
|
|||||||
const trimmedRoot = adminRoot && adminRoot.endsWith('/') ? adminRoot.slice(0, -1) : adminRoot || '';
|
const trimmedRoot = adminRoot && adminRoot.endsWith('/') ? adminRoot.slice(0, -1) : adminRoot || '';
|
||||||
const prefix = trimmedRoot || '';
|
const prefix = trimmedRoot || '';
|
||||||
const endpoint = (prefix || '') + '/${nodeName}/asset-reg';
|
const endpoint = (prefix || '') + '/${nodeName}/asset-reg';
|
||||||
|
console.info('[AssetMenu] sync request', {
|
||||||
|
endpoint,
|
||||||
|
nodeId: node && node.id ? node.id : null,
|
||||||
|
tagNumber: payload && payload.asset ? payload.asset.tagNumber : null
|
||||||
|
});
|
||||||
fetch(endpoint, {
|
fetch(endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
@@ -513,6 +528,7 @@ class AssetMenu {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
|
console.info('[AssetMenu] sync response', result);
|
||||||
if (result && result.success) {
|
if (result && result.success) {
|
||||||
const newTag = (result.data && result.data.asset_tag_number) || payload.asset.tagNumber || '';
|
const newTag = (result.data && result.data.asset_tag_number) || payload.asset.tagNumber || '';
|
||||||
this.setAssetTagNumber(node, newTag);
|
this.setAssetTagNumber(node, newTag);
|
||||||
|
|||||||
Reference in New Issue
Block a user