From 03ee2658b40686ba03e5552d7f6d66304dd0e6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanka=20Rodr=C3=ADguez?= Date: Wed, 13 Mar 2019 17:56:54 +0100 Subject: [PATCH 1/2] Show no results in logs (#1310) --- public/controllers/management/logs.js | 17 +- .../wz-config-viewer/wz-config-viewer.js | 14 +- public/templates/management/logs.html | 189 +++++++++--------- 3 files changed, 118 insertions(+), 102 deletions(-) diff --git a/public/controllers/management/logs.js b/public/controllers/management/logs.js index ccd5527f4..ecaed096c 100644 --- a/public/controllers/management/logs.js +++ b/public/controllers/management/logs.js @@ -41,12 +41,13 @@ export class LogsController { this.initialize(); this.$scope.$on('wazuhFetched', (ev, parameters) => { - this.$scope.XMLContent = this.parseLogsToText(parameters.items); + this.$scope.XMLContent = this.parseLogsToText(parameters.items) || ''; this.$scope.$broadcast('XMLContentReady', { data: this.$scope.XMLContent }); this.$scope.$applyAsync(); + this.$scope.$broadcast('doRefresh', { type: 'xml' }); }); this.$scope.$on('scrolledToBottom', (ev, parameters) => { @@ -60,11 +61,11 @@ export class LogsController { parseLogsToText(logs) { let result = ''; - logs.forEach(function(log, idx) { + logs.forEach(function (log, idx) { if (log) { result = result.concat( `${log.timestamp} ${log.tag} ${(log.level || '').toUpperCase()}: ${ - log.description + log.description }` ); if (idx !== logs.length - 1) { @@ -194,10 +195,10 @@ export class LogsController { const data = clusterEnabled ? await this.apiReq.request( - 'GET', - `/cluster/${this.selectedNode}/logs/summary`, - {} - ) + 'GET', + `/cluster/${this.selectedNode}/logs/summary`, + {} + ) : await this.apiReq.request('GET', '/manager/logs/summary', {}); const daemons = data.data.data; this.daemons = Object.keys(daemons).map(item => ({ title: item })); @@ -208,4 +209,4 @@ export class LogsController { } return; } -} +} \ No newline at end of file diff --git a/public/directives/wz-config-viewer/wz-config-viewer.js b/public/directives/wz-config-viewer/wz-config-viewer.js index c1340a089..b605a6795 100644 --- a/public/directives/wz-config-viewer/wz-config-viewer.js +++ b/public/directives/wz-config-viewer/wz-config-viewer.js @@ -77,7 +77,7 @@ class WzConfigViewer { setTimeout(function() { $scope.jsonCodeBox.refresh(); $scope.$applyAsync(); - }, 100); + }, 200); } }; @@ -91,7 +91,7 @@ class WzConfigViewer { setTimeout(function() { $scope.xmlCodeBox.refresh(); $scope.$applyAsync(); - }, 100); + }, 200); } }; @@ -128,7 +128,15 @@ class WzConfigViewer { $scope.xmlCodeBox.getScrollerElement().offsetHeight / 2; $scope.xmlCodeBox.scrollTo(null, t - middleHeight - 10); }); + + $scope.$on('doRefresh', (ev, params) => { + if (params.type === 'xml') { + $scope.xmlCodeBox.refresh(); + } else { + $scope.jsonCodeBox.refresh(); + } + }); } } -app.directive('wzConfigViewer', () => new WzConfigViewer()); +app.directive('wzConfigViewer', () => new WzConfigViewer()); \ No newline at end of file diff --git a/public/templates/management/logs.html b/public/templates/management/logs.html index e790616a7..1b045ea8a 100644 --- a/public/templates/management/logs.html +++ b/public/templates/management/logs.html @@ -1,97 +1,104 @@ -
+
- -
- Logs - Review the logs of all Wazuh manager daemons -
- - - -
- -
- + +
+ Logs + Review the logs of all Wazuh manager daemons
- - - -
- + + + +
+ +
+ +
+ + + +
+ +
+ +
+ +
+ +
+ + +
+ + + + + + + + + Play realtime + + + + Stop realtime +
- -
- - + + +
+ +
- -
- + + +
+
- - - - - - - - Play realtime - - - - Stop realtime - -
- - -
- - -
- - -
- -
-
-
- +
+
+ +
+ + + Formatted + +
- - - Formatted - - -
- - -
\ No newline at end of file + + +
+
+
+ + No results match your search criteria +
+
+
+ +
\ No newline at end of file From 03ebb9059cc57da3029847c67aa7c92f3c335f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20=C3=81ngel?= Date: Wed, 13 Mar 2019 18:06:07 +0100 Subject: [PATCH 2/2] Fix timezone for reporting (#1311) * Get browser timezone for reporting * Removed ID from table visualization (reporting) * Format shown dates with the incoming browser timezone * Updated CHANGELOG * Yarn prettier --- CHANGELOG.md | 1 + public/services/reporting.js | 8 ++- .../templates/overview/overview-general.html | 3 +- server/controllers/wazuh-reporting.js | 51 ++++++++++++------- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aeda007ec..ff2f27e42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Adapted Wazuh icon for multiple browsers where it was gone ([#1208](https://github.com/wazuh/wazuh-kibana-app/pull/1208)). - Do not fetch data from tables twice when resize window ([#1303](https://github.com/wazuh/wazuh-kibana-app/pull/1303)). - Agent syncrhonization status is updated as we browse the configuration section ([#1305](https://github.com/wazuh/wazuh-kibana-app/pull/1305)) +- Using the browser timezone for reporting documents ([#1311](https://github.com/wazuh/wazuh-kibana-app/pull/1311)). ## Wazuh v3.8.2 - Kibana v6.6.0 / v6.6.1 - Revision 419 diff --git a/public/services/reporting.js b/public/services/reporting.js index 4a195b0db..62b0e3230 100644 --- a/public/services/reporting.js +++ b/public/services/reporting.js @@ -11,6 +11,7 @@ */ import $ from 'jquery'; +import moment from 'moment'; export class ReportingService { constructor( @@ -55,7 +56,9 @@ export class ReportingService { const array = await this.vis2png.checkArray(idArray); const name = `wazuh-${ isAgents ? 'agents' : 'overview' - }-${tab}-${(Date.now() / 1000) | 0}.pdf`; + }-${tab}-${(Date.now() / 1000) | 0}.pdf`; + + const browserTimezone = moment.tz.guess(true); const data = { array, @@ -67,7 +70,8 @@ export class ReportingService { tables: appliedFilters.tables, tab, section: isAgents ? 'agents' : 'overview', - isAgents + isAgents, + browserTimezone }; await this.genericReq.request('POST', '/reports', data); diff --git a/public/templates/overview/overview-general.html b/public/templates/overview/overview-general.html index 6a8105923..3aabf1835 100644 --- a/public/templates/overview/overview-general.html +++ b/public/templates/overview/overview-general.html @@ -127,8 +127,7 @@
- +
diff --git a/server/controllers/wazuh-reporting.js b/server/controllers/wazuh-reporting.js index 0ece91fb3..acabb254a 100644 --- a/server/controllers/wazuh-reporting.js +++ b/server/controllers/wazuh-reporting.js @@ -134,7 +134,7 @@ export class WazuhReportingCtrl { return { columns: [ { - text: 'Copyright © 2018 Wazuh, Inc.', + text: 'Copyright © 2019 Wazuh, Inc.', color: '#1EA5C8', margin: [40, 40, 0, 0] }, @@ -236,14 +236,37 @@ export class WazuhReportingCtrl { } } + /** + * Format Date to string YYYY-mm-ddTHH:mm:ss + * @param {*} date JavaScript Date + */ + formatDate(date) { + const year = date.getFullYear(); + const month = date.getMonth() + 1; + const day = date.getDate(); + const hours = date.getHours(); + const minutes = date.getMinutes(); + const seconds = date.getSeconds(); + const str = `${year}-${month < 10 ? '0' + month : month}-${ + day < 10 ? '0' + day : day + }T${hours < 10 ? '0' + hours : hours}:${ + minutes < 10 ? '0' + minutes : minutes + }:${seconds < 10 ? '0' + seconds : seconds}`; + return str; + } + /** * This performs the rendering of given time range and filters * @param {Number} from Timestamp (ms) from * @param {Number} to Timestamp (ms) to * @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability */ - renderTimeRangeAndFilters(from, to, filters) { - const str = `${from} to ${to}`; + renderTimeRangeAndFilters(from, to, filters, timeZone) { + const fromDate = new Date( + new Date(from).toLocaleString('en-US', { timeZone }) + ); + const toDate = new Date(new Date(to).toLocaleString('en-US', { timeZone })); + const str = `${this.formatDate(fromDate)} to ${this.formatDate(toDate)}`; this.dd.content.push({ fontSize: 8, @@ -1370,20 +1393,14 @@ export class WazuhReportingCtrl { } if (req.payload && req.payload.array) { - const name = req.payload.name; - const tab = req.payload.tab; - const section = req.payload.section; - const apiId = req.headers && req.headers.id ? req.headers.id : false; - const pattern = - req.headers && req.headers.pattern ? req.headers.pattern : false; + const payload = (req || {}).payload || {}; + const headers = (req || {}).headers || {}; + const { name, tab, section, isAgents, browserTimezone } = payload; + const apiId = headers.id || false; + const pattern = headers.pattern || false; + const from = (payload.time || {}).from || false; + const to = (payload.time || {}).to || false; const kfilters = req.payload.filters; - const isAgents = req.payload.isAgents; - const from = - req.payload.time && req.payload.time.from - ? req.payload.time.from - : false; - const to = - req.payload.time && req.payload.time.to ? req.payload.time.to : false; if (!tab) throw new Error( @@ -1582,7 +1599,7 @@ export class WazuhReportingCtrl { } if (!isSycollector && req.payload.time && filters) { - this.renderTimeRangeAndFilters(from, to, filters); + this.renderTimeRangeAndFilters(from, to, filters, browserTimezone); } if (req.payload.time || isSycollector) {