From 70ba6f90237051b5e8ed2b26d8555f1b2a358ca0 Mon Sep 17 00:00:00 2001 From: Ezhilarasi Date: Wed, 14 Aug 2019 23:21:25 +0530 Subject: Search Template code change Added parameter in Search DB template and removed unused code in search template Change-Id: I77436e8d592876affab4b74c3883d4c03fcdf279 Issue-ID: CCSDK-1275 Signed-off-by: Ezhilarasi --- .../search-from-database.component.html | 10 ++-- .../search-template/search-template.component.ts | 60 ++++++++-------------- 2 files changed, 27 insertions(+), 43 deletions(-) (limited to 'cds-ui/client') diff --git a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html index 6683dba59..648271028 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html +++ b/cds-ui/client/src/app/feature-modules/blueprint/select-template/search-template/search-from-database/search-from-database.component.html @@ -20,8 +20,8 @@ limitations under the License. -->
- - + + @@ -41,9 +41,9 @@ limitations under the License.
{{option.blueprintModel.updatedBy}} - - - + + + 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 ce7d5aac2..ee6e9631e 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 @@ -28,12 +28,9 @@ 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, SET_BLUEPRINT_STATE, SetBlueprintState } from '../../../../common/core/store/actions/blueprint.action'; -import { json } from 'd3'; import { SortPipe } from '../../../../common/shared/pipes/sort.pipe'; import { LoaderService } from '../../../../common/core/services/loader.service'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; -import { MatAutocompleteTrigger } from '@angular/material'; - @Component({ selector: 'app-search-template', @@ -52,9 +49,8 @@ export class SearchTemplateComponent implements OnInit { result: string = ''; @Input() optionSelected: string; myControl: FormGroup; - @ViewChild('resourceSelect', { read: MatAutocompleteTrigger }) resourceSelect: MatAutocompleteTrigger; @Output() resourcesData = new EventEmitter(); - options: any[] = []; + options: any[] = []; searchText: string = ''; private paths = []; @@ -66,7 +62,7 @@ export class SearchTemplateComponent implements OnInit { private blueprintName: string; private entryDefinition: string; - constructor(private store: Store, private loader: LoaderService,private formBuilder: FormBuilder) { } + constructor(private store: Store, private loader: LoaderService, private formBuilder: FormBuilder) { } ngOnInit() { this.myControl = this.formBuilder.group({ @@ -78,18 +74,6 @@ export class SearchTemplateComponent implements OnInit { this.resourcesData.emit(value); } - fetchResourceByName() { - // this.exsistingModelService.searchByTags(this.searchText) - // .subscribe(data => { - // console.log(data); - // data.forEach(element => { - // this.options.push(element) - // }); - // this.resourceSelect.openPanel(); - // }, error => { - // window.alert('error' + error); - // }) - } fileChanged(e: any) { this.paths = []; this.file = e.target.files[0]; @@ -97,8 +81,8 @@ export class SearchTemplateComponent implements OnInit { this.zipFile.files = {}; this.zipFile.loadAsync(this.file) .then((zip) => { - if(zip) { - this.loader.showLoader(); + if (zip) { + this.loader.showLoader(); this.buildFileViewData(zip); } }); @@ -123,21 +107,21 @@ export class SearchTemplateComponent implements OnInit { this.paths = []; console.log(zip.files); for (var file in zip.files) { - console.log("name: " +zip.files[file].name); + console.log("name: " + zip.files[file].name); this.fileObject = { // nameForUIDisplay: this.uploadedFileName + '/' + zip.files[file].name, // name: zip.files[file].name, name: this.uploadedFileName + '/' + zip.files[file].name, data: '' }; - const value = await zip.files[file].async('string'); + const value = await zip.files[file].async('string'); this.fileObject.data = value; - this.paths.push(this.fileObject); + this.paths.push(this.fileObject); } - if(this.paths) { - this.paths.forEach(path =>{ - if(path.name.includes("TOSCA.meta")) { + if (this.paths) { + this.paths.forEach(path => { + if (path.name.includes("TOSCA.meta")) { this.validfile = true } }); @@ -145,7 +129,7 @@ export class SearchTemplateComponent implements OnInit { alert('Please update proper file'); } - if(this.validfile) { + if (this.validfile) { this.fetchTOSACAMetadata(); this.paths = new SortPipe().transform(this.paths, 'asc', 'name'); this.tree = this.arrangeTreeData(this.paths); @@ -173,31 +157,31 @@ export class SearchTemplateComponent implements OnInit { name: part, children: [], data: path.data, - path : path.name + path: path.name }; - if(part.trim() == this.blueprintName.trim()) { - this.activationBlueprint = path.data; - newPart.data = JSON.parse(this.activationBlueprint.toString()); + if (part.trim() == this.blueprintName.trim()) { + this.activationBlueprint = path.data; + newPart.data = JSON.parse(this.activationBlueprint.toString()); console.log('newpart', newPart); this.entryDefinition = path.name.trim(); } - if(newPart.name !== '') { - currentLevel.push(newPart); - currentLevel = newPart.children; + if (newPart.name !== '') { + currentLevel.push(newPart); + currentLevel = newPart.children; } } }); - }); + }); this.loader.hideLoader(); return tree; } fetchTOSACAMetadata() { let toscaData = {}; - this.paths.forEach(file =>{ - if(file.name.includes('TOSCA.meta')) { + this.paths.forEach(file => { + if (file.name.includes('TOSCA.meta')) { let keys = file.data.split("\n"); - keys.forEach((key)=>{ + keys.forEach((key) => { let propertyData = key.split(':'); toscaData[propertyData[0]] = propertyData[1]; }); -- cgit 1.2.3-korg