diff options
author | shaaban Altanany <shaaban.eltanany.ext@orange.com> | 2020-01-05 12:03:05 +0200 |
---|---|---|
committer | shaaban Altanany <shaaban.eltanany.ext@orange.com> | 2020-01-05 14:30:43 +0200 |
commit | 077b1ab152c61695ac4d007035dfb81e9aef2c61 (patch) | |
tree | 62d9d465e0273be7d5c57127ed9afb6389303ca9 /cds-ui | |
parent | 4f4e2de08d3c6259da2497950a96d549d3e82f8a (diff) |
add importTab component in package creation
Issue-ID: CCSDK-2016
Signed-off-by: shaaban Altanany <shaaban.eltanany.ext@orange.com>
Change-Id: I828f9891863224cd3c70dbcaf1149efdff394c6e
Diffstat (limited to 'cds-ui')
10 files changed, 128 insertions, 14 deletions
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 --- /dev/null +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/imports-tab/imports-tab.component.css 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 @@ +<div class="center"> + <ngx-file-drop dropZoneLabel="Drop files here" (onFileDrop)="dropped($event)" + (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)"> + gi<ng-template ngx-file-drop-content-tmp let-openFileSelector="openFileSelector"> + Optional custom content that replaces the the entire default content. + <button type="button" (click)="openFileSelector()">Browse Files</button> + </ng-template> + </ngx-file-drop> + <div class="upload-table"> + <table class="table"> + <thead> + <tr> + <th>Name</th> + </tr> + </thead> + <tbody class="upload-name-style"> + <tr *ngFor="let item of files; let i=index"> + <td><strong>{{ item.relativePath }}</strong></td> + </tr> + </tbody> + </table> + </div> +</div> 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<ImportsTabComponent>; + + 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<string, string> = new Map<string, string>(); + constructor(files: Map<string, string>) { + this.files = files; + } } -export class CBAPacakge { +export class CBAPackage { public metaData: Metadata; public definitions: Definition; + constructor() { + this.definitions = new Definition(new Map<string, string>()); + 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 @@ </div> </div> </div> +<app-imports-tab></app-imports-tab> 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<CBAPacakge> { +export class PackageCreationStore extends Store<CBAPackage> { constructor(private packageCreationService: PackageCreationService) { - super(new CBAPacakge()); + super(new CBAPackage()); } changeMetaData(metaDataObject: Metadata) { @@ -47,4 +44,12 @@ export class PackageCreationService extends Store<CBAPacakge> { 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: [] |