aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab
diff options
context:
space:
mode:
authorAhmed <ahmed.eldeeb.ext@orange.com>2020-03-03 15:29:38 +0200
committerKAPIL SINGAL <ks220y@att.com>2020-03-06 16:23:50 +0000
commit88929cf6c21023328644fc637627371733b085d8 (patch)
tree3a097e24a3f7d0ac3a23c2f1ac275b6e12aaa3f1 /cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab
parentfdfeef7ae2f543553e2f7a7cf322b6d075599e20 (diff)
Fixing some bugs in package creation tabs
Issue-ID: CCSDK-2123 Signed-off-by: Ahmed <ahmed.eldeeb.ext@orange.com> Change-Id: Id7a457470b14ab3491d4e6b9bdd74ef93990dd2c
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab')
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html3
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts47
2 files changed, 30 insertions, 20 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html
index 8d1894c57..5dd68ed72 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.html
@@ -24,7 +24,8 @@
aria-expanded="false" class="btn btn-link collapsed" data-toggle="collapse">
<i class="icon-file-code"></i> {{file.key}}
</button>
- <a (click)="removeFile(mapIndex)" class="accordion-delete"><i class="icon-delete"></i></a>
+ <a (click)="removeFile(file.key,mapIndex)" class="accordion-delete"><i
+ class="icon-delete"></i></a>
</h5>
</div>
<div [attr.aria-labelledby]="'head-script-'+mapIndex" [id]="'id-script-'+mapIndex" class="collapse"
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts
index 36cccc88c..5387489a2 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/scripts-tab/scripts-tab.component.ts
@@ -1,6 +1,6 @@
-import {Component, OnInit} from '@angular/core';
-import {FileSystemFileEntry, NgxFileDropEntry} from 'ngx-file-drop';
-import {PackageCreationStore} from '../package-creation.store';
+import { Component, OnInit } from '@angular/core';
+import { FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop';
+import { PackageCreationStore } from '../package-creation.store';
import 'ace-builds/src-noconflict/ace';
import 'ace-builds/webpack-resolver';
@@ -18,9 +18,7 @@ export class ScriptsTabComponent implements OnInit {
constructor(
private packageCreationStore: PackageCreationStore,
- ) {
-
- }
+ ) { }
ngOnInit() {
@@ -29,13 +27,6 @@ export class ScriptsTabComponent implements OnInit {
this.scriptsFiles = cbaPackage.scripts.files;
}
});
-
- /* this.packageStore.state$.subscribe(res => {
- // this.scriptsFiles =
- console.log('from scripts');
- console.log(res.scripts);
- this.scriptsFiles = res.scripts.files;
- });*/
}
public dropped(files: NgxFileDropEntry[]) {
@@ -52,11 +43,18 @@ export class ScriptsTabComponent implements OnInit {
}
}
- removeFile(fileIndex: number) {
- console.log(this.uploadedFiles[fileIndex]);
- const filename = 'Scripts/' + this.uploadedFiles[fileIndex].name;
- this.packageCreationStore.removeFileFromState(filename);
- this.uploadedFiles.splice(fileIndex, 1);
+ removeFile(filePath: string, FileIndex: number) {
+ const filename = filePath.split('/')[2] || '';
+ // const filename = 'Scripts/' + this.getFileType(this.uploadedFiles[fileIndex].name) + '/' + this.uploadedFiles[fileIndex].name;
+ this.packageCreationStore.removeFileFromState(filePath);
+ // remove from upload files array
+ // tslint:disable-next-line: prefer-for-of
+ for (let i = 0; i < this.uploadedFiles.length; i++) {
+ if (this.uploadedFiles[i].name === filename) {
+ this.uploadedFiles.splice(i, 1);
+ break;
+ }
+ }
}
public fileOver(event) {
@@ -73,7 +71,7 @@ export class ScriptsTabComponent implements OnInit {
droppedFile.file((file: File) => {
const fileReader = new FileReader();
fileReader.onload = (e) => {
- this.packageCreationStore.addScripts('Scripts/' + droppedFile.name,
+ this.packageCreationStore.addScripts('Scripts/' + this.getFileType(droppedFile.name) + '/' + droppedFile.name,
fileReader.result.toString());
};
fileReader.readAsText(file);
@@ -82,6 +80,17 @@ export class ScriptsTabComponent implements OnInit {
}
}
+ getFileType(filename: string): string {
+ let fileType = '';
+ const fileExtension = filename.substring(filename.lastIndexOf('.') + 1);
+ if (fileExtension === 'py') {
+ fileType = 'python';
+ } else if (fileExtension === 'kt') {
+ fileType = 'kotlin';
+ }
+ return fileType;
+ }
+
resetTheUploadedFiles() {
this.uploadedFiles = [];
}