From 42093de4805aa7f98547bdfae4b4962e90e0eaff Mon Sep 17 00:00:00 2001
From: Chris Hines <chris.hines@monash.edu>
Date: Thu, 7 Feb 2019 16:54:58 +1100
Subject: [PATCH] update for job display to include extra info

---
 src/app/app.module.ts          |  3 ++-
 src/app/job.ts                 |  4 +++-
 src/app/job/job.component.html | 41 +++++++++++++++++++++++++++++++---
 src/app/job/job.component.ts   | 24 ++++++++++++++++++++
 4 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index f7713c3..71c1ee3 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -67,6 +67,7 @@ import { ModaldialogComponent } from './modaldialog/modaldialog.component'
     Sv2SideNavComponent,
     ShareconnectComponent,
     LaunchDialogComponent,
+    ModaldialogComponent
   ],
   imports: [
   BrowserModule,
@@ -95,7 +96,7 @@ import { ModaldialogComponent } from './modaldialog/modaldialog.component'
 
 
   ],
-  entryComponents: [ LogoutdialogComponent, LaunchDialogComponent ],
+    entryComponents: [ LogoutdialogComponent, LaunchDialogComponent, ModaldialogComponent],
   providers: [ StrudelappsService, ComputesitesService, TesService, SubmitAppService, MatDialog, AuthorisationService],
   bootstrap: [AppComponent]
 })
diff --git a/src/app/job.ts b/src/app/job.ts
index ec75181..1eb2b4a 100644
--- a/src/app/job.ts
+++ b/src/app/job.ts
@@ -7,7 +7,9 @@ export class Job {
   public jobid: string;
   public desc: string;
   public state: string;
-  public time: number;
+  public endtime: string;
+  public mem: string;
+  public cpus: string;
   public batch_host: string;
   public identity: Identity;
   public app: Strudelapp;
diff --git a/src/app/job/job.component.html b/src/app/job/job.component.html
index 0bdb89c..b708c3c 100644
--- a/src/app/job/job.component.html
+++ b/src/app/job/job.component.html
@@ -1,9 +1,44 @@
 <mat-card>
   <mat-card-title>{{ jobdata.name }}</mat-card-title>
   <div *ngIf="(jobdata.connectionState === undefined || jobdata.connectionState == 0)">
-  <table>
+  <div gdAreas="name name name name|
+                status resources space buttons"
+       gdColumns="20% 60% auto 20%">
+       <div gdArea="name">
+           {{ jobdata.desc }}
+       </div>
+       <div gdArea="status">
+           {{ jobdata.state }}
+       </div>
+       <div gdArea="buttons">
+           <div fxLayout="row">
+           <div fxFlex *ngIf="!nocancel">
+              <button mat-button (click)="onCancel()" >
+                Cancel
+              </button>
+           </div>
+           <div fxFlex *ngIf="available">
+              <button mat-button (click)="onConnect()" [disabled]="busy">
+                Connect
+              </button>
+           </div>
+           </div>
+       </div>
+       <div gdArea="resources">
+           <div fxLayout="column">
+               <div>
+                    {{ resources }}
+               </div>
+               <div>
+                   {{ timeremaining }}
+               </div>
+           </div>
+       </div>
+
+  </div>
+<!--  <table>
     <tr>
-      <td width="1000%">
+      <td width="100%">
         {{ jobdata.desc }}
       </td>
       <td width="20%">
@@ -24,7 +59,7 @@
         </div>
       </td>
   </tr>
-</table>
+</table>  -->
 </div>
 <div *ngIf="jobdata.connectionState == 1">
   Getting app parameters
diff --git a/src/app/job/job.component.ts b/src/app/job/job.component.ts
index c7d191e..c3b76f4 100644
--- a/src/app/job/job.component.ts
+++ b/src/app/job/job.component.ts
@@ -14,6 +14,8 @@ export class JobComponent implements OnInit {
   public available: Boolean;
   private busy: Boolean;
   public nocancel: Boolean;
+  public resources: string;
+  public timeremaining: string;
   constructor(private tesService: TesService, private strudelAppsService: StrudelappsService) {
 
 
@@ -35,7 +37,29 @@ export class JobComponent implements OnInit {
     } else {
       this.nocancel = false;
     }
+    this.resources="";
+      if (this.jobdata.cpus != undefined) {
+          this.resources = this.resources+"CPUs: "+this.jobdata.cpus;
+      }
+      if (this.jobdata.mem != undefined) {
+          this.resources = this.resources+" Mem: "+this.jobdata.mem;
+      }
+      if (this.jobdata.endtime != undefined) {
+          let end = Date.parse(this.jobdata.endtime);
+          let remaining = end.valueOf() - Date.now().valueOf();
+          this.timeremaining = "Time remaining: "+this.secondsToHms(remaining/1000);
+      }
+
+  }
+
+  secondsToHms(d: number) {
+    var h: number = Math.floor(d / 3600);
+    var m: number = Math.floor(d % 3600 / 60);
+    var s: number = Math.floor(d % 3600 % 60);
 
+    var hDisplay = h > 0 ? h + (h == 1 ? " hour, " : " hours, ") : "";
+    var mDisplay = m > 0 ? m + (m == 1 ? " minute, " : " minutes ") : "";
+    return hDisplay + mDisplay ; 
   }
 
   onCancel() {
-- 
GitLab