mgr/dashboard: OSD list component improvements (#30488)

mgr/dashboard: OSD list component improvements

Reviewed-by: Patrick Seidensal <pnawracay@suse.com>
Reviewed-by: Volker Theile <vtheile@suse.com>
This commit is contained in:
Lenz Grimmer 2019-09-23 10:37:49 +00:00 committed by GitHub
commit 6c244abb37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 28 deletions

View File

@ -132,7 +132,10 @@ export class OsdListComponent implements OnInit {
this.i18n('Purge'),
this.i18n('OSD'),
this.i18n('purged'),
this.osdService.purge
(id) => {
this.selection = new CdTableSelection();
return this.osdService.purge(id);
}
),
disable: () => this.isNotSelectedOrInState('up'),
icon: Icons.erase
@ -145,7 +148,10 @@ export class OsdListComponent implements OnInit {
this.i18n('destroy'),
this.i18n('OSD'),
this.i18n('destroyed'),
this.osdService.destroy
(id) => {
this.selection = new CdTableSelection();
return this.osdService.destroy(id);
}
),
disable: () => this.isNotSelectedOrInState('up'),
icon: Icons.destroy
@ -235,13 +241,14 @@ export class OsdListComponent implements OnInit {
return true;
}
const validOsds = [];
let validOsds = [];
if (this.selection.hasSelection) {
for (const osdId of this.getSelectedIds()) {
validOsds.push(this.osds.filter((o) => o.id === osdId).pop());
}
}
validOsds = validOsds.filter((osd) => !_.isUndefined(osd));
if (validOsds.length === 0) {
// `osd` is undefined if the selected OSD has been removed.
return true;
@ -300,10 +307,8 @@ export class OsdListComponent implements OnInit {
},
onSubmit: () => {
observableForkJoin(
this.getSelectedIds().map((osd: any) => {
onSubmit.call(this.osdService, osd).subscribe(() => this.bsModalRef.hide());
})
);
this.getSelectedIds().map((osd: any) => onSubmit.call(this.osdService, osd))
).subscribe(() => this.bsModalRef.hide());
}
}
});
@ -337,9 +342,13 @@ export class OsdListComponent implements OnInit {
},
submitAction: () => {
observableForkJoin(
this.getSelectedIds().map((osd: any) => {
action.call(this.osdService, osd).subscribe(() => modalRef.hide());
})
this.getSelectedIds().map((osd: any) => action.call(this.osdService, osd))
).subscribe(
() => {
this.getOsdList();
modalRef.hide();
},
() => modalRef.hide()
);
}
}

View File

@ -3,6 +3,7 @@ import { FormGroup } from '@angular/forms';
import { I18n } from '@ngx-translate/i18n-polyfill';
import { BsModalRef } from 'ngx-bootstrap/modal';
import { forkJoin } from 'rxjs';
import { OsdService } from '../../../../shared/api/osd.service';
import { NotificationType } from '../../../../shared/enum/notification-type.enum';
@ -32,24 +33,21 @@ export class OsdScrubModalComponent implements OnInit {
}
scrub() {
for (const id of this.selected) {
this.osdService.scrub(id, this.deep).subscribe(
() => {
const operation = this.deep ? 'Deep scrub' : 'Scrub';
forkJoin(this.selected.map((id: any) => this.osdService.scrub(id, this.deep))).subscribe(
() => {
const operation = this.deep ? 'Deep scrub' : 'Scrub';
this.notificationService.show(
NotificationType.success,
this.i18n('{{operation}} was initialized in the following OSD(s): {{id}}', {
operation: operation,
id: this.listPipe.transform(this.selected)
})
);
this.bsModalRef.hide();
},
() => {
this.bsModalRef.hide();
}
);
}
this.notificationService.show(
NotificationType.success,
this.i18n('{{operation}} was initialized in the following OSD(s): {{id}}', {
operation: operation,
id: this.listPipe.transform(this.selected)
})
);
this.bsModalRef.hide();
},
() => this.bsModalRef.hide()
);
}
}