mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 04:35:16 +01:00
delete username and pwd in replication rule
This commit is contained in:
parent
715a49834b
commit
09c1c39cd3
@ -225,7 +225,6 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
openAddMemberModal(): void {
|
||||
this.memberForm.reset();
|
||||
this.member = new Member();
|
||||
this.addMemberOpened = true;
|
||||
this.hasChanged = false;
|
||||
@ -234,6 +233,9 @@ export class AddMemberComponent implements AfterViewChecked, OnInit, OnDestroy {
|
||||
this.isMemberNameValid = true;
|
||||
this.memberTooltip = 'MEMBER.USERNAME_IS_REQUIRED';
|
||||
this.selectUserName = [];
|
||||
setTimeout(() => {
|
||||
setInterval(() => this.ref.markForCheck(), 200);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
handleValidation(): void {
|
||||
|
@ -19,12 +19,12 @@
|
||||
<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>
|
||||
<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, 2)" [disabled]="!(selectedRow.length && hasProjectAdminRole)">{{'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, 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) || onlySelf">{{'MEMBER.DEVELOPER' | 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>
|
||||
<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>
|
||||
</button>
|
||||
</clr-dg-action-bar>
|
||||
|
@ -134,6 +134,13 @@ export class MemberComponent implements OnInit, OnDestroy {
|
||||
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) {
|
||||
if (m && m.length) {
|
||||
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_DAY_SECONDS: number = 24 * ONE_HOUR_SECONDS;
|
||||
const FAKE_PASSWORD = 'rjGcfuRu';
|
||||
|
||||
@Component ({
|
||||
selector: 'repliction-rule',
|
||||
@ -53,13 +52,10 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||
isRuleNameExist: boolean = false;
|
||||
isSubmitOver: boolean = false;
|
||||
nameChecker: Subject<string> = new Subject<string>();
|
||||
firstEndpointData: { [key: string]: string };
|
||||
realEndpointData: { [key: string]: string } = this.initEndpointData();
|
||||
|
||||
confirmSub: Subscription;
|
||||
ruleForm: FormGroup;
|
||||
copyUpdateForm: ReplicationRule;
|
||||
|
||||
emptyEndpoint = new Target();
|
||||
|
||||
@ViewChild(ListProjectModelComponent)
|
||||
@ -68,7 +64,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(CreateEditEndpointComponent)
|
||||
createEditEndpointComponent: CreateEditEndpointComponent;
|
||||
|
||||
|
||||
baseFilterData(name: string, option: string[], state: boolean) {
|
||||
return {
|
||||
name: name,
|
||||
@ -78,13 +73,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||
};
|
||||
}
|
||||
|
||||
initEndpointData(): { [key: string]: string } {
|
||||
return{
|
||||
userName: "",
|
||||
password: ""
|
||||
};
|
||||
}
|
||||
|
||||
constructor(public projectService: ProjectService,
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
@ -103,9 +91,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||
if (!this.policyId) {
|
||||
res[0].unshift(this.emptyEndpoint);
|
||||
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]) {
|
||||
@ -204,10 +189,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||
this.setTarget(rule.targets);
|
||||
this.noSelectedEndpoint = false;
|
||||
|
||||
this.realEndpointData.userName = rule.targets[0].username;
|
||||
this.realEndpointData.password = FAKE_PASSWORD;
|
||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
||||
|
||||
if (rule.filters) {
|
||||
this.setFilter(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']);
|
||||
this.setTarget([selecedTarget]);
|
||||
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 {
|
||||
return !isEmptyObject(this.getChanges()) || !compareValue(this.firstEndpointData, this.realEndpointData);
|
||||
return !isEmptyObject(this.getChanges());
|
||||
}
|
||||
|
||||
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
|
||||
this.inProgress = true;
|
||||
let copyRuleForm: ReplicationRule = this.ruleForm.value;
|
||||
copyRuleForm.trigger = this.setTriggerVaule(copyRuleForm.trigger);
|
||||
if (!this.policyId) {
|
||||
@ -541,8 +482,6 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
|
||||
this.targetList = res[0];
|
||||
this.setTarget([this.targetList[this.targetList.length - 1]]);
|
||||
this.noSelectedEndpoint = false;
|
||||
this.realEndpointData.userName = this.targetList[this.targetList.length - 1].username;
|
||||
this.firstEndpointData = Object.assign({}, this.realEndpointData);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -62,8 +62,6 @@
|
||||
</select>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
|
@ -72,31 +72,4 @@ export class ReplicationRuleServie {
|
||||
.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