This commit is contained in:
Kekskurse 2019-11-22 18:22:31 +01:00
parent 1b2f22ca31
commit 95284448f8
7 changed files with 261 additions and 5 deletions

View file

@ -9,7 +9,7 @@
> >
<v-app-bar-nav-icon class="d-flex d-md-none" @click="toggleMenu()"></v-app-bar-nav-icon> <v-app-bar-nav-icon v-if="this.$store.getters.getSettingValue('registration_possible') || this.$store.getters.getSettingValue('invite')" class="d-flex d-md-none" @click="toggleMenu()"></v-app-bar-nav-icon>
<v-toolbar-title><b>{{nameBig}}</b>{{nameSmall}}</v-toolbar-title> <v-toolbar-title><b>{{nameBig}}</b>{{nameSmall}}</v-toolbar-title>
@ -75,7 +75,7 @@
<v-list-item to="/admin/settings"> <v-list-item to="/admin/settings">
<v-list-item-title>Settings</v-list-item-title> <v-list-item-title>Settings</v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item to="/access"> <v-list-item to="/admin/user">
<v-list-item-title>User</v-list-item-title> <v-list-item-title>User</v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item to="/access"> <v-list-item to="/access">

View file

@ -15,6 +15,8 @@ import Access from '../views/Access'
import Profile from '../views/Profile' import Profile from '../views/Profile'
import AdminSettings from '../views/admin/Settings' import AdminSettings from '../views/admin/Settings'
import AdminUserList from '../views/admin/User'
import AdminUserEdit from '../views/admin/UserEdit'
Vue.use(Router) Vue.use(Router)
@ -111,6 +113,17 @@ export default new Router({
name: 'adminSettings', name: 'adminSettings',
component: AdminSettings component: AdminSettings
}, },
{
beforeEnter: admin,
path: '/admin/user',
name: 'adminUserList',
component: AdminUserList
},
{
beforeEnter: admin,
path: '/admin/user/:id',
name: 'adminUserEdit',
component: AdminUserEdit
},
] ]
}) })

View file

@ -3,5 +3,20 @@ import Api from '@/services/Api'
export default { export default {
saveSettings(settings) { saveSettings(settings) {
return Api().post('/v1/admin/settings', settings); return Api().post('/v1/admin/settings', settings);
},
getUserList() {
return Api().get("/v1/admin/user");
},
getUserDetails(id) {
return Api().get("/v1/admin/user/"+id);
},
updateUser(id, username, admin, developer) {
return Api().put("/v1/admin/user/"+id, {"username": username, "admin": admin, "developer": developer});
},
resendValidationMail(id) {
return Api().post("/v1/admin/mail/"+id+"/resend")
},
validateMail(id) {
return Api().put("/v1/admin/mail/"+id+"/status", {"status": "valide"});
} }
} }

View file

@ -99,8 +99,14 @@
this.nameBig = this.$store.getters.getSettingValue("name_big"); this.nameBig = this.$store.getters.getSettingValue("name_big");
this.nameSmall = this.$store.getters.getSettingValue("name_small"); this.nameSmall = this.$store.getters.getSettingValue("name_small");
this.slogen = this.$store.getters.getSettingValue("name_slogen"); this.slogen = this.$store.getters.getSettingValue("name_slogen");
if(this.$store.getters.getSettingValue("startpage") == false) {
this.$router.push({"path": "login"})
} else {
this.getStartpageApps(); this.getStartpageApps();
} }
}
} }
</script> </script>

View file

@ -44,7 +44,7 @@
></v-checkbox> ></v-checkbox>
<v-checkbox <v-checkbox
v-model="serverSettings['invites']" v-model="serverSettings['invites']"
label="Invites possible" label="Show invite link on Startpage"
></v-checkbox> ></v-checkbox>
<v-checkbox <v-checkbox
v-model="serverSettings['startpage']" v-model="serverSettings['startpage']"

69
src/views/admin/User.vue Normal file
View file

