xufenglei
2018-07-20 efa7b6d79650d2f6813071b49f02ccce94c03f86
src/app/routes/environment/management/management.component.ts
@@ -13,7 +13,7 @@
})
export class EnvironmentManagementComponent implements OnInit, OnDestroy {
    data: any = {};
    offlineChartData: any[] = [];
    constructor(
        private deviceService: DeviceService,
@@ -32,25 +32,17 @@
            });
        }
        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;
                }
            })
        ];
    }
}