-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
139 lines (130 loc) · 4.49 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!doctype html>
<html>
<head>
<title>Dask Clusters</title>
<link rel="stylesheet" href="static/pure-css/pure-min.css" />
<link rel="stylesheet" href="static/pure-css/grids-responsive-min.css" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
.header {
text-align: center;
}
table#clusters {
width: 100%;
}
td.cluster-link {
word-break: break-all;
}
.stop-link {
background-color: transparent;
}
body {
margin: auto;
}
</style>
</head>
<body>
<div class="pure-g">
<div class="pure-u-lg-1-6"></div>
<div class="pure-u-lg-2-3 pure-u-1-1">
<div class="header">
<h1>Dask Clusters</h1>
<p>
Currently running dask clusters. Click the cluster name to take you
to the cluster's dashboard.
</p>
</div>
<table id="clusters" class="pure-table pure-table-horizontal">
<thead>
<tr>
<th class="stop-header">Stop</th>
<th class="cluster-header">Cluster</th>
<th class="workers-header">Workers</th>
<th class="cores-header">Cores</th>
<th class="memory-header">Memory</th>
<th class="started-header">Started</th>
</tr>
</thead>
<tbody id="clusters-body"></tbody>
</table>
</div>
</div>
<script>
async function stopCluster(clusterName) {
var baseURL = document.location.href;
// trailing slash
if (baseURL[baseURL.length - 1] !== "/") {
baseURL += "/";
}
r = await fetch(baseURL + `clusters/${clusterName}`, {
method: "DELETE",
});
document.location.reload();
}
function clusterRow(cluster) {
// make a row for a cluster in the table
const tr = document.createElement("tr");
const stopCell = document.createElement("td");
const stopLink = document.createElement("button");
stopLink.classList.add("stop-link");
stopLink.classList.add("pure-button");
stopLink.appendChild(document.createTextNode("🛑"));
stopLink.title = `Stop cluster ${cluster.name}"`;
stopLink.onclick = function () {
stopCluster(cluster.name);
};
stopCell.appendChild(stopLink);
tr.appendChild(stopCell);
const clusterCell = document.createElement("td");
clusterCell.classList.add("cluster-link");
const clusterLink = document.createElement("a");
clusterLink.href = cluster.dashboard_link;
clusterLink.title = "Connect to cluster dashboard";
const clusterName = document.createTextNode(cluster.name);
clusterLink.appendChild(clusterName);
clusterCell.appendChild(clusterLink);
clusterCell.appendChild(
document.createTextNode(` (${cluster.status.toLowerCase()})`),
);
tr.appendChild(clusterCell);
const workerCell = document.createElement("td");
workerCell.appendChild(document.createTextNode(cluster.workers));
tr.appendChild(workerCell);
const coreCell = document.createElement("td");
coreCell.appendChild(document.createTextNode(cluster.cores));
tr.appendChild(coreCell);
const memoryCell = document.createElement("td");
memoryCell.appendChild(document.createTextNode(cluster.memory));
tr.appendChild(memoryCell);
const startedCell = document.createElement("td");
const started = new Date(cluster.started * 1e3);
startedCell.appendChild(
document.createTextNode(
started.toLocaleString(navigator.language || "en"),
),
);
tr.appendChild(startedCell);
return tr;
}
async function updateClusters() {
/* fetch clusters and update the cluster table
*/
var baseURL = document.location.href;
// trailing slash
if (baseURL[baseURL.length - 1] !== "/") {
baseURL += "/";
}
r = await fetch(baseURL + "clusters");
clusters = await r.json();
window.clusters = clusters;
const clusterBody = document.getElementById("clusters-body");
clusterBody.innerHTML = "";
for (cluster of clusters) {
var tr = clusterRow(cluster);
clusterBody.appendChild(tr);
}
}
updateClusters();
</script>
</body>
</html>