Skip to content

Commit

Permalink
Fix structure definition bug due to nested structures
Browse files Browse the repository at this point in the history
  • Loading branch information
ckitsanelis committed Dec 21, 2023
1 parent c3be9d9 commit 6946401
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/viewer/LogFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ export default class LogFile {
if (structureMatches.length > 0) {
updatedSelected.push(false);
updatedSelectedMini.push(true);
const name = "Structure"
const type = DEFAULT_HEADER_TYPE;
headers.push({name, type});
let num = 1;
while (true) {
const name = "Structure" + num
const type = DEFAULT_HEADER_TYPE;
if (!headers.map(h => h.name).includes(name)) {
headers.push({name, type});
break;
}
num++;
}
let currentStructureIndex = 0;
for (let i = 0; i < rows.length; i++) {
rows[i].push("");
Expand Down
9 changes: 5 additions & 4 deletions src/viewer/structures/StructureTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class StructureTable extends React.Component<Props, State> {
return (
<div id="structureHeader" style={style}>
<div className="header-background">
{this.props.headerColumns.map((h, i) =>
{this.props.headerColumns.filter(h => !h.name.startsWith("Structure")).map((h, i) =>
this.renderHeaderColumn(h.name, i, this.getInitialColumnWidth(h.name)),
)}
</div>
Expand Down Expand Up @@ -162,8 +162,9 @@ export default class StructureTable extends React.Component<Props, State> {
renderRows(containerWidth: number, containerHeight: number) {
const newContainerWidth = containerWidth + STRUCTURE_WIDTH;
const result: ReactNode[] = [];
const { structureEntries, isRemovingStructureEntries, headerColumns, onStructureEntryRemoved } =
const { structureEntries, isRemovingStructureEntries, onStructureEntryRemoved } =
this.props;
const headerColumns = this.props.headerColumns.filter(h => !h.name.startsWith("Structure"));
const structureEntryIconStyle = getStructureTableEntryIconStyle(isRemovingStructureEntries);
let structureLinkIndex = 0;

Expand Down Expand Up @@ -247,8 +248,8 @@ export default class StructureTable extends React.Component<Props, State> {
}

render() {
const { headerColumns, structureEntries } = this.props;
const numberOfRows = structureEntries.length;
const numberOfRows = this.props.structureEntries.length;
const headerColumns = this.props.headerColumns.filter(h => !h.name.startsWith("Structure"));
const containerHeight =
numberOfRows * LOG_ROW_HEIGHT + (numberOfRows - 1) * STRUCTURE_LINK_HEIGHT;
const containerWidth =
Expand Down

0 comments on commit 6946401

Please sign in to comment.