Modify users about delete myself display issue #4164

This commit is contained in:
pfh 2018-01-29 19:34:24 +08:00
parent 63dcb27d08
commit 008cf32bb3
5 changed files with 26 additions and 14 deletions

View File

@ -8,7 +8,7 @@ export const COPY_INPUT_HTML = `
<input type="text" class="command-input" size="{{inputSize}}" [(ngModel)]="defaultValue" #inputTarget readonly/>
</span>
<span>
<input type="text" size="{{inputSize}}" [(ngModel)]="defaultValue" #inputTarget1 style="width: 1px; min-width: 0px; padding: 0;">
<input type="text" size="{{inputSize}}" [(ngModel)]="defaultValue" #inputTarget1 style="width: 1px; min-width: 0px; padding: 0; opacity: .1;">
</span>
<span>
<clr-icon shape="copy" [class.is-success]="isCopied" [class.is-error]="hasCopyError" class="info-tips-icon" size="24" [ngxClipboard]="inputTarget1" (cbOnSuccess)="onSuccess($event)" (cbOnError)="onError($event)"></clr-icon>

View File

@ -471,6 +471,7 @@ export class ReplicationRuleComponent implements OnInit, OnDestroy {
this.repService.updateEndpoint(endpointId, pullData)
.then((res: any) => {
this.saveRuleOpe();
this.firstEndpointData = Object.assign({}, this.realEndpointData);
})
.catch((error: any) => {
this.inProgress = false;

View File

@ -58,7 +58,7 @@
<div formArrayName="targets">
<div class="select endpointSelect pull-left" *ngFor="let target of targets.controls; let i= index" [formGroupName]="i">
<select id="ruleTarget " class="inputWidth" (change)="targetChange($event)" formControlName="id">
<option *ngFor="let target of targetList" value="{{target.id}}">{{target.name}}<span [hidden]="!target.name">:</span> {{target.endpoint}}</option>
<option *ngFor="let target of targetList" value="{{target.id}}">{{target.name}}-{{target.endpoint}}</option>
</select>
</div>
<button class="btn btn-info btn-sm addEndpoint" (click)="openModal()"><clr-icon shape="plus"></clr-icon>&nbsp;{{'REPLICATION.NEW' | translate}}</button>

View File

@ -13,7 +13,7 @@
<clr-dg-action-bar>
<button type="button" class="btn btn-sm btn-secondary" (click)="addNewUser()"><clr-icon shape="plus" size="16"></clr-icon>&nbsp;{{'USER.ADD_ACTION' | translate}}</button>
<button type="button" class="btn btn-sm btn-secondary" id="set-admin" [disabled]="!ifSameRole" (click)="changeAdminRole()" ><clr-icon shape="wrench" size="16"></clr-icon>&nbsp;{{ISADMNISTRATOR | translate}}</button>
<button type="button" class="btn btn-sm btn-secondary" (click)="deleteUsers(selectedRow)" [disabled]="!selectedRow.length"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'USER.DEL_ACTION' | translate}}</button>
<button type="button" class="btn btn-sm btn-secondary" (click)="deleteUsers(selectedRow)" [disabled]="!selectedRow.length || onlySelf"><clr-icon shape="times" size="16"></clr-icon>&nbsp;{{'USER.DEL_ACTION' | translate}}</button>
</clr-dg-action-bar>
<clr-dg-column>{{'USER.COLUMN_NAME' | translate}}</clr-dg-column>
<clr-dg-column>{{'USER.COLUMN_ADMIN' | translate}}</clr-dg-column>

View File

@ -94,6 +94,10 @@ export class UserComponent implements OnInit, OnDestroy {
return false;
}
get onlySelf(): boolean {
return this.selectedRow.length === 1 && this.isMySelf(this.selectedRow[0].user_id);
}
private isMatchFilterTerm(terms: string, testedItem: string): boolean {
return testedItem.toLowerCase().indexOf(terms.toLowerCase()) !== -1;
}
@ -222,17 +226,17 @@ export class UserComponent implements OnInit, OnDestroy {
deleteUsers(users: User[]): void {
let userArr: string[] = [];
this.batchDelectionInfos = [];
if (users && users.length) {
for (let i = 0; i < users.length; i++) {
if (this.onlySelf) {
return;
}
if (this.isMySelf(users[i].user_id)) {
continue; //Double confirm
}
let initBatchMessage = new BatchInfo ();
initBatchMessage.name = users[i].username;
this.batchDelectionInfos.push(initBatchMessage);
userArr.push(users[i].username);
}
if (users && users.length) {
users.forEach(user => {
let initBatchMessage = new BatchInfo ();
initBatchMessage.name = user.username;
this.batchDelectionInfos.push(initBatchMessage);
userArr.push(user.username);
})
this.deletionDialogService.addBatchInfoList(this.batchDelectionInfos);
//Confirm deletion
let msg: ConfirmationMessage = new ConfirmationMessage(
@ -252,7 +256,14 @@ export class UserComponent implements OnInit, OnDestroy {
let promiseLists: any[] = [];
if (users && users.length) {
users.forEach(user => {
promiseLists.push(this.delOperate(user.user_id, user.username));
let findedList = this.batchDelectionInfos.find(data => data.name === user.username);
if (this.isMySelf(user.user_id)) {
this.translate.get('BATCH.DELETED_FAILURE').subscribe(res => {
findedList = BathInfoChanges(findedList, res, false, true);
});
} else {
promiseLists.push(this.delOperate(user.user_id, user.username));
}
});
Promise.all(promiseLists).then((item) => {