Skip to content

Commit

Permalink
feat(dashboard): add 'more info' pane to stack graph
Browse files Browse the repository at this point in the history
  • Loading branch information
benstov committed Apr 25, 2019
1 parent 4552fba commit bee72e6
Show file tree
Hide file tree
Showing 31 changed files with 1,485 additions and 120 deletions.
5 changes: 5 additions & 0 deletions dashboard/package-lock.json

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

1 change: 1 addition & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"dagre-d3": "^0.6.1",
"emotion": "^10.0.0",
"flexboxgrid": "^6.3.1",
"flexboxgrid-helpers": "^1.1.3",
"http-proxy-middleware": "^0.19.1",
"lodash": "^4.17.11",
"node-sass": "^4.10.0",
Expand Down
Binary file modified dashboard/public/favicon.ico
Binary file not shown.
12 changes: 12 additions & 0 deletions dashboard/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ import {
FetchLogsResponse,
ApiRequest,
FetchGraphResponse,
FetchTaskResultResponse,
FetchTestResultResponse,
} from "./types"

export type FetchLogsParam = string[]
export type FetchTaskResultParam = { name: string }
export type FetchTestResultParam = { name: string, module: string }

const MAX_LOG_LINES = 5000

Expand All @@ -32,6 +36,14 @@ export async function fetchStatus(): Promise<FetchStatusResponse> {
return apiPost<FetchStatusResponse>("get.status")
}

export async function fetchTaskResult(params: FetchTaskResultParam): Promise<FetchTaskResultResponse> {
return apiPost<FetchTaskResultResponse>("get.task-result", params)
}

export async function fetchTestResult(params: FetchTestResultParam): Promise<FetchTestResultResponse> {
return apiPost<FetchTestResultResponse>("get.test-result", params)
}

