Skip to content

Commit

Permalink
further changes to ui for support
Browse files Browse the repository at this point in the history
refactoring
  • Loading branch information
nimrodshn committed Jun 8, 2017
1 parent 6a9f6a0 commit 26eb2e3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 35 deletions.
Expand Up @@ -15,6 +15,12 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
project: '',
default_api_port: '',
amqp_api_port: '',
prometheus_hostname: '',
prometheus_api_port: '',
monitoring_selection: '',
prometheus_tls_ca_certs: '',
prometheus_auth_status: '',
prometheus_security_protocol: '',
hawkular_api_port: '',
metrics_api_port: '',
api_version: '',
Expand Down Expand Up @@ -48,7 +54,6 @@ 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: '',
Expand Down Expand Up @@ -138,8 +143,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 Down Expand Up @@ -186,7 +189,6 @@ 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.prometheus_api_port = '80';
$scope.emsCommonModel.prometheus_auth_status = data.prometheus_auth_status;
Expand All @@ -196,13 +198,16 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$scope.emsCommonModel.monitoring_selection = data.monitoring_selection;
$scope.emsCommonModel.default_security_protocol = data.default_security_protocol;
$scope.emsCommonModel.hawkular_security_protocol = data.hawkular_security_protocol;
$scope.emsCommonModel.prometheus_security_protocol = data.prometheus_security_protocol;
$scope.emsCommonModel.prometheus_tls_ca_certs = data.prometheus_tls_ca_certs;
$scope.emsCommonModel.default_tls_ca_certs = data.default_tls_ca_certs;
$scope.emsCommonModel.hawkular_tls_ca_certs = data.hawkular_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.prometheus_auth_status = data.prometheus_auth_status;
$scope.emsCommonModel.hawkular_auth_status = data.hawkular_auth_status;
$scope.emsCommonModel.vmware_cloud_api_version = '9.0';
miqService.sparkleOff();
Expand Down Expand Up @@ -325,10 +330,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 @@ -368,7 +369,7 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', '
$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);
// Should we revert to emsCommonModel.monitoring_selection == "disabled" ?
// Container types are nearly identical, no point resetting most fields on type change.
return;
}
Expand Down
62 changes: 37 additions & 25 deletions app/controllers/mixins/ems_common_angular.rb
Expand Up @@ -180,6 +180,15 @@ def ems_form_fields
hawkular_tls_ca_certs = @ems.connection_configurations.hawkular.endpoint.certificate_authority
end

if @ems.connection_configurations.prometheus.try(:endpoint)
prometheus_hostname = @ems.connection_configurations.prometheus.endpoint.hostname
prometheus_api_port = @ems.connection_configurations.prometheus.endpoint.port
prometheus_auth_status = @ems.authentication_status_ok?(:prometheus)
prometheus_security_protocol = @ems.connection_configurations.prometheus.endpoint.security_protocol
prometheus_security_protocol ||= security_protocol_default
prometheus_tls_ca_certs = @ems.connection_configurations.prometheus.endpoint.certificate_authority
end

if @ems.connection_configurations.default.try(:endpoint)
default_hostname = @ems.connection_configurations.default.endpoint.hostname
default_api_port = @ems.connection_configurations.default.endpoint.port
Expand Down Expand Up @@ -273,30 +282,33 @@ def ems_form_fields
:ssh_keypair_auth_status => ssh_keypair_auth_status.nil? ? true : ssh_keypair_auth_status
} if controller_name == "ems_infra"

