Advanced Cluster Enhancements

	- Added edit cluster, profile type in OKA
	- State to Git State in all pages
	- Changed mandatory fields of edit profile
	- Changed api in cluster page

Change-Id: I8a3239f83eb58a3997e4550fc030694c0a2a6c72
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/src/app/utilities/compose-packages/ComposePackages.html b/src/app/utilities/compose-packages/ComposePackages.html
index 048e8cd..007b0ab 100644
--- a/src/app/utilities/compose-packages/ComposePackages.html
+++ b/src/app/utilities/compose-packages/ComposePackages.html
@@ -17,7 +17,7 @@
 -->
 <form [formGroup]="packagesForm" (ngSubmit)="createPackages()" autocomplete="off">
   <div class="modal-header">
-    <h4 class="modal-title" *ngIf="params.page === 'vnf-packages' || params.page === 'ns-packages'"
+    <h4 class="modal-title" *ngIf="params.page === 'vnf-package' || params.page === 'ns-package'"
       id="modal-basic-title">{{'CREATEPACKAGE' | translate}}</h4>
     <h4 class="modal-title" *ngIf="params.page === 'ns-config-template'" id="modal-basic-title">
       {{'PAGE.NSCONFIGTEMPLATE.CREATENSCONFIGTEMPLATE' | translate}}</h4>
@@ -36,18 +36,32 @@
       <label class="col-sm-12 col-form-label mandatory-label"
         [ngClass]="{'text-danger': packagesForm.invalid === true && submitted === true}">{{'MANDATORYCHECK' |
         translate}}</label>
-      <label class="col-sm-6 col-form-label" *ngIf="!template else configtemplate">{{'PACKAGE' | translate}} {{'NAME' |
-        translate}}*</label>
-      <ng-template #configtemplate>
-        <label class="col-sm-6 col-form-label">{{'NAME' | translate}}*</label>
-      </ng-template>
+      <label class="col-sm-6 col-form-label" *ngIf="!template && !oka">{{'PACKAGE' | translate}} {{'NAME' | translate}}*</label>
+      <label class="col-sm-6 col-form-label" *ngIf="!template && params.page === 'oka-packages'">{{'PACKAGE' | translate}} {{'NAME' | translate}}*</label>
+      <label class="col-sm-6 col-form-label" *ngIf="!template && params.page === 'oka-packages-edit'">{{'PACKAGE' | translate}} {{'NAME' | translate}}</label>
+      <label class="col-sm-6 col-form-label" *ngIf="template">{{'NAME' | translate}}*</label>
       <div class="col-sm-6">
         <input type="text" class="form-control" placeholder="{{'NAME' | translate}}" formControlName="name" id="name"
           [ngClass]="{ 'is-invalid': submitted && f.name.errors }" required>
       </div>
     </div>
     <div class="form-group row mb-3" *ngIf="oka">
-      <label class="col-sm-6 col-form-label" for="description">{{'PAGE.K8S.DESCRIPTION' | translate}}*</label>
+      <label class="col-sm-6 col-form-label" for="profile_type"
+        *ngIf="params.page === 'oka-packages'">{{'PAGE.K8S.PROFILETYPE' | translate}}*</label>
+      <label class="col-sm-6 col-form-label" for="profile_type"
+        *ngIf="params.page === 'oka-packages-edit'">{{'PAGE.K8S.PROFILETYPE' | translate}}</label>
+      <div class="col-sm-6">
+        <ng-select placeholder="{{'SELECT' | translate}} {{'TYPE' | translate}}" [items]="profileSelect"
+          bindLabel="title" bindValue="value" formControlName="profile_type" id="profile_type"
+          [ngClass]="{ 'is-invalid': submitted && f.profile_type.errors }" required>
+        </ng-select>
+      </div>
+    </div>
+    <div class="form-group row mb-3" *ngIf="oka">
+      <label class="col-sm-6 col-form-label" for="description"
+        *ngIf="params.page === 'oka-packages'">{{'PAGE.K8S.DESCRIPTION' | translate}}*</label>
+      <label class="col-sm-6 col-form-label" for="description"
+        *ngIf="params.page === 'oka-packages-edit'">{{'PAGE.K8S.DESCRIPTION' | translate}}</label>
       <div class="col-sm-6">
         <textarea class="form-control" placeholder="{{'PAGE.K8S.DESCRIPTION' | translate}}" type="text"
           formControlName="description" id="description" [ngClass]="{ 'is-invalid': submitted && f.description.errors }"
@@ -76,7 +90,8 @@
       </div>
     </div>
     <div class="form-group row mb-3" *ngIf="oka">
-      <label class="col-sm-6 col-form-label">{{'PACKAGE' | translate}}*</label>
+      <label class="col-sm-6 col-form-label" *ngIf="params.page === 'oka-packages'">{{'PACKAGE' | translate}}*</label>
+      <label class="col-sm-6 col-form-label" *ngIf="params.page === 'oka-packages-edit'">{{'PACKAGE' | translate}}</label>
       <div class="col-sm-6">
         <label for="fileInput" class="custom-file-upload" *ngIf="this.params.page === 'oka-packages-edit'">
           <input type="file" #fileInput class="fileupload custom-file-input" formControlName="package"
@@ -95,7 +110,7 @@
   <div class="modal-footer">
     <button type="button" class="btn btn-danger" (click)="activeModal.close()">{{'CANCEL' | translate}}</button>
     <button
-      *ngIf="params.page === 'ns-config-template' || params.page === 'oka-packages' || params.page === 'vnf-packages' || params.page === 'ns-packages'"
+      *ngIf="params.page === 'ns-config-template' || params.page === 'oka-packages' || params.page === 'vnf-package' || params.page === 'ns-package'"
       type="submit" class="btn btn-primary">{{'CREATE' | translate}}</button>
     <button *ngIf="params.page === 'ns-config-template-edit' || params.page === 'oka-packages-edit'" type="submit"
       class="btn btn-primary">{{'Edit' | translate}}</button>
