wazuh-kibana-app/public/objects/testConnection.js

41 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-05-25 16:29:54 +00:00
import chrome from 'ui/chrome';
2016-08-11 12:14:42 +00:00
require('ui/modules').get('app/wazuh', [])
.service('testConnection', function ($q, $http) {
2016-08-11 12:14:42 +00:00
return {
check_stored: function () {
2016-08-11 12:14:42 +00:00
var defered = $q.defer();
var promise = defered.promise;
$http.get(chrome.addBasePath("/api/wazuh-api/check")).then(function successCallback(response) {
if (response.error) {
defered.reject(response);
2016-08-11 12:14:42 +00:00
} else {
defered.resolve(response);
2016-08-11 12:14:42 +00:00
}
}, function errorCallback(response) {
if (response.error) {
defered.reject(response);
}
});
2016-08-11 12:14:42 +00:00
2016-10-25 19:03:21 +00:00
return promise;
},
check: function (data) {
2016-10-25 19:03:21 +00:00
var defered = $q.defer();
var promise = defered.promise;
$http.post(chrome.addBasePath("/api/wazuh-api/check"), data).then(function successCallback(response) {
if (response.error) {
defered.reject(response);
2016-10-25 19:03:21 +00:00
} else {
defered.resolve(response);
2016-10-25 19:03:21 +00:00
}
}, function errorCallback(response) {
if (response.error) {
defered.reject(response);
}
});
2016-10-25 19:03:21 +00:00
2016-08-11 12:14:42 +00:00
return promise;
}
};
2017-05-25 16:29:54 +00:00
});