@@ -6,6 +6,8 @@ import { momentFormat, fetch } from "../utils";
6
6
import Modal from "react-modal" ;
7
7
import Error from "./Error" ;
8
8
9
+ import $ from "jquery" ;
10
+
9
11
export default class JobDetails extends React . Component {
10
12
static propTypes = { row : T . object . isRequired } ;
11
13
@@ -16,6 +18,8 @@ export default class JobDetails extends React.Component {
16
18
modalIsOpen : false ,
17
19
killRequestError : null ,
18
20
command : { id : "" , version : "" , name : "" } ,
21
+ cluster : { id : "" , version : "" , name : "" } ,
22
+ applications : [ ] ,
19
23
job : {
20
24
id : "" ,
21
25
tags : [ ] ,
@@ -31,6 +35,7 @@ export default class JobDetails extends React.Component {
31
35
}
32
36
}
33
37
} ;
38
+ window . myState = this . state ;
34
39
}
35
40
36
41
componentDidMount ( ) {
@@ -46,9 +51,19 @@ export default class JobDetails extends React.Component {
46
51
const url = row . _links . self . href ;
47
52
fetch ( url ) . done ( job => {
48
53
this . setState ( { job } ) ;
49
- fetch ( job . _links . command . href )
50
- . done ( command => {
51
- this . setState ( { command } ) ;
54
+
55
+ $ . when (
56
+ fetch ( job . _links . cluster . href ) ,
57
+ fetch ( job . _links . command . href ) ,
58
+ fetch ( job . _links . applications . href )
59
+ )
60
+ . done ( ( clusters , commands , applications ) => {
61
+ console . log ( applications ) ;
62
+ this . setState ( {
63
+ cluster : clusters [ 0 ] ,
64
+ command : commands [ 0 ] ,
65
+ applications : applications [ 0 ]
66
+ } ) ;
52
67
} )
53
68
. fail ( xhr => {
54
69
this . setState ( { error : xhr . responseJSON } ) ;
@@ -101,106 +116,95 @@ export default class JobDetails extends React.Component {
101
116
< tbody >
102
117
< tr >
103
118
< td className = "col-xs-2 align-right" > Job Id:</ td >
104
- < td >
105
- { this . state . job . id }
106
- </ td >
119
+ < td > { this . state . job . id } </ td >
107
120
</ tr >
108
121
< tr >
109
122
< td className = "col-xs-2 align-right" > Version:</ td >
110
- < td >
111
- { this . state . job . version }
112
- </ td >
123
+ < td > { this . state . job . version } </ td >
113
124
</ tr >
114
125
< tr >
115
126
< td className = "col-xs-2 align-right" > Description:</ td >
116
- < td >
117
- { this . state . job . description }
118
- </ td >
127
+ < td > { this . state . job . description } </ td >
119
128
</ tr >
120
129
< tr >
121
130
< td className = "col-xs-2 align-right" > Tags:</ td >
122
131
< td >
123
- { this . state . job . tags . join ( "," ) }
124
- </ td >
125
- </ tr >
126
- < tr >
127
- < td className = "col-xs-2 align-right" > Status:</ td >
128
- < td >
129
- { this . state . job . status }
132
+ < ul >
133
+ { this . state . job . tags . map ( ( tag , index ) => (
134
+ < li key = { index } > { tag } </ li >
135
+ ) ) }
136
+ </ ul >
130
137
</ td >
131
138
</ tr >
132
139
< tr >
133
140
< td className = "col-xs-2 align-right" > Status Msg:</ td >
134
- < td >
135
- { this . state . job . statusMsg }
136
- </ td >
141
+ < td > { this . state . job . statusMsg } </ td >
137
142
</ tr >
138
143
< tr >
139
144
< td className = "col-xs-2 align-right" > Created:</ td >
140
- < td >
141
- { momentFormat ( this . state . job . created ) }
142
- </ td >
145
+ < td > { momentFormat ( this . state . job . created ) } </ td >
143
146
</ tr >
144
147
< tr >
145
148
< td className = "col-xs-2 align-right" > Updated:</ td >
146
- < td >
147
- { momentFormat ( this . state . job . updated ) }
148
- </ td >
149
+ < td > { momentFormat ( this . state . job . updated ) } </ td >
149
150
</ tr >
150
151
< tr >
151
152
< td className = "col-xs-2 align-right" > Archive Location:</ td >
153
+ < td > { this . state . job . archiveLocation } </ td >
154
+ </ tr >
155
+ < tr >
156
+ < td className = "col-xs-2 align-right" > Application Ids:</ td >
152
157
< td >
153
- { this . state . job . archiveLocation }
158
+ < ul >
159
+ { this . state . applications . map ( ( application , index ) => (
160
+ < li key = { index } >
161
+ < Link
162
+ to = { `applications?name=${ application . name } &rowId=${
163
+ application . id
164
+ } `}
165
+ >
166
+ { application . id }
167
+ </ Link >
168
+ </ li >
169
+ ) ) }
170
+ </ ul >
154
171
</ td >
155
172
</ tr >
156
173
< tr >
157
- < td className = "col-xs-2 align-right" > Command Name :</ td >
174
+ < td className = "col-xs-2 align-right" > Cluster Id :</ td >
158
175
< td >
159
- < Link to = { `commands?name=${ this . state . job . commandName } ` } >
160
- { this . state . job . commandName }
176
+ < Link
177
+ to = { `clusters?name=${ this . state . job . clusterName } &rowId=${
178
+ this . state . cluster . id
179
+ } `}
180
+ >
181
+ { this . state . cluster . id }
161
182
</ Link >
162
183
</ td >
163
184
</ tr >
164
185
< tr >
165
186
< td className = "col-xs-2 align-right" > Command Id:</ td >
166
187
< td >
167
188
< Link
168
- to = { `commands?name=${ this . state . job
169
- . commandName } &rowId=${ this . state . command . id } `}
189
+ to = { `commands?name=${ this . state . job . commandName } &rowId=${
190
+ this . state . command . id
191
+ } `}
170
192
>
171
193
{ this . state . command . id }
172
194
</ Link >
173
195
</ td >
174
196
</ tr >
175
197
< tr >
176
- < td className = "col-xs-2 align-right" > Command Version:</ td >
177
- < td >
178
- { this . state . command . version }
179
- </ td >
180
- </ tr >
181
- < tr >
182
- < td className = "col-xs-2 align-right" > Command Created:</ td >
183
- < td >
184
- { momentFormat ( this . state . command . created ) }
185
- </ td >
186
- </ tr >
187
- < tr >
188
- < td className = "col-xs-2 align-right" > Command Updated:</ td >
189
- < td >
190
- { momentFormat ( this . state . command . updated ) }
191
- </ td >
198
+ < td className = "col-xs-2 align-right" > Command Args:</ td >
199
+ < td > { this . state . job . commandArgs } </ td >
192
200
</ tr >
193
201
< tr >
194
- < td className = "col-xs-2 align-right" > Command Status:</ td >
195
- < td >
196
- { this . state . command . status }
197
- </ td >
202
+ < td className = "col-xs-2 align-right" > Grouping:</ td >
203
+ < td > { this . state . job . grouping } </ td >
198
204
</ tr >
199
205
< tr >
200
- < td className = "col-xs-2 align-right" > Command Args:</ td >
201
- < td >
202
- { this . state . job . commandArgs }
203
- </ td >
206
+ < td className = "col-xs-2 align-right" > Grouping Instance:</ td >
207
+ < td > { this . state . job . groupingInstance } </ td >
204
208
</ tr >
205
209
< tr >
206
210
< td className = "col-xs-2 align-right" > Details:</ td >
@@ -243,86 +247,81 @@ export default class JobDetails extends React.Component {
243
247
</ tr >
244
248
{ ( this . state . job . status === "RUNNING" ||
245
249
this . state . job . status === "INIT" ) &&
246
- ! this . state . killJobRequestSent
247
- ? < tr >
248
- < td >
249
- < button
250
- type = "button"
251
- className = "btn btn-danger"
252
- onClick = { this . openModal }
253
- >
254
- Send Kill Request
255
- </ button >
256
- < Modal
257
- isOpen = { this . state . modalIsOpen }
258
- onRequestClose = { this . closeModal }
259
- style = { this . customStyles }
260
- >
261
- < div >
262
- < div className = "modal-header" >
263
- < h4
264
- className = "modal-title"
265
- id = "alert-modal-label"
266
- >
267
- Confirm Kill Request
268
- </ h4 >
269
- </ div >
270
- < div className = "modal-body" >
271
- < div > This cannot be undone.</ div >
272
- </ div >
273
- < div className = "modal-footer" >
274
- < button
275
- type = "button"
276
- className = "btn btn-primary"
277
- onClick = { ( ) => this . killJob ( this . state . job . id ) }
278
- >
279
- OK
280
- </ button >
281
- < button
282
- type = "button"
283
- className = "btn btn-default"
284
- onClick = { this . closeModal }
285
- >
286
- Cancel
287
- </ button >
288
- </ div >
250
+ ! this . state . killJobRequestSent ? (
251
+ < tr >
252
+ < td >
253
+ < button
254
+ type = "button"
255
+ className = "btn btn-danger"
256
+ onClick = { this . openModal }
257
+ >
258
+ Send Kill Request
259
+ </ button >
260
+ < Modal
261
+ isOpen = { this . state . modalIsOpen }
262
+ onRequestClose = { this . closeModal }
263
+ style = { this . customStyles }
264
+ >
265
+ < div >
266
+ < div className = "modal-header" >
267
+ < h4 className = "modal-title" id = "alert-modal-label" >
268
+ Confirm Kill Request
269
+ </ h4 >
270
+ </ div >
271
+ < div className = "modal-body" >
272
+ < div > This cannot be undone.</ div >
289
273
</ div >
290
- </ Modal >
291
- </ td >
292
- </ tr >
293
- : null }
274
+ < div className = "modal-footer" >
275
+ < button
276
+ type = "button"
277
+ className = "btn btn-primary"
278
+ onClick = { ( ) => this . killJob ( this . state . job . id ) }
279
+ >
280
+ OK
281
+ </ button >
282
+ < button
283
+ type = "button"
284
+ className = "btn btn-default"
285
+ onClick = { this . closeModal }
286
+ >
287
+ Cancel
288
+ </ button >
289
+ </ div >
290
+ </ div >
291
+ </ Modal >
292
+ </ td >
293
+ </ tr >
294
+ ) : null }
294
295
</ tbody >
295
296
</ table >
296
- { this . state . killJobRequestSent && ! this . state . killRequestError
297
- ? < small >
298
- *Request accepted. Please refresh the page in a few seconds to
299
- see the status change.
300
- </ small >
301
- : null }
302
- { this . state . killRequestError
303
- ? < div >
304
- < div >
305
- < small >
306
- *Request failed. Please refresh the page and try again.
307
- </ small >
308
- </ div >
309
- < div >
310
- < small >
311
- < code >
312
- { this . state . killRequestError . message } .
313
- </ code >
314
- </ small >
315
- </ div >
297
+ { this . state . killJobRequestSent && ! this . state . killRequestError ? (
298
+ < small >
299
+ *Request accepted. Please refresh the page in a few seconds to
300
+ see the status change.
301
+ </ small >
302
+ ) : null }
303
+ { this . state . killRequestError ? (
304
+ < div >
305
+ < div >
306
+ < small >
307
+ *Request failed. Please refresh the page and try again.
308
+ </ small >
309
+ </ div >
310
+ < div >
311
+ < small >
312
+ < code > { this . state . killRequestError . message } .</ code >
313
+ </ small >
316
314
</ div >
317
- : null }
318
- { this . state . error
319
- ? < div >
320
- < div >
321
- < span > Failed to load Command details:</ span >
322
- </ div >
323
- < Error error = { this . state . error } />
315
+ </ div >
316
+ ) : null }
317
+ { this . state . error ? (
318
+ < div >
319
+ < div >
320
+ < span > Failed to load Command details:</ span >
324
321
</ div >
325
- : null }
322
+ < Error error = { this . state . error } />
323
+ </ div >
324
+ ) : null }
326
325
</ div >
327
326
</ td >
328
327
</ tr >
0 commit comments