|
| 1 | +<div class="container"> |
| 2 | + <form (ngSubmit)="onSubmit()" [formGroup]="formModel"> |
| 3 | + <div class="d-flex"> |
| 4 | + <h1 class="flex-grow-1">{{ isNewService ? ('ldn-create-service.title' | translate) : ('ldn-edit-registered-service.title' | translate) }}</h1> |
| 5 | + </div> |
| 6 | + <!-- In the toggle section --> |
| 7 | + <div class="toggle-switch-container" *ngIf="!isNewService"> |
| 8 | + <label class="status-label font-weight-bold" for="enabled">{{ 'ldn-service-status' | translate }}</label> |
| 9 | + <div> |
| 10 | + <input formControlName="enabled" hidden id="enabled" name="enabled" type="checkbox"> |
| 11 | + <div (click)="toggleEnabled()" [class.checked]="formModel.get('enabled').value" class="toggle-switch"> |
| 12 | + <div class="slider"></div> |
| 13 | + </div> |
| 14 | + </div> |
| 15 | + </div> |
| 16 | + <!-- In the Name section --> |
| 17 | + <div class="mb-5"> |
| 18 | + <label for="name" class="font-weight-bold">{{ 'ldn-new-service.form.label.name' | translate }}</label> |
| 19 | + <input [class.invalid-field]="formModel.get('name').invalid && formModel.get('name').touched" |
| 20 | + [placeholder]="'ldn-new-service.form.placeholder.name' | translate" class="form-control" |
| 21 | + formControlName="name" |
| 22 | + id="name" |
| 23 | + name="name" |
| 24 | + type="text"> |
| 25 | + <div *ngIf="formModel.get('name').invalid && formModel.get('name').touched" class="error-text"> |
| 26 | + {{ 'ldn-new-service.form.error.name' | translate }} |
| 27 | + </div> |
| 28 | + </div> |
| 29 | + |
| 30 | + <!-- In the description section --> |
| 31 | + <div class="mb-5 mt-5 d-flex flex-column"> |
| 32 | + <label for="description" class="font-weight-bold">{{ 'ldn-new-service.form.label.description' | translate }}</label> |
| 33 | + <textarea [placeholder]="'ldn-new-service.form.placeholder.description' | translate" |
| 34 | + class="form-control" formControlName="description" id="description" name="description"></textarea> |
| 35 | + </div> |
| 36 | + |
| 37 | + <div class="mb-5 mt-5"> |
| 38 | + <!-- In the url section --> |
| 39 | + <div class="d-flex align-items-center"> |
| 40 | + <div class="d-flex flex-column w-50 mr-2"> |
| 41 | + <label for="url" class="font-weight-bold">{{ 'ldn-new-service.form.label.url' | translate }}</label> |
| 42 | + <input [class.invalid-field]="formModel.get('url').invalid && formModel.get('url').touched" |
| 43 | + [placeholder]="'ldn-new-service.form.placeholder.url' | translate" class="form-control" |
| 44 | + formControlName="url" |
| 45 | + id="url" |
| 46 | + name="url" |
| 47 | + type="text"> |
| 48 | + <div *ngIf="formModel.get('url').invalid && formModel.get('url').touched" class="error-text"> |
| 49 | + {{ 'ldn-new-service.form.error.url' | translate }} |
| 50 | + </div> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div class="d-flex flex-column w-50"> |
| 54 | + <label for="score" class="font-weight-bold">{{ 'ldn-new-service.form.label.score' | translate }}</label> |
| 55 | + <input [class.invalid-field]="formModel.get('score').invalid && formModel.get('score').touched" |
| 56 | + [placeholder]="'ldn-new-service.form.placeholder.score' | translate" formControlName="score" |
| 57 | + id="score" |
| 58 | + name="score" |
| 59 | + min="0" |
| 60 | + max="1" |
| 61 | + step=".01" |
| 62 | + class="form-control" |
| 63 | + type="number"> |
| 64 | + <div *ngIf="formModel.get('score').invalid && formModel.get('score').touched" class="error-text"> |
| 65 | + {{ 'ldn-new-service.form.error.score' | translate }} |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + |
| 71 | + <!-- In the IP range section --> |
| 72 | + <div class="mb-5 mt-5"> |
| 73 | + <label for="lowerIp" class="font-weight-bold">{{ 'ldn-new-service.form.label.ip-range' | translate }}</label> |
| 74 | + <div class="d-flex"> |
| 75 | + <input [class.invalid-field]="formModel.get('lowerIp').invalid && formModel.get('lowerIp').touched" |
| 76 | + [placeholder]="'ldn-new-service.form.placeholder.lowerIp' | translate" class="form-control mr-2" |
| 77 | + formControlName="lowerIp" |
| 78 | + id="lowerIp" |
| 79 | + name="lowerIp" |
| 80 | + type="text"> |
| 81 | + <input [class.invalid-field]="formModel.get('upperIp').invalid && formModel.get('upperIp').touched" |
| 82 | + [placeholder]="'ldn-new-service.form.placeholder.upperIp' | translate" class="form-control" |
| 83 | + formControlName="upperIp" |
| 84 | + id="upperIp" |
| 85 | + name="upperIp" |
| 86 | + type="text"> |
| 87 | + </div> |
| 88 | + <div *ngIf="(formModel.get('lowerIp').invalid && formModel.get('lowerIp').touched) || (formModel.get('upperIp').invalid && formModel.get('upperIp').touched)" class="error-text"> |
| 89 | + {{ 'ldn-new-service.form.error.ipRange' | translate }} |
| 90 | + </div> |
| 91 | + <div class="text-muted"> |
| 92 | + {{ 'ldn-new-service.form.hint.ipRange' | translate }} |
| 93 | + </div> |
| 94 | + </div> |
| 95 | + |
| 96 | + <!-- In the ldnUrl section --> |
| 97 | + <div class="mb-5 mt-5"> |
| 98 | + <label for="ldnUrl" class="font-weight-bold">{{ 'ldn-new-service.form.label.ldnUrl' | translate }}</label> |
| 99 | + <input [class.invalid-field]="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" |
| 100 | + [placeholder]="'ldn-new-service.form.placeholder.ldnUrl' | translate" class="form-control" |
| 101 | + formControlName="ldnUrl" |
| 102 | + id="ldnUrl" |
| 103 | + name="ldnUrl" |
| 104 | + type="text"> |
| 105 | + <div *ngIf="formModel.get('ldnUrl').invalid && formModel.get('ldnUrl').touched" class="error-text"> |
| 106 | + {{ 'ldn-new-service.form.error.ldnurl' | translate }} |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + |
| 110 | + |
| 111 | + <!-- In the Inbound Patterns Labels section --> |
| 112 | + <div class="row mb-1 mt-5" *ngIf="areControlsInitialized"> |
| 113 | + <div class="col"> |
| 114 | + <label class="font-weight-bold">{{ 'ldn-new-service.form.label.inboundPattern' | translate }} </label> |
| 115 | + </div> |
| 116 | + <ng-container *ngIf="formModel.get('notifyServiceInboundPatterns')['controls'][0]?.value?.pattern"> |
| 117 | + <div class="col"> |
| 118 | + <label class="font-weight-bold">{{ 'ldn-new-service.form.label.ItemFilter' | translate }}</label> |
| 119 | + </div> |
| 120 | + <div class="col-sm-1"> |
| 121 | + <label class="font-weight-bold">{{ 'ldn-new-service.form.label.automatic' | translate }}</label> |
| 122 | + </div> |
| 123 | + </ng-container> |
| 124 | + <div class="col-sm-2"> |
| 125 | + </div> |
| 126 | + </div> |
| 127 | + |
| 128 | + <!-- In the Inbound Patterns section --> |
| 129 | + <div *ngIf="areControlsInitialized"> |
| 130 | + <div *ngFor="let patternGroup of formModel.get('notifyServiceInboundPatterns')['controls']; let i = index" |
| 131 | + [class.marked-for-deletion]="markedForDeletionInboundPattern.includes(i)" |
| 132 | + formGroupName="notifyServiceInboundPatterns"> |
| 133 | + |
| 134 | + <ng-container [formGroupName]="i"> |
| 135 | + |
| 136 | + |
| 137 | + <div class="row mb-1 align-items-center"> |
| 138 | + <div class="col"> |
| 139 | + <div #inboundPatternDropdown="ngbDropdown" class="w-80" display="dynamic" |
| 140 | + id="additionalInboundPattern{{i}}" |
| 141 | + ngbDropdown placement="top-start"> |
| 142 | + <div class="position-relative right-addon" role="combobox" aria-expanded="false" aria-controls="inboundPatternDropdownButton"> |
| 143 | + <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle" |
| 144 | + ngbDropdownToggle></i> |
| 145 | + <input |
| 146 | + (click)="inboundPatternDropdown.open();" |
| 147 | + [readonly]="true" |
| 148 | + [value]="selectedInboundPatterns" |
| 149 | + class="form-control w-80 scrollable-dropdown-input" |
| 150 | + formControlName="patternLabel" |
| 151 | + id="inboundPatternDropdownButton" |
| 152 | + ngbDropdownAnchor |
| 153 | + type="text" |
| 154 | + [attr.aria-label]="'ldn-service-input-inbound-pattern-dropdown' | translate" |
| 155 | + /> |
| 156 | + <div aria-labelledby="inboundPatternDropdownButton" |
| 157 | + class="dropdown-menu dropdown-menu-top w-100 " |
| 158 | + ngbDropdownMenu> |
| 159 | + <div class="scrollable-menu" role="listbox"> |
| 160 | + <button (click)="selectInboundPattern(pattern, i); $event.stopPropagation()" |
| 161 | + *ngFor="let pattern of inboundPatterns; let internalIndex = index" |
| 162 | + [title]="'ldn-service.form.pattern.' + pattern + '.description' | translate" |
| 163 | + class="dropdown-item collection-item text-truncate w-100" |
| 164 | + ngbDropdownItem |
| 165 | + type="button"> |
| 166 | + <div>{{ 'ldn-service.form.pattern.' + pattern + '.label' | translate }}</div> |
| 167 | + </button> |
| 168 | + </div> |
| 169 | + </div> |
| 170 | + </div> |
| 171 | + </div> |
| 172 | + </div> |
| 173 | + |
| 174 | + <div class="col"> |
| 175 | + <ng-container |
| 176 | + *ngIf="formModel.get('notifyServiceInboundPatterns')['controls'][i].value.pattern"> |
| 177 | + <div #inboundItemfilterDropdown="ngbDropdown" class="w-100" id="constraint{{i}}" ngbDropdown |
| 178 | + placement="top-start"> |
| 179 | + <div class="position-relative right-addon" aria-expanded="false" aria-controls="inboundItemfilterDropdown" role="combobox"> |
| 180 | + <i aria-hidden="true" class="position-absolute scrollable-dropdown-toggle" |
| 181 | + ngbDropdownToggle></i> |
| 182 | + <input |
| 183 | + [readonly]="true" |
| 184 | + class="form-control d-none w-100 scrollable-dropdown-input" |
| 185 | + formControlName="constraint" |
| 186 | + id="inboundItemfilterDropdown" |
| 187 | + ngbDropdownAnchor |
| 188 | + type="text" |
| 189 | + [attr.aria-label]="'ldn-service-input-inbound-item-filter-dropdown' | translate" |
| 190 | + /> |
| 191 | + <input |
| 192 | + (click)="inboundItemfilterDropdown.open();" |
| 193 | + [readonly]="true" |
| 194 | + class="form-control w-100 scrollable-dropdown-input" |
| 195 | + formControlName="constraintFormatted" |
| 196 | + id="inboundItemfilterDropdownPrettified" |
| 197 | + ngbDropdownAnchor |
| 198 | + type="text" |
| 199 | + [attr.aria-label]="'ldn-service-input-inbound-item-filter-dropdown' | translate" |
| 200 | + /> |
| 201 | + <div aria-labelledby="inboundItemfilterDropdownButton" |
| 202 | + class="dropdown-menu scrollable-dropdown-menu w-100 " |
| 203 | + ngbDropdownMenu> |
| 204 | + <div class="scrollable-menu" role="listbox"> |
| 205 | + <button (click)="selectInboundItemFilter('', i); $event.stopPropagation()" |
| 206 | + class="dropdown-item collection-item text-truncate w-100" ngbDropdownItem type="button"> |
| 207 | + <span> {{'ldn-service.control-constaint-select-none' | translate}} </span> |
| 208 | + </button> |
| 209 | + <button (click)="selectInboundItemFilter(constraint.id, i); $event.stopPropagation()" |
| 210 | + *ngFor="let constraint of (itemfiltersRD$ | async)?.payload?.page; let internalIndex = index" |
| 211 | + class="dropdown-item collection-item text-truncate w-100" |
| 212 | + ngbDropdownItem |
| 213 | + type="button"> |
| 214 | + <div>{{ constraint.id + '.label' | translate }}</div> |
| 215 | + </button> |
| 216 | + </div> |
| 217 | + </div> |
| 218 | + </div> |
| 219 | + </div> |
| 220 | + </ng-container> |
| 221 | + </div> |
| 222 | + |
| 223 | + <div |
| 224 | + [style.visibility]="formModel.get('notifyServiceInboundPatterns')['controls'][i].value.pattern ? 'visible' : 'hidden'" |
| 225 | + class="col-sm-1"> |
| 226 | + <input formControlName="automatic" hidden id="automatic{{i}}" name="automatic{{i}}" |
| 227 | + type="checkbox"> |
| 228 | + <div (click)="toggleAutomatic(i)" |
| 229 | + [class.checked]="formModel.get('notifyServiceInboundPatterns.' + i + '.automatic').value" |
| 230 | + class="toggle-switch"> |
| 231 | + <div class="slider"></div> |
| 232 | + </div> |
| 233 | + </div> |
| 234 | + |
| 235 | + |
| 236 | + <div class="col-sm-2"> |
| 237 | + <div class="btn-group"> |
| 238 | + <button (click)="markForInboundPatternDeletion(i)" class="btn btn-outline-dark trash-button" |
| 239 | + [title]="'ldn-service-button-mark-inbound-deletion' | translate" |
| 240 | + type="button"> |
| 241 | + <i class="fas fa-trash"></i> |
| 242 | + </button> |
| 243 | + |
| 244 | + |
| 245 | + <button (click)="unmarkForInboundPatternDeletion(i)" |
| 246 | + *ngIf="markedForDeletionInboundPattern.includes(i)" |
| 247 | + [title]="'ldn-service-button-unmark-inbound-deletion' | translate" |
| 248 | + class="btn btn-warning " |
| 249 | + type="button"> |
| 250 | + <i class="fas fa-undo"></i> |
| 251 | + </button> |
| 252 | + </div> |
| 253 | + </div> |
| 254 | + </div> |
| 255 | + </ng-container> |
| 256 | + </div> |
| 257 | + </div> |
| 258 | + |
| 259 | + <span (click)="addInboundPattern()" |
| 260 | + class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span> |
| 261 | + |
| 262 | + <div class="submission-form-footer my-1 position-sticky d-flex justify-content-between" role="group"> |
| 263 | + <button (click)="resetFormAndLeave()" class="btn btn-primary" type="button"> |
| 264 | + <span> {{ 'submission.general.back.submit' | translate }}</span> |
| 265 | + </button> |
| 266 | + <button class="btn btn-primary" type="submit"> |
| 267 | + <span><i class="fas fa-save"></i> {{ 'ldn-new-service.form.label.submit' | translate }}</span> |
| 268 | + </button> |
| 269 | + </div> |
| 270 | + </form> |
| 271 | +</div> |
| 272 | +<ng-template #confirmModal> |
| 273 | + <div class="modal-header"> |
| 274 | + <h4 *ngIf="!isNewService">{{'service.overview.edit.modal' | translate }}</h4> |
| 275 | + <h4 *ngIf="isNewService">{{'service.overview.create.modal' | translate }}</h4> |
| 276 | + <button (click)="closeModal()" aria-label="Close" |
| 277 | + class="close" type="button"> |
| 278 | + <span aria-hidden="true">×</span> |
| 279 | + </button> |
| 280 | + </div> |
| 281 | + |
| 282 | + <div class="modal-body"> |
| 283 | + <div *ngIf="!isNewService"> |
| 284 | + {{ 'service.overview.edit.body' | translate }} |
| 285 | + </div> |
| 286 | + <span *ngIf="isNewService"> |
| 287 | + {{ 'service.overview.create.body' | translate }} |
| 288 | + </span> |
| 289 | + </div> |
| 290 | + <div class="modal-footer"> |
| 291 | + <div *ngIf="!isNewService"> |
| 292 | + <button (click)="closeModal()" class="btn btn-danger mr-2" |
| 293 | + id="delete-confirm-edit">{{ 'service.detail.return' | translate }} |
| 294 | + </button> |
| 295 | + <button *ngIf="!isNewService" (click)="patchService()" |
| 296 | + class="btn btn-primary">{{ 'service.detail.update' | translate }} |
| 297 | + </button> |
| 298 | + </div> |
| 299 | + <div *ngIf="isNewService"> |
| 300 | + <button (click)="closeModal()" class="btn btn-danger mr-2 " |
| 301 | + id="delete-confirm-new">{{ 'service.refuse.create' | translate }} |
| 302 | + </button> |
| 303 | + <button (click)="createService()" |
| 304 | + class="btn btn-primary">{{ 'service.confirm.create' | translate }} |
| 305 | + </button> |
| 306 | + </div> |
| 307 | + </div> |
| 308 | +</ng-template> |
| 309 | + |
| 310 | + |
0 commit comments