Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobAndrewHurst committed Aug 30, 2019
2 parents 48c75ab + 7ea07a1 commit f21a560
Show file tree
Hide file tree
Showing 75 changed files with 1,362 additions and 566 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**v1.6.1**
**v1.6.2**

# xyz

Expand Down
4 changes: 2 additions & 2 deletions mod/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module.exports = {

port: process.env.PORT || 3000,

acl_connection: (process.env.PUBLIC || process.env.PRIVATE) ?
(process.env.PUBLIC || process.env.PRIVATE).split('|') : null,
acl_connection: (process.env.PRIVATE || process.env.PUBLIC) ?
process.env.PRIVATE || process.env.PUBLIC : null,

// Global dir expands the domain to create the root path for the application.
path: process.env.DIR || '',
Expand Down
16 changes: 16 additions & 0 deletions mod/evalParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
layerValues: _layerValues,
tableDef: _tableDef,
userSchemaField: _userSchemaField,
pgFunction: _pgFunction
};

function _token(req, res, next) {
Expand Down Expand Up @@ -170,6 +171,21 @@ function _tableDef(req, res, next) {

};

function _pgFunction(req, res, next) {

req.params.pgFunction = req.params.layer.infoj.find(
entry => entry.pgFunction === decodeURIComponent(req.query.pgFunction)
);

if (!req.params.pgFunction) {
res.code(400);
return next(new Error('Missing pgFunction definition.'));
}

next();

};

function _userSchemaField(req, res, next) {

const userSchemaFields = new Set([
Expand Down
4 changes: 4 additions & 0 deletions mod/pg/acl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ module.exports = async () => {

if (!env.acl_connection) return;

env.acl_connection = env.acl_connection.split('|');

if(!env.acl_connection[1]) throw 666;

if (!env.secret) {
console.log('No secret provided for JWT. Process will be killed now!');
return process.exit();
Expand Down
80 changes: 75 additions & 5 deletions mod/pg/sql_fields.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
module.exports = async (fields, infoj, qID) => {
const sql_filter = require('./sql_filter');

// Iterate through infoj and push individual entries into fields array.
await infoj.forEach(entry => {
module.exports = async (fields, infoj, qID, roles, locale) => {

// Iterate through infoj and push individual entries into fields array
await infoj.forEach(async entry => {

if (entry.columns) return;

if (entry.withSelect) return;
//if (entry.withSelect) return;

if (entry.clusterArea) {

if (!qID
|| !entry.field
|| !entry.clusterArea.area
|| !entry.clusterArea.cluster
|| !entry.clusterArea.area_geom
|| !entry.clusterArea.cluster_geom) return;

let q = `
(
SELECT b.${entry.fieldfx || entry.field}
FROM
${entry.clusterArea.cluster} a,
${entry.clusterArea.area} b
WHERE
a.${qID} = $1
AND
${entry.clusterArea.condition || 'ST_INTERSECTS'}(
b.${entry.clusterArea.area_geom},
a.${entry.clusterArea.cluster_geom}
) LIMIT 1
) AS ${entry.field}`;

return fields.push(q);
}

if (entry.lookup) {

Expand All @@ -16,6 +45,22 @@ module.exports = async (fields, infoj, qID) => {
|| !entry.lookup.geom_a
|| !entry.lookup.geom_b) return;

let filter = {};

if(roles) await roles.forEach(async role => {

if (!entry.lookup.layer_roles) return;

const layer_roles = locale.layers[entry.lookup.layer_roles].roles;

if (!layer_roles) return;

Object.assign(filter, layer_roles[role]);

});

const filter_sql = await sql_filter(filter);

let q = `
(
SELECT ${entry.fieldfx || `${entry.lookup.aggregate || 'SUM'}(${entry.field})`}
Expand All @@ -29,8 +74,9 @@ module.exports = async (fields, infoj, qID) => {
a.${entry.lookup.geom_a},
b.${entry.lookup.geom_b}
)
${typeof filter_sql !== 'undefined' ? filter_sql : ''}
) AS ${entry.field}`;

return fields.push(q);

}
Expand All @@ -42,3 +88,27 @@ module.exports = async (fields, infoj, qID) => {
return fields;

};

async function role_filter(locale, layer, roles) {

if (!layer || !roles.length) return;

const layer_roles = locale.layers[layer].roles;

if (!Object.keys(layer_roles).some(
role => roles.includes(role)
)) return;

let filter = {};

await roles.forEach(async role => {

filter = Object.assign(filter, layer_roles[role]);

});

const filter_sql = await sql_filter(filter);

return filter_sql;

}
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xyz",
"version": "1.6.1",
"version": "1.6.2",
"repository": {
"type": "git",
"url": "https://github.com/geolytix/xyz"
Expand All @@ -25,11 +25,12 @@
"@turf/turf": "^5.1.6",
"bcrypt-nodejs": "0.0.3",
"chart.js": "^2.7.3",
"chartjs-plugin-datalabels": "^0.6.0",
"d3": "^5.9.2",
"dotenv": "^8.0.0",
"fastify": "^2.0.0",
"fastify-auth": "^0.4.0",
"fastify-cors": "^2.1.2",
"fastify-cors": "^2.1.3",
"fastify-formbody": "^3.1.0",
"fastify-helmet": "^3.0.0",
"fastify-jwt": "^0.9.3",
Expand Down
22 changes: 0 additions & 22 deletions public/cs

This file was deleted.

2 changes: 1 addition & 1 deletion public/css/_chkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
position: relative;
cursor: pointer;
display: block;
width: 90%;
/*width: 90%;*/
input[type=checkbox] {
position: absolute;
opacity: 0;
Expand Down
3 changes: 2 additions & 1 deletion public/css/_contextmenu.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.contextmenu {
background-color: #FFF;
box-shadow: 0 4px 5px 3px rgba(0, 0, 0, 0.2);
position: relative;
position: absolute;
min-width: 120px;
max-width: 180px;
padding: 2px;
z-index: 1001;
Expand Down
5 changes: 3 additions & 2 deletions public/css/control.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/control.css.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions public/css/desktop.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/desktop.css.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions public/css/mobile.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/css/mobile.css.map

Large diffs are not rendered by default.

Loading

0 comments on commit f21a560

Please sign in to comment.