add and update interface hopefully works now

This commit is contained in:
John Balasis 2023-01-20 16:31:18 +00:00
parent 52d3c2edc0
commit b044244685
6 changed files with 34 additions and 27 deletions

View File

@ -225,7 +225,7 @@ export class ApiDetails {
} }
export class RepositoryInterface extends ApiDetails { export class RepositoryInterface extends ApiDetails {
desiredCompatibilityLevel: string;
} }
export class ApiParamDetails { export class ApiParamDetails {

View File

@ -43,7 +43,7 @@
<div class="md-input-wrapper md-input-filled"> <div class="md-input-wrapper md-input-filled">
<label style="top: -16px;" class="">Select country</label> <label style="top: -16px;" class="">Select country</label>
<select class="md-input" (change)="getReposInCountry($event.target.value)"> <select class="md-input" (change)="getReposInCountry($event.target.value)">
<option value="" disabled>-- none selected --</option> <option value="" disabled selected>-- none selected --</option>
<option *ngFor="let country of countries; let i = index" value="{{ i }}">{{ country.name ? country.name : <option *ngFor="let country of countries; let i = index" value="{{ i }}">{{ country.name ? country.name :
country.code }} country.code }}
</option> </option>

View File

@ -356,12 +356,14 @@ export class RegisterExistingDatasourceComponent implements OnInit {
req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby); req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby);
} else { } else {
// console.log('comments', intrf.comments); // console.log('comments', intrf.comments);
req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf); req = this.repoService.updateInterface(this.repo.id, this.repo.registeredby,
intrf.comments, intrf, intrf.desiredCompatibilityLevel);
} }
return req; return req;
} else { } else {
// console.log('comments', intrf.comments); // console.log('comments', intrf.comments);
return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf); return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby,
intrf.comments, intrf, intrf.desiredCompatibilityLevel);
} }
}) })
).subscribe( ).subscribe(

View File

@ -246,10 +246,10 @@ export class RegisterNewDatasourceComponent implements OnInit {
concatMap(intrf => { concatMap(intrf => {
if (intrf.id) { if (intrf.id) {
// console.log('comments', intrf.comments); // console.log('comments', intrf.comments);
return this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf); return this.repoService.updateInterface(this.repo.id, this.repo.registeredby, intrf.comments, intrf, intrf.desiredCompatibilityLevel);
} else { } else {
// console.log('comments', intrf.comments); // console.log('comments', intrf.comments);
return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf); return this.repoService.addInterface(this.repo.eoscDatasourceType, this.repo.id, this.repo.registeredby, intrf.comments, intrf, intrf.desiredCompatibilityLevel);
} }
}) })
).subscribe( ).subscribe(

View File

@ -14,7 +14,7 @@
<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 *ngIf="canEdit" (click)="removeInterface()" class="uk-margin-small-left"><i class="md-icon material-icons">clear</i></a>
</div> </div>
</div> </div>
@ -29,7 +29,7 @@
<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" [ngClass]="{'uk-disabled': showIdentifiedBaseUrl}" <input id="baseurl" type="text" class="md-input" [ngClass]="{'uk-disabled': !canEdit}"
formControlName="baseurl" (blur)="getInterfaceInfo()"> formControlName="baseurl" (blur)="getInterfaceInfo()">
<span class="md-input-bar"></span> <span class="md-input-bar"></span>
</div> </div>
@ -75,6 +75,7 @@
</div> </div>
<!-- <pre>{{repoInterfaceForm.value | json}}</pre>--> <!-- <pre>{{repoInterfaceForm.value | json}}</pre>-->
<!-- <pre>{{interfaceToExport | json}}</pre>-->
</div> </div>
</div> </div>

View File

@ -51,6 +51,7 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
commentDesc: Description = commentDesc; commentDesc: Description = commentDesc;
identifiedBaseUrl: boolean; identifiedBaseUrl: boolean;
canEdit = true;
showIdentifiedBaseUrl: boolean; showIdentifiedBaseUrl: boolean;
valsetList: string[] = []; valsetList: string[] = [];
existingCompLevel: string; existingCompLevel: string;
@ -72,7 +73,10 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
// 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); if (this.currentInterface.baseurl !== null && this.currentInterface.baseurl !== '') {
this.canEdit = false;
this.repoInterfaceForm.get('baseurl').setValue(this.currentInterface.baseurl);
}
this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibility); this.repoInterfaceForm.get('compatibilityLevel').setValue(this.currentInterface.compatibility);
this.repoInterfaceForm.get('compatibilityLevelOverride').setValue(this.currentInterface.compatibilityOverride); this.repoInterfaceForm.get('compatibilityLevelOverride').setValue(this.currentInterface.compatibilityOverride);
this.repoService.getInterfaceDesiredCompatibilityLevel(this.currentInterface.datasource, this.currentInterface.id).subscribe( this.repoService.getInterfaceDesiredCompatibilityLevel(this.currentInterface.datasource, this.currentInterface.id).subscribe(
@ -182,7 +186,7 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
} }
} else { } else {
this.successMessage = ''; this.successMessage = '';
this.interfaceToExport = null; // this.interfaceToExport = null;
} }
} }
@ -190,7 +194,6 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
saveInterface() { saveInterface() {
this.errorMessage = ''; this.errorMessage = '';
this.successMessage = ''; this.successMessage = '';
console.log('saving interface: ' + this.currentInterface?.id);
if (this.formIsValid()) { if (this.formIsValid()) {
const baseurl = this.repoInterfaceForm.get('baseurl').value; const baseurl = this.repoInterfaceForm.get('baseurl').value;
let valset = ''; let valset = '';
@ -201,7 +204,8 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
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);
desiredCompLvl = this.repoInterfaceForm.get('compatibilityLevel').value; this.currentInterface.desiredCompatibilityLevel = this.repoInterfaceForm.get('desiredCompatibilityLevel').value;
desiredCompLvl = this.repoInterfaceForm.get('desiredCompatibilityLevel').value;
} }
const compLvl = this.existingCompLevel; const compLvl = this.existingCompLevel;
let comment = ''; let comment = '';
@ -212,10 +216,10 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
if (this.currentInterface) { if (this.currentInterface) {
this.updateCurrent(baseurl, valset, desiredCompLvl, compLvl, comment); this.updateCurrent(baseurl, valset, desiredCompLvl, compLvl, comment);
} else { } else {
this.addCurrent(baseurl, valset, compLvl, comment); this.addCurrent(baseurl, valset, desiredCompLvl, compLvl, comment);
} }
} else { } else {
this.interfaceToExport = null; // this.interfaceToExport = null;
this.errorMessage = 'Please make sure all required fields are filled with acceptable values.'; this.errorMessage = 'Please make sure all required fields are filled with acceptable values.';
} }
} }
@ -251,33 +255,33 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
} }
} }
addCurrent (baseurl: string, valset: string, compLvl: string, comment: string) { addCurrent (baseurl: string, valset: string, desiredCompLvl: string, compLvl: string, comment: string) {
console.log('add current'); console.log('add current');
const currentInterface = new RepositoryInterface(); this.currentInterface = new RepositoryInterface();
this.updateValidationSet(currentInterface, valset); this.updateValidationSet(this.currentInterface, valset);
currentInterface.baseurl = baseurl; this.currentInterface.baseurl = baseurl;
currentInterface.compatibilityOverride = compLvl; this.currentInterface.desiredCompatibilityLevel = desiredCompLvl;
currentInterface.compatibility = compLvl; this.currentInterface.compatibility = compLvl;
currentInterface.typology = this.currentRepo.datasourceClass; this.currentInterface.typology = this.currentRepo.datasourceClass;
currentInterface.comments = comment; this.currentInterface.comments = comment;
if (!this.inRegister) { if (!this.inRegister) {
this.addInterface(currentInterface); this.addInterface(this.currentInterface);
} else { } else {
this.successMessage = 'The harvesting settings are valid!'; this.successMessage = 'The harvesting settings are valid!';
console.log('SAVED !'); console.log('SAVED !');
this.interfaceToExport = currentInterface; this.interfaceToExport = this.currentInterface;
} }
} }
addInterface(newInterface: RepositoryInterface) { addInterface(newInterface: RepositoryInterface) {
this.loadingMessage = formSubmitting; this.loadingMessage = formSubmitting;
this.repoService.addInterface(this.currentRepo.datasourceType, this.currentRepo.id, this.repoService.addInterface(this.currentRepo.datasourceType, this.currentRepo.id,
this.currentRepo.registeredBy, this.currentRepo.comments, newInterface, this.currentRepo.registeredBy, this.currentRepo.comments, this.currentInterface,
this.repoInterfaceForm.get('desiredCompatibilityLevel').value).subscribe( this.repoInterfaceForm.get('desiredCompatibilityLevel').value).subscribe(
addedInterface => { addedInterface => {
console.log(`addInterface responded ${JSON.stringify(addedInterface)}`); console.log(`addInterface responded ${JSON.stringify(addedInterface)}`);
this.currentInterface = addedInterface; // this.currentInterface = addedInterface;
}, },
error => { error => {
console.log(error); console.log(error);
@ -302,7 +306,7 @@ export class DatasourceNewInterfaceFormComponent implements OnInit {
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;
this.currentInterface.compatibilityOverride = compLvl; this.currentInterface.desiredCompatibilityLevel = desiredCompLvl;
this.currentInterface.compatibility = compLvl; this.currentInterface.compatibility = compLvl;
this.currentInterface.typology = this.currentRepo.datasourceClass; this.currentInterface.typology = this.currentRepo.datasourceClass;
this.currentInterface.comments = comment; this.currentInterface.comments = comment;