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 = ; + const searchTerms = this.state.searchTerms || []; const renderConsoleLogs = () => { return currentConsoleLogs.map((log) => { @@ -348,7 +375,7 @@ class ConsoleLogs extends React.Component { } let panel; - if (logsType === 'errorsLog') { + if (logsType.length === 1 && logsType[0] === 'console.errorLogs') { panel =
{message}
; } else { panel =
{message}
; @@ -357,15 +384,23 @@ class ConsoleLogs extends React.Component { return panel; }); }; + return (
-
-
- +
+
+
+
+
@@ -380,12 +415,16 @@ class ConsoleLogs extends React.Component {
-
- Timezone -
-

0 ? 'down' : 'right'} />TimestampMessage

+
+

0 ? 'down' : 'right'} />Timestamp + Message +

+ Timezone +
+ +

{currentConsoleLogs.length !== 0 &&

There maybe older logs to load. Load More

diff --git a/lib/web/src/components/Sidebar.js b/lib/web/src/components/Sidebar.js index 07083e2..73c735d 100644 --- a/lib/web/src/components/Sidebar.js +++ b/lib/web/src/components/Sidebar.js @@ -104,7 +104,7 @@ class Sidebar extends React.Component { msg1 =

A new version of the {updates.name} and {updates.storage_name} modules have been released. Currently, you are using {updates.name} v{updates.version} and {storageUpdates.name} v{updates.storage_version}

; install = npm install {updates.name}@{updates.latest_version} {updates.storage_name}@{updates.storage_latest_version}; } else if (errsoleUpdates.updateNeeded) { - msg1 =

A new version of the {updates.name} module has been released. Currently, you are using {updates.name} v {updates.version}

; + msg1 =

A new version of the {updates.name} module has been released. Currently, you are using {updates.name} v{updates.version}

; install = npm install {updates.name}@{updates.latest_version}; } else if (storageUpdates.updateNeeded) { msg1 =

A new version of the {storageUpdates.name} module has been released. Currently, you are using {updates.storage_name} v{updates.storage_version}

; diff --git a/lib/web/webpack/website.config.js b/lib/web/webpack/website.config.js index a996d77..3988a97 100644 --- a/lib/web/webpack/website.config.js +++ b/lib/web/webpack/website.config.js @@ -7,7 +7,7 @@ const TerserPlugin = require('terser-webpack-plugin'); const bundleConfig = require('./bundle.config.js'); /* params */ -const mode = 'development'; +const mode = 'production'; const websiteOutput = merge(bundleConfig, { mode, diff --git a/package.json b/package.json index 3dc4190..0522e16 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "axios": "^1.6.8", "body-parser": "^1.20.2", "express": "^4.17.1", + "express-static-gzip": "^2.1.7", "json-api-serializer": "^2.6.6", "jsonwebtoken": "^9.0.2", "strip-ansi": "^6.0.1",