Skip to content

Commit

Permalink
improvement(dashboard): render ANSI color in log views
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald authored and eysi09 committed Aug 19, 2020
1 parent 0338145 commit d8aaa60
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 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.

3 changes: 2 additions & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
"@garden-io/core": "^0.12.2",
"ansi_up": "^4.0.4",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"d3": "^5.16.0",
Expand Down Expand Up @@ -64,4 +65,4 @@
"not ie <= 11",
"not op_mini all"
]
}
}
14 changes: 12 additions & 2 deletions dashboard/src/components/page-error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const PageError: React.FC<Props> = ({ error }) => {
<div>
<P>Please look at the terminal logs displayed by the dashboard server for details.</P>
<P color={colors.gardenGray}>
💡 You can get more detailed logs by running the server with <code>--log-level=debug</code>.
<span role="img" aria-label="Tip:">
💡
</span>{" "}
You can get more detailed logs by running the server with <code>--log-level=debug</code>.
</P>
</div>
)
Expand All @@ -46,7 +49,14 @@ const PageError: React.FC<Props> = ({ error }) => {
)}
>
<H3 color={colors.gardenPink}>Whoops, something went wrong.</H3>
{error && error.message && <P>{error.message}</P>}
{error && error.message && (
<P>
<span role="img" aria-label="Error:">
</span>{" "}
{error.message}
</P>
)}
{suggestion}
</div>
)
Expand Down
5 changes: 4 additions & 1 deletion dashboard/src/components/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import styled from "@emotion/styled"
import { padEnd } from "lodash"
import React from "react"
import { default as AnsiUp } from "ansi_up"

import { colors } from "../styles/variables"
import { ServiceLogEntry } from "@garden-io/core/build/src/types/plugin/service/getServiceLogs"
Expand Down Expand Up @@ -40,6 +41,8 @@ const Timestamp = styled.span`
color: ${colors.gardenGrayLight};
`

const ansiUp = new AnsiUp()

const Terminal: React.FC<Props> = ({ entries, sectionPad, showServiceName }) => {
return (
<Term className="p-1">
Expand All @@ -50,7 +53,7 @@ const Terminal: React.FC<Props> = ({ entries, sectionPad, showServiceName }) =>
<P key={idx}>
{service}
<Timestamp>[{e.timestamp}] </Timestamp>
{e.msg}
<span dangerouslySetInnerHTML={{ __html: ansiUp.ansi_to_html(e.msg) }} />
</P>
)
})}
Expand Down

0 comments on commit d8aaa60

Please sign in to comment.