Skip to content

Commit

Permalink
Mission folder creation, add indication that Apache support is deprec…
Browse files Browse the repository at this point in the history
…ating
  • Loading branch information
tariqksoliman committed Oct 25, 2019
1 parent d4fe84f commit edd7c33
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 154 deletions.
27 changes: 23 additions & 4 deletions API/routes/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
**********************************************************/
const express = require('express');
const router = express.Router();
const crypto = require('crypto');
const bcrypt = require('bcryptjs');
const buf = crypto.randomBytes(128);
const execFile = require("child_process").execFile;

const logger = require('../logger');
const Config = require('../models/config');
const config_template = require('../templates/config_template');

const fs = require('fs');

function get(req, res, next, cb ) {
Config.findAll( {
where: {
Expand Down Expand Up @@ -88,6 +87,13 @@ function add(req, res, next, cb) {
configTemplate = req.body.config || configTemplate;
configTemplate.msv.mission = req.body.mission;

if( req.body.mission !== req.body.mission.replace(/[`~!@#$%^&*()|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '') &&
req.body.mission.length === 0 &&
!isNaN(req.body.mission[0]) ) {
res.send( { status: 'failure', message: 'Bad mission name.' } );
return;
}

let newConfig = {
mission: req.body.mission,
config: configTemplate,
Expand All @@ -105,6 +111,19 @@ function add(req, res, next, cb) {
if( !mission ) {
Config.create(newConfig)
.then(created => {
let dir = './Missions/' + created.mission
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
let dir2 = dir + '/Layers'
if (!fs.existsSync(dir2)){
fs.mkdirSync(dir2);
}
let dir3 = dir + '/Data'
if (!fs.existsSync(dir3)){
fs.mkdirSync(dir3);
}
}

if( cb )
cb( { status: 'success', mission: created.mission, version: created.version } );
else
Expand Down Expand Up @@ -323,7 +342,7 @@ router.post('/destroy', function(req, res, next) {
stdout,
stderr
) {
res.send( stdout );
res.send( { s: stdout, d: process.cwd() } );
});
})
.catch( err => {
Expand Down
297 changes: 151 additions & 146 deletions config/configconfig.json
Original file line number Diff line number Diff line change
@@ -1,151 +1,156 @@
{
"missions": [],
"tools": [
{
"defaultIcon": "buffer",
"description": "Hierarchically toggle layers on and off and alter their opacities.",
"descriptionFull": "",
"hasVars": false,
"name": "Layers"
},
{
"defaultIcon": "format-list-bulleted-type",
"description": "Show a chart mapping colors and symbols to meaning.",
"descriptionFull": "",
"hasVars": false,
"name": "Legend"
},
{
"defaultIcon": "information-variant",
"description": "Display the geojson properties field of a clicked point.",
"descriptionFull": "",
"hasVars": false,
"name": "Info"
},
{
"defaultIcon": "pin",
"description": "A button bar to navigate between various map locations.",
"descriptionFull": {
"title": "A button bar to quickly navigate between preset map locations.",
"example": {
"sites": [
{
"name": "(str) Name of site",
"code": "(str) Unique identifier. Can match header layer to toggle it's sublayers",
"view": ["(num) Latitude", "(num) Longitude", "(num) Zoom level"]
"missions": [
],
"tools": [
{
"defaultIcon": "buffer",
"description": "Hierarchically toggle layers on and off and alter their opacities.",
"descriptionFull": "",
"hasVars": false,
"name": "Layers"
},
{
"defaultIcon": "format-list-bulleted-type",
"description": "Show a chart mapping colors and symbols to meaning.",
"descriptionFull": "",
"hasVars": false,
"name": "Legend"
},
{
"defaultIcon": "information-variant",
"description": "Display the geojson properties field of a clicked point.",
"descriptionFull": "",
"hasVars": false,
"name": "Info"
},
{
"defaultIcon": "pin",
"description": "A button bar to navigate between various map locations.",
"descriptionFull": {
"title": "A button bar to quickly navigate between preset map locations.",
"example": {
"sites": [
{
"name": "(str) Name of site",
"code": "(str) Unique identifier. Can match header layer to toggle it's sublayers",
"view": [
"(num) Latitude",
"(num) Longitude",
"(num) Zoom level"
]
},
{
"...": "..."
}
]
}
},
{
"...": "..."
}
]
}
},
"hasVars": true,
"name": "Sites"
},
{
"defaultIcon": "folder-multiple",
"description": "A file finder/explorer to access and display other users' drawings.",
"descriptionFull": "",
"hasVars": false,
"name": "FileManager"
},
{
"defaultIcon": "chart-areaspline",
"description": "Measure distances and generates elevation profiles.",
"descriptionFull": {
"title": "Specify a path to a Digital Elevation Model (dem) .tif. Measure distances and generates elevation profiles. Can also query specific bands at specific points of images and generate profiles of them.",
"example": {
"dem": "(str) path to Data/missionDEM.tif"
}
},
"hasVars": true,
"name": "Measure"
},
{
"defaultIcon": "lead-pencil",
"description": "Draw polygons with colors, names and descriptions.",
"descriptionFull": {
"title": "Please specify a color legend. Draw polygons with colors, names and descriptions. Polygons of the same file never overlap each other and there are options to draw, erase, delete, draw over, draw under, change the color, name, description, download and choose which file you're drawing to.",
"example": {
"colorlegend": [
{
"name": "Smooth Regolith",
"color": "#1E5CB3",
"value": "0",
"invertTextColor": true
"hasVars": true,
"name": "Sites"
},
{
"defaultIcon": "folder-multiple",
"description": "A file finder\/explorer to access and display other users' drawings.",
"descriptionFull": "",
"hasVars": false,
"name": "FileManager"
},
{
"defaultIcon": "chart-areaspline",
"description": "Measure distances and generates elevation profiles.",
"descriptionFull": {
"title": "Specify a path to a Digital Elevation Model (dem) .tif. Measure distances and generates elevation profiles. Can also query specific bands at specific points of images and generate profiles of them.",
"example": {
"dem": "(str) path to Data\/missionDEM.tif"
}
},
{
"...": "..."
}
],
"demtilesets": {
"path_to_DEM_tiles/{z}/{x}/{y}.png": {
"dim": "(int) dimension of dem tiles used. 32 for 32x32 tiles",
"z": "(int) zoom level to query elevation data off of dem tiles"
"hasVars": true,
"name": "Measure"
},
{
"defaultIcon": "lead-pencil",
"description": "Draw polygons with colors, names and descriptions.",
"descriptionFull": {
"title": "Please specify a color legend. Draw polygons with colors, names and descriptions. Polygons of the same file never overlap each other and there are options to draw, erase, delete, draw over, draw under, change the color, name, description, download and choose which file you're drawing to.",
"example": {
"colorlegend": [
{
"name": "Smooth Regolith",
"color": "#1E5CB3",
"value": "0",
"invertTextColor": true
},
{
"...": "..."
}
],
"demtilesets": {
"path_to_DEM_tiles\/{z}\/{x}\/{y}.png": {
"dim": "(int) dimension of dem tiles used. 32 for 32x32 tiles",
"z": "(int) zoom level to query elevation data off of dem tiles"
},
"...": {
"...": "..."
}
}
}
},
"...": {
"...": "..."
}
}
}
},
"hasVars": true,
"name": "Sketch"
},
{
"defaultIcon": "flask",
"description": "Display chemistry percentages via graphs of a clicked point.",
"descriptionFull": "",
"hasVars": false,
"name": "Chemistry"
},
{
"defaultIcon": "eye",
"description": "Search a layer for a string.",
"descriptionFull": {
"title": "Please specify search fields. Search a layer for a string and either go to it and/or select it. The strings are built from the layer elements' properties object. Which properties it searches through depends on the defined searchfields for each layer. Try to choose a combination that's unique. propN is a geojson property key of that layer. All propNs are placed between parentheses and separated by a space. Place 'round' or 'rmunder' before a prop to round it or remove its underscores.",
"example": {
"searchfields": {
"[Layer_Name]": "(prop1) round(prop3)",
"...": "..."
}
}
},
"hasVars": true,
"name": "Search"
},
{
"defaultIcon": "map-marker",
"description": "Mouse over the map for a by-pixel legend of a raster.",
"descriptionFull": {
"title": "Mouse over to query underlying datasets.",
"example": {
"[Layer_Name]": {
"url": "(str) path_to_data/data.tif",
"bands": "(int) how many bands to query from",
"sigfigs": "(int) how many digits after the decimal",
"unit": "(str) whatever string unit"
},
"...": {}
"hasVars": true,
"name": "Sketch"
},
{
"defaultIcon": "flask",
"description": "Display chemistry percentages via graphs of a clicked point.",
"descriptionFull": "",
"hasVars": false,
"name": "Chemistry"
},
{
"defaultIcon": "eye",
"description": "Search a layer for a string.",
"descriptionFull": {
"title": "Please specify search fields. Search a layer for a string and either go to it and\/or select it. The strings are built from the layer elements' properties object. Which properties it searches through depends on the defined searchfields for each layer. Try to choose a combination that's unique. propN is a geojson property key of that layer. All propNs are placed between parentheses and separated by a space. Place 'round' or 'rmunder' before a prop to round it or remove its underscores.",
"example": {
"searchfields": {
"[Layer_Name]": "(prop1) round(prop3)",
"...": "..."
}
}
},
"hasVars": true,
"name": "Search"
},
{
"defaultIcon": "map-marker",
"description": "Mouse over the map for a by-pixel legend of a raster.",
"descriptionFull": {
"title": "Mouse over to query underlying datasets.",
"example": {
"[Layer_Name]": {
"url": "(str) path_to_data\/data.tif",
"bands": "(int) how many bands to query from",
"sigfigs": "(int) how many digits after the decimal",
"unit": "(str) whatever string unit"
},
"...": []
}
},
"hasVars": true,
"name": "Identifier"
},
{
"defaultIcon": "magnify",
"description": "Spatially query layer data",
"descriptionFull": "A more complete description that you see when you click on the description",
"hasVars": true,
"name": "Query"
},
{
"defaultIcon": "tent",
"description": "Advanced drawing",
"descriptionFull": "",
"hasVars": true,
"name": "Draw"
}
},
"hasVars": true,
"name": "Identifier"
},
{
"defaultIcon": "magnify",
"description": "Spatially query layer data",
"descriptionFull": "A more complete description that you see when you click on the description",
"hasVars": true,
"name": "Query"
},
{
"defaultIcon": "tent",
"description": "Advanced drawing",
"descriptionFull": "",
"hasVars": true,
"name": "Draw"
}
]
}
]
}
Loading

0 comments on commit edd7c33

Please sign in to comment.