diff --git a/app/portainer/components/custom-templates-list/customTemplatesListController.js b/app/portainer/components/custom-templates-list/customTemplatesListController.js new file mode 100644 index 000000000..f92235f4f --- /dev/null +++ b/app/portainer/components/custom-templates-list/customTemplatesListController.js @@ -0,0 +1,36 @@ +angular.module('portainer.docker').controller('CustomTemplatesListController', function ($scope, $controller, DatatableService) { + angular.extend(this, $controller('GenericDatatableController', { $scope: $scope })); + + this.$onInit = function () { + this.setDefaults(); + this.prepareTableFromDataset(); + + this.state.orderBy = this.orderBy; + 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; + this.onTextFilterChange(); + } + + var storedFilters = DatatableService.getDataTableFilters(this.tableKey); + if (storedFilters !== null) { + this.filters = storedFilters; + } + if (this.filters && this.filters.state) { + this.filters.state.open = false; + } + + var storedSettings = DatatableService.getDataTableSettings(this.tableKey); + if (storedSettings !== null) { + this.settings = storedSettings; + this.settings.open = false; + } + this.onSettingsRepeaterChange(); + }; +}); diff --git a/app/portainer/components/custom-templates-list/index.js b/app/portainer/components/custom-templates-list/index.js index a8a2002fb..f946bf394 100644 --- a/app/portainer/components/custom-templates-list/index.js +++ b/app/portainer/components/custom-templates-list/index.js @@ -2,6 +2,7 @@ import angular from 'angular'; angular.module('portainer.app').component('customTemplatesList', { templateUrl: './customTemplatesList.html', + controller: 'CustomTemplatesListController', bindings: { titleText: '@', titleIcon: '@', diff --git a/app/portainer/views/custom-templates/custom-templates-view/customTemplatesView.html b/app/portainer/views/custom-templates/custom-templates-view/customTemplatesView.html index 71120c002..6a63f7c32 100644 --- a/app/portainer/views/custom-templates/custom-templates-view/customTemplatesView.html +++ b/app/portainer/views/custom-templates/custom-templates-view/customTemplatesView.html @@ -63,7 +63,7 @@ title-text="Templates" title-icon="fa-rocket" templates="$ctrl.templates" - table-key="templates" + table-key="customTemplates" is-edit-allowed="$ctrl.isEditAllowed" on-select-click="($ctrl.selectTemplate)" on-delete-click="($ctrl.confirmDelete)"