Skip to content

Commit

Permalink
Merge pull request #351 from zalando-stups/346-plot-violations-per-app
Browse files Browse the repository at this point in the history
#346 plot violations per app and violation type
  • Loading branch information
prayerslayer committed Nov 3, 2015
2 parents ae0f0d0 + 1d3c83f commit c32fb3d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
6 changes: 4 additions & 2 deletions client/lib/violation/src/violation-list/violation-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class ViolationList extends React.Component {
</Tabs.TabList>
<Tabs.TabPanel>
<ViolationAnalysis
groupByAccount={searchParams.cross && searchParams.cross.groupByAccount}
groupByAccount={searchParams.cross ? searchParams.cross.groupByAccount : true}
account={searchParams.cross ? searchParams.cross.inspectedAccount : activeAccountIds[0]}
violationType={searchParams.cross ? searchParams.cross.violationType : null}
accounts={allAccounts}
Expand All @@ -247,7 +247,9 @@ class ViolationList extends React.Component {
onConfigurationChange={this._updateSearch.bind(this, 'single')}
account={searchParams.cross ? searchParams.cross.inspectedAccount : activeAccountIds[0]}
accounts={allAccounts}
application={searchParams.inspectedApplication}
groupByApplication={searchParams.single ? searchParams.single.groupByApplication : true}
application={searchParams.single ? searchParams.single.application : ''}
violationType={searchParams.single ? searchParams.single.violationType : ''}
violationTypes={violationTypes}
violationCount={this.stores.fullstop.getViolationCountIn(searchParams.cross ? searchParams.cross.inspectedAccount : activeAccountIds[0])} />
</Tabs.TabPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ class ViolationOverviewAccount extends React.Component {
super();
}

_selectViolationType(type) {
this.props.onConfigurationChange({
groupByApplication: false,
violationType: type
});
}

_selectApp(app) {
this.props.onConfigurationChange({
groupByApplication: true,
application: app
});
}
Expand All @@ -33,16 +41,25 @@ class ViolationOverviewAccount extends React.Component {
yScale = d3.scale.linear()
.domain([0, maxQuantity])
.range([225, 0])
.nice();
.nice(),
chartData = this.props.groupByApplication ?
violationCount.filter(v => v.application === this.props.application) :
violationCount.filter(v => v.type === this.props.violationType),
subject = this.props.groupByApplication ?
<strong>App {this.props.application}</strong> :
<strong>Violation {this.props.violationType}</strong>;
if (violationCount.length) {
return <div className='violation-account-overview'>
<strong>Account {this.props.accounts[this.props.account].name} {this.props.application || ''}</strong>
<span>Account {this.props.accounts[this.props.account].name} / {subject}</span>
<AutoWidth className='violation-account-overview-chart'>
<Charts.BarChart
data={{
label: 'Violation Count',
values: _.sortByOrder(violationCount, ['quantity'], ['desc'])
.map(c => ({ x: c.type, y: c.quantity }))
values: _.sortByOrder(chartData, ['quantity'], ['desc'])
.map(c => ({
x: this.props.groupByApplication ? c.type : c.application || '',
y: c.quantity
}))
}}
tooltipHtml={(x, y0, y) => y.toString()}
tooltipMode='element'
Expand All @@ -60,7 +77,7 @@ class ViolationOverviewAccount extends React.Component {
<Table.Column
label='Application'
width={200}
cellRenderer={c => <span onClick={this._selectApp.bind(this, c)} title={c}>{c}</span>}
cellRenderer={c => <span className='sortable-table-highlight' onClick={this._selectApp.bind(this, c)} title={c}>{c}</span>}
dataKey='application' />
<Table.Column
label='Version'
Expand All @@ -71,7 +88,7 @@ class ViolationOverviewAccount extends React.Component {
label='Violation Type'
width={200}
flexGrow={3}
cellRenderer={c => <span title={c}>{c}</span>}
cellRenderer={c => <span className='sortable-table-highlight' onClick={this._selectViolationType.bind(this, c)} title={c}>{c}</span>}
dataKey='type' />
<Table.Column
label='Severity'
Expand All @@ -94,6 +111,8 @@ class ViolationOverviewAccount extends React.Component {
}
ViolationOverviewAccount.displayName = 'ViolationOverviewAccount';
ViolationOverviewAccount.propTypes = {
groupByApplication: React.PropTypes.bool,
violationType: React.PropTypes.string,
account: React.PropTypes.string,
accounts: React.PropTypes.array,
application: React.PropTypes.string,
Expand Down

0 comments on commit c32fb3d

Please sign in to comment.