From 9f5a3d15f55fea03052627f3bd4d97a4284cdf7c Mon Sep 17 00:00:00 2001
From: Pitu <heyitspitu@gmail.com>
Date: Thu, 28 Feb 2019 23:51:59 +0900
Subject: Purge user's files

---
 src/site/pages/dashboard/users.vue | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

(limited to 'src/site/pages/dashboard/users.vue')

diff --git a/src/site/pages/dashboard/users.vue b/src/site/pages/dashboard/users.vue
index c930876..59a75d3 100644
--- a/src/site/pages/dashboard/users.vue
+++ b/src/site/pages/dashboard/users.vue
@@ -171,6 +171,12 @@
 										<b-switch v-model="props.row.isAdmin"
 											@input="changeIsAdmin(props.row)" />
 									</b-table-column>
+
+									<b-table-column field="purge"
+										centered>
+										<button class="button is-primary"
+											@click="promptPurgeFiles(props.row)">Purge files</button>
+									</b-table-column>
 								</template>
 								<template slot="empty">
 									<div class="has-text-centered">
@@ -251,6 +257,22 @@ export default {
 			} catch (error) {
 				this.$onPromiseError(error);
 			}
+		},
+		promptPurgeFiles(row) {
+			this.$dialog.confirm({
+				message: 'Are you sure you want to delete this user\'s files?',
+				onConfirm: () => this.purgeFiles(row)
+			});
+		},
+		async purgeFiles(row) {
+			try {
+				const response = await this.axios.post(`${this.config.baseURL}/admin/users/purge`, {
+					id: row.id
+				});
+				this.$toast.open(response.data.message);
+			} catch (error) {
+				this.$onPromiseError(error);
+			}
 		}
 	}
 };
-- 
cgit v1.2.3

