res.locals in layergroup controller

This commit is contained in:
Simon Martín
2017-09-29 12:32:46 +02:00
parent b4d03c074a
commit a21648ab4a
3 changed files with 17 additions and 23 deletions
+1 -3
View File
@@ -6,9 +6,7 @@ function AnalysisStatusBackend() {
module.exports = AnalysisStatusBackend;
AnalysisStatusBackend.prototype.getNodeStatus = function (params, callback) {
var nodeId = params.nodeId;
AnalysisStatusBackend.prototype.getNodeStatus = function (nodeId, params, callback) {
var statusQuery = [
'SELECT node_id, status, updated_at, last_error_message as error_message',
'FROM cdb_analysis_catalog where node_id = \'' + nodeId + '\''
+2 -6
View File
@@ -22,9 +22,7 @@ function DataviewBackend(analysisBackend) {
module.exports = DataviewBackend;
DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, params, callback) {
var dataviewName = params.dataviewName;
DataviewBackend.prototype.getDataview = function (mapConfigProvider, user, dataviewName, params, callback) {
step(
function getMapConfig() {
mapConfigProvider.getMapConfig(this);
@@ -113,9 +111,7 @@ function getOverrideParams(params, ownFilter) {
return overrideParams;
}
DataviewBackend.prototype.search = function (mapConfigProvider, user, params, callback) {
var dataviewName = params.dataviewName;
DataviewBackend.prototype.search = function (mapConfigProvider, user, dataviewName, params, callback) {
step(
function getMapConfig() {
mapConfigProvider.getMapConfig(this);
+14 -14
View File
@@ -151,7 +151,7 @@ LayergroupController.prototype.analysisNodeStatus = function(req, res, next) {
step(
function retrieveNodeStatus() {
self.analysisStatusBackend.getNodeStatus(req.params, this);
self.analysisStatusBackend.getNodeStatus(req.params.nodeId, res.locals, this);
},
function finish(err, nodeStatus, stats) {
req.profiler.add(stats || {});
@@ -175,9 +175,9 @@ LayergroupController.prototype.dataview = function(req, res, next) {
step(
function retrieveDataview() {
var mapConfigProvider = new MapStoreMapConfigProvider(
self.mapStore, req.context.user, self.userLimitsApi, req.params
self.mapStore, req.context.user, self.userLimitsApi, res.locals
);
self.dataviewBackend.getDataview(mapConfigProvider, req.context.user, req.params, this);
self.dataviewBackend.getDataview(mapConfigProvider, req.context.user, req.params.dataviewName, res.locals, this);
},
function finish(err, dataview, stats) {
req.profiler.add(stats || {});
@@ -198,9 +198,9 @@ LayergroupController.prototype.dataviewSearch = function(req, res, next) {
step(
function searchDataview() {
var mapConfigProvider = new MapStoreMapConfigProvider(
self.mapStore, req.context.user, self.userLimitsApi, req.params
self.mapStore, req.context.user, self.userLimitsApi, res.locals
);
self.dataviewBackend.search(mapConfigProvider, req.context.user, req.params, this);
self.dataviewBackend.search(mapConfigProvider, req.context.user, req.params.dataviewName, res.locals, this);
},
function finish(err, searchResult, stats) {
req.profiler.add(stats || {});
@@ -224,9 +224,9 @@ LayergroupController.prototype.attributes = function(req, res, next) {
step(
function retrieveFeatureAttributes() {
var mapConfigProvider = new MapStoreMapConfigProvider(
self.mapStore, req.context.user, self.userLimitsApi, req.params
self.mapStore, req.context.user, self.userLimitsApi, res.locals
);
self.attributesBackend.getFeatureAttributes(mapConfigProvider, req.params, false, this);
self.attributesBackend.getFeatureAttributes(mapConfigProvider, res.locals, false, this);
},
function finish(err, tile, stats) {
req.profiler.add(stats || {});
@@ -260,7 +260,7 @@ LayergroupController.prototype.tileOrLayer = function (req, res, next) {
step(
function mapController$getTileOrGrid() {
self.tileBackend.getTile(
new MapStoreMapConfigProvider(self.mapStore, req.context.user, self.userLimitsApi, req.params),
new MapStoreMapConfigProvider(self.mapStore, req.context.user, self.userLimitsApi, res.locals),
req.params, this
);
},
@@ -341,11 +341,11 @@ LayergroupController.prototype.staticMap = function(req, res, width, height, zoo
function getImage() {
if (center) {
self.previewBackend.getImage(
new MapStoreMapConfigProvider(self.mapStore, req.context.user, self.userLimitsApi, req.params),
new MapStoreMapConfigProvider(self.mapStore, req.context.user, self.userLimitsApi, res.locals),
format, width, height, zoom, center, this);
} else {
self.previewBackend.getImage(
new MapStoreMapConfigProvider(self.mapStore, req.context.user, self.userLimitsApi, req.params),
new MapStoreMapConfigProvider(self.mapStore, req.context.user, self.userLimitsApi, res.locals),
format, width, height, zoom /* bounds */, this);
}
},
@@ -373,18 +373,18 @@ LayergroupController.prototype.sendResponse = function(req, res, body, status, h
// Set Last-Modified header
var lastUpdated;
if (req.params.cache_buster) {
if (res.locals.cache_buster) {
// Assuming cache_buster is a timestamp
lastUpdated = new Date(parseInt(req.params.cache_buster));
lastUpdated = new Date(parseInt(res.locals.cache_buster));
} else {
lastUpdated = new Date();
}
res.set('Last-Modified', lastUpdated.toUTCString());
var dbName = req.params.dbname;
var dbName = res.locals.dbname;
step(
function getAffectedTables() {
self.getAffectedTables(req.context.user, dbName, req.params.token, this);
self.getAffectedTables(req.context.user, dbName, res.locals.token, this);
},
function sendResponse(err, affectedTables) {
req.profiler.done('affectedTables');