Frontend coins and charts

This commit is contained in:
2021-07-14 10:12:22 -04:00
parent 4a321b4105
commit 2859574848
5 changed files with 368 additions and 41 deletions

View File

@ -37,23 +37,26 @@
api: '{{$urls->api}}',
base: '{{$urls->base}}'
},
table: null,
modal: null,
setup: function(table, modal) {
this.table = table
this.modal = modal
table.find('plus icon').css('cursor', 'pointer').click(() => {
addCoin()
})
table.find('tbody').append($('<div></div>').attr('class', 'ui active dimmer').append(
$('<div></div>').attr('class', 'ui loader')
))
table.find('.plus.icon').css('cursor', 'pointer').click((e) => {
this.add()
})
this.load(table)
this.load()
},
load: function(table) {
load: function() {
const url = this.urls.api + '/coins'
const table = this.table
const body = table.find('tbody')
table.find('tbody').append($('<div></div>').attr('class', 'ui active dimmer').append(
$('<div></div>').attr('class', 'ui loader')
))
$.getJSON(url, (data) => {
body.html('')
data.coins.forEach((v) => {
@ -95,6 +98,12 @@
).append(
$('<input />').attr('type', 'text').attr('name', 'name')
)
).append(
$('<div></div>').attr('class', 'field').append(
$('<label></label>').html('Identificador')
).append(
$('<input />').attr('type', 'text').attr('name', 'identifier')
)
).append(
$('<div></div>').attr('class', 'field').append(
$('<label></label>').html('Código')
@ -134,6 +143,7 @@
const fields = [
'name',
'code',
'identifier',
'prefix',
'suffix',
'decimals',
@ -149,7 +159,7 @@
data = JSON.stringify(data)
$.post(url, data, (response) => {
if (response.created === true) {
return reload()
return this.load()
}
}, 'json')
}
@ -226,7 +236,7 @@
data: data,
success: (response) => {
if (response.edited === true) {
return reload()
return this.load()
}
},
dataType: 'json'
@ -244,7 +254,7 @@
success: (response) => {
console.debug(response)
if (response.deleted === true) {
return reload()
return this.load()
}
},
dataType: 'json'