<commit_before>ManageIQ.angular.app.controller('hostFormController', ['$http', '$scope', '$attrs', 'hostFormId', 'miqService', function($http, $scope, $attrs, hostFormId, miqService) {
  var init = function() {
    $scope.hostModel = {
      name: '',
      hostname: '',
      ipmi_address: '',
      custom_1: '',
      user_assigned_os: '',
      operating_system: false,
      mac_address: '',
      default_userid: '',
      default_password: '',
      default_verify: '',
      remote_userid: '',
      remote_password: '',
      remote_verify: '',
      ws_userid: '',
      ws_password: '',
      ws_verify: '',
      ipmi_userid: '',
      ipmi_password: '',
      ipmi_verify: '',
      validate_id: '',
    };

    $scope.modelCopy = angular.copy( $scope.hostModel );
    $scope.afterGet = false;
    $scope.formId = hostFormId;
    $scope.validateClicked = miqService.validateWithAjax;
    $scope.formFieldsUrl = $attrs.formFieldsUrl;
    $scope.createUrl = $attrs.createUrl;
    $scope.updateUrl = $attrs.updateUrl;
    ManageIQ.angular.scope = $scope;

    if (hostFormId == 'new') {
      $scope.newRecord = true;
      $scope.hostModel.name = "";
      $scope.hostModel.hostname = "";
      $scope.hostModel.ipmi_address = "";
      $scope.hostModel.custom_1 = "";
      $scope.hostModel.user_assigned_os = "";
      $scope.hostModel.operating_system = false;
      $scope.hostModel.mac_address = "";
      $scope.hostModel.default_userid = "";
      $scope.hostModel.default_password = "";
      $scope.hostModel.default_verify = "";
      $scope.hostModel.remote_userid = "";
      $scope.hostModel.remote_password = "";
      $scope.hostModel.remote_verify = "";
      $scope.hostModel.ws_userid = "";
      $scope.hostModel.ws_password = "";
      $scope.hostModel.ws_verify = "";
      $scope.hostModel.ipmi_userid = "";
      $scope.hostModel.ipmi_password = "";
      $scope.hostModel.ipmi_verify = "";
      $scope.hostModel.validate_id = "";
      $scope.afterGet = true;

    } else if (hostFormId.split(",").length == 1) {
        miqService.sparkleOn();
        $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;
          $scope.hostModel.custom_1 = data.custom_1;
          $scope.hostModel.user_assigned_os = data.user_assigned_os;
          $scope.hostModel.operating_system = data.operating_system;
          $scope.hostModel.mac_address = data.mac_address;
          $scope.hostModel.default_userid = data.default_userid;
          $scope.hostModel.remote_userid = data.remote_userid;
          $scope.hostModel.ws_userid = data.ws_userid;
          $scope.hostModel.ipmi_userid = data.ipmi_userid;
          $scope.hostModel.validate_id = data.validate_id;

          if($scope.hostModel.default_userid != '') {
            $scope.hostModel.default_password = $scope.hostModel.default_verify = miqService.storedPasswordPlaceholder;
          }
          if($scope.hostModel.remote_userid != '') {
            $scope.hostModel.remote_password = $scope.hostModel.remote_verify = miqService.storedPasswordPlaceholder;
          }
          if($scope.hostModel.ws_userid != '') {
            $scope.hostModel.ws_password = $scope.hostModel.ws_verify = miqService.storedPasswordPlaceholder;
          }
          if($scope.hostModel.ipmi_userid != '') {
            $scope.hostModel.ipmi_password = $scope.hostModel.ipmi_verify = miqService.storedPasswordPlaceholder;
          }

          $scope.afterGet = true;

          $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.changeAuthTab = function(id) {
    $scope.currentTab = id;
  }

  $scope.addClicked = function() {
    miqService.sparkleOn();
    var url = 'create/new' + '?button=add';
    miqService.miqAjaxButton(url, true);
  };

  $scope.cancelClicked = function() {
    miqService.sparkleOn();
    if (hostFormId == 'new') {
      var url = $scope.createUrl + 'new?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();
    if (hostFormId.split(",").length > 1) {
      var url = $scope.updateUrl + '?button=save';<commit_msg>Removed $watch from host controller<commit_after>ManageIQ.angular.app.controller('hostFormController', ['$http', '$scope', '$attrs', 'hostFormId', 'miqService', function($http, $scope, $attrs, hostFormId, miqService) {
  var init = function() {
    $scope.hostModel = {
      name: '',
      hostname: '',
      ipmi_address: '',
      custom_1: '',
      user_assigned_os: '',
      operating_system: false,
      mac_address: '',
      default_userid: '',
      default_password: '',
      default_verify: '',
      remote_userid: '',
      remote_password: '',
      remote_verify: '',
      ws_userid: '',
      ws_password: '',
      ws_verify: '',
      ipmi_userid: '',
      ipmi_password: '',
      ipmi_verify: '',
      validate_id: '',
    };

    $scope.modelCopy = angular.copy( $scope.hostModel );
    $scope.afterGet = false;
    $scope.formId = hostFormId;
    $scope.validateClicked = miqService.validateWithAjax;
    $scope.formFieldsUrl = $attrs.formFieldsUrl;
    $scope.createUrl = $attrs.createUrl;
    $scope.updateUrl = $attrs.updateUrl;
    $scope.model = "hostModel";
    ManageIQ.angular.scope = $scope;

    if (hostFormId == 'new') {
      $scope.newRecord = true;
      $scope.hostModel.name = "";
      $scope.hostModel.hostname = "";
      $scope.hostModel.ipmi_address = "";
      $scope.hostModel.custom_1 = "";
      $scope.hostModel.user_assigned_os = "";
      $scope.hostModel.operating_system = false;
      $scope.hostModel.mac_address = "";
      $scope.hostModel.default_userid = "";
      $scope.hostModel.default_password = "";
      $scope.hostModel.default_verify = "";
      $scope.hostModel.remote_userid = "";
      $scope.hostModel.remote_password = "";
      $scope.hostModel.remote_verify = "";
      $scope.hostModel.ws_userid = "";
      $scope.hostModel.ws_password = "";
      $scope.hostModel.ws_verify = "";
      $scope.hostModel.ipmi_userid = "";
      $scope.hostModel.ipmi_password = "";
      $scope.hostModel.ipmi_verify = "";
      $scope.hostModel.validate_id = "";
      $scope.afterGet = true;

    } else if (hostFormId.split(",").length == 1) {
        miqService.sparkleOn();
        $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;
          $scope.hostModel.custom_1 = data.custom_1;
          $scope.hostModel.user_assigned_os = data.user_assigned_os;
          $scope.hostModel.operating_system = data.operating_system;
          $scope.hostModel.mac_address = data.mac_address;
          $scope.hostModel.default_userid = data.default_userid;
          $scope.hostModel.remote_userid = data.remote_userid;
          $scope.hostModel.ws_userid = data.ws_userid;
          $scope.hostModel.ipmi_userid = data.ipmi_userid;
          $scope.hostModel.validate_id = data.validate_id;

          if($scope.hostModel.default_userid != '') {
            $scope.hostModel.default_password = $scope.hostModel.default_verify = miqService.storedPasswordPlaceholder;
          }
          if($scope.hostModel.remote_userid != '') {
            $scope.hostModel.remote_password = $scope.hostModel.remote_verify = miqService.storedPasswordPlaceholder;
          }
          if($scope.hostModel.ws_userid != '') {
            $scope.hostModel.ws_password = $scope.hostModel.ws_verify = miqService.storedPasswordPlaceholder;
          }
          if($scope.hostModel.ipmi_userid != '') {
            $scope.hostModel.ipmi_password = $scope.hostModel.ipmi_verify = miqService.storedPasswordPlaceholder;
          }

          $scope.afterGet = true;

          $scope.modelCopy = angular.copy( $scope.hostModel );
          miqService.sparkleOff();
        });
     } else if (hostFormId.split(",").length > 1) {
      $scope.afterGet = true;
    }

     $scope.currentTab = "default";
  };

  $scope.changeAuthTab = function(id) {
    $scope.currentTab = id;
  }

  $scope.addClicked = function() {
    miqService.sparkleOn();
    var url = 'create/new' + '?button=add';
    miqService.miqAjaxButton(url, true);
  };

  $scope.cancelClicked = function() {
    miqService.sparkleOn();
    if (hostFormId == 'new') {
      var url = $scope.createUrl + 'new?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();
    if (hostFormId.split(",").length > 1) {
      var url = $scope.updateUrl + '?button=save';
{'fraction_non_alphanumeric': 0.14970748015043878, 'fraction_numerical': 0.0018804847471792729, 'mean_word_length': 2.761493123772102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4440530', 'n_tokens_mistral': 3131, 'n_tokens_neox': 3095, 'n_words': 399}