/
ontology.component.html
224 lines (203 loc) · 12.3 KB
/
ontology.component.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<div *ngIf="projectAdmin" class="desktop-only">
<dsp-progress-indicator *ngIf="loading"></dsp-progress-indicator>
<!-- toolbar: select ontology -->
<div class="content large middle" *ngIf="!loading">
<div class="app-toolbar transparent more-space-bottom">
<div class="app-toolbar-row toolbar-subtitle">
<h3 class="mat-body subtitle">Define your metadata</h3>
</div>
<div class="app-toolbar-row toolbar-form">
<h2 class="mat-title">
<span *ngIf="ontologies.length > 0">
Project has {{ontologies.length | i18nPlural: itemPluralMapping['ontology']}}
</span>
<span *ngIf="ontologies.length === 0 || !ontologies">
It seems there's no data model defined yet
</span>
</h2>
<span class="fill-remaining-space"></span>
<span class="app-toolbar-action" [class.select-form]="ontologies.length">
<form [formGroup]="ontologyForm" class="form" *ngIf="!loading && ontologies.length > 1">
<!-- list to select ontology -->
<div class="form-content">
<mat-form-field class="large-field select-ontology" *ngIf="ontologies.length">
<mat-label>
Open from list...
</mat-label>
<mat-select [formControl]="ontologyForm.controls['ontology']" [(value)]="ontologyIri">
<mat-option *ngFor="let onto of ontologies" [value]="onto.id">
{{onto.label}}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</form>
</span>
<span class="fill-remaining-space"></span>
<span class="app-toolbar-action" [class.select-form]="ontologies.length">
<button mat-raised-button color="primary" class="create-data-model-btn"
(click)="openOntologyForm('createOntology')">
{{ontologies.length ? 'New data model' : 'Create your first data model'}}
</button>
</span>
</div>
</div>
</div>
<!-- main content: overview shows resource classes of ontology -->
<div *ngIf="!loading && !loadOntology && ontology" class="ontology-editor">
<mat-toolbar class="ontology-editor-header">
<mat-toolbar-row>
<span class="ontology-info">
<h3 class="mat-title space-reducer"
[matTooltip]="ontology.comment ? ontology.comment : ontology.id"
matTooltipPosition="above">
{{ontology?.label}}
</h3>
<p class="mat-caption" [matTooltip]="'Last modification date: ' + ontology.lastModificationDate"
matTooltipPosition="above">
<span *ngIf="ontology.lastModificationDate; else noModificationDate">
Updated on: {{ontology.lastModificationDate | date:'medium'}}
</span>
<ng-template #noModificationDate>
<span class="note warning">
<!-- <mat-icon>report</mat-icon> -->
This data model can't be edited because of missing "lastModificationDate"!
</span>
</ng-template>
</p>
</span>
<span class="fill-remaining-space"></span>
<!-- toggle view -->
<!-- DSP-1560: disable graph view option in ontology editor
<span class="ontology-actions">
<p class="mat-caption space-reducer">Display as</p>
<button mat-button [class.active]="view === 'classes' || view === 'properties'"
(click)="openOntologyRoute(ontology.id, 'classes')">
<mat-icon>view_module</mat-icon>
Grid
</button>
<button mat-button [class.active]="view === 'graph'"
(click)="openOntologyRoute(ontology.id, 'graph')">
<mat-icon>scatter_plot</mat-icon>
Graph
</button>
</span>
-->
<!-- edit options -->
<span class="ontology-actions">
<p class="mat-caption space-reducer">Data model configuration</p>
<span
[matTooltip]="(ontology.lastModificationDate ? 'Edit data model info' : 'This data model can\'t be edited because of missing lastModificationDate!')">
<button mat-button [disabled]="!ontology.lastModificationDate" [disabled]="!ontology.lastModificationDate"
(click)="$event.stopPropagation(); openOntologyForm('editOntology', ontology.id)">
<mat-icon>edit</mat-icon>
Edit
</button>
</span>
<span
[matTooltip]="(ontology.lastModificationDate ? 'Delete data model' : 'This data model can\'t be edited because of missing lastModificationDate!')">
<button mat-button [disabled]="!ontology.lastModificationDate"
(click)="$event.stopPropagation(); delete('Ontology', {iri: ontologyIri, label: ontology.label})">
<mat-icon>delete</mat-icon>
Delete
</button>
</span>
</span>
</mat-toolbar-row>
</mat-toolbar>
<mat-sidenav-container #ontologyEditor *ngIf="!loadOntology && (view === 'classes' || view === 'properties')"
class="ontology-editor-container">
<mat-sidenav class="ontology-editor-sidenav" mode="side" position="end" opened>
<mat-list>
<a mat-list-item routerLinkActive="active" [routerLink]="'../classes'"
(click)="view = 'classes'">Classes</a>
<span *ngIf="view === 'classes'">
<button mat-button (click)="expandClasses = !expandClasses" [disabled]="!ontoClasses.length">
<mat-icon>{{expandClasses ? 'compress' : 'expand'}}</mat-icon>
{{expandClasses ? "Collapse all" : "Expand all"}}
</button>
<span mat-list-item *ngIf="project?.status && (sysAdmin || projectAdmin) && ontologyIri"
[matTooltip]="'This data model can\'t be edited because of missing \'lastModificationDate\'!'"
[matTooltipDisabled]="ontology.lastModificationDate">
<button mat-button [matMenuTriggerFor]="addResClassMenu"
[disabled]="!ontology.lastModificationDate">
<mat-icon>add</mat-icon>
Create new class
</button>
<mat-menu #addResClassMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor="let type of defaultClasses"
(click)="openResourceClassForm('addResourceClass', type)">
<mat-icon>{{type.icons[0]}}</mat-icon> {{ type.label }}
</button>
</mat-menu>
</span>
</span>
<mat-divider></mat-divider>
<a mat-list-item routerLinkActive="active" [routerLink]="'../properties'"
(click)="view = 'properties'">Properties</a>
<span mat-list-item *ngIf="project?.status && (sysAdmin || projectAdmin) && ontologyIri"
[matTooltip]="'This data model can\'t be edited because of missing \'lastModificationDate\'!'"
[matTooltipDisabled]="ontology.lastModificationDate">
<button mat-button *ngIf="view === 'properties'" [matMenuTriggerFor]="addPropertyMenu"
[disabled]="!ontology.lastModificationDate">
<mat-icon>add</mat-icon>
Create new property
</button>
<mat-menu #addPropertyMenu="matMenu" xPosition="before" class="switch-nested-menu">
<ng-container *ngFor="let type of defaultProperties">
<button mat-menu-item [matMenuTriggerFor]="sub_menu">{{type.group}}</button>
<mat-menu #sub_menu="matMenu" class="switch-nested-sub-menu">
<!-- <button *ngFor="let subItem of my_menu[mainItem]" mat-menu-item>{{ subItem }}</button> -->
<button mat-menu-item *ngFor="let ele of type.elements" [value]="ele"
(click)="openPropertyForm('createProperty', {propType: ele})">
<mat-icon>{{ele.icon}}</mat-icon> {{ele.label}}
</button>
</mat-menu>
</ng-container>
</mat-menu>
</span>
</mat-list>
</mat-sidenav>
<mat-sidenav-content class="ontology-editor-canvas drag-drop-stop">
<div class="ontology-editor-grid classes" *ngIf="view === 'classes'">
<!-- list of resource classes -->
<app-resource-class-info *ngFor="let resClass of ontoClasses" [resourceClass]="resClass"
[expanded]="expandClasses"
[projectCode]="projectCode"
(editResourceClass)="openResourceClassForm('editResourceClass', $event)"
(updateCardinality)="updateCard($event)"
(deleteResourceClass)="delete('ResourceClass', $event)">
</app-resource-class-info>
</div>
<div class="ontology-editor-list properties" *ngIf="view === 'properties'">
<!-- list of resource properties -->
<mat-list>
<span *ngFor="let prop of ontoProperties">
<!-- display only properties with guiOrder and if they exist in list of properties;
objectType is not a linkValue (otherwise we have the property twice) -->
<app-property-info [propDef]="ontology?.properties[prop.id]"
[projectCode]="projectCode"
[editable]="(ontology.lastModificationDate)"
(editResourceProperty)="openPropertyForm('editProperty', $event)"
(deleteResourceProperty)="delete('Property', $event)"
(clickedOnClass)="updateCard($event)">
</app-property-info>
</span>
<!-- <mat-list-item *ngFor="let prop of ontoProperties">{{prop.label}}</mat-list-item> -->
</mat-list>
</div>
</mat-sidenav-content>
</mat-sidenav-container>
<div *ngIf="view === 'graph'" class="ontology-viewer">
<app-ontology-visualizer [ontology]="ontology" [ontoClasses]="ontoClasses"></app-ontology-visualizer>
</div>
<dsp-progress-indicator *ngIf="loadOntology && !loading && view !== 'graph'"></dsp-progress-indicator>
</div>
</div>
<div *ngIf="!projectAdmin" class="content large middle">
<app-error [status]="403"></app-error>
</div>
<div class="mobile-only">
<dsp-message [message]="{status: 415, statusText: 'This content is not supported on small devices.'}">
</dsp-message>
</div>