summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/utils/file-utils.ts
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2022-06-02 10:46:40 +0100
committerMichael Morris <michael.morris@est.tech>2022-06-24 13:17:23 +0000
commit363d9a6fea48bf6f34e4f1d4ecb37d33812c7626 (patch)
tree6d5023023b0f93346ed40e62f6cf3f4bc23792b9 /catalog-ui/src/app/utils/file-utils.ts
parent2dcfb0996a8345de5c8be73a5600ee995309664a (diff)
Service Import - Read metadata from csar
Also exports metadata to the tosca template and fixes service metadata not being set when the create button is clicked Issue-ID: SDC-4044 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I6f8428d9ed385335c05e7b994e622229ea00342b
Diffstat (limited to 'catalog-ui/src/app/utils/file-utils.ts')
-rw-r--r--catalog-ui/src/app/utils/file-utils.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/catalog-ui/src/app/utils/file-utils.ts b/catalog-ui/src/app/utils/file-utils.ts
index d726736bd4..4b6f330354 100644
--- a/catalog-ui/src/app/utils/file-utils.ts
+++ b/catalog-ui/src/app/utils/file-utils.ts
@@ -66,6 +66,24 @@ export class FileUtils {
"cancelable": true
});
downloadLink.dispatchEvent(clickEvent);
+ }
+ public getEntryDefinitionFileNameFromCsarBlob = (csarBlob:Blob):Promise<any> => {
+ let JSZip = require("jszip");
+ return JSZip.loadAsync(csarBlob).then(zip => {
+ return zip.file("TOSCA-Metadata/TOSCA.meta").async("string");
+ }).then((toscaMetaData: string) => {
+ let fileEntities:Array<string> = toscaMetaData.replace("\r", "").split("\n");
+ let entryDefinitionFilename:string = fileEntities.find(element => !element.search("Entry-Definitions"))
+ .replace("Entry-Definitions:", "").trim();
+ return entryDefinitionFilename;
+ });
+ }
+
+ public getFileNameDataFromCsarBlob = (csarBlob:Blob, fileName:string):Promise<any> => {
+ let JSZip = require("jszip");
+ return JSZip.loadAsync(csarBlob).then(zip => {
+ return zip.file(fileName).async("string");
+ });
}
}