Skip to content

Commit

Permalink
only fetch bucket name when in fullview mode
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Feb 14, 2024
1 parent 6100713 commit fd64478
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
6 changes: 2 additions & 4 deletions frontend/src/components/object/ObjectList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { computed, onMounted, ref } from 'vue';
import { computed, ref } from 'vue';
import {
DeleteObjectButton,
Expand All @@ -10,7 +10,7 @@ import {
ObjectUpload
} from '@/components/object';
import { Button } from '@/lib/primevue';
import { useAuthStore, useBucketStore, useObjectStore, usePermissionStore } from '@/store';
import { useAuthStore, useObjectStore, usePermissionStore } from '@/store';
import { Permissions } from '@/utils/constants';
import { ButtonMode } from '@/utils/enums';
Expand All @@ -25,8 +25,6 @@ const props = withDefaults(defineProps<Props>(), {
bucketId: undefined
});
// Store
const bucketStore = useBucketStore();
//const navStore = useNavStore();
const objectStore = useObjectStore();
const permissionStore = usePermissionStore();
Expand Down
16 changes: 6 additions & 10 deletions frontend/src/components/object/ObjectProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { storeToRefs } from 'pinia';
import { onMounted, ref, watch } from 'vue';
import GridRow from '@/components/form/GridRow.vue';
import { useBucketStore, useMetadataStore, useObjectStore, useUserStore } from '@/store';
import { useBucketStore, useObjectStore, useUserStore } from '@/store';
import { RouteNames } from '@/utils/constants';
import { formatDateLong } from '@/utils/formatters';
Expand All @@ -13,17 +13,13 @@ import type { Bucket, COMSObject, Metadata } from '@/types';
// Props
type Props = {
objectId: string;
versionId?: string;
fullView: boolean;
};
const props = withDefaults(defineProps<Props>(), {
versionId: undefined
});
const props = withDefaults(defineProps<Props>(), {});
// Store
const bucketStore = useBucketStore();
const metadataStore = useMetadataStore();
const objectStore = useObjectStore();
const userStore = useUserStore();
const { getUserSearch } = storeToRefs(userStore);
Expand All @@ -32,17 +28,17 @@ const { getUserSearch } = storeToRefs(userStore);
const bucket: Ref<Bucket | undefined> = ref(undefined);
const createdBy: Ref<string | undefined> = ref(undefined);
const object: Ref<COMSObject | undefined> = ref(undefined);
const objectMetadata: Ref<Metadata | undefined> = ref(undefined);
const updatedBy: Ref<string | undefined> = ref(undefined);
// Actions
async function load() {
object.value = objectStore.findObjectById(props.objectId);
await bucketStore.fetchBuckets({ bucketId: object.value?.bucketId });
bucket.value = bucketStore.findBucketById(object.value?.bucketId as string);
if (props.fullView) {
objectMetadata.value = metadataStore.findMetadataByObjectId(object.value?.id as string);
// to get bucket name
await bucketStore.fetchBuckets({ bucketId: object.value?.bucketId });
bucket.value = bucketStore.findBucketById(object.value?.bucketId as string);
await userStore.fetchUsers({ userId: [object.value?.createdBy, object.value?.updatedBy] });
createdBy.value = getUserSearch.value.find((x) => x.userId === object.value?.createdBy)?.fullName;
updatedBy.value = getUserSearch.value.find((x) => x.userId === object.value?.updatedBy)?.fullName;
Expand Down
18 changes: 3 additions & 15 deletions frontend/src/components/object/ObjectTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@/components/object';
import { SyncButton } from '@/components/common';
import { ShareObjectButton } from '@/components/object/share';
import { Button, Column, DataTable, Dialog, FilterMatchMode, InputText, useToast } from '@/lib/primevue';
import { Button, Column, DataTable, Dialog, InputText, useToast } from '@/lib/primevue';
import { useAuthStore, useObjectStore, usePermissionStore } from '@/store';
import { Permissions } from '@/utils/constants';
import { ButtonMode } from '@/utils/enums';
Expand Down Expand Up @@ -49,7 +49,6 @@ const permissionStore = usePermissionStore();
const { getUserId } = storeToRefs(useAuthStore());
// State
const selectAll = ref(false);
const permissionsVisible = ref(false);
const permissionsObjectId = ref('');
const permissionsObjectName: Ref<string | undefined> = ref('');
Expand All @@ -74,16 +73,6 @@ const onDeletedSuccess = () => {
loadLazyData();
};
function selectCurrentPage() {
objectStore.setSelectedObjects(
tableData.value.filter((object) => {
return Array.from(document.querySelectorAll('[data-objectId]'))
.map((x) => x.getAttribute('data-objectId'))
.includes(object.id);
})
);
}
const showInfo = (id: string) => emit('show-object-info', id);
async function showPermissions(objectId: string) {
Expand Down Expand Up @@ -131,7 +120,6 @@ const loadLazyData = (event?: any) => {
// add to object store
r.data.forEach((o: COMSObject) => {
console.log(o);
objectStore.$patch((state) => {
state.objects.push(o);
});
Expand Down Expand Up @@ -191,12 +179,12 @@ const selectedFilters = (payload: any) => {
<div class="object-table">
<DataTable
ref="dt"
v-model:value="tableData"
v-model:selection="selectedObjects"
v-model:filters="filters"
lazy
paginator
:loading="loading"
v-model:value="tableData"
:total-records="totalRecords"
data-key="id"
class="p-datatable-sm"
Expand All @@ -205,7 +193,7 @@ const selectedFilters = (payload: any) => {
:rows-per-page-options="[10, 20, 50]"
sort-field="updatedAt"
:sort-order="-1"
filterDisplay="row"
filter-display="row"
:global-filter-fields="['name']"
:first="first"
update:filters
Expand Down

0 comments on commit fd64478

Please sign in to comment.