2016-06-13 12:12:46 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.services.destination')
|
|
|
|
.factory('PingDestinationService', PingDestinationService);
|
|
|
|
|
|
|
|
PingDestinationService.$inject = ['$http'];
|
|
|
|
|
|
|
|
function PingDestinationService($http) {
|
|
|
|
return pingDestination;
|
2016-06-15 11:46:23 +02:00
|
|
|
function pingDestination(target) {
|
|
|
|
var payload = {};
|
|
|
|
if(target['id']) {
|
|
|
|
payload = {'id': target['id']};
|
|
|
|
}else {
|
|
|
|
payload = {
|
|
|
|
'name': target['name'],
|
|
|
|
'endpoint': target['endpoint'],
|
|
|
|
'username': target['username'],
|
|
|
|
'password': target['password']
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-06-13 12:12:46 +02:00
|
|
|
return $http({
|
|
|
|
'method': 'POST',
|
|
|
|
'url': '/api/targets/ping',
|
|
|
|
'headers': {'Content-Type': 'application/x-www-form-urlencoded'},
|
|
|
|
'transformRequest': function(obj) {
|
|
|
|
var str = [];
|
|
|
|
for(var p in obj) {
|
|
|
|
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
|
|
|
|
}
|
|
|
|
return str.join("&");
|
|
|
|
},
|
2016-06-30 09:57:00 +02:00
|
|
|
'timeout': 30000,
|
2016-06-15 11:46:23 +02:00
|
|
|
'data': payload
|
2016-06-13 12:12:46 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|