summaryrefslogtreecommitdiffstats
path: root/cds-ui
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui')
-rw-r--r--cds-ui/client/src/app/common/core/store/models/itopologytemplate.model.ts6
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts38
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.html2
-rw-r--r--cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts29
4 files changed, 55 insertions, 20 deletions
diff --git a/cds-ui/client/src/app/common/core/store/models/itopologytemplate.model.ts b/cds-ui/client/src/app/common/core/store/models/itopologytemplate.model.ts
index cadf4f9e3..7457f2f8c 100644
--- a/cds-ui/client/src/app/common/core/store/models/itopologytemplate.model.ts
+++ b/cds-ui/client/src/app/common/core/store/models/itopologytemplate.model.ts
@@ -20,7 +20,7 @@ limitations under the License.
*/
export interface ITopologyTemplate {
- inputs: object;
- node_template: object;
- workflow: object;
+ inputs: object[];
+ node_template: object[];
+ workflow: object[];
} \ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts
index 176cc55a7..cfcb6471a 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts
+++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/metadata/metadata.component.ts
@@ -19,10 +19,14 @@ limitations under the License.
============LICENSE_END============================================
*/
-import { Component, OnInit, EventEmitter, Output } from '@angular/core';
+import { Component, OnInit, EventEmitter, Output, AfterViewInit, AfterContentInit, OnChanges, DoCheck, AfterViewChecked } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { IMetaData } from '../../../../common/core/store/models/metadata.model';
import { A11yModule } from '@angular/cdk/a11y';
+import { IAppState } from '../../../../common/core/store/state/app.state';
+import { Store } from '@ngrx/store';
+import { Observable } from 'rxjs';
+import { IBlueprintState } from 'src/app/common/core/store/models/blueprintState.model';
@Component({
selector: 'app-metadata',
@@ -32,11 +36,11 @@ import { A11yModule } from '@angular/cdk/a11y';
export class MetadataComponent implements OnInit {
CBAMetadataForm: FormGroup;
metadata: IMetaData;
+ bpState: Observable<IBlueprintState>;
@Output() metadataform = new EventEmitter<IMetaData>();
- constructor(private formBuilder: FormBuilder) { }
-
- ngOnInit() {
+ constructor(private formBuilder: FormBuilder, private store: Store<IAppState>) {
+ this.bpState = this.store.select('blueprint');
this.CBAMetadataForm = this.formBuilder.group({
template_author: ['', Validators.required],
author_email: ['', Validators.required],
@@ -46,9 +50,33 @@ export class MetadataComponent implements OnInit {
template_tags: ['', Validators.required]
});
}
+
+ ngOnInit() {
+ this.bpState.subscribe(
+ blueprintdata => {
+ var blueprintState: IBlueprintState = { blueprint: blueprintdata.blueprint, isLoadSuccess: blueprintdata.isLoadSuccess, isSaveSuccess: blueprintdata.isSaveSuccess, isUpdateSuccess: blueprintdata.isUpdateSuccess };
+ this.metadata = blueprintState.blueprint.metadata;
+ let metadatavalues = [];
+ for (let key in this.metadata) {
+ if (this.metadata.hasOwnProperty(key)) {
+ metadatavalues.push(this.metadata[key]);
+ }
+ }
+ let temp_author = metadatavalues[0];
+ console.log(temp_author);
+ this.CBAMetadataForm = this.formBuilder.group({
+ template_author: [metadatavalues[0], Validators.required],
+ author_email: [metadatavalues[1], Validators.required],
+ user_groups: [metadatavalues[2], Validators.required],
+ template_name: [metadatavalues[3], Validators.required],
+ template_version: [metadatavalues[4], Validators.required],
+ template_tags: [metadatavalues[5], Validators.required]
+ });
+ })
+ }
+
UploadMetadata() {
this.metadata = Object.assign({}, this.CBAMetadataForm.value);
- console.log(this.metadata.template_author);
this.metadataform.emit(this.metadata);
}
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.html b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.html
index f97ea0ee7..b6cd90286 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.html
+++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.html
@@ -22,5 +22,5 @@ limitations under the License.
<input type="file" accept=".json" (change)="fileChanged($event)">
</div>
<div>
- <button mat-button matStepperNext class="matStepNextBtn" (click)="extractBlueprint()">Upload</button>
+ <button mat-button matStepperNext class="matStepNextBtn" (click)="updateBlueprintState()">Upload</button>
</div> \ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
index 3a344c9fc..5fe28e7f9 100644
--- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
+++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-template.component.ts
@@ -21,7 +21,11 @@ limitations under the License.
import { Component, OnInit, EventEmitter, Output } from '@angular/core';
import { Store } from '@ngrx/store';
-import { IBlueprint} from '../../../../common/core/store/models/blueprint.model';
+import { IBlueprint } from '../../../../common/core/store/models/blueprint.model';
+import { IBlueprintState } from '../../../../common/core/store/models/blueprintState.model';
+import { IAppState } from '../../../../common/core/store/state/app.state';
+import { LoadBlueprintSuccess } from '../../../../common/core/store/actions/blueprint.action';
+import { Observable } from 'rxjs';
@Component({
selector: 'app-search-template',
@@ -29,25 +33,28 @@ import { IBlueprint} from '../../../../common/core/store/models/blueprint.model'
styleUrls: ['./search-template.component.scss']
})
export class SearchTemplateComponent implements OnInit {
- file: any;
+ file: File;
localBluePrintData: IBlueprint;
fileText: object[];
-
- constructor() { }
+ blueprintState: IBlueprintState;
+ bpState: Observable<IBlueprintState>;
+
+ constructor(private store: Store<IAppState>) { }
- ngOnInit() { }
+ ngOnInit() {
+ }
fileChanged(e: any) {
this.file = e.target.files[0];
+ }
+
+ updateBlueprintState() {
let fileReader = new FileReader();
- fileReader.readAsText(e.srcElement.files[0]);
+ fileReader.readAsText(this.file);
var me = this;
fileReader.onload = function () {
- let fileData = JSON.stringify(fileReader.result);
- me.localBluePrintData = JSON.parse(fileData);
- console.log(me.localBluePrintData);
+ var data: IBlueprint = JSON.parse(fileReader.result.toString());
+ me.store.dispatch(new LoadBlueprintSuccess(data));
}
}
- extractBlueprint(){
- }
}