Fix Bug 2296: Newly Created Ns should come first in NG-UI 64/13964/2
authorSANDHYA.JS <sandhya.j@tataelxsi.co.in>
Fri, 13 Oct 2023 06:15:25 +0000 (11:45 +0530)
committerjssan <sandhya.j@tataelxsi.co.in>
Tue, 7 Nov 2023 04:44:37 +0000 (05:44 +0100)
- Sorted the list using created Date in descending order
        - Incorrect Information in "Expires in " section of Admin user :
  Changed it to N/A
- VIM Resource Overview: RAM Value should be rounded off :
  Rounded off the value to 2 decimal points
- Fixed the key issue in topology

Change-Id: I634aee0b4e4540386c5108232746f56959bcc838
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
src/app/instances/ns-instances/NSInstancesComponent.ts
src/app/instances/ns-topology/NSTopologyComponent.html
src/app/instances/pdu-instances/PDUInstancesComponent.ts
src/app/instances/vnf-instances/VNFInstancesComponent.ts
src/app/users/user-details/UserDetailsComponent.ts
src/app/vim-accounts/Resources-Overview/ResourcesOverviewComponent.ts
src/models/NSInstanceModel.ts
src/services/SharedService.ts

index 5cc5519..e7de4a7 100644 (file)
@@ -144,9 +144,13 @@ export class NSInstancesComponent implements OnInit {
     /** Generate smart table row title and filters @public  */
     public generateTableColumn(): void {
         this.columnList = {
-            name: { title: this.translateService.instant('NAME'), width: '15%', sortDirection: 'asc' },
+            name: { title: this.translateService.instant('NAME'), width: '15%' },
             identifier: { title: this.translateService.instant('IDENTIFIER'), width: '20%' },
             NsdName: { title: this.translateService.instant('NSDNAME'), width: '15%' },
+            'create-time': {
+                title: this.translateService.instant('DATE'), width: '15%', sortDirection: 'desc',
+                compareFunction: this.sharedService.compareFunction
+            },
             OperationalStatus: {
                 title: this.translateService.instant('OPERATIONALSTATUS'), width: '10%', type: 'html',
                 filter: {
@@ -244,7 +248,8 @@ export class NSInstancesComponent implements OnInit {
                     nsd: nsdInstanceData.nsd,
                     'nsd-id': nsdInstanceData['nsd-id'],
                     vcaStatus: nsdInstanceData.vcaStatus,
-                    constituent: nsdInstanceData['constituent-vnfr-ref']
+                    constituent: nsdInstanceData['constituent-vnfr-ref'],
+                    'create-time': this.sharedService.convertEpochTime(Number(nsdInstanceData['create-time']))
                 };
                 this.nsInstanceData.push(nsDataObj);
             });
index d500535..084f90e 100644 (file)
@@ -113,7 +113,7 @@ Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.i
                                 </tr>
                                 <tr>
                                     <td>Vnfd Id</td>
-                                    <td>{{(vnfr.vnfdID)?vnfr.vnfdID:'-'}}</td>
+                                    <td>{{(vnfr.vnfdId)?vnfr.vnfdId:'-'}}</td>
                                 </tr>
                                 <tr>
                                     <td>Member index</td>
index 5c25279..6a2ca34 100644 (file)
@@ -124,10 +124,13 @@ export class PDUInstancesComponent implements OnInit, OnDestroy {
     public generateTableColumn(): void {
         this.columnList = {
             identifier: { title: this.translateService.instant('IDENTIFIER'), width: '25%' },
-            name: { title: this.translateService.instant('NAME'), width: '20%', sortDirection: 'asc' },
+            name: { title: this.translateService.instant('NAME'), width: '20%' },
             type: { title: this.translateService.instant('TYPE'), width: '15%' },
             usageState: { title: this.translateService.instant('USAGESTATE'), width: '15%' },
-            CreatedAt: { title: this.translateService.instant('CREATEDAT'), width: '15%' },
+            CreatedAt: {
+                title: this.translateService.instant('CREATEDAT'), width: '15%', sortDirection: 'desc',
+                compareFunction: this.sharedService.compareFunction
+            },
             Actions: {
                 name: 'Action', width: '10%', filter: false, sort: false, type: 'custom',
                 title: this.translateService.instant('ACTIONS'),
index 90bb6fe..c27384d 100644 (file)
@@ -118,7 +118,7 @@ export class VNFInstancesComponent implements OnInit {
     /** Generate smart table row title and filters @public  */
     public generateTableColumn(): void {
         this.columnList = {
-            identifier: { title: this.translateService.instant('IDENTIFIER'), width: '25%', sortDirection: 'asc' },
+            identifier: { title: this.translateService.instant('IDENTIFIER'), width: '25%' },
             VNFD: {
                 title: this.translateService.instant('VNFD'), width: '20%', type: 'custom',
                 valuePrepareFunction: (cell: VNFInstanceData, row: VNFInstanceData): VNFInstanceData => row,
@@ -126,7 +126,10 @@ export class VNFInstancesComponent implements OnInit {
             },
             MemberIndex: { title: this.translateService.instant('MEMBERINDEX'), width: '15%' },
             NS: { title: this.translateService.instant('NS'), width: '20%' },
-            CreatedAt: { title: this.translateService.instant('CREATEDAT'), width: '15%' },
+            CreatedAt: {
+                title: this.translateService.instant('CREATEDAT'), width: '15%', sortDirection: 'desc',
+                compareFunction: this.sharedService.compareFunction
+            },
             Actions: {
                 name: 'Action', width: '5%', filter: false, sort: false, type: 'custom',
                 title: this.translateService.instant('ACTIONS'),
index 12c37fe..c56f43a 100644 (file)
@@ -252,8 +252,8 @@ export class UserDetailsComponent implements OnInit, OnDestroy {
       projects: userData.projectListName,
       identifier: userData._id,
       user_status: userData._admin.user_status,
-      account_expire_time: this.sharedService.convertEpochTime(!isNullOrUndefined(userData._admin) ?
-        userData._admin.account_expire_time : null)
+      account_expire_time: (!isNullOrUndefined(userData._admin) && !isNullOrUndefined(userData._admin.account_expire_time)) ? this.sharedService.convertEpochTime(
+        userData._admin.account_expire_time) : 'N/A'
     };
     this.userData.push(userDataObj);
   }
index 11d48d7..eb7c8bc 100644 (file)
@@ -62,6 +62,9 @@ export class ResourcesOverviewComponent implements OnChanges {
     @Input() public resourcesData: VimAccountDetails;
     /** Resources data for generating chart @public */
     public chartData: RESOURCESDATA[] = [];
+    /** Count of decimalPoints @private */
+    // eslint-disable-next-line @typescript-eslint/no-magic-numbers
+    private decimalPoints: number = 2;
     constructor(injector: Injector) {
         this.injector = injector;
         this.translateService = this.injector.get(TranslateService);
@@ -115,9 +118,9 @@ export class ResourcesOverviewComponent implements OnChanges {
             let usedColor: string = RANGECOLOR.used;
             // eslint-disable-next-line security/detect-object-injection
             const getValuesUsedFree: number[] = Object.values(compute[key]);
-            const total: number = key === keyValidate ? getValuesUsedFree[0] / CONSTANTNUMBER.oneGB : getValuesUsedFree[0];
-            const used: number = key === keyValidate ? getValuesUsedFree[1] / CONSTANTNUMBER.oneGB : getValuesUsedFree[1];
-            const remaining: number = total - used;
+            const total: number = key === keyValidate ? Number((getValuesUsedFree[0] / CONSTANTNUMBER.oneGB).toFixed(this.decimalPoints)) : Number((getValuesUsedFree[0]).toFixed(this.decimalPoints));
+            const used: number = key === keyValidate ? Number((getValuesUsedFree[1] / CONSTANTNUMBER.oneGB).toFixed(this.decimalPoints)) : Number((getValuesUsedFree[1]).toFixed(this.decimalPoints));
+            const remaining: number = Number((total - used).toFixed(this.decimalPoints));
             const usedPercentage: number = (used / total) * range.percentage;
             if (usedPercentage >= range.nearlyFull && usedPercentage < range.full) {
                 usedColor = RANGECOLOR.nearlyfull;
@@ -125,7 +128,7 @@ export class ResourcesOverviewComponent implements OnChanges {
             if (usedPercentage === range.full) {
                 usedColor = RANGECOLOR.full;
             }
-            getData.push(this.generateChartData(key, { total, used, remaining }, [usedColor, '#b9bcc3'] ));
+            getData.push(this.generateChartData(key, { total, used, remaining }, [usedColor, '#b9bcc3']));
         });
         return getData;
     }
@@ -140,8 +143,10 @@ export class ResourcesOverviewComponent implements OnChanges {
             // eslint-disable-next-line security/detect-object-injection
             title: CONFIGRESOURCESTITLE[setTitle],
             values: this.generateChartDataValues(setValues.total, setValues.used, setValues.remaining),
-            data: [{data: [setValues.used, setValues.remaining], backgroundColor: setColor,
-                 hoverBackgroundColor: setColor, hoverBorderColor: setColor}]
+            data: [{
+                data: [setValues.used, setValues.remaining], backgroundColor: setColor,
+                hoverBackgroundColor: setColor, hoverBorderColor: setColor
+            }]
         };
     }
     /**
index 12ce977..5039cc5 100644 (file)
@@ -49,6 +49,8 @@ export interface NSInstanceDetails {
     additionalParamsForNs: AdditionalParamForN;
     _id?: string;
     vcaStatus?: object;
+    startTime?: string;
+    'create-time'?: string;
 }
 
 /** Interface for Admin */
@@ -266,6 +268,7 @@ export interface NSDInstanceData {
     operationParams?: OPERATIONPARAMS;
     'nsd-id': string;
     constituent: string[];
+    'create-time'?: string;
 }
 
 /** Interface for the operationparams */
index 8abe1d2..f80eb7c 100644 (file)
@@ -464,6 +464,19 @@ export class SharedService {
         }));
     }
 
+    /** Sorting the list based on date @public */
+    public compareFunction = (dir: number, a: string, b: string): number => {
+        const first: number = new Date(a).getTime();
+        const second: number = new Date(b).getTime();
+        if (first < second) {
+            return -1 * dir;
+        }
+        if (first > second) {
+            return dir;
+        }
+        return 0;
+    };
+
     /** Method to validate file extension and size @private */
     private vaildataFileInfo(fileInfo: File, fileType: string): boolean {
         const extension: string = fileInfo.name.substring(fileInfo.name.lastIndexOf('.') + 1);