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 {
desiredCompatibilityLevel: string;
}
export class ApiParamDetails {

View File

@ -43,7 +43,7 @@
<div class="md-input-wrapper md-input-filled">
<label style="top: -16px;" class="">Select country</label>
<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 :
country.code }}
</option>

View File

@ -356,12 +356,14 @@ export class RegisterExistingDatasourceComponent implements OnInit {
req = this.repoService.deleteInterface(intrf.id, this.repo.registeredby);
} else {
// 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;
} else {
// 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(

View File

@ -246,10 +246,10 @@ export class RegisterNewDatasourceComponent implements OnInit {
concatMap(intrf => {
if (intrf.id) {
// 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 {
// 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(

View File

@ -14,7 +14,7 @@
<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 *ngIf="canEdit" (click)="removeInterface()" class="uk-margin-small-left"><i class="md-icon material-icons">clear</i></a>
</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;">
Identified
</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()">
<span class="md-input-bar"></span>
</div>
@ -75,6 +75,7 @@
</div>
<!-- <pre>{{repoInterfaceForm.value | json}}</pre>-->
<!-- <pre>{{interfaceToExport | json}}</pre>-->
</div>
</div>

View File

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