Change inputs type from text to number (#17897)

1.Fixes #17890
   2.Update isDBAuth function

Signed-off-by: AllForNothing <sshijun@vmware.com>

Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
Shijun Sun 2022-12-02 12:51:38 +08:00 committed by GitHub
parent 64c03e8679
commit 5f1dff32c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 48 deletions

View File

@ -92,7 +92,7 @@
{{ 'SYSTEM_ROBOT.ROBOT_ACCOUNT_NAV' | translate }} {{ 'SYSTEM_ROBOT.ROBOT_ACCOUNT_NAV' | translate }}
</a> </a>
<a <a
*ngIf="isLdapMode || isHttpAuthMode || isOidcMode" *ngIf="!isDBAuth()"
clrVerticalNavLink clrVerticalNavLink
routerLink="/harbor/groups" routerLink="/harbor/groups"
routerLinkActive="active"> routerLinkActive="active">

View File

@ -29,7 +29,10 @@ import { NavigatorComponent } from '../../shared/components/navigator/navigator.
import { SessionService } from '../../shared/services/session.service'; import { SessionService } from '../../shared/services/session.service';
import { AboutDialogComponent } from '../../shared/components/about-dialog/about-dialog.component'; import { AboutDialogComponent } from '../../shared/components/about-dialog/about-dialog.component';
import { SearchTriggerService } from '../../shared/components/global-search/search-trigger.service'; import { SearchTriggerService } from '../../shared/components/global-search/search-trigger.service';
import { CommonRoutes } from '../../shared/entities/shared.const'; import {
CommonRoutes,
CONFIG_AUTH_MODE,
} from '../../shared/entities/shared.const';
import { THEME_ARRAY, ThemeInterface } from '../../services/theme'; import { THEME_ARRAY, ThemeInterface } from '../../services/theme';
import { clone, DEFAULT_PAGE_SIZE } from '../../shared/units/utils'; import { clone, DEFAULT_PAGE_SIZE } from '../../shared/units/utils';
import { ThemeService } from '../../services/theme.service'; import { ThemeService } from '../../services/theme.service';
@ -70,9 +73,6 @@ export class HarborShellComponent implements OnInit, OnDestroy {
searchSub: Subscription; searchSub: Subscription;
searchCloseSub: Subscription; searchCloseSub: Subscription;
isLdapMode: boolean;
isOidcMode: boolean;
isHttpAuthMode: boolean;
showScannerInfo: boolean = false; showScannerInfo: boolean = false;
scannerDocUrl: string = SCANNERS_DOC; scannerDocUrl: string = SCANNERS_DOC;
themeArray: ThemeInterface[] = clone(THEME_ARRAY); themeArray: ThemeInterface[] = clone(THEME_ARRAY);
@ -104,13 +104,6 @@ export class HarborShellComponent implements OnInit, OnDestroy {
} }
); );
} }
if (this.appConfigService.isLdapMode()) {
this.isLdapMode = true;
} else if (this.appConfigService.isHttpAuthMode()) {
this.isHttpAuthMode = true;
} else if (this.appConfigService.isOidcMode()) {
this.isOidcMode = true;
}
this.searchSub = this.searchTrigger.searchTriggerChan$.subscribe( this.searchSub = this.searchTrigger.searchTriggerChan$.subscribe(
searchEvt => { searchEvt => {
if (searchEvt && searchEvt.trim() !== '') { if (searchEvt && searchEvt.trim() !== '') {
@ -139,6 +132,16 @@ export class HarborShellComponent implements OnInit, OnDestroy {
this.styleMode = localStorage.getItem(HAS_STYLE_MODE); this.styleMode = localStorage.getItem(HAS_STYLE_MODE);
} }
} }
isDBAuth(): boolean {
if (this.appConfigService?.configurations?.auth_mode) {
return (
this.appConfigService.configurations.auth_mode ===
CONFIG_AUTH_MODE.DB_AUTH
);
}
return true;
}
publishScrollEvent() { publishScrollEvent() {
if (this.scrollDiv && this.scrollDiv.nativeElement) { if (this.scrollDiv && this.scrollDiv.nativeElement) {
this.event.publish(HarborEvent.SCROLL, { this.event.publish(HarborEvent.SCROLL, {

View File

@ -57,13 +57,13 @@
<input <input
clrInput clrInput
name="tokenExpiration" name="tokenExpiration"
type="text" type="number"
#tokenExpirationInput="ngModel" #tokenExpirationInput="ngModel"
[(ngModel)]="tokenExpirationValue" [(ngModel)]="currentConfig.token_expiration.value"
required required
pattern="^[1-9]{1}[0-9]*$" pattern="^[1-9]{1}[0-9]*$"
id="tokenExpiration" id="tokenExpiration"
size="20" max="9999999999"
[disabled]="!editable" /> [disabled]="!editable" />
<clr-control-error>{{ <clr-control-error>{{
'TOOLTIP.NUMBER_REQUIRED' | translate 'TOOLTIP.NUMBER_REQUIRED' | translate
@ -90,13 +90,13 @@
<input <input
clrInput clrInput
name="sessionTimeout" name="sessionTimeout"
type="text" type="number"
#ngSessionTimeout="ngModel" #ngSessionTimeout="ngModel"
[(ngModel)]="sessionTimeout" [(ngModel)]="currentConfig.session_timeout.value"
required required
pattern="^[1-9]{1}[0-9]*$" pattern="^[1-9]{1}[0-9]*$"
id="sessionTimeout" id="sessionTimeout"
size="10" max="9999999999"
[disabled]="!editable" /> [disabled]="!editable" />
<clr-control-error>{{ <clr-control-error>{{
'TOOLTIP.NUMBER_REQUIRED' | translate 'TOOLTIP.NUMBER_REQUIRED' | translate
@ -155,13 +155,13 @@
<input <input
clrInput clrInput
name="robotTokenExpiration" name="robotTokenExpiration"
type="text" type="number"
#robotTokenExpirationInput="ngModel" #robotTokenExpirationInput="ngModel"
[(ngModel)]="robotTokenExpirationValue" [(ngModel)]="currentConfig.robot_token_duration.value"
required required
pattern="^[1-9]{1}[0-9]*$" pattern="^[1-9]{1}[0-9]*$"
id="robotTokenExpiration" id="robotTokenExpiration"
size="20" max="9999999999"
[disabled]="!robotExpirationEditable" /> [disabled]="!robotExpirationEditable" />
<clr-control-error>{{ <clr-control-error>{{
'ROBOT_ACCOUNT.NUMBER_REQUIRED' | translate 'ROBOT_ACCOUNT.NUMBER_REQUIRED' | translate

View File

@ -154,3 +154,14 @@
.pro-creation { .pro-creation {
width: 12rem; width: 12rem;
} }
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
appearance: textfield;
}

View File

@ -56,33 +56,6 @@ export class SystemSettingsComponent implements OnInit {
); );
} }
get tokenExpirationValue() {
return this.currentConfig.token_expiration.value;
}
set tokenExpirationValue(v) {
// convert string to number
this.currentConfig.token_expiration.value = +v;
}
get sessionTimeout() {
return this.currentConfig.session_timeout.value;
}
set sessionTimeout(v) {
// convert string to number
this.currentConfig.session_timeout.value = +v;
}
get robotTokenExpirationValue() {
return this.currentConfig.robot_token_duration.value;
}
set robotTokenExpirationValue(v) {
// convert string to number
this.currentConfig.robot_token_duration.value = +v;
}
robotNamePrefixEditable(): boolean { robotNamePrefixEditable(): boolean {
return ( return (
this.currentConfig && this.currentConfig &&