diff --git a/lib/main/server/controllers/logController.js b/lib/main/server/controllers/logController.js
index 055cda0..fae6f16 100644
--- a/lib/main/server/controllers/logController.js
+++ b/lib/main/server/controllers/logController.js
@@ -4,11 +4,20 @@ const { getStorageConnection } = require('../storageConnection');
exports.getLogs = async (req, res) => {
try {
const query = req.query || {};
+ let searchTerms;
+ if (query.search_terms) {
+ searchTerms = query.search_terms.split(',');
+ }
if (query.levels) {
query.levels = query.levels.split(',').map(item => item.trim());
}
const storageConnection = getStorageConnection();
- const logs = await storageConnection.getLogs(query);
+ let logs = {};
+ if (searchTerms) {
+ logs = await storageConnection.searchLogs(searchTerms, query);
+ } else {
+ logs = await storageConnection.getLogs(query);
+ }
if (logs && logs.items) {
res.send(Jsonapi.Serializer.serialize(Jsonapi.UserType, logs.items));
} else {
diff --git a/lib/main/server/index.js b/lib/main/server/index.js
index ec7bfc6..7aa3783 100644
--- a/lib/main/server/index.js
+++ b/lib/main/server/index.js
@@ -1,4 +1,5 @@
const express = require('express');
+const expressStaticGzip = require('express-static-gzip');
const path = require('path');
const apiRoutes = require('./routes/apiRoutes');
const { initializeStorageConnection } = require('./storageConnection');
@@ -19,7 +20,7 @@ app.addPath = function (options) {
if (!filePath.endsWith('/')) {
filePath += '/';
}
- app.use(filePath + 'dist', express.static(path.join(__dirname, '..', '..', 'web', 'dist')));
+ app.use(filePath + 'dist', expressStaticGzip(path.join(__dirname, '..', '..', 'web', 'dist')));
app.use(filePath + 'assets', express.static(path.join(__dirname, '..', '..', 'web', 'assets')));
};
diff --git a/lib/web/assets/css/app.css b/lib/web/assets/css/app.css
index 09d8c7b..c24aa36 100644
--- a/lib/web/assets/css/app.css
+++ b/lib/web/assets/css/app.css
@@ -273,4 +273,61 @@ body {
background: #f0eded;
padding: 10px 20px;
border-radius: 2px;
+}
+
+.filter-div {
+ padding: 10px !important;
+ margin-bottom: 20px !important;
+}
+
+.filter-tags-div {
+ margin-left: 22px;
+ padding-left: 10px 10px 10px 0px !important;
+}
+
+.filter-tags {
+ font-size: 13px !important;
+}
+
+.filter-logs .ant-select-selection__placeholder {
+ display: block !important;
+}
+
+.filter-input-div {
+ width: calc(100% - 535px);
+}
+
+.filter-input {
+ width: 100%;
+}
+
+.filter-input .ant-select-selection__choice {
+ background-color: #108ee9 !important;
+ color: #ffffff !important;
+}
+
+.filter-input .ant-select-selection__choice__remove {
+ color: #ffffff !important;
+}
+
+.search-div {
+ padding: 10px !important;
+}
+
+.search-logs-dropdown {
+ display: none !important;
+}
+
+.search-input {
+ margin: 0px 10px !important;
+ width: 90% !important;
+}
+
+.search-input .ant-select-selection__choice {
+ background-color: #108ee9 !important;
+ color: #ffffff !important;
+}
+
+.search-input .ant-select-selection__choice__remove {
+ color: #ffffff !important;
}
\ No newline at end of file
diff --git a/lib/web/src/components/ConsoleLogs.js b/lib/web/src/components/ConsoleLogs.js
index 6f5e5ff..c6793bb 100644
--- a/lib/web/src/components/ConsoleLogs.js
+++ b/lib/web/src/components/ConsoleLogs.js
@@ -17,7 +17,7 @@ const cookies = new Cookies();
const { Content } = Layout;
const { Panel } = Collapse;
-const { Option } = Select;
+const { Option, OptGroup } = Select;
/* mapStateToProps */
const mapStateToProps = (state) => ({
@@ -36,10 +36,11 @@ class ConsoleLogs extends React.Component {
this.state = {
currentConsoleLogs: [],
consoleLogLoading: false,
- logsType: 'errorsLog',
+ logsType: ['console.errorLogs'],
searchDate: null,
searchTime: null,
selectedDatetime: null,
+ searchTerms: [],
timezone
};
}
@@ -76,42 +77,47 @@ class ConsoleLogs extends React.Component {
query.gt_id = queryRequest.logId;
}
}
-
this.getCurrentConsoleLogs(query, logsType);
}
getCurrentConsoleLogs (query, logsType) {
const self = this;
- if (logsType === 'errorsLog' || logsType === 'combinedLogs') {
- this.setState({
- consoleLogLoading: true
- });
- if (logsType === 'errorsLog') query.levels = 'error';
- if (logsType === 'combinedLogs') query.levels = 'error,info';
- this.props.consoleLogActions.getConsoleLogs(query, function (err, data) {
- if (!err) {
- try {
- let logs = data.data || [];
- if (logs.length === 0) {
- self.notificationMsg('info', 'No logs to load');
- } else {
- logs = self.sortLogs(logs);
- self.setState({
- currentConsoleLogs: logs
- });
- }
- } catch (e) {
- console.error(e);
- self.notificationMsg();
+ const searchTerms = this.state.searchTerms || [];
+ this.setState({
+ consoleLogLoading: true
+ });
+ if (logsType.length > 0) {
+ query.levels = [];
+ if (logsType.includes('console.errorLogs')) query.levels.push('error');
+ if (logsType.includes('console.infoLogs')) query.levels.push('info');
+ query.levels = query.levels.join(',');
+ }
+ if (searchTerms.length > 0) {
+ query.search_terms = searchTerms.join(',');
+ }
+ this.props.consoleLogActions.getConsoleLogs(query, function (err, data) {
+ if (!err) {
+ try {
+ let logs = data.data || [];
+ if (logs.length === 0) {
+ self.notificationMsg('info', 'No logs to load');
+ } else {
+ logs = self.sortLogs(logs);
+ self.setState({
+ currentConsoleLogs: logs
+ });
}
- } else {
+ } catch (e) {
+ console.error(e);
self.notificationMsg();
}
- self.setState({
- consoleLogLoading: false
- });
+ } else {
+ self.notificationMsg();
+ }
+ self.setState({
+ consoleLogLoading: false
});
- }
+ });
}
notificationMsg (type = 'info', message = 'Something went wrong. Please report the issue using the Help & Support section', description = '') {
@@ -123,12 +129,28 @@ class ConsoleLogs extends React.Component {
});
}
- changeLogsFilter (value) {
+ updateLogsFilter (item) {
+ let logsType = [];
+ logsType = logsType.concat(item);
+ this.setState({
+ logsType
+ });
+ }
+
+ removeFilterTags (value) {
+ let logsType = this.state.logsType || [];
+ logsType = logsType.filter(type => type !== value);
+ this.setState({
+ logsType
+ });
+ }
+
+ updateSearchTerms (terms) {
+ let searchTerms = [];
+ searchTerms = searchTerms.concat(terms);
this.setState({
- logsType: value,
- currentConsoleLogs: []
+ searchTerms
});
- this.getConsoleLogs({ logsType: value });
}
loadMoreErrors (logOrder) {
@@ -238,6 +260,9 @@ class ConsoleLogs extends React.Component {
isTimeEmpty = true;
}
if (isDateEmpty && isTimeEmpty) {
+ this.setState({
+ currentConsoleLogs: []
+ });
this.getConsoleLogs(null);
} else if (this.isValidDateFormat(searchDate) && this.isValidTimeFormat(searchTime)) {
this.setSelectedDatetime(searchDate, searchTime);
@@ -248,10 +273,12 @@ class ConsoleLogs extends React.Component {
reset () {
this.setState({
+ logsType: [],
selectedDatetime: null,
searchDate: null,
searchTime: null,
- currentConsoleLogs: []
+ currentConsoleLogs: [],
+ searchTerms: []
});
const currentTime = new Date().toISOString();
this.getConsoleLogs({ datetime: currentTime, logOrder: 'old' });
@@ -319,7 +346,7 @@ class ConsoleLogs extends React.Component {
}
render () {
- const logsType = this.state.logsType;
+ const logsType = this.state.logsType || [];
const consoleLogLoading = this.state.consoleLogLoading || false;
const searchDate = this.state.searchDate;
const searchTime = this.state.searchTime;
@@ -329,8 +356,8 @@ class ConsoleLogs extends React.Component {
const combinedLogsModalStatus = this.state.combinedLogsModalStatus || false;
const errorLogTimestamp = this.state.errorLogTimestamp || null;
const errorLogId = this.state.errorLogId || null;
-
const antIcon = {message}