diff --git a/client/components/admin/admin-pages-edit.vue b/client/components/admin/admin-pages-edit.vue index 06bac9cf..5e1d5a57 100644 --- a/client/components/admin/admin-pages-edit.vue +++ b/client/components/admin/admin-pages-edit.vue @@ -149,7 +149,7 @@ v-flex.text-xs-right(xs5).caption.grey--text.text-darken-2 {{ page.updatedAt | moment('calendar') }} v-timeline-item(hide-dot, small) .body-1 ... - v-btn.mx-0(outline, color='grey') View Full History + v-btn.mx-0(outline, color='grey', :href='`/h/` + page.locale + `/` + page.path') View Full History .body-1 ... v-timeline-item(color='pink', small) v-layout(justify-space-between) diff --git a/client/components/admin/admin-utilities-cache.vue b/client/components/admin/admin-utilities-cache.vue index c9424780..d4e3c215 100644 --- a/client/components/admin/admin-utilities-cache.vue +++ b/client/components/admin/admin-utilities-cache.vue @@ -3,27 +3,83 @@ v-toolbar(flat, color='primary', dark, dense) .subheading {{ $t('admin:utilities.cacheTitle') }} v-card-text - v-subheader.pl-0 Flush Pages Cache - .body-1 Pages are cached to disk for better performance. You can flush the cache to force all content to be fetched from the DB again. - v-btn(outline, color='primary').ml-0.mt-3 - v-icon(left) build - span Proceed - v-divider.my-3 - v-subheader.pl-0 Flush Assets Cache - .body-1 Assets such as images and other files are cached to disk for better performance. You can flush the cache to force all assets to be fetched from the DB again. - v-btn(outline, color='primary').ml-0.mt-3 + v-subheader.pl-0 Flush Pages and Assets Cache + .body-1 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. + v-btn(outline, color='primary', @click='flushCache', :disabled='loading').ml-0.mt-3 v-icon(left) build span Proceed v-divider.my-3 v-subheader.pl-0 Flush Temporary Uploads .body-1 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. - v-btn(outline, color='primary').ml-0.mt-3 + .body-1.red--text Note that performing this action while an upload is in progress can result in a failed upload. + v-btn(outline, color='primary', @click='flushUploads', :disabled='loading').ml-0.mt-3 v-icon(left) build span Proceed diff --git a/client/graph/admin/utilities/utilities-mutation-cache-flushcache.gql b/client/graph/admin/utilities/utilities-mutation-cache-flushcache.gql new file mode 100644 index 00000000..92a5bd2e --- /dev/null +++ b/client/graph/admin/utilities/utilities-mutation-cache-flushcache.gql @@ -0,0 +1,12 @@ +mutation { + pages { + flushCache { + responseResult { + succeeded + errorCode + slug + message + } + } + } +} diff --git a/client/graph/admin/utilities/utilities-mutation-cache-flushuploads.gql b/client/graph/admin/utilities/utilities-mutation-cache-flushuploads.gql new file mode 100644 index 00000000..c72d0605 --- /dev/null +++ b/client/graph/admin/utilities/utilities-mutation-cache-flushuploads.gql @@ -0,0 +1,12 @@ +mutation { + assets { + flushTempUploads { + responseResult { + succeeded + errorCode + slug + message + } + } + } +} diff --git a/server/graph/resolvers/asset.js b/server/graph/resolvers/asset.js index 8fb1d53c..1f896f25 100644 --- a/server/graph/resolvers/asset.js +++ b/server/graph/resolvers/asset.js @@ -154,6 +154,19 @@ module.exports = { } catch (err) { return graphHelper.generateError(err) } + }, + /** + * Flush Temporary Uploads + */ + async flushTempUploads(obj, args, context) { + try { + await WIKI.models.assets.flushTempUploads() + return { + responseResult: graphHelper.generateSuccess('Temporary Uploads have been flushed successfully.') + } + } catch (err) { + return graphHelper.generateError(err) + } } } // File: { diff --git a/server/graph/resolvers/page.js b/server/graph/resolvers/page.js index de592800..03134ba9 100644 --- a/server/graph/resolvers/page.js +++ b/server/graph/resolvers/page.js @@ -85,6 +85,16 @@ module.exports = { responseResult: graphHelper.generateSuccess('Page has been updated.'), page } + }, + async flushCache(obj, args, context) { + try { + await WIKI.models.pages.flushCache() + return { + responseResult: graphHelper.generateSuccess('Pages Cache has been flushed successfully.') + } + } catch (err) { + return graphHelper.generateError(err) + } } }, Page: { diff --git a/server/graph/schemas/asset.graphql b/server/graph/schemas/asset.graphql index e9b81612..f07f1307 100644 --- a/server/graph/schemas/asset.graphql +++ b/server/graph/schemas/asset.graphql @@ -44,6 +44,8 @@ type AssetMutation { deleteAsset( id: Int! ): DefaultResponse @auth(requires: ["manage:system", "manage:assets"]) + + flushTempUploads: DefaultResponse @auth(requires: ["manage:system"]) } # ----------------------------------------------- diff --git a/server/graph/schemas/page.graphql b/server/graph/schemas/page.graphql index 5620532a..fd79a708 100644 --- a/server/graph/schemas/page.graphql +++ b/server/graph/schemas/page.graphql @@ -71,6 +71,8 @@ type PageMutation { delete( id: Int! ): DefaultResponse @auth(requires: ["delete:pages", "manage:system"]) + + flushCache: DefaultResponse @auth(requires: ["manage:system"]) } # ----------------------------------------------- diff --git a/server/models/assets.js b/server/models/assets.js index 9b0bc0a7..1033ed2f 100644 --- a/server/models/assets.js +++ b/server/models/assets.js @@ -164,4 +164,8 @@ module.exports = class Asset extends Model { res.sendStatus(404) } } + + static async flushTempUploads() { + return fs.emptyDir(path.join(process.cwd(), `data/uploads`)) + } } diff --git a/server/models/pages.js b/server/models/pages.js index 24763896..5098b648 100644 --- a/server/models/pages.js +++ b/server/models/pages.js @@ -417,6 +417,10 @@ module.exports = class Page extends Model { return fs.remove(path.join(process.cwd(), `data/cache/${page.hash}.bin`)) } + static async flushCache() { + return fs.emptyDir(path.join(process.cwd(), `data/cache`)) + } + static cleanHTML(rawHTML = '') { return striptags(rawHTML || '') .replace(emojiRegex(), '')