2018-04-22 20:16:38 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2018-04-21 11:31:47 +00:00
|
|
|
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 : {
|
2018-01-23 11:52:02 +00:00
|
|
|
audit : true,
|
|
|
|
pci : true,
|
2018-05-14 11:23:56 +00:00
|
|
|
gdpr : true,
|
2018-01-23 11:52:02 +00:00
|
|
|
oscap : true,
|
2018-01-26 17:07:45 +00:00
|
|
|
aws : false,
|
2018-01-24 10:33:53 +00:00
|
|
|
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();
|
2017-12-19 17:43:59 +00:00
|
|
|
exp.setDate(exp.getDate() + 365);
|
2017-10-30 09:14:36 +00:00
|
|
|
if (extensions) {
|
2017-12-19 17:43:59 +00:00
|
|
|
$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();
|
2017-12-19 17:43:59 +00:00
|
|
|
exp.setDate(exp.getDate() + 365);
|
2017-10-30 09:14:36 +00:00
|
|
|
if (cluster_info) {
|
2017-12-19 17:43:59 +00:00
|
|
|
$cookies.putObject('_clusterInfo', cluster_info, { 'expires': exp });
|
2017-10-30 09:14:36 +00:00
|
|
|
}
|
2017-12-03 14:30:47 +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 });
|
|
|
|
},
|
2017-12-03 14:30:47 +00:00
|
|
|
setCurrentPattern: newPattern => {
|
2018-03-11 11:17:53 +00:00
|
|
|
const exp = new Date();
|
2017-12-19 17:43:59 +00:00
|
|
|
exp.setDate(exp.getDate() + 365);
|
2017-12-03 14:30:47 +00:00
|
|
|
if (newPattern) {
|
2017-12-19 17:43:59 +00:00
|
|
|
$cookies.putObject('_currentPattern', newPattern, { 'expires': exp });
|
2017-12-03 14:30:47 +00:00
|
|
|
}
|
2017-12-12 16:59:19 +00:00
|
|
|
},
|
2018-03-11 11:17:53 +00:00
|
|
|
removeCurrentPattern: () => {
|
|
|
|
return $cookies.remove('_currentPattern');
|
|
|
|
},
|
|
|
|
getCreatedAt: () => {
|
|
|
|
return $cookies.getObject('_createdAt');
|
2018-04-22 20:16:38 +00:00
|
|
|
},
|
2018-03-12 15:36:20 +00:00
|
|
|
removeCreatedAt: () => {
|
|
|
|
return $cookies.remove('_createdAt');
|
2018-04-22 20:16:38 +00:00
|
|
|
},
|
2017-12-12 16:59:19 +00:00
|
|
|
getCurrentAPI: () => {
|
|
|
|
return $cookies.getObject('API');
|
|
|
|
},
|
|
|
|
removeCurrentAPI: () => {
|
|
|
|
return $cookies.remove('API');
|
|
|
|
},
|
|
|
|
setCurrentAPI: API => {
|
2018-03-11 11:17:53 +00:00
|
|
|
const exp = new Date();
|
2017-12-19 17:43:59 +00:00
|
|
|
exp.setDate(exp.getDate() + 365);
|
2017-12-12 16:59:19 +00:00
|
|
|
if (API) {
|
2017-12-19 17:43:59 +00:00
|
|
|
$cookies.putObject('API', API, { 'expires': exp});
|
2017-12-12 16:59:19 +00:00
|
|
|
}
|
2018-01-25 12:44:01 +00:00
|
|
|
},
|
|
|
|
setUserCode: code => {
|
|
|
|
$cookies.putObject('userCode', code);
|
|
|
|
},
|
|
|
|
getUserCode: () => {
|
|
|
|
return $cookies.getObject('userCode');
|
|
|
|
},
|
|
|
|
removeUserCode: () => {
|
|
|
|
return $cookies.remove('userCode');
|
2018-03-13 14:19:11 +00:00
|
|
|
},
|
|
|
|
getPatternSelector: () => {
|
|
|
|
return $cookies.getObject('patternSelector');
|
|
|
|
},
|
|
|
|
setPatternSelector: value => {
|
|
|
|
$cookies.putObject('patternSelector', value);
|
|
|
|
},
|
|
|
|
removePatternSelector: () => {
|
|
|
|
return $cookies.remove('patternSelector');
|
2018-05-08 14:25:49 +00:00
|
|
|
},
|
|
|
|
setCurrentDevTools: current => {
|
2018-05-08 14:50:02 +00:00
|
|
|
$window.localStorage.setItem('currentDevTools',current);
|
2018-05-08 14:25:49 +00:00
|
|
|
},
|
|
|
|
getCurrentDevTools: () => {
|
2018-05-08 14:50:02 +00:00
|
|
|
return $window.localStorage.getItem('currentDevTools')
|
2017-10-30 09:14:36 +00:00
|
|
|
}
|
|
|
|
};
|
2017-12-12 16:59:19 +00:00
|
|
|
});
|