This commit is contained in:
Kekskurse 2019-11-22 16:13:51 +01:00
parent 9878d251e7
commit 1b2f22ca31
9 changed files with 325 additions and 60 deletions

View file

@ -58,6 +58,34 @@
text text
height="100%" height="100%"
>Developer</v-btn> >Developer</v-btn>
<v-menu
left
bottom
offset-y
v-if="this.$store.state.loggedIn"
>
<template v-slot:activator="{ on }">
<v-btn v-on="on" class="d-none d-md-flex" tile text height="100%">
Admin
</v-btn>
</template>
<v-list>
<v-list-item to="/admin/settings">
<v-list-item-title>Settings</v-list-item-title>
</v-list-item>
<v-list-item to="/access">
<v-list-item-title>User</v-list-item-title>
</v-list-item>
<v-list-item to="/access">
<v-list-item-title>Apps</v-list-item-title>
</v-list-item>
<v-list-item to="/access">
<v-list-item-title>Invites</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<v-menu <v-menu
left left

View file

@ -137,69 +137,15 @@
}, },
data () { data () {
return { return {
big: true,
bgcolor: "transparent",
flat: true,
nameBig: '',
nameSmall: '',
sideMenu: this.$store.state.sideMenu,
menu: [
{ icon: 'home', title: 'Login' , link: "Login" },
{ icon: 'info', title: 'Invited' },
{ icon: 'warning', title: 'Register' }
],
menu2: [
{ icon: 'home', title: 'Apps' },
{ icon: 'info', title: 'Admin' },
{ icon: 'warning', title: 'Account' }
],
menu3: []
} }
}, },
computed: { computed: {
setting: (name) => {
//this.$store.getters.getSettingValue(this.$store.state, name);
}
}, },
methods: { methods: {
generateMenu: function () {
this.menu = [];
if(!this.$store.state.loggedIn) {
this.menu.push({ icon: 'home', title: 'Login' , link: "Login" });
if(this.$store.getters.getSettingValue("invites")) {
this.menu.push({ icon: 'home', title: 'Invited' , link: "Invited" });
}
if(this.$store.getters.getSettingValue("registration_possible")) {
this.menu.push({ icon: 'home', title: 'Register' , link: "Register" });
}
} else {
if(this.$store.getters.getMe.developer) {
this.menu.push({ icon: 'home', title: 'Apps' , link: "Apps" });
}
if(this.$store.getters.getMe.admin) {
this.menu.push({ icon: 'home', title: 'Admin' , link: "Admin" });
}
this.menu.push({ icon: 'home', title: 'Profile' , link: "profile", submenu: true, menu: [
{ icon: 'home', title: 'Logout' , link: "Logout" }
] });
}
},
handleScroll: function (evt, el) {
if(evt.pageY > 100) {
this.big = false;
this.bgcolor = "#fff";
this.flat = false;
} else {
this.big = true;
this.bgcolor = "transparent";
this.flat = true;
}
}
}, },
mounted: function () { mounted: function () {
this.nameBig = this.$store.getters.getSettingValue("name_big");
this.nameSmall = this.$store.getters.getSettingValue("name_small");
this.generateMenu();
} }
} }
</script> </script>

View file

