diff --git a/templates/cp.html b/templates/cp.html
new file mode 100644
index 0000000..cfdc0c8
--- /dev/null
+++ b/templates/cp.html
@@ -0,0 +1,24 @@
+{{ define "title" }}Control Panel{{ end }} {{ define "header" }}⚙️ Control
+Panel{{ end }} {{ define "content" }}
+
+
+ {{ if .Message }}
+
Info: {{ .Message }} {{ end }}
+
+
+
+
+ Action |
+ Description |
+
+
+
+
+ Clear Daily Stats |
+ Clear Daily Stats cache |
+
+
+
+
+
+{{ end }} {{ template "layout" . }}
diff --git a/web/controlPanelHandler.go b/web/controlPanelHandler.go
new file mode 100644
index 0000000..ef4d9f6
--- /dev/null
+++ b/web/controlPanelHandler.go
@@ -0,0 +1,39 @@
+package web
+
+import (
+ "net/http"
+ "pool-stats/database"
+)
+
+type ControlPanelPageData struct {
+ PageDataBase
+
+ Message string
+}
+
+func (ws *WebServer) ControlPanelHandler(w http.ResponseWriter, r *http.Request) {
+ username := ws.getUser(r)
+ if username == "" {
+ http.Error(w, "Unauthorized", http.StatusUnauthorized)
+ return
+ }
+
+ data := ControlPanelPageData{}
+
+ action := r.URL.Query().Get("action")
+ if action != "" {
+ data.Message = ws.executeAction(action)
+ }
+
+ ws.renderTemplate(w, r, "templates/cp.html", &data)
+}
+
+func (ws *WebServer) executeAction(action string) string {
+ switch action {
+ case "ClearDailyStats":
+ database.ClearDailyStats(ws.db)
+ return "Daily stats cleared successfully"
+ default:
+ return "Unknown action"
+ }
+}
diff --git a/web/server.go b/web/server.go
index 3c785de..507799f 100644
--- a/web/server.go
+++ b/web/server.go
@@ -44,6 +44,7 @@ func NewWebServer(db *clover.DB, port int, adminPassword string) *WebServer {
func (ws *WebServer) Start() error {
http.HandleFunc("/", ws.IndexHandler)
+ http.HandleFunc("/cp", ws.ControlPanelHandler)
http.HandleFunc("/login", ws.LoginHandler)
http.HandleFunc("/logout", ws.LogoutHandler)
http.HandleFunc("/shares", ws.SharesHandler)