Commit 85390472 authored by Alicja Reniewicz's avatar Alicja Reniewicz
Browse files

default applicationId in deployment form, change info about error by getting deployment difference

parent 8dff18d4
......@@ -78,6 +78,9 @@ export class DeployingFormComponent implements OnInit {
this.deploymentService.getUploadedModels().subscribe(
value => {
this.applicationIds = value;
if (this.applicationIds.length > 0) {
this.form.applicationId.setValue(this.applicationIds[0]);
}
this.xmiModelsLoadingInProgress = false;
},
error1 => {
......
......@@ -37,8 +37,13 @@ export class DeploymentDifferenceComponent implements OnInit {
this.differenceAfterSolutionDownloaded = true;
},
error1 => {
this.snackBar.open(`Problem by getting deployment difference: ${error1.error.message}`, 'Close');
this.loadingDataInProgress = false;
if (error1.error.status === 404) {
console.log(`Deployment difference not created yet: ${error1.error.message}`);
this.loadingDataInProgress = false;
} else {
this.snackBar.open(`Problem by getting deployment difference: ${error1.error.message}`, 'Close');
this.loadingDataInProgress = false;
}
});
}
}
......@@ -6,6 +6,10 @@
<mat-card>
<mat-form-field>
<input matInput formControlName="endpoint" placeholder="endpoint">
<mat-error
*ngIf="form.endpoint.hasError('missingEndpoint')">
{{getMissingEndpointMessage()}}
</mat-error>
</mat-form-field>
<mat-form-field class="halfWidthField">
......
......@@ -10,6 +10,7 @@ import {CloudPropertyFormComponent} from '../cloud-property-form/cloud-property-
import {ProviderService} from '../service/provider.service';
import {ConfirmationDialogComponent} from '../../common-template/confirmation-dialog/confirmation-dialog.component';
import {credentialsUserValidator} from '../validator/credential-user.validator';
import {requiredEndpointValidator} from '../validator/required-endpoint.validator';
@Component({
selector: 'app-cloud-definition-form',
......@@ -79,8 +80,9 @@ export class CloudDefinitionFormComponent implements OnInit {
credential: this.credentialForm,
cloudConfiguration: this.cloudConfigurationForm
}, {
validators: credentialsUserValidator(this.dialogData.cloudDefinitions, this.apiForm, this.credentialForm, this.cloudData ?
this.cloudData.credential.user : '', this.cloudData ? this.cloudData.api.providerName : '')
validators: [credentialsUserValidator(this.dialogData.cloudDefinitions, this.apiForm, this.credentialForm, this.cloudData ?
this.cloudData.credential.user : '', this.cloudData ? this.cloudData.api.providerName : ''),
requiredEndpointValidator('endpoint', 'cloudType')]
});
if (this.cloudData) {
......@@ -115,6 +117,10 @@ export class CloudDefinitionFormComponent implements OnInit {
return 'Such user for this provide already exists. User for provider must be unique.';
}
getMissingEndpointMessage() {
return 'Required field for private provider';
}
saveCloudDefinition(cloudForm: NgForm) {
this.cloudConfigurationFormControl.properties.setValue(this.cloudProperties);
const cloudDefinition = <CloudDefinition> cloudForm.value;
......
import {FormGroup, ValidatorFn} from '@angular/forms';
import {CloudType} from '../model/cloud-type';
export function requiredEndpointValidator(endpointKey: string, cloudTypeKey: string): ValidatorFn {
return (group: FormGroup): { [key: string]: any } => {
const endpoint = group.controls[endpointKey];
const cloudType = group.controls[cloudTypeKey];
if (cloudType.value === CloudType[CloudType.PRIVATE] && endpoint.value.trim() === '') {
endpoint.setErrors({missingEndpoint: true});
return {missingEndpoint: true};
}
return null;
};
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment