mirror of
https://github.com/goharbor/harbor
synced 2025-04-20 16:28:56 +00:00
Merge pull request #4189 from pengpengshui/batchDelection
Delete username and possword in replication rule
This commit is contained in:
commit
ec5c2f0b85
|
@ -225,7 +225,6 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
openAddMemberModal(): void {
|
openAddMemberModal(): void {
|
||||||
this.memberForm.reset();
|
|
||||||
this.member = new Member();
|
this.member = new Member();
|
||||||
this.addMemberOpened = true;
|
this.addMemberOpened = true;
|
||||||
this.hasChanged = false;
|
this.hasChanged = false;
|
||||||
|
@ -234,6 +233,9 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
|
||||||
this.isMemberNameValid = true;
|
this.isMemberNameValid = true;
|
||||||
this.memberTooltip = 'MEMBER.USERNAME_IS_REQUIRED';
|
this.memberTooltip = 'MEMBER.USERNAME_IS_REQUIRED';
|
||||||
this.selectUserName = [];
|
this.selectUserName = [];
|
||||||
|
setTimeout(() => {
|
||||||
|
setInterval(() => this.ref.markForCheck(), 200);
|
||||||
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleValidation(): void {
|
handleValidation(): void {
|
||||||
|
|
|
@ -19,12 +19,12 @@
|
||||||
<clr-dropdown id='member-action' [clrCloseMenuOnItemClick]="false" class="btn btn-sm btn-secondary" clrDropdownTrigger>
|
<clr-dropdown id='member-action' [clrCloseMenuOnItemClick]="false" class="btn btn-sm btn-secondary" clrDropdownTrigger>
|
||||||
<span>{{'MEMBER.ACTION' | translate}}<clr-icon shape="caret down"></clr-icon></span>
|
<span>{{'MEMBER.ACTION' | translate}}<clr-icon shape="caret down"></clr-icon></span>
|
||||||
<clr-dropdown-menu *clrIfOpen>
|
<clr-dropdown-menu *clrIfOpen>
|
||||||
<button class="btn btn-sm btn-secondary" (click)="changeRole(selectedRow, 1)" [disabled]="!(selectedRow.length && hasProjectAdminRole)">{{'MEMBER.PROJECT_ADMIN' | translate}}</button>
|
<button class="btn btn-sm btn-secondary" (click)="changeRole(selectedRow, 1)" [disabled]="!(selectedRow.length && hasProjectAdminRole) || onlySelf">{{'MEMBER.PROJECT_ADMIN' | translate}}</button>
|
||||||
<button class="btn btn-sm btn-secondary" (click)="changeRole(selectedRow, 2)" [disabled]="!(selectedRow.length && hasProjectAdminRole)">{{'MEMBER.DEVELOPER' | translate}}</button>
|
<button class="btn btn-sm btn-secondary" (click)="changeRole(selectedRow, 2)" [disabled]="!(selectedRow.length && hasProjectAdminRole) || onlySelf">{{'MEMBER.DEVELOPER' | translate}}</button>
|
||||||
<button class="btn btn-sm btn-secondary" (click)="changeRole(selectedRow, 3)" [disabled]="!(selectedRow.length && hasProjectAdminRole)">{{'MEMBER.GUEST' | translate}}</button>
|
<button class="btn btn-sm btn-secondary" (click)="changeRole(selectedRow, 3)" [disabled]="!(selectedRow.length && hasProjectAdminRole) || onlySelf">{{'MEMBER.GUEST' | translate}}</button>
|
||||||
</clr-dropdown-menu>
|
</clr-dropdown-menu>
|
||||||
</clr-dropdown>
|
</clr-dropdown>
|
||||||
<button class="btn btn-sm btn-secondary" (click)="deleteMembers(selectedRow)" [disabled]="!(selectedRow.length && hasProjectAdminRole)">
|
<button class="btn btn-sm btn-secondary" (click)="deleteMembers(selectedRow)" [disabled]="!(selectedRow.length && hasProjectAdminRole) || onlySelf">
|
||||||
<span><clr-icon shape="times" size="16"></clr-icon> {{'MEMBER.REMOVE' | translate}}</span>
|
<span><clr-icon shape="times" size="16"></clr-icon> {{'MEMBER.REMOVE' | translate}}</span>
|
||||||
</button>
|
</button>
|
||||||
</clr-dg-action-bar>
|
</clr-dg-action-bar>
|
||||||
|
|
|
@ -134,6 +134,13 @@ export class MemberComponent implements OnInit, OnDestroy {
|
||||||
this.retrieve(this.projectId, "");
|
this.retrieve(this.projectId, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get onlySelf(): boolean {
|
||||||
|
if (this.selectedRow.length === 1 && this.selectedRow[0].user_id === this.currentUser.user_id) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
changeRole(m: Member[], roleId: number) {
|
changeRole(m: Member[], roleId: number) {
|
||||||
if (m && m.length) {
|
if (m && m.length) {
|
||||||
this.isDelete = false;
|
this.isDelete = false;
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {CreateEditEndpointComponent} from "harbor-ui/src/create-edit-endpoint/cr
|
||||||
|
|
||||||
const ONE_HOUR_SECONDS: number = 3600;
|
const ONE_HOUR_SECONDS: number = 3600;
|
||||||
const ONE_DAY_SECONDS: number = 24 * ONE_HOUR_SECONDS;
|
const ONE_DAY_SECONDS: number = 24 * ONE_HOUR_SECONDS;
|
||||||
const FAKE_PASSWORD = 'rjGcfuRu';
|
|
||||||
|
|
||||||
@Component ({
|
@Component ({
|
||||||
selector: 'repliction-rule',
|
selector: 'repliction-rule',
|
||||||
|
@ -53,13 +52,10 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
isRuleNameExist: boolean = false;
|
isRuleNameExist: boolean = false;
|
||||||
isSubmitOver: boolean = false;
|
isSubmitOver: boolean = false;
|
||||||
nameChecker: Subject<string> = new Subject<string>();
|
nameChecker: Subject<string> = new Subject<string>();
|
||||||
firstEndpointData: { [key: string]: string };
|
|
||||||
realEndpointData: { [key: string]: string } = this.initEndpointData();
|
|
||||||
|
|
||||||
confirmSub: Subscription;
|
confirmSub: Subscription;
|
||||||
ruleForm: FormGroup;
|
ruleForm: FormGroup;
|
||||||
copyUpdateForm: ReplicationRule;
|
copyUpdateForm: ReplicationRule;
|
||||||
|
|
||||||
emptyEndpoint = new Target();
|
emptyEndpoint = new Target();
|
||||||
|
|
||||||
@ViewChild(ListProjectModelComponent)
|
@ViewChild(ListProjectModelComponent)
|
||||||
|
@ -68,7 +64,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
@ViewChild(CreateEditEndpointComponent)
|
@ViewChild(CreateEditEndpointComponent)
|
||||||
createEditEndpointComponent: CreateEditEndpointComponent;
|
createEditEndpointComponent: CreateEditEndpointComponent;
|
||||||
|
|
||||||
|
|
||||||
baseFilterData(name: string, option: string[], state: boolean) {
|
baseFilterData(name: string, option: string[], state: boolean) {
|
||||||
return {
|
return {
|
||||||
name: name,
|
name: name,
|
||||||
|
@ -78,13 +73,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
initEndpointData(): { [key: string]: string } {
|
|
||||||
return{
|
|
||||||
userName: "",
|
|
||||||
password: ""
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(public projectService: ProjectService,
|
constructor(public projectService: ProjectService,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
|
@ -103,9 +91,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
if (!this.policyId) {
|
if (!this.policyId) {
|
||||||
res[0].unshift(this.emptyEndpoint);
|
res[0].unshift(this.emptyEndpoint);
|
||||||
this.setTarget([res[0][0]]);
|
this.setTarget([res[0][0]]);
|
||||||
this.realEndpointData.userName = res[0][0].username;
|
|
||||||
this.realEndpointData.password = FAKE_PASSWORD;
|
|
||||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!res[1]) {
|
if (!res[1]) {
|
||||||
|
@ -204,10 +189,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
this.setTarget(rule.targets);
|
this.setTarget(rule.targets);
|
||||||
this.noSelectedEndpoint = false;
|
this.noSelectedEndpoint = false;
|
||||||
|
|
||||||
this.realEndpointData.userName = rule.targets[0].username;
|
|
||||||
this.realEndpointData.password = FAKE_PASSWORD;
|
|
||||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
|
||||||
|
|
||||||
if (rule.filters) {
|
if (rule.filters) {
|
||||||
this.setFilter(rule.filters);
|
this.setFilter(rule.filters);
|
||||||
this.updateFilter(rule.filters);
|
this.updateFilter(rule.filters);
|
||||||
|
@ -280,8 +261,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
let selecedTarget: Target = this.targetList.find(target => target.id === +$event.target['value']);
|
let selecedTarget: Target = this.targetList.find(target => target.id === +$event.target['value']);
|
||||||
this.setTarget([selecedTarget]);
|
this.setTarget([selecedTarget]);
|
||||||
this.noSelectedEndpoint = false;
|
this.noSelectedEndpoint = false;
|
||||||
this.realEndpointData.userName = selecedTarget.username;
|
|
||||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,50 +423,12 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public hasFormChange(): boolean {
|
public hasFormChange(): boolean {
|
||||||
return !isEmptyObject(this.getChanges()) || !compareValue(this.firstEndpointData, this.realEndpointData);
|
return !isEmptyObject(this.getChanges());
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.inProgress = true;
|
|
||||||
let endpointId: string | number = this.ruleForm.value.targets[0].id;
|
|
||||||
let pullData: { [key: string]: string | number } = this.initEndpointData();
|
|
||||||
if (compareValue(this.firstEndpointData, this.realEndpointData)) {
|
|
||||||
this.saveRuleOpe();
|
|
||||||
}else {
|
|
||||||
if (this.realEndpointData.userName !== this.firstEndpointData.userName) {
|
|
||||||
pullData.userName = this.realEndpointData.userName;
|
|
||||||
}else {
|
|
||||||
delete pullData.userName;
|
|
||||||
}
|
|
||||||
if (this.realEndpointData.password !== this.firstEndpointData.password) {
|
|
||||||
pullData.password = this.realEndpointData.password;
|
|
||||||
}else {
|
|
||||||
delete pullData.password;
|
|
||||||
}
|
|
||||||
pullData.id = endpointId;
|
|
||||||
this.repService.pingEndpoint(pullData)
|
|
||||||
.then((res: any) => {
|
|
||||||
delete pullData.id;
|
|
||||||
this.repService.updateEndpoint(endpointId, pullData)
|
|
||||||
.then((res: any) => {
|
|
||||||
this.saveRuleOpe();
|
|
||||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
this.inProgress = false;
|
|
||||||
this.msgHandler.handleError(error);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
this.inProgress = false;
|
|
||||||
this.msgHandler.handleError('DESTINATION.TEST_CONNECTION_FAILURE');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
saveRuleOpe(): void {
|
|
||||||
// add new Replication rule
|
// add new Replication rule
|
||||||
|
this.inProgress = true;
|
||||||
let copyRuleForm: ReplicationRule = this.ruleForm.value;
|
let copyRuleForm: ReplicationRule = this.ruleForm.value;
|
||||||
copyRuleForm.trigger = this.setTriggerVaule(copyRuleForm.trigger);
|
copyRuleForm.trigger = this.setTriggerVaule(copyRuleForm.trigger);
|
||||||
if (!this.policyId) {
|
if (!this.policyId) {
|
||||||
|
@ -541,8 +482,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||||
this.targetList = res[0];
|
this.targetList = res[0];
|
||||||
this.setTarget([this.targetList[this.targetList.length - 1]]);
|
this.setTarget([this.targetList[this.targetList.length - 1]]);
|
||||||
this.noSelectedEndpoint = false;
|
this.noSelectedEndpoint = false;
|
||||||
this.realEndpointData.userName = this.targetList[this.targetList.length - 1].username;
|
|
||||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,6 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-info btn-sm addEndpoint" (click)="openModal()"><clr-icon shape="plus"></clr-icon> {{'REPLICATION.NEW' | translate}}</button>
|
<button class="btn btn-info btn-sm addEndpoint" (click)="openModal()"><clr-icon shape="plus"></clr-icon> {{'REPLICATION.NEW' | translate}}</button>
|
||||||
<div [hidden]="noSelectedEndpoint">userName: <input type="text" [(ngModel)]="realEndpointData.userName" [ngModelOptions]="{standalone:true}"></div>
|
|
||||||
<div [hidden]="noSelectedEndpoint">password: <input type="password" [(ngModel)]="realEndpointData.password" [ngModelOptions]="{standalone:true}"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -72,31 +72,4 @@ export class ReplicationRuleServie {
|
||||||
.catch(error => Promise.reject(error));
|
.catch(error => Promise.reject(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateEndpoint(endpointId: number | string, endpoint: any): Promise<any> | any {
|
|
||||||
if (!endpointId || endpointId <= 0) {
|
|
||||||
return Promise.reject('Bad request argument.');
|
|
||||||
}
|
|
||||||
if (!endpoint) {
|
|
||||||
return Promise.reject('Invalid endpoint.');
|
|
||||||
}
|
|
||||||
let requestUrl: string = `/api/targets/${endpointId}`;
|
|
||||||
return this.http
|
|
||||||
.put(requestUrl, JSON.stringify(endpoint), HTTP_JSON_OPTIONS)
|
|
||||||
.toPromise()
|
|
||||||
.then(response=>response.status)
|
|
||||||
.catch(error=>Promise.reject(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
public pingEndpoint(endpoint: any): Promise<any> | any {
|
|
||||||
if (!endpoint) {
|
|
||||||
return Promise.reject('Invalid endpoint.');
|
|
||||||
}
|
|
||||||
let requestUrl: string = `/api/targets/ping`;
|
|
||||||
return this.http
|
|
||||||
.post(requestUrl, endpoint, HTTP_JSON_OPTIONS)
|
|
||||||
.toPromise()
|
|
||||||
.then(response=>response.status)
|
|
||||||
.catch(error=>Promise.reject(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user