summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/components/deploy-results
diff options
context:
space:
mode:
Diffstat (limited to 'testapi/opnfv_testapi/ui/components/deploy-results')
-rw-r--r--testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResult.html31
-rw-r--r--testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResultController.js66
-rw-r--r--testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html130
-rw-r--r--testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js200
4 files changed, 427 insertions, 0 deletions
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..c0803ff
--- /dev/null
+++ b/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResult.html
@@ -0,0 +1,31 @@
+<legend>Result</legend>
+<div style="padding-right:0px">
+ <div class="table-responsive">
+ <table class="table" ng-data="ctrl.data.pods">
+ <tbody>
+ <tr ng-repeat-start="(index, detail) in ctrl.data_field" style="padding:9px">
+ <td class="podsTableTd">{{detail | capitalize}}&nbsp;:</td>
+ <td width="86%" class="podsTableLeftTd">{{ctrl.data[index]}}</td>
+ </tr>
+ <tr ng-repeat-end=>
+ </tr>
+ <tr style="padding:9px">
+ <td class="podsTableTd">Details&nbsp;:</td>
+ <td width="86%" class="podsTableLeftTd">
+ <json-tree object="ctrl.json.object" root-name="object" start-expanded="true"></json-tree>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+</div>
+<div class="col-md-12">
+ <div ng-show="ctrl.showError" class="col-md-12 alert alert-danger" role="alert">
+ <span class="pull-right">&nbsp;{{ctrl.error}}</span>
+ <span class="glyphicon glyphicon-exclamation-sign pull-right" aria-hidden="true" >Error:</span>
+ </div>
+ <div ng-show="ctrl.showSuccess" class="col-md-12 alert alert-success" role="alert">
+ <span class="pull-right">&nbsp;{{ctrl.success}}</span>
+ <span class="glyphicon glyphicon-ok pull-right" aria-hidden="true"></span>
+ </div>
+ </div> \ 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..6f9b84c
--- /dev/null
+++ b/testapi/opnfv_testapi/ui/components/deploy-results/deploy-result/deployResultController.js
@@ -0,0 +1,66 @@
+/*
+ * 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', 'dataFieldService'
+ ];
+
+ /**
+ * 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, dataFieldService) {
+ var ctrl = this;
+ ctrl.url = testapiApiUrl + '/deployresults';
+ ctrl._id = $state.params['_id'];
+ ctrl.loadDetails = loadDetails
+ ctrl.data_field = {}
+
+ ctrl.json = {};
+ ctrl.json.string = '{"id": ""}';
+ ctrl.json.object = JSON.parse(ctrl.json.string);
+
+ /**
+ *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;
+ ctrl.object=JSON.stringify(ctrl.data.details)
+ ctrl.json.object = JSON.parse(ctrl.object)
+ delete ctrl.data.details;
+ ctrl.data_field = dataFieldService.dataFunction(ctrl.data, ctrl.data_field)
+ }).catch(function (error) {
+ ctrl.data = null;
+ ctrl.showError = true;
+ ctrl.error = error.statusText;
+ });
+ }
+
+ 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..7998f3c
--- /dev/null
+++ b/testapi/opnfv_testapi/ui/components/deploy-results/deployResults.html
@@ -0,0 +1,130 @@
+<h3>{{ctrl.pageHeader}}</h3>
+<p>{{ctrl.pageParagraph}}</p>
+<div class="row" style="margin-bottom:24px;"></div>
+<div class="result-filters" style="border-top: none;">
+ <div class="row podTable" style="vertical-align:middle">
+ <div class="col-sm-1 pull-right">
+ <button type="button" class="btn btn-danger" ng-click="ctrl.clearFilters()">
+ <i class="fa fa-search"></i> Clear
+ </button>
+ </div>
+ <div class="col-sm-1 pull-right">
+ <button type="button" class="btn btn-success" ng-click="ctrl.filterList()">
+ <i class="fa fa-search"></i> Filter</button>
+ </div>
+ <div class="col-sm-2 pull-right" ng-class="{'hidden': ctrl.filter=='start_date' || ctrl.filter=='end_date'}">
+ <span style="margin-top:6px">Search:&nbsp;&nbsp;</span>
+ <input list="filter" name="filter" class="form-control search" style="display:inline;width:105px;padding-left:6px;"
+ ng-enter="ctrl.filterList()" ng-Model="ctrl.filterText" placeholder="Search String">
+ <datalist id="filter" ng-class="{ 'hidden' : ctrl.filterOption.length<0}">
+ <option ng-repeat="(index, filterValue) in ctrl.filterOption " value="{{filterValue}}">{{filterValue}}</option>
+ </datalist>
+ </div>
+ <div class="col-sm-3 pull-right" style="width:20%" ng-class="{'hidden': ctrl.filter!='start_date'}">
+ <span style="margin-top:6px">Start&nbsp;Date:&nbsp;&nbsp;</span>
+ <p class="input-group" style="width:48%;display:inline-flex;">
+ <input type="text" class="form-control"
+ ng-enter="ctrl.filterList()"
+ uib-datepicker-popup="{{ctrl.format}}"
+ ng-model="ctrl.filterText" is-open="ctrl.startOpen"
+ close-text="Close" />
+ <span class="input-group-btn">
+ <button type="button" class="btn btn-default" ng-click="ctrl.open($event, 'startOpen')">
+ <i class="glyphicon glyphicon-calendar"></i>
+ </button>
+ </span>
+ </p>
+ </div>
+ <div class="col-sm-3 pull-right" style="width:20%" ng-class="{'hidden': ctrl.filter!='end_date'}">
+ <span style="margin-top:6px">End&nbsp;Date:&nbsp;&nbsp;</span>
+ <p class="input-group" style="width:48%;display:inline-flex;">
+ <input type="text" class="form-control"
+ ng-enter="ctrl.filterList()"
+ uib-datepicker-popup="{{ctrl.format}}"
+ ng-model="ctrl.filterText" is-open="ctrl.endOpen"
+ close-text="Close" />
+ <span class="input-group-btn">
+ <button type="button" class="btn btn-default" ng-click="ctrl.open($event, 'endOpen')">
+ <i class="glyphicon glyphicon-calendar"></i>
+ </button>
+ </span>
+ </p>
+ </div>
+ <div class="col-md-2 row pull-right" style="width: 20%;">
+ <span style="margin-top:6px">Filter:&nbsp;&nbsp;</span>
+ <select ng-model="ctrl.filter" ng-change="ctrl.encodeFilter()" class="form-control" style="display:inline; width:150px;">
+ <option value="pod" ng-disabled="ctrl.testFilter('pod')" >Pod Name</option>
+ <option value="job_name" ng-disabled="ctrl.testFilter('job_name')" >Job Name</option>
+ <option value="installer" ng-disabled="ctrl.testFilter('installer')">Installer</option>
+ <option value="version" ng-disabled="ctrl.testFilter('version')">Version</option>
+ <option value="scenario" ng-disabled="ctrl.testFilter('scenario')">Scenario</option>
+ <option value="build_id" ng-disabled="ctrl.testFilter('build_id')">Build ID</option>
+ <option value="criteria" ng-disabled="ctrl.testFilter('criteria')">Criteria</option>
+ <option value="start_date" ng-disabled="ctrl.testFilter('start_date')">Start Date</option>
+ <option value="end_date" ng-disabled="ctrl.testFilter('end_date')">End Date</option>
+ </select>
+ </div>
+ <div class='filter-box'>
+ <div class='filter-tag col-md-1' ng-repeat="(key, tag) in ctrl.tagArray" style="background-color: #f5f5f5;border: 1px solid #e3e3e3;/* border: 1px; */margin-top: 3px;padding: 4px;margin-left: 15px;width: 13%;">
+ {{key}}&nbsp:&nbsp{{tag}}
+ <div class='delete-tag btn btn-danger btn-xs' ng-click='ctrl.deleteTag(key)'>
+ &times;
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+
+<div cg-busy="{promise:ctrl.authRequest,message:'Loading'}"></div>
+<div cg-busy="{promise:ctrl.resultsRequest,message:'Loading'}"></div>
+<div ng-show="ctrl.data" class="results-table">
+ <table ng-data="ctrl.data.deployresults" ng-show="ctrl.data" class="table table-striped table-hover">
+ <thead>
+ <tr>
+ <th>ID</th>
+ <th>Installer</th>
+ <th>Version</th>
+ <th>Scenario</th>
+ <th>Pod</th>
+ <th>Criteria</th>
+ <th>Start&nbsp;Date</th>
+ <th>Stop&nbsp;Date</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ <tr ng-repeat-start="(index, result) in ctrl.data.deployresults">
+ <td><a ng-click="ctrl.viewDeployResult(result._id)">{{ result._id.substr(-8) }}</a></td>
+ <td>{{ result.installer }}</td>
+ <td>{{ result.version }}</td>
+ <td>{{ result.scenario }}</td>
+ <td>{{ result.pod_name }}</td>
+ <td>{{ result.criteria }}</td>
+ <td>{{ result.start_date }}</td>
+ <td>{{ result.stop_date }}</td>
+ </tr>
+ <tr ng-repeat-end=>
+ </tr>
+ </tbody>
+ </table>
+
+ <div class="pages">
+ <uib-pagination
+ total-items="ctrl.totalItems"
+ ng-model="ctrl.currentPage"
+ items-per-page="ctrl.itemsPerPage"
+ max-size="ctrl.maxSize"
+ class="pagination-sm"
+ boundary-links="true"
+ rotate="false"
+ num-pages="ctrl.numPages"
+ ng-change="ctrl.filterList()">
+ </uib-pagination>
+ </div>
+</div>
+
+<div ng-show="ctrl.showError" class="alert alert-danger" role="alert">
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
+ <span class="sr-only">Error:</span>
+ {{ctrl.error}}
+</div>
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..1128825
--- /dev/null
+++ b/testapi/opnfv_testapi/ui/components/deploy-results/deployResultsController.js
@@ -0,0 +1,200 @@
+/*
+ * 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',
+ 'keepState'
+ ];
+
+ /**
+ * 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, keepState) {
+ 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;
+ if(!keepState.filter.deployResultFilter){
+ keepState.filter.deployResultFilter = {}
+ }
+ keepState.filter.deployResultFilter[ctrl.filter] = ctrl.filterText
+ }
+ else if(Object.keys(ctrl.tagArray).length==0){
+ if(keepState.filter.deployResultFilter){
+ ctrl.tagArray = keepState.filter.deployResultFilter
+ }
+ }
+ 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();
+ }
+ }
+})();