Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dni committed Sep 26, 2024
1 parent adc6479 commit 297785a
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
9 changes: 6 additions & 3 deletions migrations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
async def m001_initial(db):
from lnbits.db import Database


async def m001_initial(db: Database):
await db.execute(
f"""
CREATE TABLE IF NOT EXISTS tipjar.TipJars (
Expand Down Expand Up @@ -26,15 +29,15 @@ async def m001_initial(db):
)


async def m002_add_onchain_limit(db):
async def m002_add_onchain_limit(db: Database):
await db.execute(
"""
ALTER TABLE tipjar.TipJars ADD COLUMN onchain_limit INTEGER;
"""
)


async def m003_tipjar_id_string(db):
async def m003_tipjar_id_string(db: Database):
await db.execute(
"""
ALTER TABLE tipjar.TipJars ALTER COLUMN id TYPE TEXT;
Expand Down
24 changes: 9 additions & 15 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,21 @@ class Tip(BaseModel):
tipjar: str # The ID of the corresponding tip jar


class CreateTipJar(BaseModel):
name: str
wallet: str
webhook: Optional[str]
onchain: Optional[str]
onchain_limit: Optional[int]


class CreateTips(BaseModel):
name: str
sats: str
tipjar: str
message: str


class TipJar(BaseModel):
"""A TipJar represents a user's tip jar"""
class CreateTipJar(BaseModel):
name: str
wallet: str
webhook: Optional[str] = ""
onchain: Optional[str] = ""
onchain_limit: Optional[int] = 0


class TipJar(CreateTipJar):
"""A TipJar represents a user's tip jar"""
id: str
name: str # The name of the donatee
wallet: str # Lightning wallet
onchain: Optional[str] # Watchonly wallet
webhook: Optional[str] # URL to POST tips to
onchain_limit: Optional[int] # Bellow this amount, tips will be offchain only
3 changes: 2 additions & 1 deletion static/js/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ window.app = Vue.createApp({
return {
paymentReq: null,
redirectUrl: null,
tipjarId: tipjarId,
tipDialog: {
show: false,
data: {
Expand All @@ -25,7 +26,7 @@ window.app = Vue.createApp({
{
name: this.tipDialog.data.name,
sats: this.tipDialog.data.sats,
tipjar: '{{ tipjar_id }}',
tipjar: this.tipjarId,
message: this.tipDialog.data.message
}
)
Expand Down
3 changes: 1 addition & 2 deletions static/js/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const mapTipJar = function (obj) {
obj.date = Quasar.utils.date.formatDate(
obj.date = Quasar.date.formatDate(
new Date(obj.time * 1000),
'YYYY-MM-DD HH:mm'
)
Expand Down Expand Up @@ -99,7 +99,6 @@ window.app = Vue.createApp({
this.g.user.wallets[0].inkey
)
.then(function (response) {
console.log(response.data)
for (i = 0; i < response.data.length; i++) {
self.walletLinks.push(response.data[i].id)
}
Expand Down
3 changes: 3 additions & 0 deletions templates/tipjar/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,8 @@ <h5 class="q-my-none">Tip {{ donatee }} some sats!</h5>
</div>

{% endblock %} {% block scripts %}
<script>
const tipjarId = '{{ tipjar_id }}'
</script>
<script src="{{ static_url_for('tipjar/static', 'js/display.js') }}"></script>
{% endblock %}
14 changes: 6 additions & 8 deletions templates/tipjar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ <h5 class="text-subtitle1 q-my-none">TipJars</h5>
<q-table
dense
flat
:data="tipjars"
:rows="tipjars"
row-key="id"
:columns="tipjarsTable.columns"
:pagination.sync="tipjarsTable.pagination"
v-model:pagination="tipjarsTable.pagination"
>
{% raw %}
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width></q-th>
<q-th v-for="col in props.cols" :key="col.name" :props="props">
{{ col.label }}
<span v-text="col.label"></span>
</q-th>
<q-th auto-width></q-th>
</q-tr>
Expand All @@ -55,7 +54,7 @@ <h5 class="text-subtitle1 q-my-none">TipJars</h5>
></q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
{{ col.value }}
<span v-text="col.value"></span>
</q-td>
<q-td auto-width>
<q-btn
Expand All @@ -69,7 +68,6 @@ <h5 class="text-subtitle1 q-my-none">TipJars</h5>
</q-td>
</q-tr>
</template>
{% endraw %}
</q-table>
</q-card-section>
</q-card>
Expand All @@ -89,9 +87,9 @@ <h5 class="text-subtitle1 q-my-none">Tips</h5>
<q-table
dense
flat
:data="tips"
:rows="tips"
:columns="tipsTable.columns"
:pagination.sync="tipsTable.pagination"
v-model:pagination="tipsTable.pagination"
>
{% raw %}
<template v-slot:header="props">
Expand Down

0 comments on commit 297785a

Please sign in to comment.