changes for interface update form and functionality

This commit is contained in:
John Balasis 2023-01-13 16:12:16 +00:00
parent 4c08464797
commit fb452386a1
3 changed files with 51 additions and 142 deletions

View File

@ -46,13 +46,13 @@ export class RepositoryService {
return this.httpClient.post<RepositoryInterface>(url, newInterface, headerOptions); return this.httpClient.post<RepositoryInterface>(url, newInterface, headerOptions);
} }
updateInterface(repoId: string, registeredBy: string, comment: string, interfaceInfo: RepositoryInterface): Observable<RepositoryInterface> { updateInterface(repoId: string, registeredBy: string, comment: string, interfaceInfo: RepositoryInterface, desiredCompatibilityLevel?: string): Observable<RepositoryInterface> {
let url; let url;
comment = interfaceInfo.comments; // temp fix for emailing comment comment = interfaceInfo.comments; // temp fix for emailing comment
if (comment == null || comment === '') { if (comment == null || comment === '') {
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}&registeredBy=${registeredBy}`; url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}&registeredBy=${registeredBy}$desiredCompatibilityLevel=${desiredCompatibilityLevel}`;
} else { } else {
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}&registeredBy=${registeredBy}&comment=${comment}`; url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}&registeredBy=${registeredBy}&comment=${comment}$desiredCompatibilityLevel=${desiredCompatibilityLevel}`;
} }
console.log(`knocking on: ${url}`); console.log(`knocking on: ${url}`);
console.log(`sending ${JSON.stringify(interfaceInfo)}`); console.log(`sending ${JSON.stringify(interfaceInfo)}`);

View File

