Skip to content

Commit

Permalink
Fix issue with selected columns on logfile update
Browse files Browse the repository at this point in the history
  • Loading branch information
ckitsanelis committed Oct 2, 2023
1 parent 041b425 commit bd19e06
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/viewer/LogFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,32 @@ export default class LogFile {
return logFile;
}

update(rules: Rule[]): LogFile {
updateRules(rules: Rule[]): LogFile {
this.updateSelectedColumns(rules);
this.updateHeaders(rules);
this.computeRulesValuesAndColors(rules);
this.setSelectedColumns(this.selectedColumns, this.selectedColumnsMini); //only show the selected columns after updating the rules
return this;
}

updateSelectedColumns(rules: Rule[]) {
let existingHeaders = this.headers.map(h => h.name);
let updatedSelected = this.selectedColumns.slice(0, this.contentHeaders.length);
let updatedSelectedMini = this.selectedColumnsMini.slice(0, this.contentHeaders.length);

for (let i = 0; i < rules.length; i++) {
let existingIndex = existingHeaders.indexOf(rules[i].column);
if (existingIndex > -1) {
updatedSelected.push(this.selectedColumns[existingIndex]);
updatedSelectedMini.push(this.selectedColumnsMini[existingIndex]);
}
else {
updatedSelected.push(true);
updatedSelectedMini.push(true);
}
}
this.setSelectedColumns(updatedSelected, updatedSelectedMini);
}

setSelectedColumns(selected: boolean[], selectedMini: boolean[]) {
for (let column = 0; column < this.selectedColumns.length; column++) {
if (selected[column] !== undefined) {
Expand Down

0 comments on commit bd19e06

Please sign in to comment.