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 20, 2023
1 parent 3fccaf5 commit 37ae9f5
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 27 deletions.
11 changes: 2 additions & 9 deletions .github/environments/values.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ 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_EXCLUDE_TAGSET: coms-id
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
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
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: ~
10 changes: 5 additions & 5 deletions frontend/src/services/objectService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { comsAxios } from './interceptors';
import { s3MetaTagExclude, setDispositionHeader } from '@/utils/utils';
import { excludeMetaTag, setDispositionHeader } from '@/utils/utils';
import ConfigService from './configService';

import type { AxiosRequestConfig } from 'axios';
Expand Down Expand Up @@ -105,7 +105,7 @@ export default {
return comsAxios().get(`${PATH}/metadata`, { headers: headers, params: params })
// filter out metadata and return as a promise again
.then((response) => {
return s3MetaTagExclude('metadata', response);
return { data: excludeMetaTag('metadata', response.data) };
});
},

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

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

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

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

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

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

Expand All @@ -28,7 +28,7 @@ export default {
return comsAxios().get(`${PATH}/tagging`, { params: params })
// filter out a configured list of select tags
.then((response) => {
return s3MetaTagExclude('tagset', response);
return { data: excludeMetaTag('tagset', response.data) };
});
},
};
11 changes: 5 additions & 6 deletions frontend/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,24 @@ 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
* @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: string, data: any){
// 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(',') ?? [];
// filter COMS data
const filtered = axiosResponse.data.map((obj:any) => {
return data.map((obj: any) => {
return {
...obj,
[type]: obj[type]?.filter((el:any) => {
[type]: obj[type]?.filter((el: any) => {
return !excludeArray.includes(el.key);
})
};
});
return { data: filtered };
}

/**
Expand Down

0 comments on commit 37ae9f5

Please sign in to comment.