aboutsummaryrefslogtreecommitdiffstats
path: root/cds-ui/client/src/app/feature-modules/blueprint
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2019-03-13 16:23:54 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-13 16:23:54 +0000
commitc35114db4aae0c70be6ba3afe10152efb31f37d3 (patch)
treee1126098cddee42f19aeca162427c8f954de3a7a /cds-ui/client/src/app/feature-modules/blueprint
parent8b772a6141f4a331c3bb9b85ce4b130da71bd073 (diff)
parentae962e15a544e2de946032ce7c4c57cb3c2f335b (diff)
Merge "Display alert box on wrong file upload"
Diffstat (limited to 'cds-ui/client/src/app/feature-modules/blueprint')
-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.ts32
2 files changed, 22 insertions, 12 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 bb00d7f1a..66e3aeb36 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=".zip" (change)="fileChanged($event)">
</div>
<div>
- <button mat-button matStepperNext class="matStepNextBtn" (click)="updateBlueprintState()">Upload</button>
+ <button mat-button matStepperNext class="matStepNextBtn" (click)="updateBlueprintState()" [disabled]="!validfile">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 1ce33f6ab..777faee68 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
@@ -41,6 +41,7 @@ export class SearchTemplateComponent implements OnInit {
fileText: object[];
blueprintState: IBlueprintState;
bpState: Observable<IBlueprintState>;
+ validfile: boolean = false;
@ViewChild('fileInput') fileInput;
result: string = '';
@@ -60,7 +61,7 @@ export class SearchTemplateComponent implements OnInit {
fileChanged(e: any) {
this.file = e.target.files[0];
-
+ this.zipFile.files = {};
this.zipFile.loadAsync(this.file)
.then((zip) => {
if(zip) {
@@ -70,14 +71,6 @@ export class SearchTemplateComponent implements OnInit {
}
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 data: IBlueprint = this.activationBlueprint ? JSON.parse(this.activationBlueprint.toString()) : this.activationBlueprint;
let blueprintState = {
blueprint: data,
@@ -90,6 +83,8 @@ export class SearchTemplateComponent implements OnInit {
}
async buildFileViewData(zip) {
+ this.validfile = false;
+ this.paths = [];
for (var file in zip.files) {
this.fileObject = {
name: zip.files[file].name,
@@ -99,8 +94,23 @@ export class SearchTemplateComponent implements OnInit {
this.fileObject.data = value;
this.paths.push(this.fileObject);
}
- this.fetchTOSACAMetadata();
- this.tree = this.arrangeTreeData(this.paths);
+
+ if(this.paths) {
+ this.paths.forEach(path =>{
+ if(path.name.includes("TOSCA.meta")) {
+ this.validfile = true
+ }
+ });
+ } else {
+ alert('Please update proper file');
+ }
+
+ if(this.validfile) {
+ this.fetchTOSACAMetadata();
+ this.tree = this.arrangeTreeData(this.paths);
+ } else {
+ alert('Please update proper file with TOSCA metadata');
+ }
}
arrangeTreeData(paths) {