mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 20:07:37 -02:30
update dashboard and graph code to aid in automated testing
This commit is contained in:
@@ -155,7 +155,7 @@ function Dashboard({ i18n }) {
|
|||||||
</PageSection>
|
</PageSection>
|
||||||
<MainPageSection>
|
<MainPageSection>
|
||||||
<div className="spacer">
|
<div className="spacer">
|
||||||
<Card>
|
<Card id="dashboard-main-container">
|
||||||
<Tabs
|
<Tabs
|
||||||
aria-label={i18n._(t`Tabs`)}
|
aria-label={i18n._(t`Tabs`)}
|
||||||
activeKey={activeTabId}
|
activeKey={activeTabId}
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import * as d3 from 'd3';
|
import * as d3 from 'd3';
|
||||||
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
class Tooltip {
|
class Tooltip {
|
||||||
constructor(opts) {
|
constructor(opts) {
|
||||||
this.label = opts.label;
|
this.label = opts.label;
|
||||||
this.svg = opts.svg;
|
this.svg = opts.svg;
|
||||||
this.colors = opts.colors;
|
this.colors = opts.colors;
|
||||||
|
this.i18n = opts.i18n;
|
||||||
this.draw();
|
this.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
draw() {
|
draw() {
|
||||||
this.toolTipBase = d3.select(`${this.svg} > svg`).append('g');
|
this.toolTipBase = d3.select(`${this.svg} > svg`).append('g');
|
||||||
this.toolTipBase.attr('id', `svg-chart-Tooltip.base-${this.svg.slice(1)}`);
|
this.toolTipBase.attr('id', 'chart-tooltip');
|
||||||
this.toolTipBase.attr('overflow', 'visible');
|
this.toolTipBase.attr('overflow', 'visible');
|
||||||
this.toolTipBase.style('opacity', 0);
|
this.toolTipBase.style('opacity', 0);
|
||||||
this.toolTipBase.style('pointer-events', 'none');
|
this.toolTipBase.style('pointer-events', 'none');
|
||||||
@@ -54,14 +56,14 @@ class Tooltip {
|
|||||||
.attr('y', 4)
|
.attr('y', 4)
|
||||||
.attr('font-size', 12)
|
.attr('font-size', 12)
|
||||||
.attr('fill', 'white')
|
.attr('fill', 'white')
|
||||||
.text('Successful');
|
.text(this.i18n._(t`Successful`));
|
||||||
this.failText = this.toolTipBase
|
this.failText = this.toolTipBase
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('x', 43)
|
.attr('x', 43)
|
||||||
.attr('y', 28)
|
.attr('y', 28)
|
||||||
.attr('font-size', 12)
|
.attr('font-size', 12)
|
||||||
.attr('fill', 'white')
|
.attr('fill', 'white')
|
||||||
.text('Failed');
|
.text(this.i18n._(t`Failed`));
|
||||||
this.icon = this.toolTipBase
|
this.icon = this.toolTipBase
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('fill', 'white')
|
.attr('fill', 'white')
|
||||||
@@ -77,13 +79,14 @@ class Tooltip {
|
|||||||
.attr('y', -21)
|
.attr('y', -21)
|
||||||
.attr('font-size', 12)
|
.attr('font-size', 12)
|
||||||
.attr('text-anchor', 'end')
|
.attr('text-anchor', 'end')
|
||||||
.text('No Jobs');
|
.text(this.i18n._(t`No Jobs`));
|
||||||
this.successful = this.toolTipBase
|
this.successful = this.toolTipBase
|
||||||
.append('text')
|
.append('text')
|
||||||
.attr('fill', 'white')
|
.attr('fill', 'white')
|
||||||
.attr('font-size', 12)
|
.attr('font-size', 12)
|
||||||
.attr('x', 122)
|
.attr('x', 122)
|
||||||
.attr('y', 4)
|
.attr('y', 4)
|
||||||
|
.attr('id', 'successful-count')
|
||||||
.text('0');
|
.text('0');
|
||||||
this.failed = this.toolTipBase
|
this.failed = this.toolTipBase
|
||||||
.append('text')
|
.append('text')
|
||||||
@@ -91,6 +94,7 @@ class Tooltip {
|
|||||||
.attr('font-size', 12)
|
.attr('font-size', 12)
|
||||||
.attr('x', 122)
|
.attr('x', 122)
|
||||||
.attr('y', 28)
|
.attr('y', 28)
|
||||||
|
.attr('id', 'failed-count')
|
||||||
.text('0');
|
.text('0');
|
||||||
this.date = this.toolTipBase
|
this.date = this.toolTipBase
|
||||||
.append('text')
|
.append('text')
|
||||||
@@ -99,7 +103,7 @@ class Tooltip {
|
|||||||
.attr('x', 20)
|
.attr('x', 20)
|
||||||
.attr('y', -21)
|
.attr('y', -21)
|
||||||
.attr('font-size', 12)
|
.attr('font-size', 12)
|
||||||
.text('Never');
|
.text(this.i18n._(t`Never`));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMouseOver = d => {
|
handleMouseOver = d => {
|
||||||
|
|||||||
@@ -57,14 +57,17 @@ function LineChart({ id, data, height, i18n, pageContext }) {
|
|||||||
.append('svg')
|
.append('svg')
|
||||||
.attr('width', width + margin.left + margin.right)
|
.attr('width', width + margin.left + margin.right)
|
||||||
.attr('height', height + margin.top + margin.bottom)
|
.attr('height', height + margin.top + margin.bottom)
|
||||||
|
// .attr('id', 'foo')
|
||||||
.attr('z', 100)
|
.attr('z', 100)
|
||||||
.append('g')
|
.append('g')
|
||||||
|
.attr('id', 'chart-container')
|
||||||
.attr('transform', `translate(${margin.left}, ${margin.top})`);
|
.attr('transform', `translate(${margin.left}, ${margin.top})`);
|
||||||
// Tooltip
|
// Tooltip
|
||||||
const tooltip = new ChartTooltip({
|
const tooltip = new ChartTooltip({
|
||||||
svg: `#${id}`,
|
svg: `#${id}`,
|
||||||
colors,
|
colors,
|
||||||
label: i18n._(t`Jobs`),
|
label: i18n._(t`Jobs`),
|
||||||
|
i18n,
|
||||||
});
|
});
|
||||||
const parseTime = d3.timeParse('%Y-%m-%d');
|
const parseTime = d3.timeParse('%Y-%m-%d');
|
||||||
|
|
||||||
@@ -216,6 +219,10 @@ function LineChart({ id, data, height, i18n, pageContext }) {
|
|||||||
.attr('stroke-width', 2)
|
.attr('stroke-width', 2)
|
||||||
.attr('d', failLine)
|
.attr('d', failLine)
|
||||||
.call(transition);
|
.call(transition);
|
||||||
|
|
||||||
|
const dateFormat = d3.timeFormat('%-m/%-d');
|
||||||
|
|
||||||
|
// create our successLine circles
|
||||||
svg
|
svg
|
||||||
.selectAll('dot')
|
.selectAll('dot')
|
||||||
.data(formattedData)
|
.data(formattedData)
|
||||||
@@ -226,6 +233,7 @@ function LineChart({ id, data, height, i18n, pageContext }) {
|
|||||||
.style('fill', () => colors(1))
|
.style('fill', () => colors(1))
|
||||||
.attr('cx', d => x(d.DATE))
|
.attr('cx', d => x(d.DATE))
|
||||||
.attr('cy', d => y(d.RAN))
|
.attr('cy', d => y(d.RAN))
|
||||||
|
.attr('id', d => `success-dot-${dateFormat(d.DATE)}`)
|
||||||
.on('mouseover', handleMouseOver)
|
.on('mouseover', handleMouseOver)
|
||||||
.on('mousemove', handleMouseMove)
|
.on('mousemove', handleMouseMove)
|
||||||
.on('mouseout', handleMouseOut);
|
.on('mouseout', handleMouseOut);
|
||||||
@@ -240,6 +248,7 @@ function LineChart({ id, data, height, i18n, pageContext }) {
|
|||||||
.style('fill', () => colors(0))
|
.style('fill', () => colors(0))
|
||||||
.attr('cx', d => x(d.DATE))
|
.attr('cx', d => x(d.DATE))
|
||||||
.attr('cy', d => y(d.FAIL))
|
.attr('cy', d => y(d.FAIL))
|
||||||
|
.attr('id', d => `success-dot-${dateFormat(d.DATE)}`)
|
||||||
.on('mouseover', handleMouseOver)
|
.on('mouseover', handleMouseOver)
|
||||||
.on('mousemove', handleMouseMove)
|
.on('mousemove', handleMouseMove)
|
||||||
.on('mouseout', handleMouseOut);
|
.on('mouseout', handleMouseOut);
|
||||||
|
|||||||
Reference in New Issue
Block a user