Skip to content

Commit 700a8f5

Browse files
committed
Refine Web Server and Database status display in dashboard UI
1 parent 0a92bed commit 700a8f5

2 files changed

Lines changed: 42 additions & 18 deletions

File tree

‎internal/gui/dashboard/index.html‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,22 @@ <h2>Environment Diagnostics</h2>
315315
if (data.project) {
316316
document.getElementById('current-project-name').innerText = data.project.name || 'Local Project';
317317
document.getElementById('current-php').innerText = 'PHP ' + (data.project.php || '8.3');
318-
document.getElementById('current-web').innerText = data.project.web_url || 'Stopped';
319-
document.getElementById('current-db').innerText = data.project.db_url || 'Stopped';
318+
319+
const webElem = document.getElementById('current-web');
320+
if (data.project.web_url) {
321+
webElem.innerHTML = `<a href="${data.project.web_url}" target="_blank" style="color:var(--primary);text-decoration:underline;">${data.project.web_url}</a>`;
322+
} else {
323+
webElem.innerHTML = '<span style="color:var(--text-muted);">Stopped</span>';
324+
}
325+
326+
const dbElem = document.getElementById('current-db');
327+
if (data.project.db_url) {
328+
dbElem.innerHTML = `<span style="color:var(--success);">${data.project.db_url}</span>`;
329+
} else if (!data.project.db_configured) {
330+
dbElem.innerHTML = '<span style="color:var(--text-muted);font-size:0.8rem;">Not configured</span>';
331+
} else {
332+
dbElem.innerHTML = '<span style="color:var(--text-muted);">Stopped</span>';
333+
}
320334

321335
const isRunning = data.project.running;
322336
const statusPill = document.getElementById('current-project-status');

‎internal/gui/server.go‎

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"path/filepath"
1111
"strings"
1212

13+
"github.com/Vikrez22/phpvm/internal/ini"
1314
"github.com/Vikrez22/phpvm/internal/manifest"
1415
"github.com/Vikrez22/phpvm/internal/paths"
1516
"github.com/Vikrez22/phpvm/internal/resolver"
@@ -77,21 +78,23 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
7778
}
7879

7980
ps, _ := state.Load(m.ProjectRoot)
80-
running := false
8181
webURL := ""
8282
dbURL := ""
83+
dbConfigured := m.Database != nil && m.Database.Engine != "" && m.Database.Engine != "none"
8384

8485
if ps != nil {
85-
for name, pid := range ps.RunningPIDs {
86-
if supervisor.IsProcessRunning(pid) {
87-
running = true
88-
port := ps.AllocatedPorts[name]
89-
if name == "web" && port > 0 {
90-
webURL = fmt.Sprintf("http://127.0.0.1:%d", port)
91-
}
92-
if name == "mysql" && port > 0 {
93-
dbURL = fmt.Sprintf("mysql://127.0.0.1:%d", port)
94-
}
86+
rt, _ := resolver.ResolveFromManifest(m)
87+
sup := supervisor.New(m, rt, ps)
88+
sup.CleanupStalePIDs()
89+
90+
if pid := ps.RunningPIDs["web"]; pid != 0 && supervisor.IsProcessRunning(pid) {
91+
if port := ps.AllocatedPorts["web"]; port > 0 {
92+
webURL = fmt.Sprintf("http://127.0.0.1:%d", port)
93+
}
94+
}
95+
if pid := ps.RunningPIDs["mysql"]; pid != 0 && supervisor.IsProcessRunning(pid) {
96+
if port := ps.AllocatedPorts["mysql"]; port > 0 {
97+
dbURL = fmt.Sprintf("mysql://127.0.0.1:%d", port)
9598
}
9699
}
97100
}
@@ -104,11 +107,12 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
104107
json.NewEncoder(w).Encode(map[string]interface{}{
105108
"manifest_found": true,
106109
"project": map[string]interface{}{
107-
"name": name,
108-
"php": m.Runtime.PHP,
109-
"web_url": webURL,
110-
"db_url": dbURL,
111-
"running": running,
110+
"name": name,
111+
"php": m.Runtime.PHP,
112+
"web_url": webURL,
113+
"db_url": dbURL,
114+
"db_configured": dbConfigured,
115+
"running": webURL != "" || dbURL != "",
112116
},
113117
})
114118
}
@@ -168,6 +172,12 @@ func handleUp(w http.ResponseWriter, r *http.Request) {
168172
json.NewEncoder(w).Encode(map[string]interface{}{"success": false, "error": err.Error()})
169173
return
170174
}
175+
iniPath, err := ini.Generate(m.ProjectRoot, m, rt)
176+
if err != nil {
177+
json.NewEncoder(w).Encode(map[string]interface{}{"success": false, "error": err.Error()})
178+
return
179+
}
180+
rt.PHPIniPath = iniPath
171181
ps, _ := state.Load(m.ProjectRoot)
172182
sup := supervisor.New(m, rt, ps)
173183
statuses, err := sup.Up(true, true)

0 commit comments

Comments
 (0)