aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts
diff options
context:
space:
mode:
authorAhmedEldeeb50 <ahmed.eldeeb.ext@orange.com>2020-07-15 21:58:59 +0200
committerAhmedEldeeb50 <ahmed.eldeeb.ext@orange.com>2020-07-15 21:58:59 +0200
commit296d2bdbaba99d34ce62a8483b5d8d4f90761379 (patch)
treedafa84ac90f98605469e6989f5942f415d509864 /cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts
parent0882e287bbb6aee4543f7659b1f9d001a1b01a1a (diff)
support XML for "Upload Attributes List" button for mapping
Issue-ID: CCSDK-2571 Signed-off-by: AhmedEldeeb50 <ahmed.eldeeb.ext@orange.com> Change-Id: I4164fdef145e92faa2cf2550a036d50273127c6a
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts')
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts
index af7acc2d0..61ea374a3 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts
@@ -10,6 +10,7 @@ import { PackageCreationUtils } from '../../package-creation.utils';
import { JsonConvert, Any } from 'json2typescript';
import { ToastrService } from 'ngx-toastr';
import { SharedService } from '../shared-service';
+import { XmlParser } from '../utils/XmlParser';
declare var $: any;
@Component({
@@ -21,8 +22,8 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy {
@Output() showListView = new EventEmitter<any>();
@Output() showCreationView = new EventEmitter<any>();
public uploadedFiles: FileSystemFileEntry[] = [];
- fileNames: Set<string> = new Set();
- jsonConvert = new JsonConvert();
+ fileNames: Set<string> = new Set();
+ jsonConvert = new JsonConvert();
public files: NgxFileDropEntry[] = [];
fileName: any;
templateInfo = new TemplateInfo();
@@ -132,6 +133,11 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy {
}
}
+ fileExtensionFromString(filename: string): string {
+ const fileExtension = filename.substring(filename.lastIndexOf('.') + 1);
+ return fileExtension;
+ }
+
public getTemplateVariable(fileContent: string) {
const variables: string[] = [];
const stringsSlittedByBraces = fileContent.split('${');
@@ -196,22 +202,26 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy {
uploadFile() {
this.dependancies.clear();
this.dependanciesSource.clear();
- if (this.allowedExt.includes('.csv')) {
- this.fetchCSVkeys();
+ if (this.allowedExt.includes('.csv') || this.allowedExt.includes('.xml')) {
+ this.fetchkeysfromfile();
} else {
this.setTemplateFilesToStore();
}
$('.btn-cancel').click();
-
-
}
- fetchCSVkeys() {
+ fetchkeysfromfile() {
for (const droppedFile of this.uploadedFiles) {
droppedFile.file((file: File) => {
const fileReader = new FileReader();
fileReader.onload = (e) => {
- this.variables = fileReader.result.toString().split(',');
+ const fileExt = this.fileExtensionFromString(droppedFile.name);
+ if (fileExt === 'csv') {
+ this.variables = fileReader.result.toString().split(',');
+ } else {
+ const parser = new XmlParser();
+ this.variables = parser.getVariables(fileReader.result.toString());
+ }
console.log(this.variables);
this.getMappingTableFromTemplate(null);