changes for interface update form and functionality

This commit is contained in:
j.balasis92 2023-01-13 16:12:16 +00:00
parent eea5aee305
commit 509e2f035a
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);
}
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;
comment = interfaceInfo.comments; // temp fix for emailing comment
if (comment == null || comment === '') {
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}&registeredBy=${registeredBy}`;
url = `${this.apiUrl}updateRepositoryInterface?repoId=${repoId}&registeredBy=${registeredBy}$desiredCompatibilityLevel=${desiredCompatibilityLevel}`;
} 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(`sending ${JSON.stringify(interfaceInfo)}`);

View File

@ -14,129 +14,56 @@
<div class="md-card-toolbar">
<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 (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>
<!--<h3 class="md-card-toolbar-heading-text"> Card Heading </h3>-->
</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 *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,
'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' : '' }}">
<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;">
Identified
</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>
</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">
<label class="control-label">Validation 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>
<label for="selectValidationSet{{interfaceID}}" class="control-label">Set</label>
<div class="md-input-wrapper">
<!--<label class="">Select repository's country</label>-->
<select class="md-input" id="selectValidationSet{{interfaceID}}" formControlName="selectValidationSet" (change)="checkIfValid()">
<option value="" selected>-- none selected --</option>
<option *ngFor="let set of valsetList" value="{{set}}">{{set}}</option>
</select>
<span class="md-input-bar"></span>
</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 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">
<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 *ngFor="let key of classCodes" value="{{key}}">{{compClasses[key]}}</option>
</select>
<span class="md-input-bar"></span>
</div>
<!--<div class="form-group">-->
<!--<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="">
<div class="uk-margin-medium-top">
<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>-->
<!--<label class="uk-form-controls-text control-label">Current Compatibility Level</label>-->
<!--<div *ngIf="existingCompLevel">{{ existingCompLevel ? existingCompLevel : 'not available' }}</div>-->
<!--</div>-->
<div class="uk-margin-medium-top">
<label class="">Compatibility Level Override</label>
<div>{{repoInterfaceForm.get('compatibilityLevelOverride').value ? this.compClasses[repoInterfaceForm.get('compatibilityLevelOverride').value] : 'not available' }}</div>
</div>
<div class="uk-margin-medium-top">
<label class="" for="comment" title="{{ commentDesc.desc }}">Comments (What else do we need to know?)</label>
@ -145,5 +72,7 @@
</div>
<pre>{{repoInterfaceForm.value | json}}</pre>
</div>
</div>

View File

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