Tags
diff --git a/frontend/src/services/objectService.ts b/frontend/src/services/objectService.ts
index 30914f18..0d370f3a 100644
--- a/frontend/src/services/objectService.ts
+++ b/frontend/src/services/objectService.ts
@@ -1,9 +1,10 @@
-import { comsAxios } from './interceptors';
-import { 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';
@@ -102,7 +103,9 @@ export default {
getMetadata(headers: any = {}, params: GetMetadataOptions = {}) {
// 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 });
+ return comsAxios().get(`${PATH}/metadata`, { headers: headers, params: params })
+ // filter out a configured list of select metadata
+ .then((response) => ({ data: excludeMetaTag(ExcludeTypes.METADATA, response.data) }));
},
/**
@@ -112,7 +115,9 @@ export default {
* @returns {Promise} An axios response
*/
getObjectTagging(params: GetObjectTaggingOptions = {}) {
- return comsAxios().get(`${PATH}/tagging`, { params: params });
+ return comsAxios().get(`${PATH}/tagging`, { params: params })
+ // filter out a configured list of select tags
+ .then((response) => ({ data: excludeMetaTag(ExcludeTypes.TAGSET, response.data) }));
},
/**
@@ -215,7 +220,9 @@ export default {
...Object.fromEntries((headers.metadata.map((x: { key: string; value: string }) => ([x.key, x.value]))))
};
}
- return comsAxios().get(`${PATH}/metadata`, config);
+ return comsAxios().get(`${PATH}/metadata`, config)
+ // filter out a configured list of select metadata
+ .then((response) => ({ data: excludeMetaTag(ExcludeTypes.METADATA, response.data)}));
},
/**
@@ -287,7 +294,9 @@ export default {
params: {
tagset: Object.fromEntries((tagset.map((x: { key: string; value: string }) => ([x.key, x.value]))))
}
- });
+ })
+ // filter out a configured list of select tags
+ .then((response) => ({ data: excludeMetaTag(ExcludeTypes.TAGSET, response.data)}));
},
/**
diff --git a/frontend/src/services/versionService.ts b/frontend/src/services/versionService.ts
index 4c504a45..6882237a 100644
--- a/frontend/src/services/versionService.ts
+++ b/frontend/src/services/versionService.ts
@@ -1,6 +1,8 @@
import { comsAxios } from './interceptors';
+import { excludeMetaTag } from '@/utils/utils';
import type { GetVersionMetadataOptions, GetVersionTaggingOptions } from '@/types';
+import { ExcludeTypes } from '@/utils/enums';
const PATH = '/version';
@@ -11,7 +13,9 @@ export default {
* @returns {Promise} An axios response
*/
getMetadata(headers: any = {}, params: GetVersionMetadataOptions) {
- return comsAxios().get(`${PATH}/metadata`, { headers: headers, params: params });
+ return comsAxios().get(`${PATH}/metadata`, { headers: headers, params: params })
+ // filter out a configured list of select metadata
+ .then((response) => ({ data: excludeMetaTag(ExcludeTypes.METADATA, response.data) }));
},
/**
@@ -20,6 +24,8 @@ export default {
* @returns {Promise} An axios response
*/
getObjectTagging(params: GetVersionTaggingOptions) {
- return comsAxios().get(`${PATH}/tagging`, { params: params });
+ return comsAxios().get(`${PATH}/tagging`, { params: params })
+ // filter out a configured list of select tags
+ .then((response) => ({ data: excludeMetaTag(ExcludeTypes.TAGSET, response.data) }));
},
};
diff --git a/frontend/src/utils/enums.ts b/frontend/src/utils/enums.ts
index 066e3602..3a82e999 100644
--- a/frontend/src/utils/enums.ts
+++ b/frontend/src/utils/enums.ts
@@ -6,3 +6,8 @@ export enum ButtonMode {
BUTTON = 'BUTTON',
ICON = 'ICON',
}
+
+export enum ExcludeTypes {
+ METADATA = 'metadata',
+ TAGSET = 'tagset',
+}
diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts
index 14afd869..789baedf 100644
--- a/frontend/src/utils/utils.ts
+++ b/frontend/src/utils/utils.ts
@@ -1,4 +1,6 @@
import { DELIMITER } from '@/utils/constants';
+import ConfigService from '@/services/configService';
+import { ExcludeTypes } from '@/utils/enums';
/**
* @function differential
@@ -63,6 +65,31 @@ export function partition(
);
}
+/**
+ * @function excludeMetaTag
+ * Filter out a configured list of select metadata or tags from a COMS response
+ * @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 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().exclude?.[type]?.split(',').map((s: string) => s.trim()) ?? [];
+ // filter COMS data
+ return data.map((obj: any) => {
+ return {
+ ...obj,
+ [type]: obj[type]?.filter((el: any) => !excludeArray.includes(el.key))
+ };
+ });
+}
+
/**
* @function setDispositionHeader
* Constructs a valid RFC 6266 'Content-Disposition' header