* Add the quotos limition to be defined from the UI.
* Added the checkbox to activate the quote limitation.
Change-Id: I3795d00a3615018743449538e232b3bb31591d82
Signed-off-by: Barath Kumar R <barath.r@tataelxsi.co.in>
"rxjs": "^6.5.4",
"rxjs-compat": "^6.5.5",
"stream": "0.0.2",
- "text-encoding": "^0.7.0",
"tslib": "^1.11.1",
"web-animations-js": "^2.3.2",
"zone.js": "~0.10.3"
},
"devDependencies": {
- "@angular-devkit/build-angular": "~0.901.0",
+ "@angular-devkit/build-angular": "^0.901.8",
"@angular/cli": "~9.1.0",
"@angular/compiler-cli": "~9.1.0",
"@angular/language-service": "~9.1.0",
import { RestService } from 'RestService';
import { Subscription } from 'rxjs';
import { SharedService } from 'SharedService';
+import { isNullOrUndefined } from 'util';
/**
* Creating component
public generateProjectData(projectData: ProjectDetails): ProjectData {
return {
projectName: projectData.name,
- modificationDate: this.sharedService.convertEpochTime(projectData._admin.modified),
- creationDate: this.sharedService.convertEpochTime(projectData._admin.created),
+ modificationDate: this.sharedService.convertEpochTime(!isNullOrUndefined(projectData._admin)
+ ? projectData._admin.modified : null),
+ creationDate: this.sharedService.convertEpochTime(!isNullOrUndefined(projectData._admin) ? projectData._admin.created : null),
id: projectData._id,
- project: projectData._id
+ project: projectData._id,
+ quotas: !isNullOrUndefined(projectData.quotas) ? projectData.quotas : null
};
}
-->
<form [formGroup]="projectForm" (ngSubmit)="projectAction(getProjectType)">
<div class="modal-header">
- <h4 class="modal-title" id="modal-basic-title">{{ (getProjectType == 'Add' ? 'NEW' : 'EDIT') | translate}} {{'PROJECT' | translate}}</h4>
+ <h4 class="modal-title" id="modal-basic-title">{{ (getProjectType == 'Add' ? 'NEW' : 'EDIT') | translate}}
+ {{'PROJECT' | 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 project-create-update">
+ <div class="modal-body modal-body-custom-height">
+ <div class="row" *ngIf="getProjectType === 'Add'">
+ <label class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10">{{'RECENTLY' | translate}}
+ {{'CREATED' | translate}} {{'PROJECT' | translate}}:
+ <b>{{(recentProject)?recentProject.name:''}}</b>
+ </label>
+ </div>
<div class="form-group row">
- <label class="col-sm-12 col-form-label mandatory-label" [ngClass]="{'text-danger': projectForm.invalid === true && submitted === true}">{{'MANDATORYCHECK' | translate}}</label>
+ <label class="col-sm-12 col-form-label mandatory-label"
+ [ngClass]="{'text-danger': projectForm.invalid === true && submitted === true}">{{'MANDATORYCHECK' | translate}}</label>
<label class="col-sm-4 col-form-label">{{'PROJECT' | translate}} {{'NAME' | translate}}*</label>
<div class="col-sm-8">
- <input placeholder="{{'PROJECT' | translate}} {{'NAME' | translate}}" type="text" class="form-control" formControlName="project_name" [(ngModel)]="projectName" [ngClass]="{ 'is-invalid': submitted && f.project_name.errors }" required>
+ <input placeholder="{{'PROJECT' | translate}} {{'NAME' | translate}}" type="text" class="form-control"
+ formControlName="project_name" [ngClass]="{ 'is-invalid': submitted && f.project_name.errors }" required>
</div>
</div>
<div class="form-group row" *ngIf="getProjectType === 'Add'">
<label class="col-sm-4 col-form-label">{{'DOMAIN' | translate}} {{'NAME' | translate}}</label>
<div class="col-sm-8">
- <ng-select [clearable]="false" placeholder="{{'SELECT' | translate}}"
- [items]="domains" bindLabel="text" bindValue="id" formControlName="domain_name" id="domain_name"
- [ngClass]="{ 'is-invalid': submitted && f.domain_name.errors }"></ng-select> </div>
+ <ng-select [clearable]="false" placeholder="{{'SELECT' | translate}}" [items]="domains" bindLabel="text"
+ bindValue="id" formControlName="domain_name" id="domain_name"
+ [ngClass]="{ 'is-invalid': submitted && f.domain_name.errors }"></ng-select>
+ </div>
</div>
- <div class="form-group row" *ngIf="getProjectType === 'Add'">
- <label class="col-xs-10 col-sm-10 col-md-10 col-lg-10 col-xl-10">{{'RECENTLY' | translate}} {{'CREATED' | translate}} {{'PROJECT' | translate}}:
- <b>{{(recentProject)?recentProject.name:''}}</b>
- </label>
+ <div class="form-check form-check-inline ml-2">
+ <input class="form-check-input" type="checkbox" formControlName="enable_quota" (change)="checkQuota()"
+ id="quotaCheck" *ngIf="getProjectType === 'Add' || quotaRefs === null">
+ <label class="form-check-label" for="quotaCheck">{{'PAGE.PROJECT.QUOTA' | translate}}</label>
+ </div>
+ <div class="row mt-1" [ngbCollapse]="!f.enable_quota.value">
+ <div class="form-group col-sm-6" *ngFor="let quota of quotaItems;">
+ <div class="row">
+ <label class="col-sm-7 col-form-label">{{quota.title | translate}}*</label>
+ <div class="col-sm-5">
+ <input placeholder="{{'COUNT' | translate}}" type="number" min="{{quota.minValue}}"
+ class="form-control" [formControlName]="quota.value" [ngClass]="{ 'is-invalid': submitted && f[quota.value].errors }" required>
+ </div>
+ </div>
+ </div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">{{(getProjectType == 'Add' ? 'CREATE' : 'APPLY') | translate}}</button>
</div>
</form>
-<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
+<app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
* @file Project Add Modal
*/
import { Component, Injector, Input, OnInit } from '@angular/core';
-import { FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { AbstractControl, FormBuilder, FormControl, 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 } from 'CommonModel';
import { DataService } from 'DataService';
import { environment } from 'environment';
-import { ProjectData, ProjectDetails } from 'ProjectModel';
+import { ProjectData, ProjectDetails, QUOTA_ITEMS, QUOTAITEM} from 'ProjectModel';
import { ProjectService } from 'ProjectService';
import { RestService } from 'RestService';
import { SharedService } from 'SharedService';
/** Contains the recently created project details @public */
public recentProject: ProjectDetails;
- /** Contains project name @public */
- public projectName: string;
-
/** Contains project create or edit @public */
public getProjectType: string;
/** Holds list of domains @public */
public domains: {}[] = [];
+ /** Holds list of quota items @public */
+ public quotaItems: QUOTAITEM[] = QUOTA_ITEMS;
+
+ /** Holds project reference from response @public */
+ public quotaRefs: {} = null;
+
/** FormBuilder instance added to the formBuilder @private */
private formBuilder: FormBuilder;
/** Initializing Form Action */
this.projectForm = this.formBuilder.group({
project_name: ['', Validators.required],
- domain_name: [null]
+ domain_name: [null],
+ enable_quota: [false, Validators.required]
});
}
if (this.getProjectType === 'Edit') {
this.dataService.currentMessage.subscribe((data: ProjectData) => {
if (data.projectName !== undefined || data.projectName !== '' || data.projectName !== null) {
- this.projectName = data.projectName;
+ this.projectForm.patchValue({ project_name: data.projectName });
this.projectRef = data.id;
+ this.quotaRefs = data.quotas;
+ this.patchQuotaInfo(this.quotaRefs);
}
});
} else {
+ this.patchQuotaInfo();
this.getProjects();
}
}
const apiURLHeader: APIURLHEADER = {
url: environment.PROJECTS_URL
};
- const projectPayload: {} = {
+ const projectPayload: ProjectDetails = {
name: this.projectForm.value.project_name,
domain_name: !isNullOrUndefined(this.projectForm.value.domain_name) ? this.projectForm.value.domain_name : undefined
};
+ this.addQuotaLimit(projectPayload);
this.restService.postResource(apiURLHeader, projectPayload).subscribe(() => {
this.activeModal.close(this.modalData);
this.isLoadingResults = false;
this.isLoadingResults = false;
});
}
+ /** Handle enable quota limit checkbox event @public */
+ public checkQuota(): void {
+ if (this.getFormControl('enable_quota').value) {
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, Validators.required));
+ });
+ } else {
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ this.getFormControl(quotaItem.value).setValue(quotaItem.minValue);
+ });
+ }
+ }
/** Edit project @public */
public editProject(): void {
this.isLoadingResults = true;
const apiURLHeader: APIURLHEADER = {
url: environment.PROJECTS_URL + '/' + this.projectRef
};
- this.restService.patchResource(apiURLHeader, { name: this.projectForm.value.project_name }).subscribe(() => {
+ const projectPayload: ProjectDetails = {
+ name: this.projectForm.value.project_name
+ };
+ this.addQuotaLimit(projectPayload);
+ this.restService.patchResource(apiURLHeader, projectPayload).subscribe(() => {
this.activeModal.close(this.modalData);
this.isLoadingResults = false;
this.projectService.setHeaderProjects();
});
}
}
+
+ /** Used to get the AbstractControl of controlName passed @private */
+ private getFormControl(controlName: string): AbstractControl {
+ return this.projectForm.controls[controlName];
+ }
+
+ /** Add quota information to payload @private */
+ private addQuotaLimit(payload: ProjectDetails): void {
+ if (this.getFormControl('enable_quota').value) {
+ payload.quotas = {};
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ payload.quotas[quotaItem.value] = this.getFormControl(quotaItem.value).value;
+ });
+ }
+ }
+
+ /** Set quota information in project form model @private */
+ private patchQuotaInfo(quotaRef?: {}): void {
+ if (quotaRef !== null && this.getProjectType === 'Edit') {
+ this.getFormControl('enable_quota').setValue(true);
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ if (!isNullOrUndefined(quotaRef[quotaItem.value])) {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaRef[quotaItem.value],
+ [Validators.required, Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+ } else {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required,
+ Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+ }
+ });
+ } else {
+ this.quotaItems.forEach((quotaItem: QUOTAITEM): void => {
+ this.projectForm.addControl(quotaItem.value, new FormControl(quotaItem.minValue, [Validators.required,
+ Validators.min(quotaItem.minValue), Validators.max(quotaItem.maxValue)]));
+ });
+ }
+ }
}
import { RoleData, RoleDetails } from 'RolesModel';
import { Subscription } from 'rxjs';
import { SharedService } from 'SharedService';
+import { isNullOrUndefined } from 'util';
/**
* Creating component
return {
name: roleData.name,
identifier: roleData._id,
- modified: this.sharedService.convertEpochTime(Number(roleData._admin.modified)),
- created: this.sharedService.convertEpochTime(Number(roleData._admin.created)),
+ modified: this.sharedService.convertEpochTime(!isNullOrUndefined(roleData._admin) ? Number(roleData._admin.modified) : null),
+ created: this.sharedService.convertEpochTime(!isNullOrUndefined(roleData._admin) ? Number(roleData._admin.created) : null),
permissions: roleData.permissions
};
}
import { SharedService } from 'SharedService';
import { UserData, UserDetail } from 'UserModel';
import { UsersActionComponent } from 'UsersActionComponent';
+import { isNullOrUndefined } from 'util';
/**
* Creating component
public setUserDetails(userData: UserDetail): void {
const userDataObj: UserData = {
username: userData.username,
- modified: this.sharedService.convertEpochTime(userData._admin.modified),
- created: this.sharedService.convertEpochTime(userData._admin.created),
+ modified: this.sharedService.convertEpochTime(!isNullOrUndefined(userData._admin) ? userData._admin.modified : null),
+ created: this.sharedService.convertEpochTime(!isNullOrUndefined(userData._admin) ? userData._admin.created : null),
projects: userData.projectListName,
identifier: userData._id
};
</button>
<div class="dropdown-menu list-action-dropdown" ngbDropdownMenu>
<button type="button" class="btn btn-primary dropdown-item" (click)="projectEdit()" placement="left"
- container="body" ngbTooltip="{{'RENAME' | translate}}">
- <i class="fa fa-edit icons"></i> {{'RENAME' | translate}}
+ container="body" ngbTooltip="{{'EDIT' | translate}}">
+ <i class="fa fa-edit icons"></i> {{'EDIT' | translate}}
</button>
<button type="button" class="btn btn-primary dropdown-item" (click)="projectDelete()" placement="left"
container="body" ngbTooltip="{{'DELETE' | translate}}">
"YAMLCONFIG": "Yaml Konfig",
"CHOOSEFILE": "Datei wählen",
"INVALIDCONFIG": "Ungültige Konfiguration",
+ "NODATE": "Keine Datumsinformationen gefunden",
"TYPEINFO": "Um einen neuen TYPW hinzuzufügen, geben Sie oben die Eingabe ein",
"UPLOADCONFIGLABEL": "Bitte laden Sie eine Datei im .yaml- oder .yml-Format hoch",
"PAGE": {
"PROJECT": {
"NEWPROJECT": "Nieuw project",
"CREATEDSUCCESSFULLY": "Projekt erfolgreich erstellt",
- "UPDATEDSUCCESSFULLY": "Projekt erfolgreich aktualisiert"
+ "UPDATEDSUCCESSFULLY": "Projekt erfolgreich aktualisiert",
+ "QUOTA": "Kontingentlimit"
},
"NSPACKAGE": {
"ADDNSPACKAGE": "Verfassen Sie eine neue NS",
"YAMLCONFIG": "Yaml Config",
"CHOOSEFILE": "Choose File",
"INVALIDCONFIG": "Invalid configuration",
+ "NODATE": "No date information found",
"TYPEINFO": "To add a new TYPE, Please enter input above",
"UPLOADCONFIGLABEL": "Please upload file with .yaml or .yml format",
"PAGE": {
"PROJECT": {
"NEWPROJECT": "New Project",
"CREATEDSUCCESSFULLY": "Project Created Successfully",
- "UPDATEDSUCCESSFULLY": "Project Updated Successfully"
+ "UPDATEDSUCCESSFULLY": "Project Updated Successfully",
+ "QUOTA": "Quota Limit"
},
"NSPACKAGE": {
"ADDNSPACKAGE": "Compose a new NS",
"YAMLCONFIG": "Yaml Config",
"CHOOSEFILE": "Elija el archivo",
"INVALIDCONFIG": "Configuración inválida",
+ "NODATE": "No se encontró información de fecha",
"TYPEINFO": "Para agregar un nuevo TIPO, ingrese la entrada de arriba",
"UPLOADCONFIGLABEL": "Cargue el archivo con formato .yaml o .yml",
"PAGE": {
"PROJECT": {
"NEWPROJECT": "Nuevo proyecto",
"CREATEDSUCCESSFULLY": "Proyecto Creada Exitosamente",
- "UPDATEDSUCCESSFULLY": "Proyecto Actualizada Exitosamente"
+ "UPDATEDSUCCESSFULLY": "Proyecto Actualizada Exitosamente",
+ "QUOTA": "Límite de cuota"
},
"NSPACKAGE": {
"ADDNSPACKAGE": "Componer un nuevo NS",
"YAMLCONFIG": "Yaml Config",
"CHOOSEFILE": "Escolher arquivo",
"INVALIDCONFIG": "Configuração inválida",
+ "NODATE": "Nenhuma informação de data encontrada",
"TYPEINFO": "Para adicionar um novo TIPO, insira a entrada acima",
"UPLOADCONFIGLABEL": "Faça o upload do arquivo no formato .yaml ou .yml",
"PAGE": {
"PROJECT": {
"NEWPROJECT": "Novo projeto",
"CREATEDSUCCESSFULLY": "Projeto criado com sucesso",
- "UPDATEDSUCCESSFULLY": "Projeto atualizado com sucesso"
+ "UPDATEDSUCCESSFULLY": "Projeto atualizado com sucesso",
+ "QUOTA": "Limite de cota"
},
"NSPACKAGE": {
"ADDNSPACKAGE": "Componha um novo NS",
_id?: string;
name?: string;
id?: string;
+ domain_name?: string;
+ quotas?: {};
}
/** Interface for Admin */
page?: string;
id?: string;
project?: string;
+ quotas?: {};
+}
+/** Interface for quota items */
+export const QUOTA_ITEMS: QUOTAITEM[] = [
+ {
+ title: 'VNFPACKAGES',
+ value: 'vnfds',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'NSPACKAGES',
+ value: 'nsds',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'PAGE.DASHBOARD.NETSLICETEMPLATE',
+ value: 'slice_templates',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'PDUINSTANCES',
+ value: 'pduds',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'NSINSTANCES',
+ value: 'ns_instances',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'PAGE.DASHBOARD.NETSLICEINSTANCE',
+ value: 'slice_instances',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'VIMACCOUNTS',
+ value: 'vim_accounts',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'WIMACCOUNTS',
+ value: 'wim_accounts',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'SDNCONTROLLER',
+ value: 'sdn_controllers',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'PAGE.K8S.MENUK8SCLUSTER',
+ value: 'k8sclusters',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'PAGE.K8S.MENUK8SREPO',
+ value: 'k8srepos',
+ minValue: 0,
+ maxValue: 9999
+ },
+ {
+ title: 'PAGE.OSMREPO.MENUOSMREPO',
+ value: 'osmrepos',
+ minValue: 0,
+ maxValue: 9999
+ }
+];
+
+/** Interface for quota individual item */
+export interface QUOTAITEM {
+ title: string;
+ value: string;
+ minValue: number;
+ maxValue: number;
}
import { EventEmitter, Injectable, Output } from '@angular/core';
import { FormArray, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
+import { TranslateService } from '@ngx-translate/core';
import { CONSTANTNUMBER, ERRORDATA, GETAPIURLHEADER, PACKAGEINFO, PAGERSMARTTABLE, SMARTTABLECLASS, TARSETTINGS } from 'CommonModel';
import { environment } from 'environment';
import * as HttpStatus from 'http-status-codes';
/** Check for the root directory @private */
private directoryCount: number = 2;
- constructor(restService: RestService, router: Router) {
+ /** Contains tranlsate instance @private */
+ private translateService: TranslateService;
+
+ constructor(restService: RestService, router: Router, translateService: TranslateService) {
this.restService = restService;
this.router = router;
+ this.translateService = translateService;
}
/** convert epoch time function @public */
public convertEpochTime(unixtimestamp: number): string {
- const monthsArr: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
- const date: Date = new Date(unixtimestamp * this.epochTime1000);
- const year: number = date.getFullYear();
- const month: string = monthsArr[date.getMonth()];
- const day: number = date.getDate();
- const hours: number = date.getHours();
- const minutes: string = '0' + date.getMinutes();
- const seconds: string = '0' + date.getSeconds();
- return month + '-' + day + '-' + year + ' ' + hours + ':' + minutes.substr(this.epochTimeMinus2) + ':'
- + seconds.substr(this.epochTimeMinus2);
+ if (!isNullOrUndefined(unixtimestamp)) {
+ const monthsArr: string[] = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+ const date: Date = new Date(unixtimestamp * this.epochTime1000);
+ const year: number = date.getFullYear();
+ const month: string = monthsArr[date.getMonth()];
+ const day: number = date.getDate();
+ const hours: number = date.getHours();
+ const minutes: string = '0' + date.getMinutes();
+ const seconds: string = '0' + date.getSeconds();
+ return month + '-' + day + '-' + year + ' ' + hours + ':' + minutes.substr(this.epochTimeMinus2) + ':'
+ + seconds.substr(this.epochTimeMinus2);
+ }
+ return this.translateService.instant('NODATE');
}
/** Download Files function @public */