From 88e42fe9a38cc51e1f8bcb4b82a738491af22e55 Mon Sep 17 00:00:00 2001 From: Paul Van Eck Date: Mon, 17 Jul 2017 22:10:06 -0700 Subject: [PATCH] Add UI support for interop schema 2.0 New schema[1] will be released soon, so RefStack UI needs to be able to handle it. [1] https://review.openstack.org/#/c/430556 Change-Id: Ifdfe40c12a7a97ff742ed15aeb5d9ce399ee3cb1 --- .../app/components/guidelines/guidelines.html | 4 +- .../guidelines/guidelinesController.js | 43 +++++- .../guidelines/partials/guidelineDetails.html | 10 +- .../results-report/resultsReport.html | 4 +- .../results-report/resultsReportController.js | 43 +++++- refstack-ui/tests/unit/ControllerSpec.js | 128 +++++++++++++++++- refstack/api/guidelines.py | 33 ++++- refstack/tests/unit/test_guidelines.py | 94 +++++++++++++ 8 files changed, 333 insertions(+), 26 deletions(-) diff --git a/refstack-ui/app/components/guidelines/guidelines.html b/refstack-ui/app/components/guidelines/guidelines.html index 1dd39ff1..0f8aac7d 100644 --- a/refstack-ui/app/components/guidelines/guidelines.html +++ b/refstack-ui/app/components/guidelines/guidelines.html @@ -25,13 +25,13 @@
Guideline Status: - {{ctrl.guidelines.status | capitalize}} + {{ctrl.guidelineStatus | capitalize}}
Corresponding OpenStack Releases: diff --git a/refstack-ui/app/components/guidelines/guidelinesController.js b/refstack-ui/app/components/guidelines/guidelinesController.js index 7236d873..34950fbe 100644 --- a/refstack-ui/app/components/guidelines/guidelinesController.js +++ b/refstack-ui/app/components/guidelines/guidelinesController.js @@ -87,7 +87,22 @@ ctrl.capsRequest = $http.get(content_url).success(function (data) { ctrl.guidelines = data; + if ('metadata' in data && data.metadata.schema >= '2.0') { + ctrl.schema = data.metadata.schema; + ctrl.criteria = data.metadata.scoring.criteria; + ctrl.releases = + data.metadata.os_trademark_approval.releases; + ctrl.guidelineStatus = + data.metadata.os_trademark_approval.status; + } + else { + ctrl.schema = data.schema; + ctrl.criteria = data.criteria; + ctrl.releases = data.releases; + ctrl.guidelineStatus = data.status; + } ctrl.updateTargetCapabilities(); + }).error(function (error) { ctrl.showError = true; ctrl.guidelines = null; @@ -110,8 +125,24 @@ // The 'platform' target is comprised of multiple components, so // we need to get the capabilities belonging to each of its // components. - if (ctrl.target === 'platform') { - var platform_components = ctrl.guidelines.platform.required; + if (ctrl.target === 'platform' || ctrl.schema >= '2.0') { + if (ctrl.schema >= '2.0') { + var platformsMap = { + 'platform': 'OpenStack Powered Platform', + 'compute': 'OpenStack Powered Compute', + 'object': 'OpenStack Powered Storage' + }; + + var targetComponents = ctrl.guidelines.platforms[ + platformsMap[ctrl.target]].components.map( + function(c) { + return c.name; + } + ); + } + else { + var targetComponents = ctrl.guidelines.platform.required; + } // This will contain status priority values, where lower // values mean higher priorities. @@ -123,9 +154,13 @@ }; // For each component required for the platform program. - angular.forEach(platform_components, function (component) { + angular.forEach(targetComponents, function (component) { // Get each capability list belonging to each status. - angular.forEach(components[component], + var componentList = components[component]; + if (ctrl.schema >= '2.0') { + componentList = componentList.capabilities; + } + angular.forEach(componentList, function (caps, status) { // For each capability. angular.forEach(caps, function(cap) { diff --git a/refstack-ui/app/components/guidelines/partials/guidelineDetails.html b/refstack-ui/app/components/guidelines/partials/guidelineDetails.html index f020c9a0..2b345867 100644 --- a/refstack-ui/app/components/guidelines/partials/guidelineDetails.html +++ b/refstack-ui/app/components/guidelines/partials/guidelineDetails.html @@ -19,11 +19,11 @@ variable 'guidelines'. Tests ({{ctrl.getObjectLength(capability.tests)}})