Comparing version 0.5.0 to 0.5.1
{ | ||
"name": "gpxload", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "GPXLoad: GPX file Import / Export and API plugin for SignalK Server.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -67,2 +67,26 @@ core-js@2.5.7 | ||
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF | ||
THIS SOFTWARE. | ||
THIS SOFTWARE. | ||
hammerjs@2.0.8 | ||
MIT | ||
The MIT License (MIT) | ||
Copyright (C) 2011-2014 by Jorik Tangelder (Eight Media) | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
# GPXLoad: signalk-server-plugin | ||
GPX file Import / Export and API plugin for SignalK Server. | ||
**GPX file Import / Export** and **resource API provider** plugin for **Signal K Server**. | ||
@@ -14,2 +14,12 @@ SignalK server plugin and WebApp that: | ||
*v0.5.1* | ||
- Added *Manage Resources* screen to allow deletion of resources. | ||
- Set a route as the *Active Route* | ||
- Deleting a Route will also delete the associated Start / End waypoints. | ||
*v0.5.0* | ||
- Added support for SignalK HTTP API PUT actions to enable applications to update / delete resources. | ||
@@ -20,3 +30,3 @@ | ||
- Removed support for resource UUIDs that do not strictly align to the Signal K schema and use the *urn:mrn:signalk:uuid:* prefix. | ||
- v0.5.0 removed support for resource UUIDs that do not strictly align to the Signal K schema and use the *urn:mrn:signalk:uuid:* prefix. | ||
@@ -91,3 +101,4 @@ This will impact resources uploaded from GPX files with versions of GPXLoad prior to 0.4.0. Affected reources will need to be re-imported. | ||
} | ||
}``` | ||
} | ||
``` | ||
@@ -105,3 +116,49 @@ - Supplying a *null* value will DELETE the resource if the configuration is set to allow delete operations. | ||
} | ||
}``` | ||
} | ||
``` | ||
**Signal K APIs:** | ||
GPXLoad interacts with the following Signal K APIs: | ||
*HTTP:* | ||
Acts as a provider for the following paths: | ||
``` | ||
/signalk/v1/api/resources/routes | ||
/signalk/v1/api/resources/routes/<uuid> | ||
/signalk/v1/api/resources/waypoints | ||
/signalk/v1/api/resources/waypoints/<uuid> | ||
/signalk/v1/api/resources/tracks | ||
/signalk/v1/api/resources/tracks/<uuid>``` | ||
*Stream:* | ||
Sends Deltas for the following paths: | ||
``` | ||
resources.routes.<uuid> | ||
resources.waypoints.<uuid> | ||
resources.tracks.<uuid> | ||
navigation.course.activeRoute.href``` | ||
which populate the corresponding HTTP paths: | ||
``` | ||
/signalk/v1/api/resources/routes | ||
/signalk/v1/api/resources/waypoints | ||
/signalk/v1/api/resources/tracks | ||
/signalk/v1/api/vessels/self/navigation/course/activeRoute/href``` | ||
@@ -38,2 +38,3 @@ /* | ||
const apiUri='/api' | ||
const manageUri='/manage' | ||
const savePath= app.config.configPath + '/resources' | ||
@@ -150,2 +151,40 @@ const resTypes= { | ||
}) | ||
// ** manage resources ** | ||
router.post(manageUri, (req, res) => { | ||
if(!req.body.action) { | ||
res.status(401) | ||
res.send({error: true, message: `${plugin.id}: Invalid request data received!`}) | ||
} | ||
else { | ||
switch(req.body.action) { | ||
case 'activeRoute': | ||
let val= [{path: req.body.path, value: req.body.value}] | ||
app.debug(`****** Sending Delta: ******`) | ||
app.debug(JSON.stringify({updates: [ {values: val} ] })) | ||
app.handleMessage(plugin.id, {updates: [ {values: val} ] }) | ||
break | ||
case 'delete': | ||
let r={} | ||
r.type= req.body.value.type.slice(0,req.body.value.type.length-1) | ||
r.id= req.body.value.value.uuid | ||
r.value= null | ||
app.debug(r) | ||
if(persist(r)) { return { state: 'COMPLETED' } } | ||
else { | ||
return { | ||
state: 'COMPLETED', | ||
resultStatus: 502, | ||
message: `Invalid resource data values!` | ||
} | ||
} | ||
break | ||
default: | ||
res.status(401) | ||
res.send({error: true, message: `${plugin.id}: Invalid request data received!`}) | ||
} | ||
res.status(200) | ||
res.send({error: false, message: `${plugin.id}: OK`}) | ||
} | ||
}) | ||
@@ -360,2 +399,25 @@ // ** return plugin information ** | ||
if(r.value===null) { // ** delete file ** | ||
if(r.type=='route') { // for route delete start & end waypoints | ||
// get start / end waypoint uuids | ||
let w= getPersistedResources('route', fname) | ||
if(w.start) { | ||
app.debug(`** ${action} Start waypoint: ${w.start} **`) | ||
let wf= w.start.substring(w.start.lastIndexOf(':')+1) | ||
let wp= path.join(resTypes['waypoint'].path, wf) | ||
fs.unlink(wp, err=> { | ||
if(err) { app.debug('Error deleting file!') } | ||
else { sendDelta( {id: w.start, type: 'waypoint', value: null}) } | ||
}) | ||
} | ||
if(w.start) { | ||
app.debug(`** ${action} End waypoint: ${w.end} **`) | ||
wf= w.end.substring(w.end.lastIndexOf(':')+1) | ||
wp= path.join(resTypes['waypoint'].path, wf) | ||
fs.unlink(wp, err=> { | ||
if(err) { app.debug('Error deleting file!') } | ||
else { sendDelta( {id: w.end, type: 'waypoint', value: null}) } | ||
}) | ||
} | ||
} | ||
fs.unlink(p, err=> { | ||
@@ -366,4 +428,5 @@ if(err) { app.debug('Error deleting file!') } | ||
sendDelta(r) | ||
} | ||
else { | ||
else { // ** add / update file | ||
if( !validateData(r) ) { return false } | ||
@@ -376,5 +439,3 @@ // ** test for valid SignalK value ** | ||
sendDelta(r) | ||
if(r.type=='route') { | ||
r.waypoints.forEach( w=> { persist(w) }) | ||
} | ||
if(r.type=='route') { r.waypoints.forEach( w=> { persist(w) }) } | ||
} | ||
@@ -381,0 +442,0 @@ return true; |
Sorry, the diff of this file is not supported yet
2535519
1464
161