@ -14,129 +14,56 @@
<div class="md-card-toolbar"> <div class="md-card-toolbar">
<div class="md-card-toolbar-actions"> <div class="md-card-toolbar-actions">
<a *ngIf="!inRegister" (click)="saveInterface()" class="uk-margin-small-right"><i class="md-icon material-icons">save</i></a> <a *ngIf="!inRegister" (click)="saveInterface()" class="uk-margin-small-right"><i class="md-icon material-icons">save</i></a>
<a (click)="removeInterface()" class="uk-margin-small-left"><i class="md-icon material-icons">clear</i></a> <!-- <a (click)="removeInterface()" class="uk-margin-small-left"><i class="md-icon material-icons">clear</i></a>-->
</div> </div>
<!--<h3 class="md-card-toolbar-heading-text"> Card Heading </h3>-->
</div> </div>
<!--<div class="md-card-toolbar interfaceActionsPanel">-->
<!--<a *ngIf="!inRegister" (click)="saveInterface()" class="uk-margin-small-right"><i class="far fa-save fa-lg"></i></a>-->
<!--<a (click)="removeInterface()" class="uk-margin-small-left"><i class="fas fa-times fa-lg"></i></a>-->
<!--</div>-->
<div class="md-card-content"> <div class="md-card-content">
<div *ngIf="successMessage" class="uk-alert uk-alert-success" style="clear: both">{{ successMessage }}</div> <div *ngIf="successMessage" class="uk-alert uk-alert-success" style="clear: both">{{ successMessage }}</div>
<div *ngIf="errorMessage" class="uk-alert" [ngClass]="{'uk-alert-warning': errorMessage == invalidCustomBaseUrl, <div *ngIf="errorMessage" class="uk-alert" [ngClass]="{'uk-alert-warning': errorMessage == invalidCustomBaseUrl,
'uk-alert-danger': errorMessage != invalidCustomBaseUrl}" style="clear: both">{{ errorMessage }}</div> 'uk-alert-danger': errorMessage != invalidCustomBaseUrl}" style="clear: both">{{ errorMessage }}
</div>
<div class="md-input-wrapper uk-margin-medium-top {{ (repoInterfaceForm.get('baseurl') != null) ? 'md-input-filled' : '' }}"> <div class="md-input-wrapper uk-margin-medium-top {{ (repoInterfaceForm.get('baseurl') != null) ? 'md-input-filled' : '' }}">
<label class="" for="baseurl" title="{{ baseUrlDesc.desc }}">Base OAI-PMH URL (*)</label> <label class="" for="baseurl" title="{{ baseUrlDesc.desc }}">Base OAI-PMH URL (*)</label>
<span *ngIf="showIdentifiedBaseUrl" class="help-block inline" style="margin-top: 8px; margin-bottom: 0px; padding-left: 10px; display: block;"> <span *ngIf="showIdentifiedBaseUrl" class="help-block inline" style="margin-top: 8px; margin-bottom: 0px; padding-left: 10px; display: block;">
Identified Identified
</span> </span>
<input id="baseurl" type="text" class="md-input" formControlName="baseurl" (blur)="getInterfaceInfo()"> <input id="baseurl" type="text" class="md-input uk-disabled" formControlName="baseurl" (blur)="getInterfaceInfo()">
<span class="md-input-bar"></span> <span class="md-input-bar"></span>
</div> </div>
<!--<div class="form-group has-success">-->
<!--<label class="control-label" for="baseurl" title="{{ baseUrlDesc.desc }}">Base OAI-PMH URL (*)</label>-->
<!--<span *ngIf="identifiedBaseUrl" class="help-block inline" style="margin-top: 0px; margin-bottom: 0px; padding-left: 10px;">-->
<!--Identified-->
<!--</span>-->
<!--<input id="baseurl" type="text" class="form-control" formControlName="baseurl" (blur)="getInterfaceInfo()">-->
<!--</div>-->
<div class="radioButtonForm uk-margin-top"> <div class="radioButtonForm uk-margin-top">
<label class="control-label">Validation Set</label> <label for="selectValidationSet{{interfaceID}}" class="control-label">Set</label>
<div class="form-group">
<label for="selectRadio{{interfaceID}}" title="{{ existingValSetDesc.desc }}"
class="uk-button uk-link-muted visible_uk_links"
style="display: block; text-align: left;">
<input id="selectRadio{{interfaceID}}" value="select" name="validationSet{{interfaceID}}" type="radio"
(change)="chooseValSet(true)" checked >
<span class="uk-margin-small-left">Choose existing</span>
</label>
</div>
<div class="md-input-wrapper"> <div class="md-input-wrapper">
<!--<label class="">Select repository's country</label>-->
<select class="md-input" id="selectValidationSet{{interfaceID}}" formControlName="selectValidationSet" (change)="checkIfValid()"> <select class="md-input" id="selectValidationSet{{interfaceID}}" formControlName="selectValidationSet" (change)="checkIfValid()">
<option value="" selected>-- none selected --</option> <option value="" selected>-- none selected --</option>
<option *ngFor="let set of valsetList" value="{{set}}">{{set}}</option> <option *ngFor="let set of valsetList" value="{{set}}">{{set}}</option>
</select> </select>
<span class="md-input-bar"></span> <span class="md-input-bar"></span>
</div> </div>
<div class="form-group">
<label for="customRadio{{interfaceID}}" title="{{ customValSetDesc.desc }}"
class="uk-button uk-link-muted visible_uk_links"
style="display: block; text-align: left;">
<input id="customRadio{{interfaceID}}" value="custom" name="validationSet{{interfaceID}}" type="radio"
(change)="chooseValSet(false)">
<span class="uk-margin-small-left">or a custom one</span>
</label>
</div>
<div class="md-input-wrapper">
<input id="customValidationSet{{interfaceID}}" formControlName="customValidationSet"
class="md-input" type="text" (keyup)="checkIfValid()">
<span class="md-input-bar"></span>
</div>
</div> </div>
<!--<div class="form-group">-->
<!--<label class="control-label">Validation Set</label>-->
<!--<div>-->
<!--<label class="uk-button validationSetRadio" for="selectRadio{{interfaceID}}" title="{{ existingValSetDesc.desc }}">-->
<!--<input id="selectRadio{{interfaceID}}" value="select" name="validationSet{{interfaceID}}" type="radio"-->
<!--(change)="chooseValSet(true)" checked >-->
<!--<span class="uk-margin-small-left">Choose existing</span>-->
<!--</label>-->
<!--</div>-->
<!--<select id="selectValidationSet{{interfaceID}}" formControlName="selectValidationSet"-->
<!--class="form-control" (change)="checkIfValid()">-->
<!--<option value="" selected>&#45;&#45; none selected &#45;&#45;</option>-->
<!--<option *ngFor="let set of valsetList" value="{{set}}">{{set}}</option>-->
<!--</select>-->
<!--<div>-->
<!--<label class="uk-button validationSetRadio" for="customRadio{{interfaceID}}" title="{{ customValSetDesc.desc }}">-->
<!--<input id="customRadio{{interfaceID}}" value="custom" name="validationSet{{interfaceID}}" type="radio"-->
<!--(change)="chooseValSet(false)">-->
<!--<span class="uk-margin-small-left">or a custom one</span>-->
<!--</label>-->
<!--</div>-->
<!--<input id="customValidationSet{{interfaceID}}" formControlName="customValidationSet"-->
<!--class="form-control" type="text" (keyup)="checkIfValid()">-->
<!--</div>-->
<div class="md-input-wrapper md-input-filled uk-margin-medium-top"> <div class="md-input-wrapper md-input-filled uk-margin-medium-top">
<label style="top: -16px" class="" for="compLvl" title="{{ compatibilityLevelDesc.desc }}">Desired Compatibility Level (*)</label> <label style="top: -16px" class="" for="compLvl" title="{{ compatibilityLevelDesc.desc }}">Desired Compatibility Level (*)</label>
<select class="md-input" id="compLvl" formControlName="compatibilityLevel" (change)="checkIfValid()"> <select class="md-input" id="compLvl" formControlName="desiredCompatibilityLevel" (change)="checkIfValid()">
<option value="">-- none selected --</option> <option value="">-- none selected --</option>
<option *ngFor="let key of classCodes" value="{{key}}">{{compClasses[key]}}</option> <option *ngFor="let key of classCodes" value="{{key}}">{{compClasses[key]}}</option>
</select> </select>
<span class="md-input-bar"></span> <span class="md-input-bar"></span>
</div> </div>
<!--<div class="form-group">--> <div class="uk-margin-medium-top">
<!--<label class="control-label" for="compLvl" title="{{ compatibilityLevelDesc.desc }}">Desired Compatibility Level (*)</label>-->
<!--<select class="form-control" id="compLvl" formControlName="compatibilityLevel" (change)="checkIfValid()">-->
<!--<option value="">&#45;&#45; none selected &#45;&#45;</option>-->
<!--<option *ngFor="let key of classCodes" value="{{key}}">{{compClasses[key]}}</option>-->
<!--</select>-->
<!--</div>-->
<div class="">
<label class="">Current Compatibility Level</label> <label class="">Current Compatibility Level</label>
<div *ngIf="existingCompLevel">{{ existingCompLevel ? existingCompLevel : 'not available' }}</div> <div>{{repoInterfaceForm.get('compatibilityLevel').value ? this.compClasses[repoInterfaceForm.get('compatibilityLevel').value] : 'not available' }}</div>
</div> </div>
<!--<div>--> <div class="uk-margin-medium-top">
<!--<label class="uk-form-controls-text control-label">Current Compatibility Level</label>--> <label class="">Compatibility Level Override</label>
<!--<div *ngIf="existingCompLevel">{{ existingCompLevel ? existingCompLevel : 'not available' }}</div>--> <div>{{repoInterfaceForm.get('compatibilityLevelOverride').value ? this.compClasses[repoInterfaceForm.get('compatibilityLevelOverride').value] : 'not available' }}</div>
<!--</div>--> </div>
<div class="uk-margin-medium-top"> <div class="uk-margin-medium-top">
<label class="" for="comment" title="{{ commentDesc.desc }}">Comments (What else do we need to know?)</label> <label class="" for="comment" title="{{ commentDesc.desc }}">Comments (What else do we need to know?)</label>
@ -145,5 +72,7 @@
</div> </div>
<pre>{{repoInterfaceForm.value | json}}</pre>
</div> </div>
</div> </div>

