import { Component, OnInit } from '@angular/core'; import { AppService } from './app.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { constructor(private service: AppService) { } ngOnInit() { // this.service.getIndustrySegmentHierarchy().subscribe((res: any) => { // this.hierarchyList = res; // }); // this.service.getDocuments().subscribe((res: any) => { // this.dataSource = res; // if (this.dataSource && this.dataSource.filters) { // this.dataSource.filters.forEach(ele => { // if (ele.values && ele.values.length === 0) { // this.service.getAPIs(ele.apiLink).subscribe((res1: any) => { // ele.values = res; // this.reportsToDisplay = Object.assign({}, this.dataSource); // }, error => { // console.log(error); // }); // } // }); // } // // this.selectionChanged(true, this.levelOne, 1); // }); } // typeOf(obj) { // return typeof (obj); // } // setTags(fileObj, data) { // if (fileObj && fileObj.columns && fileObj.columns.tags && data) { // Object.entries(fileObj.columns.tags).forEach((ele: any) => { // if (ele[1].length > 0) { // const reqKey = data.find(x => x.tagName === ele[0]); // console.log('reqKey', reqKey); // if (reqKey) { // this.request[reqKey.requestKey] = ele[1].map(x => x.id); // } // console.log('request', this.request); // } // }); // } // } // // To prevent alphabetical sorting of object using keyvalue pipe // sortDefault() { // return 0; // } // deleteObject(e) { // this.service.deleteObj(e).subscribe((resp: any) => { // this.service.getDocuments().subscribe((res: any) => { // this.dataSource = res; // if (this.dataSource && this.dataSource.filters) { // this.dataSource.filters.forEach(ele => { // if (ele.values && ele.values.length === 0) { // this.service.getAPIs(ele.apiLink).subscribe((res1: any) => { // ele.values = res1; // this.reportsToDisplay = Object.assign({}, this.dataSource); // }, error => { // console.log(error); // }); // } // }); // } // }); // }, error => { // console.log(error); // }); // } // sortDocuments(filterKey) { // this.reportsToDisplay.data.sort((x, y) => x[filterKey] < y[filterKey] ? 1 : -1); // } // getSearchedData(val, canSearch, bindName, searchedKey?) { // if (val && canSearch) { // return val.filter(x => x[bindName].toLowerCase().includes(searchedKey.toLowerCase())); // } else { // return val; // } // } // isChecked(id, selectedFilters) { // if (selectedFilters.length > 0 && selectedFilters.findIndex(x => x === id) >= 0) { // return true; // } else { // return false; // } // } // openFile(file) { // window.open('http://in-ppmgtmot:9002/' + file, '_blank'); // } // showDetails(type, data) { // this.reportsToDisplay.data = this.dataSource.data.filter(x => // (x.columns.tags[type] && x.columns.tags[type].findIndex(y => y.id === data) !== -1)); // } // _toggleSidebar() { // this._opened = !this._opened; // if (this.sidebar3Opened) { // const c = document.getElementById('sidebar3'); // if (!(this._opened)) { // c.firstElementChild.classList.remove('ml-25'); // c.firstElementChild.classList.add('ml-0'); // } else { // c.firstElementChild.classList.remove('ml-0'); // c.firstElementChild.classList.add('ml-25'); // } // } // } // selectionChanged(event, item, id) { // if (item) { // if (event) { // if (item.multiSelect) { // item.selectedFilters.push(id); // } else if (!item.multiSelect) { // item.selectedFilters = [id]; // } // } else if (!event) { // item.selectedFilters.splice(item.selectedFilters.findIndex(x => x === id), 1); // } // } // if (this.dataSource && this.dataSource.data) { // this.dataSource.data = this.dataSource.data.filter(x => x.columns.tags[item.name] && // x.columns.tags[item.name].findIndex(obj => obj.id === id) === -1); // } // } // // selectionChanged(id, item, e?) { // // if (item) { // // if (this.request[item.requestKey]) { // // if (item.multiSelect) { // // if (e) { // // this.request[item.requestKey].push(id); // // } else if (!e) { // // this.request[item.requestKey] = this.request[item.requestKey].filter(x => x !== id); // // } // // } else if (!item.multiSelect) { // // if (e) { // // this.request[item.requestKey] = id; // // } else if (!e) { // // delete this.request[item.requestKey]; // // } // // } // // } else { // // if (item.multiSelect) { // // this.request[item.requestKey] = [id]; // // } else { // // this.request[item.requestKey] = id; // // } // // } // // } // // console.log('req', this.request); // // } // isUploadChecked(id, item) { // if (item) { // if (item.multiSelect) { // return this.request[item.requestKey] && this.request[item.requestKey.findIndex(x => x === id)] >= 0; // } else if (!item.multiSelect) { // return this.request[item.requestKey] && (this.request[item.requestKey] === id); // } // } // } // applyFilters(id, event, filterKey, selectedFilters, isMultiSelect) { // if (event) { // if (isMultiSelect) { // selectedFilters.push(id); // } else if (!isMultiSelect) { // selectedFilters = [id]; // } // } else { // selectedFilters.splice(selectedFilters.findIndex(x => x === id), 1); // } // this.dataSource.data = // this.dataSource.data.filter(x => [...new Set(x[filterKey])].filter(val => new Set(selectedFilters).has(val)).length > 0); // } // filterData(e) { // this.service.filterData(e).subscribe((res: any) => { // this.dataSource = res; // }); // } // submitData(e, action) { // if (action === 'edit') { // e['data']['dataToBeSaved']['uploadedUser'] = 279; // this.service.editFile(e['data'], e['fileId']).subscribe((res: any) => { // this.view = 'home'; // this.service.getDocuments().subscribe((resp: any) => { // this.dataSource = resp; // if (this.dataSource && this.dataSource.filters) { // this.dataSource.filters.forEach(ele => { // if (ele.values && ele.values.length === 0) { // this.service.getAPIs(ele.apiLink).subscribe((res1: any) => { // ele.values = res1; // this.reportsToDisplay = Object.assign({}, this.dataSource); // }, error => { // console.log(error); // }); // } // }); // } // }); // }, error => { // console.log('error'); // }); // } else if (action === 'add') { // this.service.uploadFile(e['data'], 279).subscribe((res: any) => { // this.view = 'home'; // this.service.getDocuments().subscribe((resp: any) => { // this.dataSource = resp; // if (this.dataSource && this.dataSource.filters) { // this.dataSource.filters.forEach(ele => { // if (ele.values && ele.values.length === 0) { // this.service.getAPIs(ele.apiLink).subscribe((res1: any) => { // ele.values = res1; // this.reportsToDisplay = Object.assign({}, this.dataSource); // }, error => { // console.log(error); // }); // } // }); // } // }); // }, error => { // console.log('error'); // }); // } else if (action === 'delete') { // this.deleteObject(e); // } // } // saveData() { // console.log(this.request); // } }