rbdForm: FormGroup;
featuresFormGroups: FormGroup;
- defaultFeaturesFormControl: FormControl;
deepFlattenFormControl: FormControl;
layeringFormControl: FormControl;
exclusiveLockFormControl: FormControl;
}
createForm() {
- this.defaultFeaturesFormControl = new FormControl(true);
this.deepFlattenFormControl = new FormControl(false);
this.layeringFormControl = new FormControl(false);
this.exclusiveLockFormControl = new FormControl(false);
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,
});
}
);
+ } else {
+ this.rbdService.defaultFeatures()
+ .subscribe((defaultFeatures: Array<string>) => {
+ this.setFeatures(defaultFeatures);
+ });
}
this.poolService.list(['pool_name', 'type', 'flags_names', 'application_metadata']).then(
resp => {
}
}
);
- this.defaultFeaturesFormControl.valueChanges.subscribe((value) => {
- this.watchDataFeatures(null, value);
- });
this.deepFlattenFormControl.valueChanges.subscribe((value) => {
this.watchDataFeatures('deep-flatten', value);
});
}
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) {
}
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);
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;
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;
}
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;
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;