Skip to content

Commit

Permalink
Merge pull request #73 from KPMP/develop
Browse files Browse the repository at this point in the history
Release v1.1.5
  • Loading branch information
rlreamy authored Sep 23, 2021
2 parents 68bd2b0 + 8855db3 commit c400f13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
7 changes: 6 additions & 1 deletion src/actions/Error/errorActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ export const sendMessageToBackend = (error) => {
return (dispatch) => {
api.post('/api/v1/error', errorMessage)
.then((res) => {
dispatch(handleError(error.response.status));
if (error.response && error.response.status) {
dispatch(handleError(error.response.status));
} else {
dispatch(handleError("send to oops"));
}

});
};
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/Slides/Menu/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import {
faChevronRight,
faChevronLeft,
faDownload,
faPrint,
faSquare,
faCheckSquare,
faCaretDown
} from '@fortawesome/free-solid-svg-icons';
import { Col, Row } from 'reactstrap';
import ReactGA from 'react-ga';
import { getNextSlide, getPreviousSlide, downloadSlide, printSlide } from '../slideHelpers.js';
import { getNextSlide, getPreviousSlide, downloadSlide } from '../slideHelpers.js';
import GridProperties from './GridProperties.js';

class Header extends Component {
Expand Down
29 changes: 15 additions & 14 deletions src/components/Slides/SlideViewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ import DivOverlays from './DivOverlays';

class SlideViewer extends Component {
constructor(props) {
super(props)
super(props);
let vertical = 500;
this.horizontalRef = React.createRef(500);
this.verticalRef = React.createRef(500);
this.handleShowGridToggle = this.handleShowGridToggle.bind(this)
this.handleShowLabelToggle = this.handleShowLabelToggle.bind(this)
this.handleSetGridPropertiesClick = this.handleSetGridPropertiesClick.bind(this)
this.handleCancelGridPropertiesClick = this.handleCancelGridPropertiesClick.bind(this);


this.state = {
showGrid: false,
showGridLabel: false,
horizontal: 500,
vertical: 500,
vertical: vertical,
overlayDivs: '',
overlayLabel: [],
renderLabels: true,
labelSetId: 0,
slideTooLarge: false,
isPilotSlide: false,
gridOverlay: []
}
}

Expand Down Expand Up @@ -60,13 +63,15 @@ class SlideViewer extends Component {


async renderOverlayLabels() {
this.setState({slideTooLarge: determineIfSlideTooLargeForGrid(this.props.selectedParticipant.selectedSlide.metadata, this.state.vertical),
isPiolotSlide: determineIfPilotSlide(this.props.participants, this.props.selectedParticipant)});

await this.setState({slideTooLarge: determineIfSlideTooLargeForGrid(this.props.selectedParticipant.selectedSlide.metadata, this.state.vertical),
isPilotSlide: determineIfPilotSlide(this.props.participants, this.props.selectedParticipant)});

if (!this.state.isPilotSlide && !this.state.slideTooLarge ) {
const [gridOverlay, overlayLabel] = await this.getGridOverlay( // eslint-disable-line
this.props.selectedParticipant.selectedSlide.metadata,
this.state.labelSetId + 1);
await this.setState({ overlayLabel, renderLabels: false, labelSetId: this.state.labelSetId + 1 })
await this.setState({ overlayLabel, gridOverlay, renderLabels: false, labelSetId: this.state.labelSetId + 1 })
await this.setState({ renderLabels: true })
}
}
Expand All @@ -76,7 +81,6 @@ class SlideViewer extends Component {
}

async getGridOverlay(metadata, labelSetId) {
// estimated micron unit
let lineThickness = 13;
let vertical = this.state.vertical / parseFloat(this.props.selectedParticipant.selectedSlide.metadata.openSlide.mpp_y);
let horizontal = this.state.horizontal / parseFloat(this.props.selectedParticipant.selectedSlide.metadata.openSlide.mpp_y);
Expand Down Expand Up @@ -108,9 +112,11 @@ class SlideViewer extends Component {
className: 'gridline'
})
}

let currentLetter = '';
let currentNumber = 0;
for (let yy = 0; yy < (height); yy += vertical) {

for (let yy = 0; yy < (height); yy += horizontal) {
currentLetter = this.getNextLetterInAlphabet('');
for (let i = 0; i < (width); i += vertical) {
overlayLabel.push(`${currentLetter + currentNumber}`)
Expand All @@ -132,11 +138,7 @@ class SlideViewer extends Component {

async initSeaDragon() {
let slideId = this.props.selectedParticipant.selectedSlide.id;
let overlayGrid = []
if (!this.state.slideTooLarge || !this.state.isPilotSlide) {
let [gridOverlay] = await this.getGridOverlay(this.props.selectedParticipant.selectedSlide.metadata, this.state.labelSetId);
overlayGrid = gridOverlay
}

OpenSeadragon.setString("Tooltips.Home", "Reset pan & zoom");
this.viewer = OpenSeadragon({
id: "osdId",
Expand All @@ -155,12 +157,11 @@ class SlideViewer extends Component {
navigatorAutoFade: false,
navigatorId: 'osd-navigator',
tileSources: 'deepZoomImages/' + slideId + '.dzi',
overlays: overlayGrid
overlays: this.state.gridOverlay
});
}

handleShowGridToggle() {

if (this.state.showGrid || this.state.slideTooLarge || this.state.isPilotSlide) {
this.setState({ showGrid: false, showGridLabel: false })
} else {
Expand Down

0 comments on commit c400f13

Please sign in to comment.