mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-14 13:16:37 +00:00
138 lines
4.1 KiB
Vue
138 lines
4.1 KiB
Vue
<template>
|
|
<b-card no-body>
|
|
<b-card-header header-bg-variant="primary-dark">
|
|
<h2 class="card-title">
|
|
{{ $gettext('Users') }}
|
|
</h2>
|
|
</b-card-header>
|
|
|
|
<b-card-body body-class="card-padding-sm">
|
|
<b-button
|
|
variant="outline-primary"
|
|
@click.prevent="doCreate"
|
|
>
|
|
<icon icon="add" />
|
|
{{ $gettext('Add User') }}
|
|
</b-button>
|
|
</b-card-body>
|
|
|
|
<data-table
|
|
id="users"
|
|
ref="datatable"
|
|
paginated
|
|
:fields="fields"
|
|
:api-url="listUrl"
|
|
>
|
|
<template #cell(name)="row">
|
|
<h5
|
|
v-if="row.item.name !== ''"
|
|
class="mb-0"
|
|
>
|
|
{{ row.item.name }}
|
|
</h5>
|
|
<a :href="'mailto:'+row.item.email">{{ row.item.email }}</a>
|
|
<span
|
|
v-if="row.item.is_me"
|
|
class="badge badge-primary"
|
|
>
|
|
{{ $gettext('You') }}
|
|
</span>
|
|
</template>
|
|
<template #cell(roles)="row">
|
|
<div
|
|
v-for="role in row.item.roles"
|
|
:key="role.id"
|
|
>
|
|
{{ role.name }}
|
|
</div>
|
|
</template>
|
|
<template #cell(actions)="row">
|
|
<b-button-group
|
|
v-if="!row.item.is_me"
|
|
size="sm"
|
|
>
|
|
<b-button
|
|
size="sm"
|
|
variant="secondary"
|
|
:href="row.item.links.masquerade"
|
|
target="_blank"
|
|
>
|
|
{{ $gettext('Log In') }}
|
|
</b-button>
|
|
<b-button
|
|
size="sm"
|
|
variant="primary"
|
|
@click.prevent="doEdit(row.item.links.self)"
|
|
>
|
|
{{ $gettext('Edit') }}
|
|
</b-button>
|
|
<b-button
|
|
size="sm"
|
|
variant="danger"
|
|
@click.prevent="doDelete(row.item.links.self)"
|
|
>
|
|
{{ $gettext('Delete') }}
|
|
</b-button>
|
|
</b-button-group>
|
|
</template>
|
|
</data-table>
|
|
</b-card>
|
|
|
|
<edit-modal
|
|
ref="editModal"
|
|
:create-url="listUrl"
|
|
:roles="roles"
|
|
@relist="relist"
|
|
/>
|
|
</template>
|
|
|
|
<script>
|
|
import DataTable from '~/components/Common/DataTable';
|
|
import EditModal from './Users/EditModal';
|
|
import Icon from '~/components/Common/Icon';
|
|
import InfoCard from '~/components/Common/InfoCard';
|
|
|
|
export default {
|
|
name: 'AdminPermissions',
|
|
components: {InfoCard, Icon, EditModal, DataTable},
|
|
props: {
|
|
listUrl: String,
|
|
roles: Object
|
|
},
|
|
data() {
|
|
return {
|
|
fields: [
|
|
{key: 'name', isRowHeader: true, label: this.$gettext('User Name'), sortable: true},
|
|
{key: 'roles', label: this.$gettext('Roles'), sortable: false},
|
|
{key: 'actions', label: this.$gettext('Actions'), sortable: false, class: 'shrink'}
|
|
]
|
|
};
|
|
},
|
|
methods: {
|
|
relist() {
|
|
this.$refs.datatable.refresh();
|
|
},
|
|
doCreate() {
|
|
this.$refs.editModal.create();
|
|
},
|
|
doEdit(url) {
|
|
this.$refs.editModal.edit(url);
|
|
},
|
|
doDelete(url) {
|
|
this.$confirmDelete({
|
|
title: this.$gettext('Delete User?'),
|
|
}).then((result) => {
|
|
if (result.value) {
|
|
this.$wrapWithLoading(
|
|
this.axios.delete(url)
|
|
).then((resp) => {
|
|
this.$notifySuccess(resp.data.message);
|
|
this.relist();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|