Skip to content

Commit

Permalink
Tenant options instead of free text
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacov committed Mar 15, 2017
1 parent 4390b5d commit 78ba391
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

dash.url = '/container_dashboard/data' + dash.providerId + '/?live=true&tenant=' + dash.tenant;

httpUtils.updateTenantList();
httpUtils.getMetricTags();
}

Expand Down Expand Up @@ -108,7 +109,6 @@
initialization();
};

dash.getTenants = httpUtils.getTenants;
dash.refreshList = httpUtils.refreshList;
dash.refreshGraph = httpUtils.refreshGraph;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ angular.module('miq.util').factory('metricsHttpFactory', function() {
miqService.handleFailure(error); });
};

var getTenants = function(include) {
return $http.get(dash.url + "&query=get_tenants&limit=7&include=" + include).then(function(response) {
var updateTenantList = function() {
var url = '/container_dashboard/data' + dash.providerId + '/?live=true&query=get_tenants';

return $http.get(url).then(function(response) {
if (utils.checkResponse(response) === false) {
return [];
dash.tenantList = [dash.tenant];
}

return response.data.tenants;
dash.tenantList = response.data.tenants;
});
}

Expand Down Expand Up @@ -113,7 +115,7 @@ angular.module('miq.util').factory('metricsHttpFactory', function() {

return {
getMetricTags: getMetricTags,
getTenants: getTenants,
updateTenantList: updateTenantList,
refreshList: refreshList,
refreshGraph: refreshGraph
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ angular.module('miq.util').factory('metricsParseUrlFactory', function() {

// TODO: get this values from GET/POST values ?
dash.tenant = '_system';
dash.tenantList = [dash.tenant];
dash.minBucketDurationInSecondes = 20 * 60;
dash.max_metrics = 1000;
};
Expand Down
21 changes: 19 additions & 2 deletions app/assets/stylesheets/metrics.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,28 @@
}
}

.timeline-stepper {
margin-left: 5px;
}

.ad-hoc-tenant, .filters-selector, .tenants-selector {
.btn {
margin-left: 0px;
}

.dropdown-menu.open {
margin-top: -11px;
}
}

.list-view-container, .line-chart, .blank-slate-pf {
margin-bottom: 0;
min-height: calc(100vh - 362px);
margin-left: 20px;
margin-right: 20px;

.list-group-item {
padding-top: 0px;
padding-bottom: 0px;
}
}

.list-view-container {
Expand Down
18 changes: 8 additions & 10 deletions app/views/ems_container/ad_hoc/_list_view_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
"ng-click" => "dash.refreshTenant()"}
= _("Set Tenant")
%input.form-control{"id" => "ad-hoc-tenant",
"type" => "text",
"ng-model" => "dash.tenant",
"placeholder" => _("Choose Tenants"),
"typeahead" => "tenenat for tenenat in dash.getTenants($viewValue)",
"typeahead-loading" => "dash.loadingTenants",
"ng-change" => "dash.tenantChanged = true",
"typeahead-on-select" => "dash.refreshTenant()",
"typeahead-wait-ms" => 500}
%select.selectpicker.tenants-selector{"pf-select" => "",
"id" => "tenant-slector",
"ng-options" => "t as t for t in dash.tenantList",
"ng-model" => "dash.tenant",
"ng-change" => "dash.tenantChanged = true",
"data-live-search" => "true",
"data-actions-box" => "true"}
.ad-hoc-toolbar{"pf-toolbar" => "", "config" => "dash.toolbarConfig"}
.ad-hoc-toolbar.filters-selector{"pf-toolbar" => "", "config" => "dash.toolbarConfig"}
%actions
%button.btn.btn-default{"type" => "button",
"ng-click" => "dash.doAddFilter()",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
describe('adHocMetricsController', function() {
var $scope, $controller, $httpBackend, pfViewUtils;
var mock_data = getJSONFixture('container_live_dashboard_response.json');
var mock_tenants_data = getJSONFixture('container_live_dashboard_tenant_response.json');
var mock_metrics_data = getJSONFixture('container_live_dashboard_metrics_response.json');
var mock_data1_data = getJSONFixture('container_live_dashboard_data1_response.json');
var mock_data2_data = getJSONFixture('container_live_dashboard_data2_response.json');
Expand All @@ -16,6 +17,7 @@ describe('adHocMetricsController', function() {

beforeEach(inject(function(_$httpBackend_, $rootScope, _$controller_) {
$httpBackend = _$httpBackend_;
$httpBackend.when('GET','/container_dashboard/data/42/?live=true&query=get_tenants').respond(mock_tenants_data);
$httpBackend.when('GET','/container_dashboard/data/42/?live=true&tenant=_system&query=metric_tags&limit=250').respond(mock_data);
$httpBackend.when('GET','/container_dashboard/data/42/?live=true&tenant=_system&limit=1000&query=metric_definitions&tags={}').respond(mock_metrics_data);
$httpBackend.when('GET','/container_dashboard/data/42/?live=true&type=gauge&tenant=_system&query=get_data&metric_id=hello1&limit=5&order=DESC').respond(mock_data1_data);
Expand Down

0 comments on commit 78ba391

Please sign in to comment.