View File

@ -39,8 +39,9 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
readonly repoInterfaceFormDef = { readonly repoInterfaceFormDef = {
baseurl: ['', Validators.required], baseurl: ['', Validators.required],
selectValidationSet: [''], selectValidationSet: [''],
customValidationSet: [''], compatibilityLevel: null,
compatibilityLevel: [''], desiredCompatibilityLevel: null,
compatibilityLevelOverride: null,
comment: [''] comment: ['']
}; };
baseUrlDesc: Description = baseUrlDesc; baseUrlDesc: Description = baseUrlDesc;
@ -68,11 +69,12 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
this.interfaceID = this.data[1]; this.interfaceID = this.data[1];
this.currentRepo = this.data[2]; this.currentRepo = this.data[2];
this.repoInterfaceForm = this.fb.group(this.repoInterfaceFormDef); this.repoInterfaceForm = this.fb.group(this.repoInterfaceFormDef);
this.chooseValSet(true); // this.chooseValSet(true);
if (this.data[3]) { if (this.data[3]) {
this.currentInterface = this.data[3]; this.currentInterface = this.data[3];
this.repoInterfaceForm.get('baseurl').setValue(this.currentInterface.baseurl); this.repoInterfaceForm.get('baseurl').setValue(this.currentInterface.baseurl);
this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibilityOverride); this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibility);
this.repoInterfaceForm.get('compatibilityLevelOverride').setValue(this.currentInterface.compatibilityOverride);
} }
this.getInterfaceInfo(); this.getInterfaceInfo();
this.getCompatibilityClasses(); this.getCompatibilityClasses();
@ -110,17 +112,17 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
this.errorMessage = noServiceMessage; this.errorMessage = noServiceMessage;
}, },
() => { () => {
if ( this.currentInterface && this.currentInterface.apiParams && this.currentInterface.apiParams.find(entry => entry.param === 'set')) { if (this.currentInterface?.apiParams?.find(entry => entry.param === 'set')) {
if ( this.valsetList.some( x => x === this.currentInterface.apiParams['set']) ) { // it will not work if set is not on valsetList
this.repoInterfaceForm.get('selectValidationSet').setValue(this.currentInterface.apiParams.find(entry => entry.param === 'set').value); if (this.valsetList.some(x => x === this.currentInterface.apiParams['set'])) {
} else { this.repoInterfaceForm.get('selectValidationSet').setValue(this.currentInterface.apiParams
this.repoInterfaceForm.get('customValidationSet').setValue(this.currentInterface.apiParams.find(entry => entry.param === 'set').value); .find(entry => entry.param === 'set').value);
}
} }
this.loadingMessage = ''; this.loadingMessage = '';
this.repoInterfaceForm.updateValueAndValidity(); this.repoInterfaceForm.updateValueAndValidity();
this.checkIfValid(); this.checkIfValid();
} }
}
); );
} }
} }
@ -148,37 +150,23 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
getExistingCompatibilityLevel() { getExistingCompatibilityLevel() {
if (this.currentInterface) { if (this.currentInterface) {
if (this.currentInterface.compatibilityOverride && if (this.currentInterface.compatibility
this.classCodes.some( x => x === this.currentInterface.compatibilityOverride ) ) { && this.classCodes.some( x => x === this.currentInterface.compatibilityOverride)) {
this.existingCompLevel = this.compClasses[this.currentInterface.compatibilityOverride]; this.existingCompLevel = this.compClasses[this.currentInterface.compatibility];
} else { } else {
this.repoInterfaceForm.get('compatibilityLevel').setValue(''); // this.repoInterfaceForm.get('compatibilityLevel').setValue('');
this.existingCompLevel = this.currentInterface.compatibilityOverride; this.existingCompLevel = this.currentInterface.compatibility;
} }
} }
} }
chooseValSet(fromList: boolean) {
this.existingValSet = fromList;
if (this.existingValSet) {
this.repoInterfaceForm.get('selectValidationSet').enable();
this.repoInterfaceForm.get('customValidationSet').disable();
} else {
this.repoInterfaceForm.get('selectValidationSet').disable();
this.repoInterfaceForm.get('customValidationSet').enable();
}
this.checkIfValid();
}
checkIfCompatibilityLevelWasChosen() { checkIfCompatibilityLevelWasChosen() {
return ( (this.repoInterfaceForm.get('compatibilityLevel').value !== '') || return ( (this.repoInterfaceForm.get('compatibilityLevel').value !== '') ||
(this.existingCompLevel && (this.existingCompLevel !== '')) ); (this.existingCompLevel && (this.existingCompLevel !== '')) );
} }
formIsValid() { formIsValid() {
return (this.repoInterfaceForm.valid && return (this.repoInterfaceForm.valid && this.identifiedBaseUrl && this.checkIfCompatibilityLevelWasChosen());
this.identifiedBaseUrl &&
this.checkIfCompatibilityLevelWasChosen());
} }
checkIfValid() { checkIfValid() {
@ -203,24 +191,21 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
let valset = ''; let valset = '';
if (this.existingValSet) { if (this.existingValSet) {
valset = this.repoInterfaceForm.get('selectValidationSet').value; valset = this.repoInterfaceForm.get('selectValidationSet').value;
} else {
valset = this.repoInterfaceForm.get('customValidationSet').value;
} }
let compLvl = ''; let desiredCompLvl = '';
if (this.repoInterfaceForm.get('compatibilityLevel').value) { if (this.repoInterfaceForm.get('compatibilityLevel').value) {
this.existingCompLevel = this.compClasses[this.repoInterfaceForm.get('compatibilityLevel').value]; // this.existingCompLevel = this.compClasses[this.repoInterfaceForm.get('compatibilityLevel').value];
console.log('this.existingCompLevel is', this.existingCompLevel); // console.log('this.existingCompLevel is', this.existingCompLevel);
compLvl = this.repoInterfaceForm.get('compatibilityLevel').value; desiredCompLvl = this.repoInterfaceForm.get('compatibilityLevel').value;
} else {
compLvl = this.existingCompLevel;
} }
const compLvl = this.existingCompLevel;
let comment = ''; let comment = '';
if (this.repoInterfaceForm.get('comment').value) { if (this.repoInterfaceForm.get('comment').value) {
comment = this.repoInterfaceForm.get('comment').value; comment = this.repoInterfaceForm.get('comment').value;
} }
if (this.currentInterface) { if (this.currentInterface) {
this.updateCurrent(baseurl, valset, compLvl, comment); this.updateCurrent(baseurl, valset, desiredCompLvl, compLvl, comment);
} else { } else {
this.addCurrent(baseurl, valset, compLvl, comment); this.addCurrent(baseurl, valset, compLvl, comment);
} }
@ -257,7 +242,7 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
validationSet = new ApiParamDetails('set', value); validationSet = new ApiParamDetails('set', value);
intrf.apiParams.push(validationSet); intrf.apiParams.push(validationSet);
} else { } else {
validationSet.value = this.repoInterfaceForm.get(this.existingValSet ? 'selectValidationSet' : 'customValidationSet').value; validationSet.value = this.repoInterfaceForm.get('selectValidationSet').value;
} }
} }
@ -282,11 +267,8 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
addInterface(newInterface: RepositoryInterface) { addInterface(newInterface: RepositoryInterface) {
this.loadingMessage = formSubmitting; this.loadingMessage = formSubmitting;
this.repoService.addInterface(this.currentRepo.datasourceType, this.repoService.addInterface(this.currentRepo.datasourceType, this.currentRepo.id,
this.currentRepo.id, this.currentRepo.registeredBy, this.currentRepo.comments, newInterface).subscribe(
this.currentRepo.registeredBy,
this.currentRepo.comments,
newInterface).subscribe(
addedInterface => { addedInterface => {
console.log(`addInterface responded ${JSON.stringify(addedInterface)}`); console.log(`addInterface responded ${JSON.stringify(addedInterface)}`);
this.currentInterface = addedInterface; this.currentInterface = addedInterface;
@ -310,7 +292,7 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
} }
updateCurrent (baseurl: string, valset: string, compLvl: string, comment: string) { updateCurrent (baseurl: string, valset: string, desiredCompLvl: string, compLvl: string, comment: string) {
console.log('update current'); console.log('update current');
this.updateValidationSet(this.currentInterface, valset); this.updateValidationSet(this.currentInterface, valset);
this.currentInterface.baseurl = baseurl; this.currentInterface.baseurl = baseurl;
@ -320,7 +302,7 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
this.currentInterface.comments = comment; this.currentInterface.comments = comment;
if (!this.inRegister) { if (!this.inRegister) {
this.updateInterface(); this.updateInterface(desiredCompLvl);
} else { } else {
this.successMessage = 'The harvesting settings are valid!'; this.successMessage = 'The harvesting settings are valid!';
console.log('SAVED !'); console.log('SAVED !');
@ -328,12 +310,10 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
} }
} }
updateInterface() { updateInterface(desiredCompatibilityLevel: string) {
this.loadingMessage = formSubmitting; this.loadingMessage = formSubmitting;
this.repoService.updateInterface(this.currentRepo.id, this.repoService.updateInterface(this.currentRepo.id, this.currentRepo.registeredBy, this.currentRepo.comments,
this.currentRepo.registeredBy, this.currentInterface, this.repoInterfaceForm.get('desiredCompatibilityLevel').value).subscribe(
this.currentRepo.comments,
this.currentInterface).subscribe(
response => { response => {
console.log(`updateRepository responded ${JSON.stringify(response)}`); console.log(`updateRepository responded ${JSON.stringify(response)}`);
if (response) { if (response) {