Browse Source

feat: added fixes to rudimentary web frontend calling /update and displaying the ItuneIDs from the database

main
Björn Kalkbrenner 2 months ago
parent
commit
e3ea0a3328
2 changed files with 36 additions and 6 deletions
  1. +4
    -4
      src/web/index.html
  2. +32
    -2
      src/web/main.js

+ 4
- 4
src/web/index.html View File

@ -40,12 +40,12 @@
<div id="main">
<table class="table">
<tr>
<th scope="col">Item</th>
<th scope="col">Id</th>
<th scope="col">ITunesID</th>
<th scope="col">Positions</th>
</tr>
<tr v-for="item in items">
<td scope="row">{{item.name}}</td>
<td scope="row">{{item.id}}</td>
<td scope="row">{{item.itunesid}}</td>
<td scope="row">{{item.positions}}</td>
</tr>
</table>
</div>

+ 32
- 2
src/web/main.js View File

@ -1,5 +1,9 @@
window.onload = function () {
function updateData(data) {
}
var ItemsVue = new Vue({
el: '#main',
data: {
@ -7,16 +11,42 @@ window.onload = function () {
},
mounted: function () {
var self = this;
function updateItems() {
$.ajax({
url: '/items',
method: 'GET',
success: function (data) {
console.log("finished")
data.forEach(function (element, index) {
self.items.push({
itunesid: element,
positions: ""
})
console.log("---")
console.log(self.items)
})
},
error: function (error) {
console.log(error);
}
});
}
$.ajax({
url: '/rank',
url: '/update',
method: 'GET',
success: function (data) {
self.items = data;
console.log("finished")
updateItems();
},
error: function (error) {
console.log(error);
updateItems();
}
});
}
});

Loading…
Cancel
Save