2018-02-01 12:27:52 +00:00
|
|
|
angular.module('portainer.docker')
|
2019-07-02 15:51:17 +00:00
|
|
|
.controller('VolumesDatatableController', ['$scope', '$controller', 'DatatableService',
|
|
|
|
function ($scope, $controller, DatatableService) {
|
2017-12-06 11:04:02 +00:00
|
|
|
|
2019-07-02 15:51:17 +00:00
|
|
|
angular.extend(this, $controller('GenericDatatableController', {$scope: $scope}));
|
2017-12-06 11:04:02 +00:00
|
|
|
|
2019-07-02 15:51:17 +00:00
|
|
|
var ctrl = this;
|
2018-07-11 14:18:44 +00:00
|
|
|
|
2017-12-06 11:04:02 +00:00
|
|
|
this.filters = {
|
2019-07-02 15:51:17 +00:00
|
|
|
state: {
|
2017-12-06 11:04:02 +00:00
|
|
|
open: false,
|
|
|
|
enabled: false,
|
|
|
|
showUsedVolumes: true,
|
|
|
|
showUnusedVolumes: true
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-08-22 15:33:06 +00:00
|
|
|
this.applyFilters = function(value) {
|
2017-12-06 11:04:02 +00:00
|
|
|
var volume = value;
|
|
|
|
var filters = ctrl.filters;
|
2019-07-02 15:51:17 +00:00
|
|
|
if ((volume.dangling && filters.state.showUnusedVolumes)
|
|
|
|
|| (!volume.dangling && filters.state.showUsedVolumes)) {
|
2017-12-06 11:04:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2018-07-11 14:18:44 +00:00
|
|
|
|
2019-07-02 15:51:17 +00:00
|
|
|
this.onstateFilterChange = function() {
|
|
|
|
var filters = this.filters.state;
|
2017-12-06 11:04:02 +00:00
|
|
|
var filtered = false;
|
|
|
|
if (!filters.showUsedVolumes || !filters.showUnusedVolumes) {
|
|
|
|
filtered = true;
|
|
|
|
}
|
2019-07-02 15:51:17 +00:00
|
|
|
this.filters.state.enabled = filtered;
|
2017-12-06 11:04:02 +00:00
|
|
|
DatatableService.setDataTableFilters(this.tableKey, this.filters);
|
|
|
|
};
|
|
|
|
|
|
|
|
this.$onInit = function() {
|
2019-07-02 15:51:17 +00:00
|
|
|
this.setDefaults();
|
|
|
|
this.prepareTableFromDataset();
|
2017-12-06 11:04:02 +00:00
|
|
|
|
2019-08-12 14:25:35 +00:00
|
|
|
this.state.orderBy = this.orderBy;
|
2017-12-06 11:04:02 +00:00
|
|
|
var storedOrder = DatatableService.getDataTableOrder(this.tableKey);
|
|
|
|
if (storedOrder !== null) {
|
|
|
|
this.state.reverseOrder = storedOrder.reverse;
|
|
|
|
this.state.orderBy = storedOrder.orderBy;
|
|
|
|
}
|
2018-07-11 14:18:44 +00:00
|
|
|
|
2019-07-02 15:51:17 +00:00
|
|
|
var textFilter = DatatableService.getDataTableTextFilters(this.tableKey);
|
|
|
|
if (textFilter !== null) {
|
|
|
|
this.state.textFilter = textFilter;
|
|
|
|
this.onTextFilterChange();
|
|
|
|
}
|
|
|
|
|
2017-12-06 11:04:02 +00:00
|
|
|
var storedFilters = DatatableService.getDataTableFilters(this.tableKey);
|
|
|
|
if (storedFilters !== null) {
|
|
|
|
this.filters = storedFilters;
|
|
|
|
}
|
2019-07-02 15:51:17 +00:00
|
|
|
if (this.filters && this.filters.state) {
|
|
|
|
this.filters.state.open = false;
|
2018-12-06 19:54:34 +00:00
|
|
|
}
|
2019-07-22 10:54:59 +00:00
|
|
|
|
|
|
|
var storedSettings = DatatableService.getDataTableSettings(this.tableKey);
|
|
|
|
if (storedSettings !== null) {
|
|
|
|
this.settings = storedSettings;
|
|
|
|
this.settings.open = false;
|
|
|
|
}
|
|
|
|
this.onSettingsRepeaterChange();
|
2017-12-06 11:04:02 +00:00
|
|
|
};
|
|
|
|
}]);
|