NG-UI Added support for the quotos 51/9351/3
authorBarath Kumar R <barath.r@tataelxsi.co.in>
Tue, 7 Jul 2020 10:42:32 +0000 (16:12 +0530)
committerbeierlm <mark.beierl@canonical.com>
Mon, 13 Jul 2020 14:51:03 +0000 (16:51 +0200)
 * 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>
13 files changed:
package.json
src/app/projects/ProjectsComponent.ts
src/app/projects/project-create-update/ProjectCreateUpdateComponent.html
src/app/projects/project-create-update/ProjectCreateUpdateComponent.ts
src/app/roles/roles-details/RolesDetailsComponent.ts
src/app/users/user-details/UserDetailsComponent.ts
src/app/utilities/projects-action/ProjectsActionComponent.html
src/assets/i18n/de.json
src/assets/i18n/en.json
src/assets/i18n/es.json
src/assets/i18n/pt.json
src/models/ProjectModel.ts
src/services/SharedService.ts

index 264dc07..4858905 100644 (file)
     "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",
index 7524994..fe55271 100644 (file)
@@ -32,6 +32,7 @@ import { ProjectsActionComponent } from 'ProjectsAction';
 import { RestService } from 'RestService';
 import { Subscription } from 'rxjs';
 import { SharedService } from 'SharedService';
+import { isNullOrUndefined } from 'util';
 
 /**
  * Creating component
@@ -169,10 +170,12 @@ export class ProjectsComponent implements OnInit, OnDestroy {
     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
         };
     }
 
index c327119..8afb727 100644 (file)
@@ -17,30 +17,51 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
 -->
 <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">
@@ -48,4 +69,4 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
     <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
index ea0bb8a..ba176e0 100644 (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';
@@ -55,9 +55,6 @@ export class ProjectCreateUpdateComponent implements OnInit {
   /** 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;
 
@@ -79,6 +76,12 @@ export class ProjectCreateUpdateComponent implements OnInit {
   /** 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;
 
@@ -116,7 +119,8 @@ export class ProjectCreateUpdateComponent implements OnInit {
     /** Initializing Form Action */
     this.projectForm = this.formBuilder.group({
       project_name: ['', Validators.required],
-      domain_name: [null]
+      domain_name: [null],
+      enable_quota: [false, Validators.required]
     });
   }
 
@@ -129,11 +133,14 @@ export class ProjectCreateUpdateComponent implements OnInit {
     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();
     }
   }
@@ -172,10 +179,11 @@ export class ProjectCreateUpdateComponent implements OnInit {
     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;
@@ -185,13 +193,29 @@ export class ProjectCreateUpdateComponent implements OnInit {
       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();
@@ -230,4 +254,40 @@ export class ProjectCreateUpdateComponent implements OnInit {
       });
     }
   }
+
+  /** 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)]));
+      });
+    }
+  }
 }
index 2568f5a..89affae 100644 (file)
@@ -30,6 +30,7 @@ import { RolesActionComponent } from 'RolesAction';
 import { RoleData, RoleDetails } from 'RolesModel';
 import { Subscription } from 'rxjs';
 import { SharedService } from 'SharedService';
+import { isNullOrUndefined } from 'util';
 
 /**
  * Creating component
@@ -170,8 +171,8 @@ export class RolesDetailsComponent implements OnInit {
     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
     };
   }
index a4bedd5..aede6e2 100644 (file)
@@ -32,6 +32,7 @@ import { Subscription } from 'rxjs';
 import { SharedService } from 'SharedService';
 import { UserData, UserDetail } from 'UserModel';
 import { UsersActionComponent } from 'UsersActionComponent';
+import { isNullOrUndefined } from 'util';
 
 /**
  * Creating component
@@ -170,8 +171,8 @@ export class UserDetailsComponent implements OnInit, OnDestroy {
   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
     };
index d105846..3f193c2 100644 (file)
@@ -22,8 +22,8 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
         </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}}">
index bde25ba..b889dd0 100644 (file)
     "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",
index 8861820..a57dfcf 100644 (file)
     "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",
index 084782f..d325d99 100644 (file)
     "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",
index 87a7554..3936203 100644 (file)
     "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",
index 878bb47..ad070c6 100644 (file)
@@ -25,6 +25,8 @@ export interface ProjectDetails {
     _id?: string;
     name?: string;
     id?: string;
+    domain_name?: string;
+    quotas?: {};
 }
 
 /** Interface for Admin */
@@ -41,4 +43,88 @@ export interface ProjectData {
     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;
 }
index 41f3d76..d35e41d 100644 (file)
@@ -22,6 +22,7 @@ import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
 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';
@@ -100,24 +101,31 @@ export class SharedService {
     /** 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 */