This is an automated email from the ASF dual-hosted git repository.

zhaoqingran pushed a commit to branch bulletin
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/bulletin by this push:
     new 498d3c583 improve
498d3c583 is described below

commit 498d3c583d105e6e1bfcb4948c51ca697fb02953
Author: zqr10159 <[email protected]>
AuthorDate: Tue Aug 20 08:03:19 2024 +0800

    improve
---
 .../src/app/routes/bulletin/bulletin.component.html  | 19 ++++++++++++-------
 .../src/app/routes/bulletin/bulletin.component.ts    | 20 +++++++++++++++++++-
 2 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/web-app/src/app/routes/bulletin/bulletin.component.html 
b/web-app/src/app/routes/bulletin/bulletin.component.html
index c66ef4dc2..5fb6989ce 100644
--- a/web-app/src/app/routes/bulletin/bulletin.component.html
+++ b/web-app/src/app/routes/bulletin/bulletin.component.html
@@ -66,18 +66,23 @@
           <tr>
             <th nzAlign="center" nzWidth="7%" [rowSpan]="2">App</th>
             <th nzAlign="center" nzWidth="7%" [rowSpan]="2">Host</th>
-            <ng-container *ngFor="let nbr of tabDefines.column.size">
-              <th nzAlign="center" 
[colSpan]="tabDefines.content.metrics[nbr].size">{{ tabDefines.column?.[nbr] 
}}</th>
+            <ng-container *ngFor="let metric of tabDefines.column">
+              <th nzAlign="center" [colSpan]="getKeys(metric).length">
+                {{ metric }}
+              </th>
             </ng-container>
           </tr>
           <tr>
-            <ng-container *ngFor="let nbr of tabDefines.column.size">
-              <ng-container *ngFor="let field of tabDefines.column?.[nbr]">
-                <th nzAlign="center">{{ field.value }}</th>
+            <ng-container *ngFor="let metric of tabDefines.column">
+              <ng-container *ngFor="let field of getKeys(metric)">
+                <th nzAlign="center" [colSpan]="1">
+                  {{ field }}
+                </th>
               </ng-container>
             </ng-container>
           </tr>
         </thead>
+
         <tbody>
           <ng-container *ngFor="let data of fixedTable.data">
             <ng-container *ngFor="let rowIndex of getRowIndexes(data)">
@@ -86,8 +91,8 @@
                   <td nzAlign="center" [rowSpan]="getMaxRowSpan(data)">{{ 
data.app }}</td>
                   <td nzAlign="center" [rowSpan]="getMaxRowSpan(data)">{{ 
data.host }}</td>
                 </ng-container>
-                <ng-container *ngFor="let metricName of tabDefines.column">
-                  <ng-container *ngFor="let field of 
tabDefines.bulletinColumn[metricName]">
+                <ng-container *ngFor="let nbr of tabDefines.column.length">
+                  <ng-container *ngFor="let field of 
tabDefines.content.metrics[nbr].length">
                     <td *ngIf="data[field] !== null">
                       {{ data[field][rowIndex].split('$$$')[0] }}
                       <nz-tag *ngIf="data[field][rowIndex] == null" 
nzColor="warning">{{ 'monitors.detail.value.null' | i18n }}</nz-tag>
diff --git a/web-app/src/app/routes/bulletin/bulletin.component.ts 
b/web-app/src/app/routes/bulletin/bulletin.component.ts
index 216305863..c8c2585c2 100644
--- a/web-app/src/app/routes/bulletin/bulletin.component.ts
+++ b/web-app/src/app/routes/bulletin/bulletin.component.ts
@@ -378,7 +378,8 @@ export class BulletinComponent implements OnInit {
           if (message.code === 0 && message.data) {
             // this.total = message.data.totalElements;
             this.tabDefines = message.data;
-            console.info('tab:', this.tabDefines);
+            console.info('tabDefines.length:', this.tabDefines.column.length);
+            console.info('tabDefines.field:', 
this.tabDefines.bulletinColumn['summary']);
           } else if (message.code !== 0) {
             this.notifySvc.warning(`${message.msg}`, '');
             console.info(`${message.msg}`);
@@ -395,6 +396,23 @@ export class BulletinComponent implements OnInit {
     this.tableLoading = false;
   }
 
+  getKeys(metricName: string): string[] {
+    const result = new Set<string>();
+
+    this.tabDefines.content.forEach((item: any) => {
+      item.metrics.forEach((metric: any) => {
+        if (metric.name === metricName) {
+          metric.fields.forEach((fieldGroup: any) => {
+            fieldGroup.forEach((field: any) => {
+              result.add(field.key);
+            });
+          });
+        }
+      });
+    });
+    return Array.from(result);
+  }
+
   getMaxRowSpan(data: { [x: string]: string | any[] }) {
     let maxRowSpan = 1;
     for (let metricName of this.tabDefines.column) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to