Skip to content

Commit

Permalink
Fixes after overall review (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanka Rodríguez authored and Jesús Ángel committed Apr 15, 2019
1 parent ec28b8b commit 7bb0b46
Show file tree
Hide file tree
Showing 24 changed files with 14,970 additions and 1,267 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
public/utils/codemirror/
public/kibana-integrations/
public/utils/table-col-resizable.js
public/utils/jquery-ui.js
130 changes: 65 additions & 65 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
{
"name": "wazuh",
"version": "3.9.0",
"revision": "0429",
"code": "0429-0",
"kibana": {
"version": "6.7.1"
},
"description": "Wazuh app",
"main": "index.js",
"keywords": [
"kibana",
"wazuh",
"ossec"
],
"node_build": "8.14.0",
"author": "Wazuh, Inc",
"license": "GPL-2.0",
"repository": {
"type": "git",
"url": "https://github.com/wazuh/wazuh-kibana-app.git"
},
"bugs": {
"url": "https://github.com/wazuh/wazuh-kibana-app/issues"
},
"homepage": "https://www.wazuh.com/",
"scripts": {
"pretty": "prettier --single-quote \"{,!(node_modules)/**/}*.js\" --write",
"tslint": "tslint -c .tslint.yml server/**/*.ts server/**/*.tsx public/**/*.ts public/**/*.tsx",
"lint": "eslint . --ext .js -c .eslintrc.json --color",
"prebuild": "tsc; find . -name \"*.ts*\" -type f -not -path \"./node_modules/*\" -delete",
"build": "plugin-helpers build",
"test": "_mocha test/**/*"
},
"dependencies": {
"angular-animate": "1.6.5",
"angular-chart.js": "^1.1.1",
"angular-cookies": "1.6.5",
"angular-material": "1.1.10",
"dom-to-image": "^2.6.0",
"install": "^0.10.1",
"js2xmlparser": "^3.0.0",
"json2csv": "^4.1.2",
"needle": "^2.0.1",
"node-cron": "^1.1.2",
"pdfmake": "^0.1.37",
"pug-loader": "^2.4.0",
"querystring-browser": "1.0.4",
"simple-tail": "^1.1.0",
"timsort": "^0.3.0",
"winston": "3.0.0"
},
"devDependencies": {
"@elastic/plugin-helpers": "^7.1.8",
"babel-eslint": "^8.2.6",
"chai": "^4.1.2",
"eslint": "^5.10.0",
"eslint-plugin-async-await": "^0.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"mocha": "^5.2.0",
"prettier": "^1.14.2",
"tslint": "^5.11.0",
"typescript": "^3.0.1",
"typescript-eslint-parser": "^18.0.0"
}
"name": "wazuh",
"version": "3.9.0",
"revision": "0429",
"code": "0429-0",
"kibana": {
"version": "6.7.1"
},
"description": "Wazuh app",
"main": "index.js",
"keywords": [
"kibana",
"wazuh",
"ossec"
],
"node_build": "8.14.0",
"author": "Wazuh, Inc",
"license": "GPL-2.0",
"repository": {
"type": "git",
"url": "https://github.com/wazuh/wazuh-kibana-app.git"
},
"bugs": {
"url": "https://github.com/wazuh/wazuh-kibana-app/issues"
},
"homepage": "https://www.wazuh.com/",
"scripts": {
"pretty": "prettier --single-quote \"{,!(node_modules)/**/}*.js\" --write",
"tslint": "tslint -c .tslint.yml server/**/*.ts server/**/*.tsx public/**/*.ts public/**/*.tsx",
"lint": "eslint . --ext .js -c .eslintrc.json --color",
"prebuild": "tsc; find . -name \"*.ts*\" -type f -not -path \"./node_modules/*\" -delete",
"build": "plugin-helpers build",
"test": "_mocha test/**/*"
},
"dependencies": {
"angular-animate": "1.6.5",
"angular-chart.js": "^1.1.1",
"angular-cookies": "1.6.5",
"angular-material": "1.1.10",
"dom-to-image": "^2.6.0",
"install": "^0.10.1",
"js2xmlparser": "^3.0.0",
"json2csv": "^4.1.2",
"needle": "^2.0.1",
"node-cron": "^1.1.2",
"pdfmake": "^0.1.37",
"pug-loader": "^2.4.0",
"querystring-browser": "1.0.4",
"simple-tail": "^1.1.0",
"timsort": "^0.3.0",
"winston": "3.0.0"
},
"devDependencies": {
"@elastic/plugin-helpers": "^7.1.8",
"babel-eslint": "^8.2.6",
"chai": "^4.1.2",
"eslint": "^5.10.0",
"eslint-plugin-async-await": "^0.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"mocha": "^5.2.0",
"prettier": "^1.14.2",
"tslint": "^5.11.0",
"typescript": "^3.0.1",
"typescript-eslint-parser": "^18.0.0"
}
}
2 changes: 1 addition & 1 deletion public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ import './utils/fontawesome/css/font-awesome.min.css';
// Dev tools
import './utils/codemirror';

import './utils/table-col-resizable';
import './utils/jquery-ui';

// Material
import 'angular-material/angular-material.css';
Expand Down
21 changes: 15 additions & 6 deletions public/controllers/management/decoders.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,28 @@ export class DecodersController {
return this.$sce.trustAsHtml(coloredString);
}

switchLocalDecoders() {
this.removeFilter('path');
if (!this.showingLocalDecoders) {
this.appliedFilters.push({ name: 'path', value: 'etc/decoders' });
}
}

/**
* This perfoms a search by a given term
* @param {String} term
*/
search(term) {
if (term && term.startsWith('path:') && term.split('path:')[1].trim()) {
this.custom_search = '';
const filter = { name: 'path', value: term.split('path:')[1].trim() };
this.appliedFilters = this.appliedFilters.filter(
item => item.name !== 'path'
);
this.appliedFilters.push(filter);
this.$scope.$broadcast('wazuhFilter', { filter });
if (!this.showingLocalDecoders) {
const filter = { name: 'path', value: term.split('path:')[1].trim() };
this.appliedFilters = this.appliedFilters.filter(
item => item.name !== 'path'
);
this.appliedFilters.push(filter);
this.$scope.$broadcast('wazuhFilter', { filter });
}
} else if (
term &&
term.startsWith('file:') &&
Expand Down
48 changes: 37 additions & 11 deletions public/controllers/management/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function RulesController(
* This performs a search with a given term
*/
$scope.search = term => {
let clearInput = true;
if (term && term.startsWith('group:') && term.split('group:')[1].trim()) {
$scope.custom_search = '';
const filter = { name: 'group', value: term.split('group:')[1].trim() };
Expand Down Expand Up @@ -97,15 +98,23 @@ export function RulesController(
term.split('path:')[1].trim()
) {
$scope.custom_search = '';
const filter = { name: 'path', value: term.split('path:')[1].trim() };
$scope.appliedFilters = $scope.appliedFilters.filter(
item => item.name !== 'path'
);
$scope.appliedFilters.push(filter);
$scope.$broadcast('wazuhFilter', { filter });
if (!$scope.mctrl.showingLocalRules) {
const filter = { name: 'path', value: term.split('path:')[1].trim() };
$scope.appliedFilters = $scope.appliedFilters.filter(
item => item.name !== 'path'
);
$scope.appliedFilters.push(filter);
$scope.$broadcast('wazuhFilter', { filter });
}
} else {
clearInput = false;
$scope.$broadcast('wazuhSearch', { term, removeFilters: 0 });
}
if (clearInput) {
const searchBar = $('#search-input-rules');
searchBar.val('');
}
$scope.$applyAsync();
};

/**
Expand All @@ -126,6 +135,13 @@ export function RulesController(
return filtered.length ? filtered[0].value : '';
};

$scope.switchLocalRules = () => {
$scope.removeFilter('path');
if (!$scope.mctrl.showingLocalRules) {
$scope.appliedFilters.push({ name: 'path', value: 'etc/rules' });
}
};

/**
* This a the filter given its name
* @param {String} filterName
Expand Down Expand Up @@ -253,16 +269,19 @@ export function RulesController(
);
const response =
(((ruleReloaded || {}).data || {}).data || {}).items || [];
if (!response.length) {
$scope.currentRule = null;
$scope.closeDetailView(true);
if (response.length) {
const result = response.filter(rule => rule.details.overwrite);
$scope.currentRule = result.length ? result[0] : response[0];
} else {
$scope.currentRule = response[0];
$scope.currentRule = false;
$scope.closeDetailView(true);
}
$scope.fetchedXML = false;
} catch (error) {
errorHandler.handle(error.message || error);
}
}

$scope.editingFile = false;
$scope.$applyAsync();
appState.setNavigation({ status: true });
Expand All @@ -279,6 +298,7 @@ export function RulesController(
* This function changes to the rules list view
*/
$scope.closeDetailView = clear => {
$scope.mctrl.showingLocalRules = !$scope.mctrl.showingLocalRules;
if (clear)
$scope.appliedFilters = $scope.appliedFilters.slice(
0,
Expand All @@ -288,6 +308,8 @@ export function RulesController(
$scope.currentRule = false;
$scope.closeEditingFile();
$scope.$emit('removeCurrentRule');
$scope.switchLocalRules();
$scope.mctrl.showingLocalRules = !$scope.mctrl.showingLocalRules;
$scope.$applyAsync();
};

Expand All @@ -297,7 +319,11 @@ export function RulesController(
apiReq
.request('get', `/rules/${incomingRule}`, {})
.then(data => {
$scope.currentRule = data.data.data.items[0];
const response = (((data || {}).data || {}).data || {}).items || [];
if (response.length) {
const result = response.filter(rule => rule.details.overwrite);
$scope.currentRule = result.length ? result[0] : response[0];
}
$scope.$emit('setCurrentRule', { currentRule: $scope.currentRule });
if (
!(Object.keys(($scope.currentRule || {}).details || {}) || []).length
Expand Down
8 changes: 3 additions & 5 deletions public/controllers/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@ export class SettingsController {
*/
async removeManager(item) {
try {
const currentApi = this.appState.getCurrentAPI();
let index = this.apiEntries.indexOf(item);
if (this.appState.getCurrentAPI()) {
if (
this.apiEntries[index]._id ===
JSON.parse(this.appState.getCurrentAPI()).id
) {
if (currentApi) {
if (this.apiEntries[index]._id === JSON.parse(currentApi).id) {
// We are trying to remove the one selected as default
this.appState.removeCurrentAPI();
}
Expand Down
2 changes: 1 addition & 1 deletion public/directives/wz-data-table/wz-data-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<tfoot>
<td colspan="{{keys.length}}">
<span ng-show="!wazuh_table_loading" class="color-grey">{{ totalItems }} items</span>
<div ng-show="items.length >= itemsPerPage" class="pagination pull-right" style="margin:0 !important">
<div ng-show="items.length > itemsPerPage" class="pagination pull-right" style="margin:0 !important">
<ul layout="row">
<li ng-show="currentPage" class="md-padding">
<a href ng-click="prevPage()">« Prev</a>
Expand Down
16 changes: 9 additions & 7 deletions public/directives/wz-list-manage/wz-list-manage.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<tfoot>
<td colspan="3">
<span ng-show="!wazuh_table_loading" class="color-grey">{{ totalItems }} items</span>
<div ng-show="items.length >= itemsPerPage" class="pagination pull-right"
<div ng-show="items.length > itemsPerPage" class="pagination pull-right"
style="margin:0 !important">
<ul layout="row">
<li ng-show="currentPage > 0" class="md-padding">
Expand Down Expand Up @@ -133,12 +133,14 @@
</tfoot>
</table>
</md-card-content>
<md-card-actions layout="row" layout-align="end center"
class="wz-card-actions layout-align-end-center layout-row">
<a class="wz-text-link cursor-pointer small md-button md-ink-ripple" id="btnDownload"
ng-click="downloadCsv('/lists', currentList.name, currentList.path)">
<react-component name="EuiIcon" props="{type:'importAction', color:'primary'}" /> Formatted
</a>
<md-card-actions layout="row" layout-align="end center" class="layout-align-end-center layout-row">
<button type="button" ng-click="downloadCsv('/lists', currentList.name, currentList.path)"
class="euiButtonEmpty euiButtonEmpty--primary euiButtonEmpty--small" id="btnDownload">
<span class="euiButtonEmpty__content">
<react-component name="EuiIcon" props="{type:'importAction'}" />
<span class="euiButtonEmpty__text">Formatted</span>
</span>
</button>
</md-card-actions>
</md-card>
</div>
Expand Down
18 changes: 11 additions & 7 deletions public/directives/wz-table/wz-table-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ app.directive('wzTable', function() {
// Prevents duplicated rows when resizing
let resizing = false;
$window.onresize = () => {
if (resizing) return;
$(`#table${$scope.scapepath}`).colResizable({ disable: true });
if (resizing || $scope.resizingColumns) return;
resizing = true;
clearTimeout(doit);
doit = setTimeout(() => {
$scope.rowsPerPage = calcTableRows($window.innerHeight, rowSizes);
$scope.itemsPerPage = $scope.rowsPerPage;
init(true)
.then(() => {
$scope.setColResizable();
resizing = false;
})
.catch(() => (resizing = false));
Expand Down Expand Up @@ -501,11 +501,15 @@ app.directive('wzTable', function() {
};

$scope.setColResizable = () => {
$(`#table${$scope.scapepath}`).colResizable({
liveDrag: true,
minWidth: 78,
partialRefresh: true,
draggingClass: false
$(`#table${$scope.scapepath} th`).resizable({
handles: 'e',
minWidth: 75,
start: () => {
$scope.resizingColumns = true;
},
end: () => {
$scope.resizingColumns = false;
}
});
$scope.$applyAsync();
};
Expand Down
Loading

0 comments on commit 7bb0b46

Please sign in to comment.