Ruleset files moved to rules/decoders section (#1304)

* Rework files tab

* prettier

* Fix style

* Delete listener

* Changes requirement

* Some fixes

* Save custom rules switch state

* Fix typo
This commit is contained in:
Juanka Rodríguez 2019-03-12 17:20:35 +01:00 committed by Jesús Ángel
parent 9bec1f3997
commit 02afbc6875
14 changed files with 185 additions and 279 deletions

View File

@ -83,12 +83,6 @@ export class DecodersController {
if (!this.$scope.$$phase) this.$scope.$digest();
});
this.$scope.$on('showFileNameInput', () => {
this.newFile = true;
this.selectedItem = { file: 'new file' };
this.$scope.$applyAsync();
});
this.$scope.$on('showSaveAndOverwrite', () => {
this.overwriteError = true;
this.$scope.$applyAsync();
@ -306,21 +300,6 @@ export class DecodersController {
if (!this.$scope.$$phase) this.$scope.$digest();
}
addNewFile(type) {
this.editingFile = true;
this.newFile = true;
this.newFileName = '';
this.selectedFileName = this.selectedRulesetTab;
this.selectedItem = { file: 'new file' };
this.fetchedXML = '<!-- Modify it at your will. -->';
this.type = type;
this.cancelSaveAndOverwrite();
if (!this.$scope.$$phase) this.$scope.$digest();
this.$location.search('editingFile', true);
this.appState.setNavigation({ status: true });
this.$scope.$emit('fetchedFile', { data: this.fetchedXML });
}
toggleSaveConfig = () => {
this.doingSaving = false;
this.$scope.$applyAsync();
@ -331,42 +310,17 @@ export class DecodersController {
this.$scope.$applyAsync();
};
doSaveConfig(isNewFile, fileName) {
doSaveConfig() {
const clusterInfo = this.appState.getClusterInfo();
const showRestartManager =
clusterInfo.status === 'enabled' ? 'cluster' : 'manager';
if (isNewFile && !fileName) {
this.errorHandler.handle(
'Error creating a new file. You need to specify a file name',
''
);
return false;
} else {
if (isNewFile) {
const validFileName = /(.+).xml/;
const containsBlanks = /.*[ ].*/;
if (fileName && !validFileName.test(fileName)) {
fileName = fileName + '.xml';
}
if (containsBlanks.test(fileName)) {
this.errorHandler.handle(
'Error creating a new file. The filename can not contain white spaces.',
''
);
return false;
}
this.selectedItem = { file: fileName };
}
this.doingSaving = true;
const objParam = {
decoder: isNewFile ? this.selectedItem : this.currentDecoder,
showRestartManager,
isNewFile: !!isNewFile,
isOverwrite: !!this.overwriteError
};
this.$scope.$broadcast('saveXmlFile', objParam);
}
this.doingSaving = true;
const objParam = {
decoder: this.currentDecoder,
showRestartManager,
isOverwrite: !!this.overwriteError
};
this.$scope.$broadcast('saveXmlFile', objParam);
}
restart = () => {

View File

@ -11,20 +11,28 @@
*/
export class FilesController {
constructor($scope, wazuhConfig, rulesetHandler, errorHandler, appState) {
constructor(
$scope,
wazuhConfig,
rulesetHandler,
errorHandler,
appState,
$location
) {
this.$scope = $scope;
this.wazuhConfig = wazuhConfig;
this.rulesetHandler = rulesetHandler;
this.errorHandler = errorHandler;
this.appState = appState;
this.$location = $location;
this.appliedFilters = [];
this.searchTerm = '';
this.overwriteError = false;
}
$onInit() {
const configuration = this.wazuhConfig.getConfig();
this.adminMode = !!(configuration || {}).admin;
this.filesSubTab = 'rules';
this.$scope.$on('editFile', (ev, params) => {
this.editFile(params);
@ -34,20 +42,53 @@ export class FilesController {
this.$scope.closeEditingFile = () => {
this.$scope.editingFile = false;
this.$scope.fetchedXML = null;
this.search();
this.$scope.$applyAsync();
};
this.$scope.doSaveConfig = () => {
this.$scope.doSaveConfig = (isNewFile, fileName) => {
const clusterInfo = this.appState.getClusterInfo();
const showRestartManager =
clusterInfo.status === 'enabled' ? 'cluster' : 'manager';
this.$scope.doingSaving = true;
const objParam = { showRestartManager };
this.$scope.currentFile.type === 'rule'
? (objParam.rule = this.$scope.currentFile)
: (objParam.decoder = this.$scope.currentFile);
this.$scope.$broadcast('saveXmlFile', objParam);
this.$scope.$applyAsync();
if (isNewFile && !fileName) {
this.errorHandler.handle(
'Error creating a new file. You need to specify a file name',
''
);
return false;
} else {
if (isNewFile) {
const validFileName = /(.+).xml/;
const containsBlanks = /.*[ ].*/;
if (fileName && !validFileName.test(fileName)) {
fileName = fileName + '.xml';
}
if (containsBlanks.test(fileName)) {
this.errorHandler.handle(
'Error creating a new file. The filename can not contain white spaces.',
''
);
return false;
}
this.selectedItem = { file: fileName };
}
this.$scope.doingSaving = true;
const objParam = {
showRestartManager,
isNewFile: !!isNewFile,
isOverwrite: !!this.overwriteError
};
(isNewFile && this.$scope.type === 'rules') ||
(!isNewFile && this.$scope.currentFile.type === 'rule')
? (objParam.rule = isNewFile
? this.selectedItem
: this.$scope.currentFile)
: (objParam.decoder = isNewFile
? this.selectedItem
: this.$scope.currentFile);
this.$scope.$broadcast('saveXmlFile', objParam);
this.$scope.$applyAsync();
}
};
this.$scope.toggleSaveConfig = () => {
@ -60,11 +101,22 @@ export class FilesController {
this.$scope.$applyAsync();
};
this.$scope.cancelSaveAndOverwrite = () => {
this.$scope.overwriteError = false;
this.$scope.$applyAsync();
};
this.$scope.$on('showRestartMsg', () => {
this.$scope.restartMsg = true;
this.$scope.$applyAsync();
});
this.$scope.$on('showFileNameInput', () => {
this.newFile = true;
this.selectedItem = { file: 'new file' };
this.$scope.$applyAsync();
});
this.$scope.restart = () => {
this.$scope.$emit('performRestart', {});
};
@ -72,13 +124,15 @@ export class FilesController {
async editFile(params) {
this.$scope.editingFile = true;
this.$scope.newFile = false;
try {
this.$scope.currentFile = params.file;
this.$scope.currentFile.type = params.path.includes('rules')
? 'rule'
: 'decoder';
this.$scope.type = `${this.$scope.currentFile.type}s`;
this.$scope.fetchedXML =
this.$scope.currentFile.type === 'rule'
this.$scope.type === 'rules'
? await this.rulesetHandler.getRuleConfiguration(
this.$scope.currentFile.file
)
@ -93,6 +147,21 @@ export class FilesController {
}
}
addNewFile(type) {
this.$scope.editingFile = true;
this.$scope.newFile = true;
this.$scope.newFileName = '';
this.$scope.selectedFileName = this.$scope.selectedRulesetTab;
this.$scope.selectedItem = { file: 'new file' };
this.$scope.fetchedXML = '<!-- Modify it at your will. -->';
this.$scope.type = type;
this.$scope.cancelSaveAndOverwrite();
this.$scope.$applyAsync();
this.$location.search('editingFile', true);
this.appState.setNavigation({ status: true });
this.$scope.$emit('fetchedFile', { data: this.$scope.fetchedXML });
}
switchFilesSubTab(tab) {
this.filesSubTab = tab;
}

View File

@ -231,9 +231,14 @@ export class ManagementController {
setRulesTab(tab) {
this.rulesetTab = tab;
this.globalRulesetTab = this.rulesetTab;
this.managingFiles = false;
this.breadCrumbBack();
}
switchFilesSubTab(flag) {
this.managingFiles = flag || true;
}
breadCrumbBack(goRoot = false) {
if (this.currentRule) {
this.$scope.$broadcast('closeRuleView');

View File

@ -25,13 +25,10 @@ export function RulesController(
wazuhConfig,
rulesetHandler
) {
$scope.showingLocalRules = false;
$scope.overwriteError = false;
$scope.switchLocalRules = () =>
($scope.showingLocalRules = !$scope.showingLocalRules);
$scope.isObject = item => typeof item === 'object';
$scope.mctrl = $scope.$parent.$parent.$parent.mctrl;
$scope.mctrl.showingLocalRules = false;
$scope.appliedFilters = [];
/**
* This performs a search with a given term
@ -257,7 +254,6 @@ export function RulesController(
(((ruleReloaded || {}).data || {}).data || {}).items || [];
if (!response.length) {
$scope.currentRule = null;
$scope.showingLocalRules = true;
$scope.closeDetailView(true);
} else {
$scope.currentRule = response[0];
@ -318,21 +314,6 @@ export function RulesController(
);
}
$scope.addNewFile = type => {
$scope.editingFile = true;
$scope.newFile = true;
$scope.newFileName = '';
$scope.selectedFileName = $scope.selectedRulesetTab;
$scope.selectedItem = { file: 'new file' };
$scope.fetchedXML = '<!-- Modify it at your will. -->';
$scope.type = type;
$scope.cancelSaveAndOverwrite();
if (!$scope.$$phase) $scope.$digest();
$location.search('editingFile', true);
appState.setNavigation({ status: true });
$scope.$emit('fetchedFile', { data: $scope.fetchedXML });
};
$scope.toggleSaveConfig = () => {
$scope.doingSaving = false;
$scope.$applyAsync();
@ -348,50 +329,19 @@ export function RulesController(
$scope.$applyAsync();
};
$scope.doSaveConfig = (isNewFile, fileName) => {
$scope.doSaveConfig = () => {
const clusterInfo = appState.getClusterInfo();
const showRestartManager =
clusterInfo.status === 'enabled' ? 'cluster' : 'manager';
if (isNewFile && !fileName) {
errorHandler.handle(
'Error creating a new file. You need to specify a file name',
''
);
return false;
} else {
if (isNewFile) {
const validFileName = /(.+).xml/;
const containsBlanks = /.*[ ].*/;
if (fileName && !validFileName.test(fileName)) {
fileName = fileName + '.xml';
}
if (containsBlanks.test(fileName)) {
errorHandler.handle(
'Error creating a new file. The filename can not contain white spaces.',
''
);
return false;
}
$scope.selectedItem = { file: fileName };
}
$scope.doingSaving = true;
const objParam = {
rule: isNewFile ? $scope.selectedItem : $scope.currentRule,
showRestartManager,
isNewFile: !!isNewFile,
isOverwrite: !!$scope.overwriteError
};
$scope.$broadcast('saveXmlFile', objParam);
}
$scope.doingSaving = true;
const objParam = {
rule: $scope.currentRule,
showRestartManager,
isOverwrite: !!$scope.overwriteError
};
$scope.$broadcast('saveXmlFile', objParam);
};
$scope.$on('showFileNameInput', () => {
$scope.newFile = true;
$scope.selectedItem = { file: 'new file' };
$scope.$applyAsync();
});
$scope.restart = () => {
$scope.$emit('performRestart', {});
};

View File

@ -76,7 +76,7 @@ app.directive('wzTable', function() {
$scope.keys.push(key.key);
}
}
init().then(() => $scope.setColResizable());
init(true).then(() => $scope.setColResizable());
};
$scope.exists = key => {
const str = key.key.value || key.key;

View File

@ -11,20 +11,22 @@
<span class="euiCheckbox__label">{{ keyEquivalence[key.key.value || key.key] }}</span>
</div>
<span flex></span>
<span class="wz-text-link font-size-18" style="line-height: 24px;" ng-click="showColumns = !showColumns" tooltip="Columns"><i
<span class="wz-text-link" style="line-height: 28px;" ng-click="showColumns = !showColumns" tooltip="Columns"><i
class="fa fa-fw fa-gear"></i></span>
</div>
<div ng-show="!error && !wazuh_table_loading && items.length" ng-if="!isPolicyMonitoring() && !isSyscheck()">
<div ng-if="!wazuh_table_loading && !isPolicyMonitoring() && !isSyscheck()" ng-show="!error && items.length">
<table class="table table-striped table-condensed table-hover no-margin-bottom" ng-class="customColumns ? 'table-resizable' : ''"
style="table-layout: fixed !important" id="wz_table">
<thead class="wz-text-bold">
<th ng-repeat="key in keys" class="wz-text-left" ng-class="{ 'cursor-pointer' : !key.nosortable}" ng-click="!key.nosortable && sort(key)"
ng-style="key.width && {'width':key.width}">
{{ path === '/agents/groups' && (key.value || key) === 'count' ? 'Agents' : keyEquivalence[key.value ||
key] || key.value || key }}
<i ng-if="!key.nosortable" class="fa wz-theader-sort-icon" ng-class="sortValue === (key.value || key) ? (sortDir ? 'fa-sort-asc' : 'fa-sort-desc') : 'fa-sort'"
aria-hidden="true"></i>
<th ng-repeat="key in keys" class="wz-text-left" ng-style="key.width && {'width':key.width}">
<span ng-class="{ 'cursor-pointer' : !key.nosortable}" ng-click="!key.nosortable && sort(key)">
{{ path === '/agents/groups' && (key.value || key) === 'count' ? 'Agents' :
keyEquivalence[key.value ||
key] || key.value || key }}
<i ng-if="!key.nosortable" class="fa wz-theader-sort-icon" ng-class="sortValue === (key.value || key) ? (sortDir ? 'fa-sort-asc' : 'fa-sort-desc') : 'fa-sort'"
aria-hidden="true"></i>
</span>
</th>
<th ng-if="(path === '/agents' || (path === '/agents/groups' && adminMode) || (isLookingGroup() && adminMode)
|| path === '/rules/files' || path === '/decoders/files' || path === '/lists/files') && !isLookingDefaultGroup"
@ -139,15 +141,16 @@
</table>
</div>
<div ng-show="!error && !wazuh_table_loading && items.length" ng-if="isPolicyMonitoring()">
<div ng-if="!wazuh_table_loading && isPolicyMonitoring()" ng-show="!error && items.length">
<table class="table table-striped table-striped-duo table-condensed table-hover no-margin-bottom" ng-class="customColumns ? 'table-resizable' : ''"
style="table-layout: fixed !important" id="wz_table">
<thead class="wz-text-bold">
<th ng-repeat="key in keys" class="wz-text-left" ng-class="{ 'cursor-pointer' : !key.nosortable }" ng-style="key.width && {'width':key.width}"
ng-click="!key.nosortable && sort(key)">
{{ keyEquivalence[key.value || key] || key.value || key }}
<i ng-if="!key.nosortable" class="fa wz-theader-sort-icon" ng-class="sortValue === (key.value || key) ? (sortDir ? 'fa-sort-asc' : 'fa-sort-desc') : 'fa-sort'"
aria-hidden="true"></i>
<th ng-repeat="key in keys" class="wz-text-left" ng-style="key.width && {'width':key.width}">
<span ng-class="{ 'cursor-pointer' : !key.nosortable }" ng-click="!key.nosortable && sort(key)">
{{ keyEquivalence[key.value || key] || key.value || key }}
<i ng-if="!key.nosortable" class="fa wz-theader-sort-icon" ng-class="sortValue === (key.value || key) ? (sortDir ? 'fa-sort-asc' : 'fa-sort-desc') : 'fa-sort'"
aria-hidden="true"></i>
</span>
</th>
</thead>
<tbody>
@ -172,7 +175,7 @@
</tr>
<tr ng-if="item.rationale || item.remediation || item.directory || (item.compliance && item.compliance.length)"
class="wz-word-wrap cursor-pointer selected" ng-show="item.expanded" ng-repeat-end="" ng-click="expandTableRow(item)">
<td colspan="3" style="border-top: none">
<td colspan="{{keys.length}}" style="border-top: none">
<div layout="row" layout-padding="" class="layout-padding layout-row">
<md-card flex="" class="wz-md-card wz-padding-top-0 wz-padding-bottom-0 wz-no-margin _md flex">
<md-card-content>
@ -246,15 +249,16 @@
</table>
</div>
<div ng-show="!error && !wazuh_table_loading && items.length" ng-if="isSyscheck()">
<div ng-if="!wazuh_table_loading && isSyscheck()" ng-show="!error && items.length">
<table class="table table-striped table-striped-duo table-condensed table-hover no-margin-bottom" ng-class="customColumns ? 'table-resizable' : ''"
style="table-layout: fixed !important" id="wz_table">
<thead class="wz-text-bold">
<th ng-repeat="key in keys" class="wz-text-left" ng-class="{ 'cursor-pointer' : !key.nosortable }" ng-style="key.width && {'width':key.width}"
ng-click="!key.nosortable && sort(key)">
{{ keyEquivalence[key.value || key] || key.value || key }}
<i ng-if="!key.nosortable" class="fa wz-theader-sort-icon" ng-class="sortValue === (key.value || key) ? (sortDir ? 'fa-sort-asc' : 'fa-sort-desc') : 'fa-sort'"
aria-hidden="true"></i>
<th ng-repeat="key in keys" class="wz-text-left" ng-style="key.width && {'width':key.width}">
<span ng-class="{ 'cursor-pointer' : !key.nosortable }" ng-click="!key.nosortable && sort(key)">{{
keyEquivalence[key.value || key] || key.value || key }}
<i ng-if="!key.nosortable" class="fa wz-theader-sort-icon" ng-class="sortValue === (key.value || key) ? (sortDir ? 'fa-sort-asc' : 'fa-sort-desc') : 'fa-sort'"
aria-hidden="true"></i>
</span>
</th>
</thead>
<tbody>

View File

@ -328,6 +328,7 @@ app.directive('wzXmlFileEditor', function() {
$document[0].getElementById('xml_box'),
{
lineNumbers: true,
lineWrapping: true,
matchClosing: true,
matchBrackets: true,
mode: 'text/xml',

View File

@ -1,8 +1,8 @@
<div ng-if="!loading && !dctrl.viewingDetail" layout="column">
<div id="content" layout="row" layout-align="start start" class="md-padding" ng-if="!dctrl.editingFile">
<input flex placeholder="Filter decoders..." ng-model="dctrl.custom_search" type="text" class="kuiLocalSearchInput height-40 ng-empty ng-pristine ng-scope ng-touched ng-valid"
<div id="content" layout="row" layout-align="start start" class="md-padding" ng-if="!dctrl.editingFile && !mctrl.filesSubTab">
<input flex placeholder="Filter decoders..." ng-model="dctrl.custom_search" type="text" class="kuiLocalSearchInput height-40"
aria-invalid="false" wz-enter="dctrl.search(dctrl.custom_search)">
<button type="submit" aria-label="Search" class="kuiLocalSearchButton height-40 wz-margin-right-8" ng-click="dctrl.search(dctrl.custom_search)">
<button type="submit" aria-label="Search" class="kuiLocalSearchButton height-40" ng-click="dctrl.search(dctrl.custom_search)">
<span class="fa fa-search" aria-hidden="true"></span>
</button>
</div>
@ -22,10 +22,9 @@
</md-chips>
<div layout="row">
<md-card flex class="wz-md-card _md flex md-margin-h" ng-if="!dctrl.editingFile">
<md-card flex class="wz-md-card _md flex md-margin-h" ng-if="!dctrl.editingFile && !mctrl.filesSubTab">
<md-card-actions layout="row" layout-align="end center" class="wz-card-actions wz-card-actions-top">
<a ng-if="adminMode" ng-click="dctrl.addNewFile('decoders')">Add new decoder <i aria-hidden="true"
class="fa fa-plus"></i></a>
<a ng-if="adminMode" ng-click="mctrl.switchFilesSubTab('decoders')">Manage decoders files</a>
<span flex></span>
<wz-kbn-switch class="md-primary wz-no-top-bottom-margin" switch-model="dctrl.showingLocalDecoders"
switch-text="Custom decoders"></wz-kbn-switch>
@ -44,44 +43,4 @@
</md-card-actions>
</md-card>
</div>
<div class="md-padding" ng-if="dctrl.editingFile && dctrl.type === 'decoders'">
<div flex layout="column">
<div layout="row" ng-if="!dctrl.newFile" class="wz-padding-bottom-14">
<span ng-click='dctrl.closeEditingFile()' class='btn btn-info'>Cancel</span>
<button ng-disabled='dctrl.xmlHasErrors || dctrl.doingSaving' ng-click='dctrl.doSaveConfig(false)'
class='btn wz-button pull-right'>
<span ng-show='!dctrl.xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save' ng-class="dctrl.doingSaving ? 'fa-spin fa-spinner' : ''"></i>Save
file</span>
<span ng-show='dctrl.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="dctrl.newFile" class="wz-padding-bottom-14">
<span ng-click='dctrl.closeEditingFile()' class='btn btn-info'>Cancel</span>
<button ng-disabled='dctrl.xmlHasErrors || dctrl.newFileName === "" || dctrl.doingSaving || dctrl.overwriteError'
ng-click='dctrl.doSaveConfig(true,dctrl.newFileName)' class='btn wz-button pull-right wz-margin-left-8'>
<span ng-show='!dctrl.xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save' ng-class="dctrl.doingSaving ? 'fa-spin fa-spinner' : ''"></i>Save
file</span>
<span ng-show='dctrl.xmlHasErrors' class='btn-danger'><i aria-hidden='true' class='fa fa-fw fa-exclamation-triangle'></i>
XML format error</span>
</button>
<input placeholder="Eg: my_local_decoder.xml" ng-model="dctrl.newFileName" ng-change="dctrl.overwriteError = false"
type="text" class="wz-margin-left-8 kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid"
aria-invalid="false">
<div ng-show="dctrl.restartMsg" class="confirmEmbedBubble confirmEmbedBubbleInline">
<span class="wz-padding-top-10 wz-padding-left-8">Configuration is not applied yet. Do you want
to restart <b>{{selectedNode}}</b> to apply it?</span>
<button class="btn cancelBtn btn-info md-padding-h" type="button" ng-click="dctrl.restartMsg = false">I
will do it later</button>
<button class="btn wz-button" type="button" ng-disabled="dctrl.doingSaving" ng-click="dctrl.restart(); dctrl.restartMsg = false">Restart
<b>{{selectedNode}}</b> now</button>
</div>
</div>
<div ng-if="dctrl.fetchedXML" style="height: calc(100vh - 220px);">
<wz-xml-file-editor file-name='{{dctrl.type}}' data="dctrl.fetchedXML" target-name="dctrl.selectedItem.file"
valid-fn='dctrl.xmlIsValid(valid)' saving-param='dctrl.toggleSaveConfig()' close-fn='dctrl.closeEditingFile(reload)'>
</wz-xml-file-editor>
</div>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
<div flex ng-if="!loading && mctrl.globalRulesetTab == 'decoders'" class="" ng-controller="decodersController as dctrl" layout="column" id="rulesContainer" layout-align="start space-around">
<div flex ng-if="!loading && mctrl.globalRulesetTab == 'decoders' && !mctrl.managingFiles" class="" ng-controller="decodersController as dctrl" layout="column" id="rulesContainer" layout-align="start space-around">
<div class='uil-ring-css' ng-show="loading">
<div></div>

View File

@ -1,22 +1,2 @@
<div flex ng-if="!loading && mctrl.globalRulesetTab == 'files'" class="" ng-controller="filesController as filesctrl"
<div flex ng-if="!loading && mctrl.managingFiles" class="" ng-controller="filesController as filesctrl"
layout="column" id="rulesContainer" layout-align="start space-around">
<div ng-show="!editingFile">
<!-- Headline -->
<div layout="column" layout-padding>
<div>
<span class="font-size-18"><i class="fa fa-fw fa-file-o" aria-hidden="true"></i> Files</span>
</div>
<span class="md-subheader">Custom rules and decoders files</span>
</div>
<!-- End headline -->
<!-- Ruleset navigation bar -->
<md-nav-bar
class="wz-nav-bar nav-bar-white-bg "
md-selected-nav-item="filesctrl.filesSubTab"
nav-bar-aria-label="Files navigation links">
<md-nav-item class="wz-nav-item" md-nav-click="filesctrl.switchFilesSubTab('rules')" name="rules">Rules</md-nav-item>
<md-nav-item class="wz-nav-item" md-nav-click="filesctrl.switchFilesSubTab('decoders')" name="decoders">Decoders</md-nav-item>
</md-nav-bar>
<!-- End Ruleset navigation bar -->
</div>

View File

@ -1,5 +1,8 @@
<div ng-if="!files.viewingDetail" ng-show="!editingFile" layout="column">
<div ng-if="!files.viewingDetail" ng-show="!editingFile" layout="column" ng-init="filesctrl.switchFilesSubTab(mctrl.globalRulesetTab)">
<div id="content" layout="row" class="md-padding ">
<md-button class="md-icon-button wz-padding-right-16 btn btn-info" style="border: 1px solid #d9d9d9;border-radius: 5px;margin-left: 0;"
aria-label="Back to list" tooltip="Back" tooltip-placement="bottom" ng-click="mctrl.setRulesTab(filesctrl.filesSubTab)"><i
class="fa fa-fw fa-arrow-left" aria-hidden="true"></i></md-button>
<input flex placeholder="Filter files..." ng-model="filesctrl.custom_search" type="text" class="kuiLocalSearchInput height-40 ng-empty ng-pristine ng-scope ng-touched ng-valid"
aria-invalid="false" wz-enter="filesctrl.search(filesctrl.custom_search)">
<button type="submit" aria-label="Search" class="kuiLocalSearchButton height-40" ng-click="filesctrl.search(filesctrl.custom_search)">
@ -8,6 +11,11 @@
</div>
<div layout="row">
<md-card flex class="wz-md-card _md flex md-margin-h">
<md-card-actions layout="row" layout-align="end center" class="wz-card-actions wz-card-actions-top">
<a ng-if="adminMode" ng-click="filesctrl.addNewFile(mctrl.globalRulesetTab)">Add
new {{mctrl.globalRulesetTab}} file <i aria-hidden="true" class="fa fa-plus"></i></a>
<span flex></span>
</md-card-actions>
<md-card-content>
<wz-table ng-if="filesctrl.filesSubTab === 'rules'" implicit-filter="[{ name:'path',value: 'etc/rules'}]"
flex path="'/rules/files'" keys="[{value: 'file', width: '75px'}]" allow-click="true" row-sizes="[16,13,11]"></wz-table>
@ -17,17 +25,31 @@
</md-card>
</div>
</div>
<div ng-show="editingFile" class="md-padding">
<!-- XML editor for rules -->
<div layout="column" layout-align="start">
<div layout="row">
<span ng-click='closeEditingFile()' class='btn btn-info'>Close</span>
<button ng-disabled='xmlHasErrors || doingSaving' ng-click='doSaveConfig()' class='btn wz-button pull-right wz-margin-left-8'>
<span ng-show='!xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save' ng-class="doingSaving ? 'fa-spin fa-spinner' : ''"></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 class="md-padding" ng-if="editingFile">
<div flex layout="column">
<div layout="row" class="wz-padding-bottom-14">
<div ng-if="!newFile">
<span ng-click='closeEditingFile()' class='btn btn-info'>Cancel</span>
<button ng-disabled='xmlHasErrors || doingSaving' ng-click='doSaveConfig(false)' class='btn wz-button pull-right wz-margin-left-8'>
<span ng-show='!xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save' ng-class="doingSaving ? 'fa-spin fa-spinner' : ''"></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 ng-if="newFile" layout="row" class="wz-width-100">
<span ng-click='closeEditingFile()' class='btn btn-info'>Cancel</span>
<button ng-disabled='xmlHasErrors || newFileName === "" || doingSaving || overwriteError' ng-click='doSaveConfig(true,newFileName)'
class='btn wz-button wz-margin-left-8'>
<span ng-show='!xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save' ng-class="doingSaving ? 'fa-spin fa-spinner' : ''"></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="{{type === 'rules' ? 'Eg: my_local_rule.xml' : 'Eg: my_local_decoder.xml'}}"
ng-model="newFileName" type="text" class="wz-margin-left-8 kuiLocalSearchInput" aria-invalid="false"
ng-change="cancelSaveAndOverwrite()">
</div>
<div ng-show="restartMsg" class="confirmEmbedBubble confirmEmbedBubbleInline">
<span class="wz-padding-top-10 wz-padding-left-8">Configuration is not applied yet. Do you want
to restart to apply it?</span>
@ -37,11 +59,10 @@
now</button>
</div>
</div>
<div class="wz-padding-top-14" ng-if="fetchedXML" style="height: calc(100vh - 220px);">
<wz-xml-file-editor file-name='rules' data="fetchedXML" target-name="currentFile.file" valid-fn='xmlIsValid(valid)'
saving-param='toggleSaveConfig()' close-fn='closeEditingFile(reload)'>
<div ng-if="fetchedXML" style="height: calc(100vh - 220px);">
<wz-xml-file-editor file-name='{{type}}' data="fetchedXML" target-name="newFile ? selectedItem.file : currentFile.file"
valid-fn='xmlIsValid(valid)' saving-param='toggleSaveConfig()' close-fn='closeEditingFile(reload)'>
</wz-xml-file-editor>
</div>
</div>
<!-- XML editor for rules -->
</div>

View File

@ -1,13 +1,13 @@
<div ng-if="!loading && !viewingDetail" layout="column">
<div id="content" layout="row" class="md-padding " ng-if="!editingFile">
<input flex placeholder="Filter rules..." ng-model="custom_search" type="text" class="kuiLocalSearchInput height-40 ng-empty ng-pristine ng-scope ng-touched ng-valid"
<div id="content" layout="row" class="md-padding" ng-if="!mctrl.filesSubTab">
<input flex placeholder="Filter rules..." ng-model="custom_search" type="text" class="kuiLocalSearchInput height-40"
aria-invalid="false" wz-enter="search(custom_search)">
<button type="submit" aria-label="Search" class="kuiLocalSearchButton height-40" ng-click="search(custom_search)">
<span class="fa fa-search" aria-hidden="true"></span>
</button>
</div>
<md-chips class="wz-chips md-padding-h wz-padding-bottom-14" readonly="true" ng-show="appliedFilters.length" ng-if="!editingFile">
<md-chips class="wz-chips md-padding-h wz-padding-bottom-14" readonly="true" ng-show="appliedFilters.length" ng-if="!editingFile && !mctrl.filesSubTab">
<md-chip class="wz-chip" ng-show="includesFilter('file')">
<span>File: {{getFilter('file')}}
<i class="fa fa-fw fa-times cursor-pointer" aria-hidden="true" ng-click="removeFilter('file')"></i>
@ -43,16 +43,18 @@
<div layout="row" ng-if="!editingFile">
<md-card flex class="wz-md-card _md flex md-margin-h">
<md-card-actions layout="row" layout-align="end center" class="wz-card-actions wz-card-actions-top">
<a ng-if="adminMode" ng-click="addNewFile('rules')">Add new rule <i aria-hidden="true" class="fa fa-plus"></i></a>
<a ng-if="adminMode" ng-click="mctrl.switchFilesSubTab('rules')">Manage
rules files</a>
<span flex></span>
<wz-kbn-switch class="md-primary wz-no-top-bottom-margin" switch-model="showingLocalRules" switch-text="Custom rules"></wz-kbn-switch>
<wz-kbn-switch class="md-primary wz-no-top-bottom-margin" switch-model="mctrl.showingLocalRules"
switch-text="Custom rules"></wz-kbn-switch>
</md-card-actions>
<md-card-content class="wz-padding-bottom-0">
<wz-table custom-columns="true" flex ng-if="showingLocalRules" path="'/rules'" keys="[{value: 'id', width: '75px'},{value:'file',size:2},{value:'description',size:2},{value:'groups',nosortable:true,size:2},{value:'pci',nosortable:true,size:2},{value:'gdpr',nosortable:true},{value: 'level', width: '100px'}]"
<wz-table custom-columns="true" flex ng-if="mctrl.showingLocalRules" path="'/rules'" keys="[{value: 'id', width: '75px'},{value:'description',size:2},{value:'groups',nosortable:true,size:2},{value:'pci',nosortable:true,size:2},{value:'gdpr',nosortable:true},{value: 'level', width: '100px'},{value:'file',size:2}]"
implicit-filter="[{ name:'path',value: 'etc/rules'}]" allow-click="true" row-sizes="[16,13,11]">
</wz-table>
<wz-table custom-columns="true" ng-if="!showingLocalRules" implicit-filter="appliedFilters" flex path="'/rules'"
keys="[{value: 'id', width: '75px'},{value:'file',size:2},{value:'description',size:2},{value:'groups',nosortable:true,size:2},{value:'pci',nosortable:true,size:2},{value:'gdpr',nosortable:true}, {value: 'level', width: '100px'}]"
<wz-table custom-columns="true" ng-if="!mctrl.showingLocalRules" implicit-filter="appliedFilters" flex path="'/rules'"
keys="[{value: 'id', width: '75px'},{value:'description',size:2},{value:'groups',nosortable:true,size:2},{value:'pci',nosortable:true,size:2},{value:'gdpr',nosortable:true}, {value: 'level', width: '100px'}, {value:'file',size:2}]"
allow-click="true" row-sizes="[16,13,11]">
</wz-table>
</md-card-content>
@ -62,42 +64,4 @@
</md-card-actions>
</md-card>
</div>
<div class="md-padding" ng-if="editingFile && type === 'rules'">
<div flex layout="column">
<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 || doingSaving' ng-click='doSaveConfig(false)' class='btn wz-button pull-right wz-margin-left-8'>
<span ng-show='!xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save' ng-class="doingSaving ? 'fa-spin fa-spinner' : ''"></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 || newFileName === "" || doingSaving || overwriteError' ng-click='doSaveConfig(true,newFileName)'
class='btn wz-button pull-right wz-margin-left-8'>
<span ng-show='!xmlHasErrors'><i aria-hidden='true' class='fa fa-fw fa-save' ng-class="doingSaving ? 'fa-spin fa-spinner' : ''"></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="Eg: my_local_rule.xml" ng-model="newFileName" type="text" class="wz-margin-left-8 kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid"
aria-invalid="false" ng-change="cancelSaveAndOverwrite()">
<div ng-show="restartMsg" class="confirmEmbedBubble confirmEmbedBubbleInline">
<span class="wz-padding-top-10 wz-padding-left-8">Configuration is not applied yet. Do you want
to restart to apply it?</span>
<button class="btn cancelBtn btn-info md-padding-h" type="button" ng-click="toggleRestartMsg()">I
will do it later</button>
<button class="btn wz-button" type="button" ng-disabled="doingSaving" ng-click="restart(); toggleRestartMsg()">Restart
now</button>
</div>
</div>
<div ng-if="fetchedXML" style="height: calc(100vh - 220px);">
<wz-xml-file-editor file-name='{{type}}' data="fetchedXML" target-name="selectedItem.file" valid-fn='xmlIsValid(valid)'
saving-param='toggleSaveConfig()' close-fn='closeEditingFile(reload)'>
</wz-xml-file-editor>
</div>
</div>
</div>
</div>

View File

@ -1,4 +1,4 @@
<div flex ng-if="!loading && mctrl.globalRuleSet == 'ruleset' && mctrl.globalRulesetTab == 'rules'" class="" ng-controller="rulesController"
<div flex ng-if="!loading && mctrl.globalRuleSet == 'ruleset' && mctrl.globalRulesetTab == 'rules' && !mctrl.managingFiles" class="" ng-controller="rulesController as rctrl"
layout="column" id="rulesContainer" layout-align="start space-around">
<div class='uil-ring-css' ng-show="loading">

View File

@ -11,6 +11,5 @@
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.setRulesTab('rules')" name="rules">Rules</md-nav-item>
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.setRulesTab('decoders')" name="decoders">Decoders</md-nav-item>
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.setRulesTab('cdblists')" name="cdblists">CDB Lists</md-nav-item>
<md-nav-item class="wz-nav-item" md-nav-click="mctrl.setRulesTab('files')" name="files">Files</md-nav-item>
</md-nav-bar>
</div>