aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard
diff options
context:
space:
mode:
authorShaabanEltanany <shaaban.eltanany.ext@orange.com>2020-09-30 14:15:33 +0200
committerShaabanEltanany <shaaban.eltanany.ext@orange.com>2020-09-30 14:15:33 +0200
commit586217be2b0fdd4af68c551bca91b6d83cb63991 (patch)
tree63a94260fa282066dd126f1ad9a4284bbd4655ab /cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard
parentdb9eee076faac066ff337193a9211d28cd206711 (diff)
adding save automatic with import
Issue-ID: CCSDK-2842 Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com> Change-Id: I8b87cf0472b2ddd3e05558fe46b8265200eb8f28
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard')
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.html7
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.ts34
2 files changed, 39 insertions, 2 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.html
index 274435cd4..d578582fd 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.html
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.html
@@ -45,9 +45,14 @@
(click)="resetTheUploadedFiles()">Cancel
</button>
<button type="button" class="btn btn-sm btn-primary" [disabled]="uploadedFiles?.length<=0"
- data-dismiss="modal" (click)="openFilesInCreationPackage();saveFileToStore()">
+ data-dismiss="modal" (click)="importAndSave()">
+ Import&Save
+ </button>
+ <button type="button" class="btn btn-sm btn-primary" [disabled]="uploadedFiles?.length<=0"
+ data-dismiss="modal" (click)="importPackageAndViewIt()">
Import
</button>
+
</div>
</div>
</div>
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.ts
index dae58a493..7496338d6 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages-dashboard/import-package/import-package.component.ts
@@ -3,6 +3,10 @@ import {FileSystemFileEntry, NgxFileDropEntry} from 'ngx-file-drop';
import {PackageCreationExtractionService} from '../../package-creation/package-creation-extraction.service';
import {Router} from '@angular/router';
import {PackageCreationStore} from '../../package-creation/package-creation.store';
+import * as JSZip from 'jszip';
+import {PackageCreationService} from '../../package-creation/package-creation.service';
+import {ToastrService} from 'ngx-toastr';
+import {PackagesStore} from '../../packages.store';
@Component({
selector: 'app-import-package',
@@ -14,10 +18,14 @@ export class ImportPackageComponent implements OnInit {
public uploadedFiles: FileSystemFileEntry[] = [];
private fileNames: Set<string> = new Set();
fileToDelete: any = {};
+ zipFile: JSZip = new JSZip();
public files: NgxFileDropEntry[] = [];
constructor(private packageCreationExtractionService: PackageCreationExtractionService,
private packageCreationStore: PackageCreationStore,
+ private packageCreationService: PackageCreationService,
+ private toastService: ToastrService,
+ private packagesStore: PackagesStore,
private router: Router) {
}
@@ -72,7 +80,12 @@ export class ImportPackageComponent implements OnInit {
public fileLeave(event) {
console.log(event);
}
-// TODO mix two function in ond bigger one
+
+ importPackageAndViewIt() {
+ this.openFilesInCreationPackage();
+ this.saveFileToStore();
+ }
+
saveFileToStore() {
console.log(this.uploadedFiles.length);
const file = this.getFile(this.uploadedFiles[this.uploadedFiles.length - 1]);
@@ -91,4 +104,23 @@ export class ImportPackageComponent implements OnInit {
console.log(err);
}
}
+
+ importAndSave() {
+ const file = this.getFile(this.uploadedFiles[this.uploadedFiles.length - 1]);
+ this.zipFile = new JSZip();
+ this.zipFile.loadAsync(file).then(zip => {
+ this.zipFile = zip;
+ console.log(this.zipFile);
+ this.resetTheUploadedFiles();
+ this.zipFile.generateAsync({type: 'blob'}).then(blob => {
+ this.packageCreationService.savePackage(blob).subscribe(
+ bluePrintDetailModels => {
+ this.toastService.info('package is imported and saved successfully ');
+ this.router.navigate(['/packages']);
+ this.packagesStore.getAll();
+ }, error =>
+ this.toastService.error('there is an error happened ' + error));
+ });
+ });
+ }
}