Skip to content

Commit

Permalink
Merge pull request #25 from KPMP/develop
Browse files Browse the repository at this point in the history
DMD Release 1.2
  • Loading branch information
zwright authored Aug 10, 2020
2 parents 87c936b + b9157d3 commit e823c44
Show file tree
Hide file tree
Showing 26 changed files with 792 additions and 186 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build/*
node_modules
node_modules/*
.project
*.css
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ notifications:
email:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/812f2e5d255f453e8021519d2a4c7056)](https://www.codacy.com/manual/rlreamy/libra-web?utm_source=github.com&utm_medium=referral&utm_content=KPMP/libra-web&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/KPMP/libra-web.svg?branch=develop)](https://travis-ci.org/KPMP/libra-web)

# libra-web
The web-layer of the KPMP curation tools.


## Hosted at:
dev-datamanager.kpmp.org
datamanager.kpmp.org
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libra-web",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"dependencies": {
"axios": "0.19.0",
Expand All @@ -21,7 +21,7 @@
"redux-thunk": "2.3.0"
},
"devDependencies": {
"node-sass-chokidar": "1.3.5",
"node-sass-chokidar": "^1.5.0",
"npm-run-all": "4.1.5"
},
"scripts": {
Expand Down
Binary file added public/img/fail-kidneys.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/happy-kidneys.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 35 additions & 33 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,67 +13,69 @@ import { Route, Switch, Router } from 'react-router-dom';
import ErrorBoundaryContainer from './components/Error/ErrorBoundaryContainer';
import Oops from './components/Error/Oops';
import PackageDashboardPageContainer from './components/PackageDashboard/PackageDashboardPageContainer';
import FilenameValidationPageContainer from './components/Validation/FilenameValidationPageContainer';
import PermissionDenied from './components/Error/PermissionDenied';
import NotRegistered from './components/Error/NotRegistered';

const cacheStore = window.sessionStorage.getItem('redux-store');
const initialState = cacheStore ? JSON.parse(cacheStore) : loadedState;
const store = applyMiddleware(thunk)(createStore)(
rootReducer,
initialState,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
rootReducer,
initialState,
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
);
const saveState = () => {
window.sessionStorage.setItem(
'redux-store',
JSON.stringify(store.getState())
);
window.sessionStorage.setItem(
'redux-store',
JSON.stringify(store.getState())
);
};

const GA_TRACKING_ID = 'UA-124331187-8';

if(process.env.NODE_ENV === 'production') {
ReactGA.initialize(GA_TRACKING_ID);
ReactGA.initialize(GA_TRACKING_ID);
}

function logPageView(location, action) {
ReactGA.set({ page: location.pathname + location.search });
ReactGA.pageview(location.pathname + location.search);
ReactGA.set({ page: location.pathname + location.search });
ReactGA.pageview(location.pathname + location.search);
}
const history = createBrowserHistory();
history.listen((location, action) => {
logPageView(location, action);
logPageView(location, action);
});

store.subscribe(function() {
console.log(store.getState());
console.log(store.getState());
});

store.subscribe(saveState);

class App extends Component {
componentWillMount() {
logPageView(window.location, '');
}
componentWillMount() {
logPageView(window.location, '');
}

render() {
return (
<Provider store={store}>
<Router history={history}>
<ErrorBoundaryContainer>
<NavBar />
<Switch>
<Route exact path="/" component={PackageDashboardPageContainer} store={store} />
<Route exact path="/oops" component={Oops} />
<Route exact path="/permissionDenied" component={PermissionDenied} />
<Route exact path="/notRegistered" component={NotRegistered} />
</Switch>
<NavFooter />
</ErrorBoundaryContainer>
</Router>
</Provider>
);
}
render() {
return (
<Provider store={store}>
<Router history={history}>
<ErrorBoundaryContainer>
<NavBar />
<Switch>
<Route exact path='/' component={PackageDashboardPageContainer} store={store} />
<Route exact path='/filenameValidation' component={FilenameValidationPageContainer} store={store}/>
<Route exact path='/oops' component={Oops} />
<Route exact path='/permissionDenied' component={PermissionDenied} />
<Route exact path='/notRegistered' component={NotRegistered} />
</Switch>
<NavFooter />
</ErrorBoundaryContainer>
</Router>
</Provider>
);
}
}

export default App;
9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

12 changes: 12 additions & 0 deletions src/actions/Packages/packageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ export const getPackages = () => {
};
}

export const movePackageFiles = (packageId) => {
return (dispatch) => {
api.post('/api/v1/packages/' + packageId + '/files/move')
.then(res => {
alert(res.data);
})
.catch(err => {
alert("There was a problem moving the files.");
});
}
}

export const setPackages = (packages) => {
return {
type: actionNames.SET_PACKAGES,
Expand Down
30 changes: 30 additions & 0 deletions src/actions/Validation/validationActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import actionNames from '../actionNames';
import Api from '../../helpers/Api';
import { sendMessageToBackend } from '../Error/errorActions';

const api = Api.getInstance();

export const setValidationResult = (result) => {
return {
type: actionNames.SET_VALIDATION_RESULT,
payload: result
};
}

export const validateFilenames = (formData) => {
return (dispatch) => {
api.post('/api//v1/package/files/validation', formData)
.then((res) => {
dispatch(setValidationResult(res.data));
})
.catch((error) => {
dispatch(sendMessageToBackend(error));
});
}
}

export const clearValidationResult = () => {
return {
type: actionNames.CLEAR_VALIDATION_RESULT
};
}
26 changes: 26 additions & 0 deletions src/actions/Validation/validationActions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import actionNames from '../actionNames';
import { setValidationResult, clearValidationResult } from './validationActions';

describe('setValidationResult', () => {
it('should return the result in the correct structure', () => {
let expectedResult = {
type: actionNames.SET_VALIDATION_RESULT,
payload: { 'key': 'value' }
};

let result = setValidationResult({ 'key': 'value' });

expect(result).toEqual(expectedResult);
});
});
describe('clearValidationResult', () => {
it('should return the result in the correct structure', () => {
let expectedResult = {
type: actionNames.CLEAR_VALIDATION_RESULT
};

let result = clearValidationResult();

expect(result).toEqual(expectedResult);
});
});
8 changes: 5 additions & 3 deletions src/actions/actionNames.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const actionNames = {
RESET_STATE: 'RESET_STATE',
SET_PACKAGES: 'SET_PACKAGES',
GET_PACKAGES: 'GET_PACKAGES'
CLEAR_VALIDATION_RESULT: 'CLEAR_VALIDATION_RESULT',
GET_PACKAGES: 'GET_PACKAGES',
RESET_STATE: 'RESET_STATE',
SET_PACKAGES: 'SET_PACKAGES',
SET_VALIDATION_RESULT: 'SET_VALIDATION_RESULT'
};

export default actionNames;
40 changes: 25 additions & 15 deletions src/components/PackageDashboard/PackageDashboardPage.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import React, { Component } from 'react';
import { Container, Row, Col } from 'reactstrap';
import { Container, Row, Col, Button } from 'reactstrap';
import { Link } from 'react-router-dom';
import PackageTable from './PackageTable';

class PackageDashboardPage extends Component {

componentDidMount() {
this.props.getPackages();
}
componentDidMount() {
this.props.getPackages();
}

render() {
return <Container id="package-dashboard-page">
<Row>
<Col sm={12}>
<PackageTable
packages={this.props.packages}
/>
</Col>
</Row>
</Container>;
}
render() {
return (
<Container id='package-dashboard-page'>
<Row className='mt-3'>
<Col sm={12}>
<Link className='float-right' to='/filenameValidation'>
<Button color="primary">Validate Filenames</Button>
</Link>
</Col>
</Row>
<Row className='mt-3'>
<Col sm={12}>
<PackageTable
packages={this.props.packages} movePackageFiles={this.props.movePackageFiles}
/>
</Col>
</Row>
</Container>
);
}
}

export default PackageDashboardPage;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { connect } from 'react-redux';
import { getPackages } from "../../actions/Packages/packageActions";
import { getPackages, movePackageFiles } from "../../actions/Packages/packageActions";
import PackageDashboardPage from './PackageDashboardPage';

const mapStateToProps = (state, props) => ({
Expand All @@ -9,6 +9,9 @@ const mapStateToProps = (state, props) => ({
const mapDispatchToProps = (dispatch, props) => ({
getPackages() {
dispatch(getPackages());
},
movePackageFiles(packageId) {
dispatch(movePackageFiles(packageId));
}
});

Expand Down
Loading

0 comments on commit e823c44

Please sign in to comment.