Add dataviews to layergroup metadata
This commit is contained in:
parent
f745e915d3
commit
ff147ca3bf
@ -383,6 +383,7 @@ MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, la
|
|||||||
|
|
||||||
// TODO this should take into account several URL patterns
|
// TODO this should take into account several URL patterns
|
||||||
addWidgetsUrl(username, layergroup);
|
addWidgetsUrl(username, layergroup);
|
||||||
|
addDataviewsUrls(username, layergroup, mapconfig.obj());
|
||||||
if (req.method === 'GET') {
|
if (req.method === 'GET') {
|
||||||
var ttl = global.environment.varnish.layergroupTtl || 86400;
|
var ttl = global.environment.varnish.layergroupTtl || 86400;
|
||||||
res.set('Cache-Control', 'public,max-age='+ttl+',must-revalidate');
|
res.set('Cache-Control', 'public,max-age='+ttl+',must-revalidate');
|
||||||
@ -401,6 +402,18 @@ MapController.prototype.afterLayergroupCreate = function(req, res, mapconfig, la
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function addDataviewsUrls(username, layergroup, mapConfig) {
|
||||||
|
layergroup.metadata.dataviews = layergroup.metadata.dataviews || {};
|
||||||
|
var dataviews = mapConfig.dataviews || {};
|
||||||
|
|
||||||
|
Object.keys(dataviews).forEach(function(dataviewName) {
|
||||||
|
var resource = layergroup.layergroupid + '/dataview/' + dataviewName;
|
||||||
|
layergroup.metadata.dataviews[dataviewName] = {
|
||||||
|
url: getUrls(username, resource)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function addWidgetsUrl(username, layergroup) {
|
function addWidgetsUrl(username, layergroup) {
|
||||||
|
|
||||||
if (layergroup.metadata && Array.isArray(layergroup.metadata.layers)) {
|
if (layergroup.metadata && Array.isArray(layergroup.metadata.layers)) {
|
||||||
|
@ -138,8 +138,6 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) {
|
|||||||
url += '?' + qs.stringify(extraParams);
|
url += '?' + qs.stringify(extraParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(url);
|
|
||||||
|
|
||||||
var layergroupId;
|
var layergroupId;
|
||||||
step(
|
step(
|
||||||
function createLayergroup() {
|
function createLayergroup() {
|
||||||
@ -165,13 +163,13 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
var parsedBody = JSON.parse(res.body);
|
var parsedBody = JSON.parse(res.body);
|
||||||
// var expectedWidgetURLS = {
|
var expectedDataviewsURLS = {
|
||||||
// http: "/api/v1/map/" + parsedBody.layergroupid + "/dataview/" + dataviewName
|
http: "/api/v1/map/" + parsedBody.layergroupid + "/dataview/" + dataviewName
|
||||||
// };
|
};
|
||||||
// assert.ok(parsedBody.metadata.dataviews[dataviewName]);
|
assert.ok(parsedBody.metadata.dataviews[dataviewName]);
|
||||||
// assert.ok(
|
assert.ok(
|
||||||
// parsedBody.metadata.dataviews[dataviewName].url.http.match(expectedWidgetURLS.http)
|
parsedBody.metadata.dataviews[dataviewName].url.http.match(expectedDataviewsURLS.http)
|
||||||
// );
|
);
|
||||||
return next(null, parsedBody.layergroupid);
|
return next(null, parsedBody.layergroupid);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user