diff options
author | 2019-03-07 15:43:32 +0530 | |
---|---|---|
committer | 2019-03-07 15:43:32 +0530 | |
commit | 3a5ecdcf6129611e1f8a016bd4e5260c1096af88 (patch) | |
tree | dc1cb3f24ae8d4c097808b506dfd1ca2ceab95c8 /cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts | |
parent | ab1ed5de2918c7f199433e3853b1a19b673ba24b (diff) |
Upload file
Change-Id: Icaab7e8800fac9a82ebe38709aacc550da9f43fa
Issue-ID: CCSDK-808
Signed-off-by: sp00501638 <sp00501638@techmahindra.com>
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts')
-rw-r--r-- | cds-ui/client/src/app/feature-modules/resource-definition/resource-creation/resource-creation.component.ts | 30 |
1 files changed, 20 insertions, 10 deletions
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); -} + } } |