Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 7x 7x 7x 7x 7x 7x 7x 7x 13x 13x 13x 7x 2x 1x 1x 7x 7x 2x 1x 1x 7x 2x 2x 2x 2x 2x 2x 7x 1x 1x 7x 7x 7x 7x 7x | import { Component, Input } from '@angular/core'; import { FormArray, FormControl, Validators } from '@angular/forms'; import { I18n } from '@ngx-translate/i18n-polyfill'; import * as _ from 'lodash'; import { NfsService } from '../../../shared/api/nfs.service'; import { CdFormGroup } from '../../../shared/forms/cd-form-group'; @Component({ selector: 'cd-nfs-form-client', template: require('./nfs-form-client.component.html'), styles: [] }) export class NfsFormClientComponent { @Input() form: CdFormGroup; nfsSquash: any[] = this.nfsService.nfsSquash; nfsAccessType: any[] = this.nfsService.nfsAccessType; constructor(private nfsService: NfsService, private i18n: I18n) {} getNoAccessTypeDescr() { if (this.form.getValue('access_type')) { return `${this.form.getValue('access_type')} ${this.i18n('(inherited from global config)')}`; } return this.i18n('-- Select the access type --'); } getAccessTypeHelp(index) { const accessTypeItem = this.nfsAccessType.find((currentAccessTypeItem) => { return this.getValue(index, 'access_type') === currentAccessTypeItem.value; }); return _.isObjectLike(accessTypeItem) ? accessTypeItem.help : ''; } getNoSquashDescr() { if (this.form.getValue('squash')) { return `${this.form.getValue('squash')} (${this.i18n('inherited from global config')})`; } return this.i18n('-- Select what kind of user id squashing is performed --'); } addClient() { const clients = this.form.get('clients') as FormArray; const REGEX_IP = `(([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\.([0-9]{1,3})([/](\\d|[1-2]\\d|3[0-2]))?)`; const REGEX_LIST_IP = `${REGEX_IP}([ ,]{1,2}${REGEX_IP})*`; const fg = new CdFormGroup({ addresses: new FormControl('', { validators: [Validators.required, Validators.pattern(REGEX_LIST_IP)] }), access_type: new FormControl(''), squash: new FormControl('') }); clients.push(fg); return fg; } removeClient(index) { const clients = this.form.get('clients') as FormArray; clients.removeAt(index); } showError(index, control, formDir, x) { return (<any>this.form.controls.clients).controls[index].showError(control, formDir, x); } getValue(index, control) { const clients = this.form.get('clients') as FormArray; const client = clients.at(index) as CdFormGroup; return client.getValue(control); } resolveModel(clients: any[]) { _.forEach(clients, (client) => { const fg = this.addClient(); fg.patchValue(client); }); } trackByFn(index) { return index; } } |