From 655a7ffefd99cc12a93466439eda2a6dcd46956d Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Fri, 9 Jun 2017 17:00:35 -0400 Subject: [PATCH 1/6] Adds icon-status component Takes 5 parameteres - status - string of the current status - success - array of strings for which to display the success icon - error - array of strings for which to display the error icon - queued - array of strings for which to display the circle clock icon - inprogress - array of strings for which to display the in progress spinner If none of the following inputs match the status, the unknown icon will be displayed --- client/app/shared/icon-status.component.js | 48 ++++++++++++++++++++++ client/app/shared/shared.module.js | 2 + 2 files changed, 50 insertions(+) create mode 100644 client/app/shared/icon-status.component.js diff --git a/client/app/shared/icon-status.component.js b/client/app/shared/icon-status.component.js new file mode 100644 index 000000000..344df0fa4 --- /dev/null +++ b/client/app/shared/icon-status.component.js @@ -0,0 +1,48 @@ +export const IconStatusComponent = { + controllerAs: 'vm', + controller: ComponentController, + bindings: { + status: '<', + success: ' + + + + + `, +}; + +/** @ngInject */ +function ComponentController() { + const vm = this; + vm.$onChanges = function() { + angular.extend(vm, { + isSuccess: vm.success ? vm.success.some((status) => status === vm.status) : false, + isError: vm.error ? vm.error.some((status) => status === vm.status) : false, + isQueued: vm.queued ? vm.queued.some((status) => status === vm.status) : false, + isInprogress: vm.inprogress ? vm.inprogress.some((status) => status === vm.status) : false, + }); + vm.isUnknown = !vm.isSuccess && !vm.isError && !vm.isQueued && !vm.isInprogress; + }; +} diff --git a/client/app/shared/shared.module.js b/client/app/shared/shared.module.js index 3ee6734ac..b1cc77144 100644 --- a/client/app/shared/shared.module.js +++ b/client/app/shared/shared.module.js @@ -7,6 +7,7 @@ import {CustomDropdownComponent} from "./custom-dropdown/custom-dropdown.compone import {DialogContentComponent} from "./dialog-content/dialog-content.component.js"; import {ElapsedTime} from "./elapsedTime.filter.js"; import {IconListComponent} from "./icon-list/icon-list.component.js"; +import {IconStatusComponent} from './icon-status.component.js'; import {LoadingComponent} from "./loading.component.js"; import {PaginationComponent} from "./pagination/pagination.component.js"; import {SSCardComponent} from "./ss-card/ss-card.component.js"; @@ -30,6 +31,7 @@ export const SharedModule = angular .component('dialogContent', DialogContentComponent) .component('explorerPagination', PaginationComponent) .component('iconList', IconListComponent) + .component('iconStatus', IconStatusComponent) .component('loading', LoadingComponent) .component('ssCard', SSCardComponent) .component('taggingWidget', TaggingComponent) From b4a3a07fe4becde991688b0a638166dfceef7964 Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Mon, 12 Jun 2017 09:40:06 -0400 Subject: [PATCH 2/6] Normalize status and status values, fix typos --- client/app/shared/icon-status.component.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client/app/shared/icon-status.component.js b/client/app/shared/icon-status.component.js index 344df0fa4..6594f0c53 100644 --- a/client/app/shared/icon-status.component.js +++ b/client/app/shared/icon-status.component.js @@ -10,23 +10,23 @@ export const IconStatusComponent = { }, template: ` @@ -34,14 +34,16 @@ export const IconStatusComponent = { }; /** @ngInject */ -function ComponentController() { +function ComponentController(lodash) { const vm = this; vm.$onChanges = function() { + vm.status = lodash.capitalize(vm.status); + angular.extend(vm, { - isSuccess: vm.success ? vm.success.some((status) => status === vm.status) : false, - isError: vm.error ? vm.error.some((status) => status === vm.status) : false, - isQueued: vm.queued ? vm.queued.some((status) => status === vm.status) : false, - isInprogress: vm.inprogress ? vm.inprogress.some((status) => status === vm.status) : false, + isSuccess: vm.success ? vm.success.some((status) => status.toLowerCase() === vm.status.toLowerCase()) : false, + isError: vm.error ? vm.error.some((status) => status.toLowerCase() === vm.status.toLowerCase()) : false, + isQueued: vm.queued ? vm.queued.some((status) => status.toLowerCase() === vm.status.toLowerCase()) : false, + isInprogress: vm.inprogress ? vm.inprogress.some((status) => status.toLowerCase() === vm.status.toLowerCase()) : false, }); vm.isUnknown = !vm.isSuccess && !vm.isError && !vm.isQueued && !vm.isInprogress; }; From 8cf4d8639d4d2025bafac036fe433fbe18dbe131 Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Mon, 12 Jun 2017 12:55:43 -0400 Subject: [PATCH 3/6] Adds icon-status to ansible details service view Supporting succeeded/successful strings for green icon And failed/failure strings for red icon --- .../service-details/service-details-ansible.html | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/app/services/service-details/service-details-ansible.html b/client/app/services/service-details/service-details-ansible.html index 8047e75f8..3f5866c7d 100644 --- a/client/app/services/service-details/service-details-ansible.html +++ b/client/app/services/service-details/service-details-ansible.html @@ -12,8 +12,8 @@

Results

- +
@@ -94,7 +94,7 @@

Details

+ items="item.credentials" custom-scope="vm">
@@ -144,7 +144,7 @@

Details

+ items="item.jobs" custom-scope="vm">
@@ -157,9 +157,8 @@

Details

Status -
- {{ item.resource_status }} -
+
From 4e4e02128c638b99a02269905ff9fc533023b23c Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Mon, 12 Jun 2017 14:32:58 -0400 Subject: [PATCH 4/6] Adds support for normalized and raw orchestation_stack statuses https://github.com/ManageIQ/manageiq/blob/master/app/models/orchestration_stack/status.rb#L40 --- .../services/service-details/service-details-ansible.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/app/services/service-details/service-details-ansible.html b/client/app/services/service-details/service-details-ansible.html index 3f5866c7d..493eeebd5 100644 --- a/client/app/services/service-details/service-details-ansible.html +++ b/client/app/services/service-details/service-details-ansible.html @@ -12,7 +12,7 @@

Results

-
@@ -157,7 +157,8 @@

Details

Status -
From 2ea16feedac54ff20b866bbf089b4fd3dcf7b695 Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Mon, 12 Jun 2017 14:33:48 -0400 Subject: [PATCH 5/6] Adds icon-status spec [Fixes #146029083] --- .../app/shared/icon-status.component.spec.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 client/app/shared/icon-status.component.spec.js diff --git a/client/app/shared/icon-status.component.spec.js b/client/app/shared/icon-status.component.spec.js new file mode 100644 index 000000000..da2bda300 --- /dev/null +++ b/client/app/shared/icon-status.component.spec.js @@ -0,0 +1,47 @@ +describe('Component: Icon-status', () => { + let parentScope, $compile; + + beforeEach(module('app.services', 'app.shared')); + + beforeEach(inject(function(_$compile_, _$rootScope_) { + $compile = _$compile_; + parentScope = _$rootScope_.$new(); + })); + + const compileHtml = function(markup, scope) { + let element = angular.element(markup); + $compile(element)(scope); + scope.$digest(); + return element; + }; + + it('should display success when status matches success', () => { + const renderedElement = compileHtml(angular.element(``), parentScope); + + expect(renderedElement[0].querySelectorAll('.pficon-ok').length).to.eq(1); + }); + + it('should display error when status matches error', () => { + const renderedElement = compileHtml(angular.element(``), parentScope); + + expect(renderedElement[0].querySelectorAll('.pficon-error-circle-o').length).to.eq(1); + }); + + it('should display pending when status matches pending', () => { + const renderedElement = compileHtml(angular.element(``), parentScope); + + expect(renderedElement[0].querySelectorAll('.fa-clock-o').length).to.eq(1); + }); + + it('should display spinner when status is matches inprogress', () => { + const renderedElement = compileHtml(angular.element(``), parentScope); + + expect(renderedElement[0].querySelectorAll('.spinner').length).to.eq(1); + }); + + it('should display unknown when status unknown', () => { + const renderedElement = compileHtml(angular.element(``), parentScope); + + expect(renderedElement[0].querySelectorAll('.pficon-help').length).to.eq(1); + }); +}); From eec8d3c3e7a4c701eef8558e4726e30a1bc3dbfd Mon Sep 17 00:00:00 2001 From: Allen Wight Date: Mon, 19 Jun 2017 08:31:12 -0400 Subject: [PATCH 6/6] Update queued status icon --- client/app/shared/icon-status.component.js | 2 +- client/app/shared/icon-status.component.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/app/shared/icon-status.component.js b/client/app/shared/icon-status.component.js index 6594f0c53..8e0e6e1ee 100644 --- a/client/app/shared/icon-status.component.js +++ b/client/app/shared/icon-status.component.js @@ -20,7 +20,7 @@ export const IconStatusComponent = { tooltip-popup-delay="1000" tooltip-placement="bottom" /> - { it('should display pending when status matches pending', () => { const renderedElement = compileHtml(angular.element(``), parentScope); - expect(renderedElement[0].querySelectorAll('.fa-clock-o').length).to.eq(1); + expect(renderedElement[0].querySelectorAll('.fa-hourglass-half').length).to.eq(1); }); it('should display spinner when status is matches inprogress', () => {