Advanced Cluster Management - NGUI

	- Added new OKA packages module under packages
	- Added Profiless, KSU under k8s section
	- Feature 11020. 11022, 11023, 11024, 11025, 11026

Change-Id: Ibddeb4d5693ce24d80e378277693405c810f6e04
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
diff --git a/src/app/k8s/k8s-action/K8sActionComponent.html b/src/app/k8s/k8s-action/K8sActionComponent.html
index c35bb19..ddce99c 100644
--- a/src/app/k8s/k8s-action/K8sActionComponent.html
+++ b/src/app/k8s/k8s-action/K8sActionComponent.html
@@ -16,12 +16,78 @@
 Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
 -->
 <div class="btn-group list action" role="group">
-  <button type="button" class="btn btn-primary" (click)="infoK8s(getK8sType)" placement="top" container="body"
-    ngbTooltip="{{'INFO' | translate}}">
+  <button *ngIf="getK8sType === 'repo'" type="button" class="btn btn-primary" (click)="infoK8s(getK8sType)"
+    placement="top" container="body" ngbTooltip="{{'INFO' | translate}}">
     <i class="fas fa-info icons list" title="info"></i>
   </button>
-  <button type="button" class="btn btn-primary" (click)="deleteK8s(getK8sType)" placement="top"
-    container="body" ngbTooltip="{{'DELETE' | translate}}">
+  <button *ngIf="(isCluster  || isProfile || isKSU) && getK8sType !== 'repo' && !checkRegister" [disabled]="state != 'CREATED'"
+    type="button" class="btn btn-primary" (click)="deleteK8s()" placement="top" container="body"
+    ngbTooltip="{{'DELETE' | translate}}">
     <i class="far fa-trash-alt icons" title="delete"></i>
   </button>
-</div>
\ No newline at end of file
+  <button *ngIf="(!isCluster  || !isProfile || !isKSU) && getK8sType === 'repo'" type="button" class="btn btn-primary"
+    (click)="deleteK8s()" placement="top" container="body" ngbTooltip="{{'DELETE' | translate}}">
+    <i class="far fa-trash-alt icons" title="delete"></i>
+  </button>
+  <button *ngIf="checkRegister && !isCluster && !isProfile && !isKSU && getK8sType !== 'repo'"
+    [disabled]="state != 'CREATED'" type="button" class="btn btn-primary" (click)="deleteK8s()" placement="top"
+    container="body" ngbTooltip="{{'DEREGISTER' | translate}}">
+    <i class="fas fa-window-close icons" title="deregister"></i>
+  </button>
+  <div *ngIf="isCluster && !isProfile && !isKSU  && getK8sType !== 'repo'" class="btn-group" placement="bottom-right" ngbDropdown
+    display="dynamic" container="body">
+    <button type="button" class="btn btn-primary" [disabled]="state != 'CREATED'" ngbDropdownToggle placement="top" container="body"
+      ngbTooltip="{{'Attach Profile' | translate}}">
+      <i class="fas fa-link"></i>
+    </button>
+    <div class="dropdown-menu list-action-dropdown" ngbDropdownMenu>
+      <button type="button" class="btn btn-primary dropdown-item" placement="left" container="body"
+        (click)="editClusterProfile('infra-config')" ngbTooltip="{{'PAGE.K8S.ATTACHINFRACONFIG' | translate}}">
+        <i class="fa fa-link"></i> {{'PAGE.K8S.ATTACHINFRACONFIG' | translate}}
+      </button>
+      <button type="button" class="btn btn-primary dropdown-item" (click)="editClusterProfile('infra-controller')"
+        placement="left" container="body" ngbTooltip="{{'PAGE.K8S.ATTACHINFRACONTROLLER' | translate}}">
+        <i class="fas fa-link"></i> {{'PAGE.K8S.ATTACHINFRACONTROLLER' | translate}}
+      </button>
+      <button type="button" class="btn btn-primary dropdown-item" placement="left"
+        (click)="editClusterProfile('app-profile')" container="body" ngbTooltip="{{'PAGE.K8S.ATTACHAPP' | translate}}">
+        <i class="fas fa-link"></i> {{'PAGE.K8S.ATTACHAPP' | translate}}
+      </button>
+      <button type="button" class="btn btn-primary dropdown-item" placement="left"
+        (click)="editClusterProfile('resource-profile')" container="body"
+        ngbTooltip="{{'PAGE.K8S.ATTACHRESOURCE' | translate}}">
+        <i class="fas fa-link"></i> {{'PAGE.K8S.ATTACHRESOURCE' | translate}}
+      </button>
+    </div>
+  </div>
+  <div *ngIf="(isProfile || isKSU || isCluster  && getK8sType !== 'repo')" class="btn-group" ngbDropdown display="dynamic" container="body">
+    <button type="button" [disabled]="state != 'CREATED'" class="btn btn-primary dropdown-toggle action-button" ngbDropdownToggle>
+      {{'ACTION' | translate}}
+    </button>
+    <div class="dropdown-menu list-action-dropdown" ngbDropdownMenu>
+      <button *ngIf="isProfile && !KSU && !isCluster" type="button" class="btn btn-primary dropdown-item"
+        placement="left" container="body" (click)="editProfile(getK8sType)" ngbTooltip="{{'PAGE.K8S.EDITPROFILE' | translate}}">
+        <i class="fa fa-edit icons"></i> {{'PAGE.K8S.EDITPROFILE' | translate}}
+      </button>
+      <button *ngIf="isKSU && !isProfile && !isCluster" type="button" class="btn btn-primary dropdown-item"
+        placement="left" (click)="moveKsu()" container="body" ngbTooltip="{{'PAGE.K8S.MOVE' | translate}}">
+        <i class="fas fa-truck-moving"></i> {{'PAGE.K8S.MOVE' | translate}}
+      </button>
+      <button *ngIf="isKSU && !isProfile && !isCluster" type="button" class="btn btn-primary dropdown-item"
+        placement="left" (click)="cloneKsu()" container="body" ngbTooltip="{{'PAGE.K8S.CLONE' | translate}}">
+        <i class="fa fa-clone icons"></i> {{'PAGE.K8S.CLONE' | translate}}
+      </button>
+      <button *ngIf="isKSU && !isProfile && !isCluster" type="button" class="btn btn-primary dropdown-item"
+        placement="left" (click)="editKsu()" container="body" ngbTooltip="{{'EDIT' | translate}}">
+        <i class="fa fa-edit icons"></i> {{'EDIT' | translate}}
+      </button>
+      <button *ngIf="!isKSU && !isProfile && isCluster" type="button" class="btn btn-primary dropdown-item"
+        placement="left" (click)="editCluster('upgrade')" container="body" ngbTooltip="{{'PAGE.K8S.UPGRADE' | translate}}">
+        <i class="fa fa-arrow-up"></i> {{'PAGE.K8S.UPGRADE' | translate}}
+      </button>
+      <button *ngIf="!isKSU && !isProfile && isCluster" type="button" class="btn btn-primary dropdown-item"
+        placement="left" (click)="editCluster('scale')" container="body" ngbTooltip="{{'PAGE.K8S.SCALE' | translate}}">
+        <i class="fas fa-compress-alt"></i> {{'PAGE.K8S.SCALE' | translate}}
+      </button>
+    </div>
+  </div>
\ No newline at end of file
diff --git a/src/app/k8s/k8s-action/K8sActionComponent.ts b/src/app/k8s/k8s-action/K8sActionComponent.ts
index f68eff6..eef33ca 100644
--- a/src/app/k8s/k8s-action/K8sActionComponent.ts
+++ b/src/app/k8s/k8s-action/K8sActionComponent.ts
@@ -7,7 +7,7 @@
 
   http://www.apache.org/licenses/LICENSE-2.0
 
