Skip to content

Commit

Permalink
Update selected columns on rule update
Browse files Browse the repository at this point in the history
  • Loading branch information
ckitsanelis committed Oct 3, 2023
1 parent 6b43630 commit ff7c3b7
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/viewer/LogFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ export default class LogFile {
}

updateRules(rules: Rule[]): LogFile {
// Slow solution
// const headers = LogFile.getHeaders(this.contentHeaders, rules);
// let logFile = new LogFile(this.contentHeaders, headers, this.rows);
// logFile = this.copyDefaultColumnColors(logFile, this.columnsColors);
// logFile.computeRulesValuesAndColors(rules);
// return logFile;

this.updateSelectedColumns(rules);
this.updateHeaders(rules);
this.computeRulesValuesAndColors(rules);
return this;
// Slower solution
let [updatedSelected, updatedSelectedMini] = this.updateSelectedColumns(rules)
const headers = LogFile.getHeaders(this.contentHeaders, rules);
let logFile = new LogFile(this.contentHeaders, headers, this.rows);
logFile.copyDefaultColumnColors(this.columnsColors);
logFile.computeRulesValuesAndColors(rules);
logFile = logFile.setSelectedColumns(updatedSelected, updatedSelectedMini);
return logFile;

// Old solution
// this.updateSelectedColumns(rules);
// this.updateHeaders(rules);
// this.computeRulesValuesAndColors(rules);
// return this;
}

updateSelectedColumns(rules: Rule[]) {
Expand All @@ -69,7 +72,7 @@ export default class LogFile {
updatedSelectedMini.push(true);
}
}
this.setSelectedColumns(updatedSelected, updatedSelectedMini);
return [updatedSelected, updatedSelectedMini]
}

setSelectedColumns(selected: boolean[], selectedMini: boolean[]) {
Expand Down Expand Up @@ -125,11 +128,10 @@ export default class LogFile {
}
}

private copyDefaultColumnColors(logFile: LogFile, colours: string[][]) {
private copyDefaultColumnColors(colours: string[][]) {
for (let i = 0; i < this.contentHeaders.length; i++) {
logFile.columnsColors[i] = colours[i];
this.columnsColors[i] = colours[i];
}
return logFile
}

private computeRulesValuesAndColors(rules: Rule[]) {
Expand Down

0 comments on commit ff7c3b7

Please sign in to comment.