Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Aug 27, 2024
1 parent d5d589c commit 676143b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 37 deletions.
4 changes: 1 addition & 3 deletions erdblick_app/app/inspection.panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface InspectorTab {
}`,
]
})
export class InspectionPanelComponent implements OnInit
export class InspectionPanelComponent
{
title = "";
tabs: InspectorTab[] = [];
Expand Down Expand Up @@ -86,8 +86,6 @@ export class InspectionPanelComponent implements OnInit
})
}

ngOnInit(): void {}

reset() {
/* We always keep the first tab, which is a feature inspector. */
this.setTab(0);
Expand Down
19 changes: 8 additions & 11 deletions erdblick_app/app/inspection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface SelectedSourceData {
export function selectedSourceDataEqualTo(a: SelectedSourceData | null, b: SelectedSourceData | null) {
if (!a || !b)
return false;
return (a == b || (a.mapId == b.mapId && a.tileId == b.tileId && a.layerId == b.layerId && a.address == b.address && a.featureId == b.featureId));
return (a === b || (a.mapId === b.mapId && a.tileId === b.tileId && a.layerId === b.layerId && a.address === b.address && a.featureId === b.featureId));
}

@Injectable({providedIn: 'root'})
Expand Down Expand Up @@ -174,16 +174,13 @@ export class InspectionService {
async loadSourceDataLayer(tileId: number, layerId: string, mapId: string) : Promise<TileSourceDataLayer> {
console.log(`Loading SourceDataLayer layerId=${layerId} tileId=${tileId}`);

let requests = [{
mapId: mapId,
layerId: layerId,
tileIds: [tileId]
}];

let tileParser = new coreLib.TileLayerParser();

let newRequestBody = JSON.stringify({
requests: requests
const tileParser = new coreLib.TileLayerParser();
const newRequestBody = JSON.stringify({
requests: [{
mapId: mapId,
layerId: layerId,
tileIds: [tileId]
}]
});

let layer: TileSourceDataLayer | undefined;
Expand Down
2 changes: 1 addition & 1 deletion erdblick_app/app/parameters.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class ParametersService {
}
});

constructor(public router: Router /*, private inspectionService: InspectionService*/) {
constructor(public router: Router) {
let parameters = this.loadSavedParameters();
this.parameters = new BehaviorSubject<ErdblickParameters>(parameters!);
this.saveParameters();
Expand Down
32 changes: 14 additions & 18 deletions erdblick_app/app/sourcedata.panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class SourceDataPanelComponent implements OnInit {
ngOnInit(): void {
this.inspectionService.loadSourceDataLayer(this.sourceData.tileId, this.sourceData.layerId, this.sourceData.mapId)
.then(layer => {
let root = layer.toObject()
const root = layer.toObject()
this.addressFormat = layer.addressFormat();

layer.delete();
Expand Down Expand Up @@ -170,7 +170,7 @@ export class SourceDataPanelComponent implements OnInit {
this.treeData = [];
this.errorMessage = message;

console.error(this.errorMessage);
console.error("Error while processing SourceData tree:", this.errorMessage)
}

/**
Expand All @@ -187,23 +187,19 @@ export class SourceDataPanelComponent implements OnInit {

const prefix = "https://developer.nds.live/schema/";

let match = schema.match(/^nds\.(([^.]+\.)+)v(\d{4}_\d{2})((\.[^.]*)+)/);
const match = schema.match(/^nds\.(([^.]+\.)+)v(\d{4}_\d{2})((\.[^.]*)+)/);
if (!match || match.length <= 4)
return schema;

// Sub-namespaces in front of the version get joined by "-". Names past the version get joined by "/"
let url =
const url =
match[1].replace(/^(.*)\.$/, "$1/").replaceAll(".", "-") +
match[3].replaceAll("_", ".") +
match[4].replaceAll(".", "/");
return `<a href="${prefix + url}" target="_blank">${schema}</a>`;
}

addressFormatter(address?: any) {
if (!address) {
return address;
}

addressFormatter(address?: any): string {
if (typeof address === 'object') {
return `${address.offset}:${address.size}`
} else {
Expand All @@ -212,23 +208,25 @@ export class SourceDataPanelComponent implements OnInit {
}

selectItemWithAddress(address: bigint) {
let searchAddress: any = address;
let addressInRange: any;
if (this.addressFormat == coreLib.SourceDataAddressFormat.BIT_RANGE) {
searchAddress = {
const searchAddress = {
offset: address >> BigInt(32) & BigInt(0xFFFFFFFF),
size: address & BigInt(0xFFFFFFFF),
}

const addressLow = typeof searchAddress === 'object' ? searchAddress['offset'] : searchAddress;
const addressHigh = addressLow + (typeof searchAddress === 'object' ? searchAddress['size'] : searchAddress);

addressInRange = (addr: any) => {
return addr.offset >= addressLow && addr.offset + addr.size <= addressHigh && (addr.size != 0 || addressLow == addressHigh);
addressInRange = (address: any) => {
return address.offset >= addressLow &&
address.offset + address.size <= addressHigh &&
(address.size != 0 || addressLow == addressHigh);
}
} else {
addressInRange = (addr: any) => {
return addr == searchAddress;
const searchAddress = address;
addressInRange = (address: any) => {
return address == searchAddress;
}
}

Expand All @@ -244,8 +242,7 @@ export class SourceDataPanelComponent implements OnInit {
node.data.styleClass = "highlight";
}

const address = node.data.address;
if (address && addressInRange(address)) {
if (node.data.address && addressInRange(node.data.address)) {
highlight = true;

if (!firstHighlightedItemIndex)
Expand All @@ -262,7 +259,6 @@ export class SourceDataPanelComponent implements OnInit {
}
};

console.log(`Highlighting item with address`, searchAddress);
this.treeData.forEach((item: TreeTableNode, index) => {
select(item, [], false, index);
});
Expand Down
8 changes: 4 additions & 4 deletions erdblick_app/app/treetablefilter-patch.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export class TreeTableFilterPatchDirective implements AfterContentInit {
if (node) {
let matched = false;
if (node.children) {
let childNodes = [...node.children].map(node => { return { ...node }; });
const children = node.children.map(node => { return { ...node }; });
node.children = [];

let hadMatchingLeaf = false;
for (let childNode of childNodes) {
for (const childNode of children) {
if (this.tt.isFilterMatched(childNode, paramsWithoutNode)) {
matched = true;
hadMatchingLeaf = hadMatchingLeaf || this.tt.isNodeLeaf(childNode);
Expand All @@ -41,7 +41,7 @@ export class TreeTableFilterPatchDirective implements AfterContentInit {
// If we had a matching leaf node, add all leaf nodes.
// Since we are in strict mode, if no child matched, add all
if (hadMatchingLeaf || !matched) {
node.children = childNodes;
node.children = children;
}
}

Expand All @@ -53,4 +53,4 @@ export class TreeTableFilterPatchDirective implements AfterContentInit {
return false;
}
}
}
}

0 comments on commit 676143b

Please sign in to comment.