mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 02:15:24 +00:00
Optimized overview welcome screen - 1
This commit is contained in:
parent
092803d428
commit
4b793857d2
@ -118,14 +118,6 @@ app.controller('overviewController', function(
|
||||
preserveDiscover = false
|
||||
) => {
|
||||
try {
|
||||
if (
|
||||
$scope.tab &&
|
||||
$scope.tab === 'welcome' &&
|
||||
typeof $scope.agentsCountTotal === 'undefined'
|
||||
) {
|
||||
await getSummary();
|
||||
}
|
||||
|
||||
if ($scope.tabView === subtab && !force) return;
|
||||
|
||||
visFactoryService.clear();
|
||||
@ -146,12 +138,11 @@ app.controller('overviewController', function(
|
||||
}
|
||||
|
||||
checkMetrics($scope.tab, subtab);
|
||||
|
||||
return;
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Overview');
|
||||
return;
|
||||
}
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
return;
|
||||
};
|
||||
|
||||
let wodlesConfiguration;
|
||||
@ -198,7 +189,24 @@ app.controller('overviewController', function(
|
||||
};
|
||||
|
||||
// Switch tab
|
||||
$scope.switchTab = (tab, force = false) => {
|
||||
$scope.switchTab = async (tab, force = false) => {
|
||||
try {
|
||||
if (tab !== 'welcome') {
|
||||
await fetchWodles();
|
||||
}
|
||||
if (tab === 'welcome' && typeof $scope.agentsCountTotal === 'undefined') {
|
||||
await getSummary();
|
||||
}
|
||||
if (tab === 'pci') {
|
||||
const pciTabs = await commonData.getPCI();
|
||||
$scope.pciTabs = pciTabs;
|
||||
$scope.selectedPciIndex = 0;
|
||||
}
|
||||
if (tab === 'gdpr') {
|
||||
const gdprTabs = await commonData.getGDPR();
|
||||
$scope.gdprTabs = gdprTabs;
|
||||
$scope.selectedGdprIndex = 0;
|
||||
}
|
||||
filterWodle(tab);
|
||||
if (tab !== 'welcome') tabHistory.push(tab);
|
||||
if (tabHistory.length > 2) tabHistory = tabHistory.slice(-2);
|
||||
@ -210,30 +218,16 @@ app.controller('overviewController', function(
|
||||
tabHistory.length === 2 && tabHistory[0] === tabHistory[1];
|
||||
$scope.tab = tab;
|
||||
|
||||
$scope.switchSubtab('panels', true, sameTab, preserveDiscover);
|
||||
await $scope.switchSubtab('panels', true, sameTab, preserveDiscover);
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Overview');
|
||||
}
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
return;
|
||||
};
|
||||
|
||||
$scope.startVis2Png = () => reportingService.startVis2Png($scope.tab);
|
||||
|
||||
// PCI and GDPR requirements
|
||||
const loadPciAndGDPR = async () => {
|
||||
try {
|
||||
const data = await Promise.all([
|
||||
commonData.getPCI(),
|
||||
commonData.getGDPR()
|
||||
]);
|
||||
const [pciTabs, gdprTabs] = data;
|
||||
$scope.pciTabs = pciTabs;
|
||||
$scope.selectedPciIndex = 0;
|
||||
$scope.gdprTabs = gdprTabs;
|
||||
$scope.selectedGdprIndex = 0;
|
||||
|
||||
return;
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
};
|
||||
|
||||
const getSummary = async () => {
|
||||
try {
|
||||
const data = await apiReq.request('GET', '/agents/summary', {});
|
||||
@ -270,19 +264,13 @@ app.controller('overviewController', function(
|
||||
|
||||
const init = async () => {
|
||||
try {
|
||||
await Promise.all([loadPciAndGDPR(), loadConfiguration(), fetchWodles()]);
|
||||
|
||||
$scope.switchTab($scope.tab, true);
|
||||
|
||||
await getSummary();
|
||||
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
|
||||
return;
|
||||
await loadConfiguration();
|
||||
await $scope.switchTab($scope.tab, true);
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Overview (init)');
|
||||
return;
|
||||
}
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
return;
|
||||
};
|
||||
|
||||
init();
|
||||
|
Loading…
Reference in New Issue
Block a user