aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/client
diff options
context:
space:
mode:
Diffstat (limited to 'cds-ui/client')
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.html4
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts30
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.html4
-rw-r--r--cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.ts22
4 files changed, 45 insertions, 15 deletions
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.html b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.html
index c488dfdd7..8ace910b1 100644
--- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.html
+++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.html
@@ -34,10 +34,10 @@
</mat-step>
<mat-step [stepControl]="step2FormGroup">
<ng-template matStepLabel>Browse or Search Resources</ng-template>
- <app-upload-resource (change)="fileChange(fileupload.files)"></app-upload-resource><br><br>
+ <app-upload-resource (fileData)=upload($event)></app-upload-resource><br><br>
<app-existing-model></app-existing-model>
<div>
- <button mat-button matStepperNext class="matStepNextBtn">Upload</button>
+ <button mat-button matStepperNext (click)="updateResourcesState()" class="matStepNextBtn">Upload</button>
</div>
</mat-step>
</mat-vertical-stepper>
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts
index bb8ceea51..c751e0ee8 100644
--- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts
+++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts
@@ -21,6 +21,9 @@
import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
+import { IResources } from 'src/app/common/core/store/models/resources.model';
+import { IAppState } from '../../../common/core/store/state/app.state';
+import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
@Component({
selector: 'app-resource-creation',
@@ -29,25 +32,32 @@ import { Store } from '@ngrx/store';
})
export class ResourceCreationComponent implements OnInit {
- myFile: File; /* property of File type */
+ myFile: any;
selectedValue: any;
- constructor() {
+ constructor(private store: Store<IAppState>) {
}
ngOnInit() {
}
- fileChange(files: any) {
- console.log(files);
- this.myFile = files[0].nativeElement;
- }
- upload(){
+ upload(value){
+ this.myFile=value;
+ }
- }
+ updateResourcesState() {
+ let fileReader = new FileReader();
+ fileReader.readAsText(this.myFile);
+ var me = this;
+ fileReader.onload = function () {
+ var data: IResources = JSON.parse(fileReader.result.toString());
+ me.store.dispatch(new LoadResourcesSuccess(data));
+ console.log(data);
+ }
+ }
- selectedOption(value){
+ selectedOption(value){
this.selectedValue=value;
console.log(this.selectedValue);
-}
+ }
}
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.html b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.html
index 97859cb37..3d60dabb8 100644
--- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.html
+++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.html
@@ -19,4 +19,6 @@
*/-->
-<input type="file" accept=".json">
+<div>
+ <input #myInput type="file" accept=".json" (change)="fileChanged($event)">
+</div> \ No newline at end of file
diff --git a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.ts b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.ts
index f408c7ac4..ac3561a21 100644
--- a/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.ts
+++ b/cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/upload-resource/upload-resource.component.ts
@@ -18,7 +18,13 @@
* ============LICENSE_END=========================================================
*/
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, EventEmitter, Output } from '@angular/core';
+import { IResources } from 'src/app/common/core/store/models/resources.model';
+import { IResourcesState } from 'src/app/common/core/store/models/resourcesState.model';
+import { LoadResourcesSuccess } from 'src/app/common/core/store/actions/resources.action';
+import { IAppState } from '../../../../common/core/store/state/app.state';
+import { Observable } from 'rxjs';
+import { Store } from '@ngrx/store';
@Component({
selector: 'app-upload-resource',
@@ -27,9 +33,21 @@ import { Component, OnInit } from '@angular/core';
})
export class UploadResourceComponent implements OnInit {
- constructor() { }
+ @Output() fileData = new EventEmitter();
+ file: File;
+ localResourcesData: IResources;
+ fileText: object[];
+ blueprintState: IResourcesState;
+ bpState: Observable<IResourcesState>;
+
+ constructor(private store: Store<IAppState>) { }
ngOnInit() {
}
+ fileChanged(e: any) {
+ this.file = e.target.files[0];
+ this.fileData.emit(this.file);
+ }
+
}