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

Improves client functions with provided id #332

Merged
merged 9 commits into from
Feb 26, 2025
89 changes: 46 additions & 43 deletions aas-web-ui/src/components/AppNavigation/AASList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
hide-details
label="Search for AAS..."
clearable
@update:model-value="filterAasDescriptorList"></v-text-field>
@update:model-value="filterAasList"></v-text-field>
</v-col>
<!-- Add AAS -->
<v-col cols="auto" class="px-0">
Expand Down Expand Up @@ -118,11 +118,7 @@
</v-list-item>
</template>
<template v-else>
<v-virtual-scroll
ref="virtualScrollRef"
:items="aasDescriptorList"
:item-height="56"
class="pb-2 bg-card">
<v-virtual-scroll ref="virtualScrollRef" :items="aasList" :item-height="56" class="pb-2 bg-card">
<template #default="{ item }">
<!-- Single AAS -->
<v-list-item
Expand Down Expand Up @@ -295,8 +291,8 @@
const router = useRouter();

// Composables
const { downloadAasx, isAvailableByIdInRepo } = useAASRepositoryClient();
const { fetchAasDescriptorList } = useAASHandling();
const { downloadAasx } = useAASRepositoryClient();
const { fetchAasDescriptorList, fetchAasList, aasIsAvailableById } = useAASHandling();
const { nameToDisplay, descriptionToDisplay } = useReferableUtils();
const { copyToClipboard } = useClipboardUtil();

Expand All @@ -309,8 +305,8 @@
const theme = useTheme();

// Data
const aasDescriptorList = ref([] as Array<any>) as Ref<Array<any>>; // Variable to store the AAS Data
const aasDescriptorListUnfiltered = ref([] as Array<any>) as Ref<Array<any>>; // Variable to store the AAS Data before filtering
const aasList = ref([] as Array<any>) as Ref<Array<any>>; // Variable to store the AAS Data (AAS or AAS Descriptors)

Check warning on line 308 in aas-web-ui/src/components/AppNavigation/AASList.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 308 in aas-web-ui/src/components/AppNavigation/AASList.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const aasListUnfiltered = ref([] as Array<any>) as Ref<Array<any>>; // Variable to store the AAS Data before filtering

