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', [])
|
2017-07-05 09:09:27 +00:00
|
|
|
.service('testConnection', function ($q, $http) {
|
2016-08-11 12:14:42 +00:00
|
|
|
return {
|
2017-02-13 19:58:44 +00:00
|
|
|
check_stored: function () {
|
2016-08-11 12:14:42 +00:00
|
|
|
var defered = $q.defer();
|
|
|
|
var promise = defered.promise;
|
2017-09-22 07:36:47 +00:00
|
|
|
$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 {
|
2017-09-22 07:36:47 +00:00
|
|
|
defered.resolve(response);
|
2016-08-11 12:14:42 +00:00
|
|
|
}
|
2017-09-22 07:36:47 +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;
|
|
|
|
},
|
2017-02-13 19:58:44 +00:00
|
|
|
check: function (data) {
|
2016-10-25 19:03:21 +00:00
|
|
|
var defered = $q.defer();
|
|
|
|
var promise = defered.promise;
|
2017-09-22 07:36:47 +00:00
|
|
|
$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 {
|
2017-09-22 07:36:47 +00:00
|
|
|
defered.resolve(response);
|
2016-10-25 19:03:21 +00:00
|
|
|
}
|
2017-09-22 07:36:47 +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
|
|
|
});
|