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

118 lines
3.8 KiB
JavaScript
Raw Normal View History

/*
* Wazuh app - App state service
* Copyright (C) 2018 Wazuh, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/
import * as modules from 'ui/modules'
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 => {
2018-03-11 11:17:53 +00:00
const 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');
},
2018-03-11 11:17:53 +00:00
removeClusterInfo: () => {
return $cookies.remove('_clusterInfo');
},
2017-11-13 11:49:22 +00:00
setClusterInfo: cluster_info => {
2018-03-11 11:17:53 +00:00
const 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');
},
2018-03-11 11:17:53 +00:00
setCreatedAt: date => {
const exp = new Date();
exp.setDate(exp.getDate() + 365);
$cookies.putObject('_createdAt',date,{ 'expires': exp });
},
setCurrentPattern: newPattern => {
2018-03-11 11:17:53 +00:00
const exp = new Date();
exp.setDate(exp.getDate() + 365);
if (newPattern) {
$cookies.putObject('_currentPattern', newPattern, { 'expires': exp });
}
},
2018-03-11 11:17:53 +00:00
removeCurrentPattern: () => {
return $cookies.remove('_currentPattern');
},
getCreatedAt: () => {
return $cookies.getObject('_createdAt');
},
removeCreatedAt: () => {
return $cookies.remove('_createdAt');
},
getCurrentAPI: () => {
return $cookies.getObject('API');
},
removeCurrentAPI: () => {
return $cookies.remove('API');
},
setCurrentAPI: API => {
2018-03-11 11:17:53 +00:00
const 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');
},
getPatternSelector: () => {
return $cookies.getObject('patternSelector');
},
setPatternSelector: value => {
$cookies.putObject('patternSelector', value);
},
removePatternSelector: () => {
return $cookies.remove('patternSelector');
},
setCurrentDevTools: current => {
$cookies.putObject('currentDevTools',current);
},
getCurrentDevTools: () => {
return $cookies.getObject('currentDevTools')
2017-10-30 09:14:36 +00:00
}
};
});