Skip to content

Commit

Permalink
fix: rollbar fixes (DEV-1324) (#817)
Browse files Browse the repository at this point in the history
* fix(project): check if project is undefined before accessing properties of project

* fix(resource): check if representationsToDisplay is undefined before calling .length on it

* fix(rollbar): don't report error to rollbar if currentProjectOntologies isn't found in the cache

* fix(results): check if resInfo is undefined before accessing its properties

* chore(results): write cleaner code
  • Loading branch information
mdelez committed Sep 8, 2022
1 parent fbee603 commit e79eee5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 12 deletions.
Expand Up @@ -87,7 +87,8 @@ export class OntologyClassInstanceComponent implements OnChanges {
// find ontology of current resource class to get the class label
const classes = ontologies[ontologies.findIndex(onto => onto.id === this.ontoId)].getAllClassDefinitions();
this.resClass = <ResourceClassDefinition>classes[classes.findIndex(res => res.id === this.classId)];
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);
}

Expand Down
Expand Up @@ -138,7 +138,8 @@ export class OntologyFormComponent implements OnInit {
const name = this._ontologyService.getOntologyName(onto.id);
this.existingOntologyNames.push(name);
});
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/project/ontology/ontology.component.ts
Expand Up @@ -383,7 +383,8 @@ export class OntologyComponent implements OnInit {
// update current list of project ontologies
ontologies[ontologies.findIndex(onto => onto.id === ontology.id)] = ontology;
this._cache.set('currentProjectOntologies', ontologies);
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);

// grab the onto class information to display
Expand Down
3 changes: 2 additions & 1 deletion src/app/project/ontology/ontology.service.ts
Expand Up @@ -116,7 +116,8 @@ export class OntologyService {
(ontologies: ReadOntology[]) => {
const onto = ontologies.find(i => i.id === baseOntoIri);
superPropIri = onto.properties[subProp].subPropertyOf[0];
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);
}

Expand Down
Expand Up @@ -191,7 +191,8 @@ export class PropertyFormComponent implements OnInit {
this.ontologyClasses.push(ontoClasses);
}
});
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);

// b) in case of list value:
Expand Down
Expand Up @@ -214,7 +214,8 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit {
this.propAttribute = onto.classes[this.propDef.objectType].label;
this.propAttributeComment = onto.classes[this.propDef.objectType].comment;
}
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);
} else {
this.propAttribute = this.ontology.classes[this.propDef.objectType].label;
Expand Down Expand Up @@ -256,7 +257,8 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit {
}
});
});
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);
}
}
Expand Down
Expand Up @@ -124,7 +124,8 @@ export class ResourceClassInfoComponent implements OnInit {
};
this.ontoProperties.push(prepareList);
});
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);

// get currently selected ontology
Expand Down
2 changes: 1 addition & 1 deletion src/app/project/project.component.html
Expand Up @@ -18,7 +18,7 @@
<mat-sidenav-container class="project-view">
<mat-sidenav mode="side" opened class="project-nav">
<!-- Project label -->
<div class="link project-title" [routerLink]="'/beta/project/' + project.shortcode">
<div *ngIf="project !== undefined" class="link project-title" [routerLink]="'/beta/project/' + project.shortcode">
<p #projectTitle matTooltip="{{project.longname}}" matTooltipShowDelay="500"
[matTooltipDisabled]="compareElementHeights(projectTitle)" matTooltipPosition="right">
{{project.longname}}
Expand Down
4 changes: 2 additions & 2 deletions src/app/workspace/resource/resource.component.html
Expand Up @@ -2,7 +2,7 @@
<div class="resource-view" *ngIf="resource">

<!-- dsp-resource-representation -->
<div class="representation-container center" *ngIf="representationsToDisplay.length && representationsToDisplay[0].fileValue"
<div class="representation-container center" *ngIf="representationsToDisplay?.length && representationsToDisplay[0].fileValue"
[ngSwitch]="representationsToDisplay[0].fileValue?.type">
<!-- still image view -->
<app-still-image #stillImage class="dsp-representation stillimage" *ngSwitchCase="representationConstants.stillImage"
Expand Down Expand Up @@ -88,7 +88,7 @@

<!-- annotations -->
<mat-tab label="annotations"
*ngIf="representationsToDisplay.length && representationsToDisplay[0].fileValue && representationsToDisplay[0].fileValue.type === representationConstants.stillImage">
*ngIf="representationsToDisplay?.length && representationsToDisplay[0].fileValue && representationsToDisplay[0].fileValue.type === representationConstants.stillImage">
<ng-template matTabLabel class="annotations">
<span [matBadge]="representationsToDisplay[0]?.annotations.length"
[matBadgeHidden]="representationsToDisplay[0]?.annotations.length === 0" matBadgeColor="primary"
Expand Down
2 changes: 1 addition & 1 deletion src/app/workspace/results/results.component.ts
Expand Up @@ -63,7 +63,7 @@ export class ResultsComponent {

onSelectionChange(res: FilteredResources) {
this.selectedResources = res;
this.resourceIri = this.selectedResources.resInfo[0].id;
this.resourceIri = this.selectedResources.resInfo[0]?.id;

if (!res || res.count <= 1) {
this.viewMode = 'single';
Expand Down

0 comments on commit e79eee5

Please sign in to comment.