]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Prettify some frontend files
authorTiago Melo <tmelo@suse.com>
Fri, 22 Jun 2018 14:13:53 +0000 (15:13 +0100)
committerTiago Melo <tmelo@suse.com>
Tue, 26 Jun 2018 13:35:15 +0000 (14:35 +0100)
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/shared/api/pool.service.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts

index 6bdf73f1089bd44839e4dd1c3ad7141a08875e6c..b980986a426f5704c81acb5e5d2f4e3235d946aa 100644 (file)
@@ -26,7 +26,6 @@ import { RbdFormResponseModel } from './rbd-form-response.model';
   styleUrls: ['./rbd-form.component.scss']
 })
 export class RbdFormComponent implements OnInit {
-
   poolPermission: Permission;
   rbdForm: FormGroup;
   featuresFormGroups: FormGroup;
@@ -91,7 +90,7 @@ export class RbdFormComponent implements OnInit {
         allowEnable: false,
         allowDisable: true
       },
-      'layering': {
+      layering: {
         desc: 'Layering',
         requires: null,
         allowEnable: false,
@@ -109,7 +108,7 @@ export class RbdFormComponent implements OnInit {
         allowEnable: true,
         allowDisable: true
       },
-      'journaling': {
+      journaling: {
         desc: 'Journaling (requires exclusive-lock)',
         requires: 'exclusive-lock',
         allowEnable: true,
@@ -134,41 +133,40 @@ export class RbdFormComponent implements OnInit {
     this.deepFlattenFormControl = new FormControl(false);
     this.layeringFormControl = new FormControl(false);
     this.exclusiveLockFormControl = new FormControl(false);
-    this.objectMapFormControl = new FormControl({value: false, disabled: true});
-    this.journalingFormControl = new FormControl({value: false, disabled: true});
-    this.fastDiffFormControl = new FormControl({value: false, disabled: true});
+    this.objectMapFormControl = new FormControl({ value: false, disabled: true });
+    this.journalingFormControl = new FormControl({ value: false, disabled: true });
+    this.fastDiffFormControl = new FormControl({ value: false, disabled: true });
     this.featuresFormGroups = new FormGroup({
       'deep-flatten': this.deepFlattenFormControl,
-      'layering': this.layeringFormControl,
+      layering: this.layeringFormControl,
       'exclusive-lock': this.exclusiveLockFormControl,
       'object-map': this.objectMapFormControl,
-      'journaling': this.journalingFormControl,
-      'fast-diff': this.fastDiffFormControl,
+      journaling: this.journalingFormControl,
+      'fast-diff': this.fastDiffFormControl
     });
-    this.rbdForm = new FormGroup({
-      parent: new FormControl(''),
-      name: new FormControl('', {
-        validators: [
-          Validators.required
-        ]
-      }),
-      pool: new FormControl(null, {
-        validators: [
-          Validators.required
-        ]
-      }),
-      useDataPool: new FormControl(false),
-      dataPool: new FormControl(null),
-      size: new FormControl(null, {
-        updateOn: 'blur'
-      }),
-      obj_size: new FormControl(this.defaultObjectSize),
-      features: this.featuresFormGroups,
-      stripingUnit: new FormControl(null),
-      stripingCount: new FormControl(null, {
-        updateOn: 'blur'
-      })
-    }, this.validateRbdForm(this.formatter));
+    this.rbdForm = new FormGroup(
+      {
+        parent: new FormControl(''),
+        name: new FormControl('', {
+          validators: [Validators.required]
+        }),
+        pool: new FormControl(null, {
+          validators: [Validators.required]
+        }),
+        useDataPool: new FormControl(false),
+        dataPool: new FormControl(null),
+        size: new FormControl(null, {
+          updateOn: 'blur'
+        }),
+        obj_size: new FormControl(this.defaultObjectSize),
+        features: this.featuresFormGroups,
+        stripingUnit: new FormControl(null),
+        stripingCount: new FormControl(null, {
+          updateOn: 'blur'
+        })
+      },
+      this.validateRbdForm(this.formatter)
+    );
   }
 
   disableForEdit() {
@@ -202,29 +200,28 @@ export class RbdFormComponent implements OnInit {
       this.mode = this.rbdFormMode.copying;
       this.disableForCopy();
     }
-    if (this.mode === this.rbdFormMode.editing ||
-        this.mode === this.rbdFormMode.cloning ||
-        this.mode === this.rbdFormMode.copying) {
-      this.route.params.subscribe(
-        (params: { pool: string, name: string, snap: string }) => {
-          const poolName = params.pool;
-          const rbdName = params.name;
-          this.snapName = params.snap;
-          this.rbdService.get(poolName, rbdName)
-            .subscribe((resp: RbdFormResponseModel) => {
-              this.setResponse(resp, this.snapName);
-            });
-        }
-      );
-    } else {
-      this.rbdService.defaultFeatures()
-        .subscribe((defaultFeatures: Array<string>) => {
-          this.setFeatures(defaultFeatures);
+    if (
+      this.mode === this.rbdFormMode.editing ||
+      this.mode === this.rbdFormMode.cloning ||
+      this.mode === this.rbdFormMode.copying
+    ) {
+      this.route.params.subscribe((params: { pool: string; name: string; snap: string }) => {
+        const poolName = params.pool;
+        const rbdName = params.name;
+        this.snapName = params.snap;
+        this.rbdService.get(poolName, rbdName).subscribe((resp: RbdFormResponseModel) => {
+          this.setResponse(resp, this.snapName);
         });
+      });
+    } else {
+      this.rbdService.defaultFeatures().subscribe((defaultFeatures: Array<string>) => {
+        this.setFeatures(defaultFeatures);
+      });
     }
     if (this.mode !== this.rbdFormMode.editing && this.poolPermission.read) {
-      this.poolService.list(['pool_name', 'type', 'flags_names', 'application_metadata']).then(
-        resp => {
+      this.poolService
+        .list(['pool_name', 'type', 'flags_names', 'application_metadata'])
+        .then((resp) => {
           const pools = [];
           const dataPools = [];
           for (const pool of resp) {
@@ -232,8 +229,10 @@ export class RbdFormComponent implements OnInit {
               if (pool.type === 'replicated') {
                 pools.push(pool);
                 dataPools.push(pool);
-              } else if (pool.type === 'erasure' &&
-                pool.flags_names.indexOf('ec_overwrites') !== -1) {
+              } else if (
+                pool.type === 'erasure' &&
+                pool.flags_names.indexOf('ec_overwrites') !== -1
+              ) {
                 dataPools.push(pool);
               }
             }
@@ -247,8 +246,7 @@ export class RbdFormComponent implements OnInit {
             this.rbdForm.get('pool').setValue(poolName);
             this.onPoolChange(poolName);
           }
-        }
-      );
+        });
     }
     this.deepFlattenFormControl.valueChanges.subscribe((value) => {
       this.watchDataFeatures('deep-flatten', value);
@@ -280,7 +278,7 @@ export class RbdFormComponent implements OnInit {
     this.dataPools = newDataPools;
   }
 
-  onUseDataPoolChange () {
+  onUseDataPoolChange() {
     if (!this.rbdForm.get('useDataPool').value) {
       this.rbdForm.get('dataPool').setValue(null);
       this.onDataPoolChange(null);
@@ -304,23 +302,24 @@ export class RbdFormComponent implements OnInit {
       const dataPoolControl = formGroup.get('dataPool');
       let dataPoolControlErrors = null;
       if (useDataPoolControl.value && dataPoolControl.value == null) {
-        dataPoolControlErrors = {'required': true};
+        dataPoolControlErrors = { required: true };
       }
       dataPoolControl.setErrors(dataPoolControlErrors);
       // Size
       const sizeControl = formGroup.get('size');
       const objectSizeControl = formGroup.get('obj_size');
       const objectSizeInBytes = formatter.toBytes(
-        objectSizeControl.value != null ? objectSizeControl.value : this.defaultObjectSize);
+        objectSizeControl.value != null ? objectSizeControl.value : this.defaultObjectSize
+      );
       const stripingCountControl = formGroup.get('stripingCount');
       const stripingCount = stripingCountControl.value != null ? stripingCountControl.value : 1;
       let sizeControlErrors = null;
       if (sizeControl.value === null) {
-        sizeControlErrors = {'required': true};
+        sizeControlErrors = { required: true };
       } else {
         const sizeInBytes = formatter.toBytes(sizeControl.value);
         if (stripingCount * objectSizeInBytes > sizeInBytes) {
-          sizeControlErrors = {'invalidSizeObject': true};
+          sizeControlErrors = { invalidSizeObject: true };
         }
       }
       sizeControl.setErrors(sizeControlErrors);
@@ -328,20 +327,20 @@ export class RbdFormComponent implements OnInit {
       const stripingUnitControl = formGroup.get('stripingUnit');
       let stripingUnitControlErrors = null;
       if (stripingUnitControl.value === null && stripingCountControl.value !== null) {
-        stripingUnitControlErrors = {'required': true};
+        stripingUnitControlErrors = { required: true };
       } else if (stripingUnitControl.value !== null) {
         const stripingUnitInBytes = formatter.toBytes(stripingUnitControl.value);
         if (stripingUnitInBytes > objectSizeInBytes) {
-          stripingUnitControlErrors = {'invalidStripingUnit': true};
+          stripingUnitControlErrors = { invalidStripingUnit: true };
         }
       }
       stripingUnitControl.setErrors(stripingUnitControlErrors);
       // Striping Count
       let stripingCountControlErrors = null;
       if (stripingCountControl.value === null && stripingUnitControl.value !== null) {
-        stripingCountControlErrors = {'required': true};
+        stripingCountControlErrors = { required: true };
       } else if (stripingCount < 1) {
-        stripingCountControlErrors = {'min': true};
+        stripingCountControlErrors = { min: true };
       }
       stripingCountControl.setErrors(stripingCountControlErrors);
       return null;
@@ -361,10 +360,8 @@ export class RbdFormComponent implements OnInit {
         }
       }
       if (this.mode === this.rbdFormMode.editing && this.featuresFormGroups.get(feature).enabled) {
-
         if (this.response.features_name.indexOf(feature) !== -1 && !details.allowDisable) {
           this.featuresFormGroups.get(feature).disable();
-
         } else if (this.response.features_name.indexOf(feature) === -1 && !details.allowEnable) {
           this.featuresFormGroups.get(feature).disable();
         }
@@ -409,7 +406,8 @@ export class RbdFormComponent implements OnInit {
       }
     } else if (response.parent) {
       const parent = response.parent;
-      this.rbdForm.get('parent')
+      this.rbdForm
+        .get('parent')
         .setValue(`${parent.pool_name}/${parent.image_name}@${parent.snap_name}`);
     }
     if (this.mode === this.rbdFormMode.editing) {
@@ -423,8 +421,9 @@ export class RbdFormComponent implements OnInit {
     this.rbdForm.get('size').setValue(this.dimlessBinaryPipe.transform(response.size));
     this.rbdForm.get('obj_size').setValue(this.dimlessBinaryPipe.transform(response.obj_size));
     this.setFeatures(response.features_name);
-    this.rbdForm.get('stripingUnit').setValue(
-      this.dimlessBinaryPipe.transform(response.stripe_unit));
+    this.rbdForm
+      .get('stripingUnit')
+      .setValue(this.dimlessBinaryPipe.transform(response.stripe_unit));
     this.rbdForm.get('stripingCount').setValue(response.stripe_count);
   }
 
index bf47f7389bcf6c19c68ab1709defcd0d76789361..c1024dd74be3f5a51fdebbfd8dfa6d1b28badd04 100644 (file)
@@ -17,7 +17,8 @@
           identifier="bucket"
           (fetchData)="getBucketList()">
   <div class="table-actions">
-    <div class="btn-group" dropdown>
+    <div class="btn-group"
+         dropdown>
       <button type="button"
               class="btn btn-sm btn-primary"
               *ngIf="permission.create && (
index 8ecdc669e9f382cbb16f23ae572a96d43ba8a7b6..4d5a90eb1bfcf2b69d8c823358da7f547f54d2a3 100644 (file)
@@ -7,18 +7,19 @@ import { ApiModule } from './api.module';
   providedIn: ApiModule
 })
 export class PoolService {
+  constructor(private http: HttpClient) {}
 
-  constructor(private http: HttpClient) {
-  }
-
-  getList () {
+  getList() {
     return this.http.get('api/pool');
   }
 
   list(attrs = []) {
     const attrsStr = attrs.join(',');
-    return this.http.get(`api/pool?attrs=${attrsStr}`).toPromise().then((resp: any) => {
-      return resp;
-    });
+    return this.http
+      .get(`api/pool?attrs=${attrsStr}`)
+      .toPromise()
+      .then((resp: any) => {
+        return resp;
+      });
   }
 }
index 134928551d99da98fa92004f48296e333edbc6f0..a22362ef35935cdd9dbe7eb9c16f6a0a0238d1c7 100644 (file)
@@ -7,9 +7,7 @@ import { ApiModule } from './api.module';
   providedIn: ApiModule
 })
 export class RbdService {
-
-  constructor(private http: HttpClient) {
-  }
+  constructor(private http: HttpClient) {}
 
   create(rbd) {
     return this.http.post('api/block/image', rbd, { observe: 'response' });
@@ -32,13 +30,15 @@ export class RbdService {
   }
 
   copy(poolName, rbdName, rbd) {
-    return this.http.post(`api/block/image/${poolName}/${rbdName}/copy`, rbd,
-      { observe: 'response' });
+    return this.http.post(`api/block/image/${poolName}/${rbdName}/copy`, rbd, {
+      observe: 'response'
+    });
   }
 
   flatten(poolName, rbdName) {
-    return this.http.post(`api/block/image/${poolName}/${rbdName}/flatten`, null,
-      { observe: 'response' });
+    return this.http.post(`api/block/image/${poolName}/${rbdName}/flatten`, null, {
+      observe: 'response'
+    });
   }
 
   defaultFeatures() {
@@ -49,43 +49,48 @@ export class RbdService {
     const request = {
       snapshot_name: snapshotName
     };
-    return this.http.post(`api/block/image/${poolName}/${rbdName}/snap`, request,
-      { observe: 'response' });
+    return this.http.post(`api/block/image/${poolName}/${rbdName}/snap`, request, {
+      observe: 'response'
+    });
   }
 
   renameSnapshot(poolName, rbdName, snapshotName, newSnapshotName) {
     const request = {
       new_snap_name: newSnapshotName
     };
-    return this.http.put(
-      `api/block/image/${poolName}/${rbdName}/snap/${snapshotName}`, request,
-        { observe: 'response' });
+    return this.http.put(`api/block/image/${poolName}/${rbdName}/snap/${snapshotName}`, request, {
+      observe: 'response'
+    });
   }
 
   protectSnapshot(poolName, rbdName, snapshotName, isProtected) {
     const request = {
       is_protected: isProtected
     };
-    return this.http.put(
-      `api/block/image/${poolName}/${rbdName}/snap/${snapshotName}`, request,
-      { observe: 'response' });
+    return this.http.put(`api/block/image/${poolName}/${rbdName}/snap/${snapshotName}`, request, {
+      observe: 'response'
+    });
   }
 
   rollbackSnapshot(poolName, rbdName, snapshotName) {
     return this.http.post(
-      `api/block/image/${poolName}/${rbdName}/snap/${snapshotName}/rollback`, null,
-      { observe: 'response' });
+      `api/block/image/${poolName}/${rbdName}/snap/${snapshotName}/rollback`,
+      null,
+      { observe: 'response' }
+    );
   }
 
   cloneSnapshot(poolName, rbdName, snapshotName, request) {
     return this.http.post(
-      `api/block/image/${poolName}/${rbdName}/snap/${snapshotName}/clone`, request,
-      { observe: 'response' });
+      `api/block/image/${poolName}/${rbdName}/snap/${snapshotName}/clone`,
+      request,
+      { observe: 'response' }
+    );
   }
 
   deleteSnapshot(poolName, rbdName, snapshotName) {
-    return this.http.delete(
-      `api/block/image/${poolName}/${rbdName}/snap/${snapshotName}`,
-      { observe: 'response' });
+    return this.http.delete(`api/block/image/${poolName}/${rbdName}/snap/${snapshotName}`, {
+      observe: 'response'
+    });
   }
 }
index baa609218b829878814a9ae2aa0209585370fabc..8d16e0ecf739ef8672bd04185bf76461bcf1ccec 100644 (file)
@@ -57,7 +57,7 @@ export class RgwBucketService {
     let params = new HttpParams();
     params = params.append('bucket_id', bucketId);
     params = params.append('uid', uid);
-    return this.http.put(`${this.url}/${bucket}`, null, { params: params});
+    return this.http.put(`${this.url}/${bucket}`, null, { params: params });
   }
 
   delete(bucket: string, purgeObjects = true) {