You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by wi...@apache.org on 2021/06/25 13:32:34 UTC

[incubator-streampipes] 01/02: add offline badge

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

wiener pushed a commit to branch edge-extensions
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git

commit 67a5a6e1ce2852ae589c659e612175f365981ac7
Author: Patrick Wiener <wi...@fzi.de>
AuthorDate: Fri Jun 25 15:31:39 2021 +0200

    add offline badge
---
 .../node-configuration.component.html                  | 17 ++++-------------
 .../node-configuration.component.scss                  | 11 +++++++++++
 .../node-configuration/node-configuration.component.ts | 18 ++++++++++++++++++
 .../dialog/save-pipeline/save-pipeline.component.html  |  2 +-
 4 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/ui/src/app/configuration/node-configuration/node-configuration.component.html b/ui/src/app/configuration/node-configuration/node-configuration.component.html
index 6cd38e4..96cdbdc 100644
--- a/ui/src/app/configuration/node-configuration/node-configuration.component.html
+++ b/ui/src/app/configuration/node-configuration/node-configuration.component.html
@@ -93,25 +93,12 @@
                                         </mat-icon>
                                         <span>edit</span>
                                     </button>
-<!--                                    <button mat-menu-item-->
-<!--                                            [disabled]="!node.active || node.condition === 'OFFLINE'"-->
-<!--                                            matTooltip="Edit node connectivity"-->
-<!--                                            matTooltipPosition="above"-->
-<!--                                            (click)="settings(node)">-->
-<!--                                        <mat-icon-->
-<!--                                                [ngClass]="'node-inactive'">-->
-<!--                                            contactless-->
-<!--                                        </mat-icon>-->
-<!--                                        <span>connectivity</span>-->
-<!--                                    </button>-->
                                 </mat-menu>
                             </div>
                             <div mat-card-avatar class="node-header-avatar">
                                 <button mat-icon-button class="node-mat-icon-button" disabled>
                                     <mat-icon [ngClass]="'node-inactive'">
                                         storage
-<!--                                        {{node.staticNodeMetadata.type == 'cloud' ? 'cloud' :-->
-<!--                                        node.staticNodeMetadata.type == 'fog' ? 'storage' : 'developer_board'}}-->
                                     </mat-icon>
                                 </button>
                             </div>
@@ -136,6 +123,10 @@
                                     <span *ngIf="node.condition === 'OFFLINE' && !node.active"
                                           class="span-node-inactive">lost
                                     </span>
+                                    <span *ngIf="node.condition === 'OFFLINE' && node.active"
+                                          class="span-node-inactive-days">since
+                                        {{calculateOfflineTime(node.lastHeartBeatTime)}}
+                                    </span>
                                 </div>
                             </mat-card-subtitle>
                         </mat-card-header>
diff --git a/ui/src/app/configuration/node-configuration/node-configuration.component.scss b/ui/src/app/configuration/node-configuration/node-configuration.component.scss
index a51354f..1861a17 100644
--- a/ui/src/app/configuration/node-configuration/node-configuration.component.scss
+++ b/ui/src/app/configuration/node-configuration/node-configuration.component.scss
@@ -91,6 +91,17 @@ li {
     margin-right: 2px;
 }
 
+.span-node-inactive-days{
+    font-size: 12px;
+    font-weight: bold;
+    color: white;
+    background: #f1c40f;
+    border: 1px solid #f1c40f;
+    padding: 2px;
+    margin-left: 2px;
+    margin-right: 2px;
+}
+
 .div-sa-tag{
     display: inline-block;
     margin-bottom: 10px;
diff --git a/ui/src/app/configuration/node-configuration/node-configuration.component.ts b/ui/src/app/configuration/node-configuration/node-configuration.component.ts
index 54a89f4..a33ba8c 100644
--- a/ui/src/app/configuration/node-configuration/node-configuration.component.ts
+++ b/ui/src/app/configuration/node-configuration/node-configuration.component.ts
@@ -206,4 +206,22 @@ export class NodeConfigurationComponent implements OnInit{
         return new Date(heartbeat).toLocaleTimeString(['en-US'],
             { hour: '2-digit', minute: "2-digit", second: "2-digit" });
     }
+
+    calculateOfflineTime(heartbeat: number) {
+        let now = new Date();
+        let seconds = Math.floor((now.getTime() - (new Date(heartbeat).getTime()))/1000);
+
+        const d = Math.floor(seconds / (3600 * 24));
+        seconds -= d * 3600 * 24;
+        const h = Math.floor(seconds / 3600);
+        seconds -= h * 3600;
+        const m = Math.floor(seconds / 60);
+        seconds -= m * 60;
+        const tmp = [];
+        (d) && tmp.push(d + 'd');
+        (d || h) && tmp.push(h + 'h');
+        (d || h || m) && tmp.push(m + 'm');
+        //tmp.push(seconds + 's');
+        return tmp.join(' ');
+    }
 }
\ No newline at end of file
diff --git a/ui/src/app/editor/dialog/save-pipeline/save-pipeline.component.html b/ui/src/app/editor/dialog/save-pipeline/save-pipeline.component.html
index 83cb1b6..a19ab7c 100644
--- a/ui/src/app/editor/dialog/save-pipeline/save-pipeline.component.html
+++ b/ui/src/app/editor/dialog/save-pipeline/save-pipeline.component.html
@@ -144,7 +144,7 @@
                                                      [expanded]="panelOpenState">
                                     <mat-expansion-panel-header>
                                         <mat-panel-description>
-                                            Modify deployment targets: <b>{{selectedPipelineExecutionPolicy}}</b>
+                                            Select node deployment targets: <b>{{selectedPipelineExecutionPolicy}}</b>
                                             <mat-icon>storage</mat-icon>
                                         </mat-panel-description>
                                     </mat-expansion-panel-header>