From 68cd905240f2bc1a9611004d3d5efad9e39481b8 Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Thu, 19 Oct 2017 16:11:05 -0400 Subject: [PATCH 1/2] Removed unnecessary filtercount functions from explorer views field subquery_count is used as this does not change with the max_results_per_page flag --- .../catalogs/catalog-explorer.component.js | 16 +- client/app/catalogs/catalog-explorer.html | 2 +- .../order-explorer.component.js | 37 +-- .../service-explorer.component.js | 46 +--- .../service-explorer.component.spec.js | 16 +- .../service-explorer/service-explorer.html | 245 +++++++++--------- 6 files changed, 165 insertions(+), 197 deletions(-) diff --git a/client/app/catalogs/catalog-explorer.component.js b/client/app/catalogs/catalog-explorer.component.js index b32f44894..64fb7f491 100644 --- a/client/app/catalogs/catalog-explorer.component.js +++ b/client/app/catalogs/catalog-explorer.component.js @@ -90,23 +90,13 @@ function ComponentController ($state, CatalogsState, ListView, EventNotification return CatalogsState.getServiceTemplates(limit, offset).then(success, failure) function success (response) { - vm.serviceTemplateList = response.resources - CatalogsState.getCatalogs(limit, offset).then((response) => { vm.catalogsList = response.resources vm.loading = false - vm.toolbarConfig.filterConfig = getFilterConfig() - getFilterCount() }) - - function getFilterCount () { - CatalogsState.getMinimal('service_templates').then(success, failure) - - function success (result) { - vm.filterCount = result.subcount - vm.toolbarConfig.filterConfig.resultsCount = result.subcount - } - } + vm.serviceTemplateList = response.resources + vm.toolbarConfig.filterConfig = getFilterConfig() + vm.toolbarConfig.filterConfig.resultsCount = response.subquery_count } function failure (_error) { diff --git a/client/app/catalogs/catalog-explorer.html b/client/app/catalogs/catalog-explorer.html index d89ec2282..50b557350 100644 --- a/client/app/catalogs/catalog-explorer.html +++ b/client/app/catalogs/catalog-explorer.html @@ -21,7 +21,7 @@ - diff --git a/client/app/orders/order-explorer/order-explorer.component.js b/client/app/orders/order-explorer/order-explorer.component.js index fbc382626..5c30471a7 100644 --- a/client/app/orders/order-explorer/order-explorer.component.js +++ b/client/app/orders/order-explorer/order-explorer.component.js @@ -9,7 +9,7 @@ export const OrderExplorerComponent = { /** @ngInject */ function ComponentController ($filter, $state, lodash, ListView, Language, OrdersState, ShoppingCart, EventNotifications, Session, RBAC, ModalService, - CollectionsApi, sprintf, Polling, POLLING_INTERVAL) { + CollectionsApi, sprintf, Polling, POLLING_INTERVAL) { const vm = this vm.permissions = OrdersState.getPermissions() vm.$onInit = activate() @@ -130,6 +130,7 @@ function ComponentController ($filter, $state, lodash, ListView, Language, Order return checkApproval() ? menuActions : null } + function expandRow (item) { if (!item.disableRowExpansion) { item.isExpanded = !item.isExpanded @@ -204,17 +205,16 @@ function ComponentController ($filter, $state, lodash, ListView, Language, Order var existingOrders = (angular.isDefined(vm.ordersList) && refresh ? angular.copy(vm.ordersList) : []) vm.offset = offset - getFilterCount().then(() => { - OrdersState.getOrders( - limit, - offset, - OrdersState.getFilters(), - OrdersState.getSort().currentField, - OrdersState.getSort().isAscending, - refresh).then(querySuccess, queryFailure) - }) + OrdersState.getOrders( + limit, + offset, + OrdersState.getFilters(), + OrdersState.getSort().currentField, + OrdersState.getSort().isAscending, + refresh).then(querySuccess, queryFailure) function querySuccess (response) { + vm.filterCount = response.subquery_count vm.loading = false vm.orders = [] vm.selectedItemsList = [] @@ -260,22 +260,6 @@ function ComponentController ($filter, $state, lodash, ListView, Language, Order } } - function getFilterCount () { - return new Promise((resolve, reject) => { - OrdersState.getMinimal(OrdersState.getFilters()).then(querySuccess, queryFailure) - - function querySuccess (result) { - vm.filterCount = result.subcount - resolve() - } - - function queryFailure (_error) { - EventNotifications.error(__('There was an error loading orders.')) - reject(__('There was an error loading orders.')) - } - }) - } - function duplicateOrder (item) { ShoppingCart.reset() ShoppingCart.delete() @@ -297,6 +281,7 @@ function ComponentController ($filter, $state, lodash, ListView, Language, Order function checkApproval () { return lodash.reduce(lodash.map(['miq_request_approval', 'miq_request_admin'], RBAC.has)) } + function requestStatus (item) { let status = item.request_state if ((item.request_state === 'finished' && item.status !== 'Ok') || (item.request_state !== 'finished')) { diff --git a/client/app/services/service-explorer/service-explorer.component.js b/client/app/services/service-explorer/service-explorer.component.js index 4247c4915..5757baba5 100644 --- a/client/app/services/service-explorer/service-explorer.component.js +++ b/client/app/services/service-explorer/service-explorer.component.js @@ -32,7 +32,6 @@ function ComponentController ($state, ServicesState, Language, ListView, Chargeb title: __('Services'), services: [], limit: 20, - filterCount: 0, servicesList: [], selectedItemsList: [], limitOptions: [5, 10, 20, 50, 100, 200, 500, 1000], @@ -348,11 +347,11 @@ function ComponentController ($state, ServicesState, Language, ListView, Chargeb } if (tag.name.match(/\//g).length === 3) { filterCategories[tag.name.substring(-1, tag.name.lastIndexOf('/'))] - .filterValues - .push({ - title: displayName.substr(displayName.lastIndexOf(':') + 1), - id: tag.name.substr(tag.name.lastIndexOf('/') + 1) - }) + .filterValues + .push({ + title: displayName.substr(displayName.lastIndexOf(':') + 1), + id: tag.name.substr(tag.name.lastIndexOf('/') + 1) + }) } }) @@ -383,37 +382,18 @@ function ComponentController ($state, ServicesState, Language, ListView, Chargeb ] } - function getFilterCount () { - return new Promise((resolve, reject) => { - ServicesState.getServicesMinimal(ServicesState.services.getFilters()) - .then(querySuccess, queryFailure) - - function querySuccess (result) { - vm.filterCount = result.subcount - vm.toolbarConfig.filterConfig.resultsCount = vm.filterCount - resolve() - } - - function queryFailure (_error) { - vm.loading = false - EventNotifications.error(__('There was an error loading the services.')) - reject(__('There was an error loading the services.')) - } - }) - } - function resolveServices (limit, offset, refresh) { Polling.stop('serviceListPolling') vm.loading = !refresh vm.offset = offset - getFilterCount().then(() => { - ServicesState.getServices( - limit, - offset, - refresh).then(querySuccess, queryFailure) - }) + + ServicesState.getServices( + limit, + offset, + refresh).then(querySuccess, queryFailure) function querySuccess (result) { + vm.toolbarConfig.filterConfig.resultsCount = result.subquery_count Polling.start('serviceListPolling', pollUpdateServicesList, vm.pollingInterval) vm.services = [] var existingServices = (angular.isDefined(vm.servicesList) && refresh ? angular.copy(vm.servicesList) : []) @@ -513,8 +493,8 @@ function ComponentController ($state, ServicesState, Language, ListView, Chargeb lodash.partial(TagEditorModal.showModal, services) return TaggingService.queryAvailableTags() - .then(extractSharedTagsFromSelectedServices) - .then(launchTagEditorForSelectedServices) + .then(extractSharedTagsFromSelectedServices) + .then(launchTagEditorForSelectedServices) } function doRemoveServices (services) { diff --git a/client/app/services/service-explorer/service-explorer.component.spec.js b/client/app/services/service-explorer/service-explorer.component.spec.js index 3e46b97c0..7649336e1 100644 --- a/client/app/services/service-explorer/service-explorer.component.spec.js +++ b/client/app/services/service-explorer/service-explorer.component.spec.js @@ -74,9 +74,19 @@ describe('Component: serviceExplorer', () => { it('should make a query for services', () => { collectionsApiMock - .expects('query') - .withArgs('services', {filter: ['ancestry=null', 'display=true']}) - .returns(Promise.resolve()) + .expects('query') + .withArgs('services', { + attributes: ['picture', 'picture.image_href', 'chargeback_report', 'evm_owner.userid', 'v_total_vms', 'power_state', 'all_service_children', 'tags'], + auto_refresh: undefined, + expand: 'resources', + filter: ['ancestry=null', 'display=true'], + limit: 20, + offset: '0', + sort_by: 'created_at', + sort_options: '', + sort_order: 'desc' + }) + .returns(Promise.resolve()) ctrl.resolveServices(20, 0) diff --git a/client/app/services/service-explorer/service-explorer.html b/client/app/services/service-explorer/service-explorer.html index 749372baa..4f8237020 100644 --- a/client/app/services/service-explorer/service-explorer.html +++ b/client/app/services/service-explorer/service-explorer.html @@ -4,37 +4,37 @@
  • {{ 'My Services' | translate }}
  • -
    -
    - +
    +
    + +
    -
    - - - - + + + +
    - - -
    -
    + + +
    +
    -
    -
    +
    +
    -
    -
    +
    +
    {{item.playbook}} -
    - - - + + +
    -
    - - -
    -
    +
    +
    + + +
    +
    -
    -
    -
    - - - -
    - -
    -
    -
    +
    +
    +
    + + + +
    + +
    + +
    - - \ No newline at end of file +
    From 778dd3919cf5824c72b26f6d446ae52924bbcf7c Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Fri, 20 Oct 2017 07:40:37 -0400 Subject: [PATCH 2/2] Update navigation badges to utilize subquery_count --- client/app/core/navigation.service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/app/core/navigation.service.js b/client/app/core/navigation.service.js index 871da1043..538805f3f 100644 --- a/client/app/core/navigation.service.js +++ b/client/app/core/navigation.service.js @@ -95,7 +95,7 @@ export function NavigationFactory (RBAC, Polling, POLLING_INTERVAL, CollectionsA return new Promise((resolve, reject) => { CollectionsApi.query(field, options) .then((data) => { - resolve(data.subcount) + resolve(data.count) }) }) }