Revision 62550
Added by John Balasis over 1 year ago
modules/uoa-repository-dashboard-gui/trunk/src/app/services/repository.service.ts | ||
---|---|---|
46 | 46 |
return this.httpClient.post<RepositoryInterface>(url, newInterface, headerOptions); |
47 | 47 |
} |
48 | 48 |
|
49 |
updateInterface(repoId: string, registeredBy: string, comment: string, interfaceInfo: RepositoryInterface): Observable<RepositoryInterface> { |
|
49 |
updateInterface(repoId: string, registeredBy: string, comment: string, interfaceInfo: RepositoryInterface, desiredCompatibilityLevel?: string): Observable<RepositoryInterface> {
|
|
50 | 50 |
let url; |
51 | 51 |
comment = interfaceInfo.comments; // temp fix for emailing comment |
52 | 52 |
if (comment == null || comment === '') { |
53 |
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}®isteredBy=${registeredBy}`; |
|
53 |
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}®isteredBy=${registeredBy}$desiredCompatibilityLevel=${desiredCompatibilityLevel}`;
|
|
54 | 54 |
} else { |
55 |
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}®isteredBy=${registeredBy}&comment=${comment}`; |
|
55 |
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}®isteredBy=${registeredBy}&comment=${comment}$desiredCompatibilityLevel=${desiredCompatibilityLevel}`;
|
|
56 | 56 |
} |
57 | 57 |
console.log(`knocking on: ${url}`); |
58 | 58 |
console.log(`sending ${JSON.stringify(interfaceInfo)}`); |
modules/uoa-repository-dashboard-gui/trunk/src/app/shared/reusablecomponents/sources-forms/datasource-new-interface-form.component.html | ||
---|---|---|
14 | 14 |
<div class="md-card-toolbar"> |
15 | 15 |
<div class="md-card-toolbar-actions"> |
16 | 16 |
<a *ngIf="!inRegister" (click)="saveInterface()" class="uk-margin-small-right"><i class="md-icon material-icons">save</i></a> |
17 |
<a (click)="removeInterface()" class="uk-margin-small-left"><i class="md-icon material-icons">clear</i></a>
|
|
17 |
<!-- <a (click)="removeInterface()" class="uk-margin-small-left"><i class="md-icon material-icons">clear</i></a>-->
|
|
18 | 18 |
</div> |
19 |
<!--<h3 class="md-card-toolbar-heading-text"> Card Heading </h3>--> |
|
20 | 19 |
</div> |
21 | 20 |
|
22 |
<!--<div class="md-card-toolbar interfaceActionsPanel">--> |
|
23 |
<!--<a *ngIf="!inRegister" (click)="saveInterface()" class="uk-margin-small-right"><i class="far fa-save fa-lg"></i></a>--> |
|
24 |
<!--<a (click)="removeInterface()" class="uk-margin-small-left"><i class="fas fa-times fa-lg"></i></a>--> |
|
25 |
<!--</div>--> |
|
26 |
|
|
27 | 21 |
<div class="md-card-content"> |
28 | 22 |
<div *ngIf="successMessage" class="uk-alert uk-alert-success" style="clear: both">{{ successMessage }}</div> |
29 | 23 |
<div *ngIf="errorMessage" class="uk-alert" [ngClass]="{'uk-alert-warning': errorMessage == invalidCustomBaseUrl, |
30 |
'uk-alert-danger': errorMessage != invalidCustomBaseUrl}" style="clear: both">{{ errorMessage }}</div> |
|
24 |
'uk-alert-danger': errorMessage != invalidCustomBaseUrl}" style="clear: both">{{ errorMessage }} |
|
25 |
</div> |
|
31 | 26 |
|
32 | 27 |
<div class="md-input-wrapper uk-margin-medium-top {{ (repoInterfaceForm.get('baseurl') != null) ? 'md-input-filled' : '' }}"> |
33 | 28 |
<label class="" for="baseurl" title="{{ baseUrlDesc.desc }}">Base OAI-PMH URL (*)</label> |
34 | 29 |
<span *ngIf="showIdentifiedBaseUrl" class="help-block inline" style="margin-top: 8px; margin-bottom: 0px; padding-left: 10px; display: block;"> |
35 | 30 |
Identified |
36 | 31 |
</span> |
37 |
<input id="baseurl" type="text" class="md-input" formControlName="baseurl" (blur)="getInterfaceInfo()"> |
|
32 |
<input id="baseurl" type="text" class="md-input uk-disabled" formControlName="baseurl" (blur)="getInterfaceInfo()">
|
|
38 | 33 |
<span class="md-input-bar"></span> |
39 | 34 |
</div> |
40 | 35 |
|
41 | 36 |
|
42 |
<!--<div class="form-group has-success">--> |
|
43 |
<!--<label class="control-label" for="baseurl" title="{{ baseUrlDesc.desc }}">Base OAI-PMH URL (*)</label>--> |
|
44 |
<!--<span *ngIf="identifiedBaseUrl" class="help-block inline" style="margin-top: 0px; margin-bottom: 0px; padding-left: 10px;">--> |
|
45 |
<!--Identified--> |
|
46 |
<!--</span>--> |
|
47 |
<!--<input id="baseurl" type="text" class="form-control" formControlName="baseurl" (blur)="getInterfaceInfo()">--> |
|
48 |
<!--</div>--> |
|
49 |
|
|
50 |
|
|
51 | 37 |
<div class="radioButtonForm uk-margin-top"> |
52 |
<label class="control-label">Validation Set</label> |
|
53 |
|
|
54 |
<div class="form-group"> |
|
55 |
<label for="selectRadio{{interfaceID}}" title="{{ existingValSetDesc.desc }}" |
|
56 |
class="uk-button uk-link-muted visible_uk_links" |
|
57 |
style="display: block; text-align: left;"> |
|
58 |
<input id="selectRadio{{interfaceID}}" value="select" name="validationSet{{interfaceID}}" type="radio" |
|
59 |
(change)="chooseValSet(true)" checked > |
|
60 |
<span class="uk-margin-small-left">Choose existing</span> |
|
61 |
</label> |
|
62 |
</div> |
|
38 |
<label for="selectValidationSet{{interfaceID}}" class="control-label">Set</label> |
|
63 | 39 |
<div class="md-input-wrapper"> |
64 |
<!--<label class="">Select repository's country</label>--> |
|
65 | 40 |
<select class="md-input" id="selectValidationSet{{interfaceID}}" formControlName="selectValidationSet" (change)="checkIfValid()"> |
66 | 41 |
<option value="" selected>-- none selected --</option> |
67 | 42 |
<option *ngFor="let set of valsetList" value="{{set}}">{{set}}</option> |
68 | 43 |
</select> |
69 | 44 |
<span class="md-input-bar"></span> |
70 | 45 |
</div> |
71 |
<div class="form-group"> |
|
72 |
<label for="customRadio{{interfaceID}}" title="{{ customValSetDesc.desc }}" |
|
73 |
class="uk-button uk-link-muted visible_uk_links" |
|
74 |
style="display: block; text-align: left;"> |
|
75 |
<input id="customRadio{{interfaceID}}" value="custom" name="validationSet{{interfaceID}}" type="radio" |
|
76 |
(change)="chooseValSet(false)"> |
|
77 |
<span class="uk-margin-small-left">or a custom one</span> |
|
78 |
</label> |
|
79 |
</div> |
|
80 |
<div class="md-input-wrapper"> |
|
81 |
<input id="customValidationSet{{interfaceID}}" formControlName="customValidationSet" |
|
82 |
class="md-input" type="text" (keyup)="checkIfValid()"> |
|
83 |
<span class="md-input-bar"></span> |
|
84 |
</div> |
|
85 | 46 |
|
86 | 47 |
</div> |
87 | 48 |
|
88 |
|
|
89 |
<!--<div class="form-group">--> |
|
90 |
<!--<label class="control-label">Validation Set</label>--> |
|
91 |
<!--<div>--> |
|
92 |
<!--<label class="uk-button validationSetRadio" for="selectRadio{{interfaceID}}" title="{{ existingValSetDesc.desc }}">--> |
|
93 |
<!--<input id="selectRadio{{interfaceID}}" value="select" name="validationSet{{interfaceID}}" type="radio"--> |
|
94 |
<!--(change)="chooseValSet(true)" checked >--> |
|
95 |
<!--<span class="uk-margin-small-left">Choose existing</span>--> |
|
96 |
<!--</label>--> |
|
97 |
<!--</div>--> |
|
98 |
<!--<select id="selectValidationSet{{interfaceID}}" formControlName="selectValidationSet"--> |
|
99 |
<!--class="form-control" (change)="checkIfValid()">--> |
|
100 |
<!--<option value="" selected>-- none selected --</option>--> |
|
101 |
<!--<option *ngFor="let set of valsetList" value="{{set}}">{{set}}</option>--> |
|
102 |
<!--</select>--> |
|
103 |
<!--<div>--> |
|
104 |
<!--<label class="uk-button validationSetRadio" for="customRadio{{interfaceID}}" title="{{ customValSetDesc.desc }}">--> |
|
105 |
<!--<input id="customRadio{{interfaceID}}" value="custom" name="validationSet{{interfaceID}}" type="radio"--> |
|
106 |
<!--(change)="chooseValSet(false)">--> |
|
107 |
<!--<span class="uk-margin-small-left">or a custom one</span>--> |
|
108 |
<!--</label>--> |
|
109 |
<!--</div>--> |
|
110 |
<!--<input id="customValidationSet{{interfaceID}}" formControlName="customValidationSet"--> |
|
111 |
<!--class="form-control" type="text" (keyup)="checkIfValid()">--> |
|
112 |
<!--</div>--> |
|
113 |
|
|
114 | 49 |
<div class="md-input-wrapper md-input-filled uk-margin-medium-top"> |
115 | 50 |
<label style="top: -16px" class="" for="compLvl" title="{{ compatibilityLevelDesc.desc }}">Desired Compatibility Level (*)</label> |
116 |
<select class="md-input" id="compLvl" formControlName="compatibilityLevel" (change)="checkIfValid()">
|
|
51 |
<select class="md-input" id="compLvl" formControlName="desiredCompatibilityLevel" (change)="checkIfValid()">
|
|
117 | 52 |
<option value="">-- none selected --</option> |
118 | 53 |
<option *ngFor="let key of classCodes" value="{{key}}">{{compClasses[key]}}</option> |
119 | 54 |
</select> |
120 | 55 |
<span class="md-input-bar"></span> |
121 | 56 |
</div> |
122 | 57 |
|
123 |
<!--<div class="form-group">--> |
|
124 |
<!--<label class="control-label" for="compLvl" title="{{ compatibilityLevelDesc.desc }}">Desired Compatibility Level (*)</label>--> |
|
125 |
<!--<select class="form-control" id="compLvl" formControlName="compatibilityLevel" (change)="checkIfValid()">--> |
|
126 |
<!--<option value="">-- none selected --</option>--> |
|
127 |
<!--<option *ngFor="let key of classCodes" value="{{key}}">{{compClasses[key]}}</option>--> |
|
128 |
<!--</select>--> |
|
129 |
<!--</div>--> |
|
130 |
|
|
131 |
<div class=""> |
|
58 |
<div class="uk-margin-medium-top"> |
|
132 | 59 |
<label class="">Current Compatibility Level</label> |
133 |
<div *ngIf="existingCompLevel">{{ existingCompLevel ? existingCompLevel : 'not available' }}</div>
|
|
60 |
<div>{{repoInterfaceForm.get('compatibilityLevel').value ? this.compClasses[repoInterfaceForm.get('compatibilityLevel').value] : 'not available' }}</div>
|
|
134 | 61 |
</div> |
135 | 62 |
|
136 |
<!--<div>-->
|
|
137 |
<!--<label class="uk-form-controls-text control-label">Current Compatibility Level</label>-->
|
|
138 |
<!--<div *ngIf="existingCompLevel">{{ existingCompLevel ? existingCompLevel : 'not available' }}</div>-->
|
|
139 |
<!--</div>-->
|
|
63 |
<div class="uk-margin-medium-top">
|
|
64 |
<label class="">Compatibility Level Override</label>
|
|
65 |
<div>{{repoInterfaceForm.get('compatibilityLevelOverride').value ? this.compClasses[repoInterfaceForm.get('compatibilityLevelOverride').value] : 'not available' }}</div>
|
|
66 |
</div>
|
|
140 | 67 |
|
141 | 68 |
<div class="uk-margin-medium-top"> |
142 | 69 |
<label class="" for="comment" title="{{ commentDesc.desc }}">Comments (What else do we need to know?)</label> |
... | ... | |
145 | 72 |
|
146 | 73 |
</div> |
147 | 74 |
|
75 |
<pre>{{repoInterfaceForm.value | json}}</pre> |
|
76 |
|
|
148 | 77 |
</div> |
149 | 78 |
</div> |
modules/uoa-repository-dashboard-gui/trunk/src/app/shared/reusablecomponents/sources-forms/datasource-new-interface-form.component.ts | ||
---|---|---|
39 | 39 |
readonly repoInterfaceFormDef = { |
40 | 40 |
baseurl: ['', Validators.required], |
41 | 41 |
selectValidationSet: [''], |
42 |
customValidationSet: [''], |
|
43 |
compatibilityLevel: [''], |
|
42 |
compatibilityLevel: null, |
|
43 |
desiredCompatibilityLevel: null, |
|
44 |
compatibilityLevelOverride: null, |
|
44 | 45 |
comment: [''] |
45 | 46 |
}; |
46 | 47 |
baseUrlDesc: Description = baseUrlDesc; |
... | ... | |
68 | 69 |
this.interfaceID = this.data[1]; |
69 | 70 |
this.currentRepo = this.data[2]; |
70 | 71 |
this.repoInterfaceForm = this.fb.group(this.repoInterfaceFormDef); |
71 |
this.chooseValSet(true); |
|
72 |
// this.chooseValSet(true);
|
|
72 | 73 |
if (this.data[3]) { |
73 | 74 |
this.currentInterface = this.data[3]; |
74 | 75 |
this.repoInterfaceForm.get('baseurl').setValue(this.currentInterface.baseurl); |
75 |
this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibilityOverride); |
|
76 |
this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibility); |
|
77 |
this.repoInterfaceForm.get('compatibilityLevelOverride').setValue(this.currentInterface.compatibilityOverride); |
|
76 | 78 |
} |
77 | 79 |
this.getInterfaceInfo(); |
78 | 80 |
this.getCompatibilityClasses(); |
... | ... | |
110 | 112 |
this.errorMessage = noServiceMessage; |
111 | 113 |
}, |
112 | 114 |
() => { |
113 |
if ( this.currentInterface && this.currentInterface.apiParams && this.currentInterface.apiParams.find(entry => entry.param === 'set')) {
|
|
114 |
if ( this.valsetList.some( x => x === this.currentInterface.apiParams['set']) ) {
|
|
115 |
this.repoInterfaceForm.get('selectValidationSet').setValue(this.currentInterface.apiParams.find(entry => entry.param === 'set').value);
|
|
116 |
} else {
|
|
117 |
this.repoInterfaceForm.get('customValidationSet').setValue(this.currentInterface.apiParams.find(entry => entry.param === 'set').value);
|
|
115 |
if (this.currentInterface?.apiParams?.find(entry => entry.param === 'set')) {
|
|
116 |
// it will not work if set is not on valsetList
|
|
117 |
if (this.valsetList.some(x => x === this.currentInterface.apiParams['set'])) {
|
|
118 |
this.repoInterfaceForm.get('selectValidationSet').setValue(this.currentInterface.apiParams
|
|
119 |
.find(entry => entry.param === 'set').value);
|
|
118 | 120 |
} |
121 |
this.loadingMessage = ''; |
|
122 |
this.repoInterfaceForm.updateValueAndValidity(); |
|
123 |
this.checkIfValid(); |
|
119 | 124 |
} |
120 |
this.loadingMessage = ''; |
|
121 |
this.repoInterfaceForm.updateValueAndValidity(); |
|
122 |
this.checkIfValid(); |
|
123 | 125 |
} |
124 | 126 |
); |
125 | 127 |
} |
... | ... | |
148 | 150 |
|
149 | 151 |
getExistingCompatibilityLevel() { |
150 | 152 |
if (this.currentInterface) { |
151 |
if (this.currentInterface.compatibilityOverride &&
|
|
152 |
this.classCodes.some( x => x === this.currentInterface.compatibilityOverride ) ) {
|
|
153 |
this.existingCompLevel = this.compClasses[this.currentInterface.compatibilityOverride];
|
|
153 |
if (this.currentInterface.compatibility |
|
154 |
&& this.classCodes.some( x => x === this.currentInterface.compatibilityOverride)) {
|
|
155 |
this.existingCompLevel = this.compClasses[this.currentInterface.compatibility]; |
|
154 | 156 |
} else { |
155 |
this.repoInterfaceForm.get('compatibilityLevel').setValue(''); |
|
156 |
this.existingCompLevel = this.currentInterface.compatibilityOverride;
|
|
157 |
// this.repoInterfaceForm.get('compatibilityLevel').setValue('');
|
|
158 |
this.existingCompLevel = this.currentInterface.compatibility; |
|
157 | 159 |
} |
158 | 160 |
} |
159 | 161 |
} |
160 | 162 |
|
161 |
chooseValSet(fromList: boolean) { |
|
162 |
this.existingValSet = fromList; |
|
163 |
if (this.existingValSet) { |
|
164 |
this.repoInterfaceForm.get('selectValidationSet').enable(); |
|
165 |
this.repoInterfaceForm.get('customValidationSet').disable(); |
|
166 |
} else { |
|
167 |
this.repoInterfaceForm.get('selectValidationSet').disable(); |
|
168 |
this.repoInterfaceForm.get('customValidationSet').enable(); |
|
169 |
} |
|
170 |
this.checkIfValid(); |
|
171 |
} |
|
172 |
|
|
173 | 163 |
checkIfCompatibilityLevelWasChosen() { |
174 | 164 |
return ( (this.repoInterfaceForm.get('compatibilityLevel').value !== '') || |
175 | 165 |
(this.existingCompLevel && (this.existingCompLevel !== '')) ); |
176 | 166 |
} |
177 | 167 |
|
178 | 168 |
formIsValid() { |
179 |
return (this.repoInterfaceForm.valid && |
|
180 |
this.identifiedBaseUrl && |
|
181 |
this.checkIfCompatibilityLevelWasChosen()); |
|
169 |
return (this.repoInterfaceForm.valid && this.identifiedBaseUrl && this.checkIfCompatibilityLevelWasChosen()); |
|
182 | 170 |
} |
183 | 171 |
|
184 | 172 |
checkIfValid() { |
... | ... | |
203 | 191 |
let valset = ''; |
204 | 192 |
if (this.existingValSet) { |
205 | 193 |
valset = this.repoInterfaceForm.get('selectValidationSet').value; |
206 |
} else { |
|
207 |
valset = this.repoInterfaceForm.get('customValidationSet').value; |
|
208 | 194 |
} |
209 |
let compLvl = '';
|
|
195 |
let desiredCompLvl = '';
|
|
210 | 196 |
if (this.repoInterfaceForm.get('compatibilityLevel').value) { |
211 |
this.existingCompLevel = this.compClasses[this.repoInterfaceForm.get('compatibilityLevel').value]; |
|
212 |
console.log('this.existingCompLevel is', this.existingCompLevel); |
|
213 |
compLvl = this.repoInterfaceForm.get('compatibilityLevel').value; |
|
214 |
} else { |
|
215 |
compLvl = this.existingCompLevel; |
|
197 |
// this.existingCompLevel = this.compClasses[this.repoInterfaceForm.get('compatibilityLevel').value]; |
|
198 |
// console.log('this.existingCompLevel is', this.existingCompLevel); |
|
199 |
desiredCompLvl = this.repoInterfaceForm.get('compatibilityLevel').value; |
|
216 | 200 |
} |
201 |
const compLvl = this.existingCompLevel; |
|
217 | 202 |
let comment = ''; |
218 | 203 |
if (this.repoInterfaceForm.get('comment').value) { |
219 | 204 |
comment = this.repoInterfaceForm.get('comment').value; |
220 | 205 |
} |
221 | 206 |
|
222 | 207 |
if (this.currentInterface) { |
223 |
this.updateCurrent(baseurl, valset, compLvl, comment); |
|
208 |
this.updateCurrent(baseurl, valset, desiredCompLvl, compLvl, comment);
|
|
224 | 209 |
} else { |
225 | 210 |
this.addCurrent(baseurl, valset, compLvl, comment); |
226 | 211 |
} |
... | ... | |
257 | 242 |
validationSet = new ApiParamDetails('set', value); |
258 | 243 |
intrf.apiParams.push(validationSet); |
259 | 244 |
} else { |
260 |
validationSet.value = this.repoInterfaceForm.get(this.existingValSet ? 'selectValidationSet' : 'customValidationSet').value;
|
|
245 |
validationSet.value = this.repoInterfaceForm.get('selectValidationSet').value;
|
|
261 | 246 |
} |
262 | 247 |
} |
263 | 248 |
|
... | ... | |
282 | 267 |
|
283 | 268 |
addInterface(newInterface: RepositoryInterface) { |
284 | 269 |
this.loadingMessage = formSubmitting; |
285 |
this.repoService.addInterface(this.currentRepo.datasourceType, |
|
286 |
this.currentRepo.id, |
|
287 |
this.currentRepo.registeredBy, |
|
288 |
this.currentRepo.comments, |
|
289 |
newInterface).subscribe( |
|
270 |
this.repoService.addInterface(this.currentRepo.datasourceType, this.currentRepo.id, |
|
271 |
this.currentRepo.registeredBy, this.currentRepo.comments, newInterface).subscribe( |
|
290 | 272 |
addedInterface => { |
291 | 273 |
console.log(`addInterface responded ${JSON.stringify(addedInterface)}`); |
292 | 274 |
this.currentInterface = addedInterface; |
... | ... | |
310 | 292 |
|
311 | 293 |
} |
312 | 294 |
|
313 |
updateCurrent (baseurl: string, valset: string, compLvl: string, comment: string) { |
|
295 |
updateCurrent (baseurl: string, valset: string, desiredCompLvl: string, compLvl: string, comment: string) {
|
|
314 | 296 |
console.log('update current'); |
315 | 297 |
this.updateValidationSet(this.currentInterface, valset); |
316 | 298 |
this.currentInterface.baseurl = baseurl; |
... | ... | |
320 | 302 |
this.currentInterface.comments = comment; |
321 | 303 |
|
322 | 304 |
if (!this.inRegister) { |
323 |
this.updateInterface(); |
|
305 |
this.updateInterface(desiredCompLvl);
|
|
324 | 306 |
} else { |
325 | 307 |
this.successMessage = 'The harvesting settings are valid!'; |
326 | 308 |
console.log('SAVED !'); |
... | ... | |
328 | 310 |
} |
329 | 311 |
} |
330 | 312 |
|
331 |
updateInterface() { |
|
313 |
updateInterface(desiredCompatibilityLevel: string) {
|
|
332 | 314 |
this.loadingMessage = formSubmitting; |
333 |
this.repoService.updateInterface(this.currentRepo.id, |
|
334 |
this.currentRepo.registeredBy, |
|
335 |
this.currentRepo.comments, |
|
336 |
this.currentInterface).subscribe( |
|
315 |
this.repoService.updateInterface(this.currentRepo.id, this.currentRepo.registeredBy, this.currentRepo.comments, |
|
316 |
this.currentInterface, this.repoInterfaceForm.get('desiredCompatibilityLevel').value).subscribe( |
|
337 | 317 |
response => { |
338 | 318 |
console.log(`updateRepository responded ${JSON.stringify(response)}`); |
339 | 319 |
if (response) { |
Also available in: Unified diff
changes for interface update form and functionality