From e168d9cd39c38b8e5a1994c8bf11376d26e9ea77 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 23 Apr 2019 18:08:07 +0200 Subject: Use one row per journey instead of split checkin/checkout entries Whether a user is in transit or not is now determined by an entry in the in_transit table instead of a dangling checkin. All completed journeys are stored in the "journeys" table. This does most of the work needed for automatic checkout. However, note that the corresponding worker process is not implemented yet. --- public/static/js/travelynx-actions.js | 18 +++++++++--------- public/static/js/travelynx-actions.min.js | 2 +- public/static/v4 | 1 - public/static/v6 | 1 + 4 files changed, 11 insertions(+), 11 deletions(-) delete mode 120000 public/static/v4 create mode 120000 public/static/v6 (limited to 'public') diff --git a/public/static/js/travelynx-actions.js b/public/static/js/travelynx-actions.js index 3f1eb89..583c806 100644 --- a/public/static/js/travelynx-actions.js +++ b/public/static/js/travelynx-actions.js @@ -1,11 +1,11 @@ -function tvly_run(link, req, redir, err_callback) { +function tvly_run(link, req, err_callback) { var error_icon = 'error'; var progressbar = $('
'); link.hide(); link.after(progressbar); $.post('/action', req, function(data) { if (data.success) { - $(location).attr('href', redir); + $(location).attr('href', data.redirect_to); } else { M.toast({html: error_icon + ' ' + data.error}); progressbar.remove(); @@ -25,7 +25,7 @@ $(document).ready(function() { station: link.data('station'), train: link.data('train'), }; - tvly_run(link, req, '/'); + tvly_run(link, req); }); $('.action-checkout').click(function() { var link = $(this); @@ -34,7 +34,7 @@ $(document).ready(function() { station: link.data('station'), force: link.data('force'), }; - tvly_run(link, req, '/s/' + req.station, function() { + tvly_run(link, req, function() { link.append(' – Ohne Echtzeitdaten auschecken?') link.data('force', true); }); @@ -45,7 +45,7 @@ $(document).ready(function() { action: 'undo', undo_id: link.data('id'), }; - tvly_run(link, req, '/'); + tvly_run(link, req); }); $('.action-cancelled-from').click(function() { var link = $(this); @@ -54,7 +54,7 @@ $(document).ready(function() { station: link.data('station'), train: link.data('train'), }; - tvly_run(link, req, '/'); + tvly_run(link, req); }); $('.action-cancelled-to').click(function() { var link = $(this); @@ -63,19 +63,19 @@ $(document).ready(function() { station: link.data('station'), force: true, }; - tvly_run(link, req, '/'); + tvly_run(link, req); }); $('.action-delete').click(function() { var link = $(this); var req = { action: 'delete', - ids: link.data('id'), + id: link.data('id'), checkin: link.data('checkin'), checkout: link.data('checkout'), }; really_delete = confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden."); if (really_delete) { - tvly_run(link, req, '/history'); + tvly_run(link, req); } }); }); diff --git a/public/static/js/travelynx-actions.min.js b/public/static/js/travelynx-actions.min.js index 57b6284..db9fa1b 100644 --- a/public/static/js/travelynx-actions.min.js +++ b/public/static/js/travelynx-actions.min.js @@ -1 +1 @@ -function tvly_run(n,t,a,c){var i='error',e=$('
');n.hide(),n.after(e),$.post("/action",t,function(t){t.success?$(location).attr("href",a):(M.toast({html:i+" "+t.error}),e.remove(),c&&c(),n.append(" "+i),n.show())})}$(document).ready(function(){$(".action-checkin").click(function(){var t=$(this);tvly_run(t,{action:"checkin",station:t.data("station"),train:t.data("train")},"/")}),$(".action-checkout").click(function(){var t=$(this),n={action:"checkout",station:t.data("station"),force:t.data("force")};tvly_run(t,n,"/s/"+n.station,function(){t.append(" – Ohne Echtzeitdaten auschecken?"),t.data("force",!0)})}),$(".action-undo").click(function(){var t=$(this);tvly_run(t,{action:"undo",undo_id:t.data("id")},"/")}),$(".action-cancelled-from").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_from",station:t.data("station"),train:t.data("train")},"/")}),$(".action-cancelled-to").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_to",station:t.data("station"),force:!0},"/")}),$(".action-delete").click(function(){var t=$(this),n={action:"delete",ids:t.data("id"),checkin:t.data("checkin"),checkout:t.data("checkout")};really_delete=confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden."),really_delete&&tvly_run(t,n,"/history")})}); +function tvly_run(t,n,a){var c='error',i=$('
');t.hide(),t.after(i),$.post("/action",n,function(n){n.success?$(location).attr("href",n.redirect_to):(M.toast({html:c+" "+n.error}),i.remove(),a&&a(),t.append(" "+c),t.show())})}$(document).ready(function(){$(".action-checkin").click(function(){var t=$(this);tvly_run(t,{action:"checkin",station:t.data("station"),train:t.data("train")})}),$(".action-checkout").click(function(){var t=$(this),n={action:"checkout",station:t.data("station"),force:t.data("force")};tvly_run(t,n,function(){t.append(" – Ohne Echtzeitdaten auschecken?"),t.data("force",!0)})}),$(".action-undo").click(function(){var t=$(this);tvly_run(t,{action:"undo",undo_id:t.data("id")})}),$(".action-cancelled-from").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_from",station:t.data("station"),train:t.data("train")})}),$(".action-cancelled-to").click(function(){var t=$(this);tvly_run(t,{action:"cancelled_to",station:t.data("station"),force:!0})}),$(".action-delete").click(function(){var t=$(this),n={action:"delete",id:t.data("id"),checkin:t.data("checkin"),checkout:t.data("checkout")};really_delete=confirm("Diese Zugfahrt wirklich löschen? Der Eintrag wird sofort aus der Datenbank entfernt und kann nicht wiederhergestellt werden."),really_delete&&tvly_run(t,n)})}); diff --git a/public/static/v4 b/public/static/v4 deleted file mode 120000 index 945c9b4..0000000 --- a/public/static/v4 +++ /dev/null @@ -1 +0,0 @@ -. \ No newline at end of file diff --git a/public/static/v6 b/public/static/v6 new file mode 120000 index 0000000..945c9b4 --- /dev/null +++ b/public/static/v6 @@ -0,0 +1 @@ +. \ No newline at end of file -- cgit v1.2.3