Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes on editing cluster configuration #564

Merged
merged 3 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,62 +302,22 @@ define(['../module'], function (module) {

// Manager - Configuration
.state('mg-conf', {
abstract: true,
templateUrl:
BASE_URL +
'static/app/SplunkAppForWazuh/js/controllers/management/configuration/breadcrumbs/breadcrumbs-mg.html',
onEnter: $navigationService => {
$navigationService.storeRoute('mg-conf')
},
controller: 'navTabCtrl',
resolve: {
isAdmin: [
'$currentDataService',
async $currentDataService => {
try {
const id = $currentDataService.getApi().id
const extensions = await $currentDataService.getExtensionsById(
id
)
return extensions['admin'] === 'true'
} catch (error) {
return false
}
}
],
clusterEnabled: [
'$requestService',
async $requestService => {
try {
const result = await $requestService.apiReq('/cluster/status')
const clusterStatus = result.data.data.enabled === 'yes' ? true : false
return clusterStatus
} catch (error) {
return false
}
}
]
}
})

// Manager - Configuration - Overview
.state('mg-conf.overview', {
templateUrl:
BASE_URL +
'static/app/SplunkAppForWazuh/js/controllers/management/configuration/both-configuration.html',
onEnter: $navigationService => {
$navigationService.storeRoute('mg-conf.overview')
$navigationService.storeRoute('mg-conf')
},
controller: 'configurationCtrl'
})

// Manager - Configuration - EditConfig
.state('mg-conf.editConfig', {
// Manager - EditConfig
.state('mg-editConfig', {
templateUrl:
BASE_URL +
'static/app/SplunkAppForWazuh/js/controllers/management/edition/edition.html',
onEnter: $navigationService => {
$navigationService.storeRoute('mg-conf.editConfig')
$navigationService.storeRoute('mg-editConfig')
},
controller: 'editionCtrl',
resolve: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ define(['../../module', '../../../utils/config-handler'], function(
$onInit() {
this.$scope.showingInfo = false
this.$scope.showInfo = () => this.showInfo()
this.$scope.breadCrumbs = true
this.$scope.goToEdition = false
this.$scope.agent =
this.agent && this.agent.data && this.agent.data.data
? this.agent.data.data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
<div layout="column" layout-align="start stretch">
<div ng-show="breadCrumbs">
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/breadcrumbs/breadcrumbs.html'"></ng-include>
</div>
<div>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/welcome/welcome.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/global-configuration/global-configuration.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/cluster/cluster.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/registration-service/registration-service.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/alerts/alerts.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/integrations/integrations.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/policy-monitoring/policy-monitoring.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/open-scap/open-scap.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/cis-cat/cis-cat.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/vulnerabilities/vulnerabilities.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/syscollector/syscollector.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/active-response/active-response.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/wazuh-commands/wazuh-commands.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/integrity-monitoring/integrity-monitoring.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/agentless/agentless.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/amazon-s3/amazon-s3.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/client/client.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/log-collection/log-collection.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/osquery/osquery.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/ruleset/ruleset.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/client-buffer/client-buffer.html'"></ng-include>
<div>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/breadcrumbs/breadcrumbs.html'"></ng-include>
<div ng-show="goToEdition" ng-click="switchToEdition()" layout="row" layout-align="start center" class="layout-align-start-center layout-row">
<button style="margin-left: 15px; margin-bottom: 10px;" ui-sref="mg-editConfig" class="btn btn-primary pull-right ng-scope">
<span aria-hidden="false"><i aria-hidden="true" class="fa fa-fw fa-pencil"></i>
Edit configuration
</span>
</button>
</div>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/welcome/welcome.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/global-configuration/global-configuration.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/cluster/cluster.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/registration-service/registration-service.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/alerts/alerts.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/integrations/integrations.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/policy-monitoring/policy-monitoring.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/open-scap/open-scap.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/cis-cat/cis-cat.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/vulnerabilities/vulnerabilities.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/syscollector/syscollector.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/active-response/active-response.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/wazuh-commands/wazuh-commands.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/integrity-monitoring/integrity-monitoring.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/agentless/agentless.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/amazon-s3/amazon-s3.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/client/client.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/log-collection/log-collection.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/osquery/osquery.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/ruleset/ruleset.html'"></ng-include>
<ng-include src="'/static/app/SplunkAppForWazuh/js/controllers/management/configuration/client-buffer/client-buffer.html'"></ng-include>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ define(['../../module', '../../../utils/config-handler'], function(
}

$onInit() {
this.$scope.goToEdition = true
this.$scope.showingInfo = false
this.$scope.showInfo = () => this.showInfo()
this.$scope.breadCrumbs = false
this.$scope.getXML = () => this.configurationHandler.getXML(this.$scope)
this.$scope.getJSON = () => this.configurationHandler.getJSON(this.$scope)
this.$scope.isString = item => typeof item === 'string'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
aria-hidden="true"></i>
<md-tooltip md-direction="bottom" class="wz-tooltip">Close file</md-tooltip>
</button>
<button style="height: 30px;" ng-if="isAdmin" ng-click="switchToEdition()" ui-sref="mg-conf.overview" class='btn btn-info wz-margin-left-10'>Cancel</button>
<button style="height: 30px;" ng-if="isAdmin" ng-click="switchToEdition()" ui-sref="mg-conf" class='btn btn-info wz-margin-left-10'>Cancel</button>
<button style="height: 30px;" ng-if="isAdmin" ng-disabled='xmlHasErrors' ng-click='saveOssecConfig()' class='btn btn-primary pull-right wz-margin-left-10'>
<span ng-show='!xmlHasErrors && isAdmin'><i aria-hidden='true' class='fa fa-fw fa-save wz-margin-left-10'></i>Save
file</span>
Expand Down Expand Up @@ -50,7 +50,7 @@


</div>
<div class="md-padding md-padding-top-10" ng-if="fetchedXML" style="height: calc(100vh - 315px)">
<div class="md-padding md-padding-top-10" ng-if="fetchedXML" style="height: calc(100vh - 260px)">
<wz-xml-file-editor style="height: inherit;" file-name='ossec.conf' data="fetchedXML" target-name="editingNode" valid-fn='xmlIsValid(valid)'>
</wz-xml-file-editor>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,29 @@ define(['../../module'], function (controllers) {
* @param {Array} clusterInfo
* @param {Boolean} isAdmin
*/
constructor($scope, isAdmin, $notificationService, clusterInfo, $fileEditor) {
constructor($scope, isAdmin, $notificationService, clusterInfo, $fileEditor, $restartService) {
this.scope = $scope
this.clusterInfo = clusterInfo
this.isAdmin = isAdmin
this.toast = $notificationService.showSimpleToast
this.clusterInfo = clusterInfo
this.fileEditor = $fileEditor
this.restartService = $restartService
}
/**
* On controller loads
*/
$onInit() {
try {
this.scope.restartInProgress = false
this.scope.editingConfig = true //Hides edit config button from parent abstract state
this.scope.editingNode = false
this.scope.editNode = (nodeName) => this.editNode(nodeName)
this.scope.cancelEditNode = () => this.cancelEditNode()
this.scope.saveOssecConfig = () => this.saveOssecConfig()
this.scope.xmlIsValid = (valid) => this.xmlIsValid(valid)
this.scope.changeNode = (node) => this.changeNode(node)
this.scope.restart = (node) => this.restart(node)

if (this.clusterInfo && this.clusterInfo.clusterEnabled) {
this.scope.clusterEnabled = this.clusterInfo.clusterEnabled
Expand Down Expand Up @@ -77,6 +80,23 @@ define(['../../module'], function (controllers) {
if (!this.scope.$$phase) this.scope.$digest()
}

async restart(node = false) {
try {
this.scope.restartInProgress = true
let result = ''
if (this.clusterInfo.clusterEnabled && node) {
result = await this.restartService.restartNode(node)
} else {
result = await this.restartService.restart()
}
this.toast(result)
this.scope.restartInProgress = false
} catch (error) {
this.toast(error)
this.scope.restartInProgress = false
}
}

}

controllers.controller('editionCtrl', Edition)
Expand Down
Loading