From 7fe6c8be1056dd9a5419f7dfeae3587ee4a14ead Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Thu, 20 Dec 2018 12:23:36 -0100 Subject: [PATCH] mgr/dashboard: Add missing frontend I18N Fixes: http://tracker.ceph.com/issues/36719 Signed-off-by: Tiago Melo --- .../rbd-details/rbd-details.component.html | 206 ++++---- .../rbd-snapshot-actions.model.ts | 147 +++--- .../rbd-snapshot-list.component.spec.ts | 7 +- .../rbd-snapshot-list.component.ts | 2 +- .../rbd-trash-move-modal.component.html | 9 +- .../osd-details/osd-details.component.spec.ts | 5 +- .../osd-recv-speed-modal.component.ts | 8 +- .../osd-recv-speed-modal.priorities.ts | 45 -- .../osd-reweight-modal.component.spec.ts | 4 +- .../erasure-code-profile-form-tooltips.ts | 64 --- .../erasure-code-profile-form.component.html | 5 +- .../erasure-code-profile-form.component.ts | 3 +- .../app/ceph/pool/pool-form/pool-form-data.ts | 27 +- .../rgw-user-details.component.html | 3 +- .../auth/user-form/user-form.component.ts | 3 +- .../api/erasure-code-profile.service.spec.ts | 4 +- .../api/erasure-code-profile.service.ts | 69 ++- .../src/app/shared/api/osd.service.spec.ts | 4 +- .../src/app/shared/api/osd.service.ts | 49 +- .../select-badges-messages.model.ts | 26 +- .../select-badges.component.spec.ts | 5 +- .../select-badges/select-badges.component.ts | 5 +- .../shared/services/task-message.service.ts | 90 ++-- .../frontend/src/locale/messages.xlf | 450 ++++++++++++++---- 24 files changed, 783 insertions(+), 457 deletions(-) delete mode 100755 src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-recv-speed-modal/osd-recv-speed-modal.priorities.ts delete mode 100644 src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/erasure-code-profile-form/erasure-code-profile-form-tooltips.ts diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-details/rbd-details.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-details/rbd-details.component.html index 92cd89c122f03..28546d0d04856 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-details/rbd-details.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-details/rbd-details.component.html @@ -1,5 +1,5 @@ -
+ Only available for RBD images with fast-diff enabled
@@ -8,106 +8,110 @@ heading="Details"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name{{ selectedItem.name }}
Pool{{ selectedItem.pool_name }}
Data Pool{{ selectedItem.data_pool | empty }}
Created{{ selectedItem.timestamp | cdDate }}
Size{{ selectedItem.size | dimlessBinary }}
Objects{{ selectedItem.num_objs | dimless }}
Object size{{ selectedItem.obj_size | dimlessBinary }}
Features - - {{ feature }} - -
Provisioned - - N/A - - - {{ selectedItem.disk_usage | dimlessBinary }} - -
Total provisioned - - N/A - - - {{ selectedItem.total_disk_usage | dimlessBinary }} - -
Striping unit{{ selectedItem.stripe_unit | dimlessBinary }}
Striping count{{ selectedItem.stripe_count }}
Parent - {{ selectedItem.parent.pool_name }}/{{ selectedItem.parent.image_name }}@{{ selectedItem.parent.snap_name }} - - -
Block name prefix{{ selectedItem.block_name_prefix }}
Order{{ selectedItem.order }}
Name{{ selectedItem.name }}
Pool{{ selectedItem.pool_name }}
Data Pool{{ selectedItem.data_pool | empty }}
Created{{ selectedItem.timestamp | cdDate }}
Size{{ selectedItem.size | dimlessBinary }}
Objects{{ selectedItem.num_objs | dimless }}
Object size{{ selectedItem.obj_size | dimlessBinary }}
Features + + {{ feature }} + +
Provisioned + + N/A + + + {{ selectedItem.disk_usage | dimlessBinary }} + +
Total provisioned + + N/A + + + {{ selectedItem.total_disk_usage | dimlessBinary }} + +
Striping unit{{ selectedItem.stripe_unit | dimlessBinary }}
Striping count{{ selectedItem.stripe_count }}
Parent + {{ selectedItem.parent.pool_name }} + /{{ selectedItem.parent.image_name }} + @{{ selectedItem.parent.snap_name }} + - +
Block name prefix{{ selectedItem.block_name_prefix }}
Order{{ selectedItem.order }}
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts index 1494bc6254917..eb408eb5f2d0f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-actions.model.ts @@ -1,69 +1,88 @@ +import { I18n } from '@ngx-translate/i18n-polyfill'; + import { CdTableAction } from '../../../shared/models/cd-table-action'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; export class RbdSnapshotActionsModel { - create: CdTableAction = { - permission: 'create', - icon: 'fa-plus', - name: 'Create' - }; - rename: CdTableAction = { - permission: 'update', - icon: 'fa-pencil', - name: 'Rename' - }; - protect: CdTableAction = { - permission: 'update', - icon: 'fa-lock', - visible: (selection: CdTableSelection) => - selection.hasSingleSelection && !selection.first().is_protected, - name: 'Protect' - }; - unprotect: CdTableAction = { - permission: 'update', - icon: 'fa-unlock', - visible: (selection: CdTableSelection) => - selection.hasSingleSelection && selection.first().is_protected, - name: 'Unprotect' - }; - clone: CdTableAction = { - permission: 'create', - canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, - disable: (selection: CdTableSelection) => - !selection.hasSingleSelection || selection.first().cdExecuting, - icon: 'fa-clone', - name: 'Clone' - }; - copy: CdTableAction = { - permission: 'create', - canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, - disable: (selection: CdTableSelection) => - !selection.hasSingleSelection || selection.first().cdExecuting, - icon: 'fa-copy', - name: 'Copy' - }; - rollback: CdTableAction = { - permission: 'update', - icon: 'fa-undo', - name: 'Rollback' - }; - deleteSnap: CdTableAction = { - permission: 'delete', - icon: 'fa-times', - disable: (selection: CdTableSelection) => { - const first = selection.first(); - return !selection.hasSingleSelection || first.cdExecuting || first.is_protected; - }, - name: 'Delete' - }; - ordering = [ - this.create, - this.rename, - this.protect, - this.unprotect, - this.clone, - this.copy, - this.rollback, - this.deleteSnap - ]; + i18n: I18n; + + create: CdTableAction; + rename: CdTableAction; + protect: CdTableAction; + unprotect: CdTableAction; + clone: CdTableAction; + copy: CdTableAction; + rollback: CdTableAction; + deleteSnap: CdTableAction; + ordering: CdTableAction[]; + + constructor(i18n: I18n) { + this.i18n = i18n; + + this.create = { + permission: 'create', + icon: 'fa-plus', + name: this.i18n('Create') + }; + this.rename = { + permission: 'update', + icon: 'fa-pencil', + name: this.i18n('Rename') + }; + this.protect = { + permission: 'update', + icon: 'fa-lock', + visible: (selection: CdTableSelection) => + selection.hasSingleSelection && !selection.first().is_protected, + name: this.i18n('Protect') + }; + this.unprotect = { + permission: 'update', + icon: 'fa-unlock', + visible: (selection: CdTableSelection) => + selection.hasSingleSelection && selection.first().is_protected, + name: this.i18n('Unprotect') + }; + this.clone = { + permission: 'create', + canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, + disable: (selection: CdTableSelection) => + !selection.hasSingleSelection || selection.first().cdExecuting, + icon: 'fa-clone', + name: this.i18n('Clone') + }; + this.copy = { + permission: 'create', + canBePrimary: (selection: CdTableSelection) => selection.hasSingleSelection, + disable: (selection: CdTableSelection) => + !selection.hasSingleSelection || selection.first().cdExecuting, + icon: 'fa-copy', + name: this.i18n('Copy') + }; + this.rollback = { + permission: 'update', + icon: 'fa-undo', + name: this.i18n('Rollback') + }; + this.deleteSnap = { + permission: 'delete', + icon: 'fa-times', + disable: (selection: CdTableSelection) => { + const first = selection.first(); + return !selection.hasSingleSelection || first.cdExecuting || first.is_protected; + }, + name: this.i18n('Delete') + }; + + this.ordering = [ + this.create, + this.rename, + this.protect, + this.unprotect, + this.clone, + this.copy, + this.rollback, + this.deleteSnap + ]; + } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts index 41861135fe271..0294daf2b09f5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts @@ -3,6 +3,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { By } from '@angular/platform-browser'; import { RouterTestingModule } from '@angular/router/testing'; +import { I18n } from '@ngx-translate/i18n-polyfill'; import { ToastModule } from 'ng2-toastr'; import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal'; import { Subject, throwError as observableThrowError } from 'rxjs'; @@ -80,11 +81,12 @@ describe('RbdSnapshotListComponent', () => { beforeEach(() => { fixture.detectChanges(); + const i18n = TestBed.get(I18n); called = false; rbdService = new RbdService(null); notificationService = new NotificationService(null, null); authStorageService = new AuthStorageService(); - authStorageService.set('user', { 'rbd-image': ['create', 'read', 'update', 'delete'] }); + authStorageService.set('user', '', { 'rbd-image': ['create', 'read', 'update', 'delete'] }); component = new RbdSnapshotListComponent( authStorageService, null, @@ -94,7 +96,8 @@ describe('RbdSnapshotListComponent', () => { null, notificationService, null, - null + null, + i18n ); spyOn(rbdService, 'deleteSnapshot').and.returnValue(observableThrowError({ status: 500 })); spyOn(notificationService, 'notifyTask').and.stub(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts index 8958dea84b2dc..e186195c5c71f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.ts @@ -77,7 +77,7 @@ export class RbdSnapshotListComponent implements OnInit, OnChanges { private i18n: I18n ) { this.permission = this.authStorageService.getPermissions().rbdImage; - const actions = new RbdSnapshotActionsModel(); + const actions = new RbdSnapshotActionsModel(this.i18n); actions.create.click = () => this.openCreateSnapshotModal(); actions.rename.click = () => this.openEditSnapshotModal(); actions.protect.click = () => this.toggleProtection(); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html index 0be5c92ddfbc7..d19a2adfa5c4c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.html @@ -9,13 +9,8 @@ [formGroup]="moveForm" novalidate>