feat: modernize error page (#2949)
* can't figure this out! * raise here so it gets picked up by exceptions * add few more info for error rendering * add a few more checks for browser not fail safe just one more layer * cleaner error display ... hopefully * add go to extension * keep buttons add go to extension * feat: identify extensions that are not installed * fix: status code * fix: full path * add account/logout button if 401 prevent getting stuck * fix: ext access * fix user button * fix: 404 page * fix: json 404 response * fix: dumb rendering * fix: `/api` request always json * fix: extension api path * test: check regtest * test: investgate * something made ws slower? * fix: change error code --------- Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com> Co-authored-by: dni ⚡ <office@dnilabs.com> Co-authored-by: Arc <33088785+arcbtc@users.noreply.github.com>
This commit is contained in:
co-authored by
Vlad Stan
dni ⚡
Arc
parent
eeca7de10d
commit
4511891297
+82
-42
@@ -1,57 +1,97 @@
|
||||
{% extends "public.html" %} {% block page %}
|
||||
<div class="row q-col-gutter-md justify-center">
|
||||
<div class="col-12 col-md-7 col-lg-6 q-gutter-y-md">
|
||||
<q-card class="q-pa-lg">
|
||||
<q-card-section class="q-pa-none">
|
||||
<center>
|
||||
<h3 class="q-my-none">Error</h3>
|
||||
{% extends "public.html" %} {% block page_container %}
|
||||
<q-page-container>
|
||||
<q-page
|
||||
class="q-px-md q-py-lg content-center"
|
||||
:class="{'q-px-lg': $q.screen.gt.xs}"
|
||||
>
|
||||
{% block page %}
|
||||
<div class="text-center q-pa-md flex flex-center">
|
||||
<div>
|
||||
<div class="error-code" v-text="statusCode"></div>
|
||||
|
||||
<div class="error-message" v-text="message"></div>
|
||||
|
||||
<div
|
||||
class="q-mx-auto q-mt-lg justify-center"
|
||||
style="width: max-content"
|
||||
>
|
||||
<q-btn
|
||||
v-if="isExtension"
|
||||
color="primary"
|
||||
@click="goToExtension"
|
||||
label="Go To Extension"
|
||||
class="q-mb-lg full-width"
|
||||
></q-btn>
|
||||
<br />
|
||||
<q-icon
|
||||
name="warning"
|
||||
class="text-grey"
|
||||
style="font-size: 20rem"
|
||||
></q-icon>
|
||||
|
||||
<h5 class="q-my-none">{{ err }}</h5>
|
||||
|
||||
<br />
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<q-btn
|
||||
@click="goBack"
|
||||
color="grey"
|
||||
outline
|
||||
label="Back"
|
||||
style="width: 100%"
|
||||
></q-btn>
|
||||
</div>
|
||||
<div class="col">
|
||||
<q-btn
|
||||
@click="goHome"
|
||||
color="grey"
|
||||
outline
|
||||
label="Home"
|
||||
style="width: 100%"
|
||||
></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</center>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<q-btn color="primary" href="/" label="Go Home"></q-btn>
|
||||
<span class="q-mx-md">OR</span>
|
||||
<q-btn color="primary" @click="goBack" label="Go Back"></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
</q-page>
|
||||
</q-page-container>
|
||||
{% endblock %} {% block scripts %}
|
||||
<style>
|
||||
.error-code {
|
||||
font-size: clamp(15vh, 20vw, 30vh);
|
||||
}
|
||||
|
||||
.error-message {
|
||||
font-size: clamp(1.5rem, calc(1.5 / 10 * 20vw), 3.75rem);
|
||||
font-weight: 300;
|
||||
opacity: 0.4;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.app = Vue.createApp({
|
||||
el: '#vue',
|
||||
mixins: [window.windowMixin],
|
||||
data() {
|
||||
return {
|
||||
err: null,
|
||||
statusCode: null,
|
||||
message: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goBack: function () {
|
||||
window.history.back()
|
||||
},
|
||||
goHome: function () {
|
||||
window.location.href = '/'
|
||||
},
|
||||
goToExtension() {
|
||||
window.location.href = `/extensions#${this.extension}`
|
||||
},
|
||||
logOut() {
|
||||
LNbits.utils
|
||||
.confirmDialog(
|
||||
'Do you really want to logout?'
|
||||
)
|
||||
.onOk( async () => {
|
||||
try {
|
||||
await LNbits.api.logout()
|
||||
window.location = '/'
|
||||
} catch (e) {
|
||||
LNbits.utils.notifyApiError(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
isExtension() {
|
||||
if (this.statusCode != 403) return false
|
||||
if (this.message.startsWith('Extension ')) return true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.err = '{{ err }}'
|
||||
this.statusCode = '{{ status_code }}' || 404
|
||||
this.message = String({{ message | tojson }}) || 'Page not found'
|
||||
if (this.isExtension) {
|
||||
this.extension = this.message.match(/'([^']+)'/)[1]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user