diff --git a/aas-web-ui/src/components/AASTreeview.vue b/aas-web-ui/src/components/AASTreeview.vue index 7527717..7062e2c 100644 --- a/aas-web-ui/src/components/AASTreeview.vue +++ b/aas-web-ui/src/components/AASTreeview.vue @@ -219,43 +219,58 @@ if (!this.submodelRegistryURL.includes('/submodel-descriptors')) { this.submodelRegistryURL += '/submodel-descriptors'; } - let path = this.submodelRegistryURL + '/' + this.URLEncode(submodelRef.keys[0].value); + const submodelId = submodelRef.keys[0].value; + let path = this.submodelRegistryURL + '/' + this.URLEncode(submodelId); let context = 'retrieving Submodel Endpoint'; let disableMessage = false; return this.getRequest(path, context, disableMessage).then((response: any) => { if (response.success) { // execute if the Request was successful - const fetchedSubmodel = response.data; - // console.log('SubmodelEndpoint: ', submodelEndpoint); - const submodelHref = this.extractEndpointHref(fetchedSubmodel, 'SUBMODEL-3.0'); - let path = submodelHref; - let context = 'retrieving Submodel Data'; - let disableMessage = true; - return this.getRequest(path, context, disableMessage).then((response: any) => { - if (response.success) { - // execute if the Request was successful - let submodel = response.data; - // give the Submodel a unique ID - submodel.id = this.UUID(); - // set the active State of the Submodel - submodel.isActive = false; - // set the Path of the Submodel - submodel.path = path; - // check if submodel has SubmodelElements - if (submodel.submodelElements && submodel.submodelElements.length > 0) { - // recursively create treestructure for contained submodelElements - let submodelElements = this.prepareTreeviewData( - submodel.submodelElements, - submodel + if (response.data?.id) { + const fetchedSubmodel = response.data; + // console.log('SubmodelEndpoint: ', submodelEndpoint); + const submodelHref = this.extractEndpointHref(fetchedSubmodel, 'SUBMODEL-3.0'); + let path = submodelHref; + let context = 'retrieving Submodel Data'; + let disableMessage = true; + return this.getRequest(path, context, disableMessage).then((response: any) => { + if (response.success && response?.data?.id) { + // execute if the Request was successful + let submodel = response.data; + // give the Submodel a unique ID + submodel.id = this.UUID(); + // set the active State of the Submodel + submodel.isActive = false; + // set the Path of the Submodel + submodel.path = path; + // check if submodel has SubmodelElements + if (submodel.submodelElements && submodel.submodelElements.length > 0) { + // recursively create treestructure for contained submodelElements + let submodelElements = this.prepareTreeviewData( + submodel.submodelElements, + submodel + ); + // add the SubmodelElements to the Submodel + submodel.children = submodelElements; + // set showChildren to false (for the Treeview Component) + submodel.showChildren = false; + } + return submodel; + } else { + return this.smNotFound( + submodelId, + path, + "Submodel '" + submodelId + "' not found in SubmodelRepository" ); - // add the SubmodelElements to the Submodel - submodel.children = submodelElements; - // set showChildren to false (for the Treeview Component) - submodel.showChildren = false; } - return submodel; - } - }); + }); + } else { + return this.smNotFound( + submodelId, + path, + "Submodel '" + submodelId + "' not found in SubmodelRegistry" + ); + } } }); }); @@ -368,6 +383,8 @@ if (!foundNode) { foundNode = true; element.isActive = true; + this.aasStore.dispatchNode(element); + this.aasStore.dispatchRealTimeObject(element); } // if prop showChildren exists, set it to true if ('showChildren' in element) { diff --git a/aas-web-ui/src/components/SubmodelElementView.vue b/aas-web-ui/src/components/SubmodelElementView.vue index fb6bd6d..24cc24e 100644 --- a/aas-web-ui/src/components/SubmodelElementView.vue +++ b/aas-web-ui/src/components/SubmodelElementView.vue @@ -332,7 +332,7 @@ this.getRequest(path, context, disableMessage).then((response: any) => { // save Concept Descriptions before overwriting the SubmodelElement Data let conceptDescriptions = this.submodelElementData.conceptDescriptions; - if (response.success) { + if (response.success && (response.data?.id || response.data?.idShort)) { // execute if the Request was successful response.data.timestamp = this.formatDate(new Date()); // add timestamp to the SubmodelElement Data response.data.path = this.SelectedNode.path; // add the path to the SubmodelElement Data diff --git a/aas-web-ui/src/components/SubmodelList.vue b/aas-web-ui/src/components/SubmodelList.vue index e7f7b6b..3062daf 100644 --- a/aas-web-ui/src/components/SubmodelList.vue +++ b/aas-web-ui/src/components/SubmodelList.vue @@ -239,31 +239,46 @@ if (!submodelRegistryURL.includes('/submodel-descriptors')) { submodelRegistryURL += '/submodel-descriptors'; } - let path = submodelRegistryURL + '/' + this.URLEncode(submodelRef.keys[0].value); + const submodelId = submodelRef.keys[0].value; + let path = submodelRegistryURL + '/' + this.URLEncode(submodelId); let context = 'retrieving Submodel Endpoint'; let disableMessage = false; return this.getRequest(path, context, disableMessage).then((response: any) => { if (response.success) { - // execute if the Request was successful - const fetchedSubmodel = response.data; - // console.log('SubmodelEndpoint: ', submodelEndpoint); - const submodelHref = this.extractEndpointHref(fetchedSubmodel, 'SUBMODEL-3.0'); - let path = submodelHref; - let context = 'retrieving Submodel Data'; - let disableMessage = true; - return this.getRequest(path, context, disableMessage).then((response: any) => { - if (response.success) { - // execute if the Request was successful - let submodel = response.data; - // give the Submodel a unique ID - submodel.id = this.UUID(); - // set the active State of the Submodel - submodel.isActive = false; - // set the Path of the Submodel - submodel.path = path; - return submodel; - } - }); + if (response.data?.id) { + // execute if the Request was successful + const fetchedSubmodel = response.data; + // console.log('SubmodelEndpoint: ', submodelEndpoint); + const submodelHref = this.extractEndpointHref(fetchedSubmodel, 'SUBMODEL-3.0'); + let path = submodelHref; + let context = 'retrieving Submodel Data'; + let disableMessage = true; + return this.getRequest(path, context, disableMessage).then((response: any) => { + if (response.success && response?.data?.id) { + // execute if the Request was successful + let submodel = response.data; + // give the Submodel a unique ID + submodel.id = this.UUID(); + // set the active State of the Submodel + submodel.isActive = false; + // set the Path of the Submodel + submodel.path = path; + return submodel; + } else { + return this.smNotFound( + submodelId, + path, + "Submodel '" + submodelId + "' not found in SubmodelRepository" + ); + } + }); + } else { + return this.smNotFound( + submodelId, + path, + "Submodel '" + submodelId + "' not found in SubmodelRegistry" + ); + } } }); }); diff --git a/aas-web-ui/src/mixins/SubmodelElementHandling.ts b/aas-web-ui/src/mixins/SubmodelElementHandling.ts index 1f50e1c..466f245 100644 --- a/aas-web-ui/src/mixins/SubmodelElementHandling.ts +++ b/aas-web-ui/src/mixins/SubmodelElementHandling.ts @@ -646,5 +646,29 @@ export default defineComponent({ }); return endpoint?.protocolInformation?.href ? endpoint.protocolInformation.href : ''; }, + + smNotFound(submodelId: string, path: string, text: string): any { + if (text.trim().length > 0) { + this.navigationStore.dispatchSnackbar({ + status: true, + timeout: 60000, + color: 'error', + btnColor: 'buttonText', + text: text, + }); + } + const submodel = { + id: submodelId, + idShort: 'Submodel not found', + modelType: 'Submodel', + semanticId: null, + description: [], + displayName: [], + submodelElements: [], + isActive: false, + path: path, + }; + return submodel; + }, }, });