# HG changeset patch # User Andrew Azores # Date 1505501853 14400 # Node ID 4678908372505bfbf60168385bbb1caa3645a40a # Parent 2554d338104fba6d7a1028c1f40ab440dd122424 Fix bug where jvm-list results do not display immediately Reviewed-by: jkang Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/025072.html diff -r 2554d338104f -r 467890837250 src/app/components/jvm-list/jvm-list.controller.js --- a/src/app/components/jvm-list/jvm-list.controller.js Mon Sep 18 14:41:36 2017 -0400 +++ b/src/app/components/jvm-list/jvm-list.controller.js Fri Sep 15 14:57:33 2017 -0400 @@ -40,9 +40,9 @@ this.translate = $translate; this.systemsOpen = {}; + this.aliveOnly = true; + this.pageConfig = { showPaginationControls: false }; - this.sortConfig = {}; - this.filterConfig = {}; this.listConfig = { showSelectBox: false, useExpandingRows: true, @@ -56,6 +56,8 @@ this.emptyStateConfig = { icon: 'pficon-warning-triangle-o', }; + + this.constructToolbarSettings(); } $onInit () { @@ -63,7 +65,6 @@ this.translate('jvmList.ERR_MESSAGE').then(s => this.emptyStateConfig.info = s); this.location.hash(''); - this.aliveOnly = true; let aliveOnlySwitch = angular.element('#aliveOnlyState'); aliveOnlySwitch.bootstrapSwitch(); aliveOnlySwitch.on('switchChange.bootstrapSwitch', (event, state) => { @@ -72,7 +73,6 @@ }); this.loadData(); - this.constructToolbarSettings(); } /** @@ -130,17 +130,18 @@ pageSize: 5 } }); + if (this.systems.length === 1) { + this.systemsOpen[this.systems[0].systemId] = true; + } + this.pageConfig.numTotalItems = this.allItems.length; + this.pageConfig.pageSize = this.allItems.length; + this.pageConfig.pageNumber = 1; + this.listConfig.itemsAvailable = true; + this.toolbarConfig.filterConfig.resultsCount = this.systems.length; + this.toolbarConfig.filterConfig.totalCount = this.allItems.length; } ); } - if (this.systems.length === 1) { - this.systemsOpen[this.systems[0].systemId] = true; - } - this.pageConfig.numTotalItems = this.allItems.length; - this.pageConfig.pageSize = this.allItems.length; - this.pageConfig.pageNumber = 1; - this.listConfig.itemsAvailable = true; - this.toolbarConfig.filterConfig.resultsCount = this.systems.length; }, () => { this.listConfig.itemsAvailable = false; @@ -152,57 +153,66 @@ } constructToolbarSettings () { - this.filterConfig = { - fields: [ - { - id: 'hostname', - filterType: 'text' - }, - { - id: 'jvmName', - filterType: 'text' + this.translate([ + 'jvmList.HOSTNAME_TITLE', + 'jvmList.filterConfig.HOSTNAME_PLACEHOLDER', + 'jvmList.filterConfig.JVM_NAME_TITLE', + 'jvmList.filterConfig.JVM_NAME_PLACEHOLDER', + 'jvmList.sortConfig.TIME_CREATED_TITLE', + 'jvmList.sortConfig.NUM_JVMS_TITLE' + ]).then(translations => { + this.filterConfig = { + fields: [ + { + id: 'hostname', + filterType: 'text', + title: translations['jvmList.HOSTNAME_TITLE'], + placeholder: translations['jvmList.filterConfig.HOSTNAME_PLACEHOLDER'] + }, + { + id: 'jvmName', + filterType: 'text', + title: translations['jvmList.filterConfig.JVM_NAME_TITLE'], + placeholder: translations['jvmList.filterConfig.JVM_NAME_PLACEHOLDER'] + } + ], + resultsCount: 0, + totalCount: 0, + appliedFilters: [], + onFilterChange: filters => { + this.applyFilters(filters); + this.toolbarConfig.filterConfig.resultsCount = this.items.length; } - ], - resultsCount: this.items.length, - totalCount: this.allItems.length, - appliedFilters: [], - onFilterChange: filters => { - this.applyFilters(filters); - this.toolbarConfig.filterConfig.resultsCount = this.items.length; - } - }; - this.translate('jvmList.HOSTNAME_TITLE').then(s => this.filterConfig.fields[0].title = s); - this.translate('jvmList.filterConfig.HOSTNAME_PLACEHOLDER').then(s => this.filterConfig.fields[0].placeholder = s); - this.translate('jvmList.filterConfig.JVM_NAME_TITLE').then(s => this.filterConfig.fields[1].title = s); - this.translate('jvmList.filterConfig.JVM_NAME_PLACEHOLDER').then(s => this.filterConfig.fields[1].placeholder = s); + }; - this.sortConfig = { - fields: [ - { - id: 'name', - sortType: 'alpha' - }, - { - id: 'timeCreated', - sortType: 'numeric' - }, - { - id: 'numJvms', - sortType: 'numeric' + this.sortConfig = { + fields: [ + { + id: 'name', + sortType: 'alpha', + title: translations['jvmList.HOSTNAME_TITLE'] + }, + { + id: 'timeCreated', + sortType: 'numeric', + title: translations['jvmList.sortConfig.TIME_CREATED_TITLE'] + }, + { + id: 'numJvms', + sortType: 'numeric', + title: translations['jvmList.sortConfig.NUM_JVMS_TITLE'] + } + ], + onSortChange: () => { + this.sortItems(); } - ], - onSortChange: () => { - this.sortItems(); - } - }; - this.translate('jvmList.HOSTNAME_TITLE').then(s => this.sortConfig.fields[0].title = s); - this.translate('jvmList.sortConfig.TIME_CREATED_TITLE').then(s => this.sortConfig.fields[1].title = s); - this.translate('jvmList.sortConfig.NUM_JVMS_TITLE').then(s => this.sortConfig.fields[2].title = s); + }; - this.toolbarConfig = { - filterConfig: this.filterConfig, - sortConfig: this.sortConfig - }; + this.toolbarConfig = { + filterConfig: this.filterConfig, + sortConfig: this.sortConfig + }; + }); } /** diff -r 2554d338104f -r 467890837250 src/app/components/jvm-list/jvm-list.controller.spec.js --- a/src/app/components/jvm-list/jvm-list.controller.spec.js Mon Sep 18 14:41:36 2017 -0400 +++ b/src/app/components/jvm-list/jvm-list.controller.spec.js Fri Sep 15 14:57:33 2017 -0400 @@ -89,7 +89,7 @@ }; timeout = sinon.spy(); translate = sinon.stub().returns({ - then: sinon.stub().yields() + then: sinon.stub().yields({}) }); jvmListSvc = { @@ -209,7 +209,7 @@ foo: false, bar: false }); - controller.listConfig.itemsAvailable = true; + controller.listConfig.itemsAvailable.should.be.True(); done(); }); @@ -230,7 +230,7 @@ foo: false, bar: false }); - controller.listConfig.itemsAvailable = true; + controller.listConfig.itemsAvailable.should.be.True(); done(); }); @@ -247,7 +247,7 @@ controller.systemsOpen.should.deepEqual({ foo: true }); - controller.listConfig.itemsAvailable = true; + controller.listConfig.itemsAvailable.should.be.True(); done(); }); @@ -256,7 +256,7 @@ rootScope.$apply(); controller.should.have.ownProperty('showErr'); controller.showErr.should.equal(true); - controller.listConfig.itemsAvailable = false; + controller.listConfig.itemsAvailable.should.be.False(); done(); }); });