mirror of https://github.com/portainer/portainer
71 lines
2.2 KiB
JavaScript
71 lines
2.2 KiB
JavaScript
angular.module('portainer.docker')
|
|
.controller('TasksDatatableController', ['PaginationService', 'DatatableService',
|
|
function (PaginationService, DatatableService) {
|
|
this.state = {
|
|
showQuickActionStats: true,
|
|
showQuickActionLogs: true,
|
|
showQuickActionConsole: true,
|
|
showQuickActionInspect: true,
|
|
selectAll: false,
|
|
orderBy: this.orderBy,
|
|
paginatedItemLimit: PaginationService.getPaginationLimit(this.tableKey),
|
|
displayTextFilter: false,
|
|
selectedItemCount: 0,
|
|
selectedItems: []
|
|
};
|
|
|
|
this.onTextFilterChange = function() {
|
|
DatatableService.setDataTableTextFilters(this.tableKey, this.state.textFilter);
|
|
};
|
|
|
|
this.changeOrderBy = function(orderField) {
|
|
this.state.reverseOrder = this.state.orderBy === orderField ? !this.state.reverseOrder : false;
|
|
this.state.orderBy = orderField;
|
|
DatatableService.setDataTableOrder(this.tableKey, orderField, this.state.reverseOrder);
|
|
};
|
|
|
|
this.selectItem = function(item) {
|
|
if (item.Checked) {
|
|
this.state.selectedItemCount++;
|
|
this.state.selectedItems.push(item);
|
|
} else {
|
|
this.state.selectedItems.splice(this.state.selectedItems.indexOf(item), 1);
|
|
this.state.selectedItemCount--;
|
|
}
|
|
};
|
|
|
|
this.selectAll = function() {
|
|
for (var i = 0; i < this.state.filteredDataSet.length; i++) {
|
|
var item = this.state.filteredDataSet[i];
|
|
if (item.Checked !== this.state.selectAll) {
|
|
item.Checked = this.state.selectAll;
|
|
this.selectItem(item);
|
|
}
|
|
}
|
|
};
|
|
|
|
this.changePaginationLimit = function() {
|
|
PaginationService.setPaginationLimit(this.tableKey, this.state.paginatedItemLimit);
|
|
};
|
|
|
|
this.$onInit = function() {
|
|
setDefaults(this);
|
|
|
|
var storedOrder = DatatableService.getDataTableOrder(this.tableKey);
|
|
if (storedOrder !== null) {
|
|
this.state.reverseOrder = storedOrder.reverse;
|
|
this.state.orderBy = storedOrder.orderBy;
|
|
}
|
|
|
|
var textFilter = DatatableService.getDataTableTextFilters(this.tableKey);
|
|
if (textFilter !== null) {
|
|
this.state.textFilter = textFilter;
|
|
}
|
|
};
|
|
|
|
function setDefaults(ctrl) {
|
|
ctrl.showTextFilter = ctrl.showTextFilter ? ctrl.showTextFilter : false;
|
|
ctrl.state.reverseOrder = ctrl.reverseOrder ? ctrl.reverseOrder : false;
|
|
}
|
|
}]);
|