Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 8 additions & 13 deletions src-tauri/src/heartbeat.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
use tokio::time::{self, Duration};
use beiboot_desktop::connection::ConnectError;

pub async fn establish_heartbeat_connection(cluster_id: &str, token: &str) -> Result<(), ConnectError> {
let mut interval = time::interval(Duration::from_secs(250));
loop {
let resp = reqwest::Client::new()
.post(format!("https://api.getdeck.dev/clusters/{}/heartbeat", cluster_id).as_str())
.header(reqwest::header::AUTHORIZATION, format!("Bearer {}", token))
.send()
.await
.expect("Failed to send");
println!("Heartbeat status: {}", resp.status());
interval.tick().await;
}
pub async fn establish_heartbeat_connection(cluster_id: &str, token: &str) -> Result<String, ConnectError> {
let resp = reqwest::Client::new()
.post(format!("https://api.getdeck.dev/clusters/{}/heartbeat", cluster_id).as_str())
.header(reqwest::header::AUTHORIZATION, format!("Bearer {}", token))
.send()
.await
.expect("Failed to send");
Ok(format!("Heartbeat status: {}", resp.status()))
}

22 changes: 20 additions & 2 deletions src/components/ClusterTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<tr>
<th>Name</th>
<th>State</th>
<th>Sunset</th>
<th>Lifetime/Timeout</th>
<th>Actions</th>
</tr>
</thead>
Expand All @@ -16,6 +18,8 @@
{{ cluster.state }}
</v-chip>
</td>
<td>{{ getClusterSunset(cluster.sunset) }}</td>
<td>{{ cluster.max_lifetime.value }} / {{ cluster.max_session_timeout.value }}</td>
<td>
<v-tooltip text="Connect">
<template v-slot:activator="{ props }">
Expand Down Expand Up @@ -92,7 +96,6 @@ const getChipColor = (state: string) => {
const getClusterList = () => {
ClustersService.clusterListClustersGet().then((res) => {
clusterList.value = res.items;
console.log(res.items);
});
};

Expand Down Expand Up @@ -137,6 +140,7 @@ const clusterDisconnect = (clusterName: string) => {
store.connection.clusterName = "";
store.connection.kubeconfigPath = "";
store.connection.connected = false;
store.connection.clusterId = "";
}).catch((err) => {
console.log(err);
});
Expand All @@ -158,7 +162,21 @@ onMounted(() => {
getClusterList();
setInterval(() => {
getClusterList();
checkRunningConnects().then((res) => console.log(res));
checkRunningConnects();
if (store.connection.clusterId) {
invoke("establish_heartbeat_connection", {
clusterId: store.connection.clusterId,
// @ts-ignore
token: store.auth.token
}).catch(err => console.error(err));

}
}, 5000);
});

const getClusterSunset = (sunset: string) => {
if (sunset) {
return new Date(`${sunset}Z`).toLocaleTimeString()
}
};
</script>