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/utilities/compose-packages/ComposePackages.html b/src/app/utilities/compose-packages/ComposePackages.html
index 03ec3b7..048e8cd 100644
--- a/src/app/utilities/compose-packages/ComposePackages.html
+++ b/src/app/utilities/compose-packages/ComposePackages.html
@@ -17,11 +17,16 @@
-->
<form [formGroup]="packagesForm" (ngSubmit)="createPackages()" autocomplete="off">
<div class="modal-header">
- <h4 class="modal-title" *ngIf="!template" id="modal-basic-title">{{'CREATEPACKAGE' | translate}}</h4>
+ <h4 class="modal-title" *ngIf="params.page === 'vnf-packages' || params.page === 'ns-packages'"
+ 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>
<h4 class="modal-title" *ngIf="params.page === 'ns-config-template-edit'" id="modal-basic-title">
{{'PAGE.NSCONFIGTEMPLATE.EDITNSCONFIGTEMPLATE' | translate}}</h4>
+ <h4 class="modal-title" *ngIf="params.page === 'oka-packages'" id="modal-basic-title">
+ {{'Create New OKA' | translate}}</h4>
+ <h4 class="modal-title" *ngIf="params.page === 'oka-packages-edit'" id="modal-basic-title">
+ {{'Edit OKA' | translate}}</h4>
<button class="button-xs" type="button" class="close" (click)="activeModal.close()">
<i class="fas fa-times-circle text-danger"></i>
</button>
@@ -31,7 +36,8 @@
<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>
+ <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>
@@ -40,6 +46,14 @@
[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>
+ <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 }"
+ required></textarea>
+ </div>
+ </div>
<div class="form-group row mb-3" *ngIf="template">
<label class="col-sm-6 col-form-label">{{'NSD' | translate}} {{'NAME' | translate}}*</label>
<div class="col-sm-6">
@@ -61,12 +75,30 @@
</div>
</div>
</div>
+ <div class="form-group row mb-3" *ngIf="oka">
+ <label class="col-sm-6 col-form-label">{{'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"
+ (change)="onFileDropped($event.target.files)" id="customFile">
+ <span>{{ selectedFileName }}</span>
+ <i class="fas fa-upload"></i>
+ </label>
+ <div class="custom-file" *ngIf="this.params.page === 'oka-packages'">
+ <input type="file" #fileInput class="fileupload custom-file-input" formControlName="package"
+ (change)="onFileDropped($event.target.files)" id="customFile">
+ </div>
+ <small class="text-info">{{'PAGE.K8S.UPLOADCONFIGGZLABEL' | translate}}</small>
+ </div>
+ </div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" (click)="activeModal.close()">{{'CANCEL' | translate}}</button>
- <button type="submit" class="btn btn-primary">{{'CREATE' | translate}}</button>
- <button *ngIf="params.page === 'ns-config-template-edit'" type="submit" class="btn btn-primary">{{'EDIT' |
- translate}}</button>
+ <button
+ *ngIf="params.page === 'ns-config-template' || params.page === 'oka-packages' || params.page === 'vnf-packages' || params.page === 'ns-packages'"
+ 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>
</div>
</form>
<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/utilities/compose-packages/ComposePackages.scss b/src/app/utilities/compose-packages/ComposePackages.scss
index 021d205..e44771c 100644
--- a/src/app/utilities/compose-packages/ComposePackages.scss
+++ b/src/app/utilities/compose-packages/ComposePackages.scss
@@ -14,4 +14,34 @@
limitations under the License.
Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
-*/
\ No newline at end of file
+*/
+@import "../../../assets/scss/mixins/mixin";
+@import "../../../assets/scss/variable";
+
+.custom-file-upload {
+ display: flex;
+ position: relative;
+ cursor: pointer;
+ overflow: hidden;
+ padding: 8px 12px;
+ color: $primary;
+ border: 1px solid;
+ border: 1px solid;
+ border-color: #054c8c;
+ border-radius: 4px;
+ width: 100%;
+}
+
+.custom-file-upload input[type="file"] {
+ position: absolute;
+ left: 0;
+ top: 0;
+ opacity: 0;
+ cursor: pointer;
+}
+
+.custom-file-upload span {
+ color: $primary;
+ width: 100%;
+ align-items: center;
+}
diff --git a/src/app/utilities/compose-packages/ComposePackages.ts b/src/app/utilities/compose-packages/ComposePackages.ts
index 0dff17a..17adaa0 100644
--- a/src/app/utilities/compose-packages/ComposePackages.ts
+++ b/src/app/utilities/compose-packages/ComposePackages.ts
@@ -34,6 +34,7 @@
import * as pako from 'pako';
import { RestService } from 'RestService';
import { SharedService, isNullOrUndefined } from 'SharedService';
+import { VNFD } from 'VNFDModel';
/** This is added globally by the tar.js library */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -77,6 +78,9 @@
/** contains NSD name @public */
public nsName: {}[] = [];
+ /** set the ns archieve file @public */
+ public okafile: File;
+
/** contains NSD details @public */
public nsdDetails: {}[];
@@ -92,12 +96,30 @@
/** Check if template or not @public */
public template = false;
+ /** Check if template or not @public */
+ public oka = false;
+
+ /** Check if template or not @public */
+ public package_name: string;
+
+ /** Element ref for fileInputConfigLabel @public */
+ @ViewChild('fileInput') fileInput: ElementRef<HTMLInputElement>;
+
+ /** Element ref for fileInputConfigLabel @public */
+ @ViewChild('fileInputLabel') fileInputLabel: ElementRef<HTMLLabelElement>;
+
/** Data of NS config @public */
public details: NSConfigData;
+ /** Data of OKA packages @public */
+ public packageData: VNFD;
+
/** Data of NF packages @public */
public nsConfigData: NSConfigData[] = [];
+ /** Contains selected file name @public */
+ public selectedFileName: string = 'Choose file...';
+
/** Element ref for fileInputConfig @public */
@ViewChild('fileInputConfig') fileInputConfig: ElementRef<HTMLInputElement>;
@@ -156,14 +178,34 @@
this.initializeForm();
if (this.params.page === 'ns-config-template') {
this.template = true;
+ this.oka = false;
this.getNsdPackageDetails();
+ this.getFormControl('description').disable();
} else if (this.params.page === 'ns-config-template-edit') {
this.template = true;
+ this.oka = false;
this.getNsdPackageDetails();
this.getFormControl('nsdId').disable();
- } else {
+ this.getFormControl('description').disable();
+ } else if (this.params.page === 'oka-packages') {
+ this.oka = true;
+ this.template = false;
this.getFormControl('nsdId').disable();
this.getFormControl('config').disable();
+ } else if (this.params.page === 'oka-packages-edit') {
+ this.oka = true;
+ this.template = false;
+ this.addNullValueForInvalidFiles();
+ this.packagesForm.value.package = '';
+ this.getOkaDetails();
+ this.getFormControl('nsdId').disable();
+ this.getFormControl('config').disable();
+ } else {
+ this.oka = false;
+ this.template = false;
+ this.getFormControl('nsdId').disable();
+ this.getFormControl('config').disable();
+ this.getFormControl('description').disable();
}
}
@@ -172,15 +214,17 @@
this.packagesForm = this.formBuilder.group({
name: ['', [Validators.required]],
nsdId: [null, [Validators.required]],
- config: [null]
+ config: [null],
+ description: ['', [Validators.required]],
+ package: ['']
});
}
/** Get NSD Package details @public */
public getNsdPackageDetails(): void {
- this.restService.getResource(environment.NSDESCRIPTORSCONTENT_URL)
- .subscribe((nsdPackageData: NSDDetails[]): void => {
- nsdPackageData.forEach((nsData: NSDDetails): void => {
+ this.restService.getResource(environment.OKAPACKAGES_URL)
+ .subscribe((nsdPackageData: []): void => {
+ nsdPackageData.forEach((nsData: VNFD): void => {
const names: {} = {
nsName: nsData.name,
nsId: nsData._id
@@ -196,6 +240,23 @@
});
}
+ /** Get NSD Package details @public */
+ public getOkaDetails(): void {
+ this.addNullValueForInvalidFiles();
+ this.restService.getResource(environment.OKAPACKAGES_URL + '/' + this.params.id)
+ .subscribe((nsdPackageData: VNFD): void => {
+ this.packageData = nsdPackageData;
+ this.packagesForm.value.package = '';
+ 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.fileInput.nativeElement.value = null;
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'get');
+ });
+ }
+
/** Get the NSD Content List & patch value in edit form @public */
public getNSConfigDetails(URL: string, name: {}[]): void {
this.restService.getResource(URL).subscribe((content: NSConfigData): void => {
@@ -226,6 +287,7 @@
this.modalData = {
message: 'Done'
};
+ this.addNullValueForInvalidFiles();
this.sharedService.cleanForm(this.packagesForm);
if (!this.packagesForm.invalid) {
this.isLoadingResults = true;
@@ -247,6 +309,29 @@
this.isLoadingResults = false;
this.notifierService.notify('error', this.translateService.instant('ERROR'));
}
+ } else if (this.oka) {
+ try {
+ this.headers = new HttpHeaders({
+ Accept: 'application/json',
+ 'Cache-Control': 'no-cache, no-store, must-revalidate, max-age=0'
+ });
+ if (this.params.page === 'oka-packages') {
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.OKAPACKAGES_URL,
+ httpOptions: { headers: this.headers }
+ };
+ this.saveFileData(apiURLHeader);
+ } else {
+ const apiURLHeader: APIURLHEADER = {
+ url: environment.OKAPACKAGES_URL + '/' + this.params.id,
+ httpOptions: { headers: this.headers }
+ };
+ this.editFileData(apiURLHeader);
+ }
+ } catch (e) {
+ this.isLoadingResults = false;
+ this.notifierService.notify('error', this.translateService.instant('ERROR'));
+ }
} else {
try {
this.headers = new HttpHeaders({
@@ -351,6 +436,68 @@
this.restService.handleError(error, 'post');
});
}
+
+ /** Drag and drop feature and fetchind the details of files @public */
+ public onFileDropped(files: FileList): void {
+ if (files && files.length === 1) {
+ const file: File = files[0];
+ if (this.sharedService.vaildataFileInfo(file, 'gz')) {
+ this.removeValidationDragDropFiles();
+ this.okafile = file;
+ this.selectedFileName = '';
+ if (this.params.page === 'oka-packages-edit') {
+ this.selectedFileName = files[0].name;
+ } else {
+ this.fileInputLabel.nativeElement.innerText = files[0].name;
+ this.fileInput.nativeElement.value = null;
+ }
+ } else {
+ this.notifierService.notify('error', this.translateService.instant('GZFILETYPEERRROR'));
+ this.addNullValueForInvalidFiles();
+ }
+ } else if (files && files.length > 1) {
+ this.notifierService.notify('error', this.translateService.instant('DROPFILESVALIDATION'));
+ }
+ }
+
+ /** Add Null value for invalid Files @public */
+ public addNullValueForInvalidFiles(): void {
+ this.getFormControl('package').setValue('');
+ }
+
+ /** Remove validation after drag drop Files @public */
+ public removeValidationDragDropFiles(): void {
+ this.getFormControl('package').setValidators([]);
+ this.getFormControl('package').updateValueAndValidity();
+ }
+
+
+ /** Post the droped files and reload the page @public */
+ public saveFileData(urlHeader: APIURLHEADER): void {
+ this.isLoadingResults = true;
+ this.packagesForm.value.package = this.okafile;
+ this.restService.postResource(urlHeader, this.toFormData(this.packagesForm.value)).subscribe((result: {}): void => {
+ this.activeModal.close(this.modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success', this.translateService.instant('OKA Package Created Successfully'));
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
+ }
+
+ /** Post the droped files and reload the page @public */
+ public editFileData(urlHeader: APIURLHEADER): void {
+ this.isLoadingResults = true;
+ this.restService.patchResource(urlHeader, this.toFormData(this.packagesForm.value)).subscribe((result: {}): void => {
+ this.activeModal.close(this.modalData);
+ this.isLoadingResults = false;
+ this.notifierService.notify('success', this.translateService.instant('OKA Package Edited Successfully'));
+ }, (error: ERRORDATA): void => {
+ this.restService.handleError(error, 'post');
+ this.isLoadingResults = false;
+ });
+ }
/** Config file process @private */
public configFile(files: FileList): void {
if (files && files.length === 1) {
@@ -453,6 +600,55 @@
return jsyaml.dump(packageYaml, { sortKeys: true });
}
+ /** Form data @private */
+ private toFormData<T>(formValue: T): FormData {
+ const formData: FormData = new FormData();
+ for (const key of Object.keys(formValue)) {
+ // eslint-disable-next-line security/detect-object-injection
+ const value: string = formValue[key];
+ if (key === 'name') {
+ if (this.params.page === 'oka-packages') {
+ if (!isNullOrUndefined(this.packagesForm.value.name)) {
+ formData.append(key, this.packagesForm.value.name);
+ }
+ } else if (this.params.page === 'oka-packages-edit') {
+ if (this.package_name.localeCompare(this.packagesForm.value.name) === 0) {
+ delete this.packagesForm.value.name;
+ } else {
+ formData.append(key, this.packagesForm.value.name);
+ }
+ }
+ else {
+ formData.append(key, '');
+ }
+ } else if (key === 'description') {
+ if (this.params.page === 'oka-packages') {
+ if (!isNullOrUndefined(this.packagesForm.value.description)) {
+ formData.append(key, this.packagesForm.value.description);
+ }
+ } else if (this.params.page === 'oka-packages-edit') {
+ if (this.packageData.description.localeCompare(this.packagesForm.value.description) === 0) {
+ delete this.packagesForm.value.description;
+ } else {
+ formData.append(key, this.packagesForm.value.description);
+ }
+ }
+ else {
+ formData.append(key, '');
+ }
+ } else if (key === 'package') {
+ if (!isNullOrUndefined(this.okafile)) {
+ formData.append(key, this.okafile);
+ } else {
+ delete this.packagesForm.value.package;
+ }
+ } else {
+ formData.append(key, value);
+ }
+ }
+ return formData;
+ }
+
/** Used to get the AbstractControl of controlName passed @private */
private getFormControl(controlName: string): AbstractControl {
// eslint-disable-next-line security/detect-object-injection