From 836e5eb2a95eeea9e4255ae97547f586e16964ff Mon Sep 17 00:00:00 2001 From: Aparna Karve Date: Mon, 17 Aug 2015 23:00:25 -0700 Subject: [PATCH] Used layouts/angular/x_edit_buttons_angular partial for the buttons Also made a few other adjustments in the haml --- app/assets/javascripts/application.js | 1 - .../controllers/host/host_form_controller.js | 81 ++++++++++++++-- .../directives/host/multiple_tabs.js | 37 -------- .../javascripts/services/miq_service.js | 66 ++----------- app/controllers/host_controller.rb | 9 +- app/views/host/_form.html.haml | 51 +++++----- ...th_credentials_angular_bootstrap.html.haml | 2 +- .../_form_buttons_verify_angular.html.haml | 22 +++-- ...haml => _multi_auth_credentials.html.haml} | 93 ++++++++++++------- config/environments/development.rb | 2 +- .../host/host_form_controller_spec.js | 17 +++- 11 files changed, 191 insertions(+), 190 deletions(-) delete mode 100644 app/assets/javascripts/directives/host/multiple_tabs.js rename app/views/layouts/angular/{_multi_auth_credentials_form.html.haml => _multi_auth_credentials.html.haml} (76%) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e905731a07c..a063d5848f2 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,7 +17,6 @@ //= require directives/repository/valid_unc_path //= require services/miq_service //= require services/timer_option_service -//= require controllers/angular-bootstrap/DatepickerCtrl //= require controllers/host/host_form_controller //= require controllers/provider_foreman/provider_foreman_form_controller //= require controllers/repository/repository_form_controller diff --git a/app/assets/javascripts/controllers/host/host_form_controller.js b/app/assets/javascripts/controllers/host/host_form_controller.js index b85b8a6ddda..c0c066da841 100644 --- a/app/assets/javascripts/controllers/host/host_form_controller.js +++ b/app/assets/javascripts/controllers/host/host_form_controller.js @@ -1,4 +1,4 @@ -ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', 'hostFormId', 'miqService', function($http, $scope, hostFormId, miqService) { +ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', '$attrs', 'hostFormId', 'miqService', function($http, $scope, $attrs, hostFormId, miqService) { var init = function() { $scope.hostModel = { name: '', @@ -26,10 +26,15 @@ ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', $scope.modelCopy = angular.copy( $scope.hostModel ); $scope.afterGet = false; $scope.formId = hostFormId; - ManageIQ.angularApplication.$scope = $scope; $scope.saveable = miqService.saveable; + $scope.validateClicked = miqService.validateClicked; + $scope.formFieldsUrl = $attrs.formFieldsUrl; + $scope.createUrl = $attrs.createUrl; + $scope.updateUrl = $attrs.updateUrl; + ManageIQ.angularApplication.$scope = $scope; if (hostFormId == 'new') { + $scope.newRecord = true; $scope.hostModel.name = ""; $scope.hostModel.hostname = ""; $scope.hostModel.ipmi_address = ""; @@ -52,9 +57,9 @@ ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', $scope.hostModel.validate_id = ""; $scope.afterGet = true; - } else { + } else if (hostFormId.split(",").length == 1) { miqService.sparkleOn(); - $http.get('/host/host_form_fields/' + hostFormId).success(function(data) { + $http.get($scope.formFieldsUrl + hostFormId).success(function (data) { $scope.hostModel.name = data.name; $scope.hostModel.hostname = data.hostname; $scope.hostModel.ipmi_address = data.ipmi_address; @@ -81,14 +86,15 @@ ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', $scope.modelCopy = angular.copy( $scope.hostModel ); miqService.sparkleOff(); }); - } + } else if (hostFormId.split(",").length > 1) { + $scope.afterGet = true; + } $scope.currentTab = "default"; $scope.$watch("hostModel.name", function() { $scope.form = $scope.angularForm; $scope.model = "hostModel"; - $scope.miqService = miqService; }); }; @@ -105,17 +111,25 @@ ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', $scope.cancelClicked = function() { miqService.sparkleOn(); if (hostFormId == 'new') { - var url = '/host/create/new' + '?button=cancel'; + var url = $scope.createUrl + 'new?button=cancel'; } - else { - var url = '/host/update/' + hostFormId + '?button=cancel'; + else if (hostFormId.split(",").length == 1) { + var url = $scope.updateUrl + hostFormId + '?button=cancel'; + } + else if (hostFormId.split(",").length > 1) { + var url = $scope.updateUrl + '?button=cancel'; } miqService.miqAjaxButton(url); }; $scope.saveClicked = function() { miqService.sparkleOn(); - var url = '/host/update/' + hostFormId + '?button=save'; + if (hostFormId.split(",").length > 1) { + var url = $scope.updateUrl + '?button=save'; + } + else { + var url = $scope.updateUrl + hostFormId + '?button=save'; + } miqService.miqAjaxButton(url, true); }; @@ -135,21 +149,25 @@ ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', $scope.isBasicInfoValid = function() { if(($scope.currentTab == "default") && + ($scope.hostModel.hostname || $scope.hostModel.validate_id) && ($scope.hostModel.default_userid != '' && $scope.angularForm.default_userid.$valid && $scope.hostModel.default_password != '' && $scope.angularForm.default_password.$valid && $scope.hostModel.default_verify != '' && $scope.angularForm.default_verify.$valid)) { return true; } else if(($scope.currentTab == "remote") && + ($scope.hostModel.hostname || $scope.hostModel.validate_id) && ($scope.hostModel.remote_userid != '' && $scope.angularForm.remote_userid.$valid && $scope.hostModel.remote_password != '' && $scope.angularForm.remote_password.$valid && $scope.hostModel.remote_verify != '' && $scope.angularForm.remote_verify.$valid)) { return true; } else if(($scope.currentTab == "ws") && + ($scope.hostModel.hostname || $scope.hostModel.validate_id) && ($scope.hostModel.ws_userid != '' && $scope.angularForm.ws_userid.$valid && $scope.hostModel.ws_password != '' && $scope.angularForm.ws_password.$valid && $scope.hostModel.ws_verify != '' && $scope.angularForm.ws_verify.$valid)) { return true; } else if(($scope.currentTab == "ipmi") && + ($scope.hostModel.ipmi_address) && ($scope.hostModel.ipmi_userid != '' && $scope.angularForm.ipmi_userid.$valid && $scope.hostModel.ipmi_password != '' && $scope.angularForm.ipmi_password.$valid && $scope.hostModel.ipmi_verify != '' && $scope.angularForm.ipmi_verify.$valid)) { @@ -158,5 +176,48 @@ ManageIQ.angularApplication.controller('hostFormController', ['$http', '$scope', return false; }; + $scope.canValidate = function () { + if ($scope.isBasicInfoValid() && $scope.validateFieldsDirty()) + return true; + else + return false; + } + + $scope.canValidateBasicInfo = function () { + if ($scope.isBasicInfoValid()) + return true; + else + return false; + } + + $scope.validateFieldsDirty = function () { + if(($scope.currentTab == "default") && + (($scope.angularForm.hostname.$dirty || $scope.angularForm.validate_id.$dirty) && + $scope.angularForm.default_userid.$dirty && + $scope.angularForm.default_password.$dirty && + $scope.angularForm.default_verify.$dirty)) { + return true; + } else if(($scope.currentTab == "remote") && + (($scope.angularForm.hostname.$dirty || $scope.angularForm.validate_id.$dirty) && + $scope.angularForm.remote_userid.$dirty && + $scope.angularForm.remote_password.$dirty && + $scope.angularForm.remote_verify.$dirty)) { + return true; + } else if(($scope.currentTab == "ws") && + (($scope.angularForm.hostname.$dirty || $scope.angularForm.validate_id.$dirty) && + $scope.angularForm.ws_userid.$dirty && + $scope.angularForm.ws_password.$dirty && + $scope.angularForm.ws_verify.$dirty)) { + return true; + } else if(($scope.currentTab == "ipmi") && + ($scope.angularForm.ipmi_address.$dirty && + $scope.angularForm.ipmi_userid.$dirty && + $scope.angularForm.ipmi_password.$dirty && + $scope.angularForm.ipmi_verify.$dirty)) { + return true; + } else + return false; + } + init(); }]); diff --git a/app/assets/javascripts/directives/host/multiple_tabs.js b/app/assets/javascripts/directives/host/multiple_tabs.js deleted file mode 100644 index 1387be4e368..00000000000 --- a/app/assets/javascripts/directives/host/multiple_tabs.js +++ /dev/null @@ -1,37 +0,0 @@ -ManageIQ.angularApplication.directive('checkpath', function (){ - return { - require: 'ngModel', - link: function (scope, elem, attrs, ctrl) { - ctrl.$parsers.unshift(function() { - if(validPath(scope, ctrl.$viewValue)) { - ctrl.$setValidity('checkpath', true); - } - else { - ctrl.$setValidity('checkpath', false); - } - }); - - validPath = function(scope, path) { - modified_path = path.replace(/\\/g, "/"); - if(new RegExp("^//[^/].*/.+$").test(modified_path)) { - $j('#flash_msg_div').text(""); - scope.path_type = "NAS"; - return true; - } - else if(/^\[[^\]].+\].*$/.test(modified_path)) { - $j('#flash_msg_div').text(""); - scope.path_type = "VMFS"; - return true; - } - else { - if(scope.formId == "new") { - scope.miqService.miqFlash("warn", "Need a valid UNC path"); - } else { - scope.miqService.miqFlash("error", "Incorrect UNC path"); - } - return false; - } - }; - } - } -}); diff --git a/app/assets/javascripts/services/miq_service.js b/app/assets/javascripts/services/miq_service.js index 1e7b5a2f832..3455663b70d 100644 --- a/app/assets/javascripts/services/miq_service.js +++ b/app/assets/javascripts/services/miq_service.js @@ -52,10 +52,10 @@ ManageIQ.angularApplication.service('miqService', function() { var outerBox = $('
'); var innerSpan = $(''); } - $(outerBox).append(innerSpan); - $(outerBox).append(txt); - $(outerMost).append(outerBox); - $(outerMost).appendTo($("#flash_msg_div")); + $(outerBox).append(innerSpan); + $(outerBox).append(txt); + $(outerMost).append(outerBox); + $(outerMost).appendTo($("#flash_msg_div")); } this.miqFlashClear = function() { @@ -66,61 +66,9 @@ ManageIQ.angularApplication.service('miqService', function() { return form.$valid && form.$dirty; }; - this.canValidate = function (form, prefix) { - if (this.validateFieldsValid(form, prefix) && this.validateFieldsDirty(form, prefix)) - return true; - else - return false; - } - - this.canValidateBasicInfo = function () { - if (ManageIQ.angularApplication.$scope.isBasicInfoValid()) - return true; - else - return false; - } - - this.validateFieldsValid = function (form, prefix) { - if (form != undefined) { - if (prefix == "log") { - if (form.depot_name.$valid && - form.uri.$valid && - form[prefix + '_userid'].$valid && - form[prefix + '_password'].$valid && - form[prefix + '_verify'].$valid) - return true; - } else { - if (form[prefix + '_userid'].$valid && - form[prefix + '_password'].$valid && - form[prefix + '_verify'].$valid) - return true; - } - } else - return false; - } - - this.validateFieldsDirty = function (form, prefix) { - if (form != undefined) { - if (prefix == "log") { - if (form.depot_name.$dirty || - form.uri.$dirty || - form[prefix + '_userid'].$dirty || - form[prefix + '_password'].$dirty || - form[prefix + '_verify'].$dirty) - return true; - } else { - if (form[prefix + '_userid'].$dirty || - form[prefix + '_password'].$dirty || - form[prefix + '_verify'].$dirty) - return true; - } - } else - return false; - } - - this.validateClicked = function (url) { - this.sparkleOn(); - this.miqAjaxButton(url, true); + this.validateClicked = function (url) { + miqSparkleOn(); + miqAjaxButton(url, true); }; this.serializeModel = function(model) { diff --git a/app/controllers/host_controller.rb b/app/controllers/host_controller.rb index 38afee87165..61487039310 100644 --- a/app/controllers/host_controller.rb +++ b/app/controllers/host_controller.rb @@ -295,7 +295,6 @@ def create add_flash(_("Credential validation was successful")) end render :update do |page| - p "XXXXXX" page.replace("flash_msg_div", :partial=>"layouts/flash_msg") end end @@ -334,7 +333,6 @@ def update assert_privileges("host_edit") case params[:button] when "cancel" - @host = find_by_id_filtered(Host, params[:id]) session[:edit] = nil # clean out the saved info flash = "Edit for Host \"" @breadcrumbs.pop if @breadcrumbs @@ -345,6 +343,7 @@ def update page.redirect_to :action=>@lastaction, :display=>session[:host_display], :flash_msg=>flash end else + @host = find_by_id_filtered(Host, params[:id]) flash = _("Edit of %{model} \"%{name}\" was cancelled by the user") % {:model=>ui_lookup(:model=>"Host"), :name=>@host.name} render :update do |page| page.redirect_to :action=>@lastaction, :id=>@host.id, :display=>session[:host_display], :flash_msg=>flash @@ -593,11 +592,11 @@ def host_form_fields host_hash = { :name => host.name, :hostname => host.hostname, - :ipmi_address => host.ipmi_address, - :custom_1 => host.custom_1, + :ipmi_address => host.ipmi_address ? host.ipmi_address : "", + :custom_1 => host.custom_1 ? host.custom_1 : "", :user_assigned_os => host.user_assigned_os, :operating_system => !(host.operating_system.nil? || host.operating_system.product_name.nil?), - :mac_address => host.mac_address, + :mac_address => host.mac_address ? host.mac_address : "", :default_userid => host.authentication_userid.to_s, :default_password => host.authentication_password.to_s, :default_verify => host.authentication_password.to_s, diff --git a/app/views/host/_form.html.haml b/app/views/host/_form.html.haml index f7fe61dfcf1..8722b9b228f 100644 --- a/app/views/host/_form.html.haml +++ b/app/views/host/_form.html.haml @@ -1,7 +1,11 @@ - @angularForm = true -%form.form-horizontal#form_div{"name" => "angularForm", - "ng-controller" => "hostFormController", - "ng-show" => "afterGet"} +%form.form-horizontal#form_div{"name" => "angularForm", + "ng-controller" => "hostFormController", + "ng-show" => "afterGet", + "form-fields-url" => "/#{controller_name}/host_form_fields/", + "create-url" => "/#{controller_name}/create/", + "update-url" => "/#{controller_name}/update/", + "novalidate" => true} = render :partial => "layouts/flash_msg" - if session[:host_items].nil? %div @@ -32,27 +36,27 @@ "checkchange" => ""} %span.help-block{"ng-show" => "angularForm.hostname.$error.miqrequired"} = _("Required") - .form-group - %label.col-md-2.control-label - = _("Custom Identifier") - .col-md-10 - %input#custom_1{"type" => "text", - "name" => "custom_1", - "ng-model" => "hostModel.custom_1", - "maxlength" => 50, - "checkchange" => ""} .form-group{"ng-class" => "{'has-error': angularForm.user_assigned_os.$invalid}", "ng-hide" => "hostModel.operating_system"} %label.col-md-2.control-label = _("Host platform") .col-md-10 = select_tag('user_assigned_os', - options_for_select([["<#{_('not specified')}>", nil]] + Host.host_create_os_types.to_a), + options_for_select([["<#{_('Choose')}>", nil]] + Host.host_create_os_types.to_a, disabled: ["<#{_('Choose')}>", nil]), "ng-model" => "hostModel.user_assigned_os", "checkchange" => "", "ng-required" => "!hostModel.operating_system", "selectpicker-for-select-tag" => "") - %span.help-block{"ng-show" => "angularForm.name.$error.miqrequired"} + %span.help-block{"ng-show" => "angularForm.user_assigned_os.$error.required"} = _("Required") + .form-group + %label.col-md-2.control-label + = _("Custom Identifier") + .col-md-10 + %input#custom_1{"type" => "text", + "name" => "custom_1", + "ng-model" => "hostModel.custom_1", + "maxlength" => 50, + "checkchange" => ""} .form-group %label.col-md-2.control-label = _("IPMI IP Address") @@ -72,17 +76,9 @@ "maxlength" => "#{MAX_NAME_LEN}", "checkchange" => ""} - = render(:partial => "/layouts/angular/multi_auth_credentials_form", :locals => {:record => @host}) - %table{:width => '100%'} - %tr - %td{:align => 'right'} - #buttons_on - - if @host.id || session[:host_items] - = button_tag("Save", :class => "btn btn-primary", "ng-click" => "saveClicked()", "ng-disabled" => "angularForm.$pristine || angularForm.$invalid", "ng-class" => "{'btn-disabled': angularForm.$pristine || angularForm.$invalid}") - = button_tag("Reset", :class => "btn btn-primary", "ng-click" => "resetClicked()", "ng-disabled" => "angularForm.$pristine", "ng-class" => "{'btn-disabled': angularForm.$pristine}") - - else - = button_tag("Add", :class => "btn btn-primary", "ng-class" => "{'btn-disabled': !angularForm.$valid}", "ng-click" => "addClicked()", "ng-disabled" => "!angularForm.$valid") - = button_tag("Cancel", :class => "btn btn-default", "ng-click" => "cancelClicked()") + = render(:partial => "/layouts/angular/multi_auth_credentials", + :locals => {:record => @host, :ng_model => "hostModel"}) + = render :partial => "layouts/angular/x_edit_buttons_angular" - unless session[:host_items].nil? %h3 @@ -99,6 +95,5 @@ = render :partial => 'layouts/gtl' :javascript - ManageIQ.angularApplication.value('hostFormId', '#{@host.id || "new"}'); - //angular.bootstrap(jQuery('#form_div'), ['ManageIQ.angularApplication'], { strictDi: true }); - angular.bootstrap(jQuery('#form_div'), ['ManageIQ.angularApplication']); + ManageIQ.angularApplication.value('hostFormId', '#{(@host.id || (session[:host_items] && session[:host_items].join(","))) || "new"}'); + angular.bootstrap(jQuery('#form_div'), ['ManageIQ.angularApplication'], { strictDi: true }); diff --git a/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml b/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml index 9cc621b5326..a595c209a9f 100644 --- a/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml +++ b/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml @@ -4,7 +4,7 @@ - pwd_label ||= "Password" - ng_reqd_userid ||= false - ng_reqd_password ||= false -- ng_reqd_verify ||= false +- ng_reqd_verify ||= "#{ng_model}.#{prefix}_password != ''" %div{"ng-show" => "#{ng_show}"} .form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_userid.$error.required}"} diff --git a/app/views/layouts/angular/_form_buttons_verify_angular.html.haml b/app/views/layouts/angular/_form_buttons_verify_angular.html.haml index 2be2ae7124f..15cb3d1d082 100644 --- a/app/views/layouts/angular/_form_buttons_verify_angular.html.haml +++ b/app/views/layouts/angular/_form_buttons_verify_angular.html.haml @@ -3,12 +3,16 @@ - else - verify_title_on = "Validate the credentials by logging into the Server" -%tr{'ng-show' => ng_show} - %td - = button_tag("Validate", - :class => "btn btn-primary btn-xs", - :alt => verify_title_on, - :title => verify_title_on, - "ng-class" => basic_info_needed ? "{'btn-disabled': !miqService.canValidateBasicInfo()}" : "{'btn-disabled': !miqService.canValidate(angularForm, valtype)}", - "ng-click" => "miqService.validateClicked('#{url_for(:action => validate_url, :id => id, :type => valtype, :button => "validate")}')", - "ng-disabled" => basic_info_needed ? "!miqService.canValidateBasicInfo()" : "!miqService.canValidate(angularForm, valtype)") +%div{'ng-show' => ng_show} + = button_tag("Validate", + :class => "btn btn-primary btn-xs btn-disabled", + :alt => "Validate", + :title => "Validate", + "ng-show" => basic_info_needed ? "!canValidateBasicInfo()" : "!canValidate()") + = button_tag("Validate", + :class => "btn btn-primary btn-xs", + :alt => verify_title_on, + :title => verify_title_on, + "ng-show" => basic_info_needed ? "canValidateBasicInfo()" : "canValidate()", + "ng-click" => "validateClicked('#{url_for(:action => validate_url, :id => id, :type => valtype, :button => "validate")}')", +) diff --git a/app/views/layouts/angular/_multi_auth_credentials_form.html.haml b/app/views/layouts/angular/_multi_auth_credentials.html.haml similarity index 76% rename from app/views/layouts/angular/_multi_auth_credentials_form.html.haml rename to app/views/layouts/angular/_multi_auth_credentials.html.haml index 407c202b477..603ac053698 100644 --- a/app/views/layouts/angular/_multi_auth_credentials_form.html.haml +++ b/app/views/layouts/angular/_multi_auth_credentials.html.haml @@ -26,92 +26,115 @@ .tab-content = miq_tab_content('default', 'default') do - %table.style1 - %tbody + %div.style1 + %div = render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap", :locals => {:ng_show => true, - :ng_model => "hostModel", + :ng_model => "#{ng_model}", :validate_url => validate_url, :uid_label => @emstype == "ec2" ? "Access Key ID" : nil, :pwd_label => @emstype == "ec2" ? "Secret Access Key" : nil, :id => record.id, :prefix => "default", :basic_info_needed => true} - %span{:style => "color:black"}= _("Required. Should have privileged access, such as root or administrator.") + %div + .form-group + .col-md-12 + %span{:style => "color:black"} + = _("Required. Should have privileged access, such as root or administrator.") - if %w(ems_cloud ems_infra).include?(params[:controller]) = miq_tab_content('metrics', 'default') do - %table.style1 - %tbody + %div.style1 + %div = render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap", :locals => {:ng_show => true, - :ng_model => "hostModel", + :ng_model => "#{ng_model}", :validate_url => validate_url, :id => record.id, :prefix => "metrics", :basic_info_needed => true} - %span{:style => "color:black"} - Used to gather Capacity & Utilization metrics. + %div + .form-group + .col-md-12 + %span{:style => "color:black"} + = _("Used to gather Capacity & Utilization metrics.") = miq_tab_content('amqp', 'default') do - %table.style1 - %tbody + %div.style1 + %div = render :partial => "layouts/angular-bootstrap/auth_cbredentials_angular_bootstrap", :locals => {:ng_show => true, - :ng_model => "hostModel", + :ng_model => "#{ng_model}", :validate_url => validate_url, :id => record.id, :prefix => "amqp", :basic_info_needed => true} - %span{:style => "color:black"} - Used to authenticate with OpenStack AMQP Messaging Bus for event handling. + %div + .form-group + .col-md-12 + %span{:style => "color:black"} + = _("Used to authenticate with OpenStack AMQP Messaging Bus for event handling.") = miq_tab_content('ssh_keypair', 'default') do - %table.style1 - %tbody + %div.style1 + %div = render :partial => "/layouts/auth_credentials_keypair", :locals => {:ng_show => true, - :ng_model => "hostModel", + :ng_model => "#{ng_model}", :validate_url => validate_url, :id => record.id, :prefix => "ssh_keypair", :basic_info_needed => true} - %span{:style => "color:black"}= _("Used for SSH connection to all %s in this provider.") % title_for_hosts + %div + .form-group + .col-md-12 + %span{:style => "color:black"} + = _("Used for SSH connection to all %s in this provider.") % title_for_hosts - else = miq_tab_content('remote', 'default') do - %table.style1 - %tbody + %div.style1 + %div = render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap", :locals => {:ng_show => true, - :ng_model => "hostModel", + :ng_model => "#{ng_model}", :validate_url => validate_url, :id => record.id, :prefix => "remote", :basic_info_needed => true} - %span{:style => "color:black"} - Required if SSH login is disabled for the Default account. + %div + .form-group + .col-md-12 + %span{:style => "color:black"} + = _("Required if SSH login is disabled for the Default account.") = miq_tab_content('ws', 'default') do - %table.style1 - %tbody + %div.style1 + %div = render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap", :locals => {:ng_show => true, - :ng_model => "hostModel", + :ng_model => "#{ng_model}", :validate_url => validate_url, :id => record.id, :prefix => "ws", :basic_info_needed => true} - %span{:style => "color:black"} - Used for access to Web Services. + %div + .form-group + .col-md-12 + %span{:style => "color:black"} + = _("Used for access to Web Services.") = miq_tab_content('ipmi', 'default') do - %table.style1 - %tbody + %div.style1 + %div = render :partial => "layouts/angular-bootstrap/auth_credentials_angular_bootstrap", :locals => {:ng_show => true, - :ng_model => "hostModel", + :ng_model => "#{ng_model}", :validate_url => validate_url, :id => record.id, :prefix => "ipmi", :basic_info_needed => true} - %span{:style => "color:black"} - Used for access to IPMI. + %div + .form-group + .col-md-12 + %span{:style => "color:black"} + = _("Used for access to IPMI.") - if !session[:host_items].nil? %div %div @@ -120,8 +143,8 @@ = _("Select Host to validate against") .col-md-10 = select_tag('validate_id', - options_for_select([["<#{_('Choose')}>", '']] + @selected_hosts.invert.sort), - "ng-model" => "hostModel.validate_id", + options_for_select([["<#{_('Choose')}>", '']] + @selected_hosts.invert.sort, disabled: ["<#{_('Choose')}>", nil]), + "ng-model" => "#{ng_model}.validate_id", "checkchange" => "", "selectpicker-for-select-tag" => "") diff --git a/config/environments/development.rb b/config/environments/development.rb index 568c42d3d32..fcd1caf5c28 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,6 +1,6 @@ Vmdb::Application.configure do # Settings specified here will take precedence over those in config/application.rb - config.eager_load = false + # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. diff --git a/spec/javascripts/controllers/host/host_form_controller_spec.js b/spec/javascripts/controllers/host/host_form_controller_spec.js index 029672089ed..232cc88d082 100644 --- a/spec/javascripts/controllers/host/host_form_controller_spec.js +++ b/spec/javascripts/controllers/host/host_form_controller_spec.js @@ -3,7 +3,7 @@ describe('hostFormController', function() { beforeEach(module('ManageIQ.angularApplication')); - beforeEach(inject(function($rootScope, _$controller_, _$httpBackend_, _miqService_) { + beforeEach(inject(function(_$httpBackend_, $rootScope, _$controller_, _miqService_) { miqService = _miqService_; spyOn(miqService, 'showButtons'); spyOn(miqService, 'hideButtons'); @@ -27,6 +27,9 @@ describe('hostFormController', function() { $httpBackend.whenGET('/host/host_form_fields/new').respond(); $controller = _$controller_('hostFormController', { $scope: $scope, + $attrs: {'formFieldsUrl': '/host/host_form_fields/', + 'createUrl': '/host/create/', + 'updateUrl': '/host/update/'}, hostFormId: 'new', miqService: miqService }); @@ -76,7 +79,11 @@ describe('hostFormController', function() { $httpBackend.whenGET('/host/host_form_fields/12345').respond(hostFormResponse); - $controller = _$controller_('hostFormController', {$scope: $scope, hostFormId: '12345'}); + $controller = _$controller_('hostFormController', {$scope: $scope, + $attrs: {'formFieldsUrl': '/host/host_form_fields/', + 'createUrl': '/host/create/', + 'updateUrl': '/host/update/'}, + hostFormId: '12345'}); $httpBackend.flush(); })); @@ -166,6 +173,7 @@ describe('hostFormController', function() { var angularForm; var element = angular.element( '
' + + '' + '' + '' + '' + @@ -176,17 +184,18 @@ describe('hostFormController', function() { $scope.$digest(); angularForm = $scope.angularForm; + $scope.angularForm.hostname.$setViewValue('abchost'); $scope.angularForm.default_userid.$setViewValue('abcuser'); $scope.angularForm.default_password.$setViewValue('abcpassword'); $scope.angularForm.default_verify.$setViewValue('abcpassword'); })); it('returns true if all the Validation fields are filled in', function() { - expect(miqService.canValidateBasicInfo()).toBe(true); + expect($scope.canValidateBasicInfo()).toBe(true); }); it('returns true if all the Validation fields are filled in and dirty', function() { - expect(miqService.canValidate()).toBe(false); + expect($scope.canValidate()).toBe(true); }); }); });