1
- function showJobs ( filter , $tableBody ) {
1
+ function showJobs ( filter , $tableBody , allowKill ) {
2
2
$ . getJSON (
3
3
'jobs' ,
4
4
filter ,
@@ -12,6 +12,9 @@ function showJobs(filter,$tableBody) {
12
12
jobsHtml += "<td>" + job . context + "</td>" ;
13
13
jobsHtml += "<td>" + job . startTime + "</td>" ;
14
14
jobsHtml += "<td>" + job . duration + "</td>" ;
15
+ if ( allowKill ) {
16
+ jobsHtml += "<td><a href='#' id=" + job . jobId + " onclick='deleteJob(this.id);return false;'>kill</a></td>" ;
17
+ }
15
18
jobsHtml += "</tr>" ;
16
19
} ) ;
17
20
$tableBody . html ( jobsHtml ) ;
@@ -20,11 +23,11 @@ function showJobs(filter,$tableBody) {
20
23
21
24
function getJobs ( ) {
22
25
//show error jobs
23
- showJobs ( { status :"error" } , $ ( '#failedJobsTable > tbody:last' ) ) ;
26
+ showJobs ( { status :"error" } , $ ( '#failedJobsTable > tbody:last' ) , false ) ;
24
27
//show running jobs
25
- showJobs ( { status :"running" } , $ ( '#runningJobsTable > tbody:last' ) ) ;
28
+ showJobs ( { status :"running" } , $ ( '#runningJobsTable > tbody:last' ) , true ) ;
26
29
//show complete jobs
27
- showJobs ( { status :"finished" } , $ ( '#completedJobsTable > tbody:last' ) ) ;
30
+ showJobs ( { status :"finished" } , $ ( '#completedJobsTable > tbody:last' ) , false ) ;
28
31
}
29
32
30
33
function getContexts ( ) {
@@ -35,27 +38,70 @@ function getContexts() {
35
38
$ ( '#contextsTable tbody' ) . empty ( ) ;
36
39
37
40
$ . each ( contexts , function ( key , contextName ) {
38
- var items = [ ] ;
39
- items . push ( "<tr><td>" + contextName + "</td></tr>" ) ;
40
- $ ( '#contextsTable > tbody:last' ) . append ( items . join ( "" ) ) ;
41
+ $ . getJSON (
42
+ 'contexts/' + contextName ,
43
+ '' ,
44
+ function ( contextDetail ) {
45
+ var items = [ ] ;
46
+ items . push (
47
+ "<tr><td>" + contextDetail . context + "</td>" +
48
+ "<td><a href='" + contextDetail . url + "' target='_blank'>" + contextDetail . url + "</a></td>" +
49
+ "<td><a href='#' id=" + contextDetail . context + " onclick='deleteContext(this.id);return false;'>kill</a></td>" +
50
+ "</tr>" ) ;
51
+ $ ( '#contextsTable > tbody:last' ) . append ( items . join ( "" ) ) ;
52
+ console . log ( items ) ;
53
+ } ) ;
41
54
} ) ;
42
55
} ) ;
43
56
}
44
57
45
- function getJars ( ) {
58
+ function deleteJob ( jobID ) {
59
+ var deleteURL = "./jobs/" + jobID ;
60
+
61
+ $ . ajax ( {
62
+ type : 'DELETE' ,
63
+ url : deleteURL
64
+ } )
65
+ . done ( function ( responseText ) {
66
+ alert ( "Killed job: " + jobID + "\n" + JSON . stringify ( responseText ) ) ;
67
+ window . location . reload ( true ) ;
68
+ } )
69
+ . fail ( function ( jqXHR ) {
70
+ alert ( "Failed killing job: " + jobID + "\n" + JSON . stringify ( jqXHR . responseJSON ) ) ;
71
+ } ) ;
72
+ }
73
+
74
+ function deleteContext ( contextName ) {
75
+ var deleteURL = "./contexts/" + contextName ;
76
+
77
+ $ . ajax ( {
78
+ type : 'DELETE' ,
79
+ url : deleteURL
80
+ } )
81
+ . done ( function ( responseText ) {
82
+ alert ( "Killed context: " + contextName + "\n" + JSON . stringify ( responseText ) ) ;
83
+ window . location . reload ( true ) ;
84
+ } )
85
+ . fail ( function ( jqXHR ) {
86
+ alert ( "Failed killing context: " + contextName + "\n" + JSON . stringify ( jqXHR . responseJSON ) ) ;
87
+ } ) ;
88
+ }
89
+
90
+ function getBinaries ( ) {
46
91
$ . getJSON (
47
- 'jars ' ,
92
+ 'binaries ' ,
48
93
'' ,
49
- function ( jars ) {
50
- $ ( '#jarsTable tbody' ) . empty ( ) ;
94
+ function ( binaries ) {
95
+ $ ( '#binariesTable tbody' ) . empty ( ) ;
51
96
52
- $ . each ( jars , function ( jarName , deploymentTime ) {
97
+ $ . each ( binaries , function ( binariesName , binaryInfo ) {
53
98
var items = [ ] ;
54
99
items . push ( "<tr>" ) ;
55
- items . push ( "<td>" + jarName + "</td>" ) ;
56
- items . push ( "<td>" + deploymentTime + "</td>" ) ;
100
+ items . push ( "<td>" + binariesName + "</td>" ) ;
101
+ items . push ( "<td>" + binaryInfo [ 'binary-type' ] + "</td>" ) ;
102
+ items . push ( "<td>" + binaryInfo [ 'upload-time' ] + "</td>" ) ;
57
103
items . push ( "</tr>" ) ;
58
- $ ( '#jarsTable > tbody:last' ) . append ( items . join ( "" ) ) ;
104
+ $ ( '#binariesTable > tbody:last' ) . append ( items . join ( "" ) ) ;
59
105
} ) ;
60
106
} ) ;
61
107
}
@@ -70,7 +116,7 @@ $(function () {
70
116
} else if ( target == "#contexts" ) {
71
117
getContexts ( ) ;
72
118
} else {
73
- getJars ( ) ;
119
+ getBinaries ( ) ;
74
120
}
75
121
} )
76
122
getJobs ( ) ;
0 commit comments