Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.service('gethostsbyip', [ '$http', '$q', function($http, $q){
- this.gethostsbyip = function(hostname, username, password){
- var deffered = $q.defer();
- var result = $http.post(REST_API_IP + 'discover?ip=' + hostname + '&username=' + username + '&password=' + password).then(function(resp){
- deffered.resolve(result);
- location.href="#createvirtualization";
- toastr.success('Your hosts, templates, networks have been updated!', 'Data was loaded!');
- }).catch(function(e){
- toastr.error('Some data in your form is incorrect. Please, try again!', 'Error!');
- });
- return deffered.promise;
- };
- }]);
- app.controller('discoverCtrl', ['$scope', '$q', function($scope, $q) {
- $scope.submitButt = function(hostname, username, password){
- if(!hostname || !username || !password){
- }
- else {
- $scope.flag = true;
- gethostsbyip.gethostsbyip(hostname, username, password).then(function(res){
- $scope.test = false;
- })
- .catch(function(e){
- $scope.test = false;
- })
- }
- };
Add Comment
Please, Sign In to add comment