mirror of
https://github.com/goharbor/harbor
synced 2025-04-13 16:53:43 +00:00
Improve user setting component (#16665)
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
bb6693b496
commit
185d38cf49
|
@ -93,7 +93,7 @@
|
||||||
<span class="spinner spinner-inline loading-top" [hidden]="showProgress === false"></span>
|
<span class="spinner spinner-inline loading-top" [hidden]="showProgress === false"></span>
|
||||||
<button type="button" id="cancel-btn" class="btn btn-outline" (click)="close()">{{'BUTTON.CANCEL' | translate}}</button>
|
<button type="button" id="cancel-btn" class="btn btn-outline" (click)="close()">{{'BUTTON.CANCEL' | translate}}</button>
|
||||||
|
|
||||||
<button type="button" id="submit-btn" class="btn btn-primary" [disabled]="!isValid || showProgress"
|
<button type="button" id="submit-btn" class="btn btn-primary" [disabled]="!isValid || showProgress || !isUserDataChange()"
|
||||||
(click)="submit()">{{'BUTTON.OK' | translate}}</button>
|
(click)="submit()">{{'BUTTON.OK' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
</clr-modal>
|
</clr-modal>
|
||||||
|
|
|
@ -12,10 +12,9 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { ChangeDetectorRef } from '@angular/core';
|
import { AfterViewChecked, Component, OnInit, ViewChild } from "@angular/core";
|
||||||
import { Component, OnInit, ViewChild, AfterViewChecked } from "@angular/core";
|
|
||||||
import { NgForm } from "@angular/forms";
|
import { NgForm } from "@angular/forms";
|
||||||
import { Router, NavigationExtras } from "@angular/router";
|
import { NavigationExtras, Router } from "@angular/router";
|
||||||
import { SessionUser } from "../../shared/entities/session-user";
|
import { SessionUser } from "../../shared/entities/session-user";
|
||||||
import { SessionService } from "../../shared/services/session.service";
|
import { SessionService } from "../../shared/services/session.service";
|
||||||
import { MessageHandlerService } from "../../shared/services/message-handler.service";
|
import { MessageHandlerService } from "../../shared/services/message-handler.service";
|
||||||
|
@ -63,20 +62,26 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||||
@ViewChild("copyInput") copyInput: CopyInputComponent;
|
@ViewChild("copyInput") copyInput: CopyInputComponent;
|
||||||
showInputSecret: boolean = false;
|
showInputSecret: boolean = false;
|
||||||
showConfirmSecret: boolean = false;
|
showConfirmSecret: boolean = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private session: SessionService,
|
private session: SessionService,
|
||||||
private msgHandler: MessageHandlerService,
|
private msgHandler: MessageHandlerService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private searchTrigger: SearchTriggerService,
|
private searchTrigger: SearchTriggerService,
|
||||||
private accountSettingsService: AccountSettingsModalService,
|
private accountSettingsService: AccountSettingsModalService,
|
||||||
private ref: ChangeDetectorRef
|
) {
|
||||||
) {}
|
}
|
||||||
|
|
||||||
private validationStateMap: any = {
|
private validationStateMap: any = {
|
||||||
account_settings_email: true,
|
account_settings_email: true,
|
||||||
account_settings_full_name: true
|
account_settings_full_name: true
|
||||||
};
|
};
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
this.refreshAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshAccount() {
|
||||||
// Value copy
|
// Value copy
|
||||||
this.account = Object.assign({}, this.session.getCurrentUser());
|
this.account = Object.assign({}, this.session.getCurrentUser());
|
||||||
this.originalStaticData = Object.assign({}, this.session.getCurrentUser());
|
this.originalStaticData = Object.assign({}, this.session.getCurrentUser());
|
||||||
|
@ -304,6 +309,10 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||||
this.isOnCalling = false;
|
this.isOnCalling = false;
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
this.msgHandler.showSuccess("PROFILE.SAVE_SUCCESS");
|
this.msgHandler.showSuccess("PROFILE.SAVE_SUCCESS");
|
||||||
|
// get user info from back-end then refresh account
|
||||||
|
this.session.retrieveUser().subscribe(() => {
|
||||||
|
this.refreshAccount();
|
||||||
|
});
|
||||||
}, error => {
|
}, error => {
|
||||||
this.isOnCalling = false;
|
this.isOnCalling = false;
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
@ -325,6 +334,7 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||||
this.renameConfirmation = false;
|
this.renameConfirmation = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmYes($event: any): void {
|
confirmYes($event: any): void {
|
||||||
if (this.RenameOnGoing) {
|
if (this.RenameOnGoing) {
|
||||||
this.RenameOnGoing = false;
|
this.RenameOnGoing = false;
|
||||||
|
@ -335,12 +345,15 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||||
this.inlineAlert.close();
|
this.inlineAlert.close();
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSuccess(event) {
|
onSuccess(event) {
|
||||||
this.inlineAlert.showInlineSuccess({message: 'PROFILE.COPY_SUCCESS'});
|
this.inlineAlert.showInlineSuccess({message: 'PROFILE.COPY_SUCCESS'});
|
||||||
}
|
}
|
||||||
|
|
||||||
onError(event) {
|
onError(event) {
|
||||||
this.inlineAlert.showInlineError({message: 'PROFILE.COPY_ERROR'});
|
this.inlineAlert.showInlineError({message: 'PROFILE.COPY_ERROR'});
|
||||||
}
|
}
|
||||||
|
|
||||||
generateCli(userId): void {
|
generateCli(userId): void {
|
||||||
let generateCliMessage = new ConfirmationMessage(
|
let generateCliMessage = new ConfirmationMessage(
|
||||||
'PROFILE.CONFIRM_TITLE_CLI_GENERATE',
|
'PROFILE.CONFIRM_TITLE_CLI_GENERATE',
|
||||||
|
@ -351,9 +364,11 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||||
ConfirmationButtons.CONFIRM_CANCEL);
|
ConfirmationButtons.CONFIRM_CANCEL);
|
||||||
this.confirmationDialogComponent.open(generateCliMessage);
|
this.confirmationDialogComponent.open(generateCliMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
showGenerateCliFn() {
|
showGenerateCliFn() {
|
||||||
this.showGenerateCli = !this.showGenerateCli;
|
this.showGenerateCli = !this.showGenerateCli;
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmGenerate(event): void {
|
confirmGenerate(event): void {
|
||||||
this.account.oidc_user_meta.secret = randomWord(9);
|
this.account.oidc_user_meta.secret = randomWord(9);
|
||||||
this.resetCliSecret(this.account.oidc_user_meta.secret);
|
this.resetCliSecret(this.account.oidc_user_meta.secret);
|
||||||
|
@ -369,14 +384,17 @@ export class AccountSettingsModalComponent implements OnInit, AfterViewChecked {
|
||||||
this.resetSecretInlineAlert.showInlineError({message: 'PROFILE.GENERATE_ERROR'});
|
this.resetSecretInlineAlert.showInlineError({message: 'PROFILE.GENERATE_ERROR'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
disableChangeCliSecret() {
|
disableChangeCliSecret() {
|
||||||
return this.resetSecretFrom.invalid || (this.resetSecretFrom.value.input_secret !== this.resetSecretFrom.value.confirm_secret);
|
return this.resetSecretFrom.invalid || (this.resetSecretFrom.value.input_secret !== this.resetSecretFrom.value.confirm_secret);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeReset() {
|
closeReset() {
|
||||||
this.showSecretDetail = false;
|
this.showSecretDetail = false;
|
||||||
this.showGenerateCliFn();
|
this.showGenerateCliFn();
|
||||||
this.resetSecretFrom.resetForm(new ResetSecret());
|
this.resetSecretFrom.resetForm(new ResetSecret());
|
||||||
}
|
}
|
||||||
|
|
||||||
openSecretDetail() {
|
openSecretDetail() {
|
||||||
this.showSecretDetail = true;
|
this.showSecretDetail = true;
|
||||||
this.resetSecretInlineAlert.close();
|
this.resetSecretInlineAlert.close();
|
||||||
|
|
|
@ -35,7 +35,7 @@ const signOffEndpoint = "/c/log_out";
|
||||||
const accountEndpoint = CURRENT_BASE_HREF + "/users/:id";
|
const accountEndpoint = CURRENT_BASE_HREF + "/users/:id";
|
||||||
const langEndpoint = "/language";
|
const langEndpoint = "/language";
|
||||||
const userExistsEndpoint = "/c/userExists";
|
const userExistsEndpoint = "/c/userExists";
|
||||||
const renameAdminEndpoint = CURRENT_BASE_HREF + '/internal/renameadmin';
|
const renameAdminEndpoint = 'api/internal/renameadmin';
|
||||||
const langMap = {
|
const langMap = {
|
||||||
"zh": "zh-CN",
|
"zh": "zh-CN",
|
||||||
"en": "en-US"
|
"en": "en-US"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user