Skip to content
Permalink
Browse files
fix: rollbar fixes (DEV-1324) (#817)
* 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 e79eee53bc0f3bca3e21c8efb557218a214f1022
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 12 deletions.
@@ -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
);
}

@@ -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
);
}

@@ -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
@@ -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
);
}

@@ -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:
@@ -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;
@@ -256,7 +257,8 @@ export class PropertyInfoComponent implements OnChanges, AfterContentInit {
}
});
});
}
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);
}
}
@@ -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
@@ -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}}
@@ -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"
@@ -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"
@@ -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';

0 comments on commit e79eee5

Please sign in to comment.