summaryrefslogtreecommitdiffstats
path: root/cds-ui/client
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2019-03-07 21:29:48 +0530
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>2019-03-07 21:29:59 +0530
commit53609a8d28e1ca0566c01ca1c8fa325be205c656 (patch)
tree32b2abd6720765dbee2598b02f839f5554552733 /cds-ui/client
parent7e06008a45d6767919fccdffb6d95e591a78a680 (diff)
TOSCA Metadata
Code to fetch the b;ueprint name from tosca.meta file Issue-ID: CCSDK-1112 Change-Id: I166e5f1c2cb210de100eaf7b8f1195cdbe7d1488 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
Diffstat (limited to 'cds-ui/client')
-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.ts75
2 files changed, 56 insertions, 21 deletions
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 b6cd90286..bb00d7f1a 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
@@ -19,7 +19,7 @@ limitations under the License.
============LICENSE_END============================================
-->
<div>
- <input type="file" accept=".json" (change)="fileChanged($event)">
+ <input type="file" accept=".zip" (change)="fileChanged($event)">
</div>
<div>
<button mat-button matStepperNext class="matStepNextBtn" (click)="updateBlueprintState()">Upload</button>
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 c6b6cc78b..02253820f 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
@@ -27,7 +27,8 @@ import { Observable } from 'rxjs';
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 { LoadBlueprintSuccess, SET_BLUEPRINT_STATE, SetBlueprintState } from '../../../../common/core/store/actions/blueprint.action';
+import { json } from 'd3';
@Component({
selector: 'app-search-template',
@@ -44,10 +45,13 @@ export class SearchTemplateComponent implements OnInit {
@ViewChild('fileInput') fileInput;
result: string = '';
- public paths = [];
- public tree;
+ private paths = [];
+ private tree;
private zipFile: JSZip = new JSZip();
private fileObject: any;
+ private activationBlueprint: any;
+ private tocsaMetadaData: any;
+ private blueprintName: string;
constructor(private store: Store<IAppState>) { }
@@ -57,22 +61,31 @@ export class SearchTemplateComponent implements OnInit {
fileChanged(e: any) {
this.file = e.target.files[0];
- // this.zipFile.loadAsync(this.file)
- // .then((zip) => {
- // if(zip) {
- // this.buildFileViewData(zip);
- // }
- // });
+ this.zipFile.loadAsync(this.file)
+ .then((zip) => {
+ if(zip) {
+ this.buildFileViewData(zip);
+ }
+ });
}
updateBlueprintState() {
- let fileReader = new FileReader();
- fileReader.readAsText(this.file);
- var me = this;
- fileReader.onload = function () {
- var data: IBlueprint = JSON.parse(fileReader.result.toString());
- me.store.dispatch(new LoadBlueprintSuccess(data));
+ // let fileReader = new FileReader();
+ // fileReader.readAsText(this.file);
+ // var me = this;
+ // fileReader.onload = function () {
+ // var data: IBlueprint = JSON.parse(fileReader.result.toString());
+ // me.store.dispatch(new LoadBlueprintSuccess(data));
+ // }
+
+ let data: IBlueprint = this.activationBlueprint ? JSON.parse(this.activationBlueprint.toString()) : this.activationBlueprint;
+ let blueprintState = {
+ blueprint: data,
+ files: this.tree,
+ filesData: this.paths
}
+ this.store.dispatch(new SetBlueprintState(blueprintState))
+ // this.store.dispatch(new LoadBlueprintSuccess(data));
}
async buildFileViewData(zip) {
@@ -85,7 +98,8 @@ export class SearchTemplateComponent implements OnInit {
this.fileObject.data = value;
this.paths.push(this.fileObject);
}
- this.arrangeTreeData(this.paths);
+ this.fetchTOSACAMetadata();
+ this.tree = this.arrangeTreeData(this.paths);
}
arrangeTreeData(paths) {
@@ -108,13 +122,34 @@ export class SearchTemplateComponent implements OnInit {
children: [],
data: path.data
};
-
- currentLevel.push(newPart);
- currentLevel = newPart.children;
+ if(part.trim() == this.blueprintName.trim()) {
+ this.activationBlueprint = path.data;
+ newPart.data = JSON.parse(this.activationBlueprint.toString());
+ console.log('newpart', newPart);
+ }
+ if(newPart.name !== '') {
+ currentLevel.push(newPart);
+ currentLevel = newPart.children;
+ }
}
});
});
- console.log('tree: ', tree);
+ console.log('tree', tree);
return tree;
}
+
+ fetchTOSACAMetadata() {
+ let toscaData = {};
+ this.paths.forEach(file =>{
+ if(file.name.includes('TOSCA.meta')) {
+ let keys = file.data.split("\n");
+ keys.forEach((key)=>{
+ let propertyData = key.split(':');
+ toscaData[propertyData[0]] = propertyData[1];
+ });
+ }
+ });
+ this.blueprintName = (((toscaData['Entry-Definitions']).split('/'))[1]).toString();;
+ console.log(toscaData);
+ }
}