Skip to content
This repository has been archived by the owner on Aug 9, 2020. It is now read-only.

Add frontend settings page for configuration file extension #55

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.4 on 2019-10-14 13:33

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('management', '0005_blocklisturl_last_updated'),
]

operations = [
migrations.AddField(
model_name='settings',
name='config_file_extension',
field=models.CharField(choices=[('ovpn', 'OVPN'), ('conf', 'CONF')], default='ovpn', max_length=10),
),
]
5 changes: 5 additions & 0 deletions backend/vpnathome/apps/management/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@

class Settings(models.Model):

FILE_EXTENSION_CHOICES = [('ovpn', 'OVPN'), ('conf', 'CONF')]

email_enabled = models.BooleanField(default=False)
registration_enabled = models.BooleanField(default=True)
config_file_extension = models.CharField(choices=FILE_EXTENSION_CHOICES,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need 2 options: one for the client (which mostly expects ovpn), one for server (which mostly requires conf file, as this is what systemd on Linux expects).

I'd then default to ovpn on the client and conf for the server.

default='ovpn',
max_length=10)

class Meta():
verbose_name = 'settings'
Expand Down
4 changes: 3 additions & 1 deletion backend/vpnathome/apps/management/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class SettingsSerializer(serializers.ModelSerializer):

class Meta:
model = Settings
fields = ('email_enabled',
fields = ('FILE_EXTENSION_CHOICES',
'email_enabled',
'config_file_extension',
'registration_enabled',
'email_from',
'email_smtp_server',
Expand Down
55 changes: 55 additions & 0 deletions frontend/src/components/settings/ConfigFileExtensionSettings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<template>
<form class="ui form" @submit.prevent="handleSubmit">
<div class="content">
<!-- TODO Remove hardcoding of available extensions -->
<div class="field">
<div class="ui radio checkbox">
<input id="ovpn" v-model="settings.config_file_extension" type="radio" value="ovpn">
<label for="ovpn">OVPN</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input id="conf" v-model="settings.config_file_extension" type="radio" value="conf">
<label for="conf">CONF</label>
</div>
</div>
<div class="field">
<button type="submit" class="ui button settings-button" role="button" @submit="{}">Save</button>
</div>
</div>
</form>
</template>

<script>
import { Component, Vue } from 'vue-property-decorator';
import NavigationBar from '@/components/NavigationBar.vue';
import _ from 'lodash';

@Component({
name: 'ConfigFileExtensionSettings',
components: {
NavigationBar
}
})
export default class ConfigFileExtensionSettings extends Vue {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have a General settings page, where more misc options can be added in the future. Having a page
per option will probably not look very good.


settings = {
config_file_extension: 'conf'
};

handleSubmit () {
this.$store.dispatch('setSettings', this.settings);
}

mounted () {
this.settings.config_file_extension = _.cloneDeep(this.$store.state.settings.config_file_extension);
}

}

</script>

<style scoped lang="scss">

</style>
3 changes: 2 additions & 1 deletion frontend/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const INITIAL_STATE = {
},
settings: {
email_enabled: window.django.email_enabled,
registration_enabled: window.django.registration_enabled
registration_enabled: window.django.registration_enabled,
config_file_extension: window.django.config_file_extension
}
};

Expand Down
6 changes: 6 additions & 0 deletions frontend/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<EmailSettings/>
</sui-tab-pane>

<sui-tab-pane icon="code file" title="Config File Extension">
<ConfigFileExtensionSettings/>
</sui-tab-pane>

<sui-tab-pane icon="user" title="Registration">
<RegistrationSettings/>
</sui-tab-pane>
Expand All @@ -23,6 +27,7 @@
<script>
import { Component, Vue } from 'vue-property-decorator';
import EmailSettings from '@/components/settings/EmailSettings';
import ConfigFileExtensionSettings from '@/components/settings/ConfigFileExtensionSettings';
import RegistrationSettings from '@/components/settings/RegistrationSettings';
import DnsFilteringSettings from '@/components/settings/DnsFilteringSettings';
import SshKeysSettings from '@/components/settings/SshKeysSettings';
Expand All @@ -31,6 +36,7 @@ import SshKeysSettings from '@/components/settings/SshKeysSettings';
name: 'Settings',
components: {
EmailSettings,
ConfigFileExtensionSettings,
RegistrationSettings,
DnsFilteringSettings,
SshKeysSettings
Expand Down