diff --git a/src/app/utilities/compose-packages/ComposePackages.ts b/src/app/utilities/compose-packages/ComposePackages.ts
index 17adaa0..a8114d0 100644
--- a/src/app/utilities/compose-packages/ComposePackages.ts
+++ b/src/app/utilities/compose-packages/ComposePackages.ts
@@ -25,7 +25,7 @@
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import { TranslateService } from '@ngx-translate/core';
 import { NotifierService } from 'angular-notifier';
-import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, URLPARAMS } from 'CommonModel';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, TYPESECTION, URLPARAMS } from 'CommonModel';
 import { DataService } from 'DataService';
 import { environment } from 'environment';
 import * as jsyaml from 'js-yaml';
@@ -120,6 +120,12 @@
   /** Contains selected file name @public */
   public selectedFileName: string = 'Choose file...';
 
+  /** Contains all profile methods */
+  public profileSelect: TYPESECTION[] = [];
+
+  /** Contains all profile methods */
+  public operationType: string;
+
   /** Element ref for fileInputConfig @public */
   @ViewChild('fileInputConfig') fileInputConfig: ElementRef<HTMLInputElement>;
 
@@ -166,6 +172,22 @@
     this.router = this.injector.get(Router);
     this.translateService = this.injector.get(TranslateService);
     this.sharedService = this.injector.get(SharedService);
+    this.profileSelect = [
+      {
+        title: 'Infra Config Profile',
+        value: 'infra_config_profiles'
+      },
+      {
+        title: 'Infra Controller Profile',
+        value: 'infra_controller_profiles'
+      }, {
+        title: 'App Profile',
+        value: 'app_profiles'
+      }, {
+        title: 'Resource Profile',
+        value: 'resource_profiles'
+      }
+    ];
   }
 
   /** convenience getter for easy access to form fields */
@@ -180,11 +202,13 @@
       this.template = true;
       this.oka = false;
       this.getNsdPackageDetails();
+      this.getFormControl('profile_type').disable();
       this.getFormControl('description').disable();
     } else if (this.params.page === 'ns-config-template-edit') {
       this.template = true;
       this.oka = false;
       this.getNsdPackageDetails();
+      this.getFormControl('profile_type').disable();
       this.getFormControl('nsdId').disable();
       this.getFormControl('description').disable();
     } else if (this.params.page === 'oka-packages') {
@@ -205,8 +229,11 @@
       this.template = false;
       this.getFormControl('nsdId').disable();
       this.getFormControl('config').disable();
+      this.getFormControl('profile_type').disable();
       this.getFormControl('description').disable();
     }
+    this.operationType = this.params.operationType;
+    this.setValidatorsForOperation();
   }
 
   /** initialize Forms @public */
@@ -215,10 +242,30 @@
       name: ['', [Validators.required]],
       nsdId: [null, [Validators.required]],
       config: [null],
+      profile_type: [null],
       description: ['', [Validators.required]],
       package: ['']
     });
   }
+  /** Get NSD Package details @public */
+  public setValidatorsForOperation(): void {
+    if (this.params.page === 'oka-packages') {
+      this.packagesForm.get('name').setValidators([Validators.required]);
+      this.packagesForm.get('description').setValidators([Validators.required]);
+      this.packagesForm.get('package').setValidators([Validators.required]);
+      this.packagesForm.get('profile_type').setValidators([Validators.required]);
+    } else if (this.params.page === 'oka-packages-edit') {
+      this.packagesForm.get('profile_type').clearValidators();
+      this.packagesForm.get('name').clearValidators();
+      this.packagesForm.get('description').clearValidators();
+      this.packagesForm.get('package').clearValidators();
+    }
+    this.packagesForm.get('profile_type').updateValueAndValidity();
+    this.packagesForm.get('name').updateValueAndValidity();
+    this.packagesForm.get('description').updateValueAndValidity();
+    this.packagesForm.get('package').updateValueAndValidity();
+  }
+
 
   /** Get NSD Package details @public */
   public getNsdPackageDetails(): void {
@@ -250,7 +297,7 @@
         this.package_name = nsdPackageData.name;
         const package_file = nsdPackageData._admin.storage.zipfile;
         this.selectedFileName = package_file;
-        this.packagesForm.patchValue({ name: this.package_name, description: nsdPackageData.description });
+        this.packagesForm.patchValue({ name: this.package_name, description: nsdPackageData.description, profile_type: nsdPackageData.profile_type });
         this.fileInput.nativeElement.value = null;
       }, (error: ERRORDATA): void => {
         this.restService.handleError(error, 'get');
diff --git a/src/app/utilities/oka-packages-action/OkaPackagesActionComponent.ts b/src/app/utilities/oka-packages-action/OkaPackagesActionComponent.ts
index 7fef0d9..6fdbd1b 100644
--- a/src/app/utilities/oka-packages-action/OkaPackagesActionComponent.ts
+++ b/src/app/utilities/oka-packages-action/OkaPackagesActionComponent.ts
@@ -91,7 +91,7 @@
     public okaEdit(): void {
         // eslint-disable-next-line security/detect-non-literal-fs-filename
         const modalRef: NgbModalRef = this.modalService.open(ComposePackages, { backdrop: 'static' });
-        modalRef.componentInstance.params = { id: this.okaID, page: 'oka-packages-edit' };
+        modalRef.componentInstance.params = { id: this.okaID, page: 'oka-packages-edit', operationType: 'edit' };
         modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
             if (result) {
                 this.sharedService.callData();