render :json => {:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
:hostname => @ems.hostname,
:default_hostname => @ems.connection_configurations.default.endpoint.hostname,
:monitoring_selection => retrieve_monitoring_selection,
:metrics_selection_default => @ems.emstype == 'kubernetes' ? 'disabled' : 'enabled',
:hawkular_hostname => hawkular_hostname,
:default_api_port => @ems.connection_configurations.default.endpoint.port,
:hawkular_api_port => hawkular_api_port,
:prometheus_hostname => prometheus_hostname,
:prometheus_api_port => prometheus_api_port,
:api_version => @ems.api_version ? @ems.api_version : "v2",
:default_security_protocol => default_security_protocol,
:hawkular_security_protocol => hawkular_security_protocol,
:default_tls_ca_certs => default_tls_ca_certs,
:hawkular_tls_ca_certs => hawkular_tls_ca_certs,
:provider_region => @ems.provider_region,
:default_userid => @ems.authentication_userid ? @ems.authentication_userid : "",
:service_account => service_account ? service_account : "",
:bearer_token_exists => @ems.authentication_token(:bearer).nil? ? false : true,
:ems_controller => controller_name,
:default_auth_status => default_auth_status,
:hawkular_auth_status => hawkular_auth_status,
render :json => { :name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
:hostname => @ems.hostname,
:default_hostname => @ems.connection_configurations.default.endpoint.hostname,
:monitoring_selection => retrieve_monitoring_selection,
:metrics_selection_default => @ems.emstype == 'kubernetes' ? 'disabled' : 'enabled',
:hawkular_hostname => hawkular_hostname,
:default_api_port => @ems.connection_configurations.default.endpoint.port,
:hawkular_api_port => hawkular_api_port,
:prometheus_hostname => prometheus_hostname,
:prometheus_api_port => prometheus_api_port,
:prometheus_tls_ca_certs => prometheus_tls_ca_certs,
:prometheus_security_protocol => prometheus_security_protocol,
:api_version => @ems.api_version ? @ems.api_version : "v2",
:default_security_protocol => default_security_protocol,
:hawkular_security_protocol => hawkular_security_protocol,
:default_tls_ca_certs => default_tls_ca_certs,
:hawkular_tls_ca_certs => hawkular_tls_ca_certs,
:provider_region => @ems.provider_region,
:default_userid => @ems.authentication_userid ? @ems.authentication_userid : "",
:service_account => service_account ? service_account : "",
:bearer_token_exists => @ems.authentication_token(:bearer).nil? ? false : true,
:ems_controller => controller_name,
:default_auth_status => default_auth_status,
:prometheus_auth_status => prometheus_auth_status,
:hawkular_auth_status => hawkular_auth_status,
} if controller_name == "ems_container"

if controller_name == "ems_middleware"
Expand Down Expand Up @@ -373,7 +385,7 @@ def set_ems_record_vars(ems, mode = nil)
hawkular_security_protocol = params[:hawkular_security_protocol].strip if params[:hawkular_security_protocol]
default_tls_ca_certs = params[:default_tls_ca_certs].strip if params[:default_tls_ca_certs]
hawkular_tls_ca_certs = params[:hawkular_tls_ca_certs].strip if params[:hawkular_tls_ca_certs]
prometheus_tls_ca_certs = params[:hawkular_tls_ca_certs].strip if params[:hawkular_tls_ca_certs]
prometheus_tls_ca_certs = params[:prometheus_tls_ca_certs].strip if params[:prometheus_tls_ca_certs]
default_endpoint = {}
amqp_endpoint = {}
ceilometer_endpoint = {}
Expand Down
Expand Up @@ -265,7 +265,7 @@
%label.col-md-2.control-label{"for" => "prov_monitoring"}
= _("Monitoring")
.col-md-8
= select_tag('monitoring_selection', options_for_select([["<#{_('Choose>')}", nil] ,[_("Disabled"), "disabled"], [_("Hawkular"), "hawkular"],
= select_tag('monitoring_selection', options_for_select([[_("Disabled"), "disabled"], [_("Hawkular"), "hawkular"],
[_("Prometheus"), "prometheus"]]),
"ng-model" => "emsCommonModel.monitoring_selection",
"checkchange" => "",
Expand Down

0 comments on commit 26eb2e3

Please sign in to comment.