From e0e8b14e106cff2dccc76e6edcc1a7ee6ffe10da Mon Sep 17 00:00:00 2001 From: shaaban Altanany Date: Mon, 17 Feb 2020 11:49:41 +0200 Subject: adding template and mapping import template files Issue-ID: CCSDK-2102 Signed-off-by: shaaban Altanany Change-Id: I38260328f868f146dbdd16f0da8f26bbb1504c29 --- .../templ-mapp-creation.component.ts | 67 +++++++++++++++++++--- 1 file changed, 60 insertions(+), 7 deletions(-) (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts') 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 3a938c5ae..752bd510b 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 @@ -1,15 +1,68 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, EventEmitter, OnInit, Output} from '@angular/core'; +import {FileSystemFileEntry, NgxFileDropEntry} from 'ngx-file-drop'; +import {PackageCreationStore} from '../../package-creation.store'; @Component({ - selector: 'app-templ-mapp-creation', - templateUrl: './templ-mapp-creation.component.html', - styleUrls: ['./templ-mapp-creation.component.css'] + selector: 'app-templ-mapp-creation', + templateUrl: './templ-mapp-creation.component.html', + styleUrls: ['./templ-mapp-creation.component.css'] }) export class TemplMappCreationComponent implements OnInit { - constructor() { } + public uploadedFiles: FileSystemFileEntry[] = []; + private fileNames: Set = new Set(); - ngOnInit() { - } + public files: NgxFileDropEntry[] = []; + fileName: any; + constructor(private packageCreationStore: PackageCreationStore) { + } + + ngOnInit() { + } + + public dropped(files: NgxFileDropEntry[]) { + this.files = files; + for (const droppedFile of files) { + // Is it a file? & Not added before + if (droppedFile.fileEntry.isFile && !this.fileNames.has(droppedFile.fileEntry.name)) { + const fileEntry = droppedFile.fileEntry as FileSystemFileEntry; + this.uploadedFiles.push(fileEntry); + this.fileNames.add(fileEntry.name); + + } + } + } + + removeFile(fileIndex: number) { + /*const filename = 'Definitions/' + this.uploadedFiles[fileIndex].name; + this.packageCreationStore.removeFileFromDefinition(filename); + this.uploadedFiles.splice(fileIndex, 1);*/ + } + + setFilesToStore() { + for (const droppedFile of this.uploadedFiles) { + droppedFile.file((file: File) => { + const fileReader = new FileReader(); + fileReader.onload = (e) => { + this.packageCreationStore.addTemplate('Templates/' + this.fileName, + fileReader.result.toString()); + }; + fileReader.readAsText(file); + }); + + } + } + + public fileOver(event) { + console.log(event); + } + + public fileLeave(event) { + console.log(event); + } + + resetTheUploadedFiles() { + this.uploadedFiles = []; + } } -- cgit 1.2.3-korg