wazuh-kibana-app/public/services/pattern-handler.js
2018-03-19 11:24:24 +01:00

26 lines
1.0 KiB
JavaScript

require('ui/modules').get('app/wazuh', [])
.service('patternHandler', function ($rootScope, $route, genericReq, courier, appState, errorHandler) {
return {
getPatternList: async () => {
try {
const patternList = await genericReq.request('GET','/get-list',{});
return patternList.data.data;
} catch (error) {
errorHandler.handle(error,'Pattern Handler (getPatternList)');
if(!$rootScope.$$phase) $rootScope.$digest();
}
},
changePattern: async selectedPattern => {
try {
const data = await genericReq.request('GET', `/api/wazuh-elastic/updatePattern/${selectedPattern}`);
appState.setCurrentPattern(selectedPattern);
return appState.getCurrentPattern();
} catch (error) {
errorHandler.handle(error,'Pattern Handler (changePattern)');
if(!$rootScope.$$phase) $rootScope.$digest();
}
}
};
});