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

Switches design and other improvements #1253

Merged
merged 4 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
6 changes: 3 additions & 3 deletions public/controllers/management/decoders.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,13 @@ export class DecodersController {
} else {
if (isNewFile) {
const validFileName = /(.+).xml/;
const containsNumberBlanks = /.*[0-9 ].*/;
const containsBlanks = /.*[ ].*/;
if (fileName && !validFileName.test(fileName)) {
fileName = fileName + '.xml';
}
if (containsNumberBlanks.test(fileName)) {
if (containsBlanks.test(fileName)) {
this.errorHandler.handle(
'Error creating a new file. The filename can not contain numbers or white spaces.',
'Error creating a new file. The filename can not contain white spaces.',
''
);
return false;
Expand Down
6 changes: 4 additions & 2 deletions public/controllers/management/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ export class ManagementController {
breadCrumbBack(goRoot = false) {
if (this.currentRule) {
this.$scope.$broadcast('closeRuleView');
} else if (this.currentDecoder) {
}
if (this.currentDecoder) {
this.$scope.$broadcast('closeDecoderView');
} else if (this.currentList) {
}
if (this.currentList) {
this.$scope.$broadcast('closeListView');
}
if (goRoot) {
Expand Down
6 changes: 3 additions & 3 deletions public/controllers/management/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,13 @@ export function RulesController(
} else {
if (isNewFile) {
const validFileName = /(.+).xml/;
const containsNumberBlanks = /.*[0-9 ].*/;
const containsBlanks = /.*[ ].*/;
if (fileName && !validFileName.test(fileName)) {
fileName = fileName + '.xml';
}
if (containsNumberBlanks.test(fileName)) {
if (containsBlanks.test(fileName)) {
errorHandler.handle(
'Error creating a new file. The filename can not contain numbers or white spaces.',
'Error creating a new file. The filename can not contain white spaces.',
''
);
return false;
Expand Down
1 change: 1 addition & 0 deletions public/directives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ import './wz-xml-file-editor/wz-xml-file-editor.less';
import './wz-multiple-selector/wz-multiple-selector';
import './wz-multiple-selector/wz-multiple-selector.less';
import './wz-list-manage/wz-list-manage';
import './wz-kbn-switch/wz-kbn-switch';
13 changes: 13 additions & 0 deletions public/directives/wz-kbn-switch/wz-kbn-switch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="euiSwitch"><input class="euiSwitch__input" ng-model="switchModel" ng-change="switchChange()" type="checkbox"><span class="euiSwitch__body"><span
class="euiSwitch__thumb"></span><span class="euiSwitch__track"><svg class="euiIcon euiIcon--medium euiSwitch__icon"
focusable="false" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16"
height="16" viewBox="0 0 16 16">
<defs>
<path id="cross-a" d="M7.293 8l-4.147 4.146a.5.5 0 0 0 .708.708L8 8.707l4.146 4.147a.5.5 0 0 0 .708-.708L8.707 8l4.147-4.146a.5.5 0 0 0-.708-.708L8 7.293 3.854 3.146a.5.5 0 1 0-.708.708L7.293 8z"></path>
</defs>
<use fill-rule="nonzero" xlink:href="#cross-a"></use>
</svg><svg class="euiIcon euiIcon--medium euiSwitch__icon euiSwitch__icon--checked" focusable="false" xmlns="http://www.w3.org/2000/svg"
width="16" height="16" viewBox="0 0 16 16">
<path d="M6.5 12a.502.502 0 0 1-.354-.146l-4-4a.502.502 0 0 1 .708-.708L6.5 10.793l6.646-6.647a.502.502 0 0 1 .708.708l-7 7A.502.502 0 0 1 6.5 12"></path>
</svg></span></span>
<label class="euiSwitch__label">{{switchText}}</label></div>
35 changes: 35 additions & 0 deletions public/directives/wz-kbn-switch/wz-kbn-switch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Wazuh app - Top nav bar directive
* Copyright (C) 2015-2019 Wazuh, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/

import template from './wz-kbn-switch.html';
import { uiModules } from 'ui/modules';

const app = uiModules.get('app/wazuh', []);

class WzKbnSwitch {
/**
* Class constructor
*/
constructor() {
this.restrict = 'E';
this.scope = {
switchModel: '=switchModel',
switchChange: '&',
switchText: '@switchText'
};
this.template = template;
}

controller() { }
}

app.directive('wzKbnSwitch', () => new WzKbnSwitch());
15 changes: 6 additions & 9 deletions public/directives/wz-table/wz-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@
<tbody>
<tr ng-class="allowClick ? 'cursor-pointer' : ''" class="wz-word-wrap" ng-repeat="item in pagedItems[currentPage] | filter:{item:'!'}"
ng-click="clickAction(item)">
<td ng-repeat="key in keys">
{{
parseValue(key,item) | limitTo: extraLimit ? 100 : 25
}}
<span ng-if="parseValue(key,item).length > (extraLimit ? 100 : 25)">...</span>
<md-tooltip ng-if="parseValue(key,item).length > (extraLimit ? 100 : 25)" md-direction="bottom"
class="wz-tooltip">
{{ parseValue(key,item) }}
</md-tooltip>
<td ng-repeat="key in keys" class="wz-text-truncatable">
<span tooltip="{{ parseValue(key,item) }}" tooltip-placement="bottom">
{{
parseValue(key,item)
}}
</span>
</td>
<td ng-if="path === '/agents'" ng-click="$event.stopPropagation()" class="cursor-default action-btn-td">
<i ng-click="clickAction(item, 'discover'); $event.stopPropagation()" class="fa fa-fw fa-compass cursor-pointer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
<md-card-actions layout="row" layout-align="end center" class="wz-card-actions wz-card-actions-top">
<a ng-click="dctrl.addNewFile('decoders')">Add new decoder <i aria-hidden="true" class="fa fa-plus"></i></a>
<span flex></span>
<md-switch class="wz-switch" ng-model="dctrl.showingLocalDecoders" class="md-primary wz-no-top-bottom-margin">
Only custom
</md-switch>
<wz-kbn-switch class="md-primary wz-no-top-bottom-margin" switch-model="dctrl.showingLocalDecoders"
switch-text="Only custom"></wz-kbn-switch>
</md-card-actions>
<md-card-content>
<wz-table ng-if="!dctrl.showingLocalDecoders" implicit-filter="dctrl.appliedFilters" flex path="'/decoders'"
Expand Down
14 changes: 7 additions & 7 deletions public/templates/management/ruleset/rules/rules-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@
<md-card-actions layout="row" layout-align="end center" class="wz-card-actions wz-card-actions-top">
<a ng-click="addNewFile('rules')">Add new rule <i aria-hidden="true" class="fa fa-plus"></i></a>
<span flex></span>
<md-switch class="wz-switch" ng-model="showingLocalRules" ng-change="switchLocalRules()" class="md-primary wz-no-top-bottom-margin">
Only custom
</md-switch>
<wz-kbn-switch class="md-primary wz-no-top-bottom-margin" switch-model="showingLocalRules" switch-text="Only custom"></wz-kbn-switch>
</md-card-actions>
<md-card-content>
<wz-table flex ng-if="showingLocalRules" path="'/rules'" keys="['id',{value:'file',size:2},{value:'description',size:2},{value:'groups',nosortable:true,size:2},{value:'pci',nosortable:true,size:2},{value:'gdpr',nosortable:true},'level']"
Expand Down Expand Up @@ -75,18 +73,20 @@
</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 === ""' ng-click='doSaveConfig(true,newFileName)' class='btn wz-button pull-right wz-margin-left-8'>
<button ng-disabled='xmlHasErrors || newFileName === ""' 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'></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-show="selectedItem.file === 'new file'" ng-model="newFileName" type="text" class="wz-margin-left-8 kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid"
<input placeholder="Eg: my_local_rule.xml" ng-show="selectedItem.file === 'new file'" ng-model="newFileName"
type="text" class="wz-margin-left-8 kuiLocalSearchInput ng-empty ng-pristine ng-scope ng-touched ng-valid"
aria-invalid="false">
</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)' close-fn='closeEditingFile(reload)'>
<wz-xml-file-editor file-name='{{type}}' data="fetchedXML" target-name="selectedItem.file" valid-fn='xmlIsValid(valid)'
close-fn='closeEditingFile(reload)'>
</wz-xml-file-editor>
</div>
</div>
Expand Down
Loading