Skip to content

Commit

Permalink
Merge pull request #39 from KPMP/develop
Browse files Browse the repository at this point in the history
v1.1
  • Loading branch information
rlreamy authored Nov 19, 2019
2 parents 495fff7 + c8686a0 commit e7e1434
Show file tree
Hide file tree
Showing 17 changed files with 3,202 additions and 3,345 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/76fbecb57cb6451ab4df40afe4c444f0)](https://www.codacy.com/manual/rlreamy/delphinus-web?utm_source=github.com&utm_medium=referral&utm_content=KPMP/delphinus-web&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/KPMP/delphinus-web.svg?branch=develop)](https://travis-ci.org/KPMP/delphinus-web)

# delphinus-web
This project is the web front-end for the Digital Pathology Repository for the Kidney Precision Medicine Project.

NOTE: Doesn't build with Node 12+


6,045 changes: 2,969 additions & 3,076 deletions package-lock.json

Large diffs are not rendered by default.

40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,34 @@
"version": "0.1.0",
"private": true,
"devDependencies": {
"node-sass-chokidar": "1.3.4",
"node-sass-chokidar": "1.4.0",
"npm-run-all": "4.1.5",
"react-scripts": "3.0.1"
"react-scripts": "3.2.0"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "1.2.8",
"@fortawesome/free-solid-svg-icons": "5.5.0",
"@fortawesome/react-fontawesome": "0.1.3",
"@fortawesome/fontawesome-svg-core": "1.2.25",
"@fortawesome/free-solid-svg-icons": "5.11.2",
"@fortawesome/react-fontawesome": "0.1.7",
"ajv": "6.10.2",
"antd": "3.11.0",
"axios": "0.18.1",
"antd": "3.25.0",
"axios": "0.19.0",
"bootstrap": "4.3.1",
"es6-shim": "0.35.4",
"history": "4.7.2",
"html-react-parser": "0.4.7",
"es6-shim": "0.35.5",
"history": "4.10.1",
"jquery": "3.4.1",
"lodash": "4.17.15",
"openseadragon": "2.4.0",
"popper.js": "1.15.0",
"openseadragon": "2.4.1",
"prop-types": "15.7.2",
"react": "16.6.3",
"react-burger-menu": "2.5.4",
"react-dom": "16.6.3",
"react-ga": "2.5.6",
"react-redux": "5.1.1",
"react-router-dom": "4.3.1",
"reactstrap": "6.5.0",
"redux": "4.0.1",
"react": "16.11.0",
"react-burger-menu": "2.6.11",
"react-dom": "16.11.0",
"react-ga": "2.7.0",
"react-redux": "7.1.3",
"react-router-dom": "5.1.2",
"reactstrap": "8.1.1",
"redux": "4.0.4",
"redux-thunk": "2.3.0",
"typescript": "3.5.3"
"typescript": "3.7.2"
},
"scripts": {
"start-js": "react-scripts start",
Expand Down
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
Expand Down
47 changes: 22 additions & 25 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ import React, { Component } from 'react';
import NavBar from './components/Nav/NavBar';
import Summary from './components/Summary/Summary';
import Slides from './components/Slides/Slides';
import { Container } from 'reactstrap';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import loadedState from './initialState';
import rootReducer from './reducers';
import { Router, Route } from 'react-router-dom';
import SlidePrintManager from './components/Slides/Menu/SlidePrintManager';
import { Router, Route, Switch } from 'react-router-dom';
import ReactGA from 'react-ga';
import createHistory from 'history/createBrowserHistory';
import Oops from './components/Error/Oops';
import ErrorBoundaryContainer from "./components/Error/ErrorBoundaryContainer";
import ErrorBoundaryContainer from './components/Error/ErrorBoundaryContainer';
import PermissionDenied from './components/Error/PermissionDenied';
import NotRegistered from './components/Error/NotRegistered';


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

ReactGA.initialize(GA_TRACKING_ID);
function logPageView(location, action) {
Expand All @@ -42,30 +41,28 @@ store.subscribe(function () {

store.subscribe(saveState);

SlidePrintManager.getInstance().setReduxStore(store);

class App extends Component {

componentWillMount() {
logPageView(window.location, "");
logPageView(window.location, '');
}

render() {
return (
<Provider store={store}>
<Container fluid>
<Router history={history}>
<div>
<ErrorBoundaryContainer>
<NavBar/>
<Route exact path={process.env.PUBLIC_URL} component={Summary}/>
<Route path={process.env.PUBLIC_URL + "/slides"} component={Slides}/>
</ErrorBoundaryContainer>
<Route exact path={process.env.PUBLIC_URL + "/oops"} component={Oops} />
</div>
</Router>
</Container>
</Provider>
<Provider store={store}>
<Router history={history}>
<ErrorBoundaryContainer>
<NavBar/>
<Switch>
<Route exact path='/slides' component={Slides}/>
<Route exact path='/oops' component={Oops} />
<Route exact path='/notRegistered' component={NotRegistered} />
<Route exact path='/permissionDenied' component={PermissionDenied} />
<Route exact path='/' component={Summary}/>
</Switch>
</ErrorBoundaryContainer>
</Router>
</Provider>
);
}
}
Expand Down
52 changes: 35 additions & 17 deletions src/actions/Error/errorActions.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import Api from '../../helpers/Api';

const api = Api.getInstance();

export const handleError = () => {
return (dispatch) => {
window.location.href = "/oops";
}
};

export const sendMessageToBackend = (error) => {
let errorMessage = { error: error.message , stackTrace: error.stack }
return (dispatch) => {
dispatch(handleError());
api.post('/api/v1/error', errorMessage);
};
}
import Api from '../../helpers/Api';

const api = Api.getInstance();

export const handleError = (statusCode) => {
return (dispatch) => {
if (statusCode === 404) {
window.location.href = '/notRegistered';
} else if (statusCode === 403) {
window.location.href = '/permissionDenied';
} else {
window.location.href = '/oops';
}
}
};

export const sendMessageToBackend = (error) => {

if (error.response && error.response.status && error.response.status >= 400) {
return (dispatch) => {
let href = window.location.href;
if (!href.includes('/oops') && !href.includes('/permissionDenied') && !href.includes('/notRegistered')) {
dispatch(handleError(error.response.status));
}
}
} else {
let errorMessage = { error: error.message , stackTrace: error.stack };
return (dispatch) => {
api.post('/api/v1/error', errorMessage)
.then((res) => {
dispatch(handleError(error.response.status));
});
};
}
};
27 changes: 27 additions & 0 deletions src/components/Error/NotRegistered.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { Component } from 'react';
import { Col, Row } from 'reactstrap';

class NotRegistered extends Component {

render() {
return (
<article id='permissions' className='container justify-content-center pt-3'>
<Row >
<Col xs={12} className='error-header pb-3'>
We're sorry. You are not authorized to access this application.
</Col>
</Row>
<Row>
<Col xs={12}>
<div className='alert alert-danger'>
You must be a registered user in order to use this KPMP application. If you would like to register or believe you received this page in error, please contact: &nbsp;
<a href='mailto:[email protected]'>[email protected]</a>
</div>
</Col>
</Row>
</article>
);
}
}

export default NotRegistered;
27 changes: 27 additions & 0 deletions src/components/Error/PermissionDenied.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { Component } from 'react';
import { Col, Row } from 'reactstrap';

class PermissionDenied extends Component {

render() {
return (
<article id='permissions' className='container justify-content-center pt-3'>
<Row >
<Col xs={12} className='error-header pb-3'>
We're sorry. You are not authorized to access this application.
</Col>
</Row>
<Row>
<Col xs={12}>
<div className='alert alert-danger'>
Your account does not have permission to use this KPMP application. If you believe you received this page in error, please contact: &nbsp;
<a href='mailto:[email protected]'>[email protected]</a>
</div>
</Col>
</Row>
</article>
);
}
}

export default PermissionDenied;
12 changes: 0 additions & 12 deletions src/components/Slides/Menu/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCaretLeft, faChevronRight, faChevronLeft, faDownload } from '@fortawesome/free-solid-svg-icons';
import { Col, Row } from 'reactstrap';
import ReactGA from 'react-ga';
import SlidePrintManager from './SlidePrintManager';
import { getNextSlide, getPreviousSlide, downloadSlide } from '../slideHelpers.js';

class Header extends Component {

constructor(props) {
super(props);
this.onPrint = this.onPrint.bind(this);
this.handleDownload = this.handleDownload.bind(this);
}

Expand All @@ -35,16 +33,6 @@ class Header extends Component {
let downloadFileName = this.props.selectedParticipant.selectedSlide.slideName + ".jpg";
downloadSlide(downloadFileName);
}

onPrint() {
ReactGA.event({
category: 'Slide View',
action: 'Print Slide',
label: this.props.selectedParticipant.selectedSlide.slideName
});
SlidePrintManager.getInstance().beforePrint();
setTimeout(window.print, 10);
}

render() {
return(
Expand Down
2 changes: 1 addition & 1 deletion src/components/Slides/Menu/SlideList.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SlideList extends Component {
let thumbnailSrc = "img/thumbnail_stain_" + slide.stain.type.toLowerCase() + ".png";
return (
<Row className={"slide-menu-item " + highlightedClass} onClick={() => this.handleSelectSlide(slide)}>
<Col xs={{size: "auto"}} className="no-padding"><img className="thumbnail" src={thumbnailSrc} alt=""/></Col>
<Col xs={{size: "auto"}} className="no-padding"><img className="thumbnail noselect" src={thumbnailSrc} alt=""/></Col>
<Col xs={{size: "auto"}} className="slide-name">{slide.slideName}</Col>
</Row>
)
Expand Down
Loading

0 comments on commit e7e1434

Please sign in to comment.