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-profile/k8s-app-profile-details/K8sAppProfileComponent.html b/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.html
new file mode 100644
index 0000000..34fb3fc
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.html
@@ -0,0 +1,45 @@
+<!--
+Copyright 2020 TATA ELXSI
+
+Licensed under the Apache License, Version 2.0 (the 'License');
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+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
+limitations under the License.
+
+Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+-->
+<div class="d-flex flex-row justify-content-between">
+ <div class="d-flex align-items-center header-style">{{'PAGE.K8S.APP' | translate}}</div>
+ <span class="button">
+ <button class="btn btn-primary me-2" type="button" placement="top" container="body"
+ ngbTooltip="{{'Create Profile' | translate}}" (click)="addProfile()">
+ <i class="fas fa-plus-circle" aria-hidden="true"></i> {{'PAGE.K8S.CREATEPROFILE' | translate}}
+ </button>
+ </span>
+</div>
+<div class="mt-2 mb-2 list-utilites-actions">
+ <div class="col-auto me-auto">
+ <nav class="custom-items-config">
+ <span><i class="fas fa-clock text-success"></i>{{operationalStateFirstStep}}</span>
+ <span><i class="fas fa-spinner text-warning"></i>{{operationalStateSecondStep}}</span>
+ <span><i class="fas fa-spinner text-danger"></i>{{operationalStateThirdStep}}</span>
+ <span><i class="fas fa-times-circle text-danger"></i>{{operationalStateFourthStep}}</span>
+ <span><i class="fas fa-times-circle text-warning"></i>{{operationalStateFifthStep}}</span>
+ </nav>
+ </div>
+ <page-per-row class="me-2" (pagePerRow)="onChange($event)"></page-per-row>
+ <page-reload></page-reload>
+</div>
+<div class="smarttable-style bg-white mt-1">
+ <ng2-smart-table [ngClass]="checkDataClass" [settings]="settings" [source]="dataSource"
+ (userRowSelect)="onUserRowSelect($event)">
+ </ng2-smart-table>
+</div>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.scss b/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.scss
new file mode 100644
index 0000000..c55461a
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.scss
@@ -0,0 +1,17 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.ts b/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.ts
new file mode 100644
index 0000000..4772c4c
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-app-profile-details/K8sAppProfileComponent.ts
@@ -0,0 +1,254 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
+/**
+ * @file K8sAppProfileComponent.ts.
+ */
+import { Component, Injector, OnDestroy, OnInit } from '@angular/core';
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { CONFIGCONSTANT, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { DataService } from 'DataService';
+import { environment } from 'environment';
+import { K8sActionComponent } from 'K8sActionComponent';
+import { INFRACONFIGPAYLOAD, K8SCreateCLUSTERDATA } from 'K8sModel';
+import { LocalDataSource } from 'ng2-smart-table';
+import { RestService } from 'RestService';
+import { Subscription } from 'rxjs';
+import { SharedService } from 'SharedService';
+import { K8sInfraConfigAddComponent } from '../k8s-infra-config-add/K8sInfraConfigAddComponent';
+/**
+ * Creating Component
+ * @Component takes K8sAppProfileComponent.html as template url
+ */
+@Component({
+ selector: 'app-app-profile',
+ templateUrl: './K8sAppProfileComponent.html',
+ styleUrls: ['./K8sAppProfileComponent.scss']
+})
+/** Exporting a class @exports K8sAppProfileComponent */
+export class K8sAppProfileComponent implements OnInit, OnDestroy {
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** handle translate @public */
+ public translateService: TranslateService;
+
+ /** Data of smarttable populate through LocalDataSource @public */
+ public dataSource: LocalDataSource = new LocalDataSource();
+
+ /** Columns list of the smart table @public */
+ public columnList: object = {};
+
+ /** Settings for smarttable to populate the table with columns @public */
+ public settings: object = {};
+
+ /** operational State created data @public */
+ public operationalStateFirstStep: string = CONFIGCONSTANT.k8OperationalStateFirstStep;
+
+ /** operational State in creation data @public */
+ public operationalStateSecondStep: string = CONFIGCONSTANT.k8OperationalStateStateSecondStep;
+
+ /** operational State in deletion data @public */
+ public operationalStateThirdStep: string = CONFIGCONSTANT.k8OperationalStateThirdStep;
+
+ /** operational State failed deletion data @public */
+ public operationalStateFourthStep: string = CONFIGCONSTANT.k8OperationalStateFourthStep;
+
+ /** operational State failed creation data @public */
+ public operationalStateFifthStep: string = CONFIGCONSTANT.k8OperationalStateFifthStep;
+
+ /** Check the loading results @public */
+ public isLoadingResults: boolean = true;
+
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
+
+ /** Class for empty and present data @public */
+ public checkDataClass: string;
+
+ /** Instance of the rest service @private */
+ private restService: RestService;
+
+ /** dataService to pass the data from one component to another @private */
+ private dataService: DataService;
+
+ /** Formation of appropriate Data for LocalDatasource @private */
+ private profileData: {}[] = [];
+
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+
+ /** Instance of the modal service @private */
+ private modalService: NgbModal;
+
+ /** Instance of subscriptions @private */
+ private generateDataSub: Subscription;
+
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.restService = this.injector.get(RestService);
+ this.dataService = this.injector.get(DataService);
+ this.sharedService = this.injector.get(SharedService);
+ this.translateService = this.injector.get(TranslateService);
+ this.modalService = this.injector.get(NgbModal);
+ }
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.generateColumns();
+ this.generateSettings();
+ this.generateData();
+ this.generateDataSub = this.sharedService.dataEvent.subscribe(() => { this.generateData(); });
+ }
+
+ /** smart table Header Colums @public */
+ public generateColumns(): void {
+ this.columnList = {
+ name: { title: this.translateService.instant('NAME'), width: '20%', sortDirection: 'asc' },
+ identifier: { title: this.translateService.instant('IDENTIFIER'), width: '15%' },
+ state: {
+ title: this.translateService.instant('STATE'), width: '15%', type: 'html',
+ filter: {
+ type: 'list',
+ config: {
+ selectText: 'Select',
+ list: [
+ { value: this.operationalStateFirstStep, title: this.operationalStateFirstStep },
+ { value: this.operationalStateSecondStep, title: this.operationalStateSecondStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateThirdStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFourthStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFifthStep }
+ ]
+ }
+ },
+ valuePrepareFunction: (cell: INFRACONFIGPAYLOAD, row: INFRACONFIGPAYLOAD): string => {
+ if (row.state === this.operationalStateFirstStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-clock text-success"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateSecondStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-warning"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateThirdStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFourthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFifthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-warning"></i>
+ </span>`;
+ } else {
+ return `<span>${row.state}</span>`;
+ }
+ }
+ },
+ created: { title: this.translateService.instant('CREATED'), width: '10%' },
+ modified: { title: this.translateService.instant('MODIFIED'), width: '10%' },
+ Actions: {
+ name: 'Action', width: '5%', filter: false, sort: false, title: this.translateService.instant('ACTIONS'), type: 'custom',
+ valuePrepareFunction: (cell: INFRACONFIGPAYLOAD, row: INFRACONFIGPAYLOAD): INFRACONFIGPAYLOAD => row,
+ renderComponent: K8sActionComponent
+ }
+ };
+ }
+
+ /** smart table Data Settings @public */
+ public generateSettings(): void {
+ this.settings = {
+ columns: this.columnList,
+ actions: { add: false, edit: false, delete: false, position: 'right' },
+ attr: this.sharedService.tableClassConfig(),
+ pager: this.sharedService.paginationPagerConfig(),
+ noDataMessage: this.translateService.instant('NODATAMSG')
+ };
+ }
+
+ /** smart table listing manipulation @public */
+ public onChange(perPageValue: number): void {
+ this.dataSource.setPaging(1, perPageValue, true);
+ }
+
+ /** smart table listing manipulation @public */
+ public onUserRowSelect(event: MessageEvent): void {
+ Object.assign(event.data, { page: 'k8-app-profile' });
+ this.dataService.changeMessage(event.data);
+ }
+
+ /** Compose new profile @public */
+ public addProfile(): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
+ const modalRef: NgbModalRef = this.modalService.open(K8sInfraConfigAddComponent, { backdrop: 'static' });
+ modalRef.componentInstance.profileType = 'app-profile';
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ }
+
+ /**
+ * Lifecyle hook which get trigger on component destruction
+ */
+ public ngOnDestroy(): void {
+ this.generateDataSub.unsubscribe();
+ }
+
+ /** Generate profile object from loop and return for the datasource @public */
+ public generateprofileData(profileData: INFRACONFIGPAYLOAD): INFRACONFIGPAYLOAD {
+ return {
+ name: profileData.name,
+ identifier: profileData._id,
+ created: this.sharedService.convertEpochTime(Number(profileData._admin.created)),
+ modified: this.sharedService.convertEpochTime(Number(profileData._admin.modified)),
+ description: profileData.description,
+ pageType: 'app-profile',
+ state: profileData.state
+ };
+ }
+
+ /** Fetching the data from server to Load in the smarttable @protected */
+ protected generateData(): void {
+ this.isLoadingResults = true;
+ this.restService.getResource(environment.K8SAPPPROFILE_URL).subscribe((profileDatas: K8SCreateCLUSTERDATA[]) => {
+ this.profileData = [];
+ profileDatas.forEach((profileData: INFRACONFIGPAYLOAD) => {
+ const profileDataObj: INFRACONFIGPAYLOAD = this.generateprofileData(profileData);
+ this.profileData.push(profileDataObj);
+ });
+ if (this.profileData.length > 0) {
+ this.checkDataClass = 'dataTables_present';
+ } else {
+ this.checkDataClass = 'dataTables_empty';
+ }
+ this.dataSource.load(this.profileData).then((data: boolean) => {
+ this.isLoadingResults = false;
+ }).catch(() => {
+ this.isLoadingResults = false;
+ });
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+}
diff --git a/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.html b/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.html
new file mode 100644
index 0000000..493cb5b
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.html
@@ -0,0 +1,52 @@
+<!--
+Copyright 2020 TATA ELXSI
+
+Licensed under the Apache License, Version 2.0 (the 'License');
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+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
+limitations under the License.
+
+Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+-->
+<form [formGroup]="profileForm" (ngSubmit)="profileSubmit();">
+ <div class="modal-header">
+ <h4 *ngIf="isAdd" class="modal-title" id="modal-basic-title">{{'PAGE.K8S.CREATEPROFILE' | translate}}</h4>
+ <h4 *ngIf="isEdit" class="modal-title" id="modal-basic-title">{{'PAGE.K8S.EDITPROFILE' | translate}}</h4>
+ <button class="button-xs" type="button" class="close" aria-label="Close" (click)="activeModal.close()">
+ <i class="fas fa-times-circle text-danger"></i>
+ </button>
+ </div>
+ <div class="modal-body modal-body-custom-height">
+ <div class="form-group row mb-3">
+ <label class="col-sm-12 col-form-label mandatory-label"
+ [ngClass]="{'text-danger': profileForm.invalid === true && submitted === true}">{{'MANDATORYCHECK' |
+ translate}}</label>
+ <label class="col-sm-4 col-form-label" for="name">{{'PAGE.K8S.NAME' | translate}}*</label>
+ <div class="col-sm-8">
+ <input autocomplete="off" class="form-control" placeholder="{{'PAGE.K8S.NAME' | translate}}" type="text"
+ formControlName="name" id="name" [ngClass]="{ 'is-invalid': submitted && f.name.errors }" required>
+ </div>
+ </div>
+ <div class="form-group row mb-3">
+ <label class="col-sm-4 col-form-label" for="description">{{'PAGE.K8S.DESCRIPTION' | translate}}*</label>
+ <div class="col-sm-8">
+ <textarea class="form-control" placeholder="{{'PAGE.K8S.DESCRIPTION' | translate}}" type="text"
+ formControlName="description" id="description"
+ [ngClass]="{ 'is-invalid': submitted && f.description.errors }" required></textarea>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-danger" (click)="activeModal.close()">{{'CANCEL' | translate}}</button>
+ <button *ngIf="isAdd" type="submit" class="btn btn-primary">{{'CREATE' | translate}}</button>
+ <button *ngIf="isEdit" type="submit" class="btn btn-primary">{{'EDIT' | translate}}</button>
+ </div>
+</form>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.scss b/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.scss
new file mode 100644
index 0000000..c55461a
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.scss
@@ -0,0 +1,17 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.ts b/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.ts
new file mode 100644
index 0000000..5299323
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-config-add/K8sInfraConfigAddComponent.ts
@@ -0,0 +1,220 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
+/**
+ * @file K8sInfraConfigAddComponent.ts.
+ */
+import { HttpHeaders } from '@angular/common/http';
+import { Component,Injector, Input, OnInit} from '@angular/core';
+import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { NotifierService } from 'angular-notifier';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, TYPESECTION, URLPARAMS } from 'CommonModel';
+import { environment } from 'environment';
+import { INFRACONFIGPAYLOAD} from 'K8sModel';
+import { RestService } from 'RestService';
+import { SharedService, isNullOrUndefined } from 'SharedService';
+/**
+ * Creating Component
+ * @Component takes K8sInfraConfigAddComponent.html as template url
+ */
+@Component({
+ selector: 'app-infra-config',
+ templateUrl: './K8sInfraConfigAddComponent.html',
+ styleUrls: ['./K8sInfraConfigAddComponent.scss']
+})
+/** Exporting a class @exports K8sInfraConfigAddComponent */
+export class K8sInfraConfigAddComponent implements OnInit {
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** FormGroup instance added to the form @ html @public */
+ public profileForm: FormGroup;
+
+ /** Instance for active modal service @public */
+ public activeModal: NgbActiveModal;
+
+ /** Form submission Add */
+ public submitted: boolean = false;
+
+ /** Check the loading results @public */
+ public isLoadingResults: boolean = false;
+
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
+
+ /** profile url @public */
+ public profileUrl: string;
+
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public profileType: string;
+
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public profileID: string;
+
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public profileName: string;
+
+ /** Input contains Modal dialog component Instance @public */
+ @Input() public profileDescription: string;
+
+ /** check Add @public */
+ public isAdd = false;
+
+ /** check Edit @public */
+ public isEdit = false;
+
+ /** FormBuilder instance added to the formBuilder @private */
+ private formBuilder: FormBuilder;
+
+ /** Utilizes rest service for any CRUD operations @private */
+ private restService: RestService;
+
+ /** Notifier service to popup notification @private */
+ private notifierService: NotifierService;
+
+ /** Contains tranlsate instance @private */
+ private translateService: TranslateService;
+
+ /** Controls the header form @private */
+ private headers: HttpHeaders;
+
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.restService = this.injector.get(RestService);
+ this.activeModal = this.injector.get(NgbActiveModal);
+ this.formBuilder = this.injector.get(FormBuilder);
+ this.notifierService = this.injector.get(NotifierService);
+ this.translateService = this.injector.get(TranslateService);
+ this.sharedService = this.injector.get(SharedService);
+ }
+
+ public ngOnInit(): void {
+ /** On Initializing call the methods */
+ this.profileFormAction();
+ this.headers = new HttpHeaders({
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
+ });
+ if (!isNullOrUndefined(this.profileID)) {
+ this.isEdit = true;
+ this.profileForm.patchValue({ name: this.profileName, description: this.profileDescription });
+ } else {
+ this.isAdd = true;
+ }
+ }
+
+ /** On modal initializing forms @public */
+ public profileFormAction(): void {
+ this.profileForm = this.formBuilder.group({
+ name: ['', [Validators.required]],
+ default: [null],
+ description: ['', [Validators.required]]
+ });
+ }
+
+ /** convenience getter for easy access to form fields */
+ get f(): FormGroup['controls'] { return this.profileForm.controls; }
+
+ /** On modal submit profileSubmit will called @public */
+ public profileSubmit(): void {
+ this.submitted = true;
+ this.sharedService.cleanForm(this.profileForm);
+ if (this.profileForm.invalid) {
+ return;
+ }
+ if (!isNullOrUndefined(this.profileID)) {
+ this.editProfile(this.profileType);
+ } else {
+ this.addProfile();
+ }
+ }
+ /** Add profile @public */
+ public addProfile(): void {
+ const modalData: MODALCLOSERESPONSEDATA = {
+ message: 'Done'
+ };
+ if (this.profileType === 'infra-config') {
+ this.profileUrl = environment.K8SINFRACONFIGPROFILE_URL;
+ } else if (this.profileType === 'infra-controller') {
+ this.profileUrl = environment.K8SINFRACONTROLLERPROFILE_URL;
+ } else if (this.profileType === 'app-profile') {
+ this.profileUrl = environment.K8SAPPPROFILE_URL;
+ } else if (this.profileType === 'resource-profile') {
+ this.profileUrl = environment.K8SRESOURCEPROFILE_URL;
+ }
+ const apiURLHeader: APIURLHEADER = {
+ url: this.profileUrl,
+ httpOptions: { headers: this.headers }
+ };
+
+ this.isLoadingResults = true;
+ const payload: INFRACONFIGPAYLOAD = {
+ name: this.profileForm.value.name,
+ description: this.profileForm.value.description
+ };
+ this.restService.postResource(apiURLHeader, payload).subscribe((result: {}) => {
+ this.activeModal.close(modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success',
+ this.translateService.instant('PAGE.K8S.PROFILECREATEDSUCCESSFULLY'));
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
+ }
+
+ /** Edit profile @public */
+ public editProfile(profileType: string): void {
+ const modalData: MODALCLOSERESPONSEDATA = {
+ message: 'Done'
+ };
+ this.isLoadingResults = true;
+ if (profileType === 'infra-config') {
+ this.profileUrl = environment.K8SINFRACONFIGPROFILE_URL + '/' + this.profileID;
+ } else if (profileType === 'infra-controller') {
+ this.profileUrl = environment.K8SINFRACONTROLLERPROFILE_URL + '/' + this.profileID;
+ } else if (this.profileType === 'app-profile') {
+ this.profileUrl = environment.K8SAPPPROFILE_URL + '/' + this.profileID;
+ } else if (this.profileType === 'resource-profile') {
+ this.profileUrl = environment.K8SRESOURCEPROFILE_URL + '/' + this.profileID;
+ }
+ const apiURLHeader: APIURLHEADER = {
+ url: this.profileUrl,
+ httpOptions: { headers: this.headers }
+ };
+ const payload: INFRACONFIGPAYLOAD = {
+ name: this.profileForm.value.name,
+ description: this.profileForm.value.description
+ };
+
+ this.restService.patchResource(apiURLHeader, payload).subscribe((result: {}) => {
+ this.activeModal.close(modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success',
+ this.translateService.instant('PAGE.K8S.PROFILEEDITEDSUCCESSFULLY'));
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
+ }
+}
diff --git a/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.html b/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.html
new file mode 100644
index 0000000..81761d5
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.html
@@ -0,0 +1,45 @@
+<!--
+Copyright 2020 TATA ELXSI
+
+Licensed under the Apache License, Version 2.0 (the 'License');
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+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
+limitations under the License.
+
+Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+-->
+<div class="d-flex flex-row justify-content-between">
+ <div class="d-flex align-items-center header-style">{{'PAGE.K8S.INFRACONFIG' | translate}}</div>
+ <span class="button">
+ <button class="btn btn-primary me-2" type="button" placement="top" container="body"
+ ngbTooltip="{{'Create Profile' | translate}}" (click)="addProfile()">
+ <i class="fas fa-plus-circle" aria-hidden="true"></i> {{'PAGE.K8S.CREATEPROFILE' | translate}}
+ </button>
+ </span>
+</div>
+<div class="mt-2 mb-2 list-utilites-actions">
+ <div class="col-auto me-auto">
+ <nav class="custom-items-config">
+ <span><i class="fas fa-clock text-success"></i>{{operationalStateFirstStep}}</span>
+ <span><i class="fas fa-spinner text-warning"></i>{{operationalStateSecondStep}}</span>
+ <span><i class="fas fa-spinner text-danger"></i>{{operationalStateThirdStep}}</span>
+ <span><i class="fas fa-times-circle text-danger"></i>{{operationalStateFourthStep}}</span>
+ <span><i class="fas fa-times-circle text-warning"></i>{{operationalStateFifthStep}}</span>
+ </nav>
+ </div>
+ <page-per-row class="me-2" (pagePerRow)="onChange($event)"></page-per-row>
+ <page-reload></page-reload>
+</div>
+<div class="smarttable-style bg-white mt-1">
+ <ng2-smart-table [ngClass]="checkDataClass" [settings]="settings" [source]="dataSource"
+ (userRowSelect)="onUserRowSelect($event)">
+ </ng2-smart-table>
+</div>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.scss b/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.scss
new file mode 100644
index 0000000..c55461a
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.scss
@@ -0,0 +1,17 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.ts b/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.ts
new file mode 100644
index 0000000..760124b
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-config-details/K8sInfraConfigProfileComponent.ts
@@ -0,0 +1,254 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
+/**
+ * @file K8sInfraConfigProfileComponent.ts.
+ */
+import { Component, Injector, OnDestroy, OnInit } from '@angular/core';
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { CONFIGCONSTANT, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { DataService } from 'DataService';
+import { environment } from 'environment';
+import { K8sActionComponent } from 'K8sActionComponent';
+import { INFRACONFIGPAYLOAD, K8SCreateCLUSTERDATA, K8SCREATEDATADISPLAY } from 'K8sModel';
+import { LocalDataSource } from 'ng2-smart-table';
+import { RestService } from 'RestService';
+import { Subscription } from 'rxjs';
+import { SharedService } from 'SharedService';
+import { K8sInfraConfigAddComponent } from '../k8s-infra-config-add/K8sInfraConfigAddComponent';
+/**
+ * Creating Component
+ * @Component takes K8sInfraConfigProfileComponent.html as template url
+ */
+@Component({
+ selector: 'app-infra-config-profile',
+ templateUrl: './K8sInfraConfigProfileComponent.html',
+ styleUrls: ['./K8sInfraConfigProfileComponent.scss']
+})
+/** Exporting a class @exports K8sInfraConfigProfileComponent */
+export class K8sInfraConfigProfileComponent implements OnInit, OnDestroy {
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** handle translate @public */
+ public translateService: TranslateService;
+
+ /** Data of smarttable populate through LocalDataSource @public */
+ public dataSource: LocalDataSource = new LocalDataSource();
+
+ /** Columns list of the smart table @public */
+ public columnList: object = {};
+
+ /** Settings for smarttable to populate the table with columns @public */
+ public settings: object = {};
+
+ /** operational State created data @public */
+ public operationalStateFirstStep: string = CONFIGCONSTANT.k8OperationalStateFirstStep;
+
+ /** operational State in creation data @public */
+ public operationalStateSecondStep: string = CONFIGCONSTANT.k8OperationalStateStateSecondStep;
+
+ /** operational State in deletion data @public */
+ public operationalStateThirdStep: string = CONFIGCONSTANT.k8OperationalStateThirdStep;
+
+ /** operational State failed deletion data @public */
+ public operationalStateFourthStep: string = CONFIGCONSTANT.k8OperationalStateFourthStep;
+
+ /** operational State failed creation data @public */
+ public operationalStateFifthStep: string = CONFIGCONSTANT.k8OperationalStateFifthStep;
+
+ /** Check the loading results @public */
+ public isLoadingResults: boolean = true;
+
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
+
+ /** Class for empty and present data @public */
+ public checkDataClass: string;
+
+ /** Instance of the rest service @private */
+ private restService: RestService;
+
+ /** dataService to pass the data from one component to another @private */
+ private dataService: DataService;
+
+ /** Formation of appropriate Data for LocalDatasource @private */
+ private profileData: {}[] = [];
+
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+
+ /** Instance of the modal service @private */
+ private modalService: NgbModal;
+
+ /** Instance of subscriptions @private */
+ private generateDataSub: Subscription;
+
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.restService = this.injector.get(RestService);
+ this.dataService = this.injector.get(DataService);
+ this.sharedService = this.injector.get(SharedService);
+ this.translateService = this.injector.get(TranslateService);
+ this.modalService = this.injector.get(NgbModal);
+ }
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.generateColumns();
+ this.generateSettings();
+ this.generateData();
+ this.generateDataSub = this.sharedService.dataEvent.subscribe(() => { this.generateData(); });
+ }
+
+ /** smart table Header Colums @public */
+ public generateColumns(): void {
+ this.columnList = {
+ name: { title: this.translateService.instant('NAME'), width: '20%', sortDirection: 'asc' },
+ identifier: { title: this.translateService.instant('IDENTIFIER'), width: '15%' },
+ state: {
+ title: this.translateService.instant('STATE'), width: '15%', type: 'html',
+ filter: {
+ type: 'list',
+ config: {
+ selectText: 'Select',
+ list: [
+ { value: this.operationalStateFirstStep, title: this.operationalStateFirstStep },
+ { value: this.operationalStateSecondStep, title: this.operationalStateSecondStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateThirdStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFourthStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFifthStep }
+ ]
+ }
+ },
+ valuePrepareFunction: (cell: INFRACONFIGPAYLOAD, row: INFRACONFIGPAYLOAD): string => {
+ if (row.state === this.operationalStateFirstStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-clock text-success"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateSecondStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-warning"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateThirdStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFourthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFifthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-warning"></i>
+ </span>`;
+ } else {
+ return `<span>${row.state}</span>`;
+ }
+ }
+ },
+ created: { title: this.translateService.instant('CREATED'), width: '10%' },
+ modified: { title: this.translateService.instant('MODIFIED'), width: '10%' },
+ Actions: {
+ name: 'Action', width: '5%', filter: false, sort: false, title: this.translateService.instant('ACTIONS'), type: 'custom',
+ valuePrepareFunction: (cell: INFRACONFIGPAYLOAD, row: INFRACONFIGPAYLOAD): INFRACONFIGPAYLOAD => row,
+ renderComponent: K8sActionComponent
+ }
+ };
+ }
+
+ /** smart table Data Settings @public */
+ public generateSettings(): void {
+ this.settings = {
+ columns: this.columnList,
+ actions: { add: false, edit: false, delete: false, position: 'right' },
+ attr: this.sharedService.tableClassConfig(),
+ pager: this.sharedService.paginationPagerConfig(),
+ noDataMessage: this.translateService.instant('NODATAMSG')
+ };
+ }
+
+ /** smart table listing manipulation @public */
+ public onChange(perPageValue: number): void {
+ this.dataSource.setPaging(1, perPageValue, true);
+ }
+
+ /** smart table listing manipulation @public */
+ public onUserRowSelect(event: MessageEvent): void {
+ Object.assign(event.data, { page: 'k8-infra-profile' });
+ this.dataService.changeMessage(event.data);
+ }
+
+ /** Compose new profile @public */
+ public addProfile(): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
+ const modalRef: NgbModalRef = this.modalService.open(K8sInfraConfigAddComponent, { backdrop: 'static' });
+ modalRef.componentInstance.profileType = 'infra-config';
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ }
+
+ /**
+ * Lifecyle hook which get trigger on component destruction
+ */
+ public ngOnDestroy(): void {
+ this.generateDataSub.unsubscribe();
+ }
+
+ /** Generate profile object from loop and return for the datasource @public */
+ public generateprofileData(profileData: INFRACONFIGPAYLOAD): INFRACONFIGPAYLOAD {
+ return {
+ name: profileData.name,
+ identifier: profileData._id,
+ created: this.sharedService.convertEpochTime(Number(profileData._admin.created)),
+ modified: this.sharedService.convertEpochTime(Number(profileData._admin.modified)),
+ description: profileData.description,
+ pageType: 'infra-config',
+ state: profileData.state
+ };
+ }
+
+ /** Fetching the data from server to Load in the smarttable @protected */
+ protected generateData(): void {
+ this.isLoadingResults = true;
+ this.restService.getResource(environment.K8SINFRACONFIGPROFILE_URL).subscribe((profileDatas: K8SCreateCLUSTERDATA[]) => {
+ this.profileData = [];
+ profileDatas.forEach((profileData: INFRACONFIGPAYLOAD) => {
+ const profileDataObj: INFRACONFIGPAYLOAD = this.generateprofileData(profileData);
+ this.profileData.push(profileDataObj);
+ });
+ if (this.profileData.length > 0) {
+ this.checkDataClass = 'dataTables_present';
+ } else {
+ this.checkDataClass = 'dataTables_empty';
+ }
+ this.dataSource.load(this.profileData).then((data: boolean) => {
+ this.isLoadingResults = false;
+ }).catch(() => {
+ this.isLoadingResults = false;
+ });
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+}
diff --git a/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.html b/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.html
new file mode 100644
index 0000000..592a0cb
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.html
@@ -0,0 +1,45 @@
+<!--
+Copyright 2020 TATA ELXSI
+
+Licensed under the Apache License, Version 2.0 (the 'License');
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+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
+limitations under the License.
+
+Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+-->
+<div class="d-flex flex-row justify-content-between">
+ <div class="d-flex align-items-center header-style">{{'PAGE.K8S.INFRACONTROLLER' | translate}}</div>
+ <span class="button">
+ <button class="btn btn-primary me-2" type="button" placement="top" container="body"
+ ngbTooltip="{{'Create Profile' | translate}}" (click)="addProfile()">
+ <i class="fas fa-plus-circle" aria-hidden="true"></i> {{'PAGE.K8S.CREATEPROFILE' | translate}}
+ </button>
+ </span>
+</div>
+<div class="mt-2 mb-2 list-utilites-actions">
+ <div class="col-auto me-auto">
+ <nav class="custom-items-config">
+ <span><i class="fas fa-clock text-success"></i>{{operationalStateFirstStep}}</span>
+ <span><i class="fas fa-spinner text-warning"></i>{{operationalStateSecondStep}}</span>
+ <span><i class="fas fa-spinner text-danger"></i>{{operationalStateThirdStep}}</span>
+ <span><i class="fas fa-times-circle text-danger"></i>{{operationalStateFourthStep}}</span>
+ <span><i class="fas fa-times-circle text-warning"></i>{{operationalStateFifthStep}}</span>
+ </nav>
+ </div>
+ <page-per-row class="me-2" (pagePerRow)="onChange($event)"></page-per-row>
+ <page-reload></page-reload>
+</div>
+<div class="smarttable-style bg-white mt-1">
+ <ng2-smart-table [ngClass]="checkDataClass" [settings]="settings" [source]="dataSource"
+ (userRowSelect)="onUserRowSelect($event)">
+ </ng2-smart-table>
+</div>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.scss b/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.scss
new file mode 100644
index 0000000..c55461a
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.scss
@@ -0,0 +1,17 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.ts b/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.ts
new file mode 100644
index 0000000..0402acf
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-infra-controller-details/K8sInfraControllerProfileComponent.ts
@@ -0,0 +1,253 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
+/**
+ * @file K8sInfraConfigProfileComponent.ts.
+ */
+import { Component, Injector, OnDestroy, OnInit } from '@angular/core';
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { CONFIGCONSTANT, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { DataService } from 'DataService';
+import { environment } from 'environment';
+import { K8sActionComponent } from 'K8sActionComponent';
+import { INFRACONFIGPAYLOAD, K8SCreateCLUSTERDATA, K8SCREATEDATADISPLAY } from 'K8sModel';
+import { LocalDataSource } from 'ng2-smart-table';
+import { RestService } from 'RestService';
+import { Subscription } from 'rxjs';
+import { SharedService } from 'SharedService';
+import { K8sInfraConfigAddComponent } from '../k8s-infra-config-add/K8sInfraConfigAddComponent';
+/**
+ * Creating Component
+ * @Component takes K8sInfraControllerProfileComponent.html as template url
+ */
+@Component({
+ selector: 'app-infra-controller-profile',
+ templateUrl: './K8sInfraControllerProfileComponent.html',
+ styleUrls: ['./K8sInfraControllerProfileComponent.scss']
+})
+/** Exporting a class @exports K8sInfraControllerProfileComponent */
+export class K8sInfraControllerProfileComponent implements OnInit, OnDestroy {
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** handle translate @public */
+ public translateService: TranslateService;
+
+ /** Data of smarttable populate through LocalDataSource @public */
+ public dataSource: LocalDataSource = new LocalDataSource();
+
+ /** Columns list of the smart table @public */
+ public columnList: object = {};
+
+ /** Settings for smarttable to populate the table with columns @public */
+ public settings: object = {};
+
+ /** operational State created data @public */
+ public operationalStateFirstStep: string = CONFIGCONSTANT.k8OperationalStateFirstStep;
+
+ /** operational State in creation data @public */
+ public operationalStateSecondStep: string = CONFIGCONSTANT.k8OperationalStateStateSecondStep;
+
+ /** operational State in deletion data @public */
+ public operationalStateThirdStep: string = CONFIGCONSTANT.k8OperationalStateThirdStep;
+
+ /** operational State failed deletion data @public */
+ public operationalStateFourthStep: string = CONFIGCONSTANT.k8OperationalStateFourthStep;
+
+ /** operational State failed creation data @public */
+ public operationalStateFifthStep: string = CONFIGCONSTANT.k8OperationalStateFifthStep;
+
+ /** Check the loading results @public */
+ public isLoadingResults: boolean = true;
+
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
+
+ /** Class for empty and present data @public */
+ public checkDataClass: string;
+
+ /** Instance of the rest service @private */
+ private restService: RestService;
+
+ /** dataService to pass the data from one component to another @private */
+ private dataService: DataService;
+
+ /** Formation of appropriate Data for LocalDatasource @private */
+ private profileData: {}[] = [];
+
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+
+ /** Instance of the modal service @private */
+ private modalService: NgbModal;
+
+ /** Instance of subscriptions @private */
+ private generateDataSub: Subscription;
+
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.restService = this.injector.get(RestService);
+ this.dataService = this.injector.get(DataService);
+ this.sharedService = this.injector.get(SharedService);
+ this.translateService = this.injector.get(TranslateService);
+ this.modalService = this.injector.get(NgbModal);
+ }
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.generateColumns();
+ this.generateSettings();
+ this.generateData();
+ this.generateDataSub = this.sharedService.dataEvent.subscribe(() => { this.generateData(); });
+ }
+
+ /** smart table Header Colums @public */
+ public generateColumns(): void {
+ this.columnList = {
+ name: { title: this.translateService.instant('NAME'), width: '20%', sortDirection: 'asc' },
+ identifier: { title: this.translateService.instant('IDENTIFIER'), width: '15%' },
+ state: {
+ title: this.translateService.instant('STATE'), width: '15%', type: 'html',
+ filter: {
+ type: 'list',
+ config: {
+ selectText: 'Select',
+ list: [
+ { value: this.operationalStateFirstStep, title: this.operationalStateFirstStep },
+ { value: this.operationalStateSecondStep, title: this.operationalStateSecondStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateThirdStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFourthStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFifthStep }
+ ]
+ }
+ },
+ valuePrepareFunction: (cell: INFRACONFIGPAYLOAD, row: INFRACONFIGPAYLOAD): string => {
+ if (row.state === this.operationalStateFirstStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-clock text-success"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateSecondStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-warning"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateThirdStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFourthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFifthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-warning"></i>
+ </span>`;
+ } else {
+ return `<span>${row.state}</span>`;
+ }
+ }
+ },
+ created: { title: this.translateService.instant('CREATED'), width: '10%' },
+ modified: { title: this.translateService.instant('MODIFIED'), width: '10%' },
+ Actions: {
+ name: 'Action', width: '5%', filter: false, sort: false, title: this.translateService.instant('ACTIONS'), type: 'custom',
+ valuePrepareFunction: (cell: K8SCREATEDATADISPLAY, row: K8SCREATEDATADISPLAY): K8SCREATEDATADISPLAY => row,
+ renderComponent: K8sActionComponent
+ }
+ };
+ }
+
+ /** smart table Data Settings @public */
+ public generateSettings(): void {
+ this.settings = {
+ columns: this.columnList,
+ actions: { add: false, edit: false, delete: false, position: 'right' },
+ attr: this.sharedService.tableClassConfig(),
+ pager: this.sharedService.paginationPagerConfig(),
+ noDataMessage: this.translateService.instant('NODATAMSG')
+ };
+ }
+
+ /** smart table listing manipulation @public */
+ public onChange(perPageValue: number): void {
+ this.dataSource.setPaging(1, perPageValue, true);
+ }
+
+ /** smart table listing manipulation @public */
+ public onUserRowSelect(event: MessageEvent): void {
+ Object.assign(event.data, { page: 'k8-infra-controller' });
+ this.dataService.changeMessage(event.data);
+ }
+
+ /** Compose new Profile @public */
+ public addProfile(): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
+ const modalRef: NgbModalRef = this.modalService.open(K8sInfraConfigAddComponent, { backdrop: 'static' });
+ modalRef.componentInstance.profileType = 'infra-controller';
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ }
+
+ /**
+ * Lifecyle hook which get trigger on component destruction
+ */
+ public ngOnDestroy(): void {
+ this.generateDataSub.unsubscribe();
+ }
+ /** Generate profile object from loop and return for the datasource @public */
+ public generateprofileData(profileData: INFRACONFIGPAYLOAD): INFRACONFIGPAYLOAD {
+ return {
+ name: profileData.name,
+ identifier: profileData._id,
+ created: this.sharedService.convertEpochTime(Number(profileData._admin.created)),
+ modified: this.sharedService.convertEpochTime(Number(profileData._admin.modified)),
+ description: profileData.description,
+ pageType: 'infra-controller',
+ state: profileData.state
+ };
+ }
+
+ /** Fetching the data from server to Load in the smarttable @protected */
+ protected generateData(): void {
+ this.isLoadingResults = true;
+ this.restService.getResource(environment.K8SINFRACONTROLLERPROFILE_URL).subscribe((profileDatas: K8SCreateCLUSTERDATA[]) => {
+ this.profileData = [];
+ profileDatas.forEach((profileData: INFRACONFIGPAYLOAD) => {
+ const profileDataObj: INFRACONFIGPAYLOAD = this.generateprofileData(profileData);
+ this.profileData.push(profileDataObj);
+ });
+ if (this.profileData.length > 0) {
+ this.checkDataClass = 'dataTables_present';
+ } else {
+ this.checkDataClass = 'dataTables_empty';
+ }
+ this.dataSource.load(this.profileData).then((data: boolean) => {
+ this.isLoadingResults = false;
+ }).catch(() => {
+ this.isLoadingResults = false;
+ });
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+}
diff --git a/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.html b/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.html
new file mode 100644
index 0000000..2e76c13
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.html
@@ -0,0 +1,45 @@
+<!--
+Copyright 2020 TATA ELXSI
+
+Licensed under the Apache License, Version 2.0 (the 'License');
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+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
+limitations under the License.
+
+Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+-->
+<div class="d-flex flex-row justify-content-between">
+ <div class="d-flex align-items-center header-style">{{'PAGE.K8S.RESOURCE' | translate}}</div>
+ <span class="button">
+ <button class="btn btn-primary me-2" type="button" placement="top" container="body"
+ ngbTooltip="{{'Create Profile' | translate}}" (click)="addProfile()">
+ <i class="fas fa-plus-circle" aria-hidden="true"></i> {{'PAGE.K8S.CREATEPROFILE' | translate}}
+ </button>
+ </span>
+</div>
+<div class="mt-2 mb-2 list-utilites-actions">
+ <div class="col-auto me-auto">
+ <nav class="custom-items-config">
+ <span><i class="fas fa-clock text-success"></i>{{operationalStateFirstStep}}</span>
+ <span><i class="fas fa-spinner text-warning"></i>{{operationalStateSecondStep}}</span>
+ <span><i class="fas fa-spinner text-danger"></i>{{operationalStateThirdStep}}</span>
+ <span><i class="fas fa-times-circle text-danger"></i>{{operationalStateFourthStep}}</span>
+ <span><i class="fas fa-times-circle text-warning"></i>{{operationalStateFifthStep}}</span>
+ </nav>
+ </div>
+ <page-per-row class="me-2" (pagePerRow)="onChange($event)"></page-per-row>
+ <page-reload></page-reload>
+</div>
+<div class="smarttable-style bg-white mt-1">
+ <ng2-smart-table [ngClass]="checkDataClass" [settings]="settings" [source]="dataSource"
+ (userRowSelect)="onUserRowSelect($event)">
+ </ng2-smart-table>
+</div>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.scss b/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.scss
new file mode 100644
index 0000000..c55461a
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.scss
@@ -0,0 +1,17 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
\ No newline at end of file
diff --git a/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.ts b/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.ts
new file mode 100644
index 0000000..296b0f6
--- /dev/null
+++ b/src/app/k8s/k8s-profile/k8s-resource-profile/K8sResourceProfileComponent.ts
@@ -0,0 +1,254 @@
+/*
+ Copyright 2020 TATA ELXSI
+
+ Licensed under the Apache License, Version 2.0 (the 'License');
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ 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
+ limitations under the License.
+
+ Author: SANDHYA JS (sandhya.j@tataelxsi.co.in)
+*/
+/**
+ * @file K8sInfraConfigProfileComponent.ts.
+ */
+import { Component, Injector, OnDestroy, OnInit } from '@angular/core';
+import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
+import { TranslateService } from '@ngx-translate/core';
+import { CONFIGCONSTANT, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { DataService } from 'DataService';
+import { environment } from 'environment';
+import { K8sActionComponent } from 'K8sActionComponent';
+import { INFRACONFIGPAYLOAD, K8SCreateCLUSTERDATA, K8SCREATEDATADISPLAY } from 'K8sModel';
+import { LocalDataSource } from 'ng2-smart-table';
+import { RestService } from 'RestService';
+import { Subscription } from 'rxjs';
+import { SharedService } from 'SharedService';
+import { K8sInfraConfigAddComponent } from '../k8s-infra-config-add/K8sInfraConfigAddComponent';
+/**
+ * Creating Component
+ * @Component takes K8sInfraConfigProfileComponent.html as template url
+ */
+@Component({
+ selector: 'app-resource-profile',
+ templateUrl: './K8sResourceProfileComponent.html',
+ styleUrls: ['./K8sResourceProfileComponent.scss']
+})
+/** Exporting a class @exports K8sResourceProfileComponent */
+export class K8sResourceProfileComponent implements OnInit, OnDestroy {
+ /** To inject services @public */
+ public injector: Injector;
+
+ /** handle translate @public */
+ public translateService: TranslateService;
+
+ /** Data of smarttable populate through LocalDataSource @public */
+ public dataSource: LocalDataSource = new LocalDataSource();
+
+ /** Columns list of the smart table @public */
+ public columnList: object = {};
+
+ /** Settings for smarttable to populate the table with columns @public */
+ public settings: object = {};
+
+ /** operational State created data @public */
+ public operationalStateFirstStep: string = CONFIGCONSTANT.k8OperationalStateFirstStep;
+
+ /** operational State in creation data @public */
+ public operationalStateSecondStep: string = CONFIGCONSTANT.k8OperationalStateStateSecondStep;
+
+ /** operational State in deletion data @public */
+ public operationalStateThirdStep: string = CONFIGCONSTANT.k8OperationalStateThirdStep;
+
+ /** operational State failed deletion data @public */
+ public operationalStateFourthStep: string = CONFIGCONSTANT.k8OperationalStateFourthStep;
+
+ /** operational State failed creation data @public */
+ public operationalStateFifthStep: string = CONFIGCONSTANT.k8OperationalStateFifthStep;
+
+ /** Check the loading results @public */
+ public isLoadingResults: boolean = true;
+
+ /** Give the message for the loading @public */
+ public message: string = 'PLEASEWAIT';
+
+ /** Class for empty and present data @public */
+ public checkDataClass: string;
+
+ /** Instance of the rest service @private */
+ private restService: RestService;
+
+ /** dataService to pass the data from one component to another @private */
+ private dataService: DataService;
+
+ /** Formation of appropriate Data for LocalDatasource @private */
+ private profileData: {}[] = [];
+
+ /** Contains all methods related to shared @private */
+ private sharedService: SharedService;
+
+ /** Instance of the modal service @private */
+ private modalService: NgbModal;
+
+ /** Instance of subscriptions @private */
+ private generateDataSub: Subscription;
+
+ constructor(injector: Injector) {
+ this.injector = injector;
+ this.restService = this.injector.get(RestService);
+ this.dataService = this.injector.get(DataService);
+ this.sharedService = this.injector.get(SharedService);
+ this.translateService = this.injector.get(TranslateService);
+ this.modalService = this.injector.get(NgbModal);
+ }
+ /** Lifecyle Hooks the trigger before component is instantiate @public */
+ public ngOnInit(): void {
+ this.generateColumns();
+ this.generateSettings();
+ this.generateData();
+ this.generateDataSub = this.sharedService.dataEvent.subscribe(() => { this.generateData(); });
+ }
+
+ /** smart table Header Colums @public */
+ public generateColumns(): void {
+ this.columnList = {
+ name: { title: this.translateService.instant('NAME'), width: '20%', sortDirection: 'asc' },
+ identifier: { title: this.translateService.instant('IDENTIFIER'), width: '15%' },
+ state: {
+ title: this.translateService.instant('STATE'), width: '15%', type: 'html',
+ filter: {
+ type: 'list',
+ config: {
+ selectText: 'Select',
+ list: [
+ { value: this.operationalStateFirstStep, title: this.operationalStateFirstStep },
+ { value: this.operationalStateSecondStep, title: this.operationalStateSecondStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateThirdStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFourthStep },
+ { value: this.operationalStateThirdStep, title: this.operationalStateFifthStep }
+ ]
+ }
+ },
+ valuePrepareFunction: (cell: INFRACONFIGPAYLOAD, row: INFRACONFIGPAYLOAD): string => {
+ if (row.state === this.operationalStateFirstStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-clock text-success"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateSecondStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-warning"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateThirdStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-spinner text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFourthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-danger"></i>
+ </span>`;
+ } else if (row.state === this.operationalStateFifthStep) {
+ return `<span class="icon-label" title="${row.state}">
+ <i class="fas fa-times-circle text-warning"></i>
+ </span>`;
+ } else {
+ return `<span>${row.state}</span>`;
+ }
+ }
+ },
+ created: { title: this.translateService.instant('CREATED'), width: '10%' },
+ modified: { title: this.translateService.instant('MODIFIED'), width: '10%' },
+ Actions: {
+ name: 'Action', width: '5%', filter: false, sort: false, title: this.translateService.instant('ACTIONS'), type: 'custom',
+ valuePrepareFunction: (cell: INFRACONFIGPAYLOAD, row: INFRACONFIGPAYLOAD): INFRACONFIGPAYLOAD => row,
+ renderComponent: K8sActionComponent
+ }
+ };
+ }
+
+ /** smart table Data Settings @public */
+ public generateSettings(): void {
+ this.settings = {
+ columns: this.columnList,
+ actions: { add: false, edit: false, delete: false, position: 'right' },
+ attr: this.sharedService.tableClassConfig(),
+ pager: this.sharedService.paginationPagerConfig(),
+ noDataMessage: this.translateService.instant('NODATAMSG')
+ };
+ }
+
+ /** smart table listing manipulation @public */
+ public onChange(perPageValue: number): void {
+ this.dataSource.setPaging(1, perPageValue, true);
+ }
+
+ /** smart table listing manipulation @public */
+ public onUserRowSelect(event: MessageEvent): void {
+ Object.assign(event.data, { page: 'k8-resource-profile' });
+ this.dataService.changeMessage(event.data);
+ }
+
+ /** Compose new Profile @public */
+ public addProfile(): void {
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
+ const modalRef: NgbModalRef = this.modalService.open(K8sInfraConfigAddComponent, { backdrop: 'static' });
+ modalRef.componentInstance.profileType = 'resource-profile';
+ modalRef.result.then((result: MODALCLOSERESPONSEDATA) => {
+ if (result) {
+ this.sharedService.callData();
+ }
+ }).catch((): void => {
+ // Catch Navigation Error
+ });
+ }
+
+ /**
+ * Lifecyle hook which get trigger on component destruction
+ */
+ public ngOnDestroy(): void {
+ this.generateDataSub.unsubscribe();
+ }
+
+ /** Generate profile object from loop and return for the datasource @public */
+ public generateProfileData(profileData: INFRACONFIGPAYLOAD): INFRACONFIGPAYLOAD {
+ return {
+ name: profileData.name,
+ identifier: profileData._id,
+ created: this.sharedService.convertEpochTime(Number(profileData._admin.created)),
+ modified: this.sharedService.convertEpochTime(Number(profileData._admin.modified)),
+ description: profileData.description,
+ pageType: 'resource-profile',
+ state: profileData.state
+ };
+ }
+
+ /** Fetching the data from server to Load in the smarttable @protected */
+ protected generateData(): void {
+ this.isLoadingResults = true;
+ this.restService.getResource(environment.K8SRESOURCEPROFILE_URL).subscribe((profileDatas: K8SCreateCLUSTERDATA[]) => {
+ this.profileData = [];
+ profileDatas.forEach((profileData: INFRACONFIGPAYLOAD) => {
+ const profileDataObj: INFRACONFIGPAYLOAD = this.generateProfileData(profileData);
+ this.profileData.push(profileDataObj);
+ });
+ if (this.profileData.length > 0) {
+ this.checkDataClass = 'dataTables_present';
+ } else {
+ this.checkDataClass = 'dataTables_empty';
+ }
+ this.dataSource.load(this.profileData).then((data: boolean) => {
+ this.isLoadingResults = false;
+ }).catch(() => {
+ this.isLoadingResults = false;
+ });
+ }, (error: ERRORDATA) => {
+ this.restService.handleError(error, 'get');
+ this.isLoadingResults = false;
+ });
+ }
+}