feat: admin utilities - rerender all pages
This commit is contained in:
parent
6920a35d80
commit
0d6562cca4
@ -86,8 +86,8 @@
|
|||||||
v-list-item(to='/mail', color='primary', v-if='hasPermission(`manage:system`)')
|
v-list-item(to='/mail', color='primary', v-if='hasPermission(`manage:system`)')
|
||||||
v-list-item-avatar(size='24'): v-icon mdi-email-multiple-outline
|
v-list-item-avatar(size='24'): v-icon mdi-email-multiple-outline
|
||||||
v-list-item-title {{ $t('admin:mail.title') }}
|
v-list-item-title {{ $t('admin:mail.title') }}
|
||||||
v-list-item(to='/ssl', color='primary', v-if='hasPermission(`manage:system`)')
|
v-list-item(to='/ssl', v-if='hasPermission(`manage:system`)', disabled)
|
||||||
v-list-item-avatar(size='24'): v-icon mdi-cloud-lock-outline
|
v-list-item-avatar(size='24'): v-icon(color='grey lighten-2') mdi-cloud-lock-outline
|
||||||
v-list-item-title {{ $t('admin:ssl.title') }}
|
v-list-item-title {{ $t('admin:ssl.title') }}
|
||||||
v-list-item(to='/system', color='primary', v-if='hasPermission(`manage:system`)')
|
v-list-item(to='/system', color='primary', v-if='hasPermission(`manage:system`)')
|
||||||
v-list-item-avatar(size='24'): v-icon mdi-tune
|
v-list-item-avatar(size='24'): v-icon mdi-tune
|
||||||
|
@ -9,6 +9,35 @@
|
|||||||
v-icon(left) mdi-gesture-double-tap
|
v-icon(left) mdi-gesture-double-tap
|
||||||
span Proceed
|
span Proceed
|
||||||
v-divider.my-5
|
v-divider.my-5
|
||||||
|
.subtitle-1.pb-3.primary--text Rerender All Pages
|
||||||
|
.body-2 All pages will be rendered again. Useful if internal links are broken or the rendering pipeline has changed.
|
||||||
|
v-btn(outlined, color='primary', @click='rerenderPages', :disabled='loading', :loading='isRerendering').ml-0.mt-3
|
||||||
|
v-icon(left) mdi-gesture-double-tap
|
||||||
|
span Proceed
|
||||||
|
v-dialog(
|
||||||
|
v-model='isRerendering'
|
||||||
|
persistent
|
||||||
|
max-width='450'
|
||||||
|
)
|
||||||
|
v-card(color='blue darken-2', dark)
|
||||||
|
v-card-text.pa-10.text-center
|
||||||
|
semipolar-spinner.animated.fadeIn(
|
||||||
|
:animation-duration='1500'
|
||||||
|
:size='65'
|
||||||
|
color='#FFF'
|
||||||
|
style='margin: 0 auto;'
|
||||||
|
)
|
||||||
|
.mt-5.body-1.white--text Rendering all pages...
|
||||||
|
.caption(v-if='renderIndex > 0') Rendering {{renderCurrentPath}}... ({{renderIndex}}/{{renderTotal}}, {{renderProgress}}%)
|
||||||
|
.caption.mt-4 Do not leave this page.
|
||||||
|
v-progress-linear.mt-5(
|
||||||
|
color='white'
|
||||||
|
:value='renderProgress'
|
||||||
|
stream
|
||||||
|
rounded
|
||||||
|
:buffer-value='0'
|
||||||
|
)
|
||||||
|
v-divider.my-5
|
||||||
.subtitle-1.pb-3.pl-0.primary--text Migrate all pages to target locale
|
.subtitle-1.pb-3.pl-0.primary--text Migrate all pages to target locale
|
||||||
.body-2 If you created content before selecting a different locale and activating the namespacing capabilities, you may want to transfer all content to the base locale.
|
.body-2 If you created content before selecting a different locale and activating the namespacing capabilities, you may want to transfer all content to the base locale.
|
||||||
.body-2.red--text: strong This operation is destructive and cannot be reversed! Make sure you have proper backups!
|
.body-2.red--text: strong This operation is destructive and cannot be reversed! Make sure you have proper backups!
|
||||||
@ -40,15 +69,26 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import gql from 'graphql-tag'
|
||||||
import utilityContentMigrateLocaleMutation from 'gql/admin/utilities/utilities-mutation-content-migratelocale.gql'
|
import utilityContentMigrateLocaleMutation from 'gql/admin/utilities/utilities-mutation-content-migratelocale.gql'
|
||||||
import utilityContentRebuildTreeMutation from 'gql/admin/utilities/utilities-mutation-content-rebuildtree.gql'
|
import utilityContentRebuildTreeMutation from 'gql/admin/utilities/utilities-mutation-content-rebuildtree.gql'
|
||||||
|
|
||||||
|
import { SemipolarSpinner } from 'epic-spinners'
|
||||||
|
|
||||||
/* global siteLangs, siteConfig */
|
/* global siteLangs, siteConfig */
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
SemipolarSpinner
|
||||||
|
},
|
||||||
data: () => {
|
data: () => {
|
||||||
return {
|
return {
|
||||||
|
isRerendering: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
renderProgress: 0,
|
||||||
|
renderIndex: 0,
|
||||||
|
renderTotal: 0,
|
||||||
|
renderCurrentPath: '',
|
||||||
sourceLocale: '',
|
sourceLocale: '',
|
||||||
targetLocale: ''
|
targetLocale: ''
|
||||||
}
|
}
|
||||||
@ -87,6 +127,82 @@ export default {
|
|||||||
this.$store.commit(`loadingStop`, 'admin-utilities-content-rebuildtree')
|
this.$store.commit(`loadingStop`, 'admin-utilities-content-rebuildtree')
|
||||||
this.loading = false
|
this.loading = false
|
||||||
},
|
},
|
||||||
|
async rerenderPages () {
|
||||||
|
this.loading = true
|
||||||
|
this.isRerendering = true
|
||||||
|
this.$store.commit(`loadingStart`, 'admin-utilities-content-rerender')
|
||||||
|
|
||||||
|
try {
|
||||||
|
const pagesRaw = await this.$apollo.query({
|
||||||
|
query: gql`
|
||||||
|
{
|
||||||
|
pages {
|
||||||
|
list {
|
||||||
|
id
|
||||||
|
path
|
||||||
|
locale
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
fetchPolicy: 'network-only'
|
||||||
|
})
|
||||||
|
if (_.get(pagesRaw, 'data.pages.list', []).length < 1) {
|
||||||
|
throw new Error('Could not find any page to render!')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.renderIndex = 0
|
||||||
|
this.renderTotal = pagesRaw.data.pages.list.length
|
||||||
|
let failed = 0
|
||||||
|
for (const page of pagesRaw.data.pages.list) {
|
||||||
|
this.renderCurrentPath = `${page.locale}/${page.path}`
|
||||||
|
this.renderIndex++
|
||||||
|
this.renderProgress = Math.round(this.renderIndex / this.renderTotal * 100)
|
||||||
|
const respRaw = await this.$apollo.mutate({
|
||||||
|
mutation: gql`
|
||||||
|
mutation($id: Int!) {
|
||||||
|
pages {
|
||||||
|
render(id: $id) {
|
||||||
|
responseResult {
|
||||||
|
succeeded
|
||||||
|
errorCode
|
||||||
|
slug
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
variables: {
|
||||||
|
id: page.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const resp = _.get(respRaw, 'data.pages.render.responseResult', {})
|
||||||
|
if (!resp.succeeded) {
|
||||||
|
failed++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (failed > 0) {
|
||||||
|
this.$store.commit('showNotification', {
|
||||||
|
message: `Completed with ${failed} pages that failed to render. Check server logs for details.`,
|
||||||
|
style: 'error',
|
||||||
|
icon: 'alert'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.$store.commit('showNotification', {
|
||||||
|
message: 'All pages have been rendered successfully.',
|
||||||
|
style: 'success',
|
||||||
|
icon: 'check'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.$store.commit('pushGraphError', err)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$store.commit(`loadingStop`, 'admin-utilities-content-rerender')
|
||||||
|
this.isRerendering = false
|
||||||
|
this.loading = false
|
||||||
|
},
|
||||||
async migrateToLocale () {
|
async migrateToLocale () {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
this.$store.commit(`loadingStart`, 'admin-utilities-content-migratelocale')
|
this.$store.commit(`loadingStart`, 'admin-utilities-content-migratelocale')
|
||||||
|
@ -312,6 +312,23 @@ module.exports = {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
return graphHelper.generateError(err)
|
return graphHelper.generateError(err)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* RENDER PAGE
|
||||||
|
*/
|
||||||
|
async render (obj, args, context) {
|
||||||
|
try {
|
||||||
|
const page = await WIKI.models.pages.query().findById(args.id)
|
||||||
|
if (!page) {
|
||||||
|
throw new Error('Invalid Page Id')
|
||||||
|
}
|
||||||
|
await WIKI.models.pages.renderPage(page)
|
||||||
|
return {
|
||||||
|
responseResult: graphHelper.generateSuccess('Page rendered successfully.')
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
return graphHelper.generateError(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Page: {
|
Page: {
|
||||||
|
@ -106,6 +106,10 @@ type PageMutation {
|
|||||||
): PageMigrationResponse @auth(requires: ["manage:system"])
|
): PageMigrationResponse @auth(requires: ["manage:system"])
|
||||||
|
|
||||||
rebuildTree: DefaultResponse @auth(requires: ["manage:system"])
|
rebuildTree: DefaultResponse @auth(requires: ["manage:system"])
|
||||||
|
|
||||||
|
render(
|
||||||
|
id: Int!
|
||||||
|
): DefaultResponse @auth(requires: ["manage:system"])
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user