You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
4.0 KiB

  1. <template lang='pug'>
  2. v-card
  3. v-toolbar(flat, color='primary', dark, dense)
  4. .subtitle-1 {{ $t('admin:utilities.cacheTitle') }}
  5. v-card-text
  6. .subtitle-1.pb-3.primary--text Flush Pages and Assets Cache
  7. .body-2 Pages and Assets are cached to disk for better performance. You can flush the cache to force all content to be fetched from the DB again.
  8. v-btn(outlined, color='primary', @click='flushCache', :disabled='loading').ml-0.mt-3
  9. v-icon(left) mdi-gesture-double-tap
  10. span Proceed
  11. v-divider.my-5
  12. .subtitle-1.pb-3.primary--text Flush Temporary Uploads
  13. .body-2 New uploads are temporarily saved to disk while they are being processed. They are automatically deleted after processing, but you can force an immediate cleanup using this tool.
  14. .body-2.red--text Note that performing this action while an upload is in progress can result in a failed upload.
  15. v-btn(outlined, color='primary', @click='flushUploads', :disabled='loading').ml-0.mt-3
  16. v-icon(left) mdi-gesture-double-tap
  17. span Proceed
  18. v-divider.my-5
  19. .subtitle-1.pb-3.primary--text Flush Client-Side Locale Cache
  20. .body-2 Locale strings are cached in the browser local storage for 24h. You can delete your current cache in order to fetch the latest data during the next page load.
  21. .body-2 Note that this affects only #[strong your own browser] and not everyone.
  22. v-btn(outlined, color='primary', @click='flushClientLocaleCache', :disabled='loading').ml-0.mt-3
  23. v-icon(left) mdi-gesture-double-tap
  24. span Proceed
  25. </template>
  26. <script>
  27. import _ from 'lodash'
  28. import utilityCacheFlushCacheMutation from 'gql/admin/utilities/utilities-mutation-cache-flushcache.gql'
  29. import utilityCacheFlushUploadsMutation from 'gql/admin/utilities/utilities-mutation-cache-flushuploads.gql'
  30. export default {
  31. data() {
  32. return {
  33. loading: false
  34. }
  35. },
  36. methods: {
  37. async flushCache() {
  38. this.loading = true
  39. this.$store.commit(`loadingStart`, 'admin-utilities-cache-flushCache')
  40. try {
  41. const respRaw = await this.$apollo.mutate({
  42. mutation: utilityCacheFlushCacheMutation
  43. })
  44. const resp = _.get(respRaw, 'data.pages.flushCache.responseResult', {})
  45. if (resp.succeeded) {
  46. this.$store.commit('showNotification', {
  47. message: 'Cache flushed successfully.',
  48. style: 'success',
  49. icon: 'check'
  50. })
  51. } else {
  52. throw new Error(resp.message)
  53. }
  54. } catch (err) {
  55. this.$store.commit('pushGraphError', err)
  56. }
  57. this.$store.commit(`loadingStop`, 'admin-utilities-cache-flushCache')
  58. this.loading = false
  59. },
  60. async flushUploads() {
  61. this.loading = true
  62. this.$store.commit(`loadingStart`, 'admin-utilities-cache-flushUploads')
  63. try {
  64. const respRaw = await this.$apollo.mutate({
  65. mutation: utilityCacheFlushUploadsMutation
  66. })
  67. const resp = _.get(respRaw, 'data.assets.flushTempUploads.responseResult', {})
  68. if (resp.succeeded) {
  69. this.$store.commit('showNotification', {
  70. message: 'Temporary Uploads flushed successfully.',
  71. style: 'success',
  72. icon: 'check'
  73. })
  74. } else {
  75. throw new Error(resp.message)
  76. }
  77. } catch (err) {
  78. this.$store.commit('pushGraphError', err)
  79. }
  80. this.$store.commit(`loadingStop`, 'admin-utilities-cache-flushUploads')
  81. this.loading = false
  82. },
  83. async flushClientLocaleCache () {
  84. for (let i = 0; i < window.localStorage.length; i++) {
  85. const lsKey = window.localStorage.key(i)
  86. if (_.startsWith(lsKey, 'i18next_res')) {
  87. window.localStorage.removeItem(lsKey)
  88. }
  89. }
  90. this.$store.commit('showNotification', {
  91. message: 'Locale Client-Side Cache flushed successfully.',
  92. style: 'success',
  93. icon: 'check'
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang='scss'>
  100. </style>