This commit is contained in:
parent
b735dcc0b8
commit
5d5c9d9f37
@ -19,25 +19,12 @@ Date.prototype.toJSONLocal = (function() {
|
|||||||
};
|
};
|
||||||
}())
|
}())
|
||||||
|
|
||||||
const query_nominatim = (q,f)=>{
|
const query_nominatim = (q,f) => axios.get('/api/place/'+q).then(res=>res.data).then(res=>res.filter(f))
|
||||||
const ENDPOINT = '/api/place/'+q;
|
const query_flight = (q) => axios.get('/api/flight/'+q).then(res=>res.data)
|
||||||
return axios.get(ENDPOINT).then(res=>res.data).then(res=>res.filter(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
const query_flight = (q)=>{
|
const is_restauration_type = e => ["restaurant", "cafe", "pub", "bar", "fast_food", "food_court"].indexOf(e.type)!=-1;
|
||||||
const ENDPOINT = '/api/flight/'+q;
|
|
||||||
return axios.get(ENDPOINT).then(res=>res.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
const is_restauration_type = (item)=>{
|
const is_attraction_type = e => ["tourism", "leisure", "place", "amenity", "highway"].indexOf(e.category)!=-1;
|
||||||
const arr = ["restaurant", "cafe", "pub", "bar", "fast_food", "food_court"];
|
|
||||||
return arr.indexOf(item.type)!=-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const is_attraction_type = (item)=>{
|
|
||||||
const arr = ["tourism", "leisure", "place", "amenity", "highway"];
|
|
||||||
return arr.indexOf(item.category)!=-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const icon_type = (item)=>{
|
const icon_type = (item)=>{
|
||||||
let t = item.type
|
let t = item.type
|
||||||
@ -111,7 +98,7 @@ const app = new Vue({
|
|||||||
window.location.href = '/'+this.journey_id;
|
window.location.href = '/'+this.journey_id;
|
||||||
},
|
},
|
||||||
add_section: function(event){
|
add_section: function(event){
|
||||||
if(this.journey_data.main===undefined) this.journey_data.main=[];
|
if(this.journey_data.main==undefined) this.journey_data.main=[];
|
||||||
this.journey_data.main.push({map:{zoom:2}, hotel:{latlon:[0,0]},places:{restaurants:[],places:[]}});
|
this.journey_data.main.push({map:{zoom:2}, hotel:{latlon:[0,0]},places:{restaurants:[],places:[]}});
|
||||||
},
|
},
|
||||||
next_step: function(){
|
next_step: function(){
|
||||||
@ -242,6 +229,7 @@ const app = new Vue({
|
|||||||
|
|
||||||
save_data: function(){
|
save_data: function(){
|
||||||
this.impexp = window.btoa(JSON.stringify(this.journey_data));
|
this.impexp = window.btoa(JSON.stringify(this.journey_data));
|
||||||
|
console.log(this.journey_data)
|
||||||
axios.post('/api/'+this.journey_id, this.journey_data).then(response => {
|
axios.post('/api/'+this.journey_id, this.journey_data).then(response => {
|
||||||
console.log("Saved...")
|
console.log("Saved...")
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@ -268,7 +256,10 @@ const app = new Vue({
|
|||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
axios.get('/api/'+this.journey_id).then(response =>{
|
axios.get('/api/'+this.journey_id).then(response =>{
|
||||||
|
console.log(response)
|
||||||
|
if(response.data=='') throw "Invalid Journey Data Received";
|
||||||
app.journey_data = response.data;
|
app.journey_data = response.data;
|
||||||
|
|
||||||
for(let e of app.journey_data.main){
|
for(let e of app.journey_data.main){
|
||||||
if(e.dateRange && e.dateRange.length===2){
|
if(e.dateRange && e.dateRange.length===2){
|
||||||
e.dateRange[0]= new Date(e.dateRange[0]);
|
e.dateRange[0]= new Date(e.dateRange[0]);
|
||||||
|
@ -14,8 +14,9 @@ module.exports = (fastify, opts, done) => {
|
|||||||
}
|
}
|
||||||
}).then(res=>reply.send(res.data));
|
}).then(res=>reply.send(res.data));
|
||||||
}else{
|
}else{
|
||||||
reply.send([]);
|
return reply.send([]);
|
||||||
}
|
}
|
||||||
|
return reply
|
||||||
});
|
});
|
||||||
fastify.get('/place/:id', async (req,reply) => {
|
fastify.get('/place/:id', async (req,reply) => {
|
||||||
const ENDPOINT = 'https://nominatim.openstreetmap.org/';
|
const ENDPOINT = 'https://nominatim.openstreetmap.org/';
|
||||||
@ -28,31 +29,32 @@ module.exports = (fastify, opts, done) => {
|
|||||||
}
|
}
|
||||||
}).then(res=>reply.send(res.data));
|
}).then(res=>reply.send(res.data));
|
||||||
}else{
|
}else{
|
||||||
reply.send([]);
|
return reply.send([]);
|
||||||
}
|
}
|
||||||
|
return reply;
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.get('/:id', async (req, reply) => {
|
fastify.get('/:id', async (req, reply) => {
|
||||||
if(req.params.id == undefined){
|
if(req.params.id == undefined)
|
||||||
return reply.code(400).send({error:"No ID query parameter"});
|
return reply.code(400).send({error:"No ID query parameter"});
|
||||||
}
|
|
||||||
|
|
||||||
return fastify.level.db.get(req.params.id, (err, val) => {
|
fastify.level.db.get(req.params.id, (err, val) => {
|
||||||
if(err){
|
if(err){
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
reply.send({name:"New Journey", main:[]});
|
reply.send({name:"New Journey", main:[]});
|
||||||
} else {
|
} else {
|
||||||
|
console.log(JSON.parse(val))
|
||||||
reply.send(JSON.parse(val));
|
reply.send(JSON.parse(val));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return reply
|
||||||
});
|
});
|
||||||
|
|
||||||
fastify.post('/:id', async (req, reply) => {
|
fastify.post('/:id', async (req, reply) => {
|
||||||
if(req.params.id == undefined){
|
if(req.params.id == undefined)
|
||||||
return reply.code(400).send({error:"No ID query parameter"});
|
return reply.code(400).send({error:"No ID query parameter"});
|
||||||
}
|
|
||||||
|
|
||||||
return fastify.level.db.put(req.params.id, JSON.stringify(req.body), (err) => {
|
fastify.level.db.put(req.params.id, JSON.stringify(req.body), (err) => {
|
||||||
if(err){
|
if(err){
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
reply.code(500).send({error:"Error with DB"});
|
reply.code(500).send({error:"Error with DB"});
|
||||||
@ -60,25 +62,8 @@ module.exports = (fastify, opts, done) => {
|
|||||||
reply.send({content:"ok"});
|
reply.send({content:"ok"});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return reply
|
||||||
});
|
});
|
||||||
|
|
||||||
// fastify.delete('/:id',(req, reply) => {
|
|
||||||
// if(req.params.id == undefined){
|
|
||||||
// reply.code(400).send({error:"No ID query parameter"});
|
|
||||||
// } else {
|
|
||||||
// fastify.level.delete(req.params.id,(err) => {
|
|
||||||
// if(err){
|
|
||||||
// console.warn(err);
|
|
||||||
// reply.code(500).send({error:"Error with DB"});
|
|
||||||
// } else {
|
|
||||||
// reply.send({content:"ok"});
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user