/
ontology.component.html
197 lines (172 loc) · 10.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
<div *ngIf="projectAdmin" class="desktop-only">
<p class="note warning center">
This is a first version of the data model editor. Some features may not work as intended.
</p>
<dsp-progress-indicator *ngIf="loading"></dsp-progress-indicator>
<!-- toolbar: select ontology -->
<div class="content large middle" *ngIf="!loading && ontologies">
<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; let first = first" [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 && ontology" class="ontology-editor">
<mat-toolbar class="ontology-editor-header">
<mat-toolbar-row>
<h3 class="mat-title" [matTooltip]="ontology.id">{{ontology?.label}}</h3>
<span class="fill-remaining-space"></span>
<span class="ontology-info">
<p class="mat-caption space-reducer">Last modification date</p>
<p class="mat-body" [matTooltip]="'Last modification date: ' + ontology.lastModificationDate"
matTooltipPosition="above">
{{ontology.lastModificationDate | date:'medium'}}</p>
</span>
<span class="fill-remaining-space"></span>
<!-- toggle view -->
<span class="ontology-actions">
<p class="mat-caption space-reducer">Display as</p>
<button mat-button [class.active]="view === 'grid'" (click)="toggleView('grid')">
<mat-icon>view_module</mat-icon>
Grid
</button>
<button mat-button [class.active]="view === 'graph'" (click)="toggleView('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>
<!-- TODO: remove following span as soon edit mode is implemented; it's only for tooltip to use with disabled button -->
<span [matTooltip]="'Edit data model info (not yet implemented)'" matTooltipPosition="above">
<button mat-button [disabled]="!ontology.lastModificationDate" [disabled]="true"
(click)="$event.stopPropagation(); openOntologyForm('editOntology', ontology.id)">
<!-- <mat-icon>edit</mat-icon> -->
Edit
</button>
</span>
<button mat-button [disabled]="!ontology.lastModificationDate"
(click)="$event.stopPropagation(); delete(ontologyIri, 'Ontology', ontology.label)">
<!-- <mat-icon>delete</mat-icon> -->
Delete
</button>
</span>
</mat-toolbar-row>
</mat-toolbar>
<div #ontologyEditor *ngIf="!loadOntology && view === 'grid'" class="ontology-editor-container">
<div class="ontology-editor-subheader">
<p *ngIf="!ontology.lastModificationDate" class="note warning center">
This data model can't be edited because of missing "lastModificationDate"!
</p>
<!-- button to select and add new resource class to the ontology -->
<div class="add-resource-class"
*ngIf="project?.status && (sysAdmin || projectAdmin) && ontologyIri && ontology.lastModificationDate">
<button mat-raised-button color="primary" [matMenuTriggerFor]="addResClassMenu">
Add resource class
<mat-icon>add</mat-icon>
</button>
<mat-menu #addResClassMenu="matMenu" xPosition="before">
<button mat-menu-item *ngFor="let type of resourceClass"
(click)="openResourceClassForm('addResourceClass', type)">
{{ type?.label }}
</button>
</mat-menu>
</div>
</div>
<div class="ontology-editor-canvas drag-drop-stop">
<div class="ontology-editor-grid">
<!-- list of resource classes -->
<div *ngFor="let resClass of ontoClasses; let i = index" class="resource-class" cdkDrag
cdkDragBoundary=".drag-drop-stop">
<mat-toolbar class="resource-class-header" cdkDragHandle>
<mat-toolbar-row>
<h4 mat-card-title [matTooltip]="resClass.comment" matTooltipPosition="above">
{{resClass.label | dspTruncate: 24}}</h4>
<span class="fill-remaining-space"></span>
<button mat-icon-button [matMenuTriggerFor]="resClassMenu"
[matTooltip]="(ontology.lastModificationDate ? null : 'This data model can\'t be edited because of missing lastModificationDate!')"
matTooltipPosition="above">
<mat-icon>more_horiz</mat-icon>
</button>
<mat-menu #resClassMenu="matMenu" xPosition="before">
<button mat-menu-item [disabled]="!ontology.lastModificationDate"
(click)="openResourceClassForm('editResourceClass', {iri: resClass.id, name: '', label: resClass.label})">
Edit resource class info
</button>
<button mat-menu-item [disabled]="!ontology.lastModificationDate"
(click)="updateCard(resClass)">
Update corresponding properties
</button>
<button mat-menu-item [disabled]="!ontology.lastModificationDate"
(click)="delete(resClass.id, 'ResourceClass', resClass.label)">
Delete resource class
</button>
</mat-menu>
</mat-toolbar-row>
</mat-toolbar>
<mat-list class="resource-class-properties">
<span *ngFor="let prop of resClass.propertiesList">
<!-- 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
*ngIf="ontology?.properties[prop.propertyIndex]
&& ontology?.properties[prop.propertyIndex].objectType !== 'http://api.knora.org/ontology/knora-api/v2#LinkValue'"
[propDef]="ontology?.properties[prop.propertyIndex]" [propCard]="prop"
[projectcode]="projectcode">
</app-property-info>
</span>
</mat-list>
</div>
</div>
</div>
</div>
<div *ngIf="view === 'graph'" class="ontology-viewer">
<app-ontology-visualizer [ontology]="ontology" [ontoClasses]="ontoClasses"></app-ontology-visualizer>
</div>
<dsp-progress-indicator *ngIf="loadOntology"></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>