From 9644dca996faf67b5dce8915fc94999a5407ba7d Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Tue, 2 Apr 2019 16:59:51 +0100 Subject: [PATCH] mgr/dashboard: Adds 'tcmu-runner' to the 'user:rbd' backstore descr Signed-off-by: Ricardo Marques (cherry picked from commit b7870c8051c33e44b2190d295c1957f2a7a17d89) --- .../iscsi-target-details.component.ts | 7 ++++--- .../iscsi-target-form.component.html | 2 +- ...i-target-image-settings-modal.component.html | 2 +- .../ceph/block/iscsi/iscsi.component.spec.ts | 5 ++++- .../src/app/ceph/block/iscsi/iscsi.component.ts | 7 ++++--- .../shared/pipes/iscsi-backstore.pipe.spec.ts | 17 +++++++++++++++++ .../app/shared/pipes/iscsi-backstore.pipe.ts | 17 +++++++++++++++++ .../src/app/shared/pipes/pipes.module.ts | 4 ++++ .../dashboard/frontend/src/locale/messages.xlf | 6 +++--- 9 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.spec.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.ts diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts index 814dc44b9f58e..588c24b5c248f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-details/iscsi-target-details.component.ts @@ -7,6 +7,7 @@ import { NodeEvent, TreeModel } from 'ng2-tree'; import { TableComponent } from '../../../shared/datatable/table/table.component'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; +import { IscsiBackstorePipe } from '../../../shared/pipes/iscsi-backstore.pipe'; @Component({ selector: 'cd-iscsi-target-details', @@ -38,7 +39,7 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { title: string; tree: TreeModel; - constructor(private i18n: I18n) {} + constructor(private i18n: I18n, private iscsiBackstorePipe: IscsiBackstorePipe) {} ngOnInit() { this.columns = [ @@ -248,8 +249,8 @@ export class IscsiTargetDetailsComponent implements OnChanges, OnInit { }); this.data.push({ displayName: 'backstore', - default: this.settings.default_backstore, - current: tempData.backstore + default: this.iscsiBackstorePipe.transform(this.settings.default_backstore), + current: this.iscsiBackstorePipe.transform(tempData.backstore) }); } else { this.columns[2].isHidden = true; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html index 53e83cc8d8345..7dc6250aa897a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.html @@ -144,7 +144,7 @@ Backstore: {{ imagesSettings[image].backstore }}.  + i18n>Backstore: {{ imagesSettings[image].backstore | iscsiBackstore }}.  This image has modified settings. diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.html index cf163f28c2209..c0dd35b5fee94 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.html @@ -20,7 +20,7 @@ [(ngModel)]="model.backstore" [disabled]="backstores.length == 1"> + [value]="bs">{{ bs | iscsiBackstore }} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts index e9bae7f321395..c7d533c186ddf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.spec.ts @@ -7,9 +7,11 @@ import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-h import { IscsiService } from '../../../shared/api/iscsi.service'; import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe'; import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; +import { IscsiBackstorePipe } from '../../../shared/pipes/iscsi-backstore.pipe'; import { ListPipe } from '../../../shared/pipes/list.pipe'; import { RelativeDatePipe } from '../../../shared/pipes/relative-date.pipe'; import { FormatterService } from '../../../shared/services/formatter.service'; +import { SharedModule } from '../../../shared/shared.module'; import { IscsiComponent } from './iscsi.component'; describe('IscsiComponent', () => { @@ -27,7 +29,7 @@ describe('IscsiComponent', () => { }; configureTestBed({ - imports: [], + imports: [SharedModule], declarations: [IscsiComponent], schemas: [NO_ERRORS_SCHEMA], providers: [ @@ -35,6 +37,7 @@ describe('IscsiComponent', () => { DimlessPipe, FormatterService, RelativeDatePipe, + IscsiBackstorePipe, ListPipe, { provide: IscsiService, useValue: fakeService }, i18nProviders diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts index fe64d02c385be..27266f4339e87 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts @@ -4,7 +4,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'; import { IscsiService } from '../../../shared/api/iscsi.service'; import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; -import { RelativeDatePipe } from '../../../shared/pipes/relative-date.pipe'; +import { IscsiBackstorePipe } from '../../../shared/pipes/iscsi-backstore.pipe'; @Component({ selector: 'cd-iscsi', @@ -29,7 +29,7 @@ export class IscsiComponent implements OnInit { constructor( private iscsiService: IscsiService, private dimlessPipe: DimlessPipe, - private relativeDatePipe: RelativeDatePipe, + private iscsiBackstorePipe: IscsiBackstorePipe, private i18n: I18n ) {} @@ -60,7 +60,8 @@ export class IscsiComponent implements OnInit { }, { name: this.i18n('Backstore'), - prop: 'backstore' + prop: 'backstore', + pipe: this.iscsiBackstorePipe }, { name: this.i18n('Read Bytes'), diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.spec.ts new file mode 100644 index 0000000000000..c82e37554f765 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.spec.ts @@ -0,0 +1,17 @@ +import { IscsiBackstorePipe } from './iscsi-backstore.pipe'; + +describe('IscsiBackstorePipe', () => { + const pipe = new IscsiBackstorePipe(); + + it('create an instance', () => { + expect(pipe).toBeTruthy(); + }); + + it('transforms "user:rbd"', () => { + expect(pipe.transform('user:rbd')).toBe('user:rbd (tcmu-runner)'); + }); + + it('transforms "other"', () => { + expect(pipe.transform('other')).toBe('other'); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.ts new file mode 100644 index 0000000000000..ae347b6f69bee --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/iscsi-backstore.pipe.ts @@ -0,0 +1,17 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'iscsiBackstore' +}) +export class IscsiBackstorePipe implements PipeTransform { + constructor() {} + + transform(value: any): any { + switch (value) { + case 'user:rbd': + return 'user:rbd (tcmu-runner)'; + default: + return value; + } + } +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts index b849af25bfd13..0248203a0db66 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts @@ -13,6 +13,7 @@ import { EncodeUriPipe } from './encode-uri.pipe'; import { FilterPipe } from './filter.pipe'; import { HealthColorPipe } from './health-color.pipe'; import { IopsPipe } from './iops.pipe'; +import { IscsiBackstorePipe } from './iscsi-backstore.pipe'; import { ListPipe } from './list.pipe'; import { LogPriorityPipe } from './log-priority.pipe'; import { MillisecondsPipe } from './milliseconds.pipe'; @@ -33,6 +34,7 @@ import { UpperFirstPipe } from './upper-first.pipe'; CephShortVersionPipe, CephReleaseNamePipe, RelativeDatePipe, + IscsiBackstorePipe, ListPipe, LogPriorityPipe, FilterPipe, @@ -55,6 +57,7 @@ import { UpperFirstPipe } from './upper-first.pipe'; CephShortVersionPipe, CephReleaseNamePipe, RelativeDatePipe, + IscsiBackstorePipe, ListPipe, LogPriorityPipe, FilterPipe, @@ -77,6 +80,7 @@ import { UpperFirstPipe } from './upper-first.pipe'; DimlessBinaryPerSecondPipe, DimlessPipe, RelativeDatePipe, + IscsiBackstorePipe, ListPipe, LogPriorityPipe, CdDatePipe, diff --git a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf index 05c13cc00c214..c2e876d610ca3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf +++ b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf @@ -2849,7 +2849,7 @@ Backstore app/ceph/block/iscsi-target-image-settings-modal/iscsi-target-image-settings-modal.component.html - 17 + 16 Confirm @@ -2925,8 +2925,8 @@ app/ceph/block/iscsi-target-form/iscsi-target-form.component.html 106 - - Backstore: .  + + Backstore: .  app/ceph/block/iscsi-target-form/iscsi-target-form.component.html 147 -- 2.39.5