Implement endpoints section (#246)

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala authored and GitHub committed 2020-04-13 18:20:19 +03:00
1 parent bd1b8069fd
commit f12b2b6a99
15 files changed
+522 -1

No files matched your search

@@ -0,0 +1,49 @@
import { KubeObject } from "../../api/kube-object";
import { observer } from "mobx-react";
import React from "react";
import { Table, TableHead, TableCell, TableRow } from "../table";
import { prevDefault } from "../../utils";
import { showDetails } from "../../navigation";
import { Trans } from "@lingui/macro";
import { endpointStore } from "../+network-endpoints/endpoints.store";
import { Spinner } from "../spinner";
interface Props {
endpoint: KubeObject;
}
@observer
export class ServiceDetailsEndpoint extends React.Component<Props> {
render() {
const { endpoint } = this.props
if (!endpoint && !endpointStore.isLoaded) return (
<div className="PodDetailsList flex justify-center"><Spinner/></div>
);
if (!endpoint) {
return null
}
return (
<div className="EndpointList flex column">
<Table
selectable
virtual={false}
scrollable={false}
className="box grow"
>
<TableHead>
<TableCell className="name" ><Trans>Name</Trans></TableCell>
<TableCell className="endpoints"><Trans>Endpoints</Trans></TableCell>
</TableHead>
<TableRow
key={endpoint.getId()}
nowrap
onClick={prevDefault(() => showDetails(endpoint.selfLink, false))}
>
<TableCell className="name">{endpoint.getName()}</TableCell>
<TableCell className="endpoints">{ endpoint.toString()}</TableCell>
</TableRow>
</Table>
</div>
)
}
}
@@ -1,2 +1,9 @@
.ServicesDetails {
.EndpointList{
.TableCell {
&.endpoints {
flex-grow: 3;
}
}
}
}
@@ -7,21 +7,31 @@ import { DrawerItem, DrawerTitle } from "../drawer";
import { Badge } from "../badge";
import { KubeEventDetails } from "../+events/kube-event-details";
import { KubeObjectDetailsProps } from "../kube-object";
import { Service, serviceApi } from "../../api/endpoints";
import { Service, serviceApi, endpointApi } from "../../api/endpoints";
import { _i18n } from "../../i18n";
import { apiManager } from "../../api/api-manager";
import { KubeObjectMeta } from "../kube-object/kube-object-meta";
import { ServicePorts } from "./service-ports";
import { endpointStore } from "../+network-endpoints/endpoints.store";
import { ServiceDetailsEndpoint } from "./service-details-endpoint";
interface Props extends KubeObjectDetailsProps<Service> {
}
@observer
export class ServiceDetails extends React.Component<Props> {
componentDidMount() {
if (!endpointStore.isLoaded) {
endpointStore.loadAll();
}
endpointApi.watch()
}
render() {
const { object: service } = this.props;
if (!service) return;
const { spec } = service;
const endpoint = endpointStore.getByName(service.getName(), service.getNs())
return (
<div className="ServicesDetails">
<KubeObjectMeta object={service}/>
@@ -59,6 +69,9 @@ export class ServiceDetails extends React.Component<Props> {
{spec.loadBalancerIP}
</DrawerItem>
)}
<DrawerTitle title={_i18n._(t`Endpoint`)}/>
<ServiceDetailsEndpoint endpoint={endpoint} />
<KubeEventDetails object={service}/>
</div>