Skip to content

Commit 04bdbcf

Browse files
rfrohocknoorul
authored andcommitted
UI additions / updates (spark-jobserver#972)
* add submitted egg to spark context on subprocess start * slight revision * ui updates - Add Spark URL to Context - Add ability to kill Context - Change Jars to Binaries and show all binary types * added ability to kill running job * roll back python egg changes from other PR
1 parent 08f9933 commit 04bdbcf

File tree

2 files changed

+68
-19
lines changed

2 files changed

+68
-19
lines changed

job-server/src/main/resources/html/index.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h1>Spark Job Server UI</h1>
1919
<ul class="nav nav-tabs nav-justified" id="navTabs">
2020
<li class="active"><a href="#jobs" data-toggle="tab">Jobs</a></li>
2121
<li><a href="#contexts" data-toggle="tab">Contexts</a></li>
22-
<li><a href="#jars" data-toggle="tab">Jars</a></li>
22+
<li><a href="#binaries" data-toggle="tab">Binaries</a></li>
2323
</ul>
2424
<div class="tab-content">
2525
<div class="tab-pane active" id="jobs">
@@ -86,6 +86,8 @@ <h1>Spark Job Server UI</h1>
8686
<thead>
8787
<tr>
8888
<th>Name</th>
89+
<th>Spark URL</th>
90+
<th>Actions</th>
8991
</tr>
9092
</thead>
9193
<tbody>
@@ -94,14 +96,15 @@ <h1>Spark Job Server UI</h1>
9496
</div>
9597
</div>
9698
</div>
97-
<div class="tab-pane" id="jars">
99+
<div class="tab-pane" id="binaries">
98100
<div class="panel">
99101
<div class="panel-heading"></div>
100102
<div class="panel-body">
101-
<table class="table table-striped" id="jarsTable">
103+
<table class="table table-striped" id="binariesTable">
102104
<thead>
103105
<tr>
104106
<th>Name</th>
107+
<th>Type</th>
105108
<th>Deployment Time</th>
106109
</tr>
107110
</thead>

job-server/src/main/resources/html/js/spark-jobserver-ui.js

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function showJobs(filter,$tableBody) {
1+
function showJobs(filter,$tableBody,allowKill) {
22
$.getJSON(
33
'jobs',
44
filter,
@@ -12,6 +12,9 @@ function showJobs(filter,$tableBody) {
1212
jobsHtml += "<td>" + job.context + "</td>";
1313
jobsHtml += "<td>" + job.startTime + "</td>";
1414
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+
}
1518
jobsHtml += "</tr>";
1619
});
1720
$tableBody.html(jobsHtml);
@@ -20,11 +23,11 @@ function showJobs(filter,$tableBody) {
2023

2124
function getJobs() {
2225
//show error jobs
23-
showJobs({status:"error"},$('#failedJobsTable > tbody:last'));
26+
showJobs({status:"error"},$('#failedJobsTable > tbody:last'), false);
2427
//show running jobs
25-
showJobs({status:"running"},$('#runningJobsTable > tbody:last'));
28+
showJobs({status:"running"},$('#runningJobsTable > tbody:last'), true);
2629
//show complete jobs
27-
showJobs({status:"finished"},$('#completedJobsTable > tbody:last'));
30+
showJobs({status:"finished"},$('#completedJobsTable > tbody:last'), false);
2831
}
2932

3033
function getContexts() {
@@ -35,27 +38,70 @@ function getContexts() {
3538
$('#contextsTable tbody').empty();
3639

3740
$.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+
});
4154
});
4255
});
4356
}
4457

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() {
4691
$.getJSON(
47-
'jars',
92+
'binaries',
4893
'',
49-
function(jars) {
50-
$('#jarsTable tbody').empty();
94+
function(binaries) {
95+
$('#binariesTable tbody').empty();
5196

52-
$.each(jars, function(jarName, deploymentTime) {
97+
$.each(binaries, function(binariesName, binaryInfo) {
5398
var items = [];
5499
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>");
57103
items.push("</tr>");
58-
$('#jarsTable > tbody:last').append(items.join(""));
104+
$('#binariesTable > tbody:last').append(items.join(""));
59105
});
60106
});
61107
}
@@ -70,7 +116,7 @@ $(function () {
70116
} else if (target == "#contexts") {
71117
getContexts();
72118
} else {
73-
getJars();
119+
getBinaries();
74120
}
75121
})
76122
getJobs();

0 commit comments

Comments
 (0)