Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
Render maps with size corresponding to the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaniel committed Jul 5, 2017
1 parent a2f5c31 commit 8b1f7cc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src-server/workspace/image-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ module.exports = function(authGuardian, mongooseConnection, webpack_middleware)
}
var mapID = new ObjectId(splitMapName[0]);

var width = Number(req.query.width);
if(!Number.isInteger(width) || width < 0 || width > 4000){
width = 1024;
}

var height = Number(req.query.height);
if(!Number.isInteger(height) || height < 0 || height > 2000){
height = 800;
}

WardleyMap
.findOne({
_id: mapID,
Expand All @@ -149,8 +159,8 @@ module.exports = function(authGuardian, mongooseConnection, webpack_middleware)
background: true,
coords: {
size: {
width: 1280,
height: 800
width: width,
height: height
}
}
};
Expand Down
3 changes: 3 additions & 0 deletions src-ui/map-editor/MapEditorPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ export default class MapEditorPage extends React.Component {
}

download(maplink, tempName) {
let canvasStore = this.canvasStore;
let size = canvasStore.getCanvasSize();
$.ajax({
url: maplink,
type: 'GET',
data : size,
xhrFields: {
responseType: 'blob'
},
Expand Down
14 changes: 14 additions & 0 deletions src-ui/map-editor/canvas-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ export default class CanvasStore extends Store {
return this.state;
}

getCanvasSize(){
if(this.state && this.state.coords && this.state.coords.size){
return {
width: this.state.coords.size.width,
height: this.state.coords.size.height
};
} else {
return {
width: 100,
height: 100
};
}
}

emitChange() {
this.state.multiNodeSelection = this.state.currentlySelectedNodes.length + this.state.currentlySelectedComments.length > 1;
super.emitChange();
Expand Down

0 comments on commit 8b1f7cc

Please sign in to comment.