Skip to content

Commit 2c9401f

Browse files
committed
Fixes problems with the DPP Demo Module
1 parent c78c2d9 commit 2c9401f

File tree

6 files changed

+65
-37
lines changed

6 files changed

+65
-37
lines changed
780 Bytes
Binary file not shown.
781 Bytes
Binary file not shown.
1.18 KB
Binary file not shown.

aas-web-ui/src/components/Plugins/Submodels/CarbonFootprint_v1_0.vue

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,10 @@
4545
icon-color="background">
4646
<template #opposite>
4747
<div
48-
v-for="pcfLifeCyclePhase in pcfSMC.value
49-
.find(
50-
(sme: any) =>
51-
checkIdShort(sme, 'LifeCyclePhases') ||
52-
checkSemanticId(
53-
sme,
54-
'https://admin-shell.io/idta/CarbonFootprint/LifeCyclePhases/1/0'
55-
)
56-
)
57-
.value.filter(
58-
(sme: any) =>
59-
checkIdShort(sme, 'LifeCyclePhase') ||
60-
checkSemanticId(sme, '0173-1#02-ABG858#003')
61-
)"
48+
v-for="pcfLifeCyclePhase in getLifeCyclePhases(pcfSMC)"
6249
:key="pcfLifeCyclePhase.idShort"
6350
class="pr-6">
64-
<p
65-
v-if="
66-
pcfLifeCyclePhase?.valueId?.keys &&
67-
Array.isArray(pcfLifeCyclePhase?.valueId?.keys) &&
68-
pcfLifeCyclePhase?.valueId?.keys.length > 0
69-
">
70-
{{
71-
getPcfLifeCyclePhaseFromId(
72-
pcfLifeCyclePhase?.valueId?.keys[0]?.value
73-
)?.value.replaceAll(', ', '\n')
74-
}}
75-
</p>
76-
<p v-else>
77-
{{ valueToDisplay(pcfLifeCyclePhase).replaceAll(', ', '\n') }}
78-
</p>
51+
<p>{{ formatLifeCyclePhaseLabel(pcfLifeCyclePhase) }}</p>
7952
</div>
8053
</template>
8154
<div class="pl-6">
@@ -457,4 +430,35 @@
457430
458431
showPieChart.value = pieChartData.value.length > 0;
459432
}
433+
434+
function getLifeCyclePhases(pcfSMC: any): Array<any> {
435+
if (!pcfSMC?.value || !Array.isArray(pcfSMC.value)) return [];
436+
437+
const lifeCyclePhasesSml = pcfSMC.value.find(
438+
(sme: any) =>
439+
checkIdShort(sme, 'LifeCyclePhases') ||
440+
checkSemanticId(sme, 'https://admin-shell.io/idta/CarbonFootprint/LifeCyclePhases/1/0')
441+
);
442+
443+
if (!lifeCyclePhasesSml?.value || !Array.isArray(lifeCyclePhasesSml.value)) return [];
444+
445+
return lifeCyclePhasesSml.value.filter(
446+
(sme: any) => checkIdShort(sme, 'LifeCyclePhase') || checkSemanticId(sme, '0173-1#02-ABG858#003')
447+
);
448+
}
449+
450+
function formatLifeCyclePhaseLabel(pcfLifeCyclePhase: any): string {
451+
const lifeCyclePhaseIdRaw = pcfLifeCyclePhase?.valueId?.keys?.[0]?.value;
452+
453+
if (typeof lifeCyclePhaseIdRaw === 'string' && lifeCyclePhaseIdRaw.trim() !== '') {
454+
const normalizedLifeCyclePhaseId = lifeCyclePhaseIdRaw.trim();
455+
const phaseInfo = getPcfLifeCyclePhaseFromId(normalizedLifeCyclePhaseId);
456+
if (phaseInfo?.value && typeof phaseInfo.value === 'string' && phaseInfo.value.trim() !== '') {
457+
return phaseInfo.value.replaceAll(', ', '\n');
458+
}
459+
}
460+
461+
const fallbackLabel = valueToDisplay(pcfLifeCyclePhase);
462+
return typeof fallbackLabel === 'string' ? fallbackLabel.replaceAll(', ', '\n') : '';
463+
}
460464
</script>

