mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 18:05:20 +00:00
Create new rules and decoders option
This commit is contained in:
parent
1a68c4de7d
commit
429a285de9
@ -46,6 +46,7 @@ export class ConfigurationRulesetController {
|
||||
|
||||
this.$scope.editConfig = async () => {
|
||||
this.$scope.editingFile = true;
|
||||
this.$scope.newFile = false;
|
||||
try {
|
||||
this.$scope.fetchedXML = this.$scope.selectedRulesetTab === 'rules' ?
|
||||
await this.rulesetHandler.getRuleConfiguration(this.$scope.selectedItem.file) :
|
||||
@ -59,6 +60,7 @@ export class ConfigurationRulesetController {
|
||||
}
|
||||
this.$scope.closeEditingFile = () => {
|
||||
this.$scope.editingFile = false;
|
||||
this.$scope.newFile = false;
|
||||
this.$scope.fetchedXML = null;
|
||||
this.$scope.$broadcast('closeEditXmlFile', {});
|
||||
};
|
||||
@ -66,9 +68,42 @@ export class ConfigurationRulesetController {
|
||||
this.$scope.xmlHasErrors = valid;
|
||||
if (!this.$scope.$$phase) this.$scope.$digest();
|
||||
};
|
||||
this.$scope.doSaveConfig = () => {
|
||||
this.$scope.editingFile = false;
|
||||
this.$scope.$broadcast('saveXmlFile', { rule: this.$scope.selectedItem });
|
||||
|
||||
this.$scope.doSaveConfig = (isNewFile,fileName) => {
|
||||
if(isNewFile && !fileName){
|
||||
this.errorHandler.handle('You need to specify a file name','Error creating a new file.');
|
||||
}else{
|
||||
this.$scope.editingFile = false;
|
||||
if(isNewFile){
|
||||
const validFileName = /(.+).xml/;
|
||||
if (fileName && !validFileName.test(fileName)) {
|
||||
fileName = fileName + '.xml'
|
||||
}
|
||||
this.$scope.selectedItem = {file:fileName}
|
||||
if(this.$scope.type === 'rules'){
|
||||
this.$scope.$broadcast('saveXmlFile', { rule: this.$scope.selectedItem });
|
||||
}else if(this.$scope.type === 'decoders'){
|
||||
this.$scope.$broadcast('saveXmlFile', { decoder: this.$scope.selectedItem });
|
||||
}
|
||||
}else{
|
||||
const objParam = this.$scope.selectedRulesetTab === 'rules' ? { rule: this.$scope.selectedItem } : { decoder: this.$scope.selectedItem };
|
||||
this.$scope.$broadcast('saveXmlFile', objParam);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
this.$scope.addNewFile = (type) => {
|
||||
this.$scope.editingFile = true;
|
||||
this.$scope.newFile = true;
|
||||
this.$scope.newFileName = '';
|
||||
this.$scope.fetchedXML = '<!-- Modify it at your will. -->';
|
||||
this.$scope.type = type;
|
||||
if (!this.$scope.$$phase) this.$scope.$digest();
|
||||
this.$scope.$broadcast('fetchedFile', { data: this.$scope.fetchedXML });
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,7 @@
|
||||
<wz-table flex path="'/rules'" keys="['file']" implicit-filter="[{ name:'path',value: '/var/ossec/etc/rules'}]"
|
||||
allow-click="true" row-sizes="[17,15,13]">
|
||||
</md-card-content>
|
||||
<button class="btn btn-primary" ng-click="addNewFile('rules');">New file</button>
|
||||
</md-card>
|
||||
</wz-table>
|
||||
</div>
|
||||
@ -34,6 +35,7 @@
|
||||
<wz-table flex path="'/decoders'" keys="['file']" implicit-filter="[{ name:'path',value: '/var/ossec/etc/decoders'}]"
|
||||
allow-click="true" row-sizes="[17,15,13]">
|
||||
</md-card-content>
|
||||
<button class="btn btn-primary" ng-click="addNewFile('decoders');">New file</button>
|
||||
</md-card>
|
||||
</wz-table>
|
||||
</div>
|
||||
@ -42,18 +44,27 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- <select ng-disabled="!selectData" class="wz-input-text wz-width-100" ng-model="selectedItem" ng-change="" ng-options="o as o for o in selectData"></select> -->
|
||||
|
||||
<!-- XML editor for node configuration -->
|
||||
<div class="md-padding" ng-show="editingFile">
|
||||
<div flex layout="column">
|
||||
<div layout="row" class="wz-padding-bottom-14">
|
||||
<div layout="row" ng-if="!newFile" class="wz-padding-bottom-14">
|
||||
<span ng-click='closeEditingFile()' class='btn btn-info'>Cancel</span>
|
||||
<button ng-disabled='xmlHasErrors' ng-click='doSaveConfig()' class='btn btn-primary pull-right wz-margin-left-8'>
|
||||
<button ng-disabled='xmlHasErrors' ng-click='doSaveConfig(false)' class='btn btn-primary pull-right wz-margin-left-8'>
|
||||
<span ng-show='!xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save'></i>Save file</span>
|
||||
<span ng-show='xmlHasErrors' class='btn-danger'><i aria-hidden='true' class='fa fa-fw fa-exclamation-triangle'></i>
|
||||
XML format error</span>
|
||||
</button>
|
||||
</div>
|
||||
<div layout="row" ng-if="newFile" class="wz-padding-bottom-14">
|
||||
<span ng-click='closeEditingFile()' class='btn btn-info'>Cancel</span>
|
||||
<button ng-disabled='xmlHasErrors' ng-click='doSaveConfig(true,newFileName)' class='btn btn-primary pull-right wz-margin-left-8'>
|
||||
<span ng-show='!xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save'></i>Save file</span>
|
||||
<span ng-show='xmlHasErrors' class='btn-danger'><i aria-hidden='true' class='fa fa-fw fa-exclamation-triangle'></i>
|
||||
XML format error</span>
|
||||
</button>
|
||||
<input placeholder="Enter file name" ng-model="newFileName" type="text" class="kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid"
|
||||
aria-invalid="false">
|
||||
</div>
|
||||
<div ng-if="fetchedXML">
|
||||
<wz-xml-file-editor file-name='{{selectedFileName}}' data="fetchedXML" target-name="selectedItem.file" valid-fn='xmlIsValid(valid)'>
|
||||
</wz-xml-file-editor>
|
||||
|
Loading…
Reference in New Issue
Block a user