Created
May 11, 2021 14:10
-
-
Save jmacqueen/aca9e0fe682f128138899d4d79a104e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const command = `/usr/local/bin/docker ps --format '{{.Names}}\t{{.Ports}}'` | |
export const refreshFrequency = 5000 // ms | |
export const render = ({ output }) => { | |
if (!output) return <h3>Docker daemon not responding</h3> | |
const lines = output.split("\n") | |
function tableRow(line) { | |
const splitLine = line.split(/\t/) | |
return ( | |
<tr> | |
<td>{splitLine[0]}</td> | |
<td>{splitLine[1]}</td> | |
</tr> | |
) | |
} | |
return ( | |
<table> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Ports</th> | |
</tr> | |
</thead> | |
<tbody> | |
{lines.filter(l => l).sort().map(tableRow)} | |
</tbody> | |
</table> | |
) | |
} | |
export const className = ` | |
background-color: rgba(0, 0, 0, 0.5); | |
padding: 0.5rem; | |
color: #fff; | |
font-family: monospace ; | |
th { | |
font-size: 1rem; | |
} | |
td { | |
border-bottom: 1px solid rgba(0,0,0,0.5); | |
padding: 0.25rem 0.5rem; | |
} | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment