forked from confluentinc/demo-scene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetails.html
49 lines (49 loc) · 1.62 KB
/
details.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Topic details</title>
<script>
function getTopic() {
const topicName = new URLSearchParams(window.location.search).get('topic_name');
document.getElementById('topic_name').innerHTML += topicName;
fetch('http://localhost:8090/kafka/v3/clusters')
.then(response => response.json())
.then(({data}) => {
topicUrl = data[0].metadata.self + '/topics/' + topicName;
return fetch(topicUrl);
})
.then(response => response.json())
.then(data => {
document.getElementById('replication_factor').innerHTML += data.replication_factor;
return data.partitions.related;
})
.then(url => fetch(url))
.then(response => response.json())
.then(({data}) => {
document.getElementById('partitions_count').innerHTML += data.length;
})
.catch(error => console.warn(error));
}
function deleteTopic(event) {
event.preventDefault();
fetch(topicUrl, {method: 'delete'})
.then(_ => {
window.location.href = './index.html';
})
.catch(error => console.warn(error));
}
let topicUrl;
window.onload = getTopic;
</script>
</head>
<body>
<ul id="topic">
<li id="topic_name">Topic name: </li>
<li id="partitions_count">Partitions count: </li>
<li id="replication_factor">Replication factor: </li>
</ul>
<br />
<button onclick="deleteTopic(event)">Delete topic</button>
</body>
</html>