Add JSDoc inline comments to JS files.
Change-Id: Iea6dd40a3c1c676d62bbf6a15eaa931c824856f3
This commit is contained in:
parent
6fffbca938
commit
960e7c3e65
|
@ -1,10 +1,10 @@
|
||||||
/* App Module */
|
/** Main app module where application dependencies are listed. */
|
||||||
|
|
||||||
var refstackApp = angular.module('refstackApp', [
|
var refstackApp = angular.module('refstackApp', [
|
||||||
'ui.router', 'ui.bootstrap', 'cgBusy']);
|
'ui.router', 'ui.bootstrap', 'cgBusy']);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Handle application routing.
|
* Handle application routing. Specific templates and controllers will be
|
||||||
|
* used based on the URL route.
|
||||||
*/
|
*/
|
||||||
refstackApp.config([
|
refstackApp.config([
|
||||||
'$stateProvider', '$urlRouterProvider',
|
'$stateProvider', '$urlRouterProvider',
|
||||||
|
@ -39,8 +39,8 @@ refstackApp.config([
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Load Config and start up the angular application.
|
* Load config and start up the angular application.
|
||||||
*/
|
*/
|
||||||
angular.element(document).ready(function () {
|
angular.element(document).ready(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
|
@ -1,15 +1,29 @@
|
||||||
/* Refstack Capabilities Controller */
|
|
||||||
|
|
||||||
var refstackApp = angular.module('refstackApp');
|
var refstackApp = angular.module('refstackApp');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refstack Capabilities Controller
|
||||||
|
* This controller is for the '/capabilities' page where a user can browse
|
||||||
|
* through tests belonging to DefCore-defined capabilities.
|
||||||
|
*/
|
||||||
refstackApp.controller('capabilitiesController',
|
refstackApp.controller('capabilitiesController',
|
||||||
['$scope', '$http', 'refstackApiUrl',
|
['$scope', '$http', 'refstackApiUrl',
|
||||||
function ($scope, $http, refstackApiUrl) {
|
function ($scope, $http, refstackApiUrl) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/** Whether to hide/collapse the achievements for each capability. */
|
||||||
$scope.hideAchievements = true;
|
$scope.hideAchievements = true;
|
||||||
|
|
||||||
|
/** Whether to hide/collapse the tests for each capability. */
|
||||||
$scope.hideTests = true;
|
$scope.hideTests = true;
|
||||||
|
|
||||||
|
/** The target OpenStack marketing program to show capabilities for. */
|
||||||
$scope.target = 'platform';
|
$scope.target = 'platform';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The various possible capability statuses. The true value for each
|
||||||
|
* status is the name of the key, so by default only required
|
||||||
|
* capabilities will be shown.
|
||||||
|
*/
|
||||||
$scope.status = {
|
$scope.status = {
|
||||||
required: 'required',
|
required: 'required',
|
||||||
advisory: '',
|
advisory: '',
|
||||||
|
@ -17,6 +31,14 @@ refstackApp.controller('capabilitiesController',
|
||||||
removed: ''
|
removed: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an array of available capability files from the Refstack
|
||||||
|
* API server, sort this array reverse-alphabetically, and store it in
|
||||||
|
* a scoped variable. The scope's selected version is initialized to
|
||||||
|
* the latest (i.e. first) version here as well. After a successful API
|
||||||
|
* call, the function to update the capabilities is called.
|
||||||
|
* Sample API return array: ["2015.03.json", "2015.04.json"]
|
||||||
|
*/
|
||||||
$scope.getVersionList = function () {
|
$scope.getVersionList = function () {
|
||||||
var content_url = refstackApiUrl + '/capabilities';
|
var content_url = refstackApiUrl + '/capabilities';
|
||||||
$scope.versionsRequest =
|
$scope.versionsRequest =
|
||||||
|
@ -31,6 +53,11 @@ refstackApp.controller('capabilitiesController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will contact the Refstack API server to retrieve the JSON
|
||||||
|
* content of the capability file corresponding to the selected
|
||||||
|
* version.
|
||||||
|
*/
|
||||||
$scope.update = function () {
|
$scope.update = function () {
|
||||||
var content_url = refstackApiUrl + '/capabilities/' +
|
var content_url = refstackApiUrl + '/capabilities/' +
|
||||||
$scope.version;
|
$scope.version;
|
||||||
|
@ -47,10 +74,21 @@ refstackApp.controller('capabilitiesController',
|
||||||
|
|
||||||
$scope.getVersionList();
|
$scope.getVersionList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a filter that will check if a specific capability belongs
|
||||||
|
* to the selected OpenStack marketing program (programs typically
|
||||||
|
* correspond to 'components' in the DefCore schema). This filter
|
||||||
|
* is meant to be used with the ng-repeat directive.
|
||||||
|
* @param {Object} A capability object from the capabilities JSON
|
||||||
|
* @returns {Boolean} True if capability belongs to program
|
||||||
|
*/
|
||||||
$scope.filterProgram = function (capability) {
|
$scope.filterProgram = function (capability) {
|
||||||
var components = $scope.capabilities.components;
|
var components = $scope.capabilities.components;
|
||||||
var cap_array = [];
|
var cap_array = [];
|
||||||
|
|
||||||
|
// The 'platform' target is comprised of multiple components, so
|
||||||
|
// we need to get the capabilities belonging to each of its
|
||||||
|
// components.
|
||||||
if ($scope.target === 'platform') {
|
if ($scope.target === 'platform') {
|
||||||
var platform_components =
|
var platform_components =
|
||||||
$scope.capabilities.platform.required;
|
$scope.capabilities.platform.required;
|
||||||
|
@ -72,6 +110,13 @@ refstackApp.controller('capabilitiesController',
|
||||||
return (cap_array.indexOf(capability.id) > -1);
|
return (cap_array.indexOf(capability.id) > -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This filter will check if a capability's status corresponds
|
||||||
|
* to a status that is checked/selected in the UI. This filter
|
||||||
|
* is meant to be used with the ng-repeat directive.
|
||||||
|
* @param {Object} capability
|
||||||
|
* @returns {Boolean} True if capability's status is selected
|
||||||
|
*/
|
||||||
$scope.filterStatus = function (capability) {
|
$scope.filterStatus = function (capability) {
|
||||||
return capability.status === $scope.status.required ||
|
return capability.status === $scope.status.required ||
|
||||||
capability.status === $scope.status.advisory ||
|
capability.status === $scope.status.advisory ||
|
||||||
|
|
|
@ -1,23 +1,42 @@
|
||||||
/* Refstack Results Report Controller */
|
|
||||||
|
|
||||||
var refstackApp = angular.module('refstackApp');
|
var refstackApp = angular.module('refstackApp');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refstack Results Report Controller
|
||||||
|
* This controller is for the '/results/<test run ID>' page where a user can
|
||||||
|
* view details for a specific test run.
|
||||||
|
*/
|
||||||
refstackApp.controller('resultsReportController',
|
refstackApp.controller('resultsReportController',
|
||||||
['$scope', '$http', '$stateParams', 'refstackApiUrl',
|
['$scope', '$http', '$stateParams', 'refstackApiUrl',
|
||||||
function ($scope, $http, $stateParams, refstackApiUrl) {
|
function ($scope, $http, $stateParams, refstackApiUrl) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/** The testID extracted from the URL route. */
|
||||||
$scope.testId = $stateParams.testID;
|
$scope.testId = $stateParams.testID;
|
||||||
|
|
||||||
|
/** Whether to hide tests on start.*/
|
||||||
$scope.hideTests = true;
|
$scope.hideTests = true;
|
||||||
|
|
||||||
|
/** The target OpenStack marketing program to compare against. */
|
||||||
$scope.target = 'platform';
|
$scope.target = 'platform';
|
||||||
|
|
||||||
|
/** Whether the required capabilities accordian should be open. */
|
||||||
$scope.requiredOpen = true;
|
$scope.requiredOpen = true;
|
||||||
|
|
||||||
|
/** Mappings of DefCore components to marketing program names. */
|
||||||
$scope.targetMappings = {
|
$scope.targetMappings = {
|
||||||
'platform': 'Openstack Powered Platform',
|
'platform': 'Openstack Powered Platform',
|
||||||
'compute': 'OpenStack Powered Compute',
|
'compute': 'OpenStack Powered Compute',
|
||||||
'object': 'OpenStack Powered Object Storage'
|
'object': 'OpenStack Powered Object Storage'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an array of available capability files from the Refstack
|
||||||
|
* API server, sort this array reverse-alphabetically, and store it in
|
||||||
|
* a scoped variable. The scope's selected version is initialized to
|
||||||
|
* the latest (i.e. first) version here as well. After a successful API
|
||||||
|
* call, the function to update the capabilities is called.
|
||||||
|
* Sample API return array: ["2015.03.json", "2015.04.json"]
|
||||||
|
*/
|
||||||
var getVersionList = function () {
|
var getVersionList = function () {
|
||||||
var content_url = refstackApiUrl + '/capabilities';
|
var content_url = refstackApiUrl + '/capabilities';
|
||||||
$scope.versionsRequest =
|
$scope.versionsRequest =
|
||||||
|
@ -33,6 +52,12 @@ refstackApp.controller('resultsReportController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve results from the Refstack API server based on the test
|
||||||
|
* run id in the URL. This function is the first function that will
|
||||||
|
* be called from the controller. Upon successful retrieval of results,
|
||||||
|
* the function that gets the version list will be called.
|
||||||
|
*/
|
||||||
var getResults = function () {
|
var getResults = function () {
|
||||||
var content_url = refstackApiUrl + '/results/' + $scope.testId;
|
var content_url = refstackApiUrl + '/results/' + $scope.testId;
|
||||||
$scope.resultsRequest =
|
$scope.resultsRequest =
|
||||||
|
@ -48,6 +73,12 @@ refstackApp.controller('resultsReportController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will contact the Refstack API server to retrieve the JSON
|
||||||
|
* content of the capability file corresponding to the selected
|
||||||
|
* version. A function to construct an object from the capability
|
||||||
|
* date will be called upon successful retrieval.
|
||||||
|
*/
|
||||||
$scope.updateCapabilities = function () {
|
$scope.updateCapabilities = function () {
|
||||||
$scope.showError = false;
|
$scope.showError = false;
|
||||||
var content_url = refstackApiUrl + '/capabilities/' +
|
var content_url = refstackApiUrl + '/capabilities/' +
|
||||||
|
@ -64,8 +95,17 @@ refstackApp.controller('resultsReportController',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will build an object based on the capability data retrieved
|
||||||
|
* from the Refstack API server. This object will contain the
|
||||||
|
* information needed to form a report in the HTML template.
|
||||||
|
*/
|
||||||
$scope.buildCapabilityObject = function () {
|
$scope.buildCapabilityObject = function () {
|
||||||
var capabilities = $scope.capabilityData.capabilities;
|
var capabilities = $scope.capabilityData.capabilities;
|
||||||
|
// This is the object template where 'count' is the number of
|
||||||
|
// total tests that fall under the given status, and 'passedCount'
|
||||||
|
// is the number of tests passed. The 'caps' array will contain
|
||||||
|
// objects with details regarding each capability.
|
||||||
var caps = {
|
var caps = {
|
||||||
'required': {'caps': [], 'count': 0, 'passedCount': 0},
|
'required': {'caps': [], 'count': 0, 'passedCount': 0},
|
||||||
'advisory': {'caps': [], 'count': 0, 'passedCount': 0},
|
'advisory': {'caps': [], 'count': 0, 'passedCount': 0},
|
||||||
|
@ -94,7 +134,9 @@ refstackApp.controller('resultsReportController',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Loop through each capability.
|
||||||
angular.forEach(capabilities, function (value, key) {
|
angular.forEach(capabilities, function (value, key) {
|
||||||
|
// If the capability is target-relevant.
|
||||||
if (cap_array.indexOf(key) > -1) {
|
if (cap_array.indexOf(key) > -1) {
|
||||||
var cap = {
|
var cap = {
|
||||||
'id': key,
|
'id': key,
|
||||||
|
@ -102,7 +144,10 @@ refstackApp.controller('resultsReportController',
|
||||||
'notPassedTests': []
|
'notPassedTests': []
|
||||||
};
|
};
|
||||||
caps[value.status].count += value.tests.length;
|
caps[value.status].count += value.tests.length;
|
||||||
|
// Loop through each test belonging to the capability.
|
||||||
angular.forEach(value.tests, function (test_id) {
|
angular.forEach(value.tests, function (test_id) {
|
||||||
|
// If the test ID is in the results' test list, add
|
||||||
|
// it to the passedTests array.
|
||||||
if ($scope.resultsData.results.indexOf(test_id) > -1) {
|
if ($scope.resultsData.results.indexOf(test_id) > -1) {
|
||||||
cap.passedTests.push(test_id);
|
cap.passedTests.push(test_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,45 @@
|
||||||
/* Refstack Results Controller */
|
|
||||||
|
|
||||||
var refstackApp = angular.module('refstackApp');
|
var refstackApp = angular.module('refstackApp');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refstack Results Controller
|
||||||
|
* This controller is for the '/results' page where a user can browse
|
||||||
|
* a listing of community uploaded results.
|
||||||
|
*/
|
||||||
refstackApp.controller('resultsController',
|
refstackApp.controller('resultsController',
|
||||||
['$scope', '$http', '$filter', 'refstackApiUrl',
|
['$scope', '$http', '$filter', 'refstackApiUrl',
|
||||||
function ($scope, $http, $filter, refstackApiUrl) {
|
function ($scope, $http, $filter, refstackApiUrl) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/** Initial page to be on. */
|
||||||
$scope.currentPage = 1;
|
$scope.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 Refstack server which
|
||||||
|
* defaults to 20.
|
||||||
|
*/
|
||||||
$scope.itemsPerPage = 20;
|
$scope.itemsPerPage = 20;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many page buttons should be displayed at max before adding
|
||||||
|
* the '...' button.
|
||||||
|
*/
|
||||||
$scope.maxSize = 5;
|
$scope.maxSize = 5;
|
||||||
|
|
||||||
|
/** The upload date lower limit to be used in filtering results. */
|
||||||
$scope.startDate = '';
|
$scope.startDate = '';
|
||||||
|
|
||||||
|
/** The upload date upper limit to be used in filtering results. */
|
||||||
$scope.endDate = '';
|
$scope.endDate = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will contact the Refstack API to get a listing of test run
|
||||||
|
* results.
|
||||||
|
*/
|
||||||
$scope.update = function () {
|
$scope.update = function () {
|
||||||
$scope.showError = false;
|
$scope.showError = false;
|
||||||
|
// Construct the API URL based on user-specified filters.
|
||||||
var content_url = refstackApiUrl + '/results?page=' +
|
var content_url = refstackApiUrl + '/results?page=' +
|
||||||
$scope.currentPage;
|
$scope.currentPage;
|
||||||
var start = $filter('date')($scope.startDate, 'yyyy-MM-dd');
|
var start = $filter('date')($scope.startDate, 'yyyy-MM-dd');
|
||||||
|
@ -44,13 +70,23 @@ refstackApp.controller('resultsController',
|
||||||
|
|
||||||
$scope.update();
|
$scope.update();
|
||||||
|
|
||||||
// This is called when a date filter calendar is opened.
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
$scope.open = function ($event, openVar) {
|
$scope.open = function ($event, openVar) {
|
||||||
$event.preventDefault();
|
$event.preventDefault();
|
||||||
$event.stopPropagation();
|
$event.stopPropagation();
|
||||||
$scope[openVar] = true;
|
$scope[openVar] = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will clear all filters and update the results
|
||||||
|
* listing.
|
||||||
|
*/
|
||||||
$scope.clearFilters = function () {
|
$scope.clearFilters = function () {
|
||||||
$scope.startDate = null;
|
$scope.startDate = null;
|
||||||
$scope.endDate = null;
|
$scope.endDate = null;
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
/* Refstack Filters */
|
|
||||||
|
|
||||||
var refstackApp = angular.module('refstackApp');
|
var refstackApp = angular.module('refstackApp');
|
||||||
|
|
||||||
// Convert an object of objects to an array of objects to use with ng-repeat
|
/** Refstack AngularJS Filters */
|
||||||
// filters.
|
|
||||||
|
/**
|
||||||
|
* Convert an object of objects to an array of objects to use with ng-repeat
|
||||||
|
* filters.
|
||||||
|
*/
|
||||||
refstackApp.filter('arrayConverter', function () {
|
refstackApp.filter('arrayConverter', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
/* Refstack Header Controller */
|
|
||||||
|
|
||||||
var refstackApp = angular.module('refstackApp');
|
var refstackApp = angular.module('refstackApp');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refstack Header Controller
|
||||||
|
* This controller is for the header template which contains the site
|
||||||
|
* navigation.
|
||||||
|
*/
|
||||||
refstackApp.controller('headerController',
|
refstackApp.controller('headerController',
|
||||||
['$scope', '$location', function ($scope, $location) {
|
['$scope', '$location', function ($scope, $location) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/** Whether the Navbar is collapsed for small displays. */
|
||||||
$scope.navbarCollapsed = true;
|
$scope.navbarCollapsed = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This determines whether a button should be in the active state based
|
||||||
|
* on the URL.
|
||||||
|
*/
|
||||||
$scope.isActive = function (viewLocation) {
|
$scope.isActive = function (viewLocation) {
|
||||||
var path = $location.path().substr(0, viewLocation.length);
|
var path = $location.path().substr(0, viewLocation.length);
|
||||||
if (path === viewLocation) {
|
if (path === viewLocation) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Jasmine specs for Refstack controllers */
|
/** Jasmine specs for Refstack controllers */
|
||||||
describe('Refstack controllers', function () {
|
describe('Refstack controllers', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
|
/** Jasmine specs for Refstack filters */
|
||||||
/* Jasmine specs for Refstack filters */
|
|
||||||
describe('Refstack filters', function () {
|
describe('Refstack filters', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue