Updated favicon, edited settings logic, specify type of parameters

This commit is contained in:
Spitap
2023-04-18 15:44:08 +02:00
committed by Antoine Nguyen
parent 415aefc764
commit 76c99094fd
11 changed files with 449 additions and 154 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

@@ -0,0 +1,149 @@
<template>
<v-list>
<template v-for="item in mainMenuItems">
<template v-if="displayMenuItem(item)">
<v-list-item
v-if="!item.children"
class="menu-item"
:to="item.to"
link
:key="item.title"
:exact="item.exact"
>
<v-list-item-icon v-if="item.icon">
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
color="white"
:key="item.text"
:prepend-icon="item.icon"
no-action>
<template v-slot:activator>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</template>
<template v-for="subitem in item.children">
<v-list-item v-if="!subitem.children"
:key="subitem.text"
:to="subitem.to"
link>
<v-list-item-content>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
:key="subitem.text"
:value="true"
no-action
sub-group>
<template v-slot:activator>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</template>
<v-list-item v-for="subsubitem in subitem.children"
:key="subsubitem.text"
:to="subsubitem.to"
link>
<v-list-item-title>{{ subsubitem.text }}</v-list-item-title>
</v-list-item>
</v-list-group>
</template>
</v-list-group>
</template>
</template>
<settings-drawer
:parametersList="parametersList"
:extension="false"
/>
</v-list>
</template>
<script>
import { mapGetters } from 'vuex'
import SettingsDrawer from './SettingsDrawer.vue'
export default {
props: ['parametersList'],
components: {
SettingsDrawer
},
computed: {
...mapGetters({
authUser: 'auth/authUser'
})
},
data () {
return {
mainMenuItems: [
{
text: this.$gettext('Dashboard'),
to: { name: 'Dashboard' },
icon: 'mdi-view-dashboard-outline',
exact: true
},
{
text: this.$gettext('Domains'),
to: { name: 'DomainList' },
icon: 'mdi-domain',
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
},
{
text: this.$gettext('Identities'),
to: { name: 'Identities' },
icon: 'mdi-account',
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
},
{
text: this.$gettext('Alarms'),
to: { name: 'Alarms' },
icon: 'mdi-bell'
},
{
icon: 'mdi-history',
text: this.$gettext('Logs'),
roles: ['SuperAdmins', 'Resellers', 'DomainAdmins'],
children: [
{
text: this.$gettext('Audit trail'),
to: { name: 'AuditTrail' },
roles: ['SuperAdmins']
},
{
text: this.$gettext('Messages'),
to: { name: 'MessageLog' },
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
]
},
{
icon: 'mdi-information',
text: this.$gettext('Information'),
roles: ['SuperAdmins'],
to: { name: 'Information' }
}
]
}
},
methods: {
displayMenuItem (item) {
return (item.roles === undefined || item.roles.indexOf(this.authUser.role) !== -1) && (item.condition === undefined || item.condition())
}
}
}
</script>
<style lang="scss" scoped>
.v-list-item {
&--active {
&::before {
opacity: 0;
}
background-color: #034bad;
color: white;
opacity: 1;
}
}
</style>
@@ -0,0 +1,154 @@
<template>
<v-list>
<template v-for="item in extensionItems">
<template v-if="!(item.activated)">
<v-list-item
class="menu-item unselectable"
:key="item.title"
:exact="item.exact"
color="blue-grey lighten-3"
@click="unselectable()"
>
<v-list-item-icon v-if="item.icon">
<v-icon color="#D3D3D3">{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</template>
<template v-else-if="displayMenuItem(item)">
<v-list-item
v-if="!item.children"
class="menu-item"
:to="item.to"
link
:key="item.title"
:exact="item.exact"
>
<v-list-item-icon v-if="item.icon">
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
color="white"
:key="item.text"
:prepend-icon="item.icon"
no-action>
<template v-slot:activator>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</template>
<template v-for="subitem in item.children">
<v-list-item v-if="!subitem.children"
:key="subitem.text"
:to="subitem.to"
link>
<v-list-item-content>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
:key="subitem.text"
:value="true"
no-action
sub-group>
<template v-slot:activator>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</template>
<v-list-item v-for="subsubitem in subitem.children"
:key="subsubitem.text"
:to="subsubitem.to"
link>
<v-list-item-title>{{ subsubitem.text }}</v-list-item-title>
</v-list-item>
</v-list-group>
</template>
</v-list-group>
</template>
</template>
<settings-drawer
:parametersList="parametersList"
:extension="true"
/>
</v-list>
</template>
<script>
import { mapGetters } from 'vuex'
import { bus } from '@/main'
import SettingsDrawer from './SettingsDrawer.vue'
export default {
props: ['imap', 'parametersList'],
components: {
SettingsDrawer
},
computed: {
...mapGetters({
authUser: 'auth/authUser'
}),
extensionItems () {
return [
{
activated: this.imapMigration,
icon: 'mdi-email-sync-outline',
text: this.$gettext('IMAP Migration'),
roles: ['SuperAdmins', 'Resellers'],
children: [
{
text: this.$gettext('Email providers'),
to: { name: 'ProvdiersList' },
roles: ['SuperAdmins', 'Resellers']
},
{
text: this.$gettext('Migrations'),
to: { name: 'MigrationsList' },
roles: ['Resellers', 'SuperAdmins']
}
]
}
]
}
},
created () {
this.imapMigration = this.imap
bus.$on('imapSettingsChanged', this.imapMigrationStatus)
},
data () {
return {
imapMigration: false
}
},
methods: {
displayMenuItem (item) {
return (item.roles === undefined || item.roles.indexOf(this.authUser.role) !== -1) && (item.condition === undefined || item.condition())
},
unselectable () {
bus.$emit('notification', { msg: this.$gettext('Activate the extension in the settings'), type: 'warning' })
},
imapMigrationStatus (status) {
this.imapMigration = status
}
}
}
</script>
<style lang="scss" scoped>
.v-list-item {
&--active {
&::before {
opacity: 0;
}
background-color: #034bad;
color: white;
opacity: 1;
}
}
.unselectable {
color: lightgrey !important;
}
</style>
+44 -148
View File
@@ -21,64 +21,33 @@
<v-icon>mdi-chevron-left</v-icon>
</v-btn>
</div>
<v-list>
<template v-for="item in menuItems">
<template v-if="displayMenuItem(item)">
<v-list-item
v-if="!item.children"
class="menu-item"
:to="item.to"
link
:key="item.title"
:exact="item.exact"
>
<v-list-item-icon v-if="item.icon">
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
color="white"
:key="item.text"
:prepend-icon="item.icon"
no-action>
<template v-slot:activator>
<v-list-item-title>{{ item.text }}</v-list-item-title>
</template>
<template v-for="subitem in item.children">
<v-list-item v-if="!subitem.children"
:key="subitem.text"
:to="subitem.to"
link>
<v-list-item-content>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
:key="subitem.text"
:value="true"
no-action
sub-group>
<template v-slot:activator>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</template>
<v-list-item v-for="subsubitem in subitem.children"
:key="subsubitem.text"
:to="subsubitem.to"
link>
<v-list-item-title>{{ subsubitem.text }}</v-list-item-title>
</v-list-item>
</v-list-group>
</template>
</v-list-group>
</template>
</template>
</v-list>
<v-layout
justify-center>
<v-chip v-if="page === 1" color="blue lighten-3" large>
<translate>Core</translate>
</v-chip>
<v-chip v-else-if="page === 2" color="blue lighten-3" large>
<translate>Extensions</translate>
</v-chip>
</v-layout>
<base-nav-bar
v-if="page === 1"
:parametersList="parametersList"
/>
<extension-nav-bar
v-else-if="page === 2"
:imap="imapMigration"
:parametersList="parametersList"
/>
<template v-slot:append>
<v-pagination
v-if="!mini"
v-model="page"
:length="2"
circle
color="blue lighten-3"
>
</v-pagination>
<v-menu rounded="lg" offset-y top>
<template v-slot:activator="{ attrs, on }">
<div class="d-flex user-box justify-center align-center white--text py-2" v-bind="attrs" v-on="on">
@@ -113,10 +82,16 @@
</template>
<script>
import parameters from '@/api/parameters'
import { mapGetters } from 'vuex'
import BaseNavBar from './BaseNavBar.vue'
import ExtensionNavBar from './ExtensionNavBar.vue'
import parameters from '@/api/parameters'
export default {
components: {
BaseNavBar,
ExtensionNavBar
},
computed: {
...mapGetters({
authUser: 'auth/authUser'
@@ -139,12 +114,6 @@ export default {
? `${this.authUser.first_name} ${this.authUser.last_name}`
: this.authUser.username
},
menuItems () {
if (this.$route.meta.layout === 'user') {
return this.userSettingsMenuItems
}
return this.mainMenuItems
},
mainColor () {
if (this.$route.meta.layout === 'user') {
return 'grey'
@@ -152,80 +121,20 @@ export default {
return 'primary'
}
},
created () {
parameters.getApplications().then(response => {
this.parametersList = response.data
})
parameters.getApplication('imap_migration').then(response => {
this.imapMigration = response.data.params.enabled_imapmigration
})
},
data () {
return {
parametersList: [],
imapMigration: false,
page: 1,
drawer: true,
mainMenuItems: [
{
text: this.$gettext('Dashboard'),
to: { name: 'Dashboard' },
icon: 'mdi-view-dashboard-outline',
exact: true
},
{
text: this.$gettext('Domains'),
to: { name: 'DomainList' },
icon: 'mdi-domain',
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
},
{
icon: 'mdi-email-sync-outline',
text: this.$gettext('Migrations'),
roles: ['SuperAdmins', 'Resellers'],
children: [
{
text: this.$gettext('Email providers'),
to: { name: 'ProvdiersList' },
roles: ['SuperAdmins', 'Resellers']
},
{
text: this.$gettext('Migrations'),
to: { name: 'MigrationsList' },
roles: ['Resellers', 'SuperAdmins']
}
]
},
{
text: this.$gettext('Identities'),
to: { name: 'Identities' },
icon: 'mdi-account',
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
},
{
text: this.$gettext('Alarms'),
to: { name: 'Alarms' },
icon: 'mdi-bell'
},
{
icon: 'mdi-history',
text: this.$gettext('Logs'),
roles: ['SuperAdmins', 'Resellers', 'DomainAdmins'],
children: [
{
text: this.$gettext('Audit trail'),
to: { name: 'AuditTrail' },
roles: ['SuperAdmins']
},
{
text: this.$gettext('Messages'),
to: { name: 'MessageLog' },
roles: ['DomainAdmins', 'Resellers', 'SuperAdmins']
}
]
},
{
icon: 'mdi-cog',
text: this.$gettext('Settings'),
children: [],
roles: ['SuperAdmins']
},
{
icon: 'mdi-information',
text: this.$gettext('Information'),
roles: ['SuperAdmins'],
to: { name: 'Information' }
}
],
userSettingsMenuItems: [
{
text: this.$gettext('API'),
@@ -275,20 +184,7 @@ export default {
]
}
},
created () {
parameters.getApplications().then(response => {
response.data.forEach(item => {
this.mainMenuItems[6].children.push({
text: item.label,
to: { name: 'ParametersEdit', params: { app: item.name } }
})
})
})
},
methods: {
displayMenuItem (item) {
return (item.roles === undefined || item.roles.indexOf(this.authUser.role) !== -1) && (item.condition === undefined || item.condition())
},
logout () {
this.$store.dispatch('auth/logout').then(() => {
this.$router.push({ name: 'Login' })
@@ -0,0 +1,86 @@
<template>
<v-list-group
color="white"
:key="settings.text"
:prepend-icon="settings.icon"
no-action>
<template v-slot:activator>
<v-list-item-title>{{ settings.title }}</v-list-item-title>
</template>
<template v-for="subitem in settings.children">
<v-list-item v-if="!subitem.children"
:key="subitem.text"
:to="subitem.to"
link>
<v-list-item-content>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-group v-else
:key="subitem.text"
:value="true"
no-action
sub-group>
<template v-slot:activator>
<v-list-item-title>{{ subitem.text }}</v-list-item-title>
</template>
<v-list-item v-for="subsubitem in subitem.children"
:key="subsubitem.text"
:to="subsubitem.to"
link>
<v-list-item-title>{{ subsubitem.text }}</v-list-item-title>
</v-list-item>
</v-list-group>
</template>
</v-list-group>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
props: ['parametersList', 'extension'],
computed: {
...mapGetters({
authUser: 'auth/authUser'
}),
settings () {
const menu = this.settingMenu
this.parametersList.forEach(item => {
if (item.is_extension === this.extension) {
menu.children.push({
text: item.label,
to: { name: 'ParametersEdit', params: { app: item.name } }
})
}
})
return menu
}
},
data () {
return {
settingMenu:
{
title: this.$gettext('Settings'),
icon: 'mdi-cog',
children: [],
roles: ['SuperAdmins']
}
}
}
}
</script>
<style lang="scss" scoped>
.v-list-item {
&--active {
&::before {
opacity: 0;
}
background-color: #034bad;
color: white;
opacity: 1;
}
}
</style>
@@ -136,6 +136,9 @@ export default {
this.formErrors = {}
parameters.saveApplication(this.$route.params.app, this.parameters).then(() => {
bus.$emit('notification', { msg: this.$gettext('Parameters updated') })
if (this.$route.params.app === 'imap_migration') {
bus.$emit('imapSettingsChanged', this.parameters.enabled_imapmigration)
}
}).catch(error => {
this.formErrors = error.response.data
})
+2 -1
View File
@@ -70,5 +70,6 @@ def load_settings():
param_tools.registry.add2(
"global", "dmarc", _("DMARC"),
GLOBAL_PARAMETERS_STRUCT,
serializers.DmarcGlobalParametersSerializer
serializers.DmarcGlobalParametersSerializer,
True
)
+2 -1
View File
@@ -19,7 +19,8 @@ def load_imapmigration_settings():
param_tools.registry.add2(
"global", "imap_migration", ugettext_lazy("IMAP Migration"),
app_settings.IMAP_MIGRATION_PARAMETERS_STRUCT,
serializers.IMAPMigrationSettingsSerializer)
serializers.IMAPMigrationSettingsSerializer,
True)
class IMAPMigrationConfig(AppConfig):
+1
View File
@@ -8,6 +8,7 @@ class ApplicationSerializer(serializers.Serializer):
name = serializers.CharField()
label = serializers.CharField()
is_extension = serializers.BooleanField()
class ParameterChoiceSerializer(serializers.Serializer):
+6 -3
View File
@@ -42,11 +42,13 @@ class Registry(object):
"label": label, "formclass": formclass, "defaults": {}
}
def add2(self, level, app, label, structure, serializer_class):
def add2(self, level, app, label, structure, serializer_class,
is_extension=False):
"""Add new parameters for given app and level."""
self._registry2[level][app] = {
"label": label, "structure": structure,
"serializer_class": serializer_class
"serializer_class": serializer_class,
"is_extension": is_extension
}
def _load_default_values(self, level):
@@ -60,7 +62,8 @@ class Registry(object):
def get_applications(self, level):
"""Return all applications registered for level."""
result = [{"name": key, "label": value["label"]}
result = [{"name": key, "label": value["label"],
"is_extension": value["is_extension"]}
for key, value in self._registry2[level].items()]
return result
+2 -1
View File
@@ -20,7 +20,8 @@ def load_pdfcredential_settings():
param_tools.registry.add2(
"global", "pdfcredentials", ugettext_lazy("PDF Credentials"),
app_settings.PDF_CREDENTIALS_PARAMETERS_STRUCT,
serializers.PDFCredentialsSettingsSerializer)
serializers.PDFCredentialsSettingsSerializer,
True)
class PDFCredentialsConfig(AppConfig):