mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 10:18:57 +00:00
Implemented Refresh function for Settings/Logs tab
This commit is contained in:
parent
1724ead13d
commit
0161d9e716
@ -15,7 +15,7 @@ import TabNames from '../../utils/tab-names';
|
||||
|
||||
const app = uiModules.get('app/wazuh', []);
|
||||
|
||||
app.controller('settingsController',
|
||||
app.controller('settingsController',
|
||||
function ($scope, $routeParams, $window, $location, testAPI, appState, genericReq, errorHandler, wzMisc, wazuhConfig) {
|
||||
if (wzMisc.getWizard()) {
|
||||
$window.sessionStorage.removeItem('healthCheck');
|
||||
@ -29,6 +29,7 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
$scope.formData = {};
|
||||
$scope.tab = 'api';
|
||||
$scope.load = true;
|
||||
$scope.loadingLogs = true;
|
||||
$scope.addManagerContainer = false;
|
||||
$scope.showEditForm = {};
|
||||
$scope.formUpdate = {};
|
||||
@ -232,7 +233,7 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
const config = wazuhConfig.getConfig();
|
||||
|
||||
appState.setPatternSelector(config['ip.selector']);
|
||||
|
||||
|
||||
tmpData.extensions.audit = config['extensions.audit'];
|
||||
tmpData.extensions.pci = config['extensions.pci'];
|
||||
tmpData.extensions.gdpr = config['extensions.gdpr'];
|
||||
@ -240,7 +241,7 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
tmpData.extensions.ciscat = config['extensions.ciscat'];
|
||||
tmpData.extensions.aws = config['extensions.aws'];
|
||||
tmpData.extensions.virustotal = config['extensions.virustotal'];
|
||||
|
||||
|
||||
const checkData = await testAPI.check(tmpData);
|
||||
|
||||
// API Check correct. Get Cluster info
|
||||
@ -280,7 +281,7 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
}
|
||||
|
||||
try {
|
||||
await genericReq.request('GET', '/api/wazuh-api/fetchAgents');
|
||||
await genericReq.request('GET', '/api/wazuh-api/fetchAgents');
|
||||
} catch (error) {
|
||||
|
||||
if(error && error.status && error.status === -1) {
|
||||
@ -288,7 +289,7 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
} else {
|
||||
errorHandler.handle(error,'Fetch agents');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
await getSettings();
|
||||
@ -434,6 +435,18 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
else $scope.messageErrorUpdate = text;
|
||||
};
|
||||
|
||||
const getAppLogs = async () => {
|
||||
try {
|
||||
$scope.loadingLogs = true;
|
||||
const logs = await genericReq.request('GET','/api/wazuh-api/logs',{});
|
||||
$scope.logs = logs.data.lastLogs.map(item => JSON.parse(item));
|
||||
$scope.loadingLogs = false;
|
||||
if(!$scope.$$phase) $scope.$digest();
|
||||
} catch (error) {
|
||||
$scope.logs = [{date: new Date(), level:'error', message: 'Error when loading Wazuh app logs'}];
|
||||
}
|
||||
};
|
||||
|
||||
const getAppInfo = async () => {
|
||||
try {
|
||||
const data = await genericReq.request('GET', '/api/wazuh-elastic/setup');
|
||||
@ -463,12 +476,10 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
$scope.extensions = appState.getExtensions(JSON.parse(appState.getCurrentAPI()).id);
|
||||
}
|
||||
|
||||
try {
|
||||
const logs = await genericReq.request('GET','/api/wazuh-api/logs',{});
|
||||
$scope.logs = logs.data.lastLogs.map(item => JSON.parse(item));
|
||||
} catch(error) {
|
||||
$scope.logs = [{date: new Date(), level:'error', message: 'Error when loading Wazuh app logs'}];
|
||||
if ($scope.tab === 'logs') {
|
||||
getAppLogs();
|
||||
}
|
||||
|
||||
if(!$scope.$$phase) $scope.$digest();
|
||||
return;
|
||||
} catch (error) {
|
||||
@ -479,4 +490,6 @@ function ($scope, $routeParams, $window, $location, testAPI, appState, genericRe
|
||||
|
||||
// Loading data
|
||||
getSettings().then(getAppInfo);
|
||||
|
||||
$scope.refreshLogs = () => getAppLogs();
|
||||
});
|
||||
|
@ -5,7 +5,18 @@
|
||||
<span class="md-subheader">Logs located at /usr/share/kibana/optimize/wazuh-logs/wazuhapp.log</span>
|
||||
</div>
|
||||
<!-- End headline -->
|
||||
<div layout="row" class="md-padding">
|
||||
|
||||
<!-- Loading ring -->
|
||||
<div class='uil-ring-css' ng-show="loadingLogs">
|
||||
<div></div>
|
||||
</div>
|
||||
<!-- End loading ring -->
|
||||
|
||||
<div layout="row" ng-show="!loadingLogs">
|
||||
<md-button class="wz-report-refresh-btn" ng-click="refreshLogs()"><i class="fa fa-fw fa-refresh"></i> Refresh</md-button>
|
||||
</div>
|
||||
|
||||
<div layout="row" class="md-padding" ng-show="!loadingLogs">
|
||||
<table class="table table-striped table-condensed" style="table-layout: fixed !important" id="wz_table">
|
||||
<thead class="wz-text-bold">
|
||||
<th class="wz-text-left col-lg-2" >Date</th>
|
||||
@ -15,17 +26,17 @@
|
||||
<tbody>
|
||||
<tr class="wz-word-wrap" ng-repeat="item in logs">
|
||||
<td>
|
||||
{{ item.date }}
|
||||
{{ item.date }}
|
||||
</td>
|
||||
<td>
|
||||
{{ item.level.toUpperCase() }}
|
||||
</td>
|
||||
<td>
|
||||
{{ item.message }}
|
||||
{{ item.level.toUpperCase() }}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{ item.message }}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -35,7 +35,7 @@
|
||||
<md-nav-item class="wz-nav-item" ng-if="apiEntries && apiEntries.length" md-nav-click="switchTab('extensions')" name="extensions">Extensions</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="switchTab('pattern')" name="pattern">Pattern</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="switchTab('configuration')" name="config">Configuration</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="switchTab('logs')" name="logs">Logs</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="switchTab('logs'); refreshLogs()" name="logs">Logs</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="switchTab('about')" name="about">About</md-nav-item>
|
||||
</md-nav-bar>
|
||||
<!-- End navigation bar -->
|
||||
|
Loading…
Reference in New Issue
Block a user