Skip to content

Commit

Permalink
add support for monitoring selection in UI
Browse files Browse the repository at this point in the history
some refactoring

further refactoring

further changes to ui for support

refactoring

moved the drop down to the provider section

further refactoring

further refactoring

further refactoring

add refactoring for support

further support for edit

Fixing specs and some refactoring

minor refactoring

some refactoring

minor fixes in design

Refactoring and renaming

.

.

minor refactoring

changed retrieve_metrics_selection

refactored code: changed variable names to 'metric_' prefix and refactored 'retrieve_metrics' method

some refactoring

refactored code and tests

refactored code a bit

some refactoring

some refactoring

minor refactoring

refactored a bit

added authentication for prometheus

losed unneeded parantheses

refctored metricsStatusChanged

added cred type

fixed tab bug

moved metrics down

minor refactoring

using angular now

minor refactoring

minor refactoring to tabs

move from jquery to angular

moved from querySelector to id

refactor code

very good commit

refactored get route

usless assignment

bad refactor
  • Loading branch information
nimrodshn committed Aug 29, 2017
1 parent 4c4fa19 commit 39f61a0
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 167 deletions.
Expand Up @@ -10,22 +10,21 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
hostname: '',
default_hostname: '',
amqp_hostname: '',
hawkular_hostname: '',
metrics_hostname: '',
metrics_selection: '',
metrics_api_port: '',
metrics_security_protocol: '',
metrics_tls_ca_certs: '',
project: '',
default_api_port: '',
amqp_api_port: '',
hawkular_api_port: '',
metrics_api_port: '',
api_version: '',
default_security_protocol: '',
default_tls_verify: true,
default_tls_ca_certs: '',
realm: '',
security_protocol: '',
amqp_security_protocol: '',
hawkular_security_protocol: '',
hawkular_tls_ca_certs: '',
provider_region: '',
default_userid: '',
default_password: '',
Expand All @@ -45,15 +44,13 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
host_default_vnc_port_start: '',
host_default_vnc_port_end: '',
event_stream_selection: '',
metrics_selection: '',
bearer_token_exists: false,
ems_controller: '',
default_auth_status: '',
amqp_auth_status: '',
service_account_auth_status: '',
metrics_auth_status: '',
ssh_keypair_auth_status: '',
hawkular_auth_status: '',
vmware_cloud_api_version: ''
};
$scope.formId = emsCommonFormId;
Expand Down Expand Up @@ -96,7 +93,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.hostname = data.hostname;
$scope.emsCommonModel.default_hostname = data.default_hostname;
$scope.emsCommonModel.amqp_hostname = data.amqp_hostname;
$scope.emsCommonModel.hawkular_hostname = data.hawkular_hostname;
$scope.emsCommonModel.metrics_selection = data.metrics_selection;
$scope.emsCommonModel.metrics_hostname = data.metrics_hostname;
$scope.emsCommonModel.project = data.project;

Expand All @@ -105,9 +102,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.provider_id = data.provider_id !== undefined ? data.provider_id.toString() : "";

$scope.emsCommonModel.default_api_port = data.default_api_port !== undefined && data.default_api_port !== '' ? data.default_api_port.toString() : $scope.getDefaultApiPort($scope.emsCommonModel.emstype);
$scope.emsCommonModel.metrics_port = data.metrics_port !== undefined && data.metrics_port !== '' ? data.metrics_port.toString() : '443';
$scope.emsCommonModel.amqp_api_port = data.amqp_api_port !== undefined && data.amqp_api_port !== '' ? data.amqp_api_port.toString() : '5672';
$scope.emsCommonModel.hawkular_api_port = data.hawkular_api_port !== undefined && data.hawkular_api_port !== '' ? data.hawkular_api_port.toString() : '443';
$scope.emsCommonModel.metrics_api_port = data.metrics_api_port !== undefined && data.metrics_api_port !== '' ? data.metrics_api_port.toString() : '';
$scope.emsCommonModel.metrics_database_name = data.metrics_database_name !== undefined && data.metrics_database_name !== '' ? data.metrics_database_name : data.metrics_default_database_name;
$scope.emsCommonModel.api_version = data.api_version;
$scope.emsCommonModel.default_security_protocol = data.default_security_protocol;
Expand All @@ -116,8 +112,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.default_tls_verify = data.default_tls_verify;
$scope.emsCommonModel.default_tls_ca_certs = data.default_tls_ca_certs;
$scope.emsCommonModel.amqp_security_protocol = data.amqp_security_protocol !== '' ? data.amqp_security_protocol : 'non-ssl';
$scope.emsCommonModel.hawkular_security_protocol = data.hawkular_security_protocol;
$scope.emsCommonModel.hawkular_tls_ca_certs = data.hawkular_tls_ca_certs;
$scope.emsCommonModel.metrics_security_protocol = data.metrics_security_protocol;
$scope.emsCommonModel.metrics_tls_ca_certs = data.metrics_tls_ca_certs;
$scope.emsCommonModel.provider_region = data.provider_region;
$scope.emsCommonModel.default_userid = data.default_userid;
$scope.emsCommonModel.amqp_userid = data.amqp_userid;
Expand All @@ -135,8 +131,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.host_default_vnc_port_end = data.host_default_vnc_port_end;

