aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/designer-client
diff options
context:
space:
mode:
authorShaabanEltanany <shaaban.eltanany.ext@orange.com>2020-09-09 11:31:06 +0200
committerShaabanEltanany <shaaban.eltanany.ext@orange.com>2020-09-09 11:31:06 +0200
commitdbf58e985a064a8a499ce2db4643b3b5c602d625 (patch)
treea646c748449e83730a02558de6465050eb82955f /cds-ui/designer-client
parent98627b6fcc481b6678fcc89c17891ab059d81ea2 (diff)
refactor package creation and configuration
Issue-ID: CCSDK-2542 Signed-off-by: ShaabanEltanany <shaaban.eltanany.ext@orange.com> Change-Id: I3525114bde445e21f1d0df880b1e7f5ac512d3dc
Diffstat (limited to 'cds-ui/designer-client')
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts84
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html4
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.component.ts36
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/package-creation.store.ts17
-rw-r--r--cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/template-mapping/templ-mapp-creation/templ-mapp-creation.component.ts4
5 files changed, 63 insertions, 82 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
index 029601d67..71afa155d 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/configuration-dashboard/configuration-dashboard.component.ts
@@ -7,7 +7,7 @@ import {MetadataTabComponent} from '../package-creation/metadata-tab/metadata-ta
import * as JSZip from 'jszip';
import {ConfigurationDashboardService} from './configuration-dashboard.service';
import {TemplateTopology, VlbDefinition} from '../package-creation/mapping-models/definitions/VlbDefinition';
-import {DslDefinition} from '../package-creation/mapping-models/CBAPacakge.model';
+import {CBAPackage, DslDefinition} from '../package-creation/mapping-models/CBAPacakge.model';
import {PackageCreationUtils} from '../package-creation/package-creation.utils';
import {PackageCreationModes} from '../package-creation/creationModes/PackageCreationModes';
import {PackageCreationBuilder} from '../package-creation/creationModes/PackageCreationBuilder';
@@ -15,6 +15,7 @@ import {saveAs} from 'file-saver';
import {DesignerStore} from '../designer/designer.store';
import {ToastrService} from 'ngx-toastr';
import {NgxFileDropEntry} from 'ngx-file-drop';
+import {PackageCreationService} from '../package-creation/package-creation.service';
@Component({
selector: 'app-configuration-dashboard',
@@ -42,16 +43,22 @@ export class ConfigurationDashboardComponent implements OnInit {
isSaveEnabled = false;
versionPattern = '^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$';
metadataClasses = 'nav-item nav-link active';
+ private cbaPackage: CBAPackage = new CBAPackage();
constructor(
private route: ActivatedRoute,
private configurationDashboardService: ConfigurationDashboardService,
private packageCreationStore: PackageCreationStore,
+ private packageCreationService: PackageCreationService,
private packageCreationUtils: PackageCreationUtils,
private router: Router,
private designerStore: DesignerStore,
private toastService: ToastrService
) {
+ this.packageCreationStore.state$.subscribe(
+ cbaPackage => {
+ this.cbaPackage = cbaPackage;
+ });
}
ngOnInit() {
@@ -60,20 +67,18 @@ export class ConfigurationDashboardComponent implements OnInit {
this.elementRef.nativeElement.focus();
this.refreshCurrentPackage();
const regexp = RegExp(this.versionPattern);
- this.packageCreationStore.state$.subscribe(
- cbaPackage => {
- if (cbaPackage && cbaPackage.metaData && cbaPackage.metaData.description
- && cbaPackage.metaData.name && cbaPackage.metaData.version &&
- regexp.test(cbaPackage.metaData.version)) {
- if (!this.metadataClasses.includes('complete')) {
- this.metadataClasses += ' complete';
- }
- } else {
- this.metadataClasses = this.metadataClasses.replace('complete', '');
- this.isSaveEnabled = false;
- }
+ if (this.cbaPackage && this.cbaPackage.metaData && this.cbaPackage.metaData.description
+ && this.cbaPackage.metaData.name && this.cbaPackage.metaData.version &&
+ regexp.test(this.cbaPackage.metaData.version)) {
+ if (!this.metadataClasses.includes('complete')) {
+ this.metadataClasses += ' complete';
+ }
+ } else {
+ this.metadataClasses = this.metadataClasses.replace('complete', '');
+ this.isSaveEnabled = false;
+ }
+
- });
}
private refreshCurrentPackage() {
@@ -161,17 +166,20 @@ export class ConfigurationDashboardComponent implements OnInit {
}
editBluePrint() {
- this.packageCreationStore.state$.subscribe(
- cbaPackage => {
- FilesContent.clear();
- let packageCreationModes: PackageCreationModes;
- cbaPackage = PackageCreationModes.mapModeType(cbaPackage);
- cbaPackage.metaData = PackageCreationModes.setEntryPoint(cbaPackage.metaData);
- packageCreationModes = PackageCreationBuilder.getCreationMode(cbaPackage);
- packageCreationModes.execute(cbaPackage, this.packageCreationUtils);
- this.filesData.push(this.folder.TREE_DATA);
- this.saveBluePrintToDataBase();
- });
+ if (this.cbaPackage) {
+ this.formTreeData();
+ this.saveBluePrintToDataBase();
+ }
+ }
+
+ private formTreeData() {
+ FilesContent.clear();
+ let packageCreationModes: PackageCreationModes;
+ this.cbaPackage = PackageCreationModes.mapModeType(this.cbaPackage);
+ this.cbaPackage.metaData = PackageCreationModes.setEntryPoint(this.cbaPackage.metaData);
+ packageCreationModes = PackageCreationBuilder.getCreationMode(this.cbaPackage);
+ packageCreationModes.execute(this.cbaPackage, this.packageCreationUtils);
+ this.filesData.push(this.folder.TREE_DATA);
}
setMetaData(metaDataObject: MetaDataTabModel, bluePrintDetailModel: BluePrintDetailModel) {
@@ -200,7 +208,7 @@ export class ConfigurationDashboardComponent implements OnInit {
this.create();
this.zipFile.generateAsync({type: 'blob'})
.then(blob => {
- this.packageCreationStore.saveBluePrint(blob).subscribe(
+ this.packageCreationService.savePackage(blob).subscribe(
bluePrintDetailModels => {
if (bluePrintDetailModels) {
const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1];
@@ -245,7 +253,7 @@ export class ConfigurationDashboardComponent implements OnInit {
}
deployCurrentPackage() {
- this.collectZipFileFromStore();
+ this.formTreeData();
this.deployPackage();
}
@@ -273,29 +281,16 @@ export class ConfigurationDashboardComponent implements OnInit {
enrichBluePrint() {
- this.collectZipFileFromStore();
+ this.formTreeData();
this.enrichPackage();
}
- private collectZipFileFromStore() {
- this.packageCreationStore.state$.subscribe(
- cbaPackage => {
- FilesContent.clear();
- console.log(cbaPackage);
- let packageCreationModes: PackageCreationModes;
- cbaPackage = PackageCreationModes.mapModeType(cbaPackage);
- cbaPackage.metaData = PackageCreationModes.setEntryPoint(cbaPackage.metaData);
- packageCreationModes = PackageCreationBuilder.getCreationMode(cbaPackage);
- packageCreationModes.execute(cbaPackage, this.packageCreationUtils);
- this.filesData.push(this.folder.TREE_DATA);
- });
- }
private enrichPackage() {
this.create();
this.zipFile.generateAsync({type: 'blob'})
.then(blob => {
- this.packageCreationStore.enrichBluePrint(blob).subscribe(response => {
+ this.packageCreationService.enrichPackage(blob).subscribe(response => {
console.log('success');
const blobInfo = new Blob([response], {type: 'application/octet-stream'});
this.configurationDashboardService.getPagedPackages(this.id).subscribe(
@@ -321,12 +316,9 @@ export class ConfigurationDashboardComponent implements OnInit {
this.create();
this.zipFile.generateAsync({type: 'blob'})
.then(blob => {
- this.packageCreationStore.deployBluePrint(blob).subscribe(response => {
+ this.packageCreationService.enrichPackage(blob).subscribe(response => {
console.log('success');
console.log(response);
-
- // saveAs(blobInfo, 'test' + '-' + '1.0.0' + '-CBA.zip');
-
});
}, error => {
this.toastService.error('error happened when deploying ' + error.message);
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html
index f2e5eedf1..58be592af 100644
--- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html
+++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/package-creation/metadata-tab/metadata-tab.component.html
@@ -33,7 +33,7 @@
<div class="single-line-model">
<label class="label-name">Name <span>*</span></label>
<div class="label-input">
- <input tourAnchor="mt-packageName" type="input" (change)="checkRequiredElements()"
+ <input tourAnchor="mt-packageName" type="input" (change)="checkRequiredElements()"
[(ngModel)]="metaDataTab.name" placeholder="Package name">
</div>
<!--<div class="model-note-container error-message">
@@ -123,4 +123,4 @@
</div>
</div>
-</div> \ No newline at end of file
+</div>
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 4145e0f8e..9a38c62be 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
@@ -19,19 +19,20 @@ limitations under the License.
============LICENSE_END============================================
*/
-import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
-import { FilesContent, FolderNodeElement, MetaDataTabModel } from './mapping-models/metadata/MetaDataTab.model';
+import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
+import {FilesContent, FolderNodeElement, MetaDataTabModel} from './mapping-models/metadata/MetaDataTab.model';
import * as JSZip from 'jszip';
-import { PackageCreationStore } from './package-creation.store';
-import { Definition } from './mapping-models/CBAPacakge.model';
-import { PackageCreationModes } from './creationModes/PackageCreationModes';
-import { PackageCreationBuilder } from './creationModes/PackageCreationBuilder';
-import { PackageCreationUtils } from './package-creation.utils';
-import { MetadataTabComponent } from './metadata-tab/metadata-tab.component';
-import { Router } from '@angular/router';
-import { ToastrService } from 'ngx-toastr';
-import { TourService } from 'ngx-tour-md-menu';
+import {PackageCreationStore} from './package-creation.store';
+import {Definition} from './mapping-models/CBAPacakge.model';
+import {PackageCreationModes} from './creationModes/PackageCreationModes';
+import {PackageCreationBuilder} from './creationModes/PackageCreationBuilder';
+import {PackageCreationUtils} from './package-creation.utils';
+import {MetadataTabComponent} from './metadata-tab/metadata-tab.component';
+import {Router} from '@angular/router';
+import {ToastrService} from 'ngx-toastr';
+import {TourService} from 'ngx-tour-md-menu';
+import {PackageCreationService} from './package-creation.service';
@Component({
@@ -46,6 +47,7 @@ export class PackageCreationComponent implements OnInit {
constructor(
private packageCreationStore: PackageCreationStore,
+ private packageCreationService: PackageCreationService,
private packageCreationUtils: PackageCreationUtils,
private router: Router,
private tourService: TourService,
@@ -54,8 +56,8 @@ export class PackageCreationComponent implements OnInit {
counter = 0;
modes: object[] = [
- { name: 'Designer Mode', style: 'mode-icon icon-designer-mode' },
- { name: 'Scripting Mode', style: 'mode-icon icon-scripting-mode' }];
+ {name: 'Designer Mode', style: 'mode-icon icon-designer-mode'},
+ {name: 'Scripting Mode', style: 'mode-icon icon-scripting-mode'}];
metaDataTab: MetaDataTabModel = new MetaDataTabModel();
folder: FolderNodeElement = new FolderNodeElement();
zipFile: JSZip = new JSZip();
@@ -63,10 +65,10 @@ export class PackageCreationComponent implements OnInit {
definition: Definition = new Definition();
isSaveEnabled = false;
- @ViewChild(MetadataTabComponent, { static: false })
+ @ViewChild(MetadataTabComponent, {static: false})
metadataTabComponent: MetadataTabComponent;
- @ViewChild('nameit', { static: true })
+ @ViewChild('nameit', {static: true})
elementRef: ElementRef;
versionPattern = '^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$';
metadataClasses = 'nav-item nav-link active complete';
@@ -115,9 +117,9 @@ export class PackageCreationComponent implements OnInit {
saveBluePrintToDataBase() {
this.create();
- this.zipFile.generateAsync({ type: 'blob' })
+ this.zipFile.generateAsync({type: 'blob'})
.then(blob => {
- this.packageCreationStore.saveBluePrint(blob).subscribe(
+ this.packageCreationService.savePackage(blob).subscribe(
bluePrintDetailModels => {
if (bluePrintDetailModels) {
const id = bluePrintDetailModels.toString().split('id')[1].split(':')[1].split('"')[1];
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 b60831238..7b1c6bfb1 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
@@ -38,7 +38,7 @@ import {TemplateTopology} from './mapping-models/definitions/VlbDefinition';
export class PackageCreationStore extends Store<CBAPackage> {
- constructor(private packageCreationService: PackageCreationService) {
+ constructor() {
super(new CBAPackage());
}
@@ -98,17 +98,6 @@ export class PackageCreationStore extends Store<CBAPackage> {
this.state.definitions.imports.delete(filename);
}
- saveBluePrint(blob): Observable<BluePrintDetailModel> {
- return this.packageCreationService.savePackage(blob);
- }
-
- enrichBluePrint(blob): Observable<any> {
- return this.packageCreationService.enrichPackage(blob);
- }
-
- deployBluePrint(blob): Observable<BluePrintDetailModel> {
- return this.packageCreationService.deploy(blob);
- }
addTemplate(filePath: string, fileContent: string) {
this.setState({
@@ -124,10 +113,6 @@ export class PackageCreationStore extends Store<CBAPackage> {
});
}
- getTemplateAndMapping(variables: string[]): Observable<ResourceDictionary[]> {
- return this.packageCreationService.getTemplateAndMapping(variables);
- }
-
clear() {
this.setState(new CBAPackage());
}
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 3e7cfea7b..4d3471263 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
@@ -12,6 +12,7 @@ import { ToastrService } from 'ngx-toastr';
import { SharedService } from '../shared-service';
import { XmlParser } from '../utils/XmlParser';
import { TourService } from 'ngx-tour-md-menu';
+import {PackageCreationService} from '../../package-creation.service';
declare var $: any;
@Component({
@@ -57,6 +58,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy {
private packageCreationUtils: PackageCreationUtils,
private toastr: ToastrService,
private sharedService: SharedService,
+ private packageCreationService: PackageCreationService,
private tourService: TourService,
) {
}
@@ -294,7 +296,7 @@ export class TemplMappCreationComponent implements OnInit, OnDestroy {
}
if (this.variables && this.variables.length > 0) {
console.log('base');
- this.packageCreationStore.getTemplateAndMapping(this.variables).subscribe(res => {
+ this.packageCreationService.getTemplateAndMapping(this.variables).subscribe(res => {
let message = 'Attributes are Fetched';
this.mappingRes = [];
this.resourceDictionaryRes = res;