feat: rerender page

pull/6775/head
NGPixel 1 year ago
parent add3631b22
commit a9784c34ea
No known key found for this signature in database
GPG Key ID: B755FB6870B30F63

@ -603,9 +603,9 @@ export default {
} }
}, },
/** /**
* RENDER PAGE * RERENDER PAGE
*/ */
async renderPage (obj, args, context) { async rerenderPage (obj, args, context) {
try { try {
const page = await WIKI.db.pages.query().findById(args.id) const page = await WIKI.db.pages.query().findById(args.id)
if (!page) { if (!page) {
@ -613,7 +613,7 @@ export default {
} }
await WIKI.db.pages.renderPage(page) await WIKI.db.pages.renderPage(page)
return { return {
operation: generateSuccess('Page rendered successfully.') operation: generateSuccess('Page rerendered successfully.')
} }
} catch (err) { } catch (err) {
return generateError(err) return generateError(err)

@ -191,8 +191,8 @@ extend type Mutation {
rebuildPageTree: DefaultResponse rebuildPageTree: DefaultResponse
renderPage( rerenderPage(
id: Int! id: UUID!
): DefaultResponse ): DefaultResponse
restorePage( restorePage(

@ -1798,6 +1798,8 @@
"profile.title": "Profile", "profile.title": "Profile",
"profile.uploadNewAvatar": "Upload New Image", "profile.uploadNewAvatar": "Upload New Image",
"profile.viewPublicProfile": "View Public Profile", "profile.viewPublicProfile": "View Public Profile",
"renderPageDialog.loading": "Rendering page...",
"renderPageDialog.success": "Page rerendered successfully.",
"search.editorAny": "Any editor", "search.editorAny": "Any editor",
"search.emptyQuery": "Enter a query in the search field above and press Enter.", "search.emptyQuery": "Enter a query in the search field above and press Enter.",
"search.filterEditor": "Editor", "search.filterEditor": "Editor",

@ -100,11 +100,11 @@
q-icon(color='deep-orange-9', name='las la-atom', size='sm') q-icon(color='deep-orange-9', name='las la-atom', size='sm')
q-item-section q-item-section
q-item-label Convert Page q-item-label Convert Page
q-item(clickable, v-if='userStore.can(`edit:pages`)') q-item(clickable, v-if='userStore.can(`edit:pages`)', @click='rerenderPage')
q-item-section.items-center(avatar) q-item-section.items-center(avatar)
q-icon(color='deep-orange-9', name='las la-magic', size='sm') q-icon(color='deep-orange-9', name='las la-magic', size='sm')
q-item-section q-item-section
q-item-label Re-render Page q-item-label Rerender Page
q-item(clickable) q-item(clickable)
q-item-section.items-center(avatar) q-item-section.items-center(avatar)
q-icon(color='deep-orange-9', name='las la-sun', size='sm') q-icon(color='deep-orange-9', name='las la-sun', size='sm')
@ -204,6 +204,17 @@ function viewPageSource () {
siteStore.$patch({ overlay: 'PageSource', overlayOpts: { } }) siteStore.$patch({ overlay: 'PageSource', overlayOpts: { } })
} }
function rerenderPage () {
$q.dialog({
component: defineAsyncComponent(() => import('../components/RerenderPageDialog.vue')),
componentProps: {
id: pageStore.id
}
}).onOk(() => {
pageStore.pageLoad({ id: pageStore.id })
})
}
function duplicatePage () { function duplicatePage () {
$q.dialog({ $q.dialog({
component: defineAsyncComponent(() => import('../components/TreeBrowserDialog.vue')), component: defineAsyncComponent(() => import('../components/TreeBrowserDialog.vue')),

@ -0,0 +1,81 @@
<template lang="pug">
q-dialog(ref='dialogRef', @hide='onDialogHide' position='bottom', persistent)
q-card(style='width: 350px;')
q-linear-progress(query, color='page')
q-card-section.text-center {{ t('renderPageDialog.loading') }}
</template>
<script setup>
import gql from 'graphql-tag'
import { useI18n } from 'vue-i18n'
import { useDialogPluginComponent, useQuasar } from 'quasar'
import { computed, onMounted, reactive } from 'vue'
import { usePageStore } from 'src/stores/page'
// EMITS
defineEmits([
...useDialogPluginComponent.emits
])
// QUASAR
const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent()
const $q = useQuasar()
// STORES
const pageStore = usePageStore()
// I18N
const { t } = useI18n()
// METHODS
async function rerenderPage () {
await new Promise(resolve => setTimeout(resolve, 1000)) // allow for dialog to show
try {
const resp = await APOLLO_CLIENT.mutate({
mutation: gql`
mutation rerenderPage(
$id: UUID!
) {
rerenderPage (
id: $id
) {
operation {
succeeded
message
}
}
}
`,
variables: {
id: pageStore.id
}
})
if (resp?.data?.rerenderPage?.operation?.succeeded) {
$q.notify({
type: 'positive',
message: t('renderPageDialog.success')
})
onDialogOK()
} else {
throw new Error(resp?.data?.rerenderPage?.operation?.message || 'An unexpected error occured.')
}
} catch (err) {
$q.notify({
type: 'negative',
message: err.message
})
onDialogCancel()
}
}
// MOUNTED
onMounted(() => {
rerenderPage()
})
</script>
Loading…
Cancel
Save