From bcc01e4eee70fd5f0bb303f82e791210e6344233 Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Mon, 28 May 2018 14:59:58 +0200 Subject: [PATCH] mgr/dashboard: Prettify RGW JS code. Signed-off-by: Volker Theile --- .../rgw/rgw-501/rgw-501.component.spec.ts | 10 +-- .../rgw-bucket-details.component.spec.ts | 10 +-- .../rgw-bucket-form.component.spec.ts | 17 +--- .../rgw-daemon-details.component.spec.ts | 8 +- .../rgw-daemon-details.component.ts | 7 +- .../rgw-daemon-list.component.spec.ts | 15 +--- .../rgw-daemon-list.component.ts | 17 ++-- ...gw-user-capability-modal.component.spec.ts | 12 +-- .../rgw-user-capability-modal.component.ts | 18 ++--- .../rgw-user-details.component.spec.ts | 16 +--- .../rgw-user-details.component.ts | 27 +++---- .../rgw-user-form.component.spec.ts | 17 +--- .../rgw-user-s3-key-modal.component.spec.ts | 12 +-- .../rgw-user-s3-key-modal.component.ts | 33 +++----- .../rgw-user-subuser-modal.component.spec.ts | 16 ++-- .../rgw-user-subuser-modal.component.ts | 46 ++++------- ...rgw-user-swift-key-modal.component.spec.ts | 11 +-- .../rgw-user-swift-key-modal.component.ts | 1 - .../frontend/src/app/ceph/rgw/rgw.module.ts | 18 ++--- .../src/app/shared/api/rgw-bucket.service.ts | 42 +++++----- .../src/app/shared/api/rgw-daemon.service.ts | 3 +- .../src/app/shared/api/rgw-user.service.ts | 80 +++++++++++-------- 22 files changed, 164 insertions(+), 272 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.spec.ts index 03368345504c4..a2e7d6323acd3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-501/rgw-501.component.spec.ts @@ -10,13 +10,9 @@ describe('Rgw501Component', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ Rgw501Component ], - imports: [ - RouterTestingModule, - SharedModule - ] - }) - .compileComponents(); + declarations: [Rgw501Component], + imports: [RouterTestingModule, SharedModule] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.spec.ts index 443ea95daa6c5..5b40159430680 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.spec.ts @@ -12,13 +12,9 @@ describe('RgwBucketDetailsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwBucketDetailsComponent ], - imports: [ - SharedModule, - TabsModule.forRoot() - ] - }) - .compileComponents(); + declarations: [RgwBucketDetailsComponent], + imports: [SharedModule, TabsModule.forRoot()] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts index 8500ed2b4c593..77cd85f8a4385 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts @@ -24,19 +24,10 @@ describe('RgwBucketFormComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwBucketFormComponent ], - imports: [ - HttpClientTestingModule, - ReactiveFormsModule, - RouterTestingModule, - SharedModule - ], - providers: [ - RgwUserService, - { provide: RgwBucketService, useClass: MockRgwBucketService } - ] - }) - .compileComponents(); + declarations: [RgwBucketFormComponent], + imports: [HttpClientTestingModule, ReactiveFormsModule, RouterTestingModule, SharedModule], + providers: [RgwUserService, { provide: RgwBucketService, useClass: MockRgwBucketService }] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.spec.ts index c271666a98af2..b49c28d141268 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.spec.ts @@ -22,12 +22,8 @@ describe('RgwDaemonDetailsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwDaemonDetailsComponent ], - imports: [ - SharedModule, - PerformanceCounterModule, - TabsModule.forRoot() - ], + declarations: [RgwDaemonDetailsComponent], + imports: [SharedModule, PerformanceCounterModule, TabsModule.forRoot()], providers: [{ provide: RgwDaemonService, useValue: fakeRgwDaemonService }] }); })); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts index de24cd779899d..4d60308646da6 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-details/rgw-daemon-details.component.ts @@ -29,9 +29,8 @@ export class RgwDaemonDetailsComponent implements OnChanges { if (_.isEmpty(this.serviceId)) { return; } - this.rgwDaemonService.get(this.serviceId) - .subscribe((resp) => { - this.metadata = resp['rgw_metadata']; - }); + this.rgwDaemonService.get(this.serviceId).subscribe((resp) => { + this.metadata = resp['rgw_metadata']; + }); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts index f5dbd4785ee3f..00919fefb021b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.spec.ts @@ -14,18 +14,9 @@ describe('RgwDaemonListComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ - RgwDaemonListComponent, - RgwDaemonDetailsComponent - ], - imports: [ - HttpClientModule, - TabsModule.forRoot(), - PerformanceCounterModule, - SharedModule - ] - }) - .compileComponents(); + declarations: [RgwDaemonListComponent, RgwDaemonDetailsComponent], + imports: [HttpClientModule, TabsModule.forRoot(), PerformanceCounterModule, SharedModule] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts index 5aa82efe9e3c6..848d1b24c4913 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-daemon-list/rgw-daemon-list.component.ts @@ -11,13 +11,14 @@ import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.p styleUrls: ['./rgw-daemon-list.component.scss'] }) export class RgwDaemonListComponent { - columns: CdTableColumn[] = []; daemons: object[] = []; selection: CdTableSelection = new CdTableSelection(); - constructor(private rgwDaemonService: RgwDaemonService, - cephShortVersionPipe: CephShortVersionPipe) { + constructor( + private rgwDaemonService: RgwDaemonService, + cephShortVersionPipe: CephShortVersionPipe + ) { this.columns = [ { name: 'ID', @@ -39,14 +40,16 @@ export class RgwDaemonListComponent { } getDaemonList() { - this.rgwDaemonService.list() - .subscribe((resp: object[]) => { + this.rgwDaemonService.list().subscribe( + (resp: object[]) => { this.daemons = resp; - }, () => { + }, + () => { // Force datatable to hide the loading indicator in // case of an error. this.daemons = []; - }); + } + ); } updateSelection(selection: CdTableSelection) { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.spec.ts index 313f66722a2f3..c7a0f5b4ebec3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.spec.ts @@ -12,14 +12,10 @@ describe('RgwUserCapabilityModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwUserCapabilityModalComponent ], - imports: [ - ReactiveFormsModule, - SharedModule - ], - providers: [ BsModalRef ] - }) - .compileComponents(); + declarations: [RgwUserCapabilityModalComponent], + imports: [ReactiveFormsModule, SharedModule], + providers: [BsModalRef] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts index dca0efc077166..2a4a282fddbe5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-capability-modal/rgw-user-capability-modal.component.ts @@ -12,7 +12,6 @@ import { RgwUserCapability } from '../models/rgw-user-capability'; styleUrls: ['./rgw-user-capability-modal.component.scss'] }) export class RgwUserCapabilityModalComponent { - /** * The event that is triggered when the 'Add' or 'Update' button * has been pressed. @@ -23,21 +22,14 @@ export class RgwUserCapabilityModalComponent { editing = true; types: string[] = []; - constructor(private formBuilder: FormBuilder, - public bsModalRef: BsModalRef) { + constructor(private formBuilder: FormBuilder, public bsModalRef: BsModalRef) { this.createForm(); } createForm() { this.formGroup = this.formBuilder.group({ - 'type': [ - null, - [Validators.required] - ], - 'perm': [ - null, - [Validators.required] - ] + type: [null, [Validators.required]], + perm: [null, [Validators.required]] }); } @@ -56,8 +48,8 @@ export class RgwUserCapabilityModalComponent { */ setValues(type: string, perm: string) { this.formGroup.setValue({ - 'type': type, - 'perm': perm + type: type, + perm: perm }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts index 015dfc581e556..51a104074739c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.spec.ts @@ -15,18 +15,10 @@ describe('RgwUserDetailsComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwUserDetailsComponent ], - imports: [ - HttpClientTestingModule, - HttpClientModule, - SharedModule, - TabsModule.forRoot() - ], - providers: [ - BsModalService - ] - }) - .compileComponents(); + declarations: [RgwUserDetailsComponent], + imports: [HttpClientTestingModule, HttpClientModule, SharedModule, TabsModule.forRoot()], + providers: [BsModalService] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts index 35cbec9902d91..b466e562eb751 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-details/rgw-user-details.component.ts @@ -8,12 +8,8 @@ import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { RgwUserS3Key } from '../models/rgw-user-s3-key'; import { RgwUserSwiftKey } from '../models/rgw-user-swift-key'; -import { - RgwUserS3KeyModalComponent -} from '../rgw-user-s3-key-modal/rgw-user-s3-key-modal.component'; -import { - RgwUserSwiftKeyModalComponent -} from '../rgw-user-swift-key-modal/rgw-user-swift-key-modal.component'; +import { RgwUserS3KeyModalComponent } from '../rgw-user-s3-key-modal/rgw-user-s3-key-modal.component'; +import { RgwUserSwiftKeyModalComponent } from '../rgw-user-swift-key-modal/rgw-user-swift-key-modal.component'; @Component({ selector: 'cd-rgw-user-details', @@ -21,7 +17,6 @@ import { styleUrls: ['./rgw-user-details.component.scss'] }) export class RgwUserDetailsComponent implements OnChanges, OnInit { - @ViewChild('accessKeyTpl') public accessKeyTpl: TemplateRef; @ViewChild('secretKeyTpl') public secretKeyTpl: TemplateRef; @@ -35,8 +30,7 @@ export class RgwUserDetailsComponent implements OnChanges, OnInit { keysColumns: CdTableColumn[] = []; keysSelection: CdTableSelection = new CdTableSelection(); - constructor(private rgwUserService: RgwUserService, - private bsModalService: BsModalService) {} + constructor(private rgwUserService: RgwUserService, private bsModalService: BsModalService) {} ngOnInit() { this.keysColumns = [ @@ -63,10 +57,9 @@ export class RgwUserDetailsComponent implements OnChanges, OnInit { // Load the user/bucket quota of the selected user. if (this.user.tenant === '') { - this.rgwUserService.getQuota(this.user.user_id) - .subscribe((resp: object) => { - _.extend(this.user, resp); - }); + this.rgwUserService.getQuota(this.user.user_id).subscribe((resp: object) => { + _.extend(this.user, resp); + }); } // Process the keys. @@ -97,13 +90,13 @@ export class RgwUserDetailsComponent implements OnChanges, OnInit { showKeyModal() { const key = this.keysSelection.first(); - const modalRef = this.bsModalService.show(key.type === 'S3' ? - RgwUserS3KeyModalComponent : RgwUserSwiftKeyModalComponent); + const modalRef = this.bsModalService.show( + key.type === 'S3' ? RgwUserS3KeyModalComponent : RgwUserSwiftKeyModalComponent + ); switch (key.type) { case 'S3': modalRef.content.setViewing(); - modalRef.content.setValues(key.ref.user, key.ref.access_key, - key.ref.secret_key); + modalRef.content.setValues(key.ref.user, key.ref.access_key, key.ref.secret_key); break; case 'Swift': modalRef.content.setValues(key.ref.user, key.ref.secret_key); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts index 573a86d135c81..69cd35f39ae61 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts @@ -24,19 +24,10 @@ describe('RgwUserFormComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwUserFormComponent ], - imports: [ - HttpClientTestingModule, - ReactiveFormsModule, - RouterTestingModule, - SharedModule - ], - providers: [ - BsModalService, - { provide: RgwUserService, useClass: MockRgwUserService } - ] - }) - .compileComponents(); + declarations: [RgwUserFormComponent], + imports: [HttpClientTestingModule, ReactiveFormsModule, RouterTestingModule, SharedModule], + providers: [BsModalService, { provide: RgwUserService, useClass: MockRgwUserService }] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.spec.ts index 382f9df2bac3b..bf09c7c426072 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.spec.ts @@ -12,14 +12,10 @@ describe('RgwUserS3KeyModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwUserS3KeyModalComponent ], - imports: [ - ReactiveFormsModule, - SharedModule - ], - providers: [ BsModalRef ] - }) - .compileComponents(); + declarations: [RgwUserS3KeyModalComponent], + imports: [ReactiveFormsModule, SharedModule], + providers: [BsModalRef] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.ts index 613962f536584..e397cfb31c6cb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-s3-key-modal/rgw-user-s3-key-modal.component.ts @@ -13,7 +13,6 @@ import { RgwUserS3Key } from '../models/rgw-user-s3-key'; styleUrls: ['./rgw-user-s3-key-modal.component.scss'] }) export class RgwUserS3KeyModalComponent { - /** * The event that is triggered when the 'Add' button as been pressed. */ @@ -23,29 +22,17 @@ export class RgwUserS3KeyModalComponent { viewing = true; userCandidates: string[] = []; - constructor(private formBuilder: FormBuilder, - public bsModalRef: BsModalRef) { + constructor(private formBuilder: FormBuilder, public bsModalRef: BsModalRef) { this.createForm(); this.listenToChanges(); } createForm() { this.formGroup = this.formBuilder.group({ - 'user': [ - null, - [Validators.required] - ], - 'generate_key': [ - true - ], - 'access_key': [ - null, - [CdValidators.requiredIf({'generate_key': false})] - ], - 'secret_key': [ - null, - [CdValidators.requiredIf({'generate_key': false})] - ] + user: [null, [Validators.required]], + generate_key: [true], + access_key: [null, [CdValidators.requiredIf({ generate_key: false })]], + secret_key: [null, [CdValidators.requiredIf({ generate_key: false })]] }); } @@ -55,7 +42,7 @@ export class RgwUserS3KeyModalComponent { // validated again if the status of their prerequisites have been changed. this.formGroup.get('generate_key').valueChanges.subscribe(() => { ['access_key', 'secret_key'].forEach((path) => { - this.formGroup.get(path).updateValueAndValidity({onlySelf: true}); + this.formGroup.get(path).updateValueAndValidity({ onlySelf: true }); }); }); } @@ -75,10 +62,10 @@ export class RgwUserS3KeyModalComponent { */ setValues(user: string, access_key: string, secret_key: string) { this.formGroup.setValue({ - 'user': user, - 'generate_key': _.isEmpty(access_key), - 'access_key': access_key, - 'secret_key': secret_key + user: user, + generate_key: _.isEmpty(access_key), + access_key: access_key, + secret_key: secret_key }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts index 6e6691a90dc7e..572ca592aff2a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.spec.ts @@ -12,14 +12,10 @@ describe('RgwUserSubuserModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwUserSubuserModalComponent ], - imports: [ - ReactiveFormsModule, - SharedModule - ], - providers: [ BsModalRef ] - }) - .compileComponents(); + declarations: [RgwUserSubuserModalComponent], + imports: [ReactiveFormsModule, SharedModule], + providers: [BsModalRef] + }).compileComponents(); })); beforeEach(() => { @@ -36,8 +32,8 @@ describe('RgwUserSubuserModalComponent', () => { beforeEach(() => { component.editing = false; component.subusers = [ - {id: 'Edith', permissions: 'full-control'}, - {id: 'Edith:images', permissions: 'read-write'} + { id: 'Edith', permissions: 'full-control' }, + { id: 'Edith:images', permissions: 'read-write' } ]; }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.ts index ac3597e40ac00..b83254e89008e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-subuser-modal/rgw-user-subuser-modal.component.ts @@ -20,7 +20,6 @@ import { RgwUserSubuser } from '../models/rgw-user-subuser'; styleUrls: ['./rgw-user-subuser-modal.component.scss'] }) export class RgwUserSubuserModalComponent { - /** * The event that is triggered when the 'Add' or 'Update' button * has been pressed. @@ -31,36 +30,19 @@ export class RgwUserSubuserModalComponent { editing = true; subusers: RgwUserSubuser[] = []; - constructor(private formBuilder: FormBuilder, - public bsModalRef: BsModalRef) { + constructor(private formBuilder: FormBuilder, public bsModalRef: BsModalRef) { this.createForm(); this.listenToChanges(); } createForm() { this.formGroup = this.formBuilder.group({ - 'uid': [ - null - ], - 'subuid': [ - null, - [ - Validators.required, - this.subuserValidator() - ] - ], - 'perm': [ - null, - [Validators.required] - ], + uid: [null], + subuid: [null, [Validators.required, this.subuserValidator()]], + perm: [null, [Validators.required]], // Swift key - 'generate_secret': [ - true - ], - 'secret_key': [ - null, - [CdValidators.requiredIf({'generate_secret': false})] - ] + generate_secret: [true], + secret_key: [null, [CdValidators.requiredIf({ generate_secret: false })]] }); } @@ -70,7 +52,7 @@ export class RgwUserSubuserModalComponent { // validated again if the status of their prerequisites have been changed. this.formGroup.get('generate_secret').valueChanges.subscribe(() => { ['secret_key'].forEach((path) => { - this.formGroup.get(path).updateValueAndValidity({onlySelf: true}); + this.formGroup.get(path).updateValueAndValidity({ onlySelf: true }); }); }); } @@ -90,7 +72,7 @@ export class RgwUserSubuserModalComponent { const found = self.subusers.some((subuser) => { return _.isEqual(self.getSubuserName(subuser.id), control.value); }); - return found ? {'subuserIdExists': true} : null; + return found ? { subuserIdExists: true } : null; }; } @@ -125,11 +107,11 @@ export class RgwUserSubuserModalComponent { */ setValues(uid: string, subuser: string = '', permissions: string = '') { this.formGroup.setValue({ - 'uid': uid, - 'subuid': this.getSubuserName(subuser), - 'perm': permissions, - 'generate_secret': true, - 'secret_key': null + uid: uid, + subuid: this.getSubuserName(subuser), + perm: permissions, + generate_secret: true, + secret_key: null }); } @@ -144,7 +126,7 @@ export class RgwUserSubuserModalComponent { // Get the values from the form and create an object that is sent // by the triggered submit action event. const values = this.formGroup.value; - const subuser = new RgwUserSubuser; + const subuser = new RgwUserSubuser(); subuser.id = `${values.uid}:${values.subuid}`; subuser.permissions = values.perm; subuser.generate_secret = values.generate_secret; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.spec.ts index ac4ae5386ffcc..d342d0f23416b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.spec.ts @@ -11,13 +11,10 @@ describe('RgwUserSwiftKeyModalComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RgwUserSwiftKeyModalComponent ], - imports: [ - FormsModule - ], - providers: [ BsModalRef ] - }) - .compileComponents(); + declarations: [RgwUserSwiftKeyModalComponent], + imports: [FormsModule], + providers: [BsModalRef] + }).compileComponents(); })); beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.ts index 4ebe4ad3d9e32..b1b534977b2d9 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-swift-key-modal/rgw-user-swift-key-modal.component.ts @@ -8,7 +8,6 @@ import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; styleUrls: ['./rgw-user-swift-key-modal.component.scss'] }) export class RgwUserSwiftKeyModalComponent { - user: string; secret_key: string; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts index 8f82285bfad7c..2ad82a56ad561 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts @@ -19,21 +19,13 @@ import { RgwBucketFormComponent } from './rgw-bucket-form/rgw-bucket-form.compon import { RgwBucketListComponent } from './rgw-bucket-list/rgw-bucket-list.component'; import { RgwDaemonDetailsComponent } from './rgw-daemon-details/rgw-daemon-details.component'; import { RgwDaemonListComponent } from './rgw-daemon-list/rgw-daemon-list.component'; -import { - RgwUserCapabilityModalComponent -} from './rgw-user-capability-modal/rgw-user-capability-modal.component'; +import { RgwUserCapabilityModalComponent } from './rgw-user-capability-modal/rgw-user-capability-modal.component'; import { RgwUserDetailsComponent } from './rgw-user-details/rgw-user-details.component'; import { RgwUserFormComponent } from './rgw-user-form/rgw-user-form.component'; import { RgwUserListComponent } from './rgw-user-list/rgw-user-list.component'; -import { - RgwUserS3KeyModalComponent -} from './rgw-user-s3-key-modal/rgw-user-s3-key-modal.component'; -import { - RgwUserSubuserModalComponent -} from './rgw-user-subuser-modal/rgw-user-subuser-modal.component'; -import { - RgwUserSwiftKeyModalComponent -} from './rgw-user-swift-key-modal/rgw-user-swift-key-modal.component'; +import { RgwUserS3KeyModalComponent } from './rgw-user-s3-key-modal/rgw-user-s3-key-modal.component'; +import { RgwUserSubuserModalComponent } from './rgw-user-subuser-modal/rgw-user-subuser-modal.component'; +import { RgwUserSwiftKeyModalComponent } from './rgw-user-swift-key-modal/rgw-user-swift-key-modal.component'; @NgModule({ entryComponents: [ @@ -85,4 +77,4 @@ import { RgwUserSubuserModalComponent ] }) -export class RgwModule { } +export class RgwModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts index 2b357e7edf6d9..0740d6dd4c3ca 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts @@ -8,26 +8,25 @@ import { Observable } from 'rxjs/Observable'; @Injectable() export class RgwBucketService { - private url = '/api/rgw/proxy/bucket'; - constructor(private http: HttpClient) { } + constructor(private http: HttpClient) {} /** * Get the list of buckets. * @return {Observable} */ list() { - return this.enumerate() - .flatMap((buckets: string[]) => { - if (buckets.length > 0) { - return Observable.forkJoin( - buckets.map((bucket: string) => { - return this.get(bucket); - })); - } - return Observable.of([]); - }); + return this.enumerate().flatMap((buckets: string[]) => { + if (buckets.length > 0) { + return Observable.forkJoin( + buckets.map((bucket: string) => { + return this.get(bucket); + }) + ); + } + return Observable.of([]); + }); } /** @@ -41,13 +40,13 @@ export class RgwBucketService { get(bucket: string) { let params = new HttpParams(); params = params.append('bucket', bucket); - return this.http.get(this.url, {params: params}); + return this.http.get(this.url, { params: params }); } create(bucket: string, uid: string) { const body = { - 'bucket': bucket, - 'uid': uid + bucket: bucket, + uid: uid }; return this.http.post('/api/rgw/bucket', body); } @@ -57,14 +56,14 @@ export class RgwBucketService { params = params.append('bucket', bucket); params = params.append('bucket-id', bucketId as string); params = params.append('uid', uid); - return this.http.put(this.url, null, {params: params}); + return this.http.put(this.url, null, { params: params }); } delete(bucket: string, purgeObjects = true) { let params = new HttpParams(); params = params.append('bucket', bucket); params = params.append('purge-objects', purgeObjects ? 'true' : 'false'); - return this.http.delete(this.url, {params: params}); + return this.http.delete(this.url, { params: params }); } /** @@ -73,10 +72,9 @@ export class RgwBucketService { * @return {Observable} */ exists(bucket: string) { - return this.enumerate() - .flatMap((resp: string[]) => { - const index = _.indexOf(resp, bucket); - return Observable.of(-1 !== index); - }); + return this.enumerate().flatMap((resp: string[]) => { + const index = _.indexOf(resp, bucket); + return Observable.of(-1 !== index); + }); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts index 0e1ffba6000b4..48e24c98ad449 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-daemon.service.ts @@ -3,10 +3,9 @@ import { Injectable } from '@angular/core'; @Injectable() export class RgwDaemonService { - private url = 'api/rgw/daemon'; - constructor(private http: HttpClient) { } + constructor(private http: HttpClient) {} list() { return this.http.get(this.url); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts index 06766f991169d..d3f9d9f65c40a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts @@ -8,26 +8,25 @@ import { Observable } from 'rxjs/Observable'; @Injectable() export class RgwUserService { - private url = '/api/rgw/proxy/user'; - constructor(private http: HttpClient) { } + constructor(private http: HttpClient) {} /** * Get the list of users. * @return {Observable} */ list() { - return this.enumerate() - .flatMap((uids: string[]) => { - if (uids.length > 0) { - return Observable.forkJoin( - uids.map((uid: string) => { - return this.get(uid); - })); - } - return Observable.of([]); - }); + return this.enumerate().flatMap((uids: string[]) => { + if (uids.length > 0) { + return Observable.forkJoin( + uids.map((uid: string) => { + return this.get(uid); + }) + ); + } + return Observable.of([]); + }); } /** @@ -41,13 +40,13 @@ export class RgwUserService { get(uid: string) { let params = new HttpParams(); params = params.append('uid', uid); - return this.http.get(this.url, {params: params}); + return this.http.get(this.url, { params: params }); } getQuota(uid: string) { let params = new HttpParams(); params = params.append('uid', uid); - return this.http.get(`${this.url}?quota`, {params: params}); + return this.http.get(`${this.url}?quota`, { params: params }); } put(args: object) { @@ -55,7 +54,7 @@ export class RgwUserService { _.keys(args).forEach((key) => { params = params.append(key, args[key]); }); - return this.http.put(this.url, null, {params: params}); + return this.http.put(this.url, null, { params: params }); } putQuota(args: object) { @@ -63,7 +62,7 @@ export class RgwUserService { _.keys(args).forEach((key) => { params = params.append(key, args[key]); }); - return this.http.put(`${this.url}?quota`, null, {params: params}); + return this.http.put(`${this.url}?quota`, null, { params: params }); } post(args: object) { @@ -71,17 +70,22 @@ export class RgwUserService { _.keys(args).forEach((key) => { params = params.append(key, args[key]); }); - return this.http.post(this.url, null, {params: params}); + return this.http.post(this.url, null, { params: params }); } delete(uid: string) { let params = new HttpParams(); params = params.append('uid', uid); - return this.http.delete(this.url, {params: params}); + return this.http.delete(this.url, { params: params }); } - addSubuser(uid: string, subuser: string, permissions: string, - secretKey: string, generateSecret: boolean) { + addSubuser( + uid: string, + subuser: string, + permissions: string, + secretKey: string, + generateSecret: boolean + ) { const mapPermissions = { 'full-control': 'full', 'read-write': 'readwrite' @@ -90,14 +94,16 @@ export class RgwUserService { params = params.append('uid', uid); params = params.append('subuser', subuser); params = params.append('key-type', 'swift'); - params = params.append('access', (permissions in mapPermissions) ? - mapPermissions[permissions] : permissions); + params = params.append( + 'access', + permissions in mapPermissions ? mapPermissions[permissions] : permissions + ); if (generateSecret) { params = params.append('generate-secret', 'true'); } else { params = params.append('secret-key', secretKey); } - return this.http.put(this.url, null, {params: params}); + return this.http.put(this.url, null, { params: params }); } deleteSubuser(uid: string, subuser: string) { @@ -105,25 +111,30 @@ export class RgwUserService { params = params.append('uid', uid); params = params.append('subuser', subuser); params = params.append('purge-keys', 'true'); - return this.http.delete(this.url, {params: params}); + return this.http.delete(this.url, { params: params }); } addCapability(uid: string, type: string, perm: string) { let params = new HttpParams(); params = params.append('uid', uid); params = params.append('user-caps', `${type}=${perm}`); - return this.http.put(`${this.url}?caps`, null, {params: params}); + return this.http.put(`${this.url}?caps`, null, { params: params }); } deleteCapability(uid: string, type: string, perm: string) { let params = new HttpParams(); params = params.append('uid', uid); params = params.append('user-caps', `${type}=${perm}`); - return this.http.delete(`${this.url}?caps`, {params: params}); + return this.http.delete(`${this.url}?caps`, { params: params }); } - addS3Key(uid: string, subuser: string, accessKey: string, - secretKey: string, generateKey: boolean) { + addS3Key( + uid: string, + subuser: string, + accessKey: string, + secretKey: string, + generateKey: boolean + ) { let params = new HttpParams(); params = params.append('uid', uid); params = params.append('key-type', 's3'); @@ -133,7 +144,7 @@ export class RgwUserService { params = params.append('secret-key', secretKey); } params = params.append('subuser', subuser); - return this.http.put(`${this.url}?key`, null, {params: params}); + return this.http.put(`${this.url}?key`, null, { params: params }); } deleteS3Key(uid: string, accessKey: string) { @@ -141,7 +152,7 @@ export class RgwUserService { params = params.append('uid', uid); params = params.append('key-type', 's3'); params = params.append('access-key', accessKey); - return this.http.delete(`${this.url}?key`, {params: params}); + return this.http.delete(`${this.url}?key`, { params: params }); } /** @@ -150,10 +161,9 @@ export class RgwUserService { * @return {Observable} */ exists(uid: string) { - return this.enumerate() - .flatMap((resp: string[]) => { - const index = _.indexOf(resp, uid); - return Observable.of(-1 !== index); - }); + return this.enumerate().flatMap((resp: string[]) => { + const index = _.indexOf(resp, uid); + return Observable.of(-1 !== index); + }); } } -- 2.39.5