- enforce: new FormControl(true, [Validators.required]),
- windowLength: new FormControl('', [Validators.required, Validators.pattern(windowLengthPattern)]),
- blockingRate: new FormControl('', [Validators.required, Validators.pattern(blockingRatePattern)]),
- triggerThreshold: new FormControl('', [Validators.required, Validators.pattern(triggerPattern)])
+ // Names must match the ACAdmissionIntervalControl interface
+ enforce: new FormControl(true, [Validators.required]),
+ class: new FormControl('', [Validators.required, Validators.min(1), Validators.max(256)]),
+ window_length: new FormControl('', [Validators.required, Validators.min(15), Validators.max(300)]),
+ blocking_rate: new FormControl('', [Validators.required, Validators.min(0), Validators.max(100)]),
+ trigger_threshold: new FormControl('', [Validators.required, Validators.min(1)])
+ });
+
+ this.instanceChange = this.instanceSelectorService.getSelectedInstance().subscribe((instance: RicInstance) => {
+ if (instance.key) {
+ // TODO: show pending action indicator
+ this.instanceKey = instance.key;
+ this.acXappService.getPolicy(instance.key).subscribe((res: ACAdmissionIntervalControl) => {
+ this.acForm.controls['class'].setValue(res.class);
+ this.acForm.controls['enforce'].setValue(res.enforce);
+ this.acForm.controls['window_length'].setValue(res.window_length);
+ this.acForm.controls['blocking_rate'].setValue(res.blocking_rate);
+ this.acForm.controls['trigger_threshold'].setValue(res.trigger_threshold);
+ // TODO: clear pending action indicator
+ },
+ (error: HttpErrorResponse) => {
+ // TODO: clear pending action indicator
+ this.errorDialogService.displayError(error.message);
+ });
+ }