Skip to content

Commit

Permalink
Change timing of ColumnType extraction for persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
ckitsanelis committed Nov 23, 2023
1 parent d304503 commit b0eaab3
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/viewer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ interface State {
}


let searchText = "";
let searchColumn = "All";
let searchTimeoutId;
let searchText: string = "";
let searchColumn: string = "All";
let logHeaderColumnTypes: StructureHeaderColumnType[] = [];

export default class App extends React.Component<Props, State> {
Expand Down Expand Up @@ -120,6 +120,7 @@ export default class App extends React.Component<Props, State> {
const logEntryCharIndexMaps = useGetCharIndicesForLogEntries(logFileText);
const logFile = LogFile.create(lines, rules);
logFile.setSelectedColumns(this.state.selectedColumns, this.state.selectedColumnsMini)
this.extractHeaderColumnTypes(logFile, rules);
this.setState({
rules,
logFile,
Expand All @@ -142,6 +143,25 @@ export default class App extends React.Component<Props, State> {
}
}

extractHeaderColumnTypes(logFile: LogFile, rules: Rule[]) {
logHeaderColumnTypes = [];
for (let h = 0; h < logFile.headers.length; h++) {
let headerType = StructureHeaderColumnType.Selected;

if (logFile.headers[h].name.toLowerCase() === "timestamp") {
headerType = StructureHeaderColumnType.Unselected;
}

rules.forEach((rule) => {
if (rule.column === logFile.headers[h].name) {
headerType = StructureHeaderColumnType.Custom;
}
});

logHeaderColumnTypes.push(headerType);
}
}

updateSearchField() {
clearTimeout(searchTimeoutId);
searchTimeoutId = setTimeout(this.updateSearchMatches, 1000);
Expand Down Expand Up @@ -226,7 +246,6 @@ export default class App extends React.Component<Props, State> {

handleStructureDialog(isClosing: boolean) {
if (isClosing === true) {
logHeaderColumnTypes = [];
this.handleStructureUpdate(isClosing);
} else {
const { logFile, rowProperties, rules, showStructureDialog } = this.state;
Expand All @@ -240,22 +259,7 @@ export default class App extends React.Component<Props, State> {
}

if (!showStructureDialog) {
for (let h = 0; h < logFile.headers.length; h++) {
let headerType = StructureHeaderColumnType.Selected;

if (logFile.headers[h].name.toLowerCase() === "timestamp") {
headerType = StructureHeaderColumnType.Unselected;
}

rules.forEach((rule) => {
if (rule.column === logFile.headers[h].name) {
headerType = StructureHeaderColumnType.Custom;
}
});

logHeaderColumnTypes.push(headerType);
}

this.extractHeaderColumnTypes(logFile, rules);
this.setState({ showStructureDialog: true });
}

Expand Down

0 comments on commit b0eaab3

Please sign in to comment.