aas-web-ui/src/pages/modules/DPPDemo/General.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@
173173
for (const sme of nameplateSubmodel.value.submodelElements) {
174174
for (const idShort of productPropertyIdShorts) {
175175
if (checkIdShort(sme, idShort) && hasValue(sme)) {
176-
let value = valueToDisplay(sme, '');
176+
const fallbackValue = firstLangStringSetText(sme);
177+
let value = valueToDisplay(sme, 'en', fallbackValue);
177178
178179
if (checkIdShort(sme, 'CountryOfOrigin')) {
179180
value = getCountryName(value, value) || value;
@@ -190,10 +191,11 @@
190191
191192
for (const idShort of manufacturerPropertyIdShorts) {
192193
if (checkIdShort(sme, idShort) && hasValue(sme)) {
194+
const fallbackValue = firstLangStringSetText(sme);
193195
generalRows.value.push({
194196
idShort: idShort,
195197
label: nameToDisplay(sme, 'en', idShort),
196-
value: idShort === 'CompanyLogo' ? 'Logo' : valueToDisplay(sme, ''),
198+
value: idShort === 'CompanyLogo' ? 'Logo' : valueToDisplay(sme, 'en', fallbackValue),
197199
type: idShort === 'CompanyLogo' ? 'logo' : 'text',
198200
});
199201
}

aas-web-ui/src/pages/modules/DPPDemo/index.vue

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@
1515
:aspect-ratio="productImageAspectRatio"
1616
class="w-100 mx-auto border rounded-lg"
1717
style="max-width: 300px"
18-
cover />
19-
<v-icon v-else size="48" color="medium-emphasis">mdi-image-off-outline</v-icon>
18+
cover
19+
@error="onProductImageError" />
20+
<v-sheet
21+
v-else
22+
class="w-100 mx-auto border rounded-lg d-flex justify-center align-center"
23+
style="max-width: 300px"
24+
min-height="140">
25+
<v-icon size="48" color="medium-emphasis">mdi-image-off-outline</v-icon>
26+
</v-sheet>
2027
</v-sheet>
2128
</v-col>
2229
<v-col cols="12" md="6" class="pa-2">
@@ -148,19 +155,34 @@
148155
String(defaultThumbnail.isExternal).toLowerCase() === 'true' ||
149156
urlRegex.test(thumbnailPath);
150157
151-
productImageSrc.value = await getBlobUrl(thumbnailPath, isExternalThumbnail);
152-
updateProductImageAspectRatio(productImageSrc.value);
158+
try {
159+
productImageSrc.value = await getBlobUrl(thumbnailPath, isExternalThumbnail);
160+
updateProductImageAspectRatio(productImageSrc.value);
161+
} catch {
162+
productImageSrc.value = '';
163+
productImageAspectRatio.value = 1;
164+
}
153165
return;
154166
}
155167
156168
const imageUrl = await getProductImageUrlByAasId(selectedAas.value.id);
157169
158170
if (imageUrl && imageUrl.url && imageUrl.url.trim() !== '') {
159-
productImageSrc.value = await getBlobUrl(imageUrl.url.trim(), imageUrl.isExternal);
160-
updateProductImageAspectRatio(productImageSrc.value);
171+
try {
172+
productImageSrc.value = await getBlobUrl(imageUrl.url.trim(), imageUrl.isExternal);
173+
updateProductImageAspectRatio(productImageSrc.value);
174+
} catch {
175+
productImageSrc.value = '';
176+
productImageAspectRatio.value = 1;
177+
}
161178
}
162179
}
163180
181+
function onProductImageError(): void {
182+
productImageSrc.value = '';
183+
productImageAspectRatio.value = 1;
184+
}
185+
164186
function updateProductImageAspectRatio(src: string): void {
165187
if (!src || src.trim() === '') {
166188
productImageAspectRatio.value = 1;

0 commit comments

Comments
 (0)