-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#59: Copied base structure, made entry in index for navigation
- Loading branch information
1 parent
d6ac8c0
commit 3ac6407
Showing
12 changed files
with
385 additions
and
0 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
37 changes: 37 additions & 0 deletions
37
ui/src/visualizations/legacy/file-tree-comparison/chart/chart.js
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,37 @@ | ||
'use strict'; | ||
|
||
import React from 'react'; | ||
import * as d3 from 'd3'; | ||
|
||
import styles from '../styles.scss'; | ||
import _ from 'lodash'; | ||
|
||
import StackedAreaChart from '../../../../components/StackedAreaChart'; | ||
import moment from 'moment'; | ||
import chroma from 'chroma-js'; | ||
|
||
export default class Changes extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
} | ||
|
||
render() { | ||
console.log(this.props); | ||
return( | ||
<table className={styles.tableGeneral}> | ||
<thead> | ||
<tr className={styles.headerCommits}> | ||
<td>Commit 1</td> | ||
<td className={styles.tdLine}>Commit 2</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr className={styles.tableContent}> | ||
<td>Test2</td> | ||
<td className={styles.tdLine}>Test3</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
ui/src/visualizations/legacy/file-tree-comparison/chart/index.js
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,18 @@ | ||
'use strict'; | ||
|
||
import { connect } from 'react-redux'; | ||
import Chart from './chart.js'; | ||
|
||
|
||
const mapStateToProps = (state /*, ownProps*/) => { | ||
const corState = state.visualizations.fileTreeComparison.state; | ||
//console.log(corState); | ||
return { | ||
commits: corState.data.data, | ||
|
||
} | ||
; | ||
}; | ||
|
||
|
||
export default connect(mapStateToProps)(Chart); |
48 changes: 48 additions & 0 deletions
48
ui/src/visualizations/legacy/file-tree-comparison/config.js
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,48 @@ | ||
'use strict'; | ||
|
||
import { connect } from 'react-redux'; | ||
import Promise from 'bluebird'; | ||
import Database from '../../../database/database'; | ||
import SearchBox from '../../../components/SearchBox'; | ||
|
||
|
||
const mapStateToProps = (state /*, ownProps*/) => { | ||
const fileTreeState = state; | ||
|
||
return { | ||
fileTreeState, | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch ) => { | ||
return { | ||
//onClickMetric: (metric) => dispatch(setDisplayMetric(metric)), | ||
//onClickCheckboxLegend: (selected) => dispatch(setSelectedAuthors(selected)), | ||
}; | ||
}; | ||
|
||
const ChangesConfigComponent = (props) => { | ||
return ( | ||
<SearchBox | ||
placeholder="Select commit..." | ||
renderOption={(i) => `#${i.iid} ${i.title}`} | ||
search={(text) => { | ||
return Promise.resolve(Database.searchCommits(text)).map((i) => { | ||
i.createdAt = new Date(i.createdAt); | ||
i.closedAt = i.closedAt && new Date(i.closedAt); | ||
return i; | ||
}); | ||
}} | ||
value={props.issue} | ||
onChange={(issue) => { | ||
if (issue !== null) { | ||
props.onSetIssue(issue); | ||
} | ||
}} | ||
/>//TODO search bar | ||
); | ||
}; | ||
|
||
const FileTreeConfig = connect(mapStateToProps, mapDispatchToProps)(ChangesConfigComponent); | ||
|
||
export default FileTreeConfig; |
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,7 @@ | ||
'use strict'; | ||
|
||
import cx from 'classnames'; | ||
|
||
import styles from './styles.scss'; | ||
|
||
export default () => <div className={cx('box', styles.help)}></div>; |
17 changes: 17 additions & 0 deletions
17
ui/src/visualizations/legacy/file-tree-comparison/index.js
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,17 @@ | ||
'use strict'; | ||
|
||
import ChartComponent from './chart'; | ||
import ConfigComponent from './config.js'; | ||
import HelpComponent from './help.js'; | ||
import saga from './sagas'; | ||
import reducer from './reducers'; | ||
|
||
export default { | ||
id: 'fileTreeComparison', | ||
label: 'FileTreeComparison', | ||
saga, | ||
reducer, | ||
ChartComponent, | ||
ConfigComponent, | ||
HelpComponent, | ||
}; |
13 changes: 13 additions & 0 deletions
13
ui/src/visualizations/legacy/file-tree-comparison/reducers/config.js
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,13 @@ | ||
'use strict'; | ||
|
||
import { handleActions } from 'redux-actions'; | ||
import _ from 'lodash'; | ||
|
||
export default handleActions( | ||
{ | ||
|
||
}, | ||
{ | ||
|
||
} | ||
); |
22 changes: 22 additions & 0 deletions
22
ui/src/visualizations/legacy/file-tree-comparison/reducers/data.js
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,22 @@ | ||
'use strict'; | ||
|
||
import { handleActions } from 'redux-actions'; | ||
import _ from 'lodash'; | ||
|
||
export default handleActions( | ||
{ | ||
REQUEST_CHANGES_DATA: (state) => _.assign({}, state, { isFetching: true }), | ||
RECEIVE_CHANGES_DATA: (state, action) => { | ||
return _.assign({}, state, { | ||
data: action.payload, | ||
isFetching: false, | ||
receivedAt: action.meta.receivedAt, | ||
}); | ||
}, | ||
}, | ||
{ | ||
data: {}, | ||
lastFetched: null, | ||
isFetching: null, | ||
} | ||
); |
10 changes: 10 additions & 0 deletions
10
ui/src/visualizations/legacy/file-tree-comparison/reducers/index.js
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,10 @@ | ||
'use strict'; | ||
|
||
import config from './config.js'; | ||
import data from './data.js'; | ||
import { combineReducers } from 'redux'; | ||
|
||
export default combineReducers({ | ||
data, | ||
config, | ||
}); |
97 changes: 97 additions & 0 deletions
97
ui/src/visualizations/legacy/file-tree-comparison/sagas/index.js
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,97 @@ | ||
'use strict'; | ||
|
||
import { fetchFactory, mapSaga, timestampedActionFactory } from '../../../../sagas/utils'; | ||
import { createAction } from 'redux-actions'; | ||
import Database from '../../../../database/database'; | ||
import { graphQl } from '../../../../utils'; | ||
|
||
export const requestCommitsAndFileTree = createAction('REQUEST_COMMITS_AND_FILE_TREE'); | ||
export const receiveCommitsAndFileTree = timestampedActionFactory('RECEIVE_COMMITS_AND_FILE_TREE'); | ||
export const receiveCommitsAndFileTreeError = createAction('RECEIVE_COMMITS_AND_FILE_TREE_ERROR'); | ||
|
||
export default function* () { | ||
// fetch data once on entry | ||
yield* fetchFileTreeEvolutionData(); | ||
} | ||
|
||
export const fetchFileTreeEvolutionData = fetchFactory( | ||
function* () { | ||
|
||
const { firstCommit, lastCommit } = yield Database.getBounds(); //getting first and last commit date | ||
const firstCommitTimestamp = Date.parse(firstCommit.date); | ||
const lastCommitTimestamp = Date.parse(lastCommit.date); | ||
|
||
const commits = yield Database.getCommitData([firstCommitTimestamp, lastCommitTimestamp], [firstCommitTimestamp, lastCommitTimestamp]); //COMMITS | ||
|
||
const fileTree = yield Database.requestFileStructure(); | ||
const hierarchicalFileTree = makeHierarchyFileTree(fileTree); //FILETREE | ||
|
||
|
||
|
||
//console.log(yield Database.searchCommits('Bug')); //search commits | ||
|
||
return { commits, hierarchicalFileTree }; | ||
|
||
return yield graphQl //TODO replace with my query, get changes by certain commit | ||
.query( | ||
`{ | ||
commits(sort: "ASC") { | ||
data { | ||
date | ||
message | ||
files { | ||
data { | ||
stats { | ||
additions | ||
deletions | ||
} | ||
file { | ||
path, | ||
} | ||
lineCount | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
) | ||
.then((resp) => { | ||
const commitsWithFileTree = []; | ||
|
||
for (const commit of resp.commits.data) { | ||
//const fileTree = makeHierarchyFileTreee(commit); | ||
//const commitWithFileTree = [commit, fileTree]; | ||
//commitsWithFileTree.push(commitWithFileTree); | ||
//fileTree = applyCommit(fileTree, commit); | ||
//fileTreeHistory.push(fileTree); | ||
} | ||
return { | ||
commitsWithFileTree, | ||
|
||
//fileTreeHistory, | ||
//commits: resp.commits.data | ||
}; | ||
}); | ||
}, | ||
requestCommitsAndFileTree, //LOGGER | ||
receiveCommitsAndFileTree, | ||
receiveCommitsAndFileTreeError | ||
); | ||
|
||
function makeHierarchyFileTree(fileTree) { | ||
const result = []; | ||
const level = { result }; | ||
|
||
fileTree.files.data.forEach((entry) => { | ||
entry.path.split('/').reduce((r, name) => { | ||
if (!r[name]) { | ||
r[name] = { result: [] }; | ||
r.result.push({ name, children: r[name].result }); | ||
} | ||
|
||
return r[name]; | ||
}, level); | ||
}); | ||
|
||
return result; | ||
} |
Oops, something went wrong.