Commit d3e88d9 1 parent e4b0a7e commit d3e88d9 Copy full SHA for d3e88d9
File tree 3 files changed +40
-8
lines changed
ui/scheduler/src/components
3 files changed +40
-8
lines changed Original file line number Diff line number Diff line change 11
11
// limitations under the License.
12
12
13
13
use crate :: SchedulerServer ;
14
- use ballista_core:: { serde :: scheduler :: ExecutorMeta , BALLISTA_VERSION } ;
14
+ use ballista_core:: BALLISTA_VERSION ;
15
15
use warp:: Rejection ;
16
16
17
17
#[ derive( Debug , serde:: Serialize ) ]
18
18
struct StateResponse {
19
- executors : Vec < ExecutorMeta > ,
19
+ executors : Vec < ExecutorMetaResponse > ,
20
20
started : u128 ,
21
21
version : & ' static str ,
22
22
}
23
23
24
+ #[ derive( Debug , serde:: Serialize ) ]
25
+ pub struct ExecutorMetaResponse {
26
+ pub id : String ,
27
+ pub host : String ,
28
+ pub port : u16 ,
29
+ pub last_seen : u128 ,
30
+ }
31
+
24
32
pub ( crate ) async fn scheduler_state (
25
33
data_server : SchedulerServer ,
26
34
) -> Result < impl warp:: Reply , Rejection > {
27
35
// TODO: Display last seen information in UI
28
- let executors: Vec < ExecutorMeta > = data_server
36
+ let executors: Vec < ExecutorMetaResponse > = data_server
29
37
. state
30
38
. get_executors_metadata ( )
31
39
. await
32
40
. unwrap_or_default ( )
33
41
. into_iter ( )
34
- . map ( |( metadata, _duration) | metadata)
42
+ . map ( |( metadata, duration) | ExecutorMetaResponse {
43
+ id : metadata. id ,
44
+ host : metadata. host ,
45
+ port : metadata. port ,
46
+ last_seen : duration. as_millis ( ) ,
47
+ } )
35
48
. collect ( ) ;
36
49
let response = StateResponse {
37
50
executors,
Original file line number Diff line number Diff line change @@ -60,6 +60,25 @@ interface DataTableProps {
60
60
maxW ?: number ;
61
61
pb ?: number ;
62
62
}
63
+
64
+ export const ElapsedCell : ( props : any ) => React . ReactNode = ( props : any ) => {
65
+ const time = new Date ( new Date ( ) . getTime ( ) - props . value ) ;
66
+ return (
67
+ < TimeAgo
68
+ date = { time }
69
+ formatter = { (
70
+ value : number ,
71
+ unit : TimeAgo . Unit ,
72
+ suffix : TimeAgo . Suffix
73
+ ) => {
74
+ if ( unit === "second" ) return "just now" ;
75
+ const plural : string = value !== 1 ? "s" : "" ;
76
+ return `${ value } ${ unit } ${ plural } ${ suffix } ` ;
77
+ } }
78
+ />
79
+ ) ;
80
+ } ;
81
+
63
82
export const DateCell : ( props : any ) => React . ReactNode = ( props : any ) => {
64
83
return (
65
84
< TimeAgo
Original file line number Diff line number Diff line change 17
17
18
18
import React from "react" ;
19
19
import { Box } from "@chakra-ui/react" ;
20
- import { Column , DateCell , DataTable } from "./DataTable" ;
20
+ import { Column , ElapsedCell , DataTable } from "./DataTable" ;
21
21
22
22
export enum NodeStatus {
23
23
RUNNING = "RUNNING" ,
@@ -50,9 +50,9 @@ const columns: Column<any>[] = [
50
50
accessor : "status" ,
51
51
} ,
52
52
{
53
- Header : "Started " ,
54
- accessor : "started " ,
55
- Cell : DateCell ,
53
+ Header : "Last Seen " ,
54
+ accessor : "last_seen " ,
55
+ Cell : ElapsedCell ,
56
56
} ,
57
57
] ;
58
58
You can’t perform that action at this time.
0 commit comments