Refactored some API endpoint
Some checks failed
Qodana / qodana (push) Has been cancelled

This commit is contained in:
Donald Zou 2025-04-07 18:45:12 +08:00
parent 8d4784052a
commit 66f4507dee
3 changed files with 35 additions and 35 deletions

View File

@ -2304,14 +2304,14 @@ def API_createWireguardConfigurationBackup():
@app.post(f'{APP_PREFIX}/api/deleteWireguardConfigurationBackup')
def API_deleteWireguardConfigurationBackup():
data = request.get_json()
if ("configurationName" not in data.keys() or
"backupFileName" not in data.keys() or
len(data['configurationName']) == 0 or
len(data['backupFileName']) == 0):
if ("ConfigurationName" not in data.keys() or
"BackupFileName" not in data.keys() or
len(data['ConfigurationName']) == 0 or
len(data['BackupFileName']) == 0):
return ResponseObject(False,
"Please provide configurationName and backupFileName in body")
configurationName = data['configurationName']
backupFileName = data['backupFileName']
configurationName = data['ConfigurationName']
backupFileName = data['BackupFileName']
if configurationName not in WireguardConfigurations.keys():
return ResponseObject(False, "Configuration does not exist")
@ -2329,14 +2329,14 @@ def API_downloadWireguardConfigurationBackup():
@app.post(f'{APP_PREFIX}/api/restoreWireguardConfigurationBackup')
def API_restoreWireguardConfigurationBackup():
data = request.get_json()
if ("configurationName" not in data.keys() or
"backupFileName" not in data.keys() or
len(data['configurationName']) == 0 or
len(data['backupFileName']) == 0):
if ("ConfigurationName" not in data.keys() or
"BackupFileName" not in data.keys() or
len(data['ConfigurationName']) == 0 or
len(data['BackupFileName']) == 0):
return ResponseObject(False,
"Please provide configurationName and backupFileName in body")
configurationName = data['configurationName']
backupFileName = data['backupFileName']
configurationName = data['ConfigurationName']
backupFileName = data['BackupFileName']
if configurationName not in WireguardConfigurations.keys():
return ResponseObject(False, "Configuration does not exist")

View File

@ -15,8 +15,8 @@ const loading = ref(false);
const deleteBackup = () => {
loading.value = true;
fetchPost("/api/deleteWireguardConfigurationBackup", {
configurationName: route.params.id,
backupFileName: props.b.filename
ConfigurationName: route.params.id,
BackupFileName: props.b.filename
}, (res) => {
loading.value = false;
if (res.status){
@ -31,8 +31,8 @@ const deleteBackup = () => {
const restoreBackup = () => {
loading.value = true;
fetchPost("/api/restoreWireguardConfigurationBackup", {
configurationName: route.params.id,
backupFileName: props.b.filename
ConfigurationName: route.params.id,
BackupFileName: props.b.filename
}, (res) => {
loading.value = false;
restoreConfirmation.value = false;

View File

@ -41,26 +41,26 @@ const store = DashboardConfigurationStore()
</a>
</div>
</div>
<div class="d-flex flex-column p-3 gap-2">
<div class="d-flex w-100">
<h5 class="mb-0">
<LocaleText t="WGDashboard Help Bot"></LocaleText>
</h5>
<div class="form-check form-switch ms-auto mb-0">
<input class="form-check-input"
v-model="store.HelpAgent.Enable"
type="checkbox" role="switch" id="enableHelpAgent">
<label class="form-check-label fw-bold" for="enableHelpAgent">
<LocaleText :t="store.HelpAgent.Enable ? 'Enabled':'Disabled'"></LocaleText>
</label>
<!-- <div class="d-flex flex-column p-3 gap-2">-->
<!-- <div class="d-flex w-100">-->
<!-- <h5 class="mb-0">-->
<!-- <LocaleText t="WGDashboard Help Bot"></LocaleText>-->
<!-- </h5>-->
<!-- <div class="form-check form-switch ms-auto mb-0">-->
<!-- <input class="form-check-input"-->
<!-- v-model="store.HelpAgent.Enable"-->
<!-- type="checkbox" role="switch" id="enableHelpAgent">-->
<!-- <label class="form-check-label fw-bold" for="enableHelpAgent">-->
<!-- <LocaleText :t="store.HelpAgent.Enable ? 'Enabled':'Disabled'"></LocaleText>-->
<!-- </label>-->
<!-- </div>-->
<!-- </div>-->
<!-- <small class="text-muted" v-if="!store.HelpAgent.Enable">-->
<!-- By using this service, you're agreed to send your messages to a Large Language Model (LLM) hosted on DigitalOcean. Your messages will not store on the server in any type of form, you can verify it on <a href="https://github.com/donaldzou/WGDashboard-Bot-Middleware" target="_blank">here</a>. For more information, please contact me through GitHub or email.-->
<!-- </small>-->
<!-- </div>-->
</div>
</div>
<small class="text-muted" v-if="!store.HelpAgent.Enable">
By using this service, you're agreed to send your messages to a Large Language Model (LLM) hosted on DigitalOcean. Your messages will not store on the server in any type of form, you can verify it on <a href="https://github.com/donaldzou/WGDashboard-Bot-Middleware" target="_blank">here</a>. For more information, please contact me through GitHub or email.
</small>
</div>
</div>
<AgentContainer key="agentContainer" v-if="store.HelpAgent.Enable"></AgentContainer>
<!-- <AgentContainer key="agentContainer" v-if="store.HelpAgent.Enable"></AgentContainer>-->
</TransitionGroup>
</div>
</template>