export async function fetchLogs(services: FetchLogsParam): Promise<FetchLogsResponse> {
const tail = Math.floor(MAX_LOG_LINES / services.length)
return apiPost<FetchLogsResponse>("logs", { services, tail })
Expand Down
36 changes: 32 additions & 4 deletions dashboard/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

export type Primitive = string | number | boolean

export interface PrimitiveMap { [key: string]: Primitive }
export interface PrimitiveMap {
[key: string]: Primitive
}

export interface DashboardPage {
title: string
Expand Down Expand Up @@ -58,7 +60,7 @@ export interface ServiceStatus {
version?: string
state?: string
runningReplicas?: number
ingresses?: ServiceIngress[],
ingresses?: ServiceIngress[]
lastMessage?: string
lastError?: string
createdAt?: string
Expand Down Expand Up @@ -91,9 +93,18 @@ export type RenderedNode = {
moduleName: string,
}

export type RenderedNodeType = "build" | "deploy" | "run" | "test" | "push" | "publish"
export type RenderedNodeType =
| "build"
| "deploy"
| "run"
| "test"
| "push"
| "publish"

export type RenderedEdge = { dependant: RenderedNode, dependency: RenderedNode }
export type RenderedEdge = {
dependant: RenderedNode,
dependency: RenderedNode,
}

export interface FetchGraphResponse {
nodes: RenderedNode[],
Expand Down Expand Up @@ -127,3 +138,20 @@ export interface WsMessage {
name: NodeTask | "taskGraphProcessing" | "taskGraphComplete"
payload: WsPayload
}

export interface FetchTaskResultResponse {
name: string
module: string
version: string
output: string
startedAt: Date
completedAt: Date
}
export interface FetchTestResultResponse {
name: string
version: string
output: string
module: string
startedAt: Date
completedAt: Date
}
27 changes: 19 additions & 8 deletions dashboard/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@ import Provider from "./components/provider"
import { colors } from "./styles/variables"
import "flexboxgrid/dist/flexboxgrid.min.css"
import "./styles/padding-margin-mixin.scss"
import "./styles/custom-flexboxgrid.scss"
import "./styles/icons.scss"

import { EventProvider } from "./context/events"
import { DataProvider } from "./context/data"
import { NavLink } from "./components/links"

import logo from "./assets/logo.png"
import { ReactComponent as Hamburger } from "./assets/hamburger.svg"
import { ReactComponent as OpenSidebarIcon } from "./assets/open-pane.svg"
import { ReactComponent as CloseSidebarIcon } from "./assets/close-pane.svg"

import { UiStateProvider, UiStateContext } from "./context/ui"

// Style and align properly
const Logo = styled.img`
width: 10rem;
height: auto;
width: 100%;
max-width: 10rem;
margin-top: .7rem;
`

const SidebarWrapper = styled.div`
Expand All @@ -43,13 +48,14 @@ const SidebarWrapper = styled.div`
position: relative;
`
const SidebarContainer = styled.div`
display: ${props => (props.visible ? `block` : "none")}
width: ${props => (props.visible ? `19rem` : "0")}
display: ${props => (props.visible ? `block` : "none")};
width: ${props => (props.visible ? `12rem` : "0")};
`

const SidebarToggleButton = styled.div`
position: absolute;
right: -2.5rem;
top: 1rem;
right: -2.2rem;
top: 3rem;
width: 1.5rem;
cursor: pointer;
`
Expand Down Expand Up @@ -81,11 +87,16 @@ const App = () => {
height: 100vh;
max-height: 100vh;
overflow-y: hidden;
background: ${colors.gardenGrayLighter};
`}
>
<SidebarWrapper>
<SidebarToggleButton onClick={toggleSidebar}>
<Hamburger width="24px" />
{isSidebarOpen ? (
<CloseSidebarIcon />
) : (
<OpenSidebarIcon />
)}
</SidebarToggleButton>
<SidebarContainer visible={isSidebarOpen}>
<div className={"ml-1"}>
Expand All @@ -111,7 +122,7 @@ const App = () => {
flex-grow: 1;
`,
"pl-3",
"pt-4",
"pt-2",
"pr-1",
)}
>
Expand Down
4 changes: 4 additions & 0 deletions dashboard/src/assets/close-pane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions dashboard/src/assets/open-pane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions dashboard/src/components/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import { colors, fontMedium } from "../styles/variables"

interface CardProps {
children: JSX.Element
title?: string
title?: string,
backgroundColor?: string
}

const Wrapper = styled.div`
background-color: ${colors.gardenWhite};
background-color: ${props => props.backgroundColor || colors.gardenWhite};
border-radius: 2px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
width: 100%;
overflow: hidden;
`

export const CardTitle = styled.h3`
Expand All @@ -28,16 +31,16 @@ export const CardTitle = styled.h3`
margin: 0;
`

const Card: React.SFC<CardProps> = ({ children, title }) => {
const Card: React.SFC<CardProps> = ({ children, title, backgroundColor }) => {
const titleEl = title
? (
<div className="pl-1 pr-1 pb-1">
<div className="p-1">
<CardTitle>{title}</CardTitle>
</div>
)
: null
return (
<Wrapper className="pt-1 mb-2">
<Wrapper className="mb-2" backgroundColor={backgroundColor}>
{titleEl}
{children}
</Wrapper>
Expand Down
16 changes: 5 additions & 11 deletions dashboard/src/components/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ const Label = styled.label`
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 1.1rem;
user-select: none;
:hover {
input, span {
background-color: ${colors.gray};
}
}
margin-bottom: 1rem;
`

const Input = styled.input`
Expand All @@ -39,8 +34,8 @@ const Input = styled.input`

const Checkmark = styled.span`
position: absolute;
top: 0;
left: 0;
top: 0rem;
left: 0rem;
height: 21px;
width: 21px;
border: 1px solid ${colors.gardenGrayLight};
Expand Down Expand Up @@ -68,16 +63,15 @@ const CheckmarkChecked = styled(Checkmark)`

interface Props {
name: string
label: string
checked?: boolean
onChange: (event: ChangeEvent<HTMLInputElement>) => void
}

const CheckBox: React.SFC<Props> = ({ name, label, onChange, checked = false }) => {
const CheckBox: React.SFC<Props> = ({ name, onChange, checked = false, children }) => {
const Mark = checked ? CheckmarkChecked : Checkmark
return (
<Label>
{label}
{children}
<Input type={"checkbox"} name={name} checked={checked} onChange={onChange} />
<Mark />
</Label>
Expand Down
41 changes: 26 additions & 15 deletions dashboard/src/components/graph/graph.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,44 @@
stroke: red;
}

text {
font-weight: 700;
font-size: 1em;
}

.node rect {
fill: #fff;
stroke: #02f2b4;
stroke-width: 2.5px;
}

.edgePath path {
stroke: rgba(0,0,0,0.32);
stroke: rgba(0, 0, 0, 0.32);
stroke-width: 1.5px;
}

div.label-wrap {
text-align: center;
.label-container {
cursor: pointer;
}

.label-container {
cursor: pointer;
}

span.name {
font-weight: 700;
font-size: 0.9rem;
div.node-container {
text-align: center;
padding: 1rem;
background-repeat: no-repeat;
background-position: left;
background-position-x: -0.5rem;
background-size: 4rem;
&--run,
&--test {
cursor: pointer;
}
span.type {
display: inline-block;
margin-top: 0.5em
.type {
color: gray;
padding-bottom: 0.2rem;
}
}

.module-name {
color: #343434;
font-weight: bold;
}
}
}
Loading

0 comments on commit bee72e6

Please sign in to comment.