From 5e37774a35b9bff0a8c5c6c81f34e8075531c3a0 Mon Sep 17 00:00:00 2001 From: thuva4 Date: Mon, 29 Jan 2018 17:08:17 +0530 Subject: Add deploy results Create view and controller for deploy results Add tests for deploy results Change-Id: Iba29e7a867d45aacd18a26dc4e2d9363cdf8928d Signed-off-by: thuva4 --- .../handlers/deploy_result_handlers.py | 15 + testapi/opnfv_testapi/router/url_mappings.py | 1 + .../tests/UI/e2e/deployResultsControllerSpec.js | 397 +++++++++++++++++++++ testapi/opnfv_testapi/ui/Gruntfile.js | 3 +- testapi/opnfv_testapi/ui/app.js | 10 + .../deploy-results/deploy-result/deployResult.html | 93 +++++ .../deploy-result/deployResultController.js | 65 ++++ .../components/deploy-results/deployResults.html | 126 +++++++ .../deploy-results/deployResultsController.js | 190 ++++++++++ testapi/opnfv_testapi/ui/index.html | 2 + testapi/opnfv_testapi/ui/shared/header/header.html | 1 + 11 files changed, 902 insertions(+), 1 deletion(-) create mode 100644 testapi/opnfv_testapi/tests/UI/e2e/deployResultsControllerSpec.js create mode 100644 testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResult.html create mode 100644 testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResultController.js create mode 100644 testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html create mode 100644 testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js (limited to 'testapi/opnfv_testapi') diff --git a/testapi/opnfv_testapi/handlers/deploy_result_handlers.py b/testapi/opnfv_testapi/handlers/deploy_result_handlers.py index 973bfef..a8fcd88 100644 --- a/testapi/opnfv_testapi/handlers/deploy_result_handlers.py +++ b/testapi/opnfv_testapi/handlers/deploy_result_handlers.py @@ -1,6 +1,7 @@ from opnfv_testapi.handlers import result_handlers from opnfv_testapi.models import deploy_result_models from opnfv_testapi.tornado_swagger import swagger +from bson import objectid class GenericDeployResultHandler(result_handlers.GenericResultHandler): @@ -113,3 +114,17 @@ class DeployResultsHandler(GenericDeployResultHandler): self._create(miss_fields=miss_fields, carriers=carriers, values_check=values_check) + + +class DeployResultHandler(GenericDeployResultHandler): + @swagger.operation(nickname='getTestDeployResultById') + def get(self, result_id): + """ + @description: get a single deploy result by result_id + @rtype: L{DeployResult} + @return 200: Deploy result exist + @raise 404: Deploy result not exist + """ + query = dict() + query["_id"] = objectid.ObjectId(result_id) + self._get_one(query=query) diff --git a/testapi/opnfv_testapi/router/url_mappings.py b/testapi/opnfv_testapi/router/url_mappings.py index a857725..b9dd231 100644 --- a/testapi/opnfv_testapi/router/url_mappings.py +++ b/testapi/opnfv_testapi/router/url_mappings.py @@ -52,6 +52,7 @@ mappings = [ (r'/api/v1/results/upload', result_handlers.ResultsUploadHandler), (r"/api/v1/results/([^/]+)", result_handlers.ResultsGURHandler), (r"/api/v1/deployresults", deploy_handlers.DeployResultsHandler), + (r"/api/v1/deployresults/([^/]+)", deploy_handlers.DeployResultHandler), # scenarios (r"/api/v1/scenarios", scenario_handlers.ScenariosCLHandler), diff --git a/testapi/opnfv_testapi/tests/UI/e2e/deployResultsControllerSpec.js b/testapi/opnfv_testapi/tests/UI/e2e/deployResultsControllerSpec.js new file mode 100644 index 0000000..e00243b --- /dev/null +++ b/testapi/opnfv_testapi/tests/UI/e2e/deployResultsControllerSpec.js @@ -0,0 +1,397 @@ +'use strict'; + +var mock = require('protractor-http-mock'); +var baseURL = "http://localhost:8000/" + +describe('testing the result page for anonymous user', function () { + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/pods', + method: 'GET' + }, + response: { + data: { + pods: [{role: "community-ci", name: "test", owner: "testUser", + details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed", + creation_date: "2017-10-25 11:58:25.926168"}] + } + } + }, + { + request: { + path: '/api/v1/deployresults', + method: 'GET', + queryString: { + page: '1' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "deployresults": [ + { + "build_id": 411, + "upstream_build_id": 184, + "scenario": "os-nosdn-nofeature-ha", + "stop_date": "2018-01-2723:21:31.3N", + "start_date": "2018-01-2723:21:28.3N", + "upstream_job_name": "daisy-os-nosdn-nofeature-ha-baremetal-daily-master", + "version": "master", + "pod_name": "zte-pod", + "criteria": "PASS", + "installer": "daisy", + "_id": "5a6dc1089a07c80f3c9f8d62", + "job_name": "daisy-deploy-baremetal-daily-master", + "details": null + } + ] + } + } + }, + { + request: { + path: '/api/v1/deployresults', + method: 'GET', + queryString: { + page: '1', + installer: 'daisy' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "deployresults": [ + { + "build_id": 411, + "upstream_build_id": 184, + "scenario": "os-nosdn-nofeature-ha", + "stop_date": "2018-01-2723:21:31.3N", + "start_date": "2018-01-2723:21:28.3N", + "upstream_job_name": "daisy-os-nosdn-nofeature-ha-baremetal-daily-master", + "version": "master", + "pod_name": "zte-pod", + "criteria": "PASS", + "installer": "daisy", + "_id": "5a6dc1089a07c80f3c9f8d63", + "job_name": "daisy-deploy-baremetal-daily-master", + "details": null + } + ] + } + } + }, + { + request: { + path: '/api/v1/deployresults', + method: 'GET', + queryString: { + page: '1', + installer: 'daisy', + job_name: 'daisy-deploy-baremetal-daily-master' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "deployresults": [ + { + "build_id": 411, + "upstream_build_id": 184, + "scenario": "os-nosdn-nofeature-ha", + "stop_date": "2018-01-2723:21:31.3N", + "start_date": "2018-01-2723:21:28.3N", + "upstream_job_name": "daisy-os-nosdn-nofeature-ha-baremetal-daily-master", + "version": "master", + "pod_name": "zte-pod", + "criteria": "PASS", + "installer": "daisy", + "_id": "5a6dc1089a07c80f3c9f8d64", + "job_name": "daisy-deploy-baremetal-daily-master", + "details": null + } + ] + } + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'should show the deploy results page for anonymous user', function() { + browser.get(baseURL+"#/deployresults"); + expect(element(by.cssContainingText(".ng-binding.ng-scope","Deploy Results")).isDisplayed()).toBe(true); + }); + + it( 'navigate anonymous user to results page', function() { + browser.get(baseURL); + var resultLink = element(by.linkText('Deploy Results')).click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '#/deployresults'), 10000); + }); + + it('Should show the results in results page for anonymous user ', function () { + browser.get(baseURL+"#/deployresults"); + var row = element.all(by.repeater('(index, result) in ctrl.data.deployresults')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("3c9f8d62"); + }); + + it('Should show the results in results page related to the filters for anonymous user ', function () { + browser.get(baseURL+"#/deployresults"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('installer'); + filterText.sendKeys('daisy'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + var row = element.all(by.repeater('(index, result) in ctrl.data.deployresults')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("3c9f8d63"); + filter.sendKeys('job_name'); + filterText.sendKeys('daisy-deploy-baremetal-daily-master') + buttonFilter.click(); + expect(cells.get(0).getText()).toContain("3c9f8d64"); + }); + it('Should not show the results in results page related to the filters for anonymous user ', function () { + browser.get(baseURL+"#/deployresults"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('installer'); + filterText.sendKeys('daisyl'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope')) + .isDisplayed()).toBe(true); + }); + +}); + +describe('testing the result page for user', function () { + beforeEach(function(){ + mock([ + { + request: { + path: '/api/v1/pods', + method: 'GET' + }, + response: { + data: { + pods: [{role: "community-ci", name: "test", owner: "testUser", + details: "DemoDetails", mode: "metal", _id: "59f02f099a07c84bfc5c7aed", + creation_date: "2017-10-25 11:58:25.926168"}] + } + } + }, + { + request: { + path: '/api/v1/profile', + method: 'GET' + }, + response: { + data: { + "fullname": "Test User", "_id": "79f82eey9a00c84bfhc7aed", + "user": "testUser", "groups": ["opnfv-testapi-users"], + "email": "testuser@test.com" + } + } + }, + { + request: { + path: '/api/v1/deployresults', + method: 'GET', + queryString: { + page: '1' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "deployresults": [ + { + "build_id": 411, + "upstream_build_id": 184, + "scenario": "os-nosdn-nofeature-ha", + "stop_date": "2018-01-2723:21:31.3N", + "start_date": "2018-01-2723:21:28.3N", + "upstream_job_name": "daisy-os-nosdn-nofeature-ha-baremetal-daily-master", + "version": "master", + "pod_name": "zte-pod", + "criteria": "PASS", + "installer": "daisy", + "_id": "5a6dc1089a07c80f3c9f8d62", + "job_name": "daisy-deploy-baremetal-daily-master", + "details": null + } + ] + } + } + }, + { + request: { + path: '/api/v1/deployresults', + method: 'GET', + queryString: { + page: '1', + installer: 'daisy' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "deployresults": [ + { + "build_id": 411, + "upstream_build_id": 184, + "scenario": "os-nosdn-nofeature-ha", + "stop_date": "2018-01-2723:21:31.3N", + "start_date": "2018-01-2723:21:28.3N", + "upstream_job_name": "daisy-os-nosdn-nofeature-ha-baremetal-daily-master", + "version": "master", + "pod_name": "zte-pod", + "criteria": "PASS", + "installer": "daisy", + "_id": "5a6dc1089a07c80f3c9f8d63", + "job_name": "daisy-deploy-baremetal-daily-master", + "details": null + } + ] + } + } + }, + { + request: { + path: '/api/v1/deployresults', + method: 'GET', + queryString: { + page: '1', + installer: 'daisy', + job_name : 'daisy-deploy-baremetal-daily-master' + } + }, + response: { + data: { + "pagination": { + "current_page": 1, + "total_pages": 1 + }, + "deployresults": [ + { + "build_id": 411, + "upstream_build_id": 184, + "scenario": "os-nosdn-nofeature-ha", + "stop_date": "2018-01-2723:21:31.3N", + "start_date": "2018-01-2723:21:28.3N", + "upstream_job_name": "daisy-os-nosdn-nofeature-ha-baremetal-daily-master", + "version": "master", + "pod_name": "zte-pod", + "criteria": "PASS", + "installer": "daisy", + "_id": "5a6dc1089a07c80f3c9f8d64", + "job_name": "daisy-deploy-baremetal-daily-master", + "details": null + } + ] + } + } + } + ]); + }); + + afterEach(function(){ + mock.teardown(); + }); + + it( 'should show the deploy results page for user', function() { + browser.get(baseURL+"#/deployresults"); + expect(element(by.cssContainingText(".ng-binding.ng-scope","Deploy Results")).isDisplayed()).toBe(true); + }); + + it( 'navigate user to results page', function() { + browser.get(baseURL); + var resultLink = element(by.linkText('Deploy Results')).click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains(baseURL+ '#/deployresults'), 10000); + }); + + it('Should show the results in results page for user ', function () { + browser.get(baseURL+"#/deployresults"); + var row = element.all(by.repeater('(index, result) in ctrl.data.deployresults')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("3c9f8d62"); + }); + + it('Should show the results in results page related to the filters for user ', function () { + browser.get(baseURL+"#/deployresults"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('installer'); + filterText.sendKeys('daisy'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + var row = element.all(by.repeater('(index, result) in ctrl.data.deployresults')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("3c9f8d63"); + filter.sendKeys('job_name'); + filterText.sendKeys('daisy-deploy-baremetal-daily-master') + buttonFilter.click(); + expect(cells.get(0).getText()).toContain("3c9f8d64"); + }); + it('Should not show the results in results page related to the filters for user ', function () { + browser.get(baseURL+"#/deployresults"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('installer'); + filterText.sendKeys('daisy1'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + expect(element(by.css('.alert.alert-danger.ng-binding.ng-scope')) + .isDisplayed()).toBe(true); + }); + + it('Clear the filter', function () { + browser.get(baseURL+"#/deployresults"); + var filter = element(by.model('ctrl.filter')); + var filterText = element(by.model('ctrl.filterText')); + filter.sendKeys('installer'); + filterText.sendKeys('daisy'); + var buttonFilter = element(by.buttonText('Filter')); + buttonFilter.click(); + var row = element.all(by.repeater('(index, result) in ctrl.data.deployresults')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("3c9f8d63"); + var buttonClear = element(by.buttonText('Clear')); + buttonClear.click(); + var row = element.all(by.repeater('(index, result) in ctrl.data.deployresults')).first(); + var cells = row.all(by.tagName('td')); + expect(cells.get(0).getText()).toContain("3c9f8d62"); + }); + + it('view the deploy results ', function () { + browser.get(baseURL+"#/deployresults"); + var viewOperation = element(by.linkText('3c9f8d62')) + viewOperation.click(); + var EC = browser.ExpectedConditions; + browser.wait(EC.urlContains('#/deployresults/5a6dc1089a07c80f3c9f8d62'), 10000); + }); + +}); \ No newline at end of file diff --git a/testapi/opnfv_testapi/ui/Gruntfile.js b/testapi/opnfv_testapi/ui/Gruntfile.js index 1be08b5..cfa8095 100644 --- a/testapi/opnfv_testapi/ui/Gruntfile.js +++ b/testapi/opnfv_testapi/ui/Gruntfile.js @@ -122,7 +122,8 @@ module.exports = function (grunt) { '../tests/UI/e2e/testCasesControllerSpec.js', '../tests/UI/e2e/resultsControllerSpec.js', '../tests/UI/e2e/scenariosControllerSpec.js', - '../tests/UI/e2e/scenarioControllerSpec.js' + '../tests/UI/e2e/scenarioControllerSpec.js', + '../tests/UI/e2e/deployResultsControllerSpec.js' ] } }, diff --git a/testapi/opnfv_testapi/ui/app.js b/testapi/opnfv_testapi/ui/app.js index c2fa774..ae50166 100644 --- a/testapi/opnfv_testapi/ui/app.js +++ b/testapi/opnfv_testapi/ui/app.js @@ -104,6 +104,16 @@ templateUrl: 'testapi-ui/components/results/result/result.html', controller: 'ResultController as ctrl' }). + state('deployresults', { + url: '/deployresults', + templateUrl: 'testapi-ui/components/deploy-results/deployResults.html', + controller: 'DeployResultsController as ctrl' + }). + state('deployresult', { + url: '/deployresults/:_id', + templateUrl: 'testapi-ui/components/deploy-results/deploy-result/deployResult.html', + controller: 'DeployResultController as ctrl' + }). state('profile', { url: '/profile', templateUrl: 'testapi-ui/components/profile/profile.html', diff --git a/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResult.html b/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResult.html new file mode 100644 index 0000000..ba9bee7 --- /dev/null +++ b/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResult.html @@ -0,0 +1,93 @@ +Result +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id :{{ctrl.data._id}}
Installer :{{ctrl.data.installer}}
Scenario :{{ctrl.data.scenario}}
Pod Name :{{ctrl.data.pod_name}}
Criteria :{{ctrl.data.criteria}}
Start Date :{{ctrl.data.start_date}}
Stop Date :{{ctrl.data.stop_date}}
Job Name :{{ctrl.data.job_name}}
Build ID :{{ctrl.data['build_id']}}
Upstream Job Name :{{ctrl.data.upstream_job_name}}
Upstream Build ID :{{ctrl.data.upstream_build_id}}
Details : + +

Hide

+

Show

+
+ + + + + + + + + + + + + + + + + + + + +
Failures :{{ctrl.data.details.failures}}
Details :{{ctrl.data.details.errors}}
Stream :

{{ctrl.data.details.stream}}

TestsRun :

{{ctrl.data.details.testsRun}}

+
+
+
+
+ + +
\ No newline at end of file diff --git a/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResultController.js b/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResultController.js new file mode 100644 index 0000000..40cf1cb --- /dev/null +++ b/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResultController.js @@ -0,0 +1,65 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function () { + 'use strict'; + + angular + .module('testapiApp') + .controller('DeployResultController', DeployResultController); + + DeployResultController.$inject = [ + '$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl','raiseAlert', + 'confirmModal' + ]; + + /** + * TestAPI DeployResultController + * This controller is for the '/result/:_id' page where a user can browse + * through result declared in TestAPI. + */ + function DeployResultController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl, + raiseAlert, confirmModal) { + var ctrl = this; + ctrl.url = testapiApiUrl + '/deployresults'; + ctrl._id = $state.params['_id']; + ctrl.loadDetails = loadDetails + ctrl.showDetails = showDetails + + /** + *Contact the testapi and retrevie the result details + */ + function loadDetails(){ + var resultUrl = ctrl.url + '/' + ctrl._id; + ctrl.showError = false; + ctrl.podsRequest = + $http.get(resultUrl).success(function (data) { + ctrl.data = data; + }).catch(function (error) { + ctrl.data = null; + ctrl.showError = true; + ctrl.error = error.statusText; + }); + } + + function showDetails(){ + if(ctrl.details){ + ctrl.details = false + }else{ + ctrl.details = true + } + } + ctrl.loadDetails(); + } +})(); \ No newline at end of file diff --git a/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html b/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html new file mode 100644 index 0000000..6fbaaea --- /dev/null +++ b/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html @@ -0,0 +1,126 @@ +