Check warning on line 309 in aas-web-ui/src/components/AppNavigation/AASList.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const listLoading = ref(false); // Variable to store if the AAS List is loading
const deleteDialog = ref(false); // Variable to store if the Delete Dialog should be shown
const aasToDelete = ref({}); // Variable to store the AAS to be deleted
Expand Down Expand Up @@ -354,10 +350,8 @@
// Watchers
watch(
() => aasRegistryURL.value,
(newValue) => {
if (newValue !== '') {
initialize();
}
() => {
initialize();
}
);

Expand All @@ -381,13 +375,13 @@
updateStatus();
}, statusCheck.value.interval);
} else {
aasDescriptorList.value.forEach((aasDescriptor: any) => {
aasList.value.forEach((aasDescriptor: any) => {
aasDescriptor.status = 'check disabled';
});

// Reset status icon after 2 seconds
setTimeout(() => {
aasDescriptorList.value.forEach((aasDescriptor: any) => {
aasList.value.forEach((aasDescriptor: any) => {
aasDescriptor.status = '';
});
}, 2000);
Expand Down Expand Up @@ -434,14 +428,23 @@
async function initialize(): Promise<void> {
listLoading.value = true;

fetchAasDescriptorList().then(async (aasDescriptors: Array<any>) => {
let aasDescriptorsSorted = aasDescriptors.sort((a: { [x: string]: number }, b: { [x: string]: number }) =>
a['id'] > b['id'] ? 1 : -1
);
fetchAasDescriptorList().then(async (aasDescriptorList: Array<any>) => {
if (aasDescriptorList.length > 0) {
let aasDescriptorListSorted = aasDescriptorList.sort(
(a: { [x: string]: number }, b: { [x: string]: number }) => (a['id'] > b['id'] ? 1 : -1)
);
aasList.value = [...aasDescriptorListSorted];

aasDescriptorList.value = [...aasDescriptorsSorted];
aasListUnfiltered.value = [...aasDescriptorListSorted];
} else {
const listOfAas = await fetchAasList();
let listOfAasSorted = listOfAas.sort((a: { [x: string]: number }, b: { [x: string]: number }) =>
a['id'] > b['id'] ? 1 : -1
);
aasList.value = [...listOfAasSorted];

aasDescriptorListUnfiltered.value = [...aasDescriptorsSorted];
aasListUnfiltered.value = [...listOfAasSorted];
}

scrollToSelectedAAS();

Expand All @@ -461,37 +464,37 @@
* based on availability checks.
*/
function updateStatus(init: boolean = false): void {
if (Array.isArray(aasDescriptorList.value) && aasDescriptorList.value.length > 0)
aasDescriptorList.value.forEach(async (aasDescriptor: any) => {
if (aasDescriptor && Object.keys(aasDescriptor).length > 0) {
if (Array.isArray(aasList.value) && aasList.value.length > 0)
aasList.value.forEach(async (aasOrAasDescriptor: any) => {
if (aasOrAasDescriptor && Object.keys(aasOrAasDescriptor).length > 0) {
await new Promise((resolve) => setTimeout(resolve, 600)); // Give the UI the chance to refresh status icons

const aasIsAvailable = await isAvailableByIdInRepo(aasDescriptor.id);
const aasIsAvailable = await aasIsAvailableById(aasOrAasDescriptor.id);

if (aasIsAvailable) {
aasDescriptor.status =
aasOrAasDescriptor.status =
statusCheck.value.state === true ? 'online' : init ? '' : 'check disabled';
} else {
aasDescriptor.status =
aasOrAasDescriptor.status =
statusCheck.value.state === true ? 'offline' : init ? '' : 'check disabled';
}
}
});
}

function filterAasDescriptorList(value: string): void {
function filterAasList(value: string): void {
if (!value || value.trim() === '') {
aasDescriptorList.value = aasDescriptorListUnfiltered.value;
aasList.value = aasListUnfiltered.value;
} else {
// filter list of AAS Descriptors
let aasDescriptorListFiltered = aasDescriptorListUnfiltered.value.filter(
let aasListFiltered = aasListUnfiltered.value.filter(
(aasDescriptor: any) =>
aasDescriptor.id.toLowerCase().includes(value.toLowerCase()) ||
aasDescriptor.idShort.toLowerCase().includes(value.toLowerCase()) ||
nameToDisplay(aasDescriptor).toLowerCase().includes(value.toLowerCase()) ||
descriptionToDisplay(aasDescriptor).toLowerCase().includes(value.toLowerCase())
);
aasDescriptorList.value = aasDescriptorListFiltered;
aasList.value = aasListFiltered;
}
scrollToSelectedAAS();
}
Expand Down Expand Up @@ -524,24 +527,24 @@
}
}

function isSelected(aas: any): boolean {
function isSelected(aasOrAasDescriptor: any): boolean {
if (
!selectedAAS.value ||
Object.keys(selectedAAS.value).length === 0 ||
!selectedAAS.value.id ||
!aas ||
Object.keys(aas).length === 0 ||
!aas.id
!aasOrAasDescriptor ||
Object.keys(aasOrAasDescriptor).length === 0 ||
!aasOrAasDescriptor.id
) {
return false;
}
return selectedAAS.value.id === aas.id;
return selectedAAS.value.id === aasOrAasDescriptor.id;
}

// Function to scroll to the selected AAS
function scrollToSelectedAAS(): void {
// Find the index of the selected item
const index = aasDescriptorList.value.findIndex((aasDescriptor: any) => isSelected(aasDescriptor));
const index = aasList.value.findIndex((aasOrAasDescriptor: any) => isSelected(aasOrAasDescriptor));

if (index !== -1) {
const intervalId = setInterval(() => {
Expand All @@ -557,16 +560,16 @@
}
}

function openDeleteDialog(AAS: any): void {
function openDeleteDialog(aasOrAasDescriptor: any): void {
deleteDialog.value = true;
aasToDelete.value = AAS;
aasToDelete.value = aasOrAasDescriptor;
}

function openEditDialog(createNew: boolean, aas?: any): void {
function openEditDialog(createNew: boolean, aasOrAasDescriptor?: any): void {
editDialog.value = true;
newShell.value = createNew;
if (createNew === false && aas) {
aasToEdit.value = aas;
if (createNew === false && aasOrAasDescriptor) {
aasToEdit.value = aasOrAasDescriptor;
}
}
</script>
Expand Down
22 changes: 9 additions & 13 deletions aas-web-ui/src/components/AppNavigation/AASListDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@
const router = useRouter();

// Composables
const { downloadAasx, fetchAssetInformation, isAvailableById: isAvailableByIdInRepo } = useAASRepositoryClient();
const { fetchAas } = useAASHandling();
const { downloadAasx, fetchAssetInformation } = useAASRepositoryClient();
const { aasIsAvailableById, fetchAas } = useAASHandling();

// Stores
const navigationStore = useNavigationStore();
Expand Down Expand Up @@ -187,19 +187,15 @@
// Watchers
watch(
() => aasRegistryURL.value,
async (newValue) => {
if (newValue !== '') {
await initializeView();
}
async () => {
initializeView();
}
);

watch(
() => aasRepoURL.value,
async (newValue) => {
if (newValue !== '') {
await initializeView();
}
async () => {
initializeView();
}
);

Expand Down Expand Up @@ -228,7 +224,7 @@
}
}

await initializeView();
initializeView();
},
{ deep: true }
);
Expand Down Expand Up @@ -295,7 +291,7 @@
}, statusCheck.value.interval);
}

await initializeView(true);
initializeView(true);
});

onBeforeUnmount(() => {
Expand All @@ -320,7 +316,7 @@
if (assetAdministrationShellData.value && Object.keys(assetAdministrationShellData.value).length > 0) {
await new Promise((resolve) => setTimeout(resolve, 600)); // Give the UI the chance to refresh status icons

const aasIsAvailable = await isAvailableByIdInRepo(assetAdministrationShellData.value.id);
const aasIsAvailable = await aasIsAvailableById(assetAdministrationShellData.value.id);

if (aasIsAvailable) {
assetAdministrationShellData.value.status =
Expand Down
4 changes: 2 additions & 2 deletions aas-web-ui/src/components/AppNavigation/UploadAAS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@

<script lang="ts" setup>
import { computed, ref, watch, watchEffect } from 'vue';
import { useSMHandling } from '@/composables/AAS/SMHandling';
import { useAASRegistryClient } from '@/composables/Client/AASRegistryClient';
import { useAASRepositoryClient } from '@/composables/Client/AASRepositoryClient';
import { useSMRegistryClient } from '@/composables/Client/SMRegistryClient';
import { useSMRepositoryClient } from '@/composables/Client/SMRepositoryClient';
import { useNavigationStore } from '@/store/NavigationStore';
import { Endpoint, ProtocolInformation, SubmodelDescriptor } from '@/types/Descriptors';
import { base64Encode } from '@/utils/EncodeDecodeUtils';
Expand All @@ -53,7 +53,7 @@

// Composables
const { fetchAas, uploadAas } = useAASRepositoryClient();
const { fetchSm } = useSMRepositoryClient();
const { fetchSm } = useSMHandling();
const { postAasDescriptor, createDescriptorFromAAS } = useAASRegistryClient();
const { postSubmodelDescriptor, createDescriptorFromSubmodel } = useSMRegistryClient();

Expand Down
9 changes: 3 additions & 6 deletions aas-web-ui/src/components/ComponentVisualization.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

// Computed Properties
const aasRegistryURL = computed(() => navigationStore.getAASRegistryURL);
const submodelRegistryServerURL = computed(() => navigationStore.getSubmodelRegistryURL);
const submodelRegistryURL = computed(() => navigationStore.getSubmodelRegistryURL);
const selectedAAS = computed(() => aasStore.getSelectedAAS);
const selectedNode = computed(() => aasStore.getSelectedNode);
const isMobile = computed(() => navigationStore.getIsMobile);
Expand Down Expand Up @@ -202,23 +202,20 @@
);

watch(
() => submodelRegistryServerURL.value,
() => submodelRegistryURL.value,
() => {
resetLocalData();
}
);

// Resets the SubmodelElementView when the AAS changes
watch(
() => selectedAAS.value,
() => {
resetLocalData();
initialize();
},
{ deep: true }
}
);

// Watch for changes in the selected Node and (re-)initialize the Component
watch(
() => selectedNode.value,
() => {
Expand Down
6 changes: 3 additions & 3 deletions aas-web-ui/src/components/EditorComponents/DeleteDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import { computed, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useRoute } from 'vue-router';
import { useSMHandling } from '@/composables/AAS/SMHandling';
import { useAASRepositoryClient } from '@/composables/Client/AASRepositoryClient';
import { useSMRegistryClient } from '@/composables/Client/SMRegistryClient';
import { useRequestHandling } from '@/composables/RequestHandling';
import { useAASStore } from '@/store/AASDataStore';
import { useNavigationStore } from '@/store/NavigationStore';
Expand All @@ -47,7 +47,7 @@
const route = useRoute();

const { deleteRequest } = useRequestHandling();
const { fetchSmDescriptorById } = useSMRegistryClient();
const { fetchSmDescriptor } = useSMHandling();
const { deleteSubmodelRef } = useAASRepositoryClient();

const props = defineProps<{
Expand Down Expand Up @@ -82,7 +82,7 @@
deleteLoading.value = true;
if (props.element.modelType === 'Submodel') {
// Fetch the submodel from the submodel registry
const smDescriptor = await fetchSmDescriptorById(props.element.id);
const smDescriptor = await fetchSmDescriptor(props.element.id);
// extract the submodel endpoint
const smEndpoint = extractEndpointHref(smDescriptor, 'SUBMODEL-3.0');
try {
Expand Down
8 changes: 5 additions & 3 deletions aas-web-ui/src/components/EditorComponents/SubmodelForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import { jsonization } from '@aas-core-works/aas-core3.0-typescript';
import { computed, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useSMHandling } from '@/composables/AAS/SMHandling';
import { useAASRepositoryClient } from '@/composables/Client/AASRepositoryClient';
import { useSMRegistryClient } from '@/composables/Client/SMRegistryClient';
import { useSMRepositoryClient } from '@/composables/Client/SMRepositoryClient';
Expand Down Expand Up @@ -98,8 +99,9 @@
(event: 'update:modelValue', value: boolean): void;
}>();

const { fetchSmById, postSubmodel, putSubmodel } = useSMRepositoryClient();
const { putSubmodelDescriptor, createDescriptorFromSubmodel, fetchSmDescriptorById } = useSMRegistryClient();
const { postSubmodel, putSubmodel } = useSMRepositoryClient();
const { putSubmodelDescriptor, createDescriptorFromSubmodel } = useSMRegistryClient();
const { fetchSmById, fetchSmDescriptor } = useSMHandling();
const { putAas } = useAASRepositoryClient();

const editSMDialog = ref(false);
Expand Down Expand Up @@ -294,7 +296,7 @@
await putSubmodel(submodelObject.value);
const jsonSubmodel = jsonization.toJsonable(submodelObject.value);
// Fetch the current desciptor from the registry
const fetchedDescriptor = await fetchSmDescriptorById(submodelObject.value.id);
const fetchedDescriptor = await fetchSmDescriptor(submodelObject.value.id);
const descriptor = createDescriptorFromSubmodel(jsonSubmodel, fetchedDescriptor.endpoints);
// Update AAS Descriptor
await putSubmodelDescriptor(descriptor);
Expand Down
Loading
Loading