From 924d23463c9e1c1da311077bdd87e5ee8d0ac16d Mon Sep 17 00:00:00 2001 From: Petr Balashov Date: Wed, 8 Mar 2017 13:44:29 +0100 Subject: [PATCH 1/2] added shepherd groom delete route --- routes/shepherd.js | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/routes/shepherd.js b/routes/shepherd.js index c581158..5999f86 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -101,6 +101,7 @@ shepherd.setIO = function(io) { }; /* + * type: GET * params: pubkey */ shepherd.get('/cache', function(req, res, next) { @@ -152,6 +153,7 @@ shepherd.get('/cache', function(req, res, next) { }); /* + * type: GET * params: filename */ shepherd.get('/groom', function(req, res, next) { @@ -195,6 +197,51 @@ shepherd.get('/groom', function(req, res, next) { }); /* + * type: DELETE + * params: filename + */ +shepherd.delete('/groom', function(req, res, next) { + var _filename = req.query.filename; + + if (_filename) { + if (fs.existsSync(iguanaDir + '/shepherd/cache-' + _filename + '.json')) { + fs.unlink(kmdDebugLogLocation, function(err) { + if (err) { + var errorObj = { + 'msg': 'error', + 'result': err + }; + + res.end(JSON.stringify(errorObj)); + } else { + var successObj = { + 'msg': 'success', + 'result': 'deleted' + }; + + res.end(JSON.stringify(successObj)); + } + }); + } else { + var errorObj = { + 'msg': 'error', + 'result': 'no file with name ' + _filename + }; + + res.end(JSON.stringify(errorObj)); + } + } else { + var errorObj = { + 'msg': 'error', + 'result': 'no file name provided' + }; + + res.end(JSON.stringify(errorObj)); + } +}); + +/* + * type: POST * params: filename, payload */ shepherd.post('/groom', function(req, res) { @@ -243,6 +290,7 @@ var cacheCallInProgress = false, // TODO: reset calls' states on new /cache call start /* + * type: GET * params: userpass, pubkey */ shepherd.get('/cache-all', function(req, res, next) { @@ -551,6 +599,7 @@ shepherd.get('/cache-all', function(req, res, next) { }); /* + * type: GET * params: userpass, pubkey, coin, address */ shepherd.get('/cache-one', function(req, res, next) { @@ -970,6 +1019,10 @@ shepherd.get('/cache-one', function(req, res, next) { } }); +/* + * type: GET + * params: herd, lastLines + */ shepherd.post('/debuglog', function(req, res) { var _herd = req.body.herdname, _lastNLines = req.body.lastLines, @@ -999,6 +1052,10 @@ shepherd.post('/debuglog', function(req, res) { }); }); +/* + * type: POST + * params: herd + */ shepherd.post('/herd', function(req, res) { console.log('======= req.body ======='); //console.log(req); @@ -1016,6 +1073,10 @@ shepherd.post('/herd', function(req, res) { res.end(JSON.stringify(obj)); }); +/* + * type: POST + * params: herdname + */ shepherd.post('/herdlist', function(req, res) { //console.log('======= req.body ======='); //console.log(req); @@ -1045,6 +1106,9 @@ shepherd.post('/herdlist', function(req, res) { }); }); +/* + * type: POST + */ shepherd.post('/slay', function(req, res) { console.log('======= req.body ======='); //console.log(req); @@ -1060,6 +1124,9 @@ shepherd.post('/slay', function(req, res) { res.end(JSON.stringify(obj)); }); +/* + * type: POST + */ shepherd.post('/setconf', function(req, res) { console.log('======= req.body ======='); //console.log(req); @@ -1075,6 +1142,9 @@ shepherd.post('/setconf', function(req, res) { res.end(JSON.stringify(obj)); }); +/* + * type: POST + */ shepherd.post('/getconf', function(req, res) { console.log('======= req.body ======='); //console.log(req); From 48d665157329faa722930a4fcad49e345f599697 Mon Sep 17 00:00:00 2001 From: pbca26 Date: Wed, 8 Mar 2017 21:03:42 +0300 Subject: [PATCH 2/2] shepherd groom delete upd --- gui/init.js | 2 +- routes/shepherd.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gui/init.js b/gui/init.js index 67077de..cbe133a 100644 --- a/gui/init.js +++ b/gui/init.js @@ -38,4 +38,4 @@ $(document).ready(function() { } sartcheck(); -}); +}); \ No newline at end of file diff --git a/routes/shepherd.js b/routes/shepherd.js index 5999f86..f143356 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -119,7 +119,7 @@ shepherd.get('/cache', function(req, res, next) { res.end(JSON.stringify(errorObj)); } else { var parsedJSON = 'JSON parse error'; - + try { parsedJSON = JSON.parse(data); } catch (e) { @@ -201,11 +201,11 @@ shepherd.get('/groom', function(req, res, next) { * params: filename */ shepherd.delete('/groom', function(req, res, next) { - var _filename = req.query.filename; + var _filename = req.body.filename; if (_filename) { if (fs.existsSync(iguanaDir + '/shepherd/cache-' + _filename + '.json')) { - fs.unlink(kmdDebugLogLocation, function(err) { + fs.unlink(iguanaDir + '/shepherd/cache-' + _filename + '.json', function(err) { if (err) { var errorObj = { 'msg': 'error',