Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
newData.sort((a, b) => { // use a custom sort as TdDataTableService only does case-sensitive sorting
let direction = 0;
if (!Number.isNaN(Number.parseFloat(a[this.sortBy])) && !Number.isNaN(Number.parseFloat(b[this.sortBy]))) {
direction = Number.parseFloat(a[this.sortBy]) - Number.parseFloat(b[this.sortBy]);
} else if (typeof a[this.sortBy] === "string" && typeof b[this.sortBy] === "string") {
direction = a[this.sortBy].localeCompare(b[this.sortBy]);
} else {
direction = a[this.sortBy] < b[this.sortBy] ? -1 : a[this.sortBy] > b[this.sortBy] ? 1 : 0;
}
return direction * (this.sortOrder === TdDataTableSortingOrder.Descending ? -1 : 1);
});
newData = this.dataTableService.pageData(newData, this.fromRow, this.currentPage * this.pageSize);
/**
* The time of the oldest alert from the last server response.
* @type {number|null}
*/
oldestTime: any = null;
ALL_ALERT_TYPES_FILTER: any;
direction: any;
PAGE_DIRECTION: any;
refreshing: any;
deferred: any;
promise: any;
total: number = 0;
page: number = 1;
sortBy: string = "startTime";
sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
columns: ITdDataTableColumn[] = [
{ name: 'level', label: 'Level', sortable: true, filter: true },
{ name: 'state', label: 'State', sortable: true, filter: true },
{ name: 'typeDisplay', label: 'Type', sortable: true, filter: true},
{ name: 'startTime', label: 'Start Time', sortable: true, filter: true},
{ name: 'description', label: 'Description', sortable: false, filter: true}
];
ngOnInit(){
this.filterTable = ObjectUtils.isDefined(this.query) ? this.query : '';
this.pageName = ObjectUtils.isDefined(this.pageName) ? this.pageName : 'alerts';
//Page State
this.loading = true;
this.showProgress = true;
//Pagination and view Type (list or table)
getFeedHealthQueryParams() {
var limit = this.paginationData.rowsPerPage;
var activeTab = this.tabService.getActiveTab(this.pageName);
var tab = activeTab.title;
var sort = this.sortFeed.sortBy;
if (this.sortFeed.sortOrder == TdDataTableSortingOrder.Descending) {
sort = "-" + sort;
}
var start = (limit * activeTab.currentPage) - limit;
return {limit:limit,fixedFilter:tab,sort:sort,start:start,filter:this.filterFeed};
}
*/
creatingNewSla: boolean = false;
/**
* Either NEW or EDIT
* @type {string}
*/
mode: any = 'NEW';
userSuppliedName: boolean = false;
userSuppliedDescription: boolean = false;
loadingMessage: any;
sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
sortBy: string = 'name';
pageSize: number = 5;
fromRow: number = 1;
searchTerm: string = '';
filteredData: any[];
filteredTotal: number = 0;
currentPage: number = 1;
columns: ITdDataTableColumn[] = [
{ name: 'name', label: 'Name', sortable: true, filter: true },
{ name: 'description', label: 'Description', sortable: true, filter: true },
{ name: 'feedNames', label: 'RelatedFeeds', sortable: true, filter: true }
];
/**
* sorted/filtered data displayed in the ui
* @type {any[]}
*/
filteredData:any[] = [];
/**
* Calc the column width based upon data?
*/
@Input()
calcColumnWidth:boolean = true;
sortBy: string = '';
sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
sort(sortEvent: ITdDataTableSortChangeEvent): void {
this.sortBy = sortEvent.name;
this.sortOrder = sortEvent.order;
this.filter();
}
filter(){
let newData:any[] = this.data;
newData = this._dataTableService.sortData(newData, this.sortBy, this.sortOrder);
this.filteredData = newData;
}
/**
* sorted/filtered data displayed in the ui
* @type {any[]}
*/
filteredData:ApplyDomainTypesRow[] = [];
/**
* Rows selected
* @type {any[]}
*/
selectedRows:ApplyDomainTypesRow[] = [];
sortBy: string = 'name';
sortOrder: TdDataTableSortingOrder = TdDataTableSortingOrder.Descending;
constructor(
private _dataTableService: TdDataTableService,
public dialogRef: MatDialogRef,
@Inject(MAT_DIALOG_DATA) public dialogData: ApplyDomainTypesData) {
}
sort(sortEvent: ITdDataTableSortChangeEvent): void {
this.sortBy = sortEvent.name;
this.sortOrder = sortEvent.order;
this.filter();
}
filter(){