forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create generalized TableLikeComparison, add table-by-table comp
- Loading branch information
Showing
7 changed files
with
177 additions
and
170 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
87 changes: 10 additions & 77 deletions
87
frontend/src/metabase/xray/containers/SegmentComparison.jsx
This file contains 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
77 changes: 10 additions & 67 deletions
77
frontend/src/metabase/xray/containers/SegmentTableComparison.jsx
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { Component } from 'react' | ||
import { connect } from 'react-redux' | ||
|
||
import TableLikeComparison from "metabase/xray/containers/TableLikeComparison"; | ||
import title from 'metabase/hoc/Title' | ||
|
||
import { fetchTableComparison } from 'metabase/xray/xray' | ||
import { getTitle } from 'metabase/xray/selectors' | ||
|
||
const mapDispatchToProps = { | ||
fetchTableComparison | ||
} | ||
|
||
@connect(null, mapDispatchToProps) | ||
@title(props => getTitle(props)) | ||
class TableComparison extends Component { | ||
render () { | ||
const { cost, tableId1, tableId2 } = this.props.params | ||
|
||
return ( | ||
<TableLikeComparison | ||
cost={cost} | ||
fetchTableLikeComparison={ | ||
() => this.props.fetchTableComparison(tableId1, tableId2, cost) | ||
} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
export default TableComparison | ||
|
92 changes: 92 additions & 0 deletions
92
frontend/src/metabase/xray/containers/TableLikeComparison.jsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import React, { Component } from 'react' | ||
import { connect } from 'react-redux' | ||
import _ from 'underscore' | ||
|
||
import { initialize } from 'metabase/xray/xray' | ||
import { | ||
getComparison, | ||
getComparisonFields, | ||
getComparisonContributors, | ||
getModelItem, | ||
getLoadingStatus, | ||
getError | ||
} from 'metabase/xray/selectors' | ||
|
||
import LoadingAndErrorWrapper from 'metabase/components/LoadingAndErrorWrapper' | ||
import XRayComparison from 'metabase/xray/components/XRayComparison' | ||
import LoadingAnimation from 'metabase/xray/components/LoadingAnimation' | ||
|
||
import { hasComparison, comparisonLoadingMessages } from 'metabase/xray/utils' | ||
|
||
const mapStateToProps = (state) => ({ | ||
comparison: getComparison(state), | ||
fields: getComparisonFields(state), | ||
contributors: getComparisonContributors(state), | ||
itemA: getModelItem(state, 0), | ||
itemB: getModelItem(state, 1), | ||
isLoading: getLoadingStatus(state), | ||
error: getError(state) | ||
}) | ||
|
||
const mapDispatchToProps = { | ||
initialize | ||
} | ||
|
||
@connect(mapStateToProps, mapDispatchToProps) | ||
class TableLikeComparison extends Component { | ||
|
||
componentWillMount () { | ||
this.props.initialize() | ||
this.props.fetchTableLikeComparison() | ||
} | ||
|
||
componentWillUnmount() { | ||
// HACK Atte Keinänen 9/20/17: We need this for now because the structure of `state.xray.xray` isn't same | ||
// for all xray types and if switching to different kind of xray (= rendering different React container) | ||
// without resetting the state fails because `state.xray.xray` subproperty lookups fail | ||
this.props.initialize(); | ||
} | ||
|
||
render () { | ||
const { | ||
comparison, | ||
contributors, | ||
error, | ||
fields, | ||
isLoading, | ||
itemA, | ||
itemB, | ||
cost | ||
} = this.props | ||
|
||
return ( | ||
<LoadingAndErrorWrapper | ||
loading={isLoading || !hasComparison(comparison)} | ||
error={error} | ||
noBackground | ||
loadingMessages={comparisonLoadingMessages} | ||
loadingScenes={[<LoadingAnimation />]} | ||
> | ||
{ () => | ||
|
||
<XRayComparison | ||
cost={cost} | ||
fields={_.sortBy(fields, 'distance').reverse()} | ||
comparisonFields={[ | ||
'Difference', | ||
'Entropy', | ||
'Histogram', | ||
'Nil%', | ||
]} | ||
contributors={contributors} | ||
comparison={comparison.comparison} | ||
itemA={itemA} | ||
itemB={itemB} | ||
/> | ||
} | ||
</LoadingAndErrorWrapper> | ||
) | ||
} | ||
} | ||
|
||
export default TableLikeComparison |
Oops, something went wrong.