Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling not available submodel(-descriptor) #73

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 47 additions & 30 deletions aas-web-ui/src/components/AASTreeview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
}
});
});
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion aas-web-ui/src/components/SubmodelElementView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 36 additions & 21 deletions aas-web-ui/src/components/SubmodelList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
}
}
});
});
Expand Down
24 changes: 24 additions & 0 deletions aas-web-ui/src/mixins/SubmodelElementHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
},
});