hunk.code_window:     }, function error(err) {
         Messages.error("Failure", err, 'Unable to retrieve application settings');
       });
       $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
         Analytics.trackPage(toState.url);
         Analytics.pageView();
       });
       $rootScope.$state = $state;
     }])
     // This is your docker url that the api will use to make requests
     // You need to set this to the api endpoint without the port i.e. http://192.168.1.9
     .constant('DOCKER_PORT', '') // Docker port, leave as an empty string if no port is required.  If you have a port, prefix it with a ':' i.e. :4243
  
hunk.labels: keep keep keep keep replace replace replace replace replace keep keep keep keep keep
hunk.file_path: app/app.js
hunk.type: replace
file: angular.module('endpoint', [])
  .controller('EndpointController', ['$scope', '$state', '$stateParams', '$filter', 'EndpointService', 'Messages',
  function ($scope, $state, $stateParams, $filter, EndpointService, Messages) {
    $scope.state = {
      error: '',
      uploadInProgress: false
    };
    $scope.formValues = {
      TLSCACert: null,
      TLSCert: null,
      TLSKey: null
    };
  
    $scope.updateEndpoint = function() {
      var ID = $scope.endpoint.Id;
      var name = $scope.endpoint.Name;
      var URL = $scope.endpoint.URL;
      var TLS = $scope.endpoint.TLS;
      var TLSCACert = $scope.formValues.TLSCACert !== $scope.endpoint.TLSCACert ? $scope.formValues.TLSCACert : null;
      var TLSCert = $scope.formValues.TLSCert !== $scope.endpoint.TLSCert ? $scope.formValues.TLSCert : null;
      var TLSKey = $scope.formValues.TLSKey !== $scope.endpoint.TLSKey ? $scope.formValues.TLSKey : null;
      var type = $scope.endpointType;
      EndpointService.updateEndpoint(ID, name, URL, TLS, TLSCACert, TLSCert, TLSKey, type).then(function success(data) {
        Messages.send("Endpoint updated", $scope.endpoint.Name);
        $state.go('endpoints');
      }, function error(err) {
        $scope.state.error = err.msg;
      }, function update(evt) {
        if (evt.upload) {
          $scope.state.uploadInProgress = evt.upload;
        }
      });
    };
  
    function getEndpoint(endpointID) {
      $('#loadingViewSpinner').show();
      EndpointService.endpoint($stateParams.id).then(function success(data) {
        $('#loadingViewSpinner').hide();
        $scope.endpoint = data;
        if (data.URL.indexOf("unix://") === 0) {
          $scope.endpointType = 'local';
        } else {
          $scope.endpointType = 'remote';
        }
        $scope.endpoint.URL = $filter('stripprotocol')(data.URL);
        $scope.formValues.TLSCACert = data.TLSCACert;
        $scope.formValues.TLSCert = data.TLSCert;
        $scope.formValues.TLSKey = data.TLSKey;
      }, function error(err) {
        $('#loadingViewSpinner').hide();
        Messages.error("Failure", err, "Unable to retrieve endpoint details");
      });
    }
  
    getEndpoint($stateParams.id);
  }]);
  