diff --git a/app.py b/app.py index 0f62dda..2914505 100644 --- a/app.py +++ b/app.py @@ -3,10 +3,15 @@ from flask import Flask, render_template, request app = Flask(__name__) @app.get("/") -def hello_world(): +def get_owned(): return render_template('owned.jinja') +@app.get("/wishlist") +def get_wishlist(): + return render_template('wishlist.jinja') + @app.get("/boardgame") def get_boardgame(): boardgame_id = request.args.get('id', '') - return render_template('boardgame.jinja') \ No newline at end of file + return render_template('boardgame.jinja') + diff --git a/static/main.js b/static/main.js index 14e4f8a..970c882 100644 --- a/static/main.js +++ b/static/main.js @@ -32,18 +32,63 @@ function add_boardgame_row(html_tbody, boardgame_json) { row.onclick = function(){ window.location.href = '/boardgame?id=' + boardgame_json.id} } +async function loadWishlistedGames() { + + var wishlist_priorities = [1,2,3,4] + + jQuery.each(wishlist_priorities, function(index, item){ + + var boardgame_datatable = new DataTable('#wishlist_table'+item, { + ajax: { + url: api_url + '/wishlist?priority='+item, + dataSrc: '' + }, + columns: [ + { + data: 'wishlist_priority' + }, + { + data: 'thumbnail_url', + render: function (data,type){ + return '' + } + }, + { + data: 'name' + }, + { + data: 'description' + }, + { + data: 'weight' + } + ], + columnDefs: [ + { + target: 0, + visible: false + } + ], + order: [[2, 'asc']] + }); + + $('#wishlist_table'+item).on('click', 'tbody tr', function() { + var boardgame_id = boardgame_datatable.row(this).data().id; + window.location.href = "/boardgame?id=" + boardgame_id + }) + }); + + +} async function loadOwnedGames() { - var boardgame_datatable = new DataTable('#boardgame_table', { + var boardgame_datatable = new DataTable('.boardgame_table', { ajax: { url: api_url + '/owned', dataSrc: '' }, columns: [ - { - data: 'id' - }, { data: 'thumbnail_url', render: function (data,type){ @@ -60,18 +105,11 @@ async function loadOwnedGames() { data: 'weight' } ], - columnDefs: [ - { - target: 0, - visible: false, - searchable: false - } - ], - order: [[2, 'asc']] + order: [[1, 'asc']] }); - $('#boardgame_table').on('click', 'tbody tr', function() { + $('.boardgame_table').on('click', 'tbody tr', function() { var boardgame_id = boardgame_datatable.row(this).data().id; window.location.href = "/boardgame?id=" + boardgame_id }) diff --git a/templates/owned.jinja b/templates/owned.jinja index 7500cd8..aa79070 100644 --- a/templates/owned.jinja +++ b/templates/owned.jinja @@ -7,18 +7,15 @@
- +
- - -
ID Thumbnail Naam Beschrijving Moeilijkheid
diff --git a/templates/wishlist.jinja b/templates/wishlist.jinja new file mode 100644 index 0000000..c37a0fd --- /dev/null +++ b/templates/wishlist.jinja @@ -0,0 +1,67 @@ +{% extends "base.jinja" %} + + +{% block body %} + + + + +
+ + + + + + + + + + +
wishlist_priorityThumbnailNaamBeschrijvingMoeilijkheid
+
+ +
+ + + + + + + + + + +
wishlist_priorityThumbnailNaamBeschrijvingMoeilijkheid
+
+ +
+ + + + + + + + + + +
wishlist_priorityThumbnailNaamBeschrijvingMoeilijkheid
+
+ +
+ + + + + + + + + + +
wishlist_priorityThumbnailNaamBeschrijvingMoeilijkheid
+
+ + + +{% endblock body %} \ No newline at end of file