chore: code clean-up
This commit is contained in:
parent
5895081dac
commit
7cfb12011c
2 changed files with 9 additions and 219 deletions
|
|
@ -95,7 +95,7 @@ const market = async () => {
|
|||
activeProduct: null,
|
||||
pool: null,
|
||||
config: null,
|
||||
configDialog: {
|
||||
configData: {
|
||||
show: false,
|
||||
data: {
|
||||
name: null,
|
||||
|
|
@ -329,8 +329,8 @@ const market = async () => {
|
|||
editConfigDialog() {
|
||||
if (this.canEditConfig && this.config?.opts) {
|
||||
let { name, about, ui } = this.config.opts
|
||||
this.configDialog.data = { name, about, ui }
|
||||
this.configDialog.data.identifier = this.config?.d
|
||||
this.configData.data = { name, about, ui }
|
||||
this.configData.data.identifier = this.config?.d
|
||||
}
|
||||
this.openConfigDialog()
|
||||
},
|
||||
|
|
@ -343,15 +343,15 @@ const market = async () => {
|
|||
})
|
||||
return
|
||||
}
|
||||
this.configDialog.show = true
|
||||
this.configData.show = true
|
||||
},
|
||||
updateUiConfig(configData) {
|
||||
console.log('### updateUiConfig', configData)
|
||||
},
|
||||
async sendConfig() {
|
||||
let { name, about, ui } = this.configDialog.data
|
||||
let { name, about, ui } = this.configData.data
|
||||
let merchants = Array.from(this.pubkeys)
|
||||
let identifier = this.configDialog.data.identifier ?? crypto.randomUUID()
|
||||
let identifier = this.configData.data.identifier ?? crypto.randomUUID()
|
||||
let event = {
|
||||
...(await NostrTools.getBlankEvent()),
|
||||
kind: 30019,
|
||||
|
|
@ -385,12 +385,12 @@ const market = async () => {
|
|||
identifier: identifier,
|
||||
relays: Array.from(this.relays)
|
||||
})
|
||||
this.config = this.configDialog.data
|
||||
this.config = this.configData.data
|
||||
this.resetConfig()
|
||||
return
|
||||
},
|
||||
resetConfig() {
|
||||
this.configDialog = {
|
||||
this.configData = {
|
||||
show: false,
|
||||
identifier: null,
|
||||
data: {
|
||||
|
|
|
|||
|
|
@ -1,160 +1,5 @@
|
|||
{% extends "public.html" %} {% block page %}
|
||||
<q-layout view="lHh Lpr lff">
|
||||
<!-- <q-header reveal bordered class="bg-marginal-bg">
|
||||
<q-toolbar>
|
||||
<q-btn flat @click="drawerLeft = !drawerLeft" round dense icon="menu" />
|
||||
<q-toolbar-title>Header</q-toolbar-title>
|
||||
<q-btn flat @click="drawerRight = !drawerRight" round dense icon="menu" />
|
||||
</q-toolbar>
|
||||
</q-header> -->
|
||||
<!-- <q-drawer v-model="drawer" side="left"></q-drawer>
|
||||
<q-drawer v-model="drawer" side="right"></q-drawer> -->
|
||||
<!-- <q-drawer v-model="drawer" side="left">
|
||||
<q-toolbar class="bg-primary text-white shadow-2">
|
||||
<q-toolbar-title>Settings</q-toolbar-title>
|
||||
<q-btn flat round dense icon="close" @click="drawer = !drawer"></q-btn>
|
||||
</q-toolbar>
|
||||
<div>
|
||||
<div v-if="account" class="bg-transparent q-ma-md">
|
||||
<q-avatar size="56px" class="q-mb-sm">
|
||||
<img :src="accountMetadata?.picture || '/nostrmarket/static/images/blank-avatar.webp'" />
|
||||
</q-avatar>
|
||||
{%raw%}
|
||||
<div class="text-weight-bold">
|
||||
{{ `${account.pubkey.slice(0, 5)}...${account.pubkey.slice(-5)}` }}
|
||||
</div>
|
||||
<div v-if="accountMetadata && accountMetadata.name">
|
||||
{{ accountMetadata.name }}
|
||||
</div>
|
||||
{%endraw%}
|
||||
<q-btn label="Delete data" class="q-mt-md" color="red" @click="deleteAccount"><q-tooltip>Delete account
|
||||
data</q-tooltip></q-btn>
|
||||
</div>
|
||||
<div v-else class="q-pa-md">
|
||||
<q-btn label="Login" class="q-mt-md" color="primary" @click="accountDialog.show = true"><q-tooltip>Login or
|
||||
Create account</q-tooltip></q-btn>
|
||||
</div>
|
||||
<q-separator></q-separator>
|
||||
</div>
|
||||
<div class="q-pa-md">
|
||||
<q-list padding>
|
||||
<q-expansion-item expand-separator icon="perm_identity" label="Merchants" caption="Add/Remove pubkeys">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<q-input filled v-model="inputPubkey" @keydown.enter="addPubkey(null)" type="text" label="Pubkey/Npub"
|
||||
hint="Add merchants">
|
||||
<q-btn @click="addPubkey(null)" dense flat icon="add"></q-btn>
|
||||
</q-input>
|
||||
<q-list class="q-mt-md">
|
||||
<q-item v-for="pub in Array.from(pubkeys)" :key="pub">
|
||||
{%raw%}
|
||||
<q-item-section avatar>
|
||||
<q-avatar>
|
||||
<img v-if="profiles.get(pub) && profiles.get(pub)?.picture" :src="profiles.get(pub).picture" />
|
||||
<img v-else src="/nostrmarket/static/images/blank-avatar.webp" />
|
||||
</q-avatar>
|
||||
</q-item-section>
|
||||
<q-item-section>
|
||||
<q-item-label v-if="profiles.get(pub) && profiles.get(pub)?.name">{{ profiles.get(pub).name
|
||||
}}</q-item-label>
|
||||
<q-item-label v-else>{{ `${pub.slice(0, 5)}...${pub.slice(-5)}`
|
||||
}}</q-item-label>
|
||||
<q-tooltip>{{ pub }}</q-tooltip>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-btn class="gt-xs" size="12px" flat dense round icon="delete" @click="removePubkey(pub)" />
|
||||
</q-item-section>
|
||||
{%endraw%}
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
<q-expansion-item expand-separator icon="perm_identity" label="Relays" caption="Add/Remove relays">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<q-input filled v-model="inputRelay" @keydown.enter="addRelay" type="text" label="Relay URL"
|
||||
hint="Add relays">
|
||||
<q-btn @click="addRelay" dense flat icon="add"></q-btn>
|
||||
</q-input>
|
||||
<q-list dense class="q-mt-md">
|
||||
<q-item v-for="url in Array.from(relays)" :key="url">
|
||||
{%raw%}
|
||||
<q-item-section>
|
||||
<q-item-label>{{ url }}</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section side>
|
||||
<q-btn class="gt-xs" size="12px" flat dense round icon="delete" @click="removeRelay(url)" />
|
||||
</q-item-section>
|
||||
{%endraw%}
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
<q-expansion-item expand-separator icon="perm_identity" label="Marketplace" caption="Marketplace info">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<q-list class="q-mt-md">
|
||||
<q-item-label header>Information</q-item-label>
|
||||
<q-item>
|
||||
{%raw%}
|
||||
<q-item-section>
|
||||
<q-item-label>Marketplace name</q-item-label>
|
||||
<q-item-label caption>{{ config?.opts?.name }}</q-item-label>
|
||||
</q-item-section>
|
||||
{%endraw%}
|
||||
</q-item>
|
||||
<q-item>
|
||||
{%raw%}
|
||||
<q-item-section>
|
||||
<q-item-label>About the marketplace</q-item-label>
|
||||
<q-item-label caption>{{ config?.opts?.about }}</q-item-label>
|
||||
</q-item-section>
|
||||
{%endraw%}
|
||||
</q-item>
|
||||
<q-item-label header>UI Config</q-item-label>
|
||||
<q-item>
|
||||
{%raw%}
|
||||
<q-item-section>
|
||||
<q-item-label>Logo</q-item-label>
|
||||
<q-item-label caption>{{ config?.opts?.ui?.picture }}</q-item-label>
|
||||
</q-item-section>
|
||||
{%endraw%}
|
||||
</q-item>
|
||||
<q-item>
|
||||
{%raw%}
|
||||
<q-item-section>
|
||||
<q-item-label>Banner URL</q-item-label>
|
||||
<q-item-label caption>{{ config?.opts?.ui?.banner }}</q-item-label>
|
||||
</q-item-section>
|
||||
{%endraw%}
|
||||
</q-item>
|
||||
<q-item>
|
||||
{%raw%}
|
||||
<q-item-section>
|
||||
<q-item-label>Theme</q-item-label>
|
||||
<q-item-label caption>{{ config?.opts?.ui?.theme }}</q-item-label>
|
||||
</q-item-section>
|
||||
{%endraw%}
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-card-section>
|
||||
<q-card-actions class="q-mx-md" align="right">
|
||||
<q-btn v-if="naddr" label="Naddr" class="q-mt-md" color="primary" @click="copyText(naddr)"><q-tooltip>Copy
|
||||
the
|
||||
naddr for this configuration</q-tooltip></q-btn>
|
||||
<q-btn v-if="naddr && canEditConfig" label="Edit" class="q-mt-md" color="primary"
|
||||
@click="editConfigDialog"><q-tooltip>Edit configuration</q-tooltip></q-btn>
|
||||
<q-btn label="New" class="q-mt-md" color="primary" @click="openConfigDialog"><q-tooltip>Create a new
|
||||
configuration</q-tooltip></q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
</q-list>
|
||||
</div>
|
||||
</q-drawer> -->
|
||||
<!-- <q-drawer v-model="drawer" side="right"></q-drawer> -->
|
||||
<q-page-container class="q-mr-md">
|
||||
<div class="row q-mb-sm">
|
||||
<div class="col-lg-2 col-md-1 col-sm-0"></div>
|
||||
|
|
@ -264,7 +109,7 @@
|
|||
|
||||
<market-config v-if="activePage === 'market-config'" :merchants="merchants" @add-merchant="addMerchant"
|
||||
@remove-merchant="removeMerchant" :relays="relays" @add-relay="addRelay" @remove-relay="removeRelay"
|
||||
:config="configDialog" @ui-config-update="updateUiConfig"></market-config>
|
||||
:config="configData" @ui-config-update="updateUiConfig"></market-config>
|
||||
|
||||
<user-config v-else-if="activePage === 'user-config'"></user-config>
|
||||
|
||||
|
|
@ -301,61 +146,6 @@
|
|||
</div>
|
||||
</q-page-container>
|
||||
|
||||
<!-- ACCOUNT DIALOG -->
|
||||
<q-dialog v-model="accountDialog.show" position="top">
|
||||
<q-card>
|
||||
<q-card-section class="row">
|
||||
<div class="text-h6">Account Setup</div>
|
||||
<q-space></q-space>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<p>Enter your Nostr private key or generate a new one.</p>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section class="q-pt-none">
|
||||
<q-input dense label="Nsec/Hex" v-model="accountDialog.data.key" autofocus @keyup.enter="createAccount"
|
||||
:error="accountDialog.data.key && !isValidAccountKey" hint="Enter you private key"></q-input>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-actions align="right" class="text-primary">
|
||||
<q-btn v-if="isValidAccountKey" label="Login" color="primary" @click="() => createAccount()"></q-btn>
|
||||
<q-btn v-else flat label="Generate" @click="generateKeyPair"></q-btn>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Close</q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<!-- Config/Naddr Dialog -->
|
||||
<q-dialog v-model="configDialog.show" position="top">
|
||||
<q-card>
|
||||
<q-card-section class="row items-center q-pb-none">
|
||||
<div class="text-h6">Customize the Marketplace</div>
|
||||
</q-card-section>
|
||||
<q-card-section>
|
||||
<p>Create an Nostr event with Market info</p>
|
||||
<small> It will include all merchants on your merchants list and relays </small>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section class="q-pt-none">
|
||||
<q-form @submit="sendConfig" class="q-gutter-md">
|
||||
<q-input filled dense v-model.trim="configDialog.data.name" label="Marketplace Name"></q-input>
|
||||
<q-input filled dense v-model.trim="configDialog.data.about" label="Description"></q-input>
|
||||
<p>Customize UI</p>
|
||||
<q-input filled dense v-model.trim="configDialog.data.ui.picture" label="Marketplace Logo"
|
||||
hint="URL to a logo image"></q-input>
|
||||
<q-input filled dense v-model.trim="configDialog.data.ui.banner" label="Marketplace banner"
|
||||
hint="URL to a header/banner image (max. 250px height)"></q-input>
|
||||
<q-select filled dense v-model="configDialog.data.ui.theme" :options="g.allowedThemes" label="Theme">
|
||||
<template v-slot:prepend>
|
||||
<q-icon name="palette" />
|
||||
</template>
|
||||
</q-select>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn unelevated color="primary" type="submit">Publish</q-btn>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Cancel</q-btn>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<!-- END CHECKOUT DIALOG -->
|
||||
<!-- INVOICE DIALOG -->
|
||||
<q-dialog v-model="qrCodeDialog.show" position="top">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue