Skip to content

Commit

Permalink
Assign excluded meta/tags in comma-separated list
Browse files Browse the repository at this point in the history
  • Loading branch information
TimCsaky committed Oct 24, 2023
1 parent 8473950 commit 569ebe8
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 54 deletions.
1 change: 1 addition & 0 deletions .github/environments/values.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config:
configMap:
FRONTEND_APIPATH: api/v1
FRONTEND_COMS_APIPATH: https://coms-dev.api.gov.bc.ca/api/v1
FRONTEND_EXCLUDE_METADATA: geodrive.common.encoding,geodrive.windows.attr,geodrive.windows.secdesc,s3b-last-modified
FRONTEND_NOTIFICATION_BANNER : This is the DEV environment of BCBox. Uploaded files may not persist and may be deleted from the COMS database as we continue development. Please do not upload personal or private information. Thank you for your understanding as we work to improve BCBox
FRONTEND_OIDC_AUTHORITY: https://dev.loginproxy.gov.bc.ca/auth/realms/standard
FRONTEND_OIDC_CLIENTID: bc-box-4555
Expand Down
10 changes: 1 addition & 9 deletions .github/environments/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,9 @@ config:
configMap:
FRONTEND_APIPATH: api/v1
FRONTEND_COMS_APIPATH: https://coms.api.gov.bc.ca/api/v1
FRONTEND_EXCLUDE_METADATA: geodrive.common.encoding,geodrive.windows.attr,geodrive.windows.secdesc,s3b-last-modified
FRONTEND_OIDC_AUTHORITY: https://loginproxy.gov.bc.ca/auth/realms/standard
FRONTEND_OIDC_CLIENTID: bc-box-4555
FRONTEND_S3METATAG_EXCLUDE:
metadata:
- geodrive.common.encoding
- geodrive.windows.attr
- geodrive.windows.secdesc
- s3b-last-modified
- sha256
tagset:
- coms-id
SERVER_APIPATH: /api/v1
SERVER_BODYLIMIT: 30mb
# SERVER_LOGFILE: ~
Expand Down
1 change: 1 addition & 0 deletions .github/environments/values.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config:
configMap:
FRONTEND_APIPATH: api/v1
FRONTEND_COMS_APIPATH: https://coms-test.api.gov.bc.ca/api/v1
FRONTEND_EXCLUDE_METADATA: geodrive.common.encoding,geodrive.windows.attr,geodrive.windows.secdesc,s3b-last-modified
FRONTEND_NOTIFICATION_BANNER: This is the TEST environment of BCBox. Uploaded files may not persist and may be deleted from the COMS database as we continue development. Please do not upload personal or private information. Thank you for your understanding as we work to improve BCBox
FRONTEND_OIDC_AUTHORITY: https://test.loginproxy.gov.bc.ca/auth/realms/standard
FRONTEND_OIDC_CLIENTID: bc-box-4555
Expand Down
7 changes: 5 additions & 2 deletions app/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
"coms": {
"apiPath": "FRONTEND_COMS_APIPATH"
},
"exclude": {
"metadata": "FRONTEND_EXCLUDE_METADATA",
"tagset": "FRONTEND_EXCLUDE_TAGSET"
},
"notificationBanner": "FRONTEND_NOTIFICATION_BANNER",
"oidc": {
"authority": "FRONTEND_OIDC_AUTHORITY",
"clientId": "FRONTEND_OIDC_CLIENTID"
},
"s3MetaTagExclude": "FRONTEND_S3METATAG_EXCLUDE"
}
},
"server": {
"apiPath": "SERVER_APIPATH",
Expand Down
5 changes: 4 additions & 1 deletion app/config/default.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"frontend": {
"apiPath": "api/v1"
"apiPath": "api/v1",
"exclude": {
"tagset": "coms-id"
}
},
"server": {
"apiPath": "/api/v1",
Expand Down
2 changes: 1 addition & 1 deletion charts/bcbox/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ maintainers:
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.5.0"
appVersion: "0.4.0"
deprecated: false
annotations: {}
3 changes: 2 additions & 1 deletion charts/bcbox/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ config:
configMap:
FRONTEND_APIPATH: "api/v1"
FRONTEND_COMS_APIPATH: ~
# FRONTEND_EXCLUDE_METADATA: ~
# FRONTEND_EXCLUDE_TAGSET: ~
# FRONTEND_NOTIFICATION_BANNER: ~
FRONTEND_OIDC_AUTHORITY: ~
FRONTEND_OIDC_CLIENTID: ~
Expand All @@ -122,4 +124,3 @@ config:
# SERVER_LOGFILE: ~
SERVER_LOGLEVEL: "http"
SERVER_PORT: "8080"
# FRONTEND_S3METATAG_EXCLUDE: ~
5 changes: 1 addition & 4 deletions frontend/src/components/object/ObjectMetadata.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ watch([props, tsGetMetadata,vsGetMetadata] , () => {
</script>

<template>
<div
v-if="objectMetadata?.metadata.length"
class="grid details-grid grid-nogutter mb-2"
>
<div class="grid details-grid grid-nogutter mb-2">
<div class="col-12">
<h2>
Metadata
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/components/object/ObjectTag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ watch( [props, tsGetTagging, vsGetTagging], () => {
</script>

<template>
<div
v-if="objectTagging?.tagset.length"
class="grid details-grid grid-nogutter mb-2"
>
<div class="grid details-grid grid-nogutter mb-2">
<div class="col-12">
<h2>
Tags
Expand Down
23 changes: 8 additions & 15 deletions frontend/src/services/objectService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { comsAxios } from './interceptors';
import { s3MetaTagExclude, setDispositionHeader } from '@/utils/utils';
import ConfigService from './configService';
import { comsAxios } from './interceptors';
import { excludeMetaTag, setDispositionHeader } from '@/utils/utils';

import type { AxiosRequestConfig } from 'axios';
import type { GetMetadataOptions, GetObjectTaggingOptions, MetadataPair, SearchObjectsOptions, Tag } from '@/types';
import { ExcludeTypes } from '@/utils/enums';

const PATH = '/object';

Expand Down Expand Up @@ -103,10 +104,8 @@ export default {
// remove objectId array if its first element is undefined
if (params.objectId && params.objectId[0] === undefined) delete params.objectId;
return comsAxios().get(`${PATH}/metadata`, { headers: headers, params: params })
// filter out metadata and return as a promise again
.then((response) => {
return s3MetaTagExclude('metadata', response);
});
// filter out a configured list of select metadata
.then((response) => ({ data: excludeMetaTag(ExcludeTypes.METADATA, response.data) }));
},

/**
Expand All @@ -118,9 +117,7 @@ export default {
getObjectTagging(params: GetObjectTaggingOptions = {}) {
return comsAxios().get(`${PATH}/tagging`, { params: params })
// filter out a configured list of select tags
.then((response) => {
return s3MetaTagExclude('tagset', response);
});
.then((response) => ({ data: excludeMetaTag(ExcludeTypes.TAGSET, response.data) }));
},

/**
Expand Down Expand Up @@ -225,9 +222,7 @@ export default {
}
return comsAxios().get(`${PATH}/metadata`, config)
// filter out a configured list of select metadata
.then((response) => {
return s3MetaTagExclude('metadata', response);
});
.then((response) => ({ data: excludeMetaTag(ExcludeTypes.METADATA, response.data)}));
},

/**
Expand Down Expand Up @@ -301,9 +296,7 @@ export default {
}
})
// filter out a configured list of select tags
.then((response) => {
return s3MetaTagExclude('tagset', response);
});
.then((response) => ({ data: excludeMetaTag(ExcludeTypes.TAGSET, response.data)}));
},

/**
Expand Down
11 changes: 4 additions & 7 deletions frontend/src/services/versionService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { comsAxios } from './interceptors';
import { s3MetaTagExclude } from '@/utils/utils';
import { excludeMetaTag } from '@/utils/utils';

import type { GetVersionMetadataOptions, GetVersionTaggingOptions } from '@/types';
import { ExcludeTypes } from '@/utils/enums';

const PATH = '/version';

Expand All @@ -14,9 +15,7 @@ export default {
getMetadata(headers: any = {}, params: GetVersionMetadataOptions) {
return comsAxios().get(`${PATH}/metadata`, { headers: headers, params: params })
// filter out a configured list of select metadata
.then((response) => {
return s3MetaTagExclude('metadata', response);
});
.then((response) => ({ data: excludeMetaTag(ExcludeTypes.METADATA, response.data) }));
},

/**
Expand All @@ -27,8 +26,6 @@ export default {
getObjectTagging(params: GetVersionTaggingOptions) {
return comsAxios().get(`${PATH}/tagging`, { params: params })
// filter out a configured list of select tags
.then((response) => {
return s3MetaTagExclude('tagset', response);
});
.then((response) => ({ data: excludeMetaTag(ExcludeTypes.TAGSET, response.data) }));
},
};
5 changes: 5 additions & 0 deletions frontend/src/utils/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ export enum ButtonMode {
BUTTON = 'BUTTON',
ICON = 'ICON',
}

export enum ExcludeTypes {
METADATA = 'metadata',
TAGSET = 'tagset',
}
24 changes: 14 additions & 10 deletions frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DELIMITER } from '@/utils/constants';
import ConfigService from '@/services/configService';
import { ExcludeTypes } from '@/utils/enums';

/**
* @function differential
Expand Down Expand Up @@ -65,25 +66,28 @@ export function partition<T>(
}

/**
* @function s3MetaTagExclude
* @function excludeMetaTag
* Filter out a configured list of select metadata or tags from a COMS response
* @param {object} type either 'metadata' or 'tagset'
* @param {object} axiosResponse A resolved axios response from COMS
* @param {string} type either 'metadata' or 'tagset'
* @param {object} data An object with metadata/tags from COMS
* @returns {object} The response data with select metadata/tags from a configured list removed
*/
export function s3MetaTagExclude(type: string, axiosResponse: { data: any }){
export function excludeMetaTag(type: ExcludeTypes, data: [{
objectId: string,
metadata?: Array<{ key: string; value: string }>,
tagset?: Array<{ key: string; value: string }>
}]){
// TODO: consider unit testing this function
// array of selected tags/metadata (keys) to hide from UI
const excludeArray = new ConfigService().getConfig().s3MetaTagExclude?.[type] ?? [];
const excludeArray = new ConfigService()
.getConfig().exclude?.[type]?.split(',').map((s: string) => s.trim()) ?? [];
// filter COMS data
const filtered = axiosResponse.data.map((obj:any) => {
return data.map((obj: any) => {
return {
...obj,
[type]: obj[type]?.filter((el:any) => {
return !excludeArray.includes(el.key);
})
[type]: obj[type]?.filter((el: any) => !excludeArray.includes(el.key))
};
});
return { data: filtered };
}

/**
Expand Down

0 comments on commit 569ebe8

Please sign in to comment.