Optimized overview welcome screen - 1

This commit is contained in:
Jesús Ángel 2018-10-28 10:30:19 +01:00
parent 092803d428
commit 4b793857d2

View File

@ -118,14 +118,6 @@ app.controller('overviewController', function(
preserveDiscover = false preserveDiscover = false
) => { ) => {
try { try {
if (
$scope.tab &&
$scope.tab === 'welcome' &&
typeof $scope.agentsCountTotal === 'undefined'
) {
await getSummary();
}
if ($scope.tabView === subtab && !force) return; if ($scope.tabView === subtab && !force) return;
visFactoryService.clear(); visFactoryService.clear();
@ -146,12 +138,11 @@ app.controller('overviewController', function(
} }
checkMetrics($scope.tab, subtab); checkMetrics($scope.tab, subtab);
return;
} catch (error) { } catch (error) {
errorHandler.handle(error, 'Overview'); errorHandler.handle(error, 'Overview');
return;
} }
if (!$scope.$$phase) $scope.$digest();
return;
}; };
let wodlesConfiguration; let wodlesConfiguration;
@ -198,42 +189,45 @@ app.controller('overviewController', function(
}; };
// Switch tab // Switch tab
$scope.switchTab = (tab, force = false) => { $scope.switchTab = async (tab, force = false) => {
filterWodle(tab); try {
if (tab !== 'welcome') tabHistory.push(tab); if (tab !== 'welcome') {
if (tabHistory.length > 2) tabHistory = tabHistory.slice(-2); await fetchWodles();
tabVisualizations.setTab(tab); }
if ($scope.tab === tab && !force) return; if (tab === 'welcome' && typeof $scope.agentsCountTotal === 'undefined') {
const sameTab = $scope.tab === tab; await getSummary();
$location.search('tab', tab); }
const preserveDiscover = if (tab === 'pci') {
tabHistory.length === 2 && tabHistory[0] === tabHistory[1]; const pciTabs = await commonData.getPCI();
$scope.tab = tab; $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);
tabVisualizations.setTab(tab);
if ($scope.tab === tab && !force) return;
const sameTab = $scope.tab === tab;
$location.search('tab', tab);
const preserveDiscover =
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); $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 () => { const getSummary = async () => {
try { try {
const data = await apiReq.request('GET', '/agents/summary', {}); const data = await apiReq.request('GET', '/agents/summary', {});
@ -270,19 +264,13 @@ app.controller('overviewController', function(
const init = async () => { const init = async () => {
try { try {
await Promise.all([loadPciAndGDPR(), loadConfiguration(), fetchWodles()]); await loadConfiguration();
await $scope.switchTab($scope.tab, true);
$scope.switchTab($scope.tab, true);
await getSummary();
if (!$scope.$$phase) $scope.$digest();
return;
} catch (error) { } catch (error) {
errorHandler.handle(error, 'Overview (init)'); errorHandler.handle(error, 'Overview (init)');
return;
} }
if (!$scope.$$phase) $scope.$digest();
return;
}; };
init(); init();