Skip to content

Commit

Permalink
Merge pull request portainer#4766 from portainer/fix/GH/3068-fix-auto…
Browse files Browse the repository at this point in the history
…-refresh-collapse

fix(docker/services): save the settings of the table for auto refresh
  • Loading branch information
jfadelhaye authored Feb 14, 2021
2 parents f2ec760 + 51d584b commit bc459b5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ angular.module('portainer.docker').controller('ServicesDatatableController', [
}
};

this.onDataRefresh = function () {
var storedExpandedItems = DatatableService.getDataTableExpandedItems(this.tableKey);
if (storedExpandedItems !== null) {
this.expandItems(storedExpandedItems);
}
};

this.$onInit = function () {
this.setDefaults();
this.prepareTableFromDataset();
Expand Down
13 changes: 7 additions & 6 deletions app/docker/views/services/servicesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ angular.module('portainer.docker').controller('ServicesController', [
function getServices() {
var agentProxy = $scope.applicationState.endpoint.mode.agentProxy;

$q.all({
services: ServiceService.services(),
tasks: TaskService.tasks(),
containers: agentProxy ? ContainerService.containers(1) : [],
nodes: NodeService.nodes(),
})
return $q
.all({
services: ServiceService.services(),
tasks: TaskService.tasks(),
containers: agentProxy ? ContainerService.containers(1) : [],
nodes: NodeService.nodes(),
})
.then(function success(data) {
var services = data.services;
var tasks = data.tasks;
Expand Down
13 changes: 11 additions & 2 deletions app/portainer/components/datatables/genericDatatableController.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ angular.module('portainer.app').controller('GenericDatatableController', [
};

this.startRepeater = function () {
this.repeater = $interval(() => {
this.refreshCallback();
this.repeater = $interval(async () => {
await this.refreshCallback();
this.onDataRefresh();
}, this.settings.repeater.refreshRate * 1000);
};

Expand All @@ -197,6 +198,14 @@ angular.module('portainer.app').controller('GenericDatatableController', [
}
DatatableService.setDataTableSettings(this.tableKey, this.settings);
};

/**
* Override this method to execute code after calling the refresh callback
*/
this.onDataRefresh = function () {
return;
};

/**
* !REPEATER SECTION
*/
Expand Down

0 comments on commit bc459b5

Please sign in to comment.