Skip to content

Commit

Permalink
Merge pull request #40 from bcgov/bugfix/fileDetailsLoading
Browse files Browse the repository at this point in the history
File Details load object
  • Loading branch information
jujaga authored Mar 1, 2023
2 parents d4a8293 + 146a596 commit f6012b2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion charts/bcbox/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: bcbox
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.1
version: 0.0.2
kubeVersion: ">= 1.13.0"
description: A frontend UI for managing access control to S3 Objects
# A chart can be either an 'application' or a 'library' chart.
Expand Down
5 changes: 2 additions & 3 deletions charts/bcbox/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ config:
configMap:
FRONTEND_APIPATH: "api/v1"
FRONTEND_COMS_APIPATH: ~
FRONTEND_KC_CLIENTID: ~
FRONTEND_KC_REALM: ~
FRONTEND_KC_SERVERURL: ~
FRONTEND_OIDC_AUTHORITY: ~
FRONTEND_OIDC_CLIENTID: ~
SERVER_APIPATH: "/api/v1"
SERVER_BODYLIMIT: "30mb"
# SERVER_STATICFILES: ~
Expand Down
25 changes: 17 additions & 8 deletions frontend/src/components/object/ObjectFileDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useRoute } from 'vue-router';
import { storeToRefs } from 'pinia';
import Button from 'primevue/button';
import Dialog from 'primevue/dialog';
import ProgressSpinner from 'primevue/progressspinner';
import { useToast } from 'primevue/usetoast';
import {
Expand All @@ -28,22 +29,24 @@ const objectStore = useObjectStore();
const toast = useToast();
const route = useRoute();
const { objectList } = storeToRefs(objectStore);
const { loading, objectList } = storeToRefs(objectStore);
const { currentUser } = storeToRefs(useUserStore());
const objectInfo: Ref<COMSObject> = ref({} as COMSObject);
const isInfoLoaded: Ref<Boolean> = ref(false);
const permissionsVisible: Ref<boolean> = ref(false);
const permissionsObjectId: Ref<string> = ref('');
const permissionsObjectName: Ref<string> = ref('');
const getObjectInfo = (objId: string) => {
const getObjectInfo = async (objId: string) => {
try {
objectInfo.value = (objectList.value.find((x: COMSObject) => x.id === objId) as COMSObject);
isInfoLoaded.value = true;
await objectStore.listObjects({ objId });
if(!objectInfo.value || !objectList.value[0]) {
throw Error(`Object ${objId} not found or you do not have access`);
}
objectInfo.value = objectList.value[0];
} catch (error: any) {
toast.add({ severity: 'error', summary: 'Unable to load Objects.', detail: error, life: 5000 });
toast.add({ severity: 'error', summary: 'Unable to load Object.', detail: error, life: 5000 });
}
};
Expand All @@ -70,7 +73,11 @@ onMounted(() => {
File details
</h1>
</div>
<div class="action-buttons">

<div
v-if="!loading && objectInfo.permissions"
class="action-buttons"
>
<ShareObjectButton
v-if="objectStore.isActionAllowed(objectInfo.permissions, Permissions.MANAGE, currentUser?.userId)"
:obj="objectInfo"
Expand All @@ -95,8 +102,10 @@ onMounted(() => {
</div>
</div>

<ProgressSpinner v-if="loading" />

<div
v-if="isInfoLoaded"
v-else
class="pl-2"
>
<ObjectProperties :object-info="objectInfo" />
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/object/ObjectMetadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defineProps<{
</div>
<div>
<DataTable
v-if="objectMetadata"
:value="objectMetadata.metadata"
striped-rows
responsive-layout="scroll"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/object/ObjectTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defineProps<{

<template>
<div
v-if="objectTag.tagset.length"
v-if="objectTag?.tagset?.length"
class="grid"
>
<div class="col-12">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/store/objectStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const useObjectStore = defineStore('objectStore', () => {
async function listObjects(params: any = {}) {
try {
loading.value = true;

objectList.value = [];

// Checks for a users object permissions within the bucket
Expand All @@ -79,6 +78,7 @@ export const useObjectStore = defineStore('objectStore', () => {
const permResponse = (await permissionService.objectSearchPermissions({
userId: currentUser.value.userId,
bucketId: params.bucketId ?? undefined,
objId: params.objId ?? undefined,
bucketPerms: true,
permCode: [Permissions.READ, Permissions.UPDATE, Permissions.DELETE, Permissions.MANAGE]
})).data;
Expand Down

0 comments on commit f6012b2

Please sign in to comment.