wazuh-kibana-app/public/services/app-state.js

72 lines
2.3 KiB
JavaScript
Raw Normal View History

require('ui/modules').get('app/wazuh', []).service('appState', function ($cookies, $window) {
2017-10-30 09:14:36 +00:00
return {
getExtensions: () => {
2018-01-17 17:55:59 +00:00
const data = {
2017-10-30 09:14:36 +00:00
extensions: $cookies.getObject('extensions')
};
2018-01-17 17:55:59 +00:00
if(typeof data.extensions === 'undefined'){
return {
extensions : {
audit : true,
pci : true,
oscap : true,
2018-01-26 17:07:45 +00:00
aws : false,
virustotal: false
2018-01-17 17:55:59 +00:00
}
}
}
return data;
2017-10-30 09:14:36 +00:00
},
2017-11-13 11:49:22 +00:00
setExtensions: extensions => {
var exp = new Date();
exp.setDate(exp.getDate() + 365);
2017-10-30 09:14:36 +00:00
if (extensions) {
$cookies.putObject('extensions', extensions, { 'expires': exp });
2017-10-30 09:14:36 +00:00
}
},
getClusterInfo: () => {
return $cookies.getObject('_clusterInfo');
},
2017-11-13 11:49:22 +00:00
setClusterInfo: cluster_info => {
var exp = new Date();
exp.setDate(exp.getDate() + 365);
2017-10-30 09:14:36 +00:00
if (cluster_info) {
$cookies.putObject('_clusterInfo', cluster_info, { 'expires': exp });
2017-10-30 09:14:36 +00:00
}
},
getCurrentPattern: () => {
return $cookies.getObject('_currentPattern');
},
setCurrentPattern: newPattern => {
var exp = new Date();
exp.setDate(exp.getDate() + 365);
if (newPattern) {
$cookies.putObject('_currentPattern', newPattern, { 'expires': exp });
}
},
getCurrentAPI: () => {
return $cookies.getObject('API');
},
removeCurrentAPI: () => {
return $cookies.remove('API');
},
setCurrentAPI: API => {
var exp = new Date();
exp.setDate(exp.getDate() + 365);
if (API) {
$cookies.putObject('API', API, { 'expires': exp});
}
2018-01-25 12:44:01 +00:00
},
setUserCode: code => {
$cookies.putObject('userCode', code);
},
getUserCode: () => {
return $cookies.getObject('userCode');
},
removeUserCode: () => {
return $cookies.remove('userCode');
2017-10-30 09:14:36 +00:00
}
};
});