]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Remove RBD "Default Features" checkbox 21526/head
authorRicardo Marques <rimarques@suse.com>
Mon, 23 Apr 2018 23:20:08 +0000 (00:20 +0100)
committerRicardo Marques <rimarques@suse.com>
Tue, 24 Apr 2018 15:50:37 +0000 (16:50 +0100)
Signed-off-by: Ricardo Marques <rimarques@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/api/rbd.service.ts

index 6fc7b86615a12b817ee667c586afa0e733927188..878b0631aef4101d4f81220780ae74458c83cb36 100644 (file)
           </label>
           <div class="col-sm-9">
             <div class="checkbox checkbox-primary"
-                 *ngIf="mode !== rbdFormMode.editing">
+                 *ngFor="let feature of featuresList">
               <input type="checkbox"
-                     id="default-features"
-                     name="default-features"
-                     formControlName="defaultFeatures">
-              <label i18n
-                     for="default-features">Use default features</label>
-            </div>
-            <div *ngIf="!featuresFormGroups.value.defaultFeatures">
-              <br *ngIf="mode !== rbdFormMode.editing">
-              <div class="checkbox checkbox-primary"
-                   *ngFor="let feature of featuresList">
-                <input type="checkbox"
-                       id="{{ feature.key }}"
-                       name="{{ feature.key }}"
-                       formControlName="{{ feature.key }}">
-                <label for="{{ feature.key }}">{{ feature.desc }}</label>
-                <cd-helper *ngIf="feature.helperHtml"
-                           html="{{ feature.helperHtml }}">
-                </cd-helper>
-              </div>
+                     id="{{ feature.key }}"
+                     name="{{ feature.key }}"
+                     formControlName="{{ feature.key }}">
+              <label for="{{ feature.key }}">{{ feature.desc }}</label>
+              <cd-helper *ngIf="feature.helperHtml"
+                         html="{{ feature.helperHtml }}">
+              </cd-helper>
             </div>
           </div>
         </div>
index d8c0cba9023b1300d02a627fe57a0081a16cc70b..d4c315c36cc3484fe23e7c18a4941acbc14083da 100644 (file)
@@ -29,7 +29,6 @@ export class RbdFormComponent implements OnInit {
 
   rbdForm: FormGroup;
   featuresFormGroups: FormGroup;
-  defaultFeaturesFormControl: FormControl;
   deepFlattenFormControl: FormControl;
   layeringFormControl: FormControl;
   exclusiveLockFormControl: FormControl;
@@ -130,7 +129,6 @@ export class RbdFormComponent implements OnInit {
   }
 
   createForm() {
-    this.defaultFeaturesFormControl = new FormControl(true);
     this.deepFlattenFormControl = new FormControl(false);
     this.layeringFormControl = new FormControl(false);
     this.exclusiveLockFormControl = new FormControl(false);
@@ -138,7 +136,6 @@ export class RbdFormComponent implements OnInit {
     this.journalingFormControl = new FormControl({value: false, disabled: true});
     this.fastDiffFormControl = new FormControl({value: false, disabled: true});
     this.featuresFormGroups = new FormGroup({
-      defaultFeatures: this.defaultFeaturesFormControl,
       'deep-flatten': this.deepFlattenFormControl,
       'layering': this.layeringFormControl,
       'exclusive-lock': this.exclusiveLockFormControl,
@@ -217,6 +214,11 @@ export class RbdFormComponent implements OnInit {
             });
         }
       );
+    } else {
+      this.rbdService.defaultFeatures()
+        .subscribe((defaultFeatures: Array<string>) => {
+          this.setFeatures(defaultFeatures);
+        });
     }
     this.poolService.list(['pool_name', 'type', 'flags_names', 'application_metadata']).then(
       resp => {
@@ -244,9 +246,6 @@ export class RbdFormComponent implements OnInit {
         }
       }
     );
-    this.defaultFeaturesFormControl.valueChanges.subscribe((value) => {
-      this.watchDataFeatures(null, value);
-    });
     this.deepFlattenFormControl.valueChanges.subscribe((value) => {
       this.watchDataFeatures('deep-flatten', value);
     });
@@ -380,9 +379,17 @@ export class RbdFormComponent implements OnInit {
   }
 
   watchDataFeatures(key, checked) {
-    if (!this.defaultFeaturesFormControl.value && key) {
-      this.featureFormUpdate(key, checked);
-    }
+    this.featureFormUpdate(key, checked);
+  }
+
+  setFeatures(features: Array<string>) {
+    const featuresControl = this.rbdForm.get('features');
+    _.forIn(this.features, (feature) => {
+      if (features.indexOf(feature.key) !== -1) {
+        featuresControl.get(feature.key).setValue(true);
+      }
+      this.watchDataFeatures(feature.key, featuresControl.get(feature.key).value);
+    });
   }
 
   setResponse(response: RbdFormResponseModel, snapName: string) {
@@ -410,13 +417,7 @@ 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));
-    const featuresControl = this.rbdForm.get('features');
-    featuresControl.get('defaultFeatures').setValue(false);
-    _.forIn(this.features, (feature) => {
-      if (response.features_name.indexOf(feature.key) !== -1) {
-        featuresControl.get(feature.key).setValue(true);
-      }
-    });
+    this.setFeatures(response.features_name);
     this.rbdForm.get('stripingUnit').setValue(
       this.dimlessBinaryPipe.transform(response.stripe_unit));
     this.rbdForm.get('stripingCount').setValue(response.stripe_count);
