Files
redash/client/app/components/admin/StatusBlock.jsx
Arik Fraimovich 56d3be2248 Prettier all the Javascript code & GitHub Action (#4433)
* Prettier all the JS files

* Add GitHub Action to autoformat code pushed to master

* Fix eslint violation due to formatting.

* Remove GitHub actions for styling

* Add restyled.io config
2019-12-11 17:05:38 +02:00

100 lines
2.6 KiB
JavaScript

/* eslint-disable react/prop-types */
import { toPairs } from "lodash";
import React from "react";
import List from "antd/lib/list";
import Card from "antd/lib/card";
import { TimeAgo } from "@/components/TimeAgo";
import { toHuman, prettySize } from "@/filters";
export function General({ info }) {
info = toPairs(info);
return (
<Card title="General" size="small">
{info.length === 0 && <div className="text-muted text-center">No data</div>}
{info.length > 0 && (
<List
size="small"
itemLayout="vertical"
dataSource={info}
renderItem={([name, value]) => (
<List.Item extra={<span className="badge">{value}</span>}>{toHuman(name)}</List.Item>
)}
/>
)}
</Card>
);
}
export function DatabaseMetrics({ info }) {
return (
<Card title="Redash Database" size="small">
{info.length === 0 && <div className="text-muted text-center">No data</div>}
{info.length > 0 && (
<List
size="small"
itemLayout="vertical"
dataSource={info}
renderItem={([name, size]) => (
<List.Item extra={<span className="badge">{prettySize(size)}</span>}>{name}</List.Item>
)}
/>
)}
</Card>
);
}
export function Queues({ info }) {
info = toPairs(info);
return (
<Card title="Queues" size="small">
{info.length === 0 && <div className="text-muted text-center">No data</div>}
{info.length > 0 && (
<List
size="small"
itemLayout="vertical"
dataSource={info}
renderItem={([name, queue]) => (
<List.Item extra={<span className="badge">{queue.size}</span>}>{name}</List.Item>
)}
/>
)}
</Card>
);
}
export function Manager({ info }) {
const items = info
? [
<List.Item
extra={
<span className="badge">
<TimeAgo date={info.lastRefreshAt} placeholder="n/a" />
</span>
}>
Last Refresh
</List.Item>,
<List.Item
extra={
<span className="badge">
<TimeAgo date={info.startedAt} placeholder="n/a" />
</span>
}>
Started
</List.Item>,
<List.Item extra={<span className="badge">{info.outdatedQueriesCount}</span>}>
Outdated Queries Count
</List.Item>,
]
: [];
return (
<Card title="Manager" size="small">
{!info && <div className="text-muted text-center">No data</div>}
{info && <List size="small" itemLayout="vertical" dataSource={items} renderItem={item => item} />}
</Card>
);
}