- Unless required by applicable law or agreed to in writing, software
+ Unless required by applicable law or agreed to in  writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
@@ -23,7 +23,11 @@
 import { TranslateService } from '@ngx-translate/core';
 import { MODALCLOSERESPONSEDATA } from 'CommonModel';
 import { DeleteComponent } from 'DeleteComponent';
-import { K8SCLUSTERDATADISPLAY, K8SREPODATADISPLAY } from 'K8sModel';
+import { K8sAddClusterComponent } from 'K8sAddClusterComponent';
+import { K8sAttachProfileComponent } from 'K8sAttachProfileComponent';
+import { K8sInfraConfigAddComponent } from 'K8sInfraConfigAddComponent';
+import { INFRACONFIGPAYLOAD, K8SCLUSTERDATADISPLAY, K8SPayload, K8SREPODATADISPLAY } from 'K8sModel';
+import { KSUAddComponent } from 'KSUAddComponent';
 import { SharedService } from 'SharedService';
 import { ShowInfoComponent } from 'ShowInfoComponent';
 /**
@@ -36,19 +40,34 @@
   styleUrls: ['./K8sActionComponent.scss']
 })
 /** Exporting a class @exports K8sActionComponent */
-export class K8sActionComponent{
+export class K8sActionComponent {
   /** To inject services @public */
   public injector: Injector;
 
   /** To get the value from the Users action via valuePrepareFunction default Property of ng-smarttable @public */
-  public value: K8SCLUSTERDATADISPLAY | K8SREPODATADISPLAY;
+  public value: K8SCLUSTERDATADISPLAY | K8SREPODATADISPLAY | INFRACONFIGPAYLOAD;
 
   /** handle translate @public */
   public translateService: TranslateService;
 
-  /** Contains K8s Type @private */
+  /** Contains K8s Type @public */
   public getK8sType: string;
 
+  /** Check register page @public */
+  public checkRegister = false;
+
+  /** Contains state @public */
+  public state: string;
+
+  /** Check profile or not @public */
+  public isProfile = false;
+
+  /** Check ksu or not @public */
+  public isKSU = false;
+
+  /** Check cluster or not @public */
+  public isCluster = false;
+
   /** Instance of the modal service @private */
   private modalService: NgbModal;
 
@@ -71,10 +90,28 @@
   public ngOnInit(): void {
     this.instanceID = this.value.identifier;
     this.getK8sType = this.value.pageType;
+    this.state = this.value.state;
+    if (sessionStorage.getItem('clusterType') === 'Registered') {
+      this.checkRegister = true;
+    }
+    if (this.getK8sType === 'infra-config' || this.getK8sType === 'infra-controller' || this.getK8sType === 'app-profile' || this.getK8sType === 'resource-profile') {
+      this.isCluster = false;
+      this.isProfile = true;
+      this.isKSU = false;
+    } else if (sessionStorage.getItem('clusterType') === 'Managed') {
+      this.isCluster = true;
+      this.isProfile = false;
+      this.isKSU = false;
+    }
+    if (this.getK8sType === 'k8-ksu') {
+      this.isKSU = true;
+      this.isCluster = false;
+      this.isProfile = false;
+    }
   }
 
   /** Delete User Account @public */
-  public deleteK8s(pageType: string): void {
+  public deleteK8s(): void {
     // eslint-disable-next-line security/detect-non-literal-fs-filename
     const modalRef: NgbModalRef = this.modalService.open(DeleteComponent, { backdrop: 'static' });
     modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
@@ -83,7 +120,7 @@
       }
     }).catch((): void => {
       // Catch Navigation Error
-  });
+    });
   }
 
   /** Shows information using modalservice @public */
@@ -104,4 +141,96 @@
       titleName: title
     };
   }
+  /** Edit profile @public */
+  public editProfile(editType: string): void {
+    // eslint-disable-next-line security/detect-non-literal-fs-filename
+    const modalRef: NgbModalRef = this.modalService.open(K8sInfraConfigAddComponent, { backdrop: 'static' });
+    modalRef.componentInstance.profileID = this.value.identifier;
+    modalRef.componentInstance.profileType = editType;
+    modalRef.componentInstance.profileName = this.value.name;
+    modalRef.componentInstance.profileDescription = this.value.description;
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch((): void => {
+      // Catch Navigation Error
+    });
+  }
+
+  /** Edit cluster @public */
+  public editCluster(editType: string): void {
+    // eslint-disable-next-line security/detect-non-literal-fs-filename
+    const modalRef: NgbModalRef = this.modalService.open(K8sAddClusterComponent, { backdrop: 'static' });
+    modalRef.componentInstance.profileID = this.value.identifier;
+    modalRef.componentInstance.profileType = editType;
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch((): void => {
+      // Catch Navigation Error
+    });
+  }
+
+
+  /** Edit profile under cluster @public */
+  public editClusterProfile(editType: string): void {
+    // eslint-disable-next-line security/detect-non-literal-fs-filename
+    const modalRef: NgbModalRef = this.modalService.open(K8sAttachProfileComponent, { backdrop: 'static' });
+    modalRef.componentInstance.profileID = this.value.identifier;
+    modalRef.componentInstance.profileType = editType;
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch((): void => {
+      // Catch Navigation Error
+    });
+  }
+
+  /** Move KSU @public */
+  public moveKsu(): void {
+    // eslint-disable-next-line security/detect-non-literal-fs-filename
+    const modalRef: NgbModalRef = this.modalService.open(KSUAddComponent, { backdrop: 'static' });
+    modalRef.componentInstance.profileID = this.value.identifier;
+    modalRef.componentInstance.profileType = 'move';
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch((): void => {
+      // Catch Navigation Error
+    });
+  }
+
+  /** Edit KSU @public */
+  public editKsu(): void {
+    // eslint-disable-next-line security/detect-non-literal-fs-filename
+    const modalRef: NgbModalRef = this.modalService.open(KSUAddComponent, { backdrop: 'static' });
+    modalRef.componentInstance.profileID = this.value.identifier;
+    modalRef.componentInstance.profileType = 'edit';
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch((): void => {
+      // Catch Navigation Error
+    });
+  }
+
+  /** Clone KSU @public */
+  public cloneKsu(): void {
+    // eslint-disable-next-line security/detect-non-literal-fs-filename
+    const modalRef: NgbModalRef = this.modalService.open(KSUAddComponent, { backdrop: 'static' });
+    modalRef.componentInstance.profileID = this.value.identifier;
+    modalRef.componentInstance.profileType = 'clone';
+    modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+      if (result) {
+        this.sharedService.callData();
+      }
+    }).catch((): void => {
+      // Catch Navigation Error
+    });
+  }
 }