From c4dd09cb8d41589a2156068bc0881df49e1149b3 Mon Sep 17 00:00:00 2001 From: Francesco Nigro Date: Tue, 16 Oct 2018 13:28:14 +0200 Subject: [PATCH] ARTEMIS-2125 Tabs pref changes to display columns not persisted through page refresh --- .../src/main/webapp/plugin/js/addresses.js | 19 ++++++++++++++++++- .../src/main/webapp/plugin/js/connections.js | 19 ++++++++++++++++++- .../src/main/webapp/plugin/js/consumers.js | 19 ++++++++++++++++++- .../src/main/webapp/plugin/js/producers.js | 19 ++++++++++++++++++- .../src/main/webapp/plugin/js/sessions.js | 19 ++++++++++++++++++- 5 files changed, 90 insertions(+), 5 deletions(-) diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/addresses.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/addresses.js index b7cdab9f2e..6cc10b080c 100644 --- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/addresses.js +++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/addresses.js @@ -29,7 +29,7 @@ var ARTEMIS = (function(ARTEMIS) { var objectType = "address"; var method = 'listAddresses(java.lang.String, int, int)'; - var attributes = [ + var defaultAttributes = [ { field: 'manage', displayName: 'manage', @@ -59,6 +59,23 @@ var ARTEMIS = (function(ARTEMIS) { sortable: false } ]; + ARTEMIS.log.debug('sessionStorage: addressesColumnDefs =', sessionStorage.getItem('addressesColumnDefs')); + var attributes = defaultAttributes; + if (sessionStorage.getItem('addressesColumnDefs')) { + attributes = JSON.parse(sessionStorage.getItem('addressesColumnDefs')); + } + $scope.$on('ngGridEventColumns', function (newColumns) { + ARTEMIS.log.debug('ngGridEventColumns:', newColumns); + var visibles = newColumns.targetScope.columns.reduce(function (visibles, column) { + visibles[column.field] = column.visible; + return visibles; + }, {}); + ARTEMIS.log.debug('ngGridEventColumns: visibles =', visibles); + attributes.forEach(function (attribute) { + attribute.visible = visibles[attribute.field]; + }); + sessionStorage.setItem('addressesColumnDefs', JSON.stringify(attributes)); + }); $scope.filter = { fieldOptions: [ {id: 'ID', name: 'ID'}, diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js index 4843968f5c..bab70c6c19 100644 --- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js +++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/connections.js @@ -29,7 +29,7 @@ var ARTEMIS = (function(ARTEMIS) { var objectType = "connection" var method = 'listConnections(java.lang.String, int, int)'; - var attributes = [ + var defaultAttributes = [ { field: 'connectionID', displayName: 'ID', @@ -73,6 +73,23 @@ var ARTEMIS = (function(ARTEMIS) { width: '*' } ]; + ARTEMIS.log.debug('sessionStorage: connectionsColumnDefs =', sessionStorage.getItem('connectionsColumnDefs')); + var attributes = defaultAttributes; + if (sessionStorage.getItem('connectionsColumnDefs')) { + attributes = JSON.parse(sessionStorage.getItem('connectionsColumnDefs')); + } + $scope.$on('ngGridEventColumns', function (newColumns) { + ARTEMIS.log.debug('ngGridEventColumns:', newColumns); + var visibles = newColumns.targetScope.columns.reduce(function (visibles, column) { + visibles[column.field] = column.visible; + return visibles; + }, {}); + ARTEMIS.log.debug('ngGridEventColumns: visibles =', visibles); + attributes.forEach(function (attribute) { + attribute.visible = visibles[attribute.field]; + }); + sessionStorage.setItem('connectionsColumnDefs', JSON.stringify(attributes)); + }); $scope.filter = { fieldOptions: [ {id: 'CONNECTION_ID', name: 'Connection ID'}, diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js index a90c1c858d..d4e5c63274 100644 --- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js +++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/consumers.js @@ -29,7 +29,7 @@ var ARTEMIS = (function(ARTEMIS) { var objectType = "consumer"; var method = 'listConsumers(java.lang.String, int, int)'; - var attributes = [ + var defaultAttributes = [ { field: 'id', displayName: 'ID', @@ -84,6 +84,23 @@ var ARTEMIS = (function(ARTEMIS) { width: '*' } ]; + ARTEMIS.log.debug('sessionStorage: consumersColumnDefs =', sessionStorage.getItem('consumersColumnDefs')); + var attributes = defaultAttributes; + if (sessionStorage.getItem('consumersColumnDefs')) { + attributes = JSON.parse(sessionStorage.getItem('consumersColumnDefs')); + } + $scope.$on('ngGridEventColumns', function (newColumns) { + ARTEMIS.log.debug('ngGridEventColumns:', newColumns); + var visibles = newColumns.targetScope.columns.reduce(function (visibles, column) { + visibles[column.field] = column.visible; + return visibles; + }, {}); + ARTEMIS.log.debug('ngGridEventColumns: visibles =', visibles); + attributes.forEach(function (attribute) { + attribute.visible = visibles[attribute.field]; + }); + sessionStorage.setItem('consumersColumnDefs', JSON.stringify(attributes)); + }); $scope.filter = { fieldOptions: [ {id: 'ID', name: 'ID'}, diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/producers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/producers.js index d55754ba08..fe597d6a35 100644 --- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/producers.js +++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/producers.js @@ -29,7 +29,7 @@ var ARTEMIS = (function(ARTEMIS) { var objectType = "producer"; var method = 'listProducers(java.lang.String, int, int)'; - var attributes = [ + var defaultAttributes = [ { field: 'id', displayName: 'ID', @@ -79,6 +79,23 @@ var ARTEMIS = (function(ARTEMIS) { sortable: false } ]; + ARTEMIS.log.debug('sessionStorage: producersColumnDefs =', sessionStorage.getItem('producersColumnDefs')); + var attributes = defaultAttributes; + if (sessionStorage.getItem('producersColumnDefs')) { + attributes = JSON.parse(sessionStorage.getItem('producersColumnDefs')); + } + $scope.$on('ngGridEventColumns', function (newColumns) { + ARTEMIS.log.debug('ngGridEventColumns:', newColumns); + var visibles = newColumns.targetScope.columns.reduce(function (visibles, column) { + visibles[column.field] = column.visible; + return visibles; + }, {}); + ARTEMIS.log.debug('ngGridEventColumns: visibles =', visibles); + attributes.forEach(function (attribute) { + attribute.visible = visibles[attribute.field]; + }); + sessionStorage.setItem('producersColumnDefs', JSON.stringify(attributes)); + }); $scope.filter = { fieldOptions: [ {id: 'ID', name: 'ID'}, diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js index c2f575e846..a1db1af851 100644 --- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js +++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/sessions.js @@ -29,7 +29,7 @@ var ARTEMIS = (function(ARTEMIS) { var objectType = "sessions" var method = 'listSessions(java.lang.String, int, int)'; - var attributes = [ + var defaultAttributes = [ { field: 'id', displayName: 'ID', @@ -64,6 +64,23 @@ var ARTEMIS = (function(ARTEMIS) { width: '*' }, ]; + ARTEMIS.log.debug('sessionStorage: sessionsColumnDefs =', sessionStorage.getItem('sessionsColumnDefs')); + var attributes = defaultAttributes; + if (sessionStorage.getItem('sessionsColumnDefs')) { + attributes = JSON.parse(sessionStorage.getItem('sessionsColumnDefs')); + } + $scope.$on('ngGridEventColumns', function (newColumns) { + ARTEMIS.log.debug('ngGridEventColumns:', newColumns); + var visibles = newColumns.targetScope.columns.reduce(function (visibles, column) { + visibles[column.field] = column.visible; + return visibles; + }, {}); + ARTEMIS.log.debug('ngGridEventColumns: visibles =', visibles); + attributes.forEach(function (attribute) { + attribute.visible = visibles[attribute.field]; + }); + sessionStorage.setItem('sessionsColumnDefs', JSON.stringify(attributes)); + }); $scope.filter = { fieldOptions: [ {id: 'ID', name: 'ID'},