1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 07:10:09 +01:00

I think this is it :)

This commit is contained in:
Donald Zou 2024-08-17 00:31:46 -04:00
parent d81dce536c
commit c2cbaf0937
5 changed files with 79 additions and 30 deletions

View File

@ -57,14 +57,14 @@
<hr> <hr>
## Table of Content ## 📋 Table of Content
<!-- TOC --> <!-- TOC -->
* [📣 What's New: v4.0](#-whats-new-v40) * [📣 What's New: v4.0](#-whats-new-v40)
* [🎉 New Features](#-new-features) * [🎉 New Features](#-new-features)
* [🧐 Other Changes](#-other-changes) * [🧐 Other Changes](#-other-changes)
* [🥘 New Experimental Features](#-new-experimental-features) * [🥘 New Experimental Features](#-new-experimental-features)
* [Table of Content](#table-of-content) * [📋 Table of Content](#-table-of-content)
* [💡 Features](#-features) * [💡 Features](#-features)
* [📝 Requirements](#-requirements) * [📝 Requirements](#-requirements)
* [Supported Operating Systems](#supported-operating-systems) * [Supported Operating Systems](#supported-operating-systems)
@ -91,7 +91,7 @@
* [Solution 1 from @DaanSelen](#solution-1-from-daanselen) * [Solution 1 from @DaanSelen](#solution-1-from-daanselen)
* [Solution 2 from @shuricksumy](#solution-2-from-shuricksumy) * [Solution 2 from @shuricksumy](#solution-2-from-shuricksumy)
* [📖 WGDashboard REST API Documentation & How to use API Key](#-wgdashboard-rest-api-documentation--how-to-use-api-key) * [📖 WGDashboard REST API Documentation & How to use API Key](#-wgdashboard-rest-api-documentation--how-to-use-api-key)
* [🥘 Experimental Functions](#-experimental-functions) * [🥘 Experimental Features](#-experimental-features)
* [Cross-Server Access](#cross-server-access) * [Cross-Server Access](#cross-server-access)
* [Desktop App](#desktop-app) * [Desktop App](#desktop-app)
* [🔍 Screenshot](#-screenshot) * [🔍 Screenshot](#-screenshot)
@ -531,7 +531,7 @@ Please visit [shuricksumy/docker-wgdashboard](https://github.com/shuricksumy/doc
Please visit the [API Documentation](./docs/api-documents.md) Please visit the [API Documentation](./docs/api-documents.md)
## 🥘 Experimental Functions ## 🥘 Experimental Features
### Cross-Server Access ### Cross-Server Access

View File

@ -12,6 +12,7 @@ import secrets
import subprocess import subprocess
import time import time
import re import re
import urllib.error
import uuid import uuid
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Any from typing import Any
@ -2003,6 +2004,24 @@ def API_traceroute_execute():
else: else:
return ResponseObject(False, "Please provide ipAddress") return ResponseObject(False, "Please provide ipAddress")
@app.route(f'{APP_PREFIX}/api/getDashboardUpdate')
def API_getDashboardUpdate():
import urllib.request as req;
try:
r = req.urlopen("https://api.github.com/repos/donaldzou/WGDashboard/releases/latest", timeout=5).read()
data = dict(json.loads(r))
tagName = data.get('tag_name')
htmlUrl = data.get('html_url')
if tagName is not None and htmlUrl is not None:
if tagName != DASHBOARD_VERSION:
return ResponseObject(message=f"{tagName} is now avaible for update!", data=htmlUrl)
else:
return ResponseObject(message="You're on the latest version")
return ResponseObject(False)
except urllib.error.HTTPError as e:
return ResponseObject(False, f"Request to GitHub API failed. Returned a {e.code} status.")
''' '''
Sign Up Sign Up
@ -2111,7 +2130,6 @@ _, app_port = DashboardConfig.GetConfig("Server", "app_port")
_, WG_CONF_PATH = DashboardConfig.GetConfig("Server", "wg_conf_path") _, WG_CONF_PATH = DashboardConfig.GetConfig("Server", "wg_conf_path")
WireguardConfigurations: dict[str, WireguardConfiguration] = {} WireguardConfigurations: dict[str, WireguardConfiguration] = {}
WireguardConfigurations = _getConfigurationList() WireguardConfigurations = _getConfigurationList()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,7 @@
import {wgdashboardStore} from "@/stores/wgdashboardStore.js"; import {wgdashboardStore} from "@/stores/wgdashboardStore.js";
import {WireguardConfigurationsStore} from "@/stores/WireguardConfigurationsStore.js"; import {WireguardConfigurationsStore} from "@/stores/WireguardConfigurationsStore.js";
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js"; import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
import {fetchGet} from "@/utilities/fetch.js";
export default { export default {
name: "navbar", name: "navbar",
@ -9,6 +10,27 @@ export default {
const wireguardConfigurationsStore = WireguardConfigurationsStore(); const wireguardConfigurationsStore = WireguardConfigurationsStore();
const dashboardConfigurationStore = DashboardConfigurationStore(); const dashboardConfigurationStore = DashboardConfigurationStore();
return {wireguardConfigurationsStore, dashboardConfigurationStore} return {wireguardConfigurationsStore, dashboardConfigurationStore}
},
data(){
return {
updateAvailable: false,
updateMessage: "Checking for update...",
updateUrl: ""
}
},
mounted() {
fetchGet("/api/getDashboardUpdate", {}, (res) => {
if (res.status){
if (res.data){
this.updateAvailable = true
this.updateUrl = res.data
}
this.updateMessage = res.message
}else{
this.updateMessage = "Failed to check available update"
console.log(`Failed to get update: ${res.message}`)
}
})
} }
} }
</script> </script>
@ -65,11 +87,20 @@ export default {
@click="this.dashboardConfigurationStore.signOut()" @click="this.dashboardConfigurationStore.signOut()"
role="button" style="font-weight: bold"> role="button" style="font-weight: bold">
<i class="bi bi-box-arrow-left me-2"></i> <i class="bi bi-box-arrow-left me-2"></i>
Sign Out</a></li> Sign Out</a>
</ul> </li>
<ul class="nav flex-column"> <li class="nav-item" style="font-size: 0.8rem">
<li class="nav-item"><a href="https://github.com/donaldzou/WGDashboard/releases/tag/"><small class="nav-link text-muted"></small></a></li> <a :href="this.updateUrl" v-if="this.updateAvailable" class="text-decoration-none" target="_blank">
<small class="nav-link text-muted rounded-3" >
{{ this.updateMessage }}
</small>
</a>
<small class="nav-link text-muted" v-else>
{{ this.updateMessage }}
</small>
</li>
</ul> </ul>
</div> </div>
</nav> </nav>
</div> </div>