res.locals fixing controllers
This commit is contained in:
@@ -321,25 +321,41 @@ LayergroupController.prototype.finalizeGetTileOrGrid = function(err, req, res, t
|
||||
};
|
||||
|
||||
LayergroupController.prototype.bbox = function(req, res, next) {
|
||||
this.staticMap(req, res, +req.params.width, +req.params.height, {
|
||||
west: +req.params.west,
|
||||
north: +req.params.north,
|
||||
east: +req.params.east,
|
||||
south: +req.params.south
|
||||
}, next);
|
||||
this.staticMap(
|
||||
req,
|
||||
res,
|
||||
+req.params.width,
|
||||
+req.params.height,
|
||||
null,
|
||||
{
|
||||
west: +req.params.west,
|
||||
north: +req.params.north,
|
||||
east: +req.params.east,
|
||||
south: +req.params.south
|
||||
},
|
||||
next
|
||||
);
|
||||
};
|
||||
|
||||
LayergroupController.prototype.center = function(req, res, next) {
|
||||
this.staticMap(req, res, +req.params.width, +req.params.height, +req.params.z, {
|
||||
lng: +req.params.lng,
|
||||
lat: +req.params.lat
|
||||
}, next);
|
||||
this.staticMap(
|
||||
req,
|
||||
res,
|
||||
+req.params.width,
|
||||
+req.params.height,
|
||||
+req.params.z,
|
||||
{
|
||||
lng: +req.params.lng,
|
||||
lat: +req.params.lat
|
||||
},
|
||||
next
|
||||
);
|
||||
};
|
||||
|
||||
LayergroupController.prototype.staticMap = function(req, res, width, height, zoom /* bounds */, center, next) {
|
||||
var format = req.params.format === 'jpg' ? 'jpeg' : 'png';
|
||||
req.params.layer = req.params.layer || 'all';
|
||||
req.params.format = req.params.format || 'png';
|
||||
res.locals.layer = res.locals.layer || 'all';
|
||||
|
||||
var self = this;
|
||||
|
||||
|
||||
@@ -181,7 +181,8 @@ MapController.prototype.create = function(req, res, prepareConfigFn, next) {
|
||||
var datasource = context.datasource || Datasource.EmptyDatasource();
|
||||
mapConfig = new MapConfig(requestMapConfig, datasource);
|
||||
self.mapBackend.createLayergroup(
|
||||
mapConfig, req.params,
|
||||
mapConfig,
|
||||
res.locals,
|
||||
new CreateLayergroupMapConfigProvider(mapConfig, req.context.user, self.userLimitsApi, res.locals),
|
||||
this
|
||||
);
|
||||
|
||||
@@ -125,7 +125,7 @@ NamedMapsController.prototype.staticMap = function(req, res, next) {
|
||||
|
||||
var format = req.params.format === 'jpg' ? 'jpeg' : 'png';
|
||||
res.locals.format = req.params.format || 'png';
|
||||
res.locals.layer = req.params.layer || 'all';
|
||||
res.locals.layer = res.locals.layer || 'all';
|
||||
|
||||
var namedMapProvider;
|
||||
step(
|
||||
@@ -148,7 +148,7 @@ NamedMapsController.prototype.staticMap = function(req, res, next) {
|
||||
},
|
||||
function prepareImageOptions(err) {
|
||||
assert.ifError(err);
|
||||
self.getStaticImageOptions(cdbUser, req.params, namedMapProvider, this);
|
||||
self.getStaticImageOptions(cdbUser, res.locals, namedMapProvider, this);
|
||||
},
|
||||
function getImage(err, imageOpts) {
|
||||
assert.ifError(err);
|
||||
@@ -222,7 +222,7 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (
|
||||
}
|
||||
|
||||
// overwrites 'all' default filter
|
||||
req.params.layer = layerVisibilityFilter.join(',');
|
||||
res.locals.layer = layerVisibilityFilter.join(',');
|
||||
|
||||
// recreates the provider
|
||||
self.namedMapProviderCache.get(
|
||||
|
||||
@@ -74,6 +74,9 @@ module.exports = _.extend({}, serverOptions, {
|
||||
}
|
||||
req.params.dbname = 'test_windshaft_cartodb_user_1_db';
|
||||
|
||||
// add all params to res.locals
|
||||
res.locals = _.extend({}, req.params);
|
||||
|
||||
|
||||
// increment number of calls counter
|
||||
global.req2params_calls = global.req2params_calls ? global.req2params_calls + 1 : 1;
|
||||
|
||||
Reference in New Issue
Block a user