diff --git a/index.js b/index.js
index a23f4ea..99006b6 100644
--- a/index.js
+++ b/index.js
@@ -29,7 +29,7 @@ let bodyParser = require('body-parser');
let morgan = require('morgan');
let TaskManager = require('./libs/taskManager');
let Task = require('./libs/Task');
-let odmOptionsParser = require('./libs/odmOptionsParser');
+let odmOptions = require('./libs/odmOptions');
app.use(morgan('tiny'));
app.use(bodyParser.urlencoded({extended: true}));
@@ -59,8 +59,18 @@ let upload = multer({
app.post('/task/new', addRequestId, upload.array('images'), (req, res) => {
if (req.files.length === 0) res.json({error: "Need at least 1 file."});
else{
- // Move to data
async.series([
+ cb => {
+ odmOptions.filterOptions(req.body.options, (err, options) => {
+ if (err) cb(err);
+ else{
+ req.body.options = options;
+ cb(null);
+ }
+ });
+ },
+
+ // Move uploads to data dir
cb => {
fs.stat(`data/${req.id}`, (err, stat) => {
if (err && err.code === 'ENOENT') cb();
@@ -70,19 +80,21 @@ app.post('/task/new', addRequestId, upload.array('images'), (req, res) => {
cb => { fs.mkdir(`data/${req.id}`, undefined, cb); },
cb => {
fs.rename(`tmp/${req.id}`, `data/${req.id}/images`, err => {
- if (!err){
- new Task(req.id, req.body.name, (err, task) => {
- if (err) cb(err);
- else{
- taskManager.addNew(task);
- res.json({uuid: req.id, success: true});
- cb();
- }
- });
- }else{
- cb(new Error("Could not move images folder."))
- }
+ if (!err) cb();
+ else cb(new Error("Could not move images folder."))
});
+ },
+
+ // Create task
+ cb => {
+ new Task(req.id, req.body.name, (err, task) => {
+ if (err) cb(err);
+ else{
+ taskManager.addNew(task);
+ res.json({uuid: req.id, success: true});
+ cb();
+ }
+ }, req.body.options);
}
], err => {
if (err) res.json({error: err.message})
@@ -139,7 +151,7 @@ app.post('/task/restart', uuidCheck, (req, res) => {
});
app.get('/getOptions', (req, res) => {
- odmOptionsParser.getOptions((err, options) => {
+ odmOptions.getOptions((err, options) => {
if (err) res.json({error: err.message});
else res.json(options);
});
@@ -147,7 +159,7 @@ app.get('/getOptions', (req, res) => {
let gracefulShutdown = done => {
async.series([
- cb => { taskManager.dumpTaskList(cb) },
+ cb => { taskManager.dumpTaskList(cb); },
cb => {
console.log("Closing server");
server.close();
diff --git a/libs/Task.js b/libs/Task.js
index ff5c077..40f0f99 100644
--- a/libs/Task.js
+++ b/libs/Task.js
@@ -25,7 +25,7 @@ let archiver = require('archiver');
let statusCodes = require('./statusCodes');
module.exports = class Task{
- constructor(uuid, name, done){
+ constructor(uuid, name, done, options = []){
assert(uuid !== undefined, "uuid must be set");
assert(done !== undefined, "ready must be set");
@@ -34,10 +34,12 @@ module.exports = class Task{
this.dateCreated = new Date().getTime();
this.processingTime = -1;
this.setStatus(statusCodes.QUEUED);
- this.options = {};
+ this.options = options;
this.output = [];
this.runnerProcess = null;
+ this.options.forEach(option => { console.log(option); });
+
// Read images info
fs.readdir(this.getImagesFolderPath(), (err, files) => {
if (err) done(err);
@@ -64,7 +66,7 @@ module.exports = class Task{
}
done(null, task);
}
- })
+ }, taskJson.options);
}
// Get path where images are stored for this task
diff --git a/libs/odmOptionsParser.js b/libs/odmOptions.js
similarity index 75%
rename from libs/odmOptionsParser.js
rename to libs/odmOptions.js
index 8066cfa..5610f29 100644
--- a/libs/odmOptionsParser.js
+++ b/libs/odmOptions.js
@@ -32,8 +32,12 @@ module.exports = {
else{
options = {};
for (let option in json){
- if (["-h", "--project-path", "--zip-results"].indexOf(option) !== -1) continue;
-
+ // Not all options are useful to the end user
+ // (num cores can be set programmatically, so can gcpFile, etc.)
+ if (["-h", "--project-path",
+ "--zip-results", "--pmvs-num-cores", "--odm_georeferencing-useGcp",
+ "--start-with", "--odm_georeferencing-gcpFile", "--end-with"].indexOf(option) !== -1) continue;
+
let values = json[option];
option = option.replace(/^--/, "");
@@ -83,5 +87,21 @@ module.exports = {
done(null, options);
}
});
+ },
+
+ // Checks that the options (as received from the rest endpoint)
+ // Are valid and within proper ranges.
+ // The result of filtering is passed back via callback
+ // @param options[]
+ filterOptions: function(options, done){
+ try{
+ if (typeof options === "string") options = JSON.parse(options);
+
+ // TODO: range checks, filtering
+
+ done(null, options);
+ }catch(e){
+ done(e);
+ }
}
};
diff --git a/public/css/main.css b/public/css/main.css
index 64b802a..0da13d7 100644
--- a/public/css/main.css
+++ b/public/css/main.css
@@ -59,4 +59,8 @@
.selectric-items li{
background: #fff;
+}
+
+#options .checkbox{
+ margin-right: 143px;
}
\ No newline at end of file
diff --git a/public/css/selectric.css b/public/css/selectric.css
deleted file mode 100644
index 8508f16..0000000
--- a/public/css/selectric.css
+++ /dev/null
@@ -1,198 +0,0 @@
-/*======================================
- Selectric v1.10.1
-======================================*/
-
-.selectric-wrapper {
- position: relative;
- cursor: pointer;
-}
-
-.selectric-responsive {
- width: 100%;
-}
-
-.selectric {
- border: 1px solid #DDD;
- background: #F8F8F8;
- position: relative;
-}
-.selectric .label {
- display: block;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin: 0 38px 0 10px;
- font-size: 12px;
- line-height: 38px;
- color: #444;
- height: 38px;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-.selectric .button {
- display: block;
- position: absolute;
- right: 0;
- top: 0;
- width: 38px;
- height: 38px;
- color: #BBB;
- text-align: center;
- font: 0/0 a;
- *font: 20px/38px Lucida Sans Unicode, Arial Unicode MS, Arial;
-}
-.selectric .button:after {
- content: " ";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- margin: auto;
- width: 0;
- height: 0;
- border: 4px solid transparent;
- border-top-color: #BBB;
- border-bottom: none;
-}
-
-.selectric-focus .selectric {
- border-color: #AAA;
-}
-
-.selectric-hover .selectric {
- border-color: #C4C4C4;
-}
-.selectric-hover .selectric .button {
- color: #A2A2A2;
-}
-.selectric-hover .selectric .button:after {
- border-top-color: #A2A2A2;
-}
-
-.selectric-open {
- z-index: 9999;
-}
-.selectric-open .selectric {
- border-color: #C4C4C4;
-}
-.selectric-open .selectric-items {
- display: block;
-}
-
-.selectric-disabled {
- filter: alpha(opacity=50);
- opacity: 0.5;
- cursor: default;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-
-.selectric-hide-select {
- position: relative;
- overflow: hidden;
- width: 0;
- height: 0;
-}
-.selectric-hide-select select {
- position: absolute;
- left: -100%;
- display: none;
-}
-
-.selectric-input {
- position: absolute !important;
- top: 0 !important;
- left: 0 !important;
- overflow: hidden !important;
- clip: rect(0, 0, 0, 0) !important;
- margin: 0 !important;
- padding: 0 !important;
- width: 1px !important;
- height: 1px !important;
- outline: none !important;
- border: none !important;
- *font: 0/0 a !important;
- background: none !important;
-}
-
-.selectric-temp-show {
- position: absolute !important;
- visibility: hidden !important;
- display: block !important;
-}
-
-/* Items box */
-.selectric-items {
- display: none;
- position: absolute;
- top: 100%;
- left: 0;
- background: #F8F8F8;
- border: 1px solid #C4C4C4;
- z-index: -1;
- box-shadow: 0 0 10px -6px;
-}
-.selectric-items .selectric-scroll {
- height: 100%;
- overflow: auto;
-}
-.selectric-above .selectric-items {
- top: auto;
- bottom: 100%;
-}
-.selectric-items ul, .selectric-items li {
- list-style: none;
- padding: 0;
- margin: 0;
- font-size: 12px;
- line-height: 20px;
- min-height: 20px;
-}
-.selectric-items li {
- display: block;
- padding: 10px;
- color: #666;
- cursor: pointer;
-}
-.selectric-items li.selected {
- background: #E0E0E0;
- color: #444;
-}
-.selectric-items li:hover {
- background: #D5D5D5;
- color: #444;
-}
-.selectric-items .disabled {
- filter: alpha(opacity=50);
- opacity: 0.5;
- cursor: default !important;
- background: none !important;
- color: #666 !important;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-.selectric-items .selectric-group .selectric-group-label {
- font-weight: bold;
- padding-left: 10px;
- cursor: default;
- -webkit-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
- background: none;
- color: #444;
-}
-.selectric-items .selectric-group.disabled li {
- filter: alpha(opacity=100);
- opacity: 1;
-}
-.selectric-items .selectric-group li {
- padding-left: 25px;
-}
diff --git a/public/index.html b/public/index.html
index 55e59c8..d830827 100644
--- a/public/index.html
+++ b/public/index.html
@@ -15,8 +15,6 @@
}
-
-
@@ -42,22 +40,40 @@