From 09c1c39cd3624c11d5bb8b4a2ab06d14d2df235a Mon Sep 17 00:00:00 2001 From: pfh Date: Tue, 30 Jan 2018 18:47:27 +0800 Subject: [PATCH] delete username and pwd in replication rule --- .../member/add-member/add-member.component.ts | 4 +- .../app/project/member/member.component.html | 8 +-- .../app/project/member/member.component.ts | 7 ++ .../replication-rule.component.ts | 65 +------------------ .../replication-rule/replication-rule.html | 2 - .../replication-rule.service.ts | 27 -------- 6 files changed, 16 insertions(+), 97 deletions(-) diff --git a/src/ui_ng/src/app/project/member/add-member/add-member.component.ts b/src/ui_ng/src/app/project/member/add-member/add-member.component.ts index adc2948cf..e9d98b650 100644 --- a/src/ui_ng/src/app/project/member/add-member/add-member.component.ts +++ b/src/ui_ng/src/app/project/member/add-member/add-member.component.ts @@ -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 { diff --git a/src/ui_ng/src/app/project/member/member.component.html b/src/ui_ng/src/app/project/member/member.component.html index a47b8264d..acf5b9a51 100644 --- a/src/ui_ng/src/app/project/member/member.component.html +++ b/src/ui_ng/src/app/project/member/member.component.html @@ -19,12 +19,12 @@ {{'MEMBER.ACTION' | translate}} - - - + + + - diff --git a/src/ui_ng/src/app/project/member/member.component.ts b/src/ui_ng/src/app/project/member/member.component.ts index e4330b88d..c67639d38 100644 --- a/src/ui_ng/src/app/project/member/member.component.ts +++ b/src/ui_ng/src/app/project/member/member.component.ts @@ -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; diff --git a/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts b/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts index 1ccb7d7b7..f45431806 100644 --- a/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts +++ b/src/ui_ng/src/app/replication/replication-rule/replication-rule.component.ts @@ -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 = new Subject(); - 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); }); } } diff --git a/src/ui_ng/src/app/replication/replication-rule/replication-rule.html b/src/ui_ng/src/app/replication/replication-rule/replication-rule.html index d2ea5266c..b8a1b2bd6 100644 --- a/src/ui_ng/src/app/replication/replication-rule/replication-rule.html +++ b/src/ui_ng/src/app/replication/replication-rule/replication-rule.html @@ -62,8 +62,6 @@ -
userName:   
-
password:   
diff --git a/src/ui_ng/src/app/replication/replication-rule/replication-rule.service.ts b/src/ui_ng/src/app/replication/replication-rule/replication-rule.service.ts index 55f22b71c..fbe5a1c4c 100644 --- a/src/ui_ng/src/app/replication/replication-rule/replication-rule.service.ts +++ b/src/ui_ng/src/app/replication/replication-rule/replication-rule.service.ts @@ -72,31 +72,4 @@ export class ReplicationRuleServie { .catch(error => Promise.reject(error)); } - public updateEndpoint(endpointId: number | string, endpoint: any): Promise | 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 { - 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)); - } - }