roughed in ServiceDetail (#107)

This commit is contained in:
Michael Quigley 2022-12-22 15:18:49 -05:00
parent a125c4b40b
commit 0756e48841
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 54 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import EnvironmentDetail from "./EnvironmentDetail";
import AccountDetail from "./AccountDetail";
import ServiceDetail from "./ServiceDetail";
const Detail = (props) => {
let detailComponent = <h1>{props.selection.id} ({props.selection.type})</h1>;
@ -12,6 +13,9 @@ const Detail = (props) => {
case "environment":
detailComponent = <EnvironmentDetail selection={props.selection} />;
break;
case "service":
detailComponent = <ServiceDetail selection={props.selection} />;
}
return (

View File

@ -16,7 +16,6 @@ const EnvironmentDetail = (props) => {
useEffect(() => {
let mounted = true;
let interval = setInterval(() => {
if(mounted) {}
metadata.getEnvironmentDetail(props.selection.id)
.then(resp => {
if(mounted) {

View File

@ -0,0 +1,45 @@
import * as metadata from "../../api/metadata";
import {Sparklines, SparklinesLine, SparklinesSpots} from "react-sparklines";
import {useEffect, useState} from "react";
const ServiceDetail = (props) => {
const [detail, setDetail] = useState({});
useEffect(() => {
metadata.getServiceDetail(props.selection.id)
.then(resp => {
setDetail(resp.data);
});
}, [props.selection]);
useEffect(() => {
let mounted = true;
let interval = setInterval(() => {
metadata.getServiceDetail(props.selection.id)
.then(resp => {
setDetail(resp.data);
});
}, 1000);
return () => {
mounted = false;
clearInterval(interval);
}
}, [props.selection]);
if(detail) {
return (
<div>
<h2>Service: {detail.token}</h2>
<div className={"zrok-big-sparkline"}>
<Sparklines data={detail.metrics} limit={60} height={20}>
<SparklinesLine color={"#3b2693"} />
<SparklinesSpots />
</Sparklines>
</div>
</div>
);
}
return <></>;
}
export default ServiceDetail;

View File

@ -41,6 +41,11 @@ code, pre {
margin-top: 30px;
}
.zrok-big-sparkline {
margin-top: 30px;
padding: 50px;
}
.btn-close {
background: transparent url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3E%3Cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3E%3C/svg%3E") 50%/1em auto no-repeat;
height: 25px;