mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-14 19:51:23 +01:00
Fix a save button bug on system setting page (#13830)
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
c660727877
commit
28734d7ac4
@ -129,7 +129,7 @@ export class NewRobotComponent implements OnInit, OnDestroy {
|
||||
.pipe(finalize(() => this.loadingSystemConfig = false))
|
||||
.subscribe(res => {
|
||||
if (res && res.robot_token_duration && res.robot_token_duration.value) {
|
||||
this.systemRobot.duration = Math.floor(res.robot_token_duration.value / MINUETS_ONE_DAY);
|
||||
this.systemRobot.duration = res.robot_token_duration.value;
|
||||
this.systemExpirationDays = this.systemRobot.duration;
|
||||
}
|
||||
});
|
||||
|
@ -141,7 +141,7 @@ export class Configuration {
|
||||
this.email_insecure = new BoolValueItem(false, true);
|
||||
this.token_expiration = new NumberValueItem(30, true);
|
||||
this.robot_name_prefix = new StringValueItem("", true);
|
||||
this.robot_token_duration = new NumberValueItem(30 * (60 * 24), true);
|
||||
this.robot_token_duration = new NumberValueItem(30, true);
|
||||
this.cfg_expiration = new NumberValueItem(30, true);
|
||||
this.verify_remote_cert = new BoolValueItem(false, true);
|
||||
this.scan_all_policy = new ComplexValueItem({
|
||||
|
@ -27,7 +27,7 @@
|
||||
</clr-tooltip>
|
||||
</label>
|
||||
<input clrInput name="tokenExpiration" type="text" #tokenExpirationInput="ngModel"
|
||||
[(ngModel)]="systemSettings.token_expiration.value" required pattern="^[1-9]{1}[0-9]*$"
|
||||
[(ngModel)]="tokenExpirationValue" required pattern="^[1-9]{1}[0-9]*$"
|
||||
id="tokenExpiration" size="20" [disabled]="!editable" />
|
||||
<clr-control-error>{{'TOOLTIP.NUMBER_REQUIRED' | translate}}</clr-control-error>
|
||||
|
||||
@ -58,12 +58,12 @@
|
||||
</clr-tooltip>
|
||||
</label>
|
||||
<input clrInput name="robotTokenExpiration" type="text" #robotTokenExpirationInput="ngModel"
|
||||
(ngModelChange)="changeToken($event)" [(ngModel)]="robotTokenExpiration" required
|
||||
[(ngModel)]="robotTokenExpirationValue" required
|
||||
pattern="^[1-9]{1}[0-9]*$" id="robotTokenExpiration" size="20" [disabled]="!robotExpirationEditable" />
|
||||
<clr-control-error>{{'ROBOT_ACCOUNT.NUMBER_REQUIRED' | translate}}</clr-control-error>
|
||||
|
||||
</clr-input-container>
|
||||
<label *ngIf="canDownloadCert" for="certDownloadLink"
|
||||
<label *ngIf="canDownloadCert"
|
||||
class="clr-control-label cert-down-label mt-1">{{'CONFIG.ROOT_CERT' | translate}}
|
||||
<clr-tooltip>
|
||||
<clr-icon clrTooltipTrigger shape="info-circle" size="24"></clr-icon>
|
||||
@ -90,7 +90,7 @@
|
||||
|
||||
|
||||
<div class="clr-form-control d-f">
|
||||
<label for="systemAllowlist"
|
||||
<label
|
||||
class="clr-control-label">{{'CVE_ALLOWLIST.DEPLOYMENT_SECURITY'|translate}}</label>
|
||||
<div class="form-content">
|
||||
<div class="font-size-13">
|
||||
@ -142,8 +142,7 @@
|
||||
</div>
|
||||
<div class="clr-col padding-top-8">
|
||||
<div class="clr-row expire-data">
|
||||
<label class="bottom-line clr-col-4"
|
||||
for="expires">{{'CVE_ALLOWLIST.EXPIRES_AT'|translate}}</label>
|
||||
<label class="bottom-line clr-col-4">{{'CVE_ALLOWLIST.EXPIRES_AT'|translate}}</label>
|
||||
<div>
|
||||
<input #dateInput placeholder="{{'CVE_ALLOWLIST.NEVER_EXPIRES'|translate}}" readonly
|
||||
type="date" [(clrDate)]="expiresDate" newFormLayout="true">
|
||||
|
@ -25,8 +25,6 @@ import {
|
||||
import {forkJoin} from "rxjs";
|
||||
|
||||
const fakePass = 'aWpLOSYkIzJTTU4wMDkx';
|
||||
const ONE_HOUR_MINUTES: number = 60;
|
||||
const ONE_DAY_MINUTES: number = 24 * ONE_HOUR_MINUTES;
|
||||
const ONE_THOUSAND: number = 1000;
|
||||
const CVE_DETAIL_PRE_URL = `https://nvd.nist.gov/vuln/detail/`;
|
||||
const TARGET_BLANK = "_blank";
|
||||
@ -82,6 +80,20 @@ export class SystemSettingsComponent implements OnChanges, OnInit {
|
||||
this.systemSettings.robot_token_duration.editable;
|
||||
}
|
||||
|
||||
get tokenExpirationValue() {
|
||||
return this.systemSettings.token_expiration.value;
|
||||
}
|
||||
set tokenExpirationValue(v) {
|
||||
// convert string to number
|
||||
this.systemSettings.token_expiration.value = +v;
|
||||
}
|
||||
get robotTokenExpirationValue() {
|
||||
return this.systemSettings.robot_token_duration.value;
|
||||
}
|
||||
set robotTokenExpirationValue(v) {
|
||||
// convert string to number
|
||||
this.systemSettings.robot_token_duration.value = +v;
|
||||
}
|
||||
robotNamePrefixEditable(): boolean {
|
||||
return this.systemSettings &&
|
||||
this.systemSettings.robot_name_prefix &&
|
||||
@ -217,7 +229,6 @@ export class SystemSettingsComponent implements OnChanges, OnInit {
|
||||
ack.state === ConfirmationState.CONFIRMED) {
|
||||
let changes = this.getChanges();
|
||||
this.reset(changes);
|
||||
this.initRobotToken();
|
||||
if (!compareValue(this.systemAllowlistOrigin, this.systemAllowlist)) {
|
||||
this.systemAllowlist = clone(this.systemAllowlistOrigin);
|
||||
}
|
||||
@ -262,7 +273,6 @@ export class SystemSettingsComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.initRobotToken();
|
||||
this.getSystemAllowlist();
|
||||
this.getSystemInfo();
|
||||
}
|
||||
@ -292,26 +302,6 @@ export class SystemSettingsComponent implements OnChanges, OnInit {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private initRobotToken(): void {
|
||||
if (this.config &&
|
||||
this.config.robot_token_duration) {
|
||||
let robotExpiration = this.config.robot_token_duration.value;
|
||||
this.robotTokenExpiration = Math.floor(robotExpiration / ONE_DAY_MINUTES) + '';
|
||||
}
|
||||
}
|
||||
|
||||
changeToken(v: string) {
|
||||
if (!v || v === "") {
|
||||
return;
|
||||
}
|
||||
if (!(this.config &&
|
||||
this.config.robot_token_duration)) {
|
||||
return;
|
||||
}
|
||||
this.config.robot_token_duration.value = +v * ONE_DAY_MINUTES;
|
||||
}
|
||||
|
||||
deleteItem(index: number) {
|
||||
this.systemAllowlist.items.splice(index, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user