mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-12-26 17:04:14 +08:00
zh-CN Update
This commit is contained in:
parent
94b597d29a
commit
49467c906d
11 changed files with 65 additions and 45 deletions
|
@ -1388,7 +1388,7 @@ class DashboardConfig:
|
|||
elif type(value) in [int, float]:
|
||||
self.__config[section][key] = str(value)
|
||||
elif type(value) is list:
|
||||
self.__config[section][key] = "||".join(value)
|
||||
self.__config[section][key] = "||".join(value).strip("||")
|
||||
else:
|
||||
self.__config[section][key] = value
|
||||
return self.SaveConfig(), ""
|
||||
|
@ -1416,7 +1416,7 @@ class DashboardConfig:
|
|||
return True, False
|
||||
|
||||
if section == "WireGuardConfiguration" and key == "autostart":
|
||||
return True, self.__config[section][key].split("||")
|
||||
return True, list(filter(lambda x: len(x) > 0, self.__config[section][key].split("||")))
|
||||
|
||||
return True, self.__config[section][key]
|
||||
|
||||
|
@ -1894,7 +1894,7 @@ def API_updateDashboardConfigurationItem():
|
|||
WireguardConfigurations.clear()
|
||||
_getConfigurationList()
|
||||
|
||||
return ResponseObject()
|
||||
return ResponseObject(True, data=DashboardConfig.GetConfig(data["section"], data["key"])[1])
|
||||
|
||||
@app.get(f'{APP_PREFIX}/api/getDashboardAPIKeys')
|
||||
def API_getDashboardAPIKeys():
|
||||
|
|
4
src/static/app/dist/assets/index.css
vendored
4
src/static/app/dist/assets/index.css
vendored
File diff suppressed because one or more lines are too long
4
src/static/app/dist/assets/index.js
vendored
4
src/static/app/dist/assets/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,7 @@
|
|||
<script setup>
|
||||
import {onMounted, ref} from "vue";
|
||||
import dayjs from "dayjs";
|
||||
import LocaleText from "@/components/text/localeText.vue";
|
||||
|
||||
const props = defineProps({
|
||||
configurationName: String,
|
||||
|
@ -35,7 +36,9 @@ onMounted(() => {
|
|||
</samp>
|
||||
</h6>
|
||||
<small class="text-muted">
|
||||
{{backups.length}} {{backups.length > 1 ? "Backups": "Backup" }}
|
||||
{{backups.length}}
|
||||
<LocaleText t="Backups" v-if="backups.length > 1"></LocaleText>
|
||||
<LocaleText t="Backup" v-else></LocaleText>
|
||||
</small>
|
||||
</div>
|
||||
<h5 class="ms-auto mb-0 dropdownIcon text-muted" :class="{active: showBackups}">
|
||||
|
@ -59,7 +62,8 @@ onMounted(() => {
|
|||
</small>
|
||||
<small >
|
||||
<i class="bi bi-database me-2"></i>
|
||||
{{b.database? "Yes" : "No" }}
|
||||
<LocaleText t="Yes" v-if="b.database"></LocaleText>
|
||||
<LocaleText t="No" v-else></LocaleText>
|
||||
</small>
|
||||
<small class="text-muted ms-auto">
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
|
|
|
@ -105,14 +105,14 @@ const availableIPAddress = computed(() => {
|
|||
const peersCount = computed(() => {
|
||||
if (props.selectedConfigurationBackup.database){
|
||||
let l = props.selectedConfigurationBackup.databaseContent.split("\n")
|
||||
return l.filter(x => x.search('INSERT INTO "(.*)"') >= 0).length
|
||||
return l.filter(x => x.search(`INSERT INTO "${newConfiguration.ConfigurationName}"`) >= 0).length
|
||||
}
|
||||
return 0
|
||||
})
|
||||
const restrictedPeersCount = computed(() => {
|
||||
if (props.selectedConfigurationBackup.database){
|
||||
let l = props.selectedConfigurationBackup.databaseContent.split("\n")
|
||||
return l.filter(x => x.search('INSERT INTO "(.*)_restrict_access"') >= 0).length
|
||||
return l.filter(x => x.search(`INSERT INTO "${newConfiguration.ConfigurationName}_restrict_access"`) >= 0).length
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
@ -136,7 +136,7 @@ const submitRestore = async () => {
|
|||
<form class="d-flex flex-column gap-3">
|
||||
<div class="d-flex flex-column flex-sm-row align-items-start align-items-sm-center gap-3">
|
||||
<h4 class="mb-0">
|
||||
<LocaleText t="Configuration File"></LocaleText>
|
||||
<LocaleText t="Configuration"></LocaleText>
|
||||
</h4>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -220,7 +220,7 @@ const submitRestore = async () => {
|
|||
<LocaleText t="IP Address/CIDR"></LocaleText>
|
||||
</small>
|
||||
<small class="ms-auto" :class="[availableIPAddress > 0 ? 'text-success':'text-danger']">
|
||||
{{availableIPAddress}} Available IP Address
|
||||
<LocaleText :t="availableIPAddress + ' Available IP Address'"></LocaleText>
|
||||
</small>
|
||||
</label>
|
||||
<input type="text" class="form-control"
|
||||
|
@ -299,14 +299,16 @@ const submitRestore = async () => {
|
|||
<div class="col-sm">
|
||||
<div class="card text-bg-success rounded-3">
|
||||
<div class="card-body">
|
||||
<i class="bi bi-person-fill me-2"></i> Contain <strong>{{peersCount}}</strong> Peer{{peersCount > 1 ? 's':''}}
|
||||
<i class="bi bi-person-fill me-2"></i>
|
||||
<LocaleText t="Contain"></LocaleText> <strong>{{peersCount}}</strong> <LocaleText t="Peer" v-if="peersCount > 1"></LocaleText><LocaleText t="Peer" v-else></LocaleText>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="card text-bg-warning rounded-3">
|
||||
<div class="card-body">
|
||||
<i class="bi bi-person-fill-lock me-2"></i> Contain <strong>{{restrictedPeersCount}}</strong> Restricted Peer{{restrictedPeersCount > 1 ? 's':''}}
|
||||
<i class="bi bi-person-fill-lock me-2"></i>
|
||||
<LocaleText t="Contain"></LocaleText> <strong>{{restrictedPeersCount}}</strong> <LocaleText t="Restricted Peers" v-if="restrictedPeersCount > 1" /><LocaleText t="Restricted Peers" v-else></LocaleText>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -318,7 +320,8 @@ const submitRestore = async () => {
|
|||
:disabled="!validateForm || loading"
|
||||
@click="submitRestore()"
|
||||
>
|
||||
<i class="bi bi-clock-history me-2"></i> {{ !loading ? 'Restore':'Restoring...'}}
|
||||
<i class="bi bi-clock-history me-2"></i>
|
||||
<LocaleText :t="!loading ? 'Restore':'Restoring...'"></LocaleText>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -78,7 +78,7 @@ export default {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="d-flex flex-column gap-2">
|
||||
<form class="d-flex flex-column gap-2">
|
||||
<div class="row g-2">
|
||||
<div class="col-sm">
|
||||
<div class="form-group">
|
||||
|
@ -88,6 +88,7 @@ export default {
|
|||
</small></strong>
|
||||
</label>
|
||||
<input type="password" class="form-control"
|
||||
autocomplete="current-password"
|
||||
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
|
||||
v-model="this.value.currentPassword"
|
||||
:id="'currentPassword_' + this.uuid">
|
||||
|
@ -102,6 +103,7 @@ export default {
|
|||
</small></strong>
|
||||
</label>
|
||||
<input type="password" class="form-control"
|
||||
autocomplete="new-password"
|
||||
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
|
||||
v-model="this.value.newPassword"
|
||||
:id="'newPassword_' + this.uuid">
|
||||
|
@ -116,6 +118,7 @@ export default {
|
|||
</small></strong>
|
||||
</label>
|
||||
<input type="password" class="form-control"
|
||||
autocomplete="new-password"
|
||||
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
|
||||
v-model="this.value.repeatNewPassword"
|
||||
:id="'repeatNewPassword_' + this.uuid">
|
||||
|
@ -128,7 +131,7 @@ export default {
|
|||
<i class="bi bi-save2-fill me-2"></i>
|
||||
<LocaleText t="Update Password"></LocaleText>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
|
|
@ -45,7 +45,6 @@ export default {
|
|||
handler(newValue){
|
||||
if (newValue){
|
||||
fetchGet("/api/getDashboardAPIKeys", {}, (res) => {
|
||||
console.log(res)
|
||||
if(res.status){
|
||||
this.apiKeys = res.data
|
||||
}else{
|
||||
|
|
|
@ -13,13 +13,17 @@ const configurations = computed(() => {
|
|||
})
|
||||
|
||||
const updateAutostart = async () => {
|
||||
console.log(data.value)
|
||||
await fetchPost("/api/updateDashboardConfigurationItem", {
|
||||
section: "WireGuardConfiguration",
|
||||
key: "autostart",
|
||||
value: data.value
|
||||
}, async (res) => {
|
||||
console.log(res);
|
||||
if (res.status){
|
||||
store.newMessage("Server", "Start up configurations saved", "success")
|
||||
data.value = res.data
|
||||
}else{
|
||||
store.newMessage("Server", "Start up configurations failed to save", "danger")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -29,12 +33,8 @@ const toggle = (c) => {
|
|||
}else{
|
||||
data.value.push(c)
|
||||
}
|
||||
}
|
||||
|
||||
watch(data, () => {
|
||||
updateAutostart()
|
||||
})
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -2,7 +2,6 @@ import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.
|
|||
|
||||
export const GetLocale = (key) => {
|
||||
const store = DashboardConfigurationStore()
|
||||
|
||||
if (store.Locale === null)
|
||||
return key
|
||||
const reg = Object.keys(store.Locale)
|
||||
|
@ -10,6 +9,7 @@ export const GetLocale = (key) => {
|
|||
return key.match(new RegExp('^' + x + '$', 'gi')) !== null
|
||||
})
|
||||
if (match.length === 0 || match.length > 1){
|
||||
// console.log(`[Translation Needed] Language: ${store.Configuration.Server.dashboard_language} \nKey: ${key}`)
|
||||
return key
|
||||
}
|
||||
return key.replace(new RegExp(match[0], 'gi'), store.Locale[match[0]])
|
||||
|
|
|
@ -41,7 +41,9 @@ const selectedConfiguration = ref("")
|
|||
<i class="bi bi-1-circle-fill"></i>
|
||||
</h1>
|
||||
<div>
|
||||
<h4 class="mb-0">Step 1</h4>
|
||||
<h4 class="mb-0">
|
||||
<LocaleText t="Step 1"></LocaleText>
|
||||
</h4>
|
||||
<small class="text-muted">
|
||||
<LocaleText t="Select a backup you want to restore" v-if="!confirm"></LocaleText>
|
||||
<LocaleText t="Click to change a backup" v-else></LocaleText>
|
||||
|
@ -50,7 +52,9 @@ const selectedConfiguration = ref("")
|
|||
</div>
|
||||
<Transition name="zoomReversed">
|
||||
<div class="ms-sm-auto" v-if="confirm">
|
||||
<small class="text-muted">Selected Backup</small>
|
||||
<small class="text-muted">
|
||||
<LocaleText t="Selected Backup"></LocaleText>
|
||||
</small>
|
||||
<h6>
|
||||
<samp>{{selectedConfigurationBackup.filename}}</samp>
|
||||
</h6>
|
||||
|
@ -58,21 +62,7 @@ const selectedConfiguration = ref("")
|
|||
</Transition>
|
||||
</div>
|
||||
<div id="step1Detail" v-if="!confirm">
|
||||
<!-- <div class="mb-4">-->
|
||||
<!-- <h5>Backup of existing WireGuard Configurations</h5>-->
|
||||
<!-- <hr>-->
|
||||
<!-- <div class="d-flex gap-3 flex-column">-->
|
||||
<!-- <BackupGroup-->
|
||||
<!-- @select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"-->
|
||||
<!-- :open="selectedConfiguration === c"-->
|
||||
<!-- :selectedConfigurationBackup="selectedConfigurationBackup"-->
|
||||
<!-- v-for="c in Object.keys(backups.ExistingConfigurations)"-->
|
||||
<!-- :configuration-name="c" :backups="backups.ExistingConfigurations[c]"></BackupGroup>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<div class="mb-4">
|
||||
<!-- <h5>Backup of non-existing WireGuard Configurations</h5>-->
|
||||
<!-- <hr>-->
|
||||
<div class="d-flex gap-3 flex-column">
|
||||
<BackupGroup
|
||||
@select="(b) => {selectedConfigurationBackup = b; selectedConfiguration = c; confirm = true}"
|
||||
|
@ -83,7 +73,9 @@ const selectedConfiguration = ref("")
|
|||
<div v-if="Object.keys(backups.NonExistingConfigurations).length === 0">
|
||||
<div class="card rounded-3">
|
||||
<div class="card-body">
|
||||
<p class="mb-0">You don't have any configuration to restore</p>
|
||||
<p class="mb-0">
|
||||
<LocaleText t="You don't have any configuration to restore"></LocaleText>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -242,5 +242,24 @@
|
|||
"Is Alive": "在线",
|
||||
"Average / Min / Max Round Trip Time": "平均 / 最低 / 最高来回通讯延迟",
|
||||
"Sent / Received / Lost Package": "发送 / 接收 / 丢失数据包",
|
||||
"Manual restart of WGDashboard is needed to apply changes on IP Address and Listen Port": "更改 IP 地址或监听端口后需要手动重启 WGDashboard 以使用最新的设置"
|
||||
"Manual restart of WGDashboard is needed to apply changes on IP Address and Listen Port": "更改 IP 地址或监听端口后需要手动重启 WGDashboard 以使用最新的设置",
|
||||
"Restore Configuration": "恢复配置",
|
||||
"Step (.*)": "第$1步",
|
||||
"Select a backup you want to restore": "选择一个您想恢复的配置",
|
||||
"Click to change a backup": "点击更换备份",
|
||||
"Selected Backup": "已选择备份",
|
||||
"You don't have any configuration to restore": "您没有任何配置备份可以恢复",
|
||||
"Help": "帮助",
|
||||
"Backups": "个备份",
|
||||
"Backup": "个备份",
|
||||
"Yes": "是",
|
||||
"No": "否",
|
||||
"Backup not selected": "没有选择备份",
|
||||
"Confirm \\& edit restore information": "确认和编辑备份信息",
|
||||
"(.*) Available IP Address": "$1个可用的 IP 地址",
|
||||
"Database File": "数据库文件",
|
||||
"Contain": "含有",
|
||||
"Restricted Peers?": "已限制访问端点",
|
||||
"Restore": "恢复",
|
||||
"Restoring": "恢复中..."
|
||||
}
|
Loading…
Reference in a new issue