@@ -428,15 +429,11 @@ export class RbdFormComponent implements OnInit {
     request.name = this.rbdForm.get('name').value;
     request.size = this.formatter.toBytes(this.rbdForm.get('size').value);
     request.obj_size = this.formatter.toBytes(this.rbdForm.get('obj_size').value);
-    if (!this.defaultFeaturesFormControl.value) {
-      _.forIn(this.features, (feature) => {
-        if (this.featuresFormGroups.get(feature.key).value) {
-          request.features.push(feature.key);
-        }
-      });
-    } else {
-      request.features = null;
-    }
+    _.forIn(this.features, (feature) => {
+      if (this.featuresFormGroups.get(feature.key).value) {
+        request.features.push(feature.key);
+      }
+    });
     request.stripe_unit = this.formatter.toBytes(this.rbdForm.get('stripingUnit').value);
     request.stripe_count = this.rbdForm.get('stripingCount').value;
     request.data_pool = this.rbdForm.get('dataPool').value;
@@ -474,13 +471,11 @@ export class RbdFormComponent implements OnInit {
     const request = new RbdFormEditRequestModel();
     request.name = this.rbdForm.get('name').value;
     request.size = this.formatter.toBytes(this.rbdForm.get('size').value);
-    if (!this.defaultFeaturesFormControl.value) {
-      _.forIn(this.features, (feature) => {
-        if (this.featuresFormGroups.get(feature.key).value) {
-          request.features.push(feature.key);
-        }
-      });
-    }
+    _.forIn(this.features, (feature) => {
+      if (this.featuresFormGroups.get(feature.key).value) {
+        request.features.push(feature.key);
+      }
+    });
     return request;
   }
 
@@ -489,15 +484,11 @@ export class RbdFormComponent implements OnInit {
     request.child_pool_name = this.rbdForm.get('pool').value;
     request.child_image_name = this.rbdForm.get('name').value;
     request.obj_size = this.formatter.toBytes(this.rbdForm.get('obj_size').value);
-    if (!this.defaultFeaturesFormControl.value) {
-      _.forIn(this.features, (feature) => {
-        if (this.featuresFormGroups.get(feature.key).value) {
-          request.features.push(feature.key);
-        }
-      });
-    } else {
-      request.features = null;
-    }
+    _.forIn(this.features, (feature) => {
+      if (this.featuresFormGroups.get(feature.key).value) {
+        request.features.push(feature.key);
+      }
+    });
     request.stripe_unit = this.formatter.toBytes(this.rbdForm.get('stripingUnit').value);
     request.stripe_count = this.rbdForm.get('stripingCount').value;
     request.data_pool = this.rbdForm.get('dataPool').value;
@@ -578,15 +569,11 @@ export class RbdFormComponent implements OnInit {
     request.dest_pool_name = this.rbdForm.get('pool').value;
     request.dest_image_name = this.rbdForm.get('name').value;
     request.obj_size = this.formatter.toBytes(this.rbdForm.get('obj_size').value);
-    if (!this.defaultFeaturesFormControl.value) {
-      _.forIn(this.features, (feature) => {
-        if (this.featuresFormGroups.get(feature.key).value) {
-          request.features.push(feature.key);
-        }
-      });
-    } else {
-      request.features = null;
-    }
+    _.forIn(this.features, (feature) => {
+      if (this.featuresFormGroups.get(feature.key).value) {
+        request.features.push(feature.key);
+      }
+    });
     request.stripe_unit = this.formatter.toBytes(this.rbdForm.get('stripingUnit').value);
     request.stripe_count = this.rbdForm.get('stripingCount').value;
     request.data_pool = this.rbdForm.get('dataPool').value;
index 047a1a693e5fcb712179b54938a61003082e9f5b..30099c4a0f1f58343f57b2511264ae152dd9e4cb 100644 (file)
@@ -37,6 +37,10 @@ export class RbdService {
       { observe: 'response' });
   }
 
+  defaultFeatures() {
+    return this.http.get('api/block/image/default_features');
+  }
+
   createSnapshot(poolName, rbdName, snapshotName) {
     const request = {
       snapshot_name: snapshotName