Skip to content

Commit

Permalink
fix(ontology): Displaying ontology on click (DEV-1545) (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vijeinath committed Dec 21, 2022
1 parent 2b61078 commit 479c1e8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 56 deletions.
104 changes: 51 additions & 53 deletions src/app/project/ontology/ontology.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class OntologyComponent implements OnInit {
};

/**
* list of all default resource classes (sub class of)
* list of all default resource classes (subclass of)
*/
defaultClasses: DefaultClass[] = DefaultResourceClasses.data;
defaultProperties: PropertyCategory[] = DefaultProperties.data;
Expand All @@ -138,7 +138,18 @@ export class OntologyComponent implements OnInit {
private _sortingService: SortingService,
private _titleService: Title,
private _projectService: ProjectService
) {
) {}

@HostListener('window:resize', ['$event']) onWindwoResize(e: Event) {
this.disableContent = (window.innerWidth <= 768);
// reset the page title
if (!this.disableContent) {
this._setPageTitle();
}
}

ngOnInit() {
this.loading = true;
// get the uuid of the current project
this._route.parent.paramMap.subscribe((params: Params) => {
this.projectUuid = params.get('uuid');
Expand All @@ -164,67 +175,55 @@ export class OntologyComponent implements OnInit {
const iriBase = this._ontologyService.getIriBaseUrl();
const ontologyName = params['onto'];
this.ontologyIri = `${iriBase}/ontology/${shortcode}/${ontologyName}/v2`;
}
);
});
}
}

@HostListener('window:resize', ['$event']) onWindwoResize(e: Event) {
this.disableContent = (window.innerWidth <= 768);
// reset the page title
if (!this.disableContent) {
this._setPageTitle();
}
}

ngOnInit() {

this.disableContent = (window.innerWidth <= 768);
this.loading = true;
this.disableContent = (window.innerWidth <= 768);

// get information about the logged-in user
this.session = this._session.getSession();
// get information about the logged-in user
this.session = this._session.getSession();

// is the logged-in user system admin?
this.sysAdmin = this.session.user.sysAdmin;
// is the logged-in user system admin?
this.sysAdmin = this.session.user.sysAdmin;

// default value for projectAdmin
this.projectAdmin = this.sysAdmin;
// default value for projectAdmin
this.projectAdmin = this.sysAdmin;

// get the project data from cache
this._cache.get(this.projectUuid).subscribe(
(response: ReadProject) => {
this.project = response;
// get the project data from cache
this._cache.get(this.projectUuid).subscribe(
(response: ReadProject) => {
this.project = response;

// set the page title
this._setPageTitle();
// set the page title
this._setPageTitle();

// is logged-in user projectAdmin?
this.projectAdmin = this.sysAdmin ? this.sysAdmin : this.session.user.projectAdmin.some(e => e === this.project.id);
// is logged-in user projectAdmin?
this.projectAdmin = this.sysAdmin ? this.sysAdmin : this.session.user.projectAdmin.some(e => e === this.project.id);

this._dspApiConnection.admin.usersEndpoint.getUserByUsername(this.session.user.name).subscribe(
(userResponse: ApiResponseData<UserResponse>) => {
this.projectMember = userResponse.body.user.projects.some(p => p.shortcode === this.project.shortcode);
this._dspApiConnection.admin.usersEndpoint.getUserByUsername(this.session.user.name).subscribe(
(userResponse: ApiResponseData<UserResponse>) => {
this.projectMember = userResponse.body.user.projects.some(p => p.shortcode === this.project.shortcode);

// get the ontologies for this project
this.initOntologiesList();
});
// get the ontologies for this project
this.initOntologiesList();
});

this.ontologyForm = this._fb.group({
ontology: new UntypedFormControl({
value: this.ontologyIri, disabled: false
})
});
this.ontologyForm = this._fb.group({
ontology: new UntypedFormControl({
value: this.ontologyIri, disabled: false
})
});

this.ontologyForm.valueChanges.subscribe(val => this.onValueChanged(val.ontology));
this.ontologyForm.valueChanges.subscribe(val => this.onValueChanged(val.ontology));

},
(error: ApiResponseError) => {
this._errorHandler.showMessage(error);
this.loading = false;
}
);
},
(error: ApiResponseError) => {
this._errorHandler.showMessage(error);
this.loading = false;
}
);
}
);
});
}
}

/**
Expand Down Expand Up @@ -525,8 +524,7 @@ export class OntologyComponent implements OnInit {
* delete either ontology, resource class or property
*
* @param mode Can be 'Ontology' or 'ResourceClass'
* @param id
* @param title
* @param info
*/
delete(mode: 'Ontology' | 'ResourceClass' | 'Property', info: DefaultClass) {
const dialogConfig: MatDialogConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ResourceClassInfoComponent implements OnInit {

classCanReplaceCardinality: boolean;

// list of properties that can be displayed (not all of the props should be displayed)
// list of properties that can be displayed (not all the props should be displayed)
propsToDisplay: PropToDisplay[] = [];

subClassOfLabel = '';
Expand Down Expand Up @@ -133,7 +133,7 @@ export class ResourceClassInfoComponent implements OnInit {
(response: ReadOntology) => {
this.ontology = response;
this.lastModificationDate = this.ontology.lastModificationDate;
// translate iris from "sub class of" array
// translate iris from "subclass of" array
this.translateSubClassOfIri(this.resourceClass.subClassOf);
// prepare list of properties to display
this.preparePropsToDisplay(this.resourceClass.propertiesList);
Expand All @@ -150,7 +150,7 @@ export class ResourceClassInfoComponent implements OnInit {
}

/**
* translates iris from "sub class of" array
* translates iris from "subclass of" array
* - display label from default resource classes (as part of DSP System Project)
* - in case the class is a subclass of another class in the same ontology: display this class label
* - in none of those cases display the name from the class IRI
Expand Down

0 comments on commit 479c1e8

Please sign in to comment.