Compare commits
2 Commits
20912ba17c
...
v0.0.20
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e188813adf | ||
![]() |
e1ba6e49a8 |
5
dist/supervisorTemplate.json
vendored
5
dist/supervisorTemplate.json
vendored
@@ -3,8 +3,9 @@
|
|||||||
"name":"Database DBM",
|
"name":"Database DBM",
|
||||||
"executePath":"dist/test-windows-amd64.exe",
|
"executePath":"dist/test-windows-amd64.exe",
|
||||||
"workingDirectory":".",
|
"workingDirectory":".",
|
||||||
"startDelay":2,
|
"startDelay":1000,
|
||||||
"priority":0
|
"priority":0,
|
||||||
|
"arguments":["-sleep 5"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
BIN
dist/test-windows-amd64.exe
vendored
Normal file
BIN
dist/test-windows-amd64.exe
vendored
Normal file
Binary file not shown.
@@ -2,8 +2,8 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"processSupervisor/models"
|
"processSupervisor/models"
|
||||||
@@ -15,8 +15,6 @@ type MainPage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewMainPage(templates *embed.FS) (*MainPage, error) {
|
func NewMainPage(templates *embed.FS) (*MainPage, error) {
|
||||||
fmt.Println(10)
|
|
||||||
fmt.Println(os.Getwd())
|
|
||||||
var supervisor models.Supervisor
|
var supervisor models.Supervisor
|
||||||
if _, err := os.Stat("cfg/"); err != nil {
|
if _, err := os.Stat("cfg/"); err != nil {
|
||||||
s, err := models.ReadTemplate("dist/supervisorTemplate.json")
|
s, err := models.ReadTemplate("dist/supervisorTemplate.json")
|
||||||
@@ -25,7 +23,6 @@ func NewMainPage(templates *embed.FS) (*MainPage, error) {
|
|||||||
}
|
}
|
||||||
supervisor = s
|
supervisor = s
|
||||||
}
|
}
|
||||||
fmt.Println(11)
|
|
||||||
|
|
||||||
if err := supervisor.StartProcesses(); err != nil {
|
if err := supervisor.StartProcesses(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -43,5 +40,61 @@ func (m *MainPage) UpdateMainPage(w http.ResponseWriter, r *http.Request) {
|
|||||||
"templates/index.html",
|
"templates/index.html",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
tmpl.Execute(w, nil)
|
|
||||||
|
// tmpl := template.Must(
|
||||||
|
// template.New("index.html").ParseFiles(
|
||||||
|
// "templates/index.html",
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
tmpl.Execute(w, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MainPage) StartProcess(w http.ResponseWriter, r *http.Request) {
|
||||||
|
name := r.PostFormValue("name")
|
||||||
|
|
||||||
|
// This is where you trigger the .Start method
|
||||||
|
err := m.Supervisor.StartProcessByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to start process", err)
|
||||||
|
|
||||||
|
//http.Error(w, "Failed to start process", http.StatusInternalServerError)
|
||||||
|
//return
|
||||||
|
}
|
||||||
|
m.UpdateMainPage(w, r)
|
||||||
|
//w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MainPage) StopProcess(w http.ResponseWriter, r *http.Request) {
|
||||||
|
name := r.PostFormValue("name")
|
||||||
|
|
||||||
|
err := m.Supervisor.StopProcessByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to stop process", err)
|
||||||
|
//http.Error(w, "Failed to stop process", http.StatusInternalServerError)
|
||||||
|
//return
|
||||||
|
}
|
||||||
|
m.UpdateMainPage(w, r)
|
||||||
|
//w.WriteHeader(http.StatusOK)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MainPage) RestartProcess(w http.ResponseWriter, r *http.Request) {
|
||||||
|
name := r.PostFormValue("name")
|
||||||
|
|
||||||
|
err := m.Supervisor.StopProcessByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to start process", err)
|
||||||
|
|
||||||
|
//http.Error(w, "Failed to start process", http.StatusInternalServerError)
|
||||||
|
//return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = m.Supervisor.StartProcessByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Failed to stop process", err)
|
||||||
|
|
||||||
|
// http.Error(w, "Failed to stop process", http.StatusInternalServerError)
|
||||||
|
// return
|
||||||
|
}
|
||||||
|
m.UpdateMainPage(w, r)
|
||||||
|
//w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
15
main.go
15
main.go
@@ -4,6 +4,7 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"processSupervisor/handlers"
|
"processSupervisor/handlers"
|
||||||
@@ -23,15 +24,23 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mianPage, err := handlers.NewMainPage(&templatesFS)
|
mainPage, err := handlers.NewMainPage(&templatesFS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticFS))))
|
staticSub, err := fs.Sub(staticFS, "static")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
|
||||||
|
|
||||||
http.HandleFunc("/taskmanager/htop", htop.UpdateHTop)
|
http.HandleFunc("/taskmanager/htop", htop.UpdateHTop)
|
||||||
http.HandleFunc("/", mianPage.UpdateMainPage)
|
http.HandleFunc("/", mainPage.UpdateMainPage)
|
||||||
|
http.HandleFunc("/start-process", mainPage.StartProcess)
|
||||||
|
http.HandleFunc("/stop-process", mainPage.StopProcess)
|
||||||
|
http.HandleFunc("/restart-process", mainPage.RestartProcess)
|
||||||
http.HandleFunc("/taskmanager/kill", handlers.KillHandler)
|
http.HandleFunc("/taskmanager/kill", handlers.KillHandler)
|
||||||
http.HandleFunc("/taskmanager/usage", handlers.UsageHandler)
|
http.HandleFunc("/taskmanager/usage", handlers.UsageHandler)
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,16 +11,6 @@ type Supervisor struct {
|
|||||||
Processes []*SupervisorProcess `json:"processes"`
|
Processes []*SupervisorProcess `json:"processes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SupervisorProcess struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
ExecutePath string `json:"executePath"`
|
|
||||||
WorkingDirectory string `json:"workingDirectory,omitempty"`
|
|
||||||
StartDelay int `json:"startDelay,omitempty"`
|
|
||||||
Priority int `json:"priority,omitempty"`
|
|
||||||
Arguments []string `json:"arguments,omitempty"`
|
|
||||||
process *exec.Cmd `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func ReadTemplate(path string) (supervisor Supervisor, err error) {
|
func ReadTemplate(path string) (supervisor Supervisor, err error) {
|
||||||
content, err := os.ReadFile(path)
|
content, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -38,20 +27,33 @@ func (s *Supervisor) StartProcesses() error {
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, p := range s.Processes {
|
for _, p := range s.Processes {
|
||||||
go func() {
|
p.Start()
|
||||||
p.process = exec.Command(p.ExecutePath, p.Arguments...)
|
|
||||||
//cmd.Env = append(cmd.Env, "MY_VAR=some_value")
|
|
||||||
p.process.Dir = p.WorkingDirectory
|
|
||||||
|
|
||||||
output, err := p.process.Output()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Error:", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Output:", string(output))
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
fmt.Println(3)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Supervisor) GetProcesses() (processes []SupervisorProcess) {
|
||||||
|
for _, p := range s.Processes {
|
||||||
|
processes = append(processes, *p)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Supervisor) StartProcessByName(name string) error {
|
||||||
|
for _, p := range s.Processes {
|
||||||
|
if p.Name == name {
|
||||||
|
return p.Start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("process %s not found", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Supervisor) StopProcessByName(name string) error {
|
||||||
|
for _, p := range s.Processes {
|
||||||
|
if p.Name == name {
|
||||||
|
return p.Stop()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("process %s not found", name)
|
||||||
|
}
|
||||||
|
92
models/supervisorProcess.go
Normal file
92
models/supervisorProcess.go
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SupervisorProcess struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
ExecutePath string `json:"executePath"`
|
||||||
|
WorkingDirectory string `json:"workingDirectory,omitempty"`
|
||||||
|
StartDelay int `json:"startDelay,omitempty"`
|
||||||
|
Priority int `json:"priority,omitempty"`
|
||||||
|
Arguments []string `json:"arguments,omitempty"`
|
||||||
|
process *exec.Cmd `json:"-"`
|
||||||
|
cancel *context.CancelFunc `json:"-"`
|
||||||
|
Running bool `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *SupervisorProcess) Start() error {
|
||||||
|
if p.process != nil && p.process.Process != nil {
|
||||||
|
return fmt.Errorf("process %s already running", p.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
p.cancel = &cancel
|
||||||
|
|
||||||
|
var args []string
|
||||||
|
for _, arg := range p.Arguments {
|
||||||
|
fields := strings.Fields(arg)
|
||||||
|
args = append(args, fields...)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.CommandContext(ctx, p.ExecutePath, args...)
|
||||||
|
cmd.Dir = p.WorkingDirectory
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
|
p.process = cmd
|
||||||
|
|
||||||
|
time.Sleep(time.Duration(p.StartDelay) * time.Millisecond)
|
||||||
|
|
||||||
|
if err := cmd.Start(); err != nil {
|
||||||
|
return fmt.Errorf("failed to start process %s: %w", p.Name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
p.Running = false
|
||||||
|
}()
|
||||||
|
|
||||||
|
p.Running = true
|
||||||
|
err := cmd.Wait()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Process %s exited with error: %v\n", p.Name, err)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Process %s exited successfully\n", p.Name)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *SupervisorProcess) Stop() error {
|
||||||
|
defer func() {
|
||||||
|
p.Running = false
|
||||||
|
}()
|
||||||
|
|
||||||
|
if p.process == nil || p.process.Process == nil {
|
||||||
|
return fmt.Errorf("process %s is not running", p.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel the context
|
||||||
|
if p.cancel != nil {
|
||||||
|
(*p.cancel)()
|
||||||
|
}
|
||||||
|
|
||||||
|
err := p.process.Process.Kill()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to kill process %s: %w", p.Name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.process = nil
|
||||||
|
p.cancel = nil
|
||||||
|
|
||||||
|
fmt.Printf("Process %s stopped.\n", p.Name)
|
||||||
|
return nil
|
||||||
|
}
|
@@ -4,30 +4,13 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Process Dashboard</title>
|
<title>Process Dashboard</title>
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.5"></script>
|
<script src="https://unpkg.com/htmx.org@1.9.5"></script>
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
font-family: sans-serif;
|
|
||||||
margin: 2rem;
|
|
||||||
}
|
|
||||||
.top-link {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
ul#process-list {
|
|
||||||
list-style: none;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
ul#process-list li {
|
|
||||||
background: #f4f4f4;
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
padding: 0.75rem;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Placeholder List for Future Processes -->
|
||||||
|
<ul id="process-list">
|
||||||
<div class="top-link-container">
|
<div class="top-link-container">
|
||||||
<a href="/taskmanager/htop" class="top-link" target="_blank" rel="noopener noreferrer">
|
<a href="/taskmanager/htop" class="top-link" target="_blank" rel="noopener noreferrer">
|
||||||
📈 Task Manager
|
📈 Task Manager
|
||||||
@@ -35,28 +18,160 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<h2>Future Processes</h2>
|
<h2>Processes</h2>
|
||||||
|
{{ range .Supervisor.GetProcesses }}
|
||||||
|
<li>
|
||||||
|
<span class="process-name">📦
|
||||||
|
{{ if .Running }}
|
||||||
|
🟢 {{ .Name }}
|
||||||
|
{{ else }}
|
||||||
|
🔴 {{ .Name }}
|
||||||
|
{{ end }}
|
||||||
|
</span>
|
||||||
|
|
||||||
<!-- Placeholder List for Future Processes -->
|
<div class="dropdown">
|
||||||
<ul id="process-list">
|
<button class="dot-button">⋮</button>
|
||||||
<li>📌 Process A (placeholder)</li>
|
<div class="dropdown-content">
|
||||||
<li>📌 Process B (placeholder)</li>
|
|
||||||
<li>📌 Process C (placeholder)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<!-- Example Button for Future HTMX Action -->
|
|
||||||
<button
|
<button
|
||||||
hx-get="/get-latest-processes"
|
hx-post="/start-process"
|
||||||
|
hx-vals='{"name": "{{ .Name }}"}'
|
||||||
|
hx-trigger="click"
|
||||||
hx-target="#process-list"
|
hx-target="#process-list"
|
||||||
hx-swap="innerHTML">
|
hx-swap="innerHTML">
|
||||||
🔄 Load Latest Processes
|
▶️ Start
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
hx-post="/stop-process"
|
||||||
|
hx-vals='{"name": "{{ .Name }}"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#process-list"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
⏹️ Stop
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
hx-post="/restart-process"
|
||||||
|
hx-vals='{"name": "{{ .Name }}"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#process-list"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
🔁 Restart
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
<style>
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: "Segoe UI", Roboto, sans-serif;
|
||||||
|
margin: 2rem;
|
||||||
|
background-color: #f7f9fb;
|
||||||
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
.top-link-container {
|
.top-link-container {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-link {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #4a90e2;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
text-align: center;
|
||||||
|
color: #444;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul#process-list {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul#process-list li {
|
||||||
|
background: #fff;
|
||||||
|
margin: 0.75rem 0;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
transition: box-shadow 0.25s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul#process-list li:hover {
|
||||||
|
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.process-name {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-button {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #777;
|
||||||
|
padding: 0 4px;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-button:hover {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-content {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 1.8rem;
|
||||||
|
background-color: #fff;
|
||||||
|
min-width: 130px;
|
||||||
|
box-shadow: 0 6px 12px rgba(0,0,0,0.1);
|
||||||
|
border-radius: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown:hover .dropdown-content {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-content button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 12px;
|
||||||
|
text-align: left;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: #333;
|
||||||
|
transition: background 0.2s, color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-content button:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #000;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</html>
|
</html>
|
||||||
|
156
templates/processes.html
Normal file
156
templates/processes.html
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
<ul id="process-list">
|
||||||
|
{{ range .Supervisor.GetProcesses }}
|
||||||
|
<li>
|
||||||
|
<span class="process-name">📦
|
||||||
|
{{ if .Running }}
|
||||||
|
🟢 {{ .Name }}
|
||||||
|
{{ else }}
|
||||||
|
🔴 {{ .Name }}
|
||||||
|
{{ end }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="dot-button">⋮</button>
|
||||||
|
<div class="dropdown-content">
|
||||||
|
<button
|
||||||
|
hx-post="/start-process"
|
||||||
|
hx-vals='{"name": "{{ .Name }}"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#process-list"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
▶️ Start
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
hx-post="/stop-process"
|
||||||
|
hx-vals='{"name": "{{ .Name }}"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#process-list"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
⏹️ Stop
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
hx-post="/restart-process"
|
||||||
|
hx-vals='{"name": "{{ .Name }}"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#process-list"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
🔁 Restart
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: "Segoe UI", Roboto, sans-serif;
|
||||||
|
margin: 2rem;
|
||||||
|
background-color: #f7f9fb;
|
||||||
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-link-container {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-link {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #4a90e2;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
text-align: center;
|
||||||
|
color: #444;
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul#process-list {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul#process-list li {
|
||||||
|
background: #fff;
|
||||||
|
margin: 0.75rem 0;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
transition: box-shadow 0.25s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul#process-list li:hover {
|
||||||
|
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.process-name {
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 1rem;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-button {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
color: #777;
|
||||||
|
padding: 0 4px;
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-button:hover {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-content {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 1.8rem;
|
||||||
|
background-color: #fff;
|
||||||
|
min-width: 130px;
|
||||||
|
box-shadow: 0 6px 12px rgba(0,0,0,0.1);
|
||||||
|
border-radius: 6px;
|
||||||
|
overflow: hidden;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown:hover .dropdown-content {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-content button {
|
||||||
|
width: 100%;
|
||||||
|
padding: 10px 12px;
|
||||||
|
text-align: left;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: #333;
|
||||||
|
transition: background 0.2s, color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-content button:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</html>
|
Reference in New Issue
Block a user