Allow users to select information grouping
This commit allows users to select how they want to group information on the dashboard page. It basically enumerates the existing run metadata keys and let the user choose any of them. As up to today, we were only grouping information by project. Change-Id: I31514e75629483f91a35c8e7b622bc298db6a41f Depends-On: Ibe591d9af94c1cd8d5c1d4956c1c82b4a764b5b7 Co-Authored-By: Tim Buckley <timothy.jas.buckley@hpe.com>
This commit is contained in:
parent
821601b16d
commit
8ea97d4e57
@ -53,11 +53,20 @@ function HomeController(healthService, startDate, projectService) {
|
||||
};
|
||||
};
|
||||
|
||||
var loadData = function() {
|
||||
function loadRunMetadataKeys() {
|
||||
healthService.getRunMetadataKeys().then(function(response) {
|
||||
vm.runMetadataKeys = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
var loadData = function(runMetadataKey) {
|
||||
var groupBy = runMetadataKey || vm.selectedRunMetadataKey;
|
||||
vm.selectedRunMetadataKey = groupBy;
|
||||
|
||||
var start = new Date(startDate);
|
||||
start.setDate(start.getDate() - 20);
|
||||
|
||||
healthService.getRunsGroupedByMetadataPerDatetime('project', {
|
||||
healthService.getRunsGroupedByMetadataPerDatetime(groupBy, {
|
||||
start_date: start,
|
||||
datetime_resolution: 'hour'
|
||||
}).then(function(response) {
|
||||
@ -68,9 +77,12 @@ function HomeController(healthService, startDate, projectService) {
|
||||
// ViewModel
|
||||
var vm = this;
|
||||
vm.searchProject = '';
|
||||
vm.selectedRunMetadataKey = 'project';
|
||||
vm.loadRunMetadataKeys = loadRunMetadataKeys;
|
||||
vm.processData = processData;
|
||||
vm.loadData = loadData;
|
||||
|
||||
vm.loadData();
|
||||
vm.loadRunMetadataKeys();
|
||||
}
|
||||
controllersModule.controller('HomeController', HomeController);
|
||||
|
@ -1,16 +1,16 @@
|
||||
<header class="bs-header">
|
||||
<div class="container">
|
||||
<h1 class="page-header">OpenStack Health</h1>
|
||||
<crumb-menu></crumb-menu>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h1 class="page-header">OpenStack Health</h1>
|
||||
<crumb-menu></crumb-menu>
|
||||
<loading-indicator></loading-indicator>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<loading-indicator></loading-indicator>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="panel panel-default">
|
||||
@ -36,10 +36,19 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="sel1">Group information by:</label>
|
||||
<select ng-init="selectedRunMetadataKey = 'project'"
|
||||
ng-model="selectedRunMetadataKey"
|
||||
ng-options="runMetadataKey for runMetadataKey in home.runMetadataKeys"
|
||||
ng-change="home.loadData(selectedRunMetadataKey)"
|
||||
class="form-control">
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon"><i class="fa fa-search"></i></div>
|
||||
<input type="text" class="form-control" placeholder="Search for project" ng-model="home.searchProject">
|
||||
<input type="text" class="form-control" placeholder="Search for {{ home.selectedRunMetadataKey }}" ng-model="home.searchProject">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -47,7 +56,7 @@
|
||||
<div class="col-lg-4" ng-repeat="project in home.projects | filter:home.searchProject">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<a ui-sref="groupedRuns({ runMetadataKey: 'project', name: project.name })">
|
||||
<a ui-sref="groupedRuns({ runMetadataKey: home.selectedRunMetadataKey, name: project.name })">
|
||||
<h3 class="panel-title">{{project.name}}</h3>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -1,2 +1,11 @@
|
||||
[default]
|
||||
db_uri = mysql+pymysql://query:query@logstash.openstack.org/subunit2sql
|
||||
ignored_run_metadata_keys =
|
||||
build_change
|
||||
build_master
|
||||
build_node
|
||||
build_patchset
|
||||
build_ref
|
||||
build_short_uuid
|
||||
build_uuid
|
||||
build_zuul_url
|
||||
|
@ -93,9 +93,22 @@ def get_runs_from_build_name(build_name):
|
||||
|
||||
@app.route('/runs/metadata/keys', methods=['GET'])
|
||||
def get_run_metadata_keys():
|
||||
global Session
|
||||
global config
|
||||
try:
|
||||
if config:
|
||||
ignored_keys = (config
|
||||
.get('default', 'ignored_run_metadata_keys')
|
||||
.splitlines())
|
||||
else:
|
||||
ignored_keys = []
|
||||
except ConfigParser.NoOptionError:
|
||||
ignored_keys = []
|
||||
|
||||
session = Session()
|
||||
return jsonify(api.get_all_run_metadata_keys(session))
|
||||
existing_keys = set(api.get_all_run_metadata_keys(session))
|
||||
allowed_keys = existing_keys.difference(ignored_keys)
|
||||
|
||||
return jsonify(list(allowed_keys))
|
||||
|
||||
|
||||
def _parse_datetimes(datetime_str):
|
||||
|
@ -62,8 +62,12 @@ class TestRestAPI(base.TestCase):
|
||||
res = self.app.get('/runs/metadata/keys')
|
||||
self.assertEqual(200, res.status_code)
|
||||
api_mock.assert_called_once_with(api.Session())
|
||||
expected_response = [u'build_name', u'project', u'build_uuid']
|
||||
self.assertEqual(expected_response, json.loads(res.data))
|
||||
expected_response = [
|
||||
u'build_name',
|
||||
u'project',
|
||||
u'build_uuid'
|
||||
]
|
||||
self.assertItemsEqual(expected_response, json.loads(res.data))
|
||||
|
||||
@mock.patch('subunit2sql.db.api.get_test_run_dict_by_run_meta_key_value',
|
||||
return_value=[
|
||||
|
11
test/e2e/mocks/run_metadata_keys.js
Normal file
11
test/e2e/mocks/run_metadata_keys.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
request: {
|
||||
method: 'JSONP',
|
||||
path: '/runs/metadata/keys'
|
||||
},
|
||||
response: {
|
||||
data: ['build_branch', 'build_change', 'build_master', 'build_name',
|
||||
'build_node', 'build_patchset', 'build_queue', 'build_ref', 'build_short_uuid',
|
||||
'build_uuid', 'build_zuul_url', 'filename', 'project', 'voting']
|
||||
}
|
||||
};
|
@ -7,7 +7,7 @@ var mock = require('protractor-http-mock');
|
||||
describe('E2E: Routes', function() {
|
||||
|
||||
it('should have a working home route', function() {
|
||||
mock(['config', 'home_project']);
|
||||
mock(['config', 'run_metadata_keys', 'home_project']);
|
||||
|
||||
browser.get('#/');
|
||||
|
||||
|
@ -5,6 +5,15 @@ describe('HomeController', function() {
|
||||
|
||||
var $controller, homeController, projectService;
|
||||
var mockResponse = { data: {} };
|
||||
var mockMetadataKeysResponse = {
|
||||
data: {
|
||||
runs: {
|
||||
metadata: {
|
||||
keys: ['filename', 'project', 'voting']
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(inject(function(_$controller_) {
|
||||
$controller = _$controller_;
|
||||
@ -13,6 +22,11 @@ describe('HomeController', function() {
|
||||
var healthService = {
|
||||
getRunsGroupedByMetadataPerDatetime: function(key, options) {
|
||||
return { then: function(callback) { callback(mockResponse); } };
|
||||
},
|
||||
getRunMetadataKeys: function() {
|
||||
return {
|
||||
then: function(callback) { callback(mockMetadataKeysResponse); }
|
||||
};
|
||||
}
|
||||
};
|
||||
projectService = {
|
||||
|
Loading…
Reference in New Issue
Block a user