$scope.emsCommonModel.event_stream_selection = data.event_stream_selection;
$scope.emsCommonModel.metrics_selection = data.metrics_selection;
$scope.emsCommonModel.metrics_selection_default = data.metrics_selection_default;

$scope.emsCommonModel.bearer_token_exists = data.bearer_token_exists;

Expand All @@ -146,7 +140,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.service_account_auth_status = data.service_account_auth_status;
$scope.emsCommonModel.metrics_auth_status = data.metrics_auth_status;
$scope.emsCommonModel.ssh_keypair_auth_status = data.ssh_keypair_auth_status;
$scope.emsCommonModel.hawkular_auth_status = data.hawkular_auth_status;
$scope.emsCommonModel.metrics_api_port = data.metrics_api_port !== undefined && data.metrics_api_port !== '' ? data.metrics_api_port.toString() : ''

if ($scope.emsCommonModel.default_userid !== '') {
$scope.emsCommonModel.default_password = miqService.storedPasswordPlaceholder;
Expand Down Expand Up @@ -183,22 +177,22 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.openstack_infra_providers_exist = data.openstack_infra_providers_exist;
$scope.emsCommonModel.default_api_port = '';
$scope.emsCommonModel.amqp_api_port = '5672';
$scope.emsCommonModel.metrics_selection = data.metrics_selection;
$scope.emsCommonModel.hawkular_api_port = '443';
$scope.emsCommonModel.api_version = 'v2';
$scope.emsCommonModel.ems_controller = data.ems_controller;
$scope.emsCommonModel.ems_controller === 'ems_container' ? $scope.emsCommonModel.default_api_port = '8443' : $scope.emsCommonModel.default_api_port = '';
$scope.emsCommonModel.metrics_api_port = '443';
$scope.emsCommonModel.metrics_selection = data.metrics_selection;
$scope.emsCommonModel.default_security_protocol = data.default_security_protocol;
$scope.emsCommonModel.hawkular_security_protocol = data.hawkular_security_protocol;
$scope.emsCommonModel.metrics_security_protocol = data.metrics_security_protocol;
$scope.emsCommonModel.default_tls_ca_certs = data.default_tls_ca_certs;
$scope.emsCommonModel.hawkular_tls_ca_certs = data.hawkular_tls_ca_certs;
$scope.emsCommonModel.metrics_tls_ca_certs = data.metrics_tls_ca_certs;
$scope.emsCommonModel.default_auth_status = data.default_auth_status;
$scope.emsCommonModel.amqp_auth_status = data.amqp_auth_status;
$scope.emsCommonModel.service_account_auth_status = data.service_account_auth_status;
$scope.emsCommonModel.metrics_auth_status = true;
$scope.emsCommonModel.ssh_keypair_auth_status = true;
$scope.emsCommonModel.hawkular_auth_status = data.hawkular_auth_status;
$scope.emsCommonModel.metrics_auth_status = data.metrics_auth_status;
$scope.emsCommonModel.vmware_cloud_api_version = '9.0';

miqService.sparkleOff();

$scope.afterGet = true;
Expand Down Expand Up @@ -253,9 +247,9 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
($scope.emsCommonModel.default_hostname != '' && $scope.emsCommonModel.default_api_port) &&
($scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid)) {
return true;
} else if(($scope.currentTab == "hawkular" && $scope.emsCommonModel.ems_controller == "ems_container") &&
} else if(($scope.emsCommonModel.metrics_selection != "disabled" && $scope.emsCommonModel.ems_controller == "ems_container") &&
($scope.emsCommonModel.emstype) &&
($scope.emsCommonModel.hawkular_hostname != '' && $scope.emsCommonModel.hawkular_api_port) &&
($scope.emsCommonModel.metrics_hostname != '' && $scope.emsCommonModel.metrics_api_port) &&
($scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid)) {
return true;
} else if($scope.emsCommonModel.emstype == "gce" && $scope.emsCommonModel.project != '' &&
Expand All @@ -268,7 +262,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
};

$scope.isDetectionEnabled = function() {
return ($scope.currentTab == "hawkular" && $scope.emsCommonModel.ems_controller == "ems_container") &&
return ($scope.emsCommonModel.metrics_selection == "hawkular" && $scope.emsCommonModel.ems_controller == "ems_container") &&
($scope.emsCommonModel.emstype == "openshift") &&
($scope.emsCommonModel.default_hostname && $scope.emsCommonModel.default_api_port) &&
($scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid);
Expand Down Expand Up @@ -306,10 +300,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.$broadcast('clearErrorOnTab', {tab: "amqp"});
}

if ($scope.emsCommonModel.metrics_selection === "hawkular_disabled") {
$scope.$broadcast('clearErrorOnTab', {tab: "hawkular"});
}

