mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-09-04 02:41:14 +00:00
Backup and restore for AWG is done
This commit is contained in:
21
src/static/app/src/components/protocolBadge.vue
Normal file
21
src/static/app/src/components/protocolBadge.vue
Normal file
@@ -0,0 +1,21 @@
|
||||
<script setup>
|
||||
import LocaleText from "@/components/text/localeText.vue";
|
||||
|
||||
const props = defineProps({
|
||||
protocol: String,
|
||||
mini: false
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="badge wireguardBg rounded-3 shadow" v-if="protocol === 'wg'">
|
||||
WireGuard <LocaleText t="Configuration" v-if="!mini"></LocaleText>
|
||||
</span>
|
||||
<span class="badge amneziawgBg rounded-3 shadow" v-else-if="protocol === 'awg'">
|
||||
AmneziaWG <LocaleText t="Configuration" v-if="!mini"></LocaleText>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@@ -2,12 +2,14 @@
|
||||
import {onMounted, ref} from "vue";
|
||||
import dayjs from "dayjs";
|
||||
import LocaleText from "@/components/text/localeText.vue";
|
||||
import ProtocolBadge from "@/components/protocolBadge.vue";
|
||||
|
||||
const props = defineProps({
|
||||
configurationName: String,
|
||||
backups: Array,
|
||||
open: false,
|
||||
selectedConfigurationBackup: Object
|
||||
selectedConfigurationBackup: Object,
|
||||
protocol: Array
|
||||
})
|
||||
|
||||
const emit = defineEmits(["select"])
|
||||
@@ -28,18 +30,20 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<div class="card rounded-3 shadow-sm">
|
||||
<a role="button" class="card-body d-flex align-items-center text-decoration-none" @click="showBackups = !showBackups">
|
||||
<div class="d-flex gap-3 align-items-center">
|
||||
<h6 class="mb-0">
|
||||
<samp>
|
||||
{{configurationName}}
|
||||
</samp>
|
||||
</h6>
|
||||
<small class="text-muted">
|
||||
<LocaleText :t="backups.length + (backups.length > 1 ? ' Backups':' Backup')"></LocaleText>
|
||||
</small>
|
||||
</div>
|
||||
<h5 class="ms-auto mb-0 dropdownIcon text-muted" :class="{active: showBackups}">
|
||||
<a role="button" class="card-body d-flex align-items-center text-decoration-none d-flex gap-3" @click="showBackups = !showBackups">
|
||||
<h6 class="mb-0 d-flex align-items-center gap-3">
|
||||
<samp>
|
||||
{{configurationName}}
|
||||
</samp>
|
||||
|
||||
<ProtocolBadge
|
||||
v-for="p in protocol"
|
||||
:protocol="p"></ProtocolBadge>
|
||||
</h6>
|
||||
<small class="text-muted ms-auto d-block">
|
||||
<LocaleText :t="backups.length + (backups.length > 1 ? ' Backups':' Backup')"></LocaleText>
|
||||
</small>
|
||||
<h5 class="mb-0 dropdownIcon text-muted" :class="{active: showBackups}">
|
||||
<i class="bi bi-chevron-down"></i>
|
||||
</h5>
|
||||
</a>
|
||||
|
@@ -6,6 +6,7 @@ import {parse} from "cidr-tools";
|
||||
import {fetchPost} from "@/utilities/fetch.js";
|
||||
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
||||
import {useRouter} from "vue-router";
|
||||
import ProtocolBadge from "@/components/protocolBadge.vue";
|
||||
|
||||
|
||||
const props = defineProps({
|
||||
@@ -14,7 +15,8 @@ const props = defineProps({
|
||||
|
||||
const newConfiguration = reactive({
|
||||
ConfigurationName: props.selectedConfigurationBackup.filename.split("_")[0],
|
||||
Backup: props.selectedConfigurationBackup.filename
|
||||
Backup: props.selectedConfigurationBackup.filename,
|
||||
Protocol: props.selectedConfigurationBackup.protocol
|
||||
})
|
||||
|
||||
const lineSplit = props.selectedConfigurationBackup.content.split("\n");
|
||||
@@ -136,6 +138,16 @@ const submitRestore = async () => {
|
||||
<LocaleText t="Configuration"></LocaleText>
|
||||
</h4>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-muted mb-1">
|
||||
<small>
|
||||
<LocaleText t="Protocol"></LocaleText>
|
||||
</small>
|
||||
</label>
|
||||
<h5 class="mb-0">
|
||||
<ProtocolBadge :protocol="selectedConfigurationBackup.protocol" :mini="true"></ProtocolBadge>
|
||||
</h5>
|
||||
</div>
|
||||
<div>
|
||||
<label class="text-muted mb-1" for="ConfigurationName"><small>
|
||||
<LocaleText t="Configuration Name"></LocaleText>
|
||||
|
@@ -180,11 +180,7 @@ router.beforeEach(async (to, from, next) => {
|
||||
next()
|
||||
}
|
||||
}else {
|
||||
if (to.path === "/signin" && await checkAuth()){
|
||||
next("/")
|
||||
}else{
|
||||
next()
|
||||
}
|
||||
next()
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -2,15 +2,22 @@
|
||||
import {parse} from "cidr-tools";
|
||||
import '@/utilities/wireguard.js'
|
||||
import {WireguardConfigurationsStore} from "@/stores/WireguardConfigurationsStore.js";
|
||||
import {fetchPost} from "@/utilities/fetch.js";
|
||||
import {fetchGet, fetchPost} from "@/utilities/fetch.js";
|
||||
import LocaleText from "@/components/text/localeText.vue";
|
||||
import {ref} from "vue";
|
||||
|
||||
export default {
|
||||
name: "newConfiguration",
|
||||
components: {LocaleText},
|
||||
setup(){
|
||||
async setup(){
|
||||
const store = WireguardConfigurationsStore()
|
||||
return {store}
|
||||
const protocols = ref([])
|
||||
await fetchGet("/api/protocolsEnabled", {}, (res) => {
|
||||
protocols.value = res.data
|
||||
})
|
||||
|
||||
|
||||
return {store, protocols}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
@@ -279,30 +286,31 @@ export default {
|
||||
<div id="newConfigurationOptionalAccordionCollapse"
|
||||
class="accordion-collapse collapse" data-bs-parent="#newConfigurationOptionalAccordion">
|
||||
<div class="accordion-body d-flex flex-column gap-3">
|
||||
<div class="card rounded-3">
|
||||
<div class="card-header">PreUp</div>
|
||||
<div class="card rounded-3" v-for="key in ['PreUp', 'PreDown', 'PostUp', 'PostDown']">
|
||||
<div class="card-header">{{ key }}</div>
|
||||
<div class="card-body">
|
||||
<input type="text" class="form-control" id="preUp" v-model="this.newConfiguration.PreUp">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card rounded-3">
|
||||
<div class="card-header">PreDown</div>
|
||||
<div class="card-body">
|
||||
<input type="text" class="form-control" id="preDown" v-model="this.newConfiguration.PreDown">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card rounded-3">
|
||||
<div class="card-header">PostUp</div>
|
||||
<div class="card-body">
|
||||
<input type="text" class="form-control" id="postUp" v-model="this.newConfiguration.PostUp">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card rounded-3">
|
||||
<div class="card-header">PostDown</div>
|
||||
<div class="card-body">
|
||||
<input type="text" class="form-control" id="postDown" v-model="this.newConfiguration.PostDown">
|
||||
<input type="text"
|
||||
class="form-control font-monospace" :id="key" v-model="this.newConfiguration[key]">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="card rounded-3">-->
|
||||
<!-- <div class="card-header">PreDown</div>-->
|
||||
<!-- <div class="card-body">-->
|
||||
<!-- <input type="text" class="form-control" id="preDown" v-model="this.newConfiguration.PreDown">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="card rounded-3">-->
|
||||
<!-- <div class="card-header">PostUp</div>-->
|
||||
<!-- <div class="card-body">-->
|
||||
<!-- <input type="text" class="form-control" id="postUp" v-model="this.newConfiguration.PostUp">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="card rounded-3">-->
|
||||
<!-- <div class="card-header">PostDown</div>-->
|
||||
<!-- <div class="card-body">-->
|
||||
<!-- <input type="text" class="form-control" id="postDown" v-model="this.newConfiguration.PostDown">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -67,6 +67,7 @@ const selectedConfiguration = ref("")
|
||||
@select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"
|
||||
:selectedConfigurationBackup="selectedConfigurationBackup"
|
||||
:open="selectedConfiguration === c"
|
||||
:protocol="[...new Set(backups.NonExistingConfigurations[c].map(x => x.protocol))]"
|
||||
v-for="c in Object.keys(backups.NonExistingConfigurations)"
|
||||
:configuration-name="c" :backups="backups.NonExistingConfigurations[c]"></BackupGroup>
|
||||
<div v-if="Object.keys(backups.NonExistingConfigurations).length === 0">
|
||||
|
Reference in New Issue
Block a user