Guest User

Untitled

a guest
Mar 28th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. app.service('gethostsbyip', [ '$http', '$q', function($http, $q){
  2. this.gethostsbyip = function(hostname, username, password){
  3. var deffered = $q.defer();
  4. var result = $http.post(REST_API_IP + 'discover?ip=' + hostname + '&username=' + username + '&password=' + password).then(function(resp){
  5. deffered.resolve(result);
  6. location.href="#createvirtualization";
  7. toastr.success('Your hosts, templates, networks have been updated!', 'Data was loaded!');
  8. }).catch(function(e){
  9. toastr.error('Some data in your form is incorrect. Please, try again!', 'Error!');
  10. });
  11. return deffered.promise;
  12. };
  13. }]);
  14.  
  15. app.controller('discoverCtrl', ['$scope', '$q', function($scope, $q) {
  16.  
  17. $scope.submitButt = function(hostname, username, password){
  18. if(!hostname || !username || !password){
  19. }
  20. else {
  21. $scope.flag = true;
  22. gethostsbyip.gethostsbyip(hostname, username, password).then(function(res){
  23. $scope.test = false;
  24. })
  25. .catch(function(e){
  26. $scope.test = false;
  27. })
  28. }
  29. };
Add Comment
Please, Sign In to add comment