mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-21 20:12:33 +03:00
Created about page
Created about page with version check and some basic info. Removed footer.
This commit is contained in:
parent
fdb36e4711
commit
185331f10b
5 changed files with 164 additions and 2 deletions
|
@ -808,3 +808,10 @@ func ApplyServerConfig(db store.IStore, tmplBox *rice.Box) echo.HandlerFunc {
|
|||
return c.JSON(http.StatusOK, jsonHTTPResponse{true, "Applied server config successfully"})
|
||||
}
|
||||
}
|
||||
|
||||
// AboutPage handler
|
||||
func AboutPage() echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
return c.Render(http.StatusOK, "about.html", map[string]interface{}{})
|
||||
}
|
||||
}
|
||||
|
|
1
main.go
1
main.go
|
@ -147,6 +147,7 @@ func main() {
|
|||
sendmail = emailer.NewSmtpMail(util.SmtpHostname, util.SmtpPort, util.SmtpUsername, util.SmtpPassword, util.SmtpNoTLSCheck, util.SmtpAuthType, util.EmailFromName, util.EmailFrom, util.SmtpEncryption)
|
||||
}
|
||||
|
||||
app.GET(util.BasePath+"/about", handler.AboutPage())
|
||||
app.GET(util.BasePath+"/_health", handler.Health())
|
||||
app.POST(util.BasePath+"/new-client", handler.NewClient(db), handler.ValidSession, handler.ContentTypeJson)
|
||||
app.POST(util.BasePath+"/update-client", handler.UpdateClient(db), handler.ValidSession, handler.ContentTypeJson)
|
||||
|
|
|
@ -93,6 +93,11 @@ func New(tmplBox *rice.Box, extraData map[string]string, secret []byte) *echo.Ec
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
aboutPageString, err := tmplBox.String("about.html")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// create template list
|
||||
funcs := template.FuncMap{
|
||||
"StringsJoin": strings.Join,
|
||||
|
@ -105,6 +110,7 @@ func New(tmplBox *rice.Box, extraData map[string]string, secret []byte) *echo.Ec
|
|||
templates["global_settings.html"] = template.Must(template.New("global_settings").Funcs(funcs).Parse(tmplBaseString + tmplGlobalSettingsString))
|
||||
templates["status.html"] = template.Must(template.New("status").Funcs(funcs).Parse(tmplBaseString + tmplStatusString))
|
||||
templates["wake_on_lan_hosts.html"] = template.Must(template.New("wake_on_lan_hosts").Funcs(funcs).Parse(tmplBaseString + tmplWakeOnLanHostsString))
|
||||
templates["about.html"] = template.Must(template.New("about").Funcs(funcs).Parse(tmplBaseString + aboutPageString))
|
||||
|
||||
e.Logger.SetLevel(log.DEBUG)
|
||||
e.Pre(middleware.RemoveTrailingSlash())
|
||||
|
|
139
templates/about.html
Normal file
139
templates/about.html
Normal file
|
@ -0,0 +1,139 @@
|
|||
{{ define "title"}}
|
||||
About
|
||||
{{ end }}
|
||||
|
||||
{{ define "top_css"}}
|
||||
{{ end }}
|
||||
|
||||
{{ define "username"}}
|
||||
{{ .username }}
|
||||
{{ end }}
|
||||
|
||||
{{ define "page_title"}}
|
||||
About
|
||||
{{ end }}
|
||||
|
||||
{{ define "page_content"}}
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<!-- <h5 class="mt-4 mb-2">Global Settings</h5> -->
|
||||
<div class="row">
|
||||
<!-- left column -->
|
||||
<div class="col-md-6">
|
||||
<div class="card card-success">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">About Wireguard-UI</h3>
|
||||
</div>
|
||||
<!-- /.card-header -->
|
||||
<div class="card-body">
|
||||
<div class="form-group">
|
||||
<label for="version" class="control-label">Current version</label>
|
||||
<input type="text" class="form-control" id="version" value="{{ .appVersion }}" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="currentReleaseDate" class="control-label">Current version release date</label>
|
||||
<input type="text" class="form-control" id="currentReleaseDate" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="latestRelease" class="control-label">Latest release</label>
|
||||
<input type="text" class="form-control" id="latestRelease" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="latestReleaseDate" class="control-label">Latest release date</label>
|
||||
<input type="text" class="form-control" id="latestReleaseDate" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="author" class="control-label">Author</label>
|
||||
<div id="author">
|
||||
<a id="authorLink">
|
||||
<img id="authorImage"
|
||||
style="width: 50px; height: 50px; border-radius: 50%; border: 1px solid #000;">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="contributors" class="control-label">Contributors</label>
|
||||
<div id="contributors"></div>
|
||||
</div>
|
||||
<strong>Copyright ©
|
||||
<script>document.write(new Date().getFullYear())</script>
|
||||
<a href="https://github.com/ngoduykhanh/wireguard-ui">Wireguard UI</a>.
|
||||
</strong> All rights reserved.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ define "bottom_js"}}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
method: 'GET',
|
||||
url: 'https://api.github.com/repos/ngoduykhanh/wireguard-ui/releases/tags/' + $("#version").val(),
|
||||
dataType: 'json',
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
$("#currentReleaseDate").attr("value", data.published_at.split("T")[0]);
|
||||
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
$("#currentReleaseDate").attr("value", "Could not find this version on GitHub.com");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
method: 'GET',
|
||||
url: 'https://api.github.com/repos/ngoduykhanh/wireguard-ui/releases/latest',
|
||||
dataType: 'json',
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
$("#latestRelease").attr("value", data.tag_name);
|
||||
$("#latestReleaseDate").attr("value", data.published_at.split("T")[0]);
|
||||
$("#author").attr("value", data.author.login);
|
||||
$("#authorImage").attr("src", data.author.avatar_url);
|
||||
$("#authorImage").after("<b> " + data.author.login + "</b>");
|
||||
$("#authorLink").attr("href", data.author.html_url);
|
||||
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
$("#latestRelease").attr("value", "Could not connect to GitHub.com");
|
||||
$("#latestReleaseDate").attr("value", "Could not connect to GitHub.com");
|
||||
$("#author").attr("value", "Could not connect to GitHub.com");
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
cache: false,
|
||||
method: 'GET',
|
||||
url: 'https://api.github.com/repos/ngoduykhanh/wireguard-ui/contributors',
|
||||
dataType: 'json',
|
||||
contentType: "application/json",
|
||||
success: function (data) {
|
||||
data.forEach(contributor => $("#contributors").append("<a href=\"" + contributor.html_url + "\" title=\"" + contributor.login + "\">" +
|
||||
"<img src=\"" + contributor.avatar_url + "\" style=\"width: 50px; height: 50px; border-radius: 50%; border: 1px solid #000; margin: 5px;\"/></a>"));
|
||||
},
|
||||
error: function (jqXHR, exception) {
|
||||
$("#contributors").html("<p>Could not connect to GitHub.com</p>");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ajaxStop(function () {
|
||||
if (Date.parse($("#currentReleaseDate").val()) < Date.parse($("#latestReleaseDate").val())) {
|
||||
$("#currentReleaseDate").after("<p style=\"color:red\">Current version is out of date</p>")
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
{{ end }}
|
|
@ -141,6 +141,15 @@
|
|||
</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-header">ABOUT</li>
|
||||
<li class="nav-item">
|
||||
<a href="{{.basePath}}/about" class="nav-link {{if eq .baseData.Active "about" }}active{{end}}">
|
||||
<i class="nav-icon fas fa-solid fa-id-card"></i>
|
||||
<p>
|
||||
About
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<!-- /.sidebar-menu -->
|
||||
|
@ -281,7 +290,7 @@
|
|||
<!-- /.content -->
|
||||
</div>
|
||||
<!-- /.content-wrapper -->
|
||||
|
||||
<!--
|
||||
<footer class="main-footer">
|
||||
<div class="float-right d-none d-sm-block">
|
||||
<b>Version</b> {{ .appVersion }}
|
||||
|
@ -289,7 +298,7 @@
|
|||
<strong>Copyright © <script>document.write(new Date().getFullYear())</script> <a href="https://github.com/ngoduykhanh/wireguard-ui">Wireguard UI</a>.</strong> All rights
|
||||
reserved.
|
||||
</footer>
|
||||
|
||||
-->
|
||||
<!-- Control Sidebar -->
|
||||
<aside class="control-sidebar control-sidebar-dark">
|
||||
<!-- Control sidebar content goes here -->
|
||||
|
|
Loading…
Add table
Reference in a new issue