From 077b1ab152c61695ac4d007035dfb81e9aef2c61 Mon Sep 17 00:00:00 2001 From: shaaban Altanany Date: Sun, 5 Jan 2020 12:03:05 +0200 Subject: add importTab component in package creation Issue-ID: CCSDK-2016 Signed-off-by: shaaban Altanany Change-Id: I828f9891863224cd3c70dbcaf1149efdff394c6e --- cds-ui/designer-client/src/app/app.module.ts | 2 + .../imports-tab/imports-tab.component.css | 0 .../imports-tab/imports-tab.component.html | 23 +++++++++++ .../imports-tab/imports-tab.component.spec.ts | 25 ++++++++++++ .../imports-tab/imports-tab.component.ts | 46 ++++++++++++++++++++++ .../mapping-models/CBAPacakge.model.ts | 13 +++++- .../package-creation.component.html | 1 + .../package-creation/package-creation.component.ts | 4 +- .../package-creation/package-creation.store.ts | 23 ++++++----- .../feature-modules/packages/packages.module.ts | 5 ++- 10 files changed, 128 insertions(+), 14 deletions(-) create mode 100644 cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.css create mode 100644 cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.html create mode 100644 cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.spec.ts create mode 100644 cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.ts (limited to 'cds-ui/designer-client/src/app') diff --git a/cds-ui/designer-client/src/app/app.module.ts b/cds-ui/designer-client/src/app/app.module.ts index 20b9b4d7b..9817edf70 100644 --- a/cds-ui/designer-client/src/app/app.module.ts +++ b/cds-ui/designer-client/src/app/app.module.ts @@ -33,6 +33,7 @@ import {HttpClientModule} from '@angular/common/http'; import {PackagesModule} from './modules/feature-modules/packages/packages.module'; import { SidebarModule } from 'ng-sidebar'; import {SharedModulesModule} from './modules/shared-modules/shared-modules.module'; +import { NgxFileDropModule } from 'ngx-file-drop'; @NgModule({ declarations: [ @@ -48,6 +49,7 @@ import {SharedModulesModule} from './modules/shared-modules/shared-modules.modul HttpClientModule, PackagesModule, SharedModulesModule, + NgxFileDropModule, ], providers: [ApiService], diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.css b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.html new file mode 100644 index 000000000..fc1015ca0 --- /dev/null +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.html @@ -0,0 +1,23 @@ +
+ + gi + Optional custom content that replaces the the entire default content. + + + +
+ + + + + + + + + + + +
Name
{{ item.relativePath }}
+
+
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.spec.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.spec.ts new file mode 100644 index 000000000..a51a83a13 --- /dev/null +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ImportsTabComponent } from './imports-tab.component'; + +describe('ImportsTabComponent', () => { + let component: ImportsTabComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ ImportsTabComponent ] + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(ImportsTabComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.ts new file mode 100644 index 000000000..8aa9d5e6d --- /dev/null +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.ts @@ -0,0 +1,46 @@ +import {Component, OnInit} from '@angular/core'; +import {NgxFileDropEntry, FileSystemFileEntry, FileSystemDirectoryEntry} from 'ngx-file-drop'; +import {PackageCreationStore} from '../package-creation.store'; + + +@Component({ + selector: 'app-imports-tab', + templateUrl: './imports-tab.component.html', + styleUrls: ['./imports-tab.component.css'] +}) +export class ImportsTabComponent { + constructor(private packageCreationStore: PackageCreationStore) { + } + + public files: NgxFileDropEntry[] = []; + + public dropped(files: NgxFileDropEntry[]) { + this.files = files; + for (const droppedFile of files) { + + // Is it a file? + if (droppedFile.fileEntry.isFile) { + const fileEntry = droppedFile.fileEntry as FileSystemFileEntry; + fileEntry.file((file: File) => { + console.log(droppedFile.relativePath, file); + this.packageCreationStore.addDefinition(droppedFile.relativePath, ''); + + }); + } else { + // It was a directory (empty directories are added, otherwise only files) + const fileEntry = droppedFile.fileEntry as FileSystemDirectoryEntry; + console.log(droppedFile.relativePath, fileEntry); + this.packageCreationStore.addDefinition(droppedFile.relativePath, ''); + + } + } + } + + public fileOver(event) { + console.log(event); + } + + public fileLeave(event) { + console.log(event); + } +} diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts index f92d58f89..7b6743f6a 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/mapping-models/CBAPacakge.model.ts @@ -1,13 +1,22 @@ import {Metadata} from './definitions/VlbDefinition'; -class Definition { +export class Definition { + public files: Map = new Map(); + constructor(files: Map) { + this.files = files; + } } -export class CBAPacakge { +export class CBAPackage { public metaData: Metadata; public definitions: Definition; + constructor() { + this.definitions = new Definition(new Map()); + this.metaData = new Metadata(); + } + } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.html index 2f3e4a053..1f5245222 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.html +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.html @@ -45,3 +45,4 @@ + diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts index 6ba91d76d..440f2e23b 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts @@ -160,8 +160,8 @@ export class PackageCreationComponent implements OnInit { searchPackages($event: Event) { - const searchQuery = event.target.value; + /* const searchQuery = event.target.value; searchQuery = searchQuery.trim(); - this.packagesStore.search(searchQuery); + this.packagesStore.search(searchQuery);*/ } } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts index 9a7484cc3..214b516a2 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts @@ -21,23 +21,20 @@ limitations under the License. import {Injectable} from '@angular/core'; -import {Observable} from 'rxjs'; -import {ApiService} from '../../../../common/core/services/api.service'; -import {BlueprintURLs} from '../../../../common/constants/app-constants'; import {Store} from '../../../../common/core/stores/Store'; -import {PackagesDashboardState} from '../model/packages-dashboard.state'; -import {PackagesApiService} from '../packages-api.service'; -import {CBAPacakge} from './mapping-models/CBAPacakge.model'; + +import {CBAPackage, Definition} from './mapping-models/CBAPacakge.model'; import {Metadata} from './mapping-models/definitions/VlbDefinition'; -import {BluePrintPage} from '../model/BluePrint.model'; +import {PackageCreationService} from './package-creation.service'; + @Injectable({ providedIn: 'root' }) -export class PackageCreationService extends Store { +export class PackageCreationStore extends Store { constructor(private packageCreationService: PackageCreationService) { - super(new CBAPacakge()); + super(new CBAPackage()); } changeMetaData(metaDataObject: Metadata) { @@ -47,4 +44,12 @@ export class PackageCreationService extends Store { metaData: metaDataObject }); } + + addDefinition(name: string, content: string) { + + this.setState({ + ...this.state, + definitions: new Definition(this.state.definitions.files.set(name, content)) + }); + } } diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages.module.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages.module.ts index ac251ffaa..3bd2019ad 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages.module.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/packages.module.ts @@ -18,7 +18,8 @@ import {FunctionsComponent} from './designer/functions/functions.component'; import {ActionsComponent} from './designer/actions/actions.component'; import {PackageCreationComponent} from './package-creation/package-creation.component'; import {FormsModule} from '@angular/forms'; - +import { ImportsTabComponent } from './package-creation/imports-tab/imports-tab.component'; +import { NgxFileDropModule } from 'ngx-file-drop'; @NgModule({ declarations: [PackagesDashboardComponent, @@ -33,6 +34,7 @@ import {FormsModule} from '@angular/forms'; FunctionsComponent, ActionsComponent, PackageCreationComponent, + ImportsTabComponent, ], imports: [ CommonModule, @@ -41,6 +43,7 @@ import {FormsModule} from '@angular/forms'; SharedModulesModule, SidebarModule.forRoot(), FormsModule, + NgxFileDropModule, ], providers: [ApiService, JsonPipe], bootstrap: [] -- cgit 1.2.3-korg