mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 02:15:24 +00:00
Management - "controller as"
This commit is contained in:
parent
498f103a60
commit
2d14195869
@ -20,43 +20,22 @@ class Management {
|
||||
this.$rootScope = $rootScope;
|
||||
this.$routeParams = $routeParams;
|
||||
this.$location = $location;
|
||||
this.$scope.tab = 'welcome';
|
||||
this.$scope.rulesetTab = 'rules';
|
||||
this.$scope.tabNames = TabNames;
|
||||
|
||||
this.$scope.wazuhManagementTabs = ['ruleset', 'groups'];
|
||||
this.$scope.statusReportsTabs = [
|
||||
this.tab = 'welcome';
|
||||
this.rulesetTab = 'rules';
|
||||
this.tabNames = TabNames;
|
||||
this.wazuhManagementTabs = ['ruleset', 'groups'];
|
||||
this.statusReportsTabs = [
|
||||
'status',
|
||||
'logs',
|
||||
'monitoring',
|
||||
'reporting'
|
||||
];
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
if (this.$routeParams.tab) {
|
||||
this.$scope.tab = this.$routeParams.tab;
|
||||
this.tab = this.$routeParams.tab;
|
||||
this.switchTab(this.tab)
|
||||
}
|
||||
|
||||
this.$scope.reloadGroups = () => this.reloadGroups();
|
||||
this.$scope.reloadRuleset = () => this.reloadRuleset();
|
||||
|
||||
this.$scope.inArray = (item, array) => this.inArray(item, array);
|
||||
|
||||
this.$scope.switchTab = tab => this.switchTab(tab);
|
||||
this.$scope.setRulesTab = tab => this.setRulesTab(tab);
|
||||
|
||||
this.$scope.$watch('tab', () => this.watchTab());
|
||||
}
|
||||
|
||||
reloadGroups() {
|
||||
this.$scope.tab = 'groups';
|
||||
this.$scope.$broadcast('groupsIsReloaded');
|
||||
}
|
||||
|
||||
reloadRuleset() {
|
||||
this.$scope.tab = 'ruleset';
|
||||
this.$scope.$broadcast('rulesetIsReloaded');
|
||||
}
|
||||
|
||||
inArray(item, array) {
|
||||
@ -64,23 +43,28 @@ class Management {
|
||||
}
|
||||
|
||||
switchTab(tab) {
|
||||
this.$scope.tab = tab;
|
||||
}
|
||||
|
||||
setRulesTab(tab) {
|
||||
this.$scope.rulesetTab = tab;
|
||||
}
|
||||
|
||||
watchTab() {
|
||||
if (this.$scope.tab === 'ruleset') {
|
||||
this.tab = tab;
|
||||
|
||||
if(this.tab === 'groups') {
|
||||
this.$scope.$broadcast('groupsIsReloaded');
|
||||
}
|
||||
|
||||
if(this.tab === 'ruleset') {
|
||||
this.$scope.$broadcast('rulesetIsReloaded');
|
||||
this.$rootScope.globalRuleSet = 'ruleset';
|
||||
this.$rootScope.globalRulesetTab = this.$scope.rulesetTab;
|
||||
this.$rootScope.globalRulesetTab = this.rulesetTab;
|
||||
} else {
|
||||
delete this.$rootScope.globalRuleSet;
|
||||
delete this.$rootScope.globalRulesetTab;
|
||||
}
|
||||
this.$location.search('tab', this.$scope.tab);
|
||||
|
||||
this.$location.search('tab', this.tab);
|
||||
}
|
||||
|
||||
setRulesTab(tab) {
|
||||
this.rulesetTab = tab;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.controller('managementController', Management);
|
||||
|
@ -27,6 +27,10 @@
|
||||
<i class="fa fa-fw fa-code" aria-hidden="true"></i> Dev tools
|
||||
</md-button>
|
||||
|
||||
<md-button class="wz-menu-button" ng-href="#/wazuh-monitoring" ng-class="{'wz-menu-active': menuNavItem === 'wazuh-monitoring' }" aria-label="Cluster monitoring tab">
|
||||
<i class="fa fa-fw fa-chain-broken" aria-hidden="true"></i> Cluster monitoring
|
||||
</md-button>
|
||||
|
||||
<!-- Fill up the space between left and right area -->
|
||||
<span flex></span>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div flex="auto" layout="column" ng-controller="managementConfigurationController" ng-if="tab === 'configuration'" ng-init="switchConfigurationTab('welcome')">
|
||||
<div flex="auto" layout="column" ng-controller="managementConfigurationController" ng-if="mctrl.tab === 'configuration'" ng-init="switchConfigurationTab('welcome')">
|
||||
|
||||
<!-- Navigation section -->
|
||||
<div layout="row" layout-align="start center">
|
||||
@ -6,17 +6,17 @@
|
||||
<div layout="row" layout-padding>
|
||||
<!-- Welcome section -->
|
||||
<div ng-if="configurationTab === 'welcome'">
|
||||
<span class="wz-text-link cursor-pointer" ng-click="switchTab('welcome')">Management</span>
|
||||
<span class="wz-text-link cursor-pointer" ng-click="mctrl.switchTab('welcome')">Management</span>
|
||||
<span> / </span>
|
||||
<span>{{ tabNames[tab] }}</span>
|
||||
<span>{{ mctrl.tabNames[mctrl.tab] }}</span>
|
||||
</div>
|
||||
<!-- First-level section -->
|
||||
<div ng-if="configurationTab !== 'welcome'">
|
||||
<span class="wz-text-link cursor-pointer" ng-click="switchTab('welcome')">Management</span>
|
||||
<span class="wz-text-link cursor-pointer" ng-click="mctrl.switchTab('welcome')">Management</span>
|
||||
<span> / </span>
|
||||
<span class="wz-text-link cursor-pointer" ng-click="switchConfigurationTab('welcome')">{{ tabNames[tab] }}</span>
|
||||
<span class="wz-text-link cursor-pointer" ng-click="switchConfigurationTab('welcome')">{{ mctrl.tabNames[mctrl.tab] }}</span>
|
||||
<span> / </span>
|
||||
<span>{{ tabNames[configurationTab] }}</span>
|
||||
<span>{{ mctrl.tabNames[configurationTab] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End breadcrumbs -->
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div flex layout="column" class="mozilla-table-size-85" ng-controller="groupsPreviewController" ng-if="tab == 'groups'">
|
||||
<div flex layout="column" class="mozilla-table-size-85" ng-controller="groupsPreviewController" ng-if="mctrl.tab == 'groups'">
|
||||
<md-content flex layout="column" class="overflow-hidden" ng-init="lookingGroup=false">
|
||||
|
||||
<!-- Loading ring -->
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div layout="column" class="mozilla-table-size-85" ng-controller="managerLogController as ctrl" ng-if="!ctrl.loading && tab == 'logs'">
|
||||
<div layout="column" class="mozilla-table-size-85" ng-controller="managerLogController as ctrl" ng-if="!ctrl.loading && mctrl.tab == 'logs'">
|
||||
|
||||
<!-- Headline -->
|
||||
<div ng-show="!ctrl.loading" layout="column" layout-padding>
|
||||
|
@ -1,20 +1,20 @@
|
||||
<div flex="auto" layout="column" ng-cloak ng-controller="managementController">
|
||||
<div flex="auto" layout="column" ng-cloak ng-controller="managementController as mctrl">
|
||||
|
||||
<!-- Top navbar section -->
|
||||
<wz-menu ng-init="menuNavItem = 'manager'"></wz-menu>
|
||||
<!-- End top navbar section -->
|
||||
|
||||
<!-- Navigation section -->
|
||||
<div layout="row" layout-align="start center" ng-if="tab !== 'monitoring' && tab !== 'configuration'">
|
||||
<div layout="row" layout-align="start center" ng-if="mctrl.tab !== 'monitoring' && mctrl.tab !== 'configuration'">
|
||||
<!-- Breadcrumbs -->
|
||||
<div layout="row" layout-padding>
|
||||
<!-- If you're not on the Welcome tab, show a functional breadcrumb -->
|
||||
<div ng-if="tab !== 'welcome'">
|
||||
<span class="wz-text-link cursor-pointer" ng-click="switchTab('welcome')">Management</span>
|
||||
<span> / {{ tabNames[tab] }}</span>
|
||||
<div ng-if="mctrl.tab !== 'welcome'">
|
||||
<span class="wz-text-link cursor-pointer" ng-click="mctrl.switchTab('welcome')">Management</span>
|
||||
<span> / {{ mctrl.tabNames[mctrl.tab] }}</span>
|
||||
</div>
|
||||
<!-- If you're on the Welcome tab, show a blank, simple breadcrumb -->
|
||||
<div ng-if="tab === 'welcome'">
|
||||
<div ng-if="mctrl.tab === 'welcome'">
|
||||
<span>Management / Welcome</span>
|
||||
</div>
|
||||
</div>
|
||||
@ -24,26 +24,25 @@
|
||||
|
||||
<!-- Wazuh management navigation bar -->
|
||||
<md-nav-bar
|
||||
ng-if="!load && inArray(tab, wazuhManagementTabs)"
|
||||
ng-if="!mctrl.load && mctrl.inArray(mctrl.tab, mctrl.wazuhManagementTabs)"
|
||||
class="wz-nav-bar"
|
||||
ng-show="tab !== 'welcome'"
|
||||
md-selected-nav-item="tab"
|
||||
ng-show="mctrl.tab !== 'welcome'"
|
||||
md-selected-nav-item="mctrl.tab"
|
||||
nav-bar-aria-label="Wazuh management navigation links">
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="reloadRuleset()" name="ruleset">Ruleset</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="reloadGroups()" name="groups">Groups</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.switchTab('ruleset')" name="ruleset">Ruleset</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.switchTab('groups')" name="groups">Groups</md-nav-item>
|
||||
</md-nav-bar>
|
||||
<!-- End Wazuh management navigation bar -->
|
||||
|
||||
<!-- Status and reports navigation bar -->
|
||||
<md-nav-bar
|
||||
ng-if="!load && inArray(tab, statusReportsTabs) && tab !== 'monitoring'"
|
||||
ng-if="!mctrl.load && mctrl.inArray(mctrl.tab, mctrl.statusReportsTabs) && mctrl.tab !== 'monitoring'"
|
||||
class="wz-nav-bar"
|
||||
ng-show="tab !== 'welcome'"
|
||||
md-selected-nav-item="tab"
|
||||
ng-show="mctrl.tab !== 'welcome'"
|
||||
md-selected-nav-item="mctrl.tab"
|
||||
nav-bar-aria-label="Status and reports navigation links">
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="switchTab('status')" name="status">Status</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('monitoring')" name="monitoring">Monitoring</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="switchTab('reporting')" name="reporting">Reporting</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.switchTab('status')" name="status">Status</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.switchTab('logs')" name="logs">Logs</md-nav-item>
|
||||
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.switchTab('reporting')" name="reporting">Reporting</md-nav-item>
|
||||
</md-nav-bar>
|
||||
<!-- End Status and reports navigation bar -->
|
||||
|
@ -4,7 +4,6 @@ include ./status.html
|
||||
include ./configuration/configuration.jade
|
||||
include ./logs.html
|
||||
include ./reporting.html
|
||||
include ./monitoring/monitoring.jade
|
||||
include ./groups/groups.html
|
||||
include ./ruleset/ruleset.jade
|
||||
include ../footer.foot
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div layout="column" layout-align="start stretch" ng-controller="reportingController as ctrl" ng-if="tab === 'reporting'">
|
||||
<div layout="column" layout-align="start stretch" ng-controller="reportingController as ctrl" ng-if="mctrl.tab === 'reporting'">
|
||||
|
||||
<!-- Loading ring -->
|
||||
<div class='uil-ring-css' ng-show="ctrl.loading">
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div layout="column" layout-align="start stretch" ng-controller="managerStatusController as ctrl" ng-if="tab === 'status'">
|
||||
<div layout="column" layout-align="start stretch" ng-controller="managerStatusController as ctrl" ng-if="mctrl.tab === 'status'">
|
||||
|
||||
<!-- Loading ring -->
|
||||
<div class='uil-ring-css' ng-show="ctrl.load">
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div layout="column" layout-align="start stretch" ng-if="tab === 'welcome'">
|
||||
<div layout="column" layout-align="start stretch" ng-if="mctrl.tab === 'welcome'">
|
||||
|
||||
<!-- Headline -->
|
||||
<div layout="column" layout-padding>
|
||||
@ -17,17 +17,17 @@
|
||||
<div class="euiFlexGrid euiFlexGrid--gutterLarge euiFlexGrid--halves">
|
||||
<wz-welcome-card
|
||||
class="euiFlexItem" logo="'icons/ruleset.png'" title="'Ruleset'"
|
||||
switch-tab="reloadRuleset()" current-tab="'rules'"
|
||||
switch-tab="mctrl.switchTab('ruleset')" current-tab="'rules'"
|
||||
description="'Explore your Wazuh cluster ruleset.'"
|
||||
></wz-welcome-card>
|
||||
<wz-welcome-card
|
||||
class="euiFlexItem" logo="'icons/groups.png'"
|
||||
title="'Groups'" switch-tab="reloadGroups()" current-tab="'groups'"
|
||||
title="'Groups'" switch-tab="mctrl.switchTab('groups')" current-tab="'groups'"
|
||||
description="'Check your agent groups.'"
|
||||
></wz-welcome-card>
|
||||
<wz-welcome-card
|
||||
class="euiFlexItem" logo="'icons/app_devtools.svg'"
|
||||
title="'Configuration'" switch-tab="switchTab('configuration')" current-tab="'configuration'"
|
||||
title="'Configuration'" switch-tab="mctrl.switchTab('configuration')" current-tab="'configuration'"
|
||||
description="'Check your Wazuh cluster configuration.'"
|
||||
></wz-welcome-card>
|
||||
</div>
|
||||
@ -40,22 +40,17 @@
|
||||
<div class="euiFlexGrid euiFlexGrid--gutterLarge euiFlexGrid--halves">
|
||||
<wz-welcome-card
|
||||
class="euiFlexItem" logo="'icons/app_monitoring.svg'" title="'Status'"
|
||||
switch-tab="switchTab('status')" current-tab="'status'"
|
||||
switch-tab="mctrl.switchTab('status')" current-tab="'status'"
|
||||
description="'Check your Wazuh cluster status.'"
|
||||
></wz-welcome-card>
|
||||
<wz-welcome-card
|
||||
class="euiFlexItem" logo="'icons/app_logging.svg'" title="'Logs'"
|
||||
switch-tab="switchTab('logs')" current-tab="'logs'"
|
||||
switch-tab="mctrl.switchTab('logs')" current-tab="'logs'"
|
||||
description="'Logs from your Wazuh cluster.'"
|
||||
></wz-welcome-card>
|
||||
<wz-welcome-card
|
||||
class="euiFlexItem" logo="'icons/app_index_pattern.svg'" title="'Monitoring'"
|
||||
switch-tab="switchTab('monitoring')" current-tab="'monitoring'"
|
||||
description="'Visualize your Wazuh cluster.'"
|
||||
></wz-welcome-card>
|
||||
<wz-welcome-card
|
||||
class="euiFlexItem" logo="'icons/reporting.png'" title="'Reporting'"
|
||||
switch-tab="switchTab('reporting')" current-tab="'reporting'"
|
||||
switch-tab="mctrl.switchTab('reporting')" current-tab="'reporting'"
|
||||
description="'Check your stored Wazuh reports.'"
|
||||
></wz-welcome-card>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user