<!-- Size -->
<div class="form-item">
- <cds-text-label for="size"
+ <cds-text-label labelInputID="size"
i18n
[invalid]="!rbdForm.controls['size'].valid && (rbdForm.controls['size'].dirty)"
[invalidText]="sizeError"
type="text"
placeholder="e.g., 10GiB"
id="size"
- name="size"
formControlName="size"
defaultUnit="GiB"
[invalid]="!rbdForm.controls['size'].valid && (rbdForm.controls['size'].dirty)"
i18n>This field is required.</span>
<span class="invalid-feedback"
*ngIf="rbdForm.showError('size', formDir, 'invalidSizeObject')"
- i18n>You have to increase the size.</span>
+ i18n>Size must be increased.</span>
<span *ngIf="rbdForm.showError('size', formDir, 'pattern')"
class="invalid-feedback"
i18n>Size must be a number or in a valid format. eg: 5 GiB</span>
<div class="form-item"
*ngIf="mode !== 'editing' && rbdForm.getValue('pool') && namespaces === null">
<cds-select label="Namespace"
- for="namespace"
- name="namespace"
+ labelInputID="namespace"
id="namespace"
[skeleton]="true"
formControlName="namespace">
<div class="form-item"
*ngIf="(mode === 'editing' && rbdForm.getValue('namespace')) || mode !== 'editing' && (namespaces && namespaces.length > 0 || !poolPermission.read)">
<cds-text-label label="Namespace"
- id="namespace"
+ labelInputID="namespace"
[helperText]="namespaceHelperTpl"
*ngIf="mode === 'editing' || !poolPermission.read"
i18n>Namespace
<cds-select label="Namespace"
[helperText]="namespaceHelperTpl"
- for="namespace"
- name="namespace"
id="namespace"
formControlName="namespace"
(valueChange)="disableMirroring($event)"
<!-- Snapshot Schedule Interval -->
<div class="form-item"
- *ngIf="rbdForm.getValue('mirroringMode') === 'snapshot' && mirroring">
+ *ngIf="rbdForm.getValue('mirroringMode') === rbdMirrorModes.snapshot && mirroring">
<cds-text-label for="schedule"
helperText="Create Mirror-Snapshots automatically on a periodic basis. The interval can be specified in days, hours, or minutes using d, h, m suffix respectively. To create mirror snapshots, you must import or create and have available peers to mirror"
cdRequiredField="Schedule Interval"
import { RbdFormMode } from './rbd-form-mode.enum';
import { RbdFormResponseModel } from './rbd-form-response.model';
import { CdValidators } from '~/app/shared/forms/cd-validators';
-import { RBDActionHelpers } from '../rbd-contants';
+import { RBDActionHelpers, RBDMirroringModes, RBDPoolMirrorModes } from '../rbd-contants';
class ExternalData {
rbd: RbdFormResponseModel;
snapName: string;
defaultObjectSize = '4 MiB';
+ rbdPoolMirrorModes = RBDPoolMirrorModes;
+ rbdMirrorModes = RBDMirroringModes;
+
mirroringOptions = [
{
- value: 'journal',
+ value: this.rbdMirrorModes.journal,
text: RBDActionHelpers.journalTooltipText
},
{
- value: 'snapshot',
+ value: this.rbdMirrorModes.snapshot,
text: RBDActionHelpers.snapshotTooltipText
}
];
validators: [
Validators.pattern(/^([0-9]+)d|([0-9]+)h|([0-9]+)m$/),
CdValidators.requiredIf({
- mirroringMode: 'snapshot',
+ mirroringMode: this.rbdMirrorModes.snapshot,
mirroring: true
})
] // check schedule interval to be in format - 1d or 1h or 1m
}
setExclusiveLock() {
- if (this.mirroring && this.rbdForm.get('mirroringMode').value === 'journal') {
+ if (this.mirroring && this.rbdForm.get('mirroringMode').value === this.rbdMirrorModes.journal) {
this.rbdForm.get('exclusive-lock').setValue(true);
this.rbdForm.get('exclusive-lock').disable();
} else {
} else {
this.showMirrorDisableMessage = false;
}
- if (this.currentPoolMirrorMode !== 'image') {
+ if (this.currentPoolMirrorMode !== this.rbdPoolMirrorModes.image) {
this.rbdForm.get('mirroring').disable();
this.rbdForm.get('mirroringMode').disable();
}
}
if (this.mode === this.rbdFormMode.editing) {
this.rbdForm.get('name').setValue(response.name);
- if (response?.mirror_mode === 'snapshot' || response.features_name.includes('journaling')) {
+ if (
+ response?.mirror_mode === this.rbdMirrorModes.snapshot ||
+ response.features_name.includes('journaling')
+ ) {
this.mirroring = true;
this.rbdForm.get('mirroring').setValue(this.mirroring);
this.rbdForm.get('mirroringMode').setValue(response?.mirror_mode);
request.size = this.formatter.toBytes(this.rbdForm.getValue('size'));
this.addObjectSizeAndStripingToRequest(request);
request.configuration = this.getDirtyConfigurationValues();
- if (this.mirroring && this.currentPoolMirrorMode === 'image') {
+ if (this.mirroring && this.currentPoolMirrorMode === this.rbdPoolMirrorModes.image) {
request.mirror_mode = this.rbdForm.getValue('mirroringMode');
}
return request;
}
});
- if (this.mirroring && this.rbdForm.getValue('mirroringMode') === 'journal') {
+ if (this.mirroring && this.rbdForm.getValue('mirroringMode') === this.rbdMirrorModes.journal) {
request.features.push('journaling');
}
});
if (request.enable_mirror) {
request.image_mirror_mode = this.currentImageMirrorMode;
- if (this.rbdForm.getValue('mirroringMode') === 'journal') {
- request.mirror_mode = 'journal';
+ if (this.rbdForm.getValue('mirroringMode') === this.rbdMirrorModes.journal) {
+ request.mirror_mode = this.rbdMirrorModes.journal;
request.features.push('journaling');
}
- if (this.currentPoolMirrorMode === 'image') {
+ if (this.currentPoolMirrorMode === this.rbdPoolMirrorModes.image) {
request.mirror_mode = this.rbdForm.getValue('mirroringMode');
}
} else {
}
shouldDisable(option: string): boolean {
- return this.currentPoolMirrorMode === 'pool' && option === 'snapshot' ? true : false;
+ return (
+ this.currentPoolMirrorMode === this.rbdPoolMirrorModes.pool &&
+ option === this.rbdMirrorModes.snapshot
+ );
}
disableMirroring(namespace: string) {
const mirroringControl = this.rbdForm.get('mirroring');
if (namespace) {
this.mirroring = false;
+ mirroringControl.setValue(false);
mirroringControl.disable();
} else {
- this.mirroring = true;
mirroringControl.enable();
}
}