Skip to content

Commit

Permalink
Deployment info page
Browse files Browse the repository at this point in the history
  • Loading branch information
relferreira committed Feb 11, 2019
1 parent 821c82a commit 44719aa
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 10 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ func main() {
c.JSON(200, deployments)
})

r.GET("/api/:namespace/deployments/:name", func(c *gin.Context) {
namespace := c.Param("namespace")
name := c.Param("name")

deployment, err := clientset.AppsV1beta2().Deployments(namespace).Get(name, metav1.GetOptions{})
if err != nil {
panic(err.Error())
}

c.JSON(200, deployment)
})

r.GET("/api/:namespace/pods", func(c *gin.Context) {
namespace := c.Param("namespace")

Expand Down
13 changes: 11 additions & 2 deletions ui/components/DeployCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,25 @@ import PropTypes from 'prop-types';
import styled from '@emotion/styled';

import GridCard from './GridCard';
import { Link } from '@reach/router';

const DeployReplicas = styled.span`
font-size: 25px;
margin-right: 16px;
`;

const DeployLink = styled(Link)`
width: 100%;
color: inherit;
text-decoration: none;
`;

const DeployCard = ({ replicas, name }) => (
<GridCard>
<DeployReplicas>{replicas}</DeployReplicas>
<span>{name}</span>
<DeployLink to={`${name}/info`}>
<DeployReplicas>{replicas}</DeployReplicas>
<span>{name}</span>
</DeployLink>
</GridCard>
);

Expand Down
8 changes: 0 additions & 8 deletions ui/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ const NavLink = styled(CustomLink)`
font-size: 18px;
cursor: pointer;
&:hover {
text-decoration: underline;
}
&.active {
font-weight: bold;
color: ${primaryDark};
Expand All @@ -64,10 +60,6 @@ const ThemeLink = styled.a`
text-decoration: none;
font-size: 18px;
cursor: pointer;
&:hover {
text-decoration: underline;
}
`;

const HistoryLink = styled(NavLink)`
Expand Down
2 changes: 2 additions & 0 deletions ui/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import Deployments from './Deployments';
import Services from './Services';
import ServiceInfo from './ServiceInfo';
import DeploymentInfo from './DeploymentInfo';

const lightTheme = {
name: 'light',
Expand Down Expand Up @@ -106,6 +107,7 @@ function App() {
<Services path="/:namespace/services" />
<ServiceInfo path="/:namespace/services/:name/info" />
<Deployments path="/:namespace/deployments" />
<DeploymentInfo path="/:namespace/deployments/:name/info" />
<Pods path="/:namespace/pods" />
<PodInfo path="/:namespace/pods/:name/info" />
<Logs
Expand Down
39 changes: 39 additions & 0 deletions ui/containers/DeploymentInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { getDeployment } from '../state-management/deployments-management';
import Table from '../components/Table';

export default function DeploymentInfo({ namespace, name }) {
const { response, loading } = getDeployment(namespace, name);

if (loading) return <div>Loading...</div>;

if (!response) return null;

const {
data: { metadata, spec, status }
} = response || {};

return (
<div>
<h1>{metadata.name}</h1>

<h3>Status</h3>
<Table>
<thead>
<tr>
<th>Replicas</th>
<th>Available Replicas</th>
<th>Updated Replicas</th>
</tr>
</thead>
<tbody>
<tr>
<td>{status.replicas}</td>
<td>{status.availableReplicas}</td>
<td>{status.updatedReplicas}</td>
</tr>
</tbody>
</Table>
</div>
);
}
7 changes: 7 additions & 0 deletions ui/state-management/deployments-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ export const listDeployments = namespace =>
method: 'GET',
trigger: namespace
});

export const getDeployment = (namespace, name) =>
useAxios({
url: `${process.env.API}/${namespace}/deployments/${name}`,
method: 'GET',
trigger: namespace
});

0 comments on commit 44719aa

Please sign in to comment.