-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add alerts drop down to provider view #1918
Changes from 5 commits
a67c6ed
6689316
73060b3
ac68b9d
3228bb5
473c334
6da318b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,13 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' | |
service_account_auth_status: '', | ||
metrics_auth_status: '', | ||
ssh_keypair_auth_status: '', | ||
vmware_cloud_api_version: '' | ||
vmware_cloud_api_version: '', | ||
prometheus_alerts_hostname: '', | ||
prometheus_alerts_api_port: '', | ||
prometheus_alerts_tls_ca_certs: '', | ||
prometheus_alerts_auth_status: '', | ||
prometheus_alerts_security_protocol: '', | ||
alerts_selection: '', | ||
}; | ||
$scope.formId = emsCommonFormId; | ||
$scope.afterGet = false; | ||
|
@@ -140,7 +146,13 @@ 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.metrics_api_port = data.metrics_api_port !== undefined && data.metrics_api_port !== '' ? data.metrics_api_port.toString() : '' | ||
$scope.emsCommonModel.metrics_api_port = data.metrics_api_port !== undefined && data.metrics_api_port !== '' ? data.metrics_api_port.toString() : ''; | ||
$scope.emsCommonModel.alerts_selection = data.alerts_selection; | ||
$scope.emsCommonModel.prometheus_alerts_hostname = data.prometheus_alerts_hostname; | ||
$scope.emsCommonModel.prometheus_alerts_api_port = data.prometheus_alerts_api_port !== undefined && data.prometheus_alerts_api_port !== '' ? data.prometheus_alerts_api_port.toString() : '443'; | ||
$scope.emsCommonModel.prometheus_alerts_auth_status = data.prometheus_alerts_auth_status; | ||
$scope.emsCommonModel.prometheus_alerts_security_protocol = data.prometheus_alerts_security_protocol; | ||
$scope.emsCommonModel.prometheus_alerts_tls_ca_certs = data.prometheus_alerts_tls_ca_certs; | ||
|
||
if ($scope.emsCommonModel.default_userid !== '') { | ||
$scope.emsCommonModel.default_password = miqService.storedPasswordPlaceholder; | ||
|
@@ -177,6 +189,11 @@ 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.alerts_selection = data.alerts_selection; | ||
$scope.emsCommonModel.prometheus_alerts_api_port = '443'; | ||
$scope.emsCommonModel.prometheus_alerts_auth_status = data.prometheus_alerts_auth_status; | ||
$scope.emsCommonModel.prometheus_alerts_security_protocol = data.prometheus_alerts_security_protocol; | ||
$scope.emsCommonModel.prometheus_alerts_tls_ca_certs = data.prometheus_alerts_tls_ca_certs; | ||
$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 = ''; | ||
|
@@ -247,10 +264,15 @@ 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.emsCommonModel.metrics_selection != "disabled" && $scope.emsCommonModel.ems_controller == "ems_container") && | ||
} else if(($scope.emsCommonModel.ems_controller == "ems_container") && | ||
($scope.emsCommonModel.emstype) && | ||
($scope.emsCommonModel.metrics_hostname != '' && $scope.emsCommonModel.metrics_api_port) && | ||
($scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid)) { | ||
($scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly Please apply this elsewhere too (to all your PR changes where this is applicable) |
||
(($scope.currentTab == "metrics" && | ||
$scope.emsCommonModel.metrics_hostname != '' && | ||
$scope.emsCommonModel.metrics_api_port) || | ||
($scope.currentTab == "alerts" && | ||
$scope.emsCommonModel.prometheus_alerts_hostname != '' && | ||
$scope.emsCommonModel.prometheus_alerts_api_port != ''))) { | ||
return true; | ||
} else if($scope.emsCommonModel.emstype == "gce" && $scope.emsCommonModel.project != '' && | ||
($scope.currentTab == "default" || | ||
|
@@ -336,16 +358,24 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' | |
} | ||
}; | ||
|
||
$scope.metricSelectionChanged = function() { | ||
if ($scope.emsCommonModel.metrics_selection == "disabled") { | ||
$scope.tabSelectionChanged = function(tabSelector, selection) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nice @yaacov ! 👍 🐈 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you seating at a beach drinking from a coconut, and commenting on hard working peoples PR's ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, just your'e PR's! 😉 |
||
if (selection == "disabled") { | ||
$scope.changeAuthTab('default'); | ||
angular.element('.nav-tabs a[href="#default"]').tab('show'); | ||
angular.element("#metrics_tab").hide(); | ||
angular.element(tabSelector).hide(); | ||
} else { | ||
angular.element("#metrics_tab").show(); | ||
angular.element(tabSelector).show(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is OK for the first pass, since it has already been tested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes 👍 , the whole ruby |
||
}; | ||
|
||
$scope.metricSelectionChanged = function() { | ||
$scope.tabSelectionChanged("#metrics_tab", $scope.emsCommonModel.metrics_selection); | ||
}; | ||
|
||
$scope.alertsSelectionChanged = function() { | ||
$scope.tabSelectionChanged("#alerts_tab", $scope.emsCommonModel.alerts_selection); | ||
}; | ||
|
||
$scope.providerTypeChanged = function() { | ||
if ($scope.emsCommonModel.ems_controller === 'ems_container') { | ||
$scope.emsCommonModel.default_api_port = "8443"; // TODO: correct per-type port | ||
|
@@ -429,14 +459,19 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' | |
if ($scope.emsCommonModel.ssh_keypair_auth_status === true) { | ||
$scope.postValidationModelRegistry("ssh_keypair"); | ||
} | ||
if ($scope.emsCommonModel.prometheus_alerts_auth_status === true) { | ||
$scope.postValidationModelRegistry("prometheus_alerts"); | ||
} | ||
}; | ||
|
||
$scope.postValidationModelRegistry = function(prefix) { | ||
if ($scope.postValidationModel === undefined) { | ||
$scope.postValidationModel = {default: {}, | ||
amqp: {}, | ||
metrics: {}, | ||
ssh_keypair: {} | ||
$scope.postValidationModel = { | ||
default: {}, | ||
amqp: {}, | ||
metrics: {}, | ||
ssh_keypair: {}, | ||
prometheus_alerts: {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. trailing comma is missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Thanks ! how did this pass code climate ? |
||
} | ||
} | ||
if (prefix === "default") { | ||
|
@@ -503,6 +538,12 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' | |
$scope.postValidationModel['service_account'] = { | ||
service_account: $scope.emsCommonModel.service_account | ||
} | ||
} else if (prefix == "prometheus_alerts") { | ||
$scope.postValidationModel['prometheus_alerts'] = {}; | ||
['prometheus_alerts_hostname', 'prometheus_alerts_api_port', 'prometheus_alerts_security_protocol', 'prometheus_alerts_tls_ca_certs'] | ||
.forEach( function(resource) { | ||
$scope.postValidationModel['prometheus_alerts'][resource] = $scope.emsCommonModel[resource]; | ||
}); | ||
} | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
===
instead of==
Also, a space is preferred after
if
per style guideThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AparnaKarve Thanks 👍 the
if
with no space, looked wrong ... but codeclimate didn't shout so I thought is was ok :-)