aboutsummaryrefslogtreecommitdiff
path: root/src/site/pages/dashboard/admin/user
diff options
context:
space:
mode:
Diffstat (limited to 'src/site/pages/dashboard/admin/user')
-rw-r--r--src/site/pages/dashboard/admin/user/_id.vue96
1 files changed, 58 insertions, 38 deletions
diff --git a/src/site/pages/dashboard/admin/user/_id.vue b/src/site/pages/dashboard/admin/user/_id.vue
index 2a56c34..7814468 100644
--- a/src/site/pages/dashboard/admin/user/_id.vue
+++ b/src/site/pages/dashboard/admin/user/_id.vue
@@ -9,41 +9,59 @@
<Sidebar />
</div>
<div class="column">
- <h2 class="subtitle">User details</h2>
+ <h2 class="subtitle">
+ User details
+ </h2>
<hr>
- <b-field label="User Id"
+ <b-field
+ label="User Id"
horizontal>
<span>{{ user.id }}</span>
</b-field>
- <b-field label="Username"
+ <b-field
+ label="Username"
horizontal>
<span>{{ user.username }}</span>
</b-field>
- <b-field label="Enabled"
+ <b-field
+ label="Enabled"
horizontal>
<span>{{ user.enabled }}</span>
</b-field>
- <b-field label="Registered"
+ <b-field
+ label="Registered"
horizontal>
<span><timeago :since="user.createdAt" /></span>
</b-field>
- <b-field label="Files"
+ <b-field
+ label="Files"
horizontal>
- <span>{{ files.length }}</span>
+ <span>{{ user.files.length }}</span>
</b-field>
<div class="mb2 mt2 text-center">
- <button class="button is-danger"
- @click="promptDisableUser">Disable user</button>
+ <b-button
+ v-if="user.enabled"
+ type="is-danger"
+ @click="promptDisableUser">
+ Disable user
+ </b-button>
+ <b-button
+ v-if="!user.enabled"
+ type="is-success"
+ @click="promptEnableUser">
+ Enable user
+ </b-button>
</div>
- <Grid v-if="files.length"
- :files="files" />
+ <Grid
+ v-if="user.files.length"
+ :files="user.files" />
</div>
</div>
</div>
@@ -51,50 +69,52 @@
</template>
<script>
+import { mapState } from 'vuex';
import Sidebar from '~/components/sidebar/Sidebar.vue';
import Grid from '~/components/grid/Grid.vue';
export default {
components: {
Sidebar,
- Grid
+ Grid,
},
- middleware: ['auth', 'admin'],
+ middleware: ['auth', 'admin', ({ route, store }) => {
+ try {
+ store.dispatch('admin/fetchUser', route.params.id);
+ } catch (e) {
+ // eslint-disable-next-line no-console
+ console.error(e);
+ }
+ }],
data() {
return {
options: {},
- files: null,
- user: null
};
},
- async asyncData({ $axios, route }) {
- try {
- const response = await $axios.$get(`/admin/users/${route.params.id}`);
- return {
- files: response.files ? response.files : null,
- user: response.user ? response.user : null
- };
- } catch (error) {
- console.error(error);
- return {
- files: null,
- user: null
- };
- }
- },
+ computed: mapState({
+ user: (state) => state.admin.user,
+ }),
methods: {
promptDisableUser() {
this.$buefy.dialog.confirm({
- message: 'Are you sure you want to disable the account of the user that uploaded this file?',
- onConfirm: () => this.disableUser()
+ type: 'is-danger',
+ message: 'Are you sure you want to disable the account of this user?',
+ onConfirm: () => this.disableUser(),
});
},
- async disableUser() {
- const response = await this.$axios.$post('admin/users/disable', {
- id: this.user.id
+ promptEnableUser() {
+ this.$buefy.dialog.confirm({
+ type: 'is-danger',
+ message: 'Are you sure you want to enable the account of this user?',
+ onConfirm: () => this.enableUser(),
});
- this.$buefy.toast.open(response.message);
- }
- }
+ },
+ disableUser() {
+ this.$handler.executeAction('admin/disableUser', this.user.id);
+ },
+ enableUser() {
+ this.$handler.executeAction('admin/enableUser', this.user.id);
+ },
+ },
};
</script>