@ -0,0 +1,69 @@
<template>
<div style="margin-top: 50px;">
<v-container grid-list-md pa-10>
<v-layout row wrap>
<v-flex md12>
<h1>Users</h1>
<br><br>
<p>Here you can Administrate your apps</p>
<v-simple-table>
<template v-slot:default>
<thead>
<tr>
<th class="text-left">Name</th>
<th class="text-left">Status</th>
<th class="text-left">Primary Mail</th>
<th class="text-left">Flags</th>
</tr>
</thead>
<tbody>
<tr @click="userDetails(item.id)" v-for="item in user" :key="item.name">
<td>{{ item.username }}</td>
<td>{{ item.status }}</td>
<td>{{ item.primaryMail }}</td>
<td>
<v-icon v-if="item.developer">mdi-code-tags</v-icon>
<v-icon v-if="item.admin">mdi-account-key</v-icon>
</td>
</tr>
</tbody>
</template>
</v-simple-table>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
<script>
import AdminService from '../../services/Admin'
export default {
data () {
return {
user: []
}
},
components: {
},
methods: {
'loadUser': function () {
AdminService.getUserList().then((res) => {
this.user = res.data.data;
})
},
'userDetails': function(id) {
this.$router.push({"path": "/admin/user/"+id})
}
},
mounted: function() {
this.loadUser();
}
}
</script>

View file

@ -0,0 +1,153 @@
<template>
<div style="margin-top: 50px;">
<v-container grid-list-md pa-10>
<v-layout row wrap>
<v-flex md12>
<h1>Users Edit</h1>
<br><br>
<v-text-field
label="Username"
type="text"
v-model="user.username"
></v-text-field>
<v-text-field
label="Primary E-Mail"
disabled=true
type="text"
v-model="user.primaryMail"
></v-text-field>
<v-text-field
label="Created at"
disabled=true
type="text"
v-model="user.created_at"
></v-text-field>
<v-text-field
label="Updated at"
disabled=true
type="text"
v-model="user.updated_at"
></v-text-field>
<v-text-field
label="Invite Code"
disabled=true
type="text"
v-model="user.inviteCode"
></v-text-field>
<v-select
:items="statusAvalible"
label="Status"
v-model="user.status"
disabled="disabled"
></v-select>
<v-checkbox
v-model="user.developer"
label="Developer"
></v-checkbox>
<v-checkbox
v-model="user.admin"
label="Admin Access"
></v-checkbox>
<v-btn
color="success"
@click="saveSettings"
>Save</v-btn>
<br><br>
<v-simple-table>
<template v-slot:default>
<thead>
<tr>
<th class="text-left">#</th>
<th class="text-left">Mail</th>
<th>Status</th>
<th class="text-right">Action</th>
</tr>
</thead>
<tbody>
<tr v-for="item in mails" :key="item.id">
<td>{{ item.id }}</td>
<td>{{ item.mail }}</td>
<td>{{ item.status }}</td>
<td class="text-right">
<v-menu offset-y>
<template v-slot:activator="{ on }">
<v-btn
color="primary"
v-on="on"
>
<v-icon>mdi-settings</v-icon>
</v-btn>
</template>
<v-list>
<v-list-item
:disabled="item.status != 'waiting'"
link
@click="validateMail(item.id)"
>
<v-list-item-title>Activate Mail adress</v-list-item-title>
</v-list-item>
<v-list-item
link
@click="resendValidationMail(item.id)"
>
<v-list-item-title>Resend Validation Mail</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</td>
</tr>
</tbody>
</template>
</v-simple-table>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
<script>
import AdminService from '../../services/Admin'
export default {
data () {
return {
user: {},
statusAvalible: ['active'],
mails: []
}
},
components: {
},
methods: {
'loadUser': function () {
AdminService.getUserDetails(this.$route.params.id).then((res) => {
this.user = res.data.data.details;
this.mails = res.data.data.mails;
})
},
'saveSettings': function () {
AdminService.updateUser(this.$route.params.id, this.user.username, this.user.admin, this.user.developer).then(() => {
this.loadUser();
});
},
'resendValidationMail': function(id) {
AdminService.resendValidationMail(id).then((res) => {
alert("Mail send again");
});
},
'validateMail': function(id) {
AdminService.validateMail(id).then((res) => {
this.loadUser();
})
}
},
mounted: function() {
this.loadUser();
}
}
</script>