Add validator for duration of banner message (#19057)

1.Fixes #19049

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
Shijun Sun 2023-08-01 18:31:32 +08:00 committed by GitHub
parent b496edf304
commit 39ec1e4b1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 22 deletions

View File

@ -434,17 +434,22 @@
!messageText
}">
<label>{{ 'BANNER_MESSAGE.FROM' | translate }}</label>
<input
class="date"
type="date"
id="from"
clrDate
[(ngModel)]="messageFromDate"
[ngModelOptions]="{ standalone: true }"
[disabled]="
!currentConfig.banner_message.editable ||
!messageText
" />
<clr-date-container>
<input
class="date"
type="date"
id="from"
autocomplete="off"
min="{{ currentDate | date : 'yyyy-MM-dd' }}"
max="{{ messageToDate | date : 'yyyy-MM-dd' }}"
clrDate
[(ngModel)]="messageFromDate"
[ngModelOptions]="{ standalone: true }"
[disabled]="
!currentConfig.banner_message.editable ||
!messageText
" />
</clr-date-container>
</div>
<div
class="clr-checkbox-wrapper flex ml-1"
@ -454,17 +459,21 @@
!messageText
}">
<label>{{ 'BANNER_MESSAGE.TO' | translate }}</label>
<input
class="date"
clrDate
type="date"
id="to"
[(ngModel)]="messageToDate"
[disabled]="
!currentConfig.banner_message.editable ||
!messageText
"
[ngModelOptions]="{ standalone: true }" />
<clr-date-container>
<input
class="date"
clrDate
type="date"
id="to"
min="{{ minDateForEndDay | date : 'yyyy-MM-dd' }}"
autocomplete="off"
[(ngModel)]="messageToDate"
[disabled]="
!currentConfig.banner_message.editable ||
!messageText
"
[ngModelOptions]="{ standalone: true }" />
</clr-date-container>
</div>
</div>
</div>

View File

@ -50,6 +50,8 @@ export class SystemSettingsComponent implements OnInit, OnDestroy {
messageFromDateCopy: Date;
messageToDateCopy: Date;
bannerRefreshSub: Subscription;
currentDate: Date = new Date();
minDateForEndDay: Date;
@ViewChild('systemConfigFrom') systemSettingsForm: NgForm;
@ -60,6 +62,9 @@ export class SystemSettingsComponent implements OnInit, OnDestroy {
private event: EventService
) {
this.downloadLink = CURRENT_BASE_HREF + '/systeminfo/getcert';
this.minDateForEndDay = this.messageFromDate
? this.messageFromDate
: this.currentDate;
}
ngOnInit() {