| | |
| | | }) |
| | | export class EnvironmentManagementComponent implements OnInit, OnDestroy { |
| | | |
| | | data: any = {}; |
| | | offlineChartData: any[] = []; |
| | | |
| | | constructor( |
| | | private deviceService: DeviceService, |
| | |
| | | }); |
| | | } |
| | | |
| | | this.data = { |
| | | searchData: searchData |
| | | }; |
| | | const offlineChartData = []; |
| | | for (let i = 0; i < 20; i += 1) { |
| | | offlineChartData.push({ |
| | | x: new Date().getTime() + 1000 * 60 * 30 * i, |
| | | y1: Math.floor(Math.random() * 100) + 10, |
| | | y2: Math.floor(Math.random() * 100) + 10 |
| | | }); |
| | | } |
| | | this.offlineChartData = offlineChartData; |
| | | } |
| | | |
| | | ngOnDestroy(): void { |
| | | } |
| | | |
| | | sort(sortName, sortValue) { |
| | | this.data.searchData = [ |
| | | ...(<any[]>this.data.searchData).sort((a, b) => { |
| | | if (a[sortName] > b[sortName]) { |
| | | return (sortValue === 'ascend') ? 1 : -1; |
| | | } else if (a[sortName] < b[sortName]) { |
| | | return (sortValue === 'ascend') ? -1 : 1; |
| | | } else { |
| | | return 0; |
| | | } |
| | | }) |
| | | ]; |
| | | } |
| | | } |