]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form-client/nfs-form-client.component.ts
import ceph 16.2.7
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / nfs / nfs-form-client / nfs-form-client.component.ts
index 8423f177567952303c4f9979174d73d8492393ea..942e96e2eb9674aef87266bcab7beaf624878f83 100644 (file)
@@ -1,4 +1,4 @@
-import { Component, Input, OnInit } from '@angular/core';
+import { Component, ContentChild, Input, OnInit, TemplateRef } from '@angular/core';
 import { FormArray, FormControl, NgForm, Validators } from '@angular/forms';
 
 import _ from 'lodash';
@@ -19,9 +19,12 @@ export class NfsFormClientComponent implements OnInit {
   @Input()
   clients: any[];
 
+  @ContentChild('squashHelper', { static: true }) squashHelperTpl: TemplateRef<any>;
+
   nfsSquash: any[] = this.nfsService.nfsSquash;
   nfsAccessType: any[] = this.nfsService.nfsAccessType;
   icons = Icons;
+  clientsFormArray: FormArray;
 
   constructor(private nfsService: NfsService) {}
 
@@ -30,6 +33,7 @@ export class NfsFormClientComponent implements OnInit {
       const fg = this.addClient();
       fg.patchValue(client);
     });
+    this.clientsFormArray = this.form.get('clients') as FormArray;
   }
 
   getNoAccessTypeDescr() {
@@ -54,11 +58,10 @@ export class NfsFormClientComponent implements OnInit {
   }
 
   addClient() {
-    const clients = this.form.get('clients') as FormArray;
+    this.clientsFormArray = 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)]
@@ -67,13 +70,13 @@ export class NfsFormClientComponent implements OnInit {
       squash: new FormControl('')
     });
 
-    clients.push(fg);
+    this.clientsFormArray.push(fg);
     return fg;
   }
 
   removeClient(index: number) {
-    const clients = this.form.get('clients') as FormArray;
-    clients.removeAt(index);
+    this.clientsFormArray = this.form.get('clients') as FormArray;
+    this.clientsFormArray.removeAt(index);
   }
 
   showError(index: number, control: string, formDir: NgForm, x: string) {
@@ -81,8 +84,8 @@ export class NfsFormClientComponent implements OnInit {
   }
 
   getValue(index: number, control: string) {
-    const clients = this.form.get('clients') as FormArray;
-    const client = clients.at(index) as CdFormGroup;
+    this.clientsFormArray = this.form.get('clients') as FormArray;
+    const client = this.clientsFormArray.at(index) as CdFormGroup;
     return client.getValue(control);
   }