Skip to content

Commit

Permalink
NAS-130452 / 24.10 / Network Interfaces | Set min seconds to be >= 10…
Browse files Browse the repository at this point in the history
… seconds at least & Allow numbers only (#10404)

* NAS-130452: Network Interfaces | Set min seconds to be >= 10 seconds at least & Allow numbers only

* NAS-130452: Network Interfaces | Set min seconds to be >= 10 seconds at least & Allow numbers only

* NAS-130452: Network Interfaces | Set min seconds to be >= 10 seconds at least & Allow numbers only

* NAS-130452: PR Update

* NAS-130452: PR Update
  • Loading branch information
AlexKarpov98 authored Aug 8, 2024
1 parent b843a33 commit fa06c8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/app/pages/network/network.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,29 @@
@if (!checkinWaiting) {
<div>
<p>{{ helptext.pending_changes_text | translate }}</p>

<p>
{{ helptext.checkin_text | translate }}
<mat-form-field floatPlaceholder="never" id="timeout-field">
<input
#checkinTimeoutField="ngModel"
matInput
type="number"
ixTest="checkin-timeout"
required
[min]="checkinTimeoutMinValue"
[pattern]="checkinTimeoutPattern"
[(ngModel)]="checkinTimeout"
/>
</mat-form-field>
{{ helptext.checkin_text_2 | translate }}
</p>

<mat-error *ngIf="!checkinTimeout || checkinTimeoutField.errors?.min || checkinTimeoutField.errors?.pattern">
<span>
{{ 'Invalid value. Must be greater than or equal to ' | translate }} {{ checkinTimeoutMinValue }}
</span>
</mat-error>
</div>
} @else {
<div>
Expand All @@ -37,7 +48,7 @@
<button
mat-button
ixTest="test-changes"
[disabled]="isHaEnabled"
[disabled]="isHaEnabled || isCheckinTimeoutFieldInvalid"
(click)="commitPendingChanges()"
>
{{ helptext.commit_button | translate }}
Expand Down
11 changes: 10 additions & 1 deletion src/app/pages/network/network.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
Component, Inject, OnInit, ChangeDetectionStrategy, ChangeDetectorRef,
ViewChild,
} from '@angular/core';
import { NgModel } from '@angular/forms';
import { Navigation, Router } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Actions, ofType } from '@ngrx/effects';
Expand Down Expand Up @@ -41,11 +43,14 @@ import { networkInterfacesChanged } from 'app/store/network-interfaces/network-i
export class NetworkComponent implements OnInit {
protected readonly searchableElements = networkElements;

@ViewChild('checkinTimeoutField', { static: false }) checkinTimeoutField: NgModel;

isHaEnabled = false;
hasPendingChanges = false;
checkinWaiting = false;
checkinTimeout = 60;
checkinTimeoutPattern = /\d+/;
checkinTimeoutMinValue = 10;
checkinTimeoutPattern = '^[0-9]+$';
checkinRemaining: number = null;
private uniqueIps: string[] = [];
private affectedServices: string[] = [];
Expand All @@ -54,6 +59,10 @@ export class NetworkComponent implements OnInit {
private navigation: Navigation;
helptext = helptextInterfaces;

get isCheckinTimeoutFieldInvalid(): boolean {
return this.checkinTimeoutField?.invalid;
}

constructor(
private ws: WebSocketService,
private router: Router,
Expand Down

0 comments on commit fa06c8e

Please sign in to comment.