|
| 1 | +<cd-modal [modalRef]="activeModal"> |
| 2 | + <ng-container i18n="form title" |
| 3 | + class="modal-title">{{ action | titlecase }} {{ resource | upperFirst }}</ng-container> |
| 4 | + <ng-container class="modal-content" |
| 5 | + *cdFormLoading="loading"> |
| 6 | + <form name="snapScheduleForm" |
| 7 | + #formDir="ngForm" |
| 8 | + [formGroup]="snapScheduleForm" |
| 9 | + novalidate> |
| 10 | + <div class="modal-body"> |
| 11 | + <!-- Directory --> |
| 12 | + <div class="form-group row"> |
| 13 | + <label class="cd-col-form-label required" |
| 14 | + for="directory" |
| 15 | + i18n>Directory |
| 16 | + </label> |
| 17 | + <div class="cd-col-form-input"> |
| 18 | + <ng-template #loading> |
| 19 | + <i [ngClass]="[icons.spinner, icons.spin, 'mt-2', 'me-2']"></i> |
| 20 | + <span i18n>Loading directories</span> |
| 21 | + </ng-template> |
| 22 | + <select class="form-select" |
| 23 | + id="directory" |
| 24 | + name="directory" |
| 25 | + formControlName="directory" |
| 26 | + *ngIf="directories$ | async as directories; else loading"> |
| 27 | + <option [ngValue]="null" |
| 28 | + i18n>--Select a directory--</option> |
| 29 | + <option *ngFor="let dir of directories" |
| 30 | + [value]="dir.path">{{ dir.path }}</option> |
| 31 | + </select> |
| 32 | + <span class="invalid-feedback" |
| 33 | + *ngIf="snapScheduleForm.showError('directory', formDir, 'required')" |
| 34 | + i18n>This field is required.</span> |
| 35 | + <span class="invalid-feedback" |
| 36 | + *ngIf="snapScheduleForm.showError('directory', formDir, 'notUnique')" |
| 37 | + i18n>A snapshot schedule for this path already exists.</span> |
| 38 | + </div> |
| 39 | + </div> |
| 40 | + <!--Start date --> |
| 41 | + <div class="form-group row"> |
| 42 | + <label class="cd-col-form-label required" |
| 43 | + for="startDate" |
| 44 | + i18n>Start date |
| 45 | + </label> |
| 46 | + <div class="cd-col-form-input"> |
| 47 | + <div class="input-group"> |
| 48 | + <input class="form-control" |
| 49 | + placeholder="yyyy-mm-dd" |
| 50 | + name="startDate" |
| 51 | + id="startDate" |
| 52 | + formControlName="startDate" |
| 53 | + [minDate]="minDate" |
| 54 | + ngbDatepicker |
| 55 | + #d="ngbDatepicker" |
| 56 | + (click)="d.open()"> |
| 57 | + <button type="button" |
| 58 | + class="btn btn-light" |
| 59 | + (click)="d.toggle()" |
| 60 | + title="Open"> |
| 61 | + <i [ngClass]="icons.calendar"></i> |
| 62 | + </button> |
| 63 | + </div> |
| 64 | + <span class="invalid-feedback" |
| 65 | + *ngIf="snapScheduleForm.showError('startDate', formDir, 'required')" |
| 66 | + i18n>This field is required.</span> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + <!-- Start time --> |
| 70 | + <div class="form-group row"> |
| 71 | + <label class="cd-col-form-label required" |
| 72 | + for="startTime" |
| 73 | + i18n>Start time |
| 74 | + <cd-helper>The time zone is assumed to be UTC.</cd-helper> |
| 75 | + </label> |
| 76 | + <div class="cd-col-form-input"> |
| 77 | + <ngb-timepicker [spinners]="false" |
| 78 | + [seconds]="false" |
| 79 | + [meridian]="true" |
| 80 | + formControlName="startTime" |
| 81 | + id="startTime" |
| 82 | + name="startTime"></ngb-timepicker> |
| 83 | + <span class="invalid-feedback" |
| 84 | + *ngIf="snapScheduleForm.showError('startTime', formDir, 'required')" |
| 85 | + i18n>This field is required.</span> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + <!-- Repeat interval --> |
| 89 | + <div class="form-group row"> |
| 90 | + <label class="cd-col-form-label required" |
| 91 | + for="repeatInterval" |
| 92 | + i18n>Schedule |
| 93 | + </label> |
| 94 | + <div class="cd-col-form-input"> |
| 95 | + <div class="input-group"> |
| 96 | + <input class="form-control" |
| 97 | + type="number" |
| 98 | + min="1" |
| 99 | + id="repeatInterval" |
| 100 | + name="repeatInterval" |
| 101 | + formControlName="repeatInterval"> |
| 102 | + <select [ngClass]="['form-select', 'me-5']" |
| 103 | + id="repeatFrequency" |
| 104 | + name="repeatFrequency" |
| 105 | + formControlName="repeatFrequency" |
| 106 | + *ngIf="repeatFrequencies"> |
| 107 | + <option *ngFor="let freq of repeatFrequencies" |
| 108 | + [value]="freq[1]" |
| 109 | + i18n>{{ freq[0] }}</option> |
| 110 | + </select> |
| 111 | + </div> |
| 112 | + <span class="invalid-feedback" |
| 113 | + *ngIf="snapScheduleForm.showError('repeatFrequency', formDir, 'notUnique')" |
| 114 | + i18n>This schedule already exists for the selected directory.</span> |
| 115 | + <span class="invalid-feedback" |
| 116 | + *ngIf="snapScheduleForm.showError('repeatInterval', formDir, 'required')" |
| 117 | + i18n>This field is required.</span> |
| 118 | + <span class="invalid-feedback" |
| 119 | + *ngIf="snapScheduleForm.showError('repeatInterval', formDir, 'min')" |
| 120 | + i18n>Choose a value greater than 0.</span> |
| 121 | + </div> |
| 122 | + </div> |
| 123 | + <!-- Retention policies --> |
| 124 | + <ng-container formArrayName="retentionPolicies" |
| 125 | + *ngFor="let retentionPolicy of retentionPolicies.controls; index as i"> |
| 126 | + <ng-container [formGroupName]="i"> |
| 127 | + <div class="form-group row"> |
| 128 | + <label [ngClass]="{'cd-col-form-label': true, 'visible': i == 0, 'invisible': i > 0}" |
| 129 | + for="retentionInterval" |
| 130 | + i18n>Retention policy |
| 131 | + </label> |
| 132 | + <div class="cd-col-form-input"> |
| 133 | + <div class="input-group"> |
| 134 | + <input class="form-control" |
| 135 | + type="number" |
| 136 | + min="1" |
| 137 | + id="retentionInterval" |
| 138 | + name="retentionInterval" |
| 139 | + formControlName="retentionInterval"> |
| 140 | + <select class="form-select" |
| 141 | + id="retentionFrequency" |
| 142 | + name="retentionFrequency" |
| 143 | + formControlName="retentionFrequency" |
| 144 | + *ngIf="retentionFrequencies"> |
| 145 | + <option *ngFor="let freq of retentionFrequencies" |
| 146 | + [value]="freq[1]" |
| 147 | + i18n>{{ freq[0] }}</option> |
| 148 | + </select> |
| 149 | + <button class="btn btn-light" |
| 150 | + type="button" |
| 151 | + (click)="removeRetentionPolicy(i)"> |
| 152 | + <i [ngClass]="[icons.trash]"></i> |
| 153 | + </button> |
| 154 | + </div> |
| 155 | + <span class="invalid-feedback" |
| 156 | + *ngIf="snapScheduleForm.controls['retentionPolicies'].controls[i].invalid" |
| 157 | + i18n>This retention policy already exists for the selected directory.</span> |
| 158 | + </div> |
| 159 | + </div> |
| 160 | + </ng-container> |
| 161 | + </ng-container> |
| 162 | + <div class="d-flex flex-row align-content-center justify-content-end"> |
| 163 | + <button class="btn btn-light" |
| 164 | + type="button" |
| 165 | + (click)="addRetentionPolicy()"> |
| 166 | + <i [ngClass]="[icons.add, 'me-2']"></i> |
| 167 | + <span i18n>Add retention policy</span> |
| 168 | + </button> |
| 169 | + </div> |
| 170 | + </div> |
| 171 | + |
| 172 | + <div class="modal-footer"> |
| 173 | + <cd-form-button-panel (submitActionEvent)="submit()" |
| 174 | + [form]="snapScheduleForm" |
| 175 | + [submitText]="(action | titlecase) + ' ' + (resource | upperFirst)"></cd-form-button-panel> |
| 176 | + </div> |
| 177 | + </form> |
| 178 | + </ng-container> |
| 179 | +</cd-modal> |
0 commit comments