0;
}
- // subscribeToMessageChannel() {
- // console.log("Subscribe called");
- // if (!this.logChannelSub) {
- // this.logChannelSub = subscribe(
- // this.messageContext,
- // STATE,
- // (message) => {
- // this.setFileData(message);
- // },
- // { scope: APPLICATION_SCOPE }
- // );
- // this.logChannelSub = true;
- // }
- // }
-
- // setFileData(message) {
- // if (message !== null && message !== undefined) {
- // // console.log("[LogPreviewer.js] setFileData called", message);
- // if (message.fileData !== undefined && message.fileData !== null) {
- // this.fileData = message.fileData;
- // this.pageNumber = 1;
- // this.noOfPages = Math.ceil(
- // this.fileData.length / this.linesPerPage
- // );
- // this.calculations();
- // }
- // if (
- // message.fileMetadata !== undefined &&
- // message.fileMetadata !== null
- // ) {
- // this.fileMetadata = message.fileMetadata;
- // }
- // if (
- // message.eventsPicklistValues !== undefined &&
- // message.eventsPicklistValues !== null
- // ) {
- // if (Array.isArray(message.eventsPicklistValues)) {
- // this.filterPickListMaster =
- // message.eventsPicklistValues.map((str) => ({
- // value: str,
- // label: str
- // }));
- // }
- // }
- // }
- // }
onLinesPerPageChange(event) {
// console.log("Page Change: ", event.target.value);
let input = parseInt(event.target.value, 10);
@@ -508,15 +493,59 @@ export default class logViewer extends LightningElement {
handleSearch() {
this.isSearching = !this.isSearching;
- // const payload = this.fileData;
- // publish('searchChannel', payload);
+ if (this.isSearching === false) {
+ this.processNoSearchRes();
+ }
+ }
+
+ processSearchRes(event) {
+ const lineNumbers = event.detail;
+ this.LineNumMap = new Map();
+ console.log(lineNumbers);
+ if (Array.isArray(lineNumbers)) {
+ lineNumbers.forEach((l) => {
+ if (this.linesPerPage !== 0) {
+ const pNum = Math.ceil(l / this.linesPerPage);
+ if (this.LineNumMap.has(pNum)) {
+ this.LineNumMap.get(pNum).push(l);
+ } else {
+ this.LineNumMap.set(pNum, [l]);
+ }
+ }
+ });
+ }
+ // console.log('Map: ', this.LineNumMap);
+ }
+
+ goToMatch(event) {
+ const lineNumber = event.detail;
+ // console.log('lineNumber: ', lineNumber);
+ this.goToPage(lineNumber);
}
- goToNxtMatch(event) {
- console.log(event.detail);
+ goToPage(lineNumber) {
+ //calculate the pagenumber
+ if (this.linesPerPage <= 0 || lineNumber <= 0) return;
+ this.LineNumFocus = lineNumber;
+ this.pageNumber = Math.ceil(lineNumber / this.linesPerPage);
+ this.calculations();
}
- goToPrevMatch(event) {
- console.log(event.detail);
+ processNoSearchRes() {
+ this.LineNumFocus = null;
+ if (this.LineNumMap.size > 0) {
+ if (this.LineNumMap.has(this.pageNumber)) {
+ const highEle = this.LineNumMap.get(this.pageNumber);
+ highEle.forEach((ele) => {
+ const element = this.template.querySelector(
+ `[data-logid="${ele}"]`
+ );
+ if (element) {
+ element.style.backgroundColor = 'rgba(0, 0, 0, 0)';
+ }
+ });
+ }
+ }
+ this.LineNumMap = new Map();
}
}
diff --git a/src/modules/ui/search/search.js b/src/modules/ui/search/search.js
index 0d93f94..26ec3e4 100644
--- a/src/modules/ui/search/search.js
+++ b/src/modules/ui/search/search.js
@@ -5,7 +5,7 @@ export default class Search extends LightningElement {
onRes = 0;
totRes = 0;
nextDisabled = false;
- prevDisabled = true;
+ prevDisabled = false;
matchedLines = [];
@api logtobeFiltered = [];
@@ -24,32 +24,52 @@ export default class Search extends LightningElement {
this.timeoutId = setTimeout(() => {
this.searchLog(input);
}, 500);
- console.log('input: ', event.target.value);
+ // console.log('input: ', event.target.value);
}
gotoNext() {
+ let idx = this.onRes - 1;
if (this.onRes < this.totRes) {
+ this.onRes++;
this.dispatchEvent(
- new CustomEvent('nextmatch', {
- detail: this.matchedLines[this.onRes++]
+ new CustomEvent('matchchange', {
+ detail: this.matchedLines[++idx]
})
);
+ } else if (this.onRes === this.totRes) {
+ if (this.totRes !== 0) {
+ this.onRes = 1;
+ this.dispatchEvent(
+ new CustomEvent('matchchange', {
+ detail: this.matchedLines[0]
+ })
+ );
+ }
}
- this.nextDisabled = this.onRes === this.totRes ? true : false;
- this.prevDisabled = this.onRes === 0 ? true : false;
+ // this.nextDisabled = this.onRes === this.totRes ? true : false;
+ // this.prevDisabled = this.onRes === 0 ? true : false;
}
goBack() {
- if (this.onRes > 0) {
+ let idx = this.onRes - 1;
+ if (idx > 0) {
+ this.onRes--;
this.dispatchEvent(
- new CustomEvent('prevmatch', {
- detail: this.matchedLines[this.onRes--]
+ new CustomEvent('matchchange', {
+ detail: this.matchedLines[--idx]
+ })
+ );
+ } else if (idx === 0) {
+ this.onRes = this.totRes;
+ this.dispatchEvent(
+ new CustomEvent('matchchange', {
+ detail: this.matchedLines[this.onRes - 1]
})
);
}
- this.nextDisabled = this.onRes === this.totRes ? true : false;
- this.prevDisabled = this.onRes === 0 ? true : false;
+ // this.nextDisabled = this.onRes === this.totRes ? true : false;
+ // this.prevDisabled = this.onRes === 0 ? true : false;
}
searchLog(searchTerm) {
@@ -57,7 +77,7 @@ export default class Search extends LightningElement {
this.onRes = this.totRes = 0;
return;
}
- if (searchTerm.length !== 0 && searchTerm !== undefined) {
+ if (searchTerm.length > 2 && searchTerm !== undefined) {
const results = this.logtobeFiltered.filter((log) =>
log.line.includes(searchTerm)
);
@@ -66,20 +86,27 @@ export default class Search extends LightningElement {
// console.log('Found logs:', results);
this.matchedLines = results.map((log) => log.lineNumber);
this.totRes = this.matchedLines.length;
-
+ this.onRes = 1;
+ this.dispatchEvent(
+ new CustomEvent('searchres', {
+ detail: this.matchedLines
+ })
+ );
this.dispatchEvent(
- new CustomEvent('nextmatch', {
- detail: this.matchedLines[this.onRes++]
+ new CustomEvent('matchchange', {
+ detail: this.matchedLines[this.onRes - 1]
})
);
// console.log('Line numbers:', lineNumbers);
} else if (results.length === 0) {
this.onRes = 0;
this.totRes = 0;
+ this.dispatchEvent(new CustomEvent('nores'));
}
} else {
this.onRes = 0;
this.totRes = 0;
+ this.dispatchEvent(new CustomEvent('nores'));
}
}
}
From 3a035bc3af2c1e40c23e86834533346ae713d53e Mon Sep 17 00:00:00 2001
From: Charan Girijala <82193104+charangirijala@users.noreply.github.com>
Date: Mon, 23 Dec 2024 21:05:11 +0530
Subject: [PATCH 2/2] GoTo functionality implemented
---
src/modules/main/logViewer/logViewer.html | 35 +++++++----------------
src/modules/main/logViewer/logViewer.js | 14 +++++++--
src/modules/ui/input/input.html | 31 ++++++++++++++------
src/modules/ui/input/input.js | 15 +++++++++-
src/modules/ui/search/search.js | 3 +-
5 files changed, 59 insertions(+), 39 deletions(-)
diff --git a/src/modules/main/logViewer/logViewer.html b/src/modules/main/logViewer/logViewer.html
index 5bb818b..ec66434 100644
--- a/src/modules/main/logViewer/logViewer.html
+++ b/src/modules/main/logViewer/logViewer.html
@@ -49,28 +49,11 @@
|