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/TemplateType.ts | 5 ++ .../templ-mapp-creation.component.html | 58 +++++++++++-------- .../templ-mapp-creation.component.ts | 67 +++++++++++++++++++--- .../templ-mapp-listing.component.html | 14 ++--- .../templ-mapp-listing.component.ts | 31 ++++++---- 5 files changed, 125 insertions(+), 50 deletions(-) create mode 100644 cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/TemplateType.ts (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping') diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/TemplateType.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/TemplateType.ts new file mode 100644 index 000000000..17a4bfae6 --- /dev/null +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/TemplateType.ts @@ -0,0 +1,5 @@ +export enum TemplateType { + Velocity = 'vtl', + Koltin = 'kt', + Jinja = 'Unknown' +} diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html index 10f1db65d..3c92bc7c7 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.html @@ -4,9 +4,9 @@ - +
- +
@@ -17,7 +17,7 @@
@@ -30,29 +30,35 @@
-
Use the editor to add parameters or you can also Import File
+
Use the editor to add parameters or you can also Import + File
@@ -63,7 +69,7 @@
@@ -74,12 +80,12 @@
- +
- + - +
@@ -111,7 +117,7 @@ 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 = []; + } } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html index a0a54031f..ddf06c824 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.html @@ -19,15 +19,15 @@
\ No newline at end of file + diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts index 525e58128..5cb41c35e 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-listing/templ-mapp-listing.component.ts @@ -1,20 +1,29 @@ -import { Component, OnInit, Output, EventEmitter } from '@angular/core'; +import {Component, EventEmitter, OnInit, Output} from '@angular/core'; +import {PackageCreationStore} from '../../package-creation.store'; +import {Template} from '../../mapping-models/CBAPacakge.model'; @Component({ - selector: 'app-templ-mapp-listing', - templateUrl: './templ-mapp-listing.component.html', - styleUrls: ['./templ-mapp-listing.component.css'] + selector: 'app-templ-mapp-listing', + templateUrl: './templ-mapp-listing.component.html', + styleUrls: ['./templ-mapp-listing.component.css'] }) export class TemplMappListingComponent implements OnInit { - @Output() showCreationViewParentNotification = new EventEmitter(); + @Output() showCreationViewParentNotification = new EventEmitter(); + private templates: Template; - constructor() { } + constructor(private packageCreationStore: PackageCreationStore) { + this.packageCreationStore.state$.subscribe(cba => { + if (cba.templates) { + this.templates = cba.templates; + } + }); + } - ngOnInit() { - } + ngOnInit() { + } - openCreationView() { - this.showCreationViewParentNotification.emit('tell parent to open create views'); - } + openCreationView() { + this.showCreationViewParentNotification.emit('tell parent to open create views'); + } } -- cgit 1.2.3-korg