Skip to content

Commit

Permalink
Creates separate component for SpecificAssetIds
Browse files Browse the repository at this point in the history
  • Loading branch information
seicke committed Dec 10, 2024
1 parent 6a39f7f commit f6ff74a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 70 deletions.
74 changes: 4 additions & 70 deletions aas-web-ui/src/components/UIComponents/AssetInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,10 @@
:id-type="'Global Asset ID'"
:name-type="'assetType'"></IdentificationElement>
<v-divider
v-if="assetObject.specificAssetIds && assetObject.specificAssetIds.length > 0"
v-if="Array.isArray(assetObject?.specificAssetIds) && assetObject?.specificAssetIds.length > 0"
class="mt-2"></v-divider>
<!-- Specific Asset IDs -->
<v-list-item v-if="assetObject.specificAssetIds && assetObject.specificAssetIds.length > 0">
<template #title>
<div class="mt-2 mb-2 text-subtitle-2">
{{ 'Specific Asset IDs:' }}
</div>
</template>
<v-list-item-subtitle v-for="(specificAssetId, index) in assetObject.specificAssetIds" :key="index">
<div class="px-2">
<v-list-item-title>
<v-hover v-slot="{ isHovering, props }">
<div
v-bind="props"
:class="isHovering ? 'cursor-pointer' : ''"
class="text-caption"
@click="copyToClipboard(specificAssetId.value, specificAssetId.name)">
<span class="text-subtitle-2">{{ specificAssetId.name + ': ' }}</span>
<v-icon v-if="isHovering" color="subtitleText" size="x-small" class="mr-1"
>mdi-clipboard-file-outline</v-icon
>
<span>{{ specificAssetId.value }}</span>
</div>
</v-hover>
</v-list-item-title>
<v-list-item-subtitle>
<SemanticID
v-if="
specificAssetId.semanticId &&
specificAssetId.semanticId.keys &&
specificAssetId.semanticId.keys.length > 0
"
:semantic-id-object="specificAssetId.semanticId"
:semantic-title="
specificAssetId.semanticId.keys.length > 0 ? 'Semantic IDs' : 'Semantic ID:'
"
:small="true"
class="mt-n3"></SemanticID>
</v-list-item-subtitle>
</div>
<v-divider v-if="index < assetObject.specificAssetIds.length - 1" class="my-2"></v-divider>
</v-list-item-subtitle>
</v-list-item>
<SpecificAssetIds :asset-object="assetObject"></SpecificAssetIds>
<v-divider v-if="assetObject.defaultThumbnail" class="mt-2"></v-divider>
<v-img
v-if="assetObject.defaultThumbnail"
Expand All @@ -67,25 +27,16 @@
<script lang="ts">
import { defineComponent } from 'vue';
import IdentificationElement from '@/components/UIComponents/IdentificationElement.vue';
import SemanticID from '@/components/UIComponents/SemanticID.vue';
import { useNavigationStore } from '@/store/NavigationStore';
import SpecificAssetIds from '@/components/UIComponents/SpecificAssetIds.vue';
export default defineComponent({
name: 'AssetInformation',
components: {
IdentificationElement,
SemanticID,
SpecificAssetIds,
},
props: ['assetObject'],
setup() {
const navigationStore = useNavigationStore();
return {
navigationStore, // NavigationStore Object
};
},
data() {
return {
thumbnailMaxHeight: 0,
Expand Down Expand Up @@ -146,23 +97,6 @@
this.thumbnailMaxHeight = 0.4 * availableHeight;
}
},
// Function to copy the id to the clipboard
copyToClipboard(value: string, name: string) {
if (!value || !value) return;
// console.log('Copy ID to Clipboard: ', this.identificationObject.id);
// copy the path to the clipboard
navigator.clipboard.writeText(value);
// open Snackbar to inform the user that the path was copied to the clipboard
this.navigationStore.dispatchSnackbar({
status: true,
timeout: 2000,
color: 'success',
btnColor: 'buttonText',
text: (name ? name : value) + ' copied to Clipboard.',
});
},
},
});
</script>
85 changes: 85 additions & 0 deletions aas-web-ui/src/components/UIComponents/SpecificAssetIds.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<v-container fluid class="pa-0">
<v-list-item v-if="Array.isArray(assetObject?.specificAssetIds) && assetObject?.specificAssetIds.length > 0">
<template #title>
<div class="mt-2 mb-2 text-subtitle-2">
{{ 'Specific Asset IDs:' }}
</div>
</template>
<v-list-item-subtitle v-for="(specificAssetId, index) in assetObject.specificAssetIds" :key="index">
<div class="px-2">
<v-list-item-title>
<v-hover v-slot="{ isHovering, props }">
<div
v-bind="props"
:class="isHovering ? 'cursor-pointer' : ''"
class="text-caption"
@click="copyToClipboard(specificAssetId.value, specificAssetId.name)">
<span class="text-subtitle-2">{{ specificAssetId.name + ': ' }}</span>
<v-icon v-if="isHovering" color="subtitleText" size="x-small" class="mr-1"
>mdi-clipboard-file-outline</v-icon
>
<span>{{ specificAssetId.value }}</span>
</div>
</v-hover>
</v-list-item-title>
<v-list-item-subtitle>
<SemanticID
v-if="
Array.isArray(specificAssetId?.semanticId?.keys) &&
specificAssetId.semanticId.keys.length > 0
"
:semantic-id-object="specificAssetId.semanticId"
:semantic-title="
specificAssetId.semanticId.keys.length > 0 ? 'Semantic IDs' : 'Semantic ID:'
"
:small="true"
class="mt-n3"></SemanticID>
</v-list-item-subtitle>
</div>
<v-divider v-if="index < assetObject.specificAssetIds.length - 1" class="my-2"></v-divider>
</v-list-item-subtitle>
</v-list-item>
</v-container>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import SemanticID from '@/components/UIComponents/SemanticID.vue';
import { useNavigationStore } from '@/store/NavigationStore';
export default defineComponent({
name: 'SpecificAssetIds',
components: {
SemanticID,
},
props: ['assetObject'],
setup() {
const navigationStore = useNavigationStore();
return {
navigationStore, // NavigationStore Object
};
},
methods: {
// Function to copy the id to the clipboard
copyToClipboard(value: string, name: string) {
if (!value || !value) return;
// console.log('Copy ID to Clipboard: ', this.identificationObject.id);
// copy the path to the clipboard
navigator.clipboard.writeText(value);
// open Snackbar to inform the user that the path was copied to the clipboard
this.navigationStore.dispatchSnackbar({
status: true,
timeout: 2000,
color: 'success',
btnColor: 'buttonText',
text: (name ? name : value) + ' copied to Clipboard.',
});
},
},
});
</script>

0 comments on commit f6ff74a

Please sign in to comment.