var authStatus = $scope.currentTab + "_auth_status";
if ($scope.emsCommonModel[authStatus] === true) {
$scope.postValidationModelRegistry($scope.currentTab);
Expand Down Expand Up @@ -346,11 +336,19 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
}
};

$scope.metricSelectionChanged = function() {
if ($scope.emsCommonModel.metrics_selection == "disabled") {
$scope.changeAuthTab('default');
angular.element('.nav-tabs a[href="#default"]').tab('show');
angular.element("#metrics_tab").hide();
} else {
angular.element("#metrics_tab").show();
}
};

$scope.providerTypeChanged = function() {
if ($scope.emsCommonModel.ems_controller === 'ems_container') {
$scope.emsCommonModel.default_api_port = "8443"; // TODO: correct per-type port
$scope.emsCommonModel.metrics_selection = "hawkular_".concat($scope.emsCommonModel.metrics_selection_default);
// Container types are nearly identical, no point resetting most fields on type change.
return;
}
$scope.emsCommonModel.default_api_port = "";
Expand Down Expand Up @@ -431,18 +429,15 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
if ($scope.emsCommonModel.ssh_keypair_auth_status === true) {
$scope.postValidationModelRegistry("ssh_keypair");
}
if ($scope.emsCommonModel.hawkular_auth_status === true) {
$scope.postValidationModelRegistry("hawkular");
}
};

$scope.postValidationModelRegistry = function(prefix) {
if ($scope.postValidationModel === undefined) {
$scope.postValidationModel = {default: {},
amqp: {},
metrics: {},
ssh_keypair: {},
hawkular: {}}
ssh_keypair: {}
}
}
if (prefix === "default") {
if ($scope.newRecord) {
Expand Down Expand Up @@ -477,17 +472,22 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
amqp_password: amqp_password,
};
} else if (prefix === "metrics") {
if ($scope.newRecord) {
var metrics_password = $scope.emsCommonModel.metrics_password;
} else {
var metrics_password = $scope.emsCommonModel.metrics_password === "" ? "" : miqService.storedPasswordPlaceholder;
}
var metricsValidationModel = {
metrics_hostname: $scope.emsCommonModel.metrics_hostname,
metrics_api_port: $scope.emsCommonModel.metrics_api_port,
metrics_userid: $scope.emsCommonModel.metrics_userid,
metrics_password: metrics_password,
metrics_hostname: $scope.emsCommonModel.metrics_hostname,
metrics_api_port: $scope.emsCommonModel.metrics_api_port,
};
if ($scope.emsCommonModel.metrics_selection == "hawkular" || $scope.emsCommonModel.metrics_selection == "prometheus") {
metricsValidationModel.metrics_security_protocol = $scope.emsCommonModel.metrics_security_protocol;
metricsValidationModel.metrics_tls_ca_certs = $scope.emsCommonModel.metrics_tls_ca_certs;
} else {
if ($scope.newRecord) {
var metrics_password = $scope.emsCommonModel.metrics_password;
} else {
var metrics_password = $scope.emsCommonModel.metrics_password === "" ? "" : miqService.storedPasswordPlaceholder;
}
metricsValidationModel.metrics_userid = $scope.emsCommonModel.metrics_userid;
metricsValidationModel.metrics_password = metrics_password;
}
$scope.postValidationModel['metrics'] = metricsValidationModel;
} else if (prefix === "ssh_keypair") {
if ($scope.newRecord) {
Expand All @@ -503,13 +503,6 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.postValidationModel['service_account'] = {
service_account: $scope.emsCommonModel.service_account
}
} else if (prefix === "hawkular") {
$scope.postValidationModel['hawkular'] = {
hawkular_hostname: $scope.emsCommonModel.hawkular_hostname,
hawkular_api_port: $scope.emsCommonModel.hawkular_api_port,
hawkular_security_protocol: $scope.emsCommonModel.hawkular_security_protocol,
hawkular_tls_ca_certs: $scope.emsCommonModel.hawkular_tls_ca_certs,
}
}
};

Expand All @@ -534,7 +527,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
};

$scope.updateHawkularHostname = function(value) {
$scope.emsCommonModel.hawkular_hostname = value;
$scope.emsCommonModel.metrics_hostname = value;
};

$scope.radioSelectionChanged = function() {
Expand All @@ -551,11 +544,5 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
}
};

$scope.containerMetricsChanged = function() {
if ($scope.emsCommonModel.metrics_selection === "hawkular_disabled") {
$scope.$broadcast('clearErrorOnTab', {tab: "hawkular"});
}
};

init();
}]);
8 changes: 7 additions & 1 deletion app/controllers/ems_container_controller.rb
Expand Up @@ -92,7 +92,13 @@ def get_hostname_from_routes(ems)
end

def retrieve_metrics_selection
@ems.endpoints.count == 1 ? 'hawkular_disabled' : 'hawkular_enabled'
if @ems.connection_configurations.try(:prometheus)
"prometheus"
elsif @ems.connection_configurations.try(:hawkular)
"hawkular"
else
"disabled"
end
end

private
Expand Down

0 comments on commit 39f61a0

Please sign in to comment.