@@ -2,6 +2,7 @@ import React, { useState } from 'react';
2
2
import { bind } from '../../utils/bind' ;
3
3
import styles from './Home.module.css' ;
4
4
import { sentJump } from '../../infrastructure/postJump' ;
5
+ import { sentJumpGrpc } from '../../infrastructure/postJumpGrpc' ;
5
6
import { ResponseBack } from '../../domain/ResponseBack' ;
6
7
import { AppService } from '../../domain/AppService' ;
7
8
import { JumpLog } from '../../domain/JumpLog' ;
@@ -52,6 +53,7 @@ export const Home: React.FunctionComponent<Props> = () => {
52
53
} ;
53
54
54
55
const [ data , setData ] = useState ( jumps ) ;
56
+ const [ grpc , setGrpc ] = useState ( false ) ;
55
57
const [ calls , setCalls ] = useState ( 1 ) ;
56
58
const [ callsInterval , setCallsInterval ] = useState ( 1 ) ;
57
59
const [ callLogs , setCallLogs ] = useState ( { ...jumpLogTest } ) ;
@@ -67,11 +69,13 @@ export const Home: React.FunctionComponent<Props> = () => {
67
69
const sendJumps = async ( ) => {
68
70
setCallLogs ( { ...jumpLogTest } ) ;
69
71
72
+ const jumpsRequest = data . map ( ( i ) => i . jump )
73
+
70
74
const finalJump : Jump = {
71
75
message : 'hello' ,
72
76
jump_path : '/jump' ,
73
77
last_path : '/jump' ,
74
- jumps : data . map ( ( i ) => i . jump )
78
+ jumps : jumpsRequest ,
75
79
} ;
76
80
77
81
const timeout = async ( ms : number ) => {
@@ -83,7 +87,14 @@ export const Home: React.FunctionComponent<Props> = () => {
83
87
for ( let index = 0 ; index < calls ; index ++ ) {
84
88
await timeout ( callsInterval ) ;
85
89
setCallLogs ( { ...jumpLogTest } ) ;
86
- const jump : ResponseBack = await sentJump ( appBack , finalJump ) ;
90
+
91
+ var jump : ResponseBack = { } as any ;
92
+
93
+ if ( ! grpc ) {
94
+ jump = await sentJump ( appBack , finalJump ) ;
95
+ } else {
96
+ jump = await sentJumpGrpc ( appBack , jumpsRequest )
97
+ }
87
98
const timeLog = new Date ( ) ;
88
99
const time = timeLog . getTime ( ) ;
89
100
const date = new Date ( time ) ;
@@ -185,7 +196,20 @@ export const Home: React.FunctionComponent<Props> = () => {
185
196
</ div >
186
197
</ div >
187
198
< div role = 'jumpbox' className = { cx ( 'jumps-box' ) } >
188
- < h1 > Jumps</ h1 >
199
+ < h1 > Jumps</ h1 >
200
+ < div className = { cx ( 'jumps-box-grpc-section' ) } >
201
+ < p >
202
+ < input
203
+ type = "checkbox"
204
+ id = "grpc"
205
+ name = "grpc"
206
+ defaultChecked = { grpc }
207
+ onChange = { ( event ) =>
208
+ setGrpc ( event . target . checked )
209
+ } />
210
+ gRPC Enabled
211
+ </ p >
212
+ </ div >
189
213
< DragDropContext onDragEnd = { handleOnDragEnd } >
190
214
< Droppable droppableId = 'jumps' >
191
215
{ ( provided ) => (
0 commit comments