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 of multiple Concept Descriptions #138

Merged
merged 14 commits into from
Jun 3, 2024
Merged
35 changes: 19 additions & 16 deletions aas-gui/Frontend/aas-web-gui/src/components/SubmodelElementView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@
<AnnotatedRelationshipElement v-else-if="submodelElementData.modelType === 'AnnotatedRelationshipElement'" :annotatedRelationshipElementObject="submodelElementData"></AnnotatedRelationshipElement>
<InvalidElement v-else :invalidElementObject="submodelElementData"></InvalidElement>
</v-list>
<!-- ConceptDescription -->
<v-divider v-if="submodelElementData.conceptDescription" class="mt-5"></v-divider>
<v-list nav v-if="submodelElementData.conceptDescription">
<ConceptDescription :conceptDescriptionObject="submodelElementData.conceptDescription"></ConceptDescription>
<!-- ConceptDescriptions -->
<v-divider v-if="submodelElementData.conceptDescriptions" class="mt-5"></v-divider>
<v-list nav v-if="submodelElementData.conceptDescriptions">
seicke marked this conversation as resolved.
Show resolved Hide resolved
<v-list-item v-for="(conceptDescription, i) in submodelElementData.conceptDescriptions" :key="i">
seicke marked this conversation as resolved.
Show resolved Hide resolved
<ConceptDescription :conceptDescriptionObject="conceptDescription"></ConceptDescription>
<v-divider v-if="i != Object.keys(submodelElementData.conceptDescriptions).length - 1" class="mt-2"></v-divider>
</v-list-item>
</v-list>
<!-- Last Sync -->
<v-divider class="mt-5"></v-divider>
Expand Down Expand Up @@ -131,7 +134,7 @@ export default defineComponent({
data() {
return {
submodelElementData: {} as any, // SubmodelElement Data
conceptDescription: {} as any, // ConceptDescription Data
conceptDescriptions: {} as any, // Data of Concept Descriptions
seicke marked this conversation as resolved.
Show resolved Hide resolved
requestInterval: null as any, // interval to send requests to the AAS
}
},
Expand Down Expand Up @@ -242,7 +245,7 @@ export default defineComponent({

methods: {
// Initialize the Component
initializeView(withConceptDescription = false) {
initializeView(withConceptDescriptions = false) {
// console.log('Selected Node: ', this.SelectedNode);
// Check if a Node is selected
if (Object.keys(this.SelectedNode).length == 0) {
Expand All @@ -254,8 +257,8 @@ export default defineComponent({
let context = 'retrieving SubmodelElement';
let disableMessage = true;
this.getRequest(path, context, disableMessage).then((response: any) => {
// save embeddedDataSpecifications (ConceptDescription) before overwriting the SubmodelElement Data
let conceptDescription = this.submodelElementData.conceptDescription;
// save Concept Descriptions before overwriting the SubmodelElement Data
let conceptDescriptions = this.submodelElementData.conceptDescriptions;
if (response.success) { // 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 All @@ -273,31 +276,31 @@ export default defineComponent({
this.submodelElementData.timestamp = 'no sync';
this.submodelElementData.path = this.SelectedNode.path; // add the path to the SubmodelElement Data
}
if (withConceptDescription) {
this.getCD(); // fetch ConceptDescriptions for the SubmodelElement
if (withConceptDescriptions) {
this.getCD(); // fetch Concept Descriptions for the SubmodelElement
} else {
this.submodelElementData.conceptDescription = conceptDescription; // add the ConceptDescription to the SubmodelElement Data
this.submodelElementData.conceptDescriptions = conceptDescriptions; // add Concept Descriptions to the SubmodelElement Data
}
// console.log('SubmodelElement Data (SubmodelElementView): ', this.submodelElementData)
// add SubmodelElement Data to the store (as RealTimeDataObject)
this.aasStore.dispatchRealTimeObject(this.submodelElementData);
});
},

// Get the ConceptDescriptions for the SubmodelElement from the ConceptDescription Repository
// Get Concept Descriptions for the SubmodelElement from the ConceptDescription Repository
getCD() {
// Check if a Node is selected
if (Object.keys(this.SelectedNode).length == 0 || !this.SelectedNode.semanticId || !this.SelectedNode.semanticId.keys || this.SelectedNode.semanticId.keys.length == 0) {
this.conceptDescription = {}; // Reset the SubmodelElement Data when no Node is selected
this.conceptDescriptions = {}; // Reset the SubmodelElement Data when no Node is selected
return;
}
// call mixin to request concept description from the CD Repo
this.getConceptDescription(this.SelectedNode).then((response: any) => {
this.requestConceptDescriptions(this.SelectedNode).then((response: any) => {
// console.log('ConceptDescription: ', response)
this.conceptDescription = response;
this.conceptDescriptions = response;
// add ConceptDescription to the SubmodelElement Data
if (response ) {
this.submodelElementData.conceptDescription = response;
this.submodelElementData.conceptDescriptions = response;
}
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,26 @@ export default defineComponent({
},

methods: {
// Get the Unit from the EmbeddedDataSpecification of the Property (if available)
// Get the Unit from the EmbeddedDataSpecification of the ConceptDescription of the Property (if available)
unitSuffix(prop: any) {
// console.log('prop: ', prop);
if (prop.conceptDescription && prop.conceptDescription.embeddedDataSpecifications && prop.conceptDescription.embeddedDataSpecifications.length > 0 && prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent && prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.unit) {
return prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.unit;
if (prop.conceptDescriptions) {

for (let i = 0; i < prop.conceptDescriptions.length; i++) {
seicke marked this conversation as resolved.
Show resolved Hide resolved

let conceptDescription = prop.conceptDescriptions[i];
if (conceptDescription.embeddedDataSpecifications && conceptDescription.embeddedDataSpecifications.length > 0) {

for (let j = 0; j < conceptDescription.embeddedDataSpecifications.length; j++) {

let embeddedDataSpecification = conceptDescription.embeddedDataSpecifications[j];
if (embeddedDataSpecification.dataSpecificationContent && embeddedDataSpecification.dataSpecificationContent.unit) return embeddedDataSpecification.dataSpecificationContent.unit;

}

}

}

} else {
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,26 @@ export default defineComponent({
});
},

// Get the Unit from the EmbeddedDataSpecification of the Property (if available)
// Get the Unit from the EmbeddedDataSpecification of the ConceptDescription of the Property (if available)
unitSuffix(prop: any) {
if (prop.conceptDescription && prop.conceptDescription.embeddedDataSpecifications && prop.conceptDescription.embeddedDataSpecifications.length > 0 && prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent && prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.unit) {
return prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.unit;
if (prop.conceptDescriptions) {

for (let i = 0; i < prop.conceptDescriptions.length; i++) {
seicke marked this conversation as resolved.
Show resolved Hide resolved

let conceptDescription = prop.conceptDescriptions[i];
if (conceptDescription.embeddedDataSpecifications && conceptDescription.embeddedDataSpecifications.length > 0) {

for (let j = 0; j < conceptDescription.embeddedDataSpecifications.length; j++) {

let embeddedDataSpecification = conceptDescription.embeddedDataSpecifications[j];
if (embeddedDataSpecification.dataSpecificationContent && embeddedDataSpecification.dataSpecificationContent.unit) return embeddedDataSpecification.dataSpecificationContent.unit;

}

}

}

} else {
return '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,26 @@ export default defineComponent({
if (!e) this.newNumberValue = this.numberValue.value; // set input to current value in the AAS if the input field is not focused
},

// Get the Unit from the EmbeddedDataSpecification of the Property (if available)
// Get the Unit from the EmbeddedDataSpecification of the ConceptDescription of the Property (if available)
unitSuffix(prop: any) {
if (prop.conceptDescription && prop.conceptDescription.embeddedDataSpecifications && prop.conceptDescription.embeddedDataSpecifications.length > 0 && prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent && prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.unit) {
return prop.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.unit;
if (prop.conceptDescriptions) {

for (let i = 0; i < prop.conceptDescriptions.length; i++) {
seicke marked this conversation as resolved.
Show resolved Hide resolved

let conceptDescription = prop.conceptDescriptions[i];
if (conceptDescription.embeddedDataSpecifications && conceptDescription.embeddedDataSpecifications.length > 0) {

for (let j = 0; j < conceptDescription.embeddedDataSpecifications.length; j++) {

let embeddedDataSpecification = conceptDescription.embeddedDataSpecifications[j];
if (embeddedDataSpecification.dataSpecificationContent && embeddedDataSpecification.dataSpecificationContent.unit) return embeddedDataSpecification.dataSpecificationContent.unit;

}

}

}

} else {
return '';
}
Expand Down
seicke marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ import SubmodelElementHandling from '../../mixins/SubmodelElementHandling';
import IdentificationElement from '../UIComponents/IdentificationElement.vue';
import DescriptionElement from '../UIComponents/DescriptionElement.vue';

import SubmodelElementWrapper from '../UIComponents/SubmodelElementWrapper.vue';
// import SubmodelElementWrapper from '../UIComponents/SubmodelElementWrapper.vue';
seicke marked this conversation as resolved.
Show resolved Hide resolved
import CollectionWrapper from '../UIComponents/CollectionWrapper.vue';
import GenericDataVisu from '../UIComponents/GenericDataVisu.vue';

Expand All @@ -146,7 +146,7 @@ export default defineComponent({
DescriptionElement,

seicke marked this conversation as resolved.
Show resolved Hide resolved
// SubmodelElements
seicke marked this conversation as resolved.
Show resolved Hide resolved
SubmodelElementWrapper,
// SubmodelElementWrapper,
seicke marked this conversation as resolved.
Show resolved Hide resolved
CollectionWrapper,
GenericDataVisu,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ export default defineComponent({
// request the concept descriptions for the records (if they have semanticIds)
// Create a list of promises
let promises = records.map((record: any) => {
return this.getConceptDescription(record).then((response: any) => {
return this.requestConceptDescriptions(record).then((response: any) => {
// console.log('Response: ', response, ' Record: ', record)
// check if the response is not an empty object and if it contains embeddedDataSpecifications
// TODO not tested, but it won't work that way
seicke marked this conversation as resolved.
Show resolved Hide resolved
if (response && Object.keys(response).length !== 0 && response.embeddedDataSpecifications) {
// create new property embeddedDataSpecifications in the record
record.embeddedDataSpecifications = response.embeddedDataSpecifications;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</v-list>
<v-divider v-if="conceptDescriptionObject.embeddedDataSpecifications && conceptDescriptionObject.embeddedDataSpecifications.length > 0" class="mt-2"></v-divider>
<v-list nav v-if="conceptDescriptionObject.embeddedDataSpecifications && conceptDescriptionObject.embeddedDataSpecifications.length > 0">
<v-card v-for="(embeddedDataSpecification, i) in conceptDescriptionObject.embeddedDataSpecifications" :key="i"color="elevatedCard" class="mt-2">
<v-card v-for="(embeddedDataSpecification, i) in conceptDescriptionObject.embeddedDataSpecifications" :key="i" color="elevatedCard" class="mt-2">
<v-list nav class="bg-elevatedCard pt-0">
<!-- hasDataSpecification -->
<SemanticID v-if="embeddedDataSpecification.dataSpecification && embeddedDataSpecification.dataSpecification.keys && embeddedDataSpecification.dataSpecification.keys.length > 0" :semanticIdObject="embeddedDataSpecification.dataSpecification" :semanticTitle="'Data Specification'" class="mb-2"></SemanticID>
Expand Down
seicke marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import SubmodelElementHandling from '../../mixins/SubmodelElementHandling';
import IdentificationElement from '../UIComponents/IdentificationElement.vue';
import DescriptionElement from '../UIComponents/DescriptionElement.vue';

import SubmodelElementWrapper from '../UIComponents/SubmodelElementWrapper.vue';
// import SubmodelElementWrapper from '../UIComponents/SubmodelElementWrapper.vue';
seicke marked this conversation as resolved.
Show resolved Hide resolved
import CollectionWrapper from '../UIComponents/CollectionWrapper.vue';

import SubmodelElementList from '../SubmodelElements/SubmodelElementList.vue';
Expand All @@ -64,7 +64,7 @@ export default defineComponent({
DescriptionElement,

// SubmodelElements
SubmodelElementWrapper,
// SubmodelElementWrapper,
seicke marked this conversation as resolved.
Show resolved Hide resolved
CollectionWrapper,
seicke marked this conversation as resolved.
Show resolved Hide resolved

SubmodelElementList,
Expand Down Expand Up @@ -96,7 +96,7 @@ export default defineComponent({
data() {
return {
localSubmodelElementData: [] as Array<any>, // SubmodelElement Data
conceptDescription: {}, // ConceptDescription Object
// conceptDescriptions: {}, // Data of Concept Descriptions
}
},

Expand All @@ -123,15 +123,15 @@ export default defineComponent({
}
let submodelElementData = [ ...this.submodelElementData ];
// console.log('SubmodelElementData: ', submodelElementData)
submodelElementData.forEach((submodelElement: any) => {
// console.log('ModelType: ', submodelElement);
if (submodelElement.modelType === 'SubmodelElementList') {
// add embeddedDataSpecifications to every value of the SubmodelElementList
submodelElement.value.forEach((value: any) => {
value.embeddedDataSpecifications = submodelElement.conceptDescription.embeddedDataSpecifications;
});
}
});
// submodelElementData.forEach((submodelElement: any) => {
// // console.log('ModelType: ', submodelElement);
// if (submodelElement.modelType === 'SubmodelElementList') {
// // add embeddedDataSpecifications to every value of the SubmodelElementList
// submodelElement.value.forEach((value: any) => {
// value.embeddedDataSpecifications = submodelElement.conceptDescription.embeddedDataSpecifications;
// });
// }
// });
this.localSubmodelElementData = submodelElementData;
},

Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please revert the changes in this file? The original version conforms to the Vuetify examples and to the approach in line 9 of this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the file to support displaying multiple SemanticIDs, see screenshots in #138 (comment)
I used DescriptionElement.vue as a guide for the adaption

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<div v-html="semanticTitle + ':'" class="text-subtitle-2 mt-2"></div>
</template>
<!-- SemanticId List -->
<template v-slot:subtitle>
<div v-for="(semanticId, i) in semanticIdObject.keys" :key="i" class="pt-2">
<v-list-item-subtitle v-for="(semanticId, i) in semanticIdObject.keys" :key="i">
<div class="pt-2">
<v-chip label size="x-small" border class="mr-2">{{ semanticId.type }}</v-chip>
<span v-html="semanticId.value"></span>
</div>
</template>
</v-list-item-subtitle>
</v-list-item>
</v-container>
</template>
Expand Down
seicke marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<v-container fluid class="pa-0">
<v-card :variant="cardStyle ? cardStyle : 'elevated'">
<v-list nav class="pt-0">
<DescriptionElement v-if="SubmodelElementObject.conceptDescription.embeddedDataSpecifications && SubmodelElementObject.conceptDescription.embeddedDataSpecifications.length > 0 && SubmodelElementObject.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.definition" :descriptionObject="SubmodelElementObject.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.definition" :descriptionTitle="'Definition'" :small="true"></DescriptionElement>
<v-divider v-if="SubmodelElementObject.conceptDescription.embeddedDataSpecifications && SubmodelElementObject.conceptDescription.embeddedDataSpecifications.length > 0 && SubmodelElementObject.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.definition" class="mt-2"></v-divider>
<!-- <DescriptionElement v-if="SubmodelElementObject.conceptDescription.embeddedDataSpecifications && SubmodelElementObject.conceptDescription.embeddedDataSpecifications.length > 0 && SubmodelElementObject.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.definition" :descriptionObject="SubmodelElementObject.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.definition" :descriptionTitle="'Definition'" :small="true"></DescriptionElement> -->
seicke marked this conversation as resolved.
Show resolved Hide resolved
<!-- <v-divider v-if="SubmodelElementObject.conceptDescription.embeddedDataSpecifications && SubmodelElementObject.conceptDescription.embeddedDataSpecifications.length > 0 && SubmodelElementObject.conceptDescription.embeddedDataSpecifications[0].dataSpecificationContent.definition" class="mt-2"></v-divider> -->
seicke marked this conversation as resolved.
Show resolved Hide resolved
<MultiLanguageProperty v-if="SubmodelElementObject.modelType == 'MultiLanguageProperty'" :multiLanguagePropertyObject="SubmodelElementObject"></MultiLanguageProperty>
<Property v-if="SubmodelElementObject.modelType == 'Property'" :propertyObject="SubmodelElementObject" @updateValue="updatePropertyValue"></Property>
<File v-if="SubmodelElementObject.modelType == 'File'" :fileObject="SubmodelElementObject"></File>
Expand Down
Loading
Loading