@ -14,6 +14,8 @@ import Register from '../views/Register'
import Access from '../views/Access' import Access from '../views/Access'
import Profile from '../views/Profile' import Profile from '../views/Profile'
import AdminSettings from '../views/admin/Settings'
Vue.use(Router) Vue.use(Router)
function guard(to, from, next){ function guard(to, from, next){
@ -25,6 +27,15 @@ function guard(to, from, next){
} }
} }
function admin(to, from, next){
if(store.state.loggedIn) {
next(); // allow to enter route
} else{
store.state.redirectIfLoggedIn = to;
next('/login'); // go to '/login';
}
}
export default new Router({ export default new Router({
routes: [ routes: [
{ {
@ -93,6 +104,13 @@ export default new Router({
path: '/user/mails', path: '/user/mails',
name: 'userMails', name: 'userMails',
component: Mail component: Mail
} },
{
beforeEnter: admin,
path: '/admin/settings',
name: 'adminSettings',
component: AdminSettings
},
] ]
}) })

7
src/services/Admin.js Normal file
View file

@ -0,0 +1,7 @@
import Api from '@/services/Api'
export default {
saveSettings(settings) {
return Api().post('/v1/admin/settings', settings);
}
}

View file

@ -4,6 +4,9 @@ export default {
getPublicSettings (params) { getPublicSettings (params) {
return Api().get('/v1/server/settings') return Api().get('/v1/server/settings')
}, },
getAllSettings () {
return Api().get('/v1/server/settings?all=1')
},
getStatus () { getStatus () {
return Api().get("/v1/status/check") return Api().get("/v1/status/check")
} }

View file

@ -32,10 +32,16 @@ export default {
removeMail(mailID) { removeMail(mailID) {
return Api().delete('/v1/user/me/mail/'+mailID); return Api().delete('/v1/user/me/mail/'+mailID);
}, },
markMailAsPrimary(mailID) {
return Api().post('/v1/user/me/mail/'+mailID+'/markAsPrimary');
},
getCaptchaSettings() { getCaptchaSettings() {
return Api().get("/v1/user/captcha"); return Api().get("/v1/user/captcha");
}, },
getInviteCodeInfo(code) { getInviteCodeInfo(code) {
return Api().get("/v1/user/invites?code="+code) return Api().get("/v1/user/invites?code="+code)
},
changePassword(newPassword) {
return Api().post("/v1/user/me/changePassword", {"password": newPassword});
} }
} }

View file

@ -27,7 +27,7 @@
<td class="text-right"> <td class="text-right">
<!--<v-btn depressed x-small :disabled="item.status == 'valide'" color="primary" style="margin-right: 10px;">Resend Validation</v-btn>!--> <!--<v-btn depressed x-small :disabled="item.status == 'valide'" color="primary" style="margin-right: 10px;">Resend Validation</v-btn>!-->
<v-btn depressed x-small :disabled="item.primary" @click="removeMail(item.id)" color="error" style="margin-right: 10px;">Remove Mail</v-btn> <v-btn depressed x-small :disabled="item.primary" @click="removeMail(item.id)" color="error" style="margin-right: 10px;">Remove Mail</v-btn>
<v-btn depressed x-small :disabled="item.primary || item.status != 'valide'" color="success">Mark as Primary</v-btn> <v-btn depressed x-small :disabled="item.primary || item.status != 'valide'" @click="markAsPrimary(item.id)" color="success">Mark as Primary</v-btn>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -48,6 +48,20 @@
Add Mail Add Mail
</v-btn> </v-btn>
<h2>Password</h2> <h2>Password</h2>
<p>New Password</p>
<v-text-field
label="New Password"
value=""
type="password"
v-model="newpassword"
></v-text-field>
<v-btn
color="success"
@click="changePassword"
>
Change Password
</v-btn>
</v-flex> </v-flex>
</v-layout> </v-layout>
</v-container> </v-container>
@ -66,7 +80,8 @@
nameBig: '', nameBig: '',
nameSmall: '', nameSmall: '',
mails: [], mails: [],
newmail: '' newmail: '',
newpassword: ''
} }
}, },
components: { components: {
@ -87,6 +102,18 @@
UserService.removeMail(id).then((res) => { UserService.removeMail(id).then((res) => {
this.getMails(); this.getMails();
}); });
},
markAsPrimary: function(id) {
UserService.markMailAsPrimary(id).then((res) => {
this.getMails();
})
},
changePassword: function() {
UserService.changePassword(this.newpassword).then(() => {
alert("Password changed");
}).catch((res) => {
alert("There was an error: "+res.response.data.data.password[0]);
});
} }
}, },
mounted: function() { mounted: function() {

View file

@ -93,7 +93,7 @@
export default { export default {
data () { data () {
return { return {
success: true, success: false,
inviteCode: '', inviteCode: '',
errorMsg: '', errorMsg: '',
username: '', username: '',

View file

@ -0,0 +1,230 @@
<template>
<div style="margin-top:50px;">
<v-container grid-list-md pa-10 >
<v-layout row wrap>
<v-flex md12>
<h1>Admin Settings</h1>
<br><br>
<v-expansion-panels>
<v-expansion-panel>
<v-expansion-panel-header>General</v-expansion-panel-header>
<v-expansion-panel-content>
<v-text-field
label="Big Name"
value=""
type="text"
v-model="serverSettings.name_big"
></v-text-field>
<v-text-field
label="Big Small"
value=""
type="text"
v-model="serverSettings['name_small']"
></v-text-field>
<v-text-field
label="Slogen"
value=""
type="text"
v-model="serverSettings['name_slogen']"
></v-text-field>
<v-text-field
label="Frontend URL"
value=""
type="text"
v-model="serverSettings['url']"
></v-text-field>
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header>Features</v-expansion-panel-header>
<v-expansion-panel-content>
<v-checkbox
v-model="serverSettings['registration_possible']"
label="Registration possible"
></v-checkbox>
<v-checkbox
v-model="serverSettings['invites']"
label="Invites possible"
></v-checkbox>
<v-checkbox
v-model="serverSettings['startpage']"
label="Startpage"
></v-checkbox>
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header>SMTP</v-expansion-panel-header>
<v-expansion-panel-content>
<v-checkbox
v-model="serverSettings['smtp_active']"
label="Send Mails"
></v-checkbox>
<v-text-field
label="SMTP Server"
value=""
type="text"
v-model="serverSettings['smtp_host']"
></v-text-field>
<v-text-field
label="SMTP Port"
value=""
type="text"
v-model="serverSettings['smtp_port']"
></v-text-field>
<v-text-field
label="SMTP Secure"
value="tls"
type="text"
v-model="serverSettings['smtp_secure']"
></v-text-field>
<v-checkbox
v-model="serverSettings['smtp_smtpAuth']"
label="SMTP Auth"
></v-checkbox>
<v-text-field
label="SMTP Username"
value=""
type="text"
v-model="serverSettings['smtp_username']"
></v-text-field>
<v-text-field
label="SMTP Password"
value=""
type="password"
v-model="serverSettings['smtp_password']"
></v-text-field>
<v-text-field
label="From Mail"
value=""
type="text"
v-model="serverSettings['smtp_from_mail']"
></v-text-field>
<v-text-field
label="From Name"
value=""
type="text"
v-model="serverSettings['smtp_from_name']"
></v-text-field>
<v-text-field
label="BCC Mail"
value=""
type="text"
v-model="serverSettings['smtp_bcc']"
></v-text-field>
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel>
<v-expansion-panel-header>reCAPTCHA</v-expansion-panel-header>
<v-expansion-panel-content>
<v-checkbox
v-model="serverSettings['recaptcha_v2_login']"
label="reCAPTCHA to login"
></v-checkbox>
<v-checkbox
v-model="serverSettings['recaptcha_v2_register']"
label="reCAPTCHA to register"
></v-checkbox>
<v-text-field
label="Recaptcha V2 Key"
value=""
type="text"
v-model="serverSettings['recaptcha_v2_key']"
></v-text-field>
<v-text-field
label="Recaptcha V2 Secret"
value=""
type="password"
v-model="serverSettings['recaptcha_v2_secret']"
></v-text-field>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels><br>
<v-btn
color="success"
@click="saveSettings"
>Save</v-btn>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
<script>
import ServerService from '../../services/Server'
import AdminService from '../../services/Admin'
export default {
data () {
return {
nameBig: '',
nameSmall: '',
serverSettings: []
}
},
components: {
},
methods: {
getAllSettings: function () {
ServerService.getAllSettings().then((res) => {
let settingsArray = {};
for(let i = 0; i < res.data.data.length; i++) {
settingsArray[res.data.data[i].name] = res.data.data[i].value;
}
this.serverSettings = settingsArray;
});
},
saveSettings: function () {
console.log(this.serverSettings);
AdminService.saveSettings(this.serverSettings).then(() => {
alert("Changed saved");
}).catch(() => {
alert("Something go wrong");
});
}
},
mounted: function() {
this.nameBig = this.$store.getters.getSettingValue("name_big");
this.nameSmall = this.$store.getters.getSettingValue("name_small");
this.getAllSettings();
}
}
</script>
<style>
.header {
background-image: url('~@/assets/manhattan-407703_1920.jpg');
background-repeat: no-repeat;
margin-top: -100px;
height: 30vh;
text-align: center;
}
.header h1{
padding-top: 200px;
font-size: 56px !important;
font-weight: 400;
line-height: 32px !important;
letter-spacing: normal !important;
}
.header h1 .small{
font-weight: 300 !important;
}
.header h2{
padding-top: 30px;
font-size: 34px !important;
font-weight: 300;
line-height: 32px !important;
letter-spacing: normal !important;
}
h1{
font-weight: 300;
line-height: 32px !important;
letter-spacing: normal !important;
}
h2{
font-weight: 300;
line-height: 32px !important;
letter-spacing: normal !important;
}
</style>