{{ctrl.pageHeader}}

+

{{ctrl.pageParagraph}}

+
+
+
+
+ +
+
+ +
+
+ Search:   + + + + +
+
+ Start Date:   +

+ + + + +

+
+
+ End Date:   +

+ + + + +

+
+
+ Filter:   + +
+
+
+ {{key}} : {{tag}} +
+ × +
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
IDInstallerScenarioPodCriteriaStart DateStop Date
{{ result._id.substr(-8) }}{{ result.installer }}{{ result.scenario }}{{ result.pod_name }}{{ result.criteria }}{{ result.start_date }}{{ result.stop_date }}
+ +
+ + +
+
+ + diff --git a/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js b/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js new file mode 100644 index 0000000..5230a75 --- /dev/null +++ b/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js @@ -0,0 +1,190 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +(function () { + 'use strict'; + + angular + .module('testapiApp') + .controller('DeployResultsController', DeployResultsController); + + DeployResultsController.$inject = [ + '$scope', '$http', '$filter', '$state', 'testapiApiUrl','raiseAlert' + ]; + + /** + * TestAPI Deploy Results Controller + * This controller is for the '/deployresults' page where a user can browse + * a listing of community uploaded results. + */ + function DeployResultsController($scope, $http, $filter, $state, testapiApiUrl, + raiseAlert) { + var ctrl = this; + + ctrl.open = open; + ctrl.clearFilters = clearFilters; + ctrl.deleteTag = deleteTag; + ctrl.filterList= filterList; + ctrl.testFilter = testFilter + ctrl.filter = "pod" + ctrl.filterValue = "pod_name" + ctrl.encodeFilter = encodeFilter + ctrl.viewDeployResult = viewDeployResult + ctrl.tagArray = {} + ctrl.filterOption=[] + + /** Initial page to be on. */ + ctrl.currentPage = 1; + + /** + * How many results should display on each page. Since pagination + * is server-side implemented, this value should match the + * 'results_per_page' configuration of the TestAPI server which + * defaults to 20. + */ + ctrl.itemsPerPage = 20; + + /** + * How many page buttons should be displayed at max before adding + * the '...' button. + */ + ctrl.maxSize = 5; + + /** The upload date lower limit to be used in filtering results. */ + ctrl.startDate = ''; + + /** The upload date upper limit to be used in filtering results. */ + ctrl.endDate = ''; + + /** The date format for the date picker. */ + ctrl.format = 'yyyy-MM-dd'; + + ctrl.pageHeader = "Deploy Results" + + ctrl.pageParagraph = 'Your most recently uploaded deploy results are listed here.' + ctrl.isPublic = false; + + function encodeFilter(){ + ctrl.filterText = '' + ctrl.filterOption=[] + if(ctrl.filter=="pod" || ctrl.filter=="scenario"){ + var reqURL = testapiApiUrl +"/" + ctrl.filter + "s" + ctrl.datasRequest = + $http.get(reqURL).success(function (data) { + ctrl.filterData = data; + for(var index in ctrl.filterData[ctrl.filter + "s"]){ + if( ctrl.filterOption.indexOf(ctrl.filterData[ctrl.filter + "s"][index]["name"]) < 0){ + ctrl.filterOption.push(ctrl.filterData[ctrl.filter + "s"][index]["name"]) + } + } + }).catch(function (data) { + ctrl.data = null; + ctrl.showError = true; + ctrl.error = data.statusText; + }); + + } + } + + function deleteTag(index){ + delete ctrl.tagArray[index]; + ctrl.filterList(); + } + + function testFilter(text){ + for (var filter in ctrl.tagArray){ + if(text==filter){ + return true; + } + } + return false; + } + + function viewDeployResult(_id){ + $state.go('deployresult', {'_id':_id}, {reload: true}); + } + + /** + * This will contact the TestAPI API to get a listing of deploy + * results. + */ + function filterList(){ + if(ctrl.filter && ctrl.filterText!="" && ctrl.filterText!=undefined){ + ctrl.tagArray[ctrl.filter] = ctrl.filterText; + } + ctrl.showError = false; + var content_url = testapiApiUrl + '/deployresults' + + '?page=' + ctrl.currentPage; + for(var key in ctrl.tagArray){ + if(key=="start_date"){ + var start = $filter('date')(ctrl.tagArray[key], 'yyyy-MM-dd'); + if (start) { + content_url = + content_url + '&from=' + start + ' 00:00:00'; + } + } + else if(key=="end_date"){ + var end = $filter('date')(ctrl.tagArray[key], 'yyyy-MM-dd'); + if (end) { + content_url = content_url + '&to=' + end + ' 23:59:59'; + } + } + else{ + content_url = content_url + "&" + key + "=" + ctrl.tagArray[key] + } + if (ctrl.isUserResults) { + content_url = content_url + '&signed'; + } + } + ctrl.resultsRequest = + $http.get(content_url).success(function (data) { + ctrl.data = data; + ctrl.totalItems = ctrl.data.pagination.total_pages * ctrl.itemsPerPage; + ctrl.currentPage = ctrl.data.pagination.current_page; + ctrl.encodeFilter(); + }).catch(function (error) { + ctrl.data = null; + ctrl.totalItems = 0; + ctrl.showError = true; + ctrl.error = error.statusText + }); + ctrl.filterText = '' + } + ctrl.filterList(); + + + /** + * This is called when the date filter calendar is opened. It + * does some event handling, and sets a scope variable so the UI + * knows which calendar was opened. + * @param {Object} $event - The Event object + * @param {String} openVar - Tells which calendar was opened + */ + function open($event, openVar) { + $event.preventDefault(); + $event.stopPropagation(); + ctrl[openVar] = true; + } + + /** + * This function will clear all filters and update the results + * listing. + */ + function clearFilters() { + ctrl.tagArray = {} + ctrl.filter = undefined + ctrl.filterList(); + } + } +})(); diff --git a/testapi/opnfv_testapi/ui/index.html b/testapi/opnfv_testapi/ui/index.html index beec61d..68c6cc5 100644 --- a/testapi/opnfv_testapi/ui/index.html +++ b/testapi/opnfv_testapi/ui/index.html @@ -51,6 +51,8 @@ + + diff --git a/testapi/opnfv_testapi/ui/shared/header/header.html b/testapi/opnfv_testapi/ui/shared/header/header.html index 3b2aba1..2b7be2f 100644 --- a/testapi/opnfv_testapi/ui/shared/header/header.html +++ b/testapi/opnfv_testapi/ui/shared/header/header.html @@ -20,6 +20,7 @@ TestAPI
  • Pods
  • Projects
  • Results
  • +
  • Deploy Results
  • Scenarios