Skip to content

Commit

Permalink
FE fix cluster ping request, BE fix dto attr
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Jan 16, 2024
1 parent 16822a3 commit deb9dae
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ResponseEntity<ApiResponse> updateCluster(@RequestBody UpdateClusterDto u
@PostMapping("/ping")
public ResponseEntity<ApiResponse> pingCluster(@RequestBody PingClusterDto pingClusterDto) {

ClusterPingResponse resp = clusterService.pingCluster(pingClusterDto.getId());
ClusterPingResponse resp = clusterService.pingCluster(Integer.parseInt(pingClusterDto.getId()));
return new ResponseEntity<ApiResponse>(new ApiResponse(resp.getIsAccessible(), resp.getMessage()), HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
@ToString
public class PingClusterDto {

private Integer id;
private String id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
<td>{{ cluster.id }}</td>
<td>{{ cluster.url }}</td>
<td>{{ cluster.port }}</td>
<td :style="{ color: getStatusColor(cluster.status) }">{{ cluster.status }}</td>
<td :style="{ color: getStatusColor(cluster.status) }">
{{ cluster.status }}
</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -60,23 +62,39 @@ export default {
// Add the "Test Cluster" method
async pingCluster() {
try {
const response = await axios.get(`http://localhost:9999/cluster/ping`);
this.clusterStatus = response.data;
console.log("Test Cluster Response:", response.data);
// Handle the response as needed
swal({
text: "Cluster Connection Status : " + this.clusterStatus.status,
icon: "success",
closeOnClickOutside: false,
});
} catch (error) {
console.error(error);
}
const toPingCluster = {
id: this.$route.params.id,
};
await axios({
method: "post",
url: "http://localhost:9999/cluster/ping",
data: JSON.stringify(toPingCluster),
headers: {
"Content-Type": "application/json",
},
})
.then((res) => {
console.log("Test Cluster Response:", res.data);
if (res.data.success) {
swal({
text: "Cluster Connection Status: Connected",
icon: "success",
closeOnClickOutside: false,
});
} else {
swal({
text: "Cluster Connection Status: Not Connected",
icon: "error",
closeOnClickOutside: false,
});
}
})
.catch((err) => console.log(err));
},
getStatusColor(status) {
// Add logic to determine color based on status
return status === 'connected' ? 'green' : 'red';
return status === "connected" ? "green" : "red";
},
},
mounted() {
Expand Down

0 comments on commit deb9dae

Please sign in to comment.