Compare commits
1 Commits
eb4fae52ab
...
v0.0.21
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9f262c4a55 |
@@ -89,8 +89,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Zip artifact
|
- name: Zip artifact
|
||||||
run: |
|
run: |
|
||||||
cd bin
|
zip bin/${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.zip bin/${{ env.APP_NAME }}-*
|
||||||
zip "${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.zip" "${{ env.APP_NAME }}-"* -x "*.zip"
|
|
||||||
|
|
||||||
- name: Upload zipped artifact
|
- name: Upload zipped artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
|
9
dist/supervisorTemplate.json
vendored
9
dist/supervisorTemplate.json
vendored
@@ -1,11 +1,20 @@
|
|||||||
{
|
{
|
||||||
"processes":[{
|
"processes":[{
|
||||||
"name":"Database DBM",
|
"name":"Database DBM",
|
||||||
|
"description":"data description",
|
||||||
"executePath":"dist/test-windows-amd64.exe",
|
"executePath":"dist/test-windows-amd64.exe",
|
||||||
"workingDirectory":".",
|
"workingDirectory":".",
|
||||||
"startDelay":1000,
|
"startDelay":1000,
|
||||||
"priority":0,
|
"priority":0,
|
||||||
"arguments":["-sleep 5"]
|
"arguments":["-sleep 5"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"Pau",
|
||||||
|
"description":"my lovely wife",
|
||||||
|
"executePath":"explorer.exe",
|
||||||
|
"workingDirectory":".",
|
||||||
|
"startDelay":1000,
|
||||||
|
"priority":2
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@@ -1,100 +0,0 @@
|
|||||||
package handlers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"embed"
|
|
||||||
"html/template"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"processSupervisor/models"
|
|
||||||
)
|
|
||||||
|
|
||||||
type MainPage struct {
|
|
||||||
templates *embed.FS
|
|
||||||
Supervisor *models.Supervisor
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMainPage(templates *embed.FS) (*MainPage, error) {
|
|
||||||
var supervisor models.Supervisor
|
|
||||||
if _, err := os.Stat("cfg/"); err != nil {
|
|
||||||
s, err := models.ReadTemplate("dist/supervisorTemplate.json")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
supervisor = s
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := supervisor.StartProcesses(); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return &MainPage{
|
|
||||||
templates: templates,
|
|
||||||
Supervisor: &supervisor,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *MainPage) UpdateMainPage(w http.ResponseWriter, r *http.Request) {
|
|
||||||
tmpl := template.Must(
|
|
||||||
template.New("index.html").ParseFS(
|
|
||||||
m.templates,
|
|
||||||
"templates/index.html",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
// 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)
|
|
||||||
}
|
|
@@ -1,26 +1,26 @@
|
|||||||
package handlers
|
package htop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"processSupervisor/models"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed templates
|
||||||
|
var templatesFS embed.FS
|
||||||
|
|
||||||
type HTopHandler struct {
|
type HTopHandler struct {
|
||||||
Table *models.HtopTable
|
Table *HtopTable
|
||||||
templates *embed.FS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHTopHandler(templates *embed.FS) (*HTopHandler, error) {
|
func NewHTopHandler() (*HTopHandler, error) {
|
||||||
table, err := models.NewTable()
|
table, err := NewTable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &HTopHandler{
|
return &HTopHandler{
|
||||||
Table: table,
|
Table: table,
|
||||||
templates: templates,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,8 +42,8 @@ func (h *HTopHandler) UpdateHTop(w http.ResponseWriter, r *http.Request) {
|
|||||||
if r.Header.Get("HX-Request") == "true" {
|
if r.Header.Get("HX-Request") == "true" {
|
||||||
tmpl := template.Must(
|
tmpl := template.Must(
|
||||||
template.New("table.html").Funcs(funcMap).ParseFS(
|
template.New("table.html").Funcs(funcMap).ParseFS(
|
||||||
h.templates,
|
templatesFS,
|
||||||
"templates/htop/table.html",
|
"templates/table.html",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
tmpl.Execute(w, h.Table)
|
tmpl.Execute(w, h.Table)
|
||||||
@@ -52,9 +52,9 @@ func (h *HTopHandler) UpdateHTop(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
tmpl := template.Must(
|
tmpl := template.Must(
|
||||||
template.New("htop.html").Funcs(funcMap).ParseFS(
|
template.New("htop.html").Funcs(funcMap).ParseFS(
|
||||||
h.templates,
|
templatesFS,
|
||||||
"templates/htop/htop.html",
|
"templates/htop.html",
|
||||||
"templates/htop/table.html",
|
"templates/table.html",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
tmpl.Execute(w, h.Table)
|
tmpl.Execute(w, h.Table)
|
||||||
@@ -90,7 +90,7 @@ func toFloat64(v any) float64 {
|
|||||||
|
|
||||||
// GET /taskmanager/usage
|
// GET /taskmanager/usage
|
||||||
func UsageHandler(w http.ResponseWriter, r *http.Request) {
|
func UsageHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
cpu, mem, err := models.GetSystemUsage()
|
cpu, mem, err := GetSystemUsage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "Failed to get usage", 500)
|
http.Error(w, "Failed to get usage", 500)
|
||||||
return
|
return
|
@@ -1,8 +1,9 @@
|
|||||||
package models
|
package htop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"processSupervisor/htop/models"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -11,13 +12,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type HtopTable struct {
|
type HtopTable struct {
|
||||||
Processes []Process
|
Processes []models.Process
|
||||||
CurrentSort string
|
CurrentSort string
|
||||||
CurrentOrder string
|
CurrentOrder string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTable() (*HtopTable, error) {
|
func NewTable() (*HtopTable, error) {
|
||||||
processes, err := GetProcesses()
|
processes, err := models.GetProcesses()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &HtopTable{}, err
|
return &HtopTable{}, err
|
||||||
}
|
}
|
||||||
@@ -28,7 +29,7 @@ func NewTable() (*HtopTable, error) {
|
|||||||
|
|
||||||
func (t *HtopTable) UpdateTable() error {
|
func (t *HtopTable) UpdateTable() error {
|
||||||
var err error
|
var err error
|
||||||
t.Processes, err = GetProcesses()
|
t.Processes, err = models.GetProcesses()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
@@ -1,10 +1,10 @@
|
|||||||
package handlers
|
package htop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"processSupervisor/models"
|
"processSupervisor/htop/models"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,6 +35,6 @@ func KillHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl := template.Must(template.ParseFiles("templates/htop/table.html"))
|
tmpl := template.Must(template.ParseFiles("templates/table.html"))
|
||||||
tmpl.Execute(w, processes)
|
tmpl.Execute(w, processes)
|
||||||
}
|
}
|
@@ -63,7 +63,7 @@
|
|||||||
hx-get="/taskmanager/kill?pid={{.PID}}"
|
hx-get="/taskmanager/kill?pid={{.PID}}"
|
||||||
hx-target="#process-table"
|
hx-target="#process-table"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-confirm="Are you sure you want to kill this process?">
|
hx-confirm="Are you sure you want to kill {{.Cmd}} process?">
|
||||||
Kill
|
Kill
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
26
main.go
26
main.go
@@ -7,24 +7,23 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"processSupervisor/handlers"
|
"processSupervisor/htop"
|
||||||
|
"processSupervisor/mainPage"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed templates/*.html templates/*/*.html
|
|
||||||
var templatesFS embed.FS
|
|
||||||
|
|
||||||
//go:embed static
|
//go:embed static
|
||||||
var staticFS embed.FS
|
var staticFS embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
port := flag.Uint("port", 9400, "listening port")
|
port := flag.Uint("port", 9400, "listening port")
|
||||||
htop, err := handlers.NewHTopHandler(&templatesFS)
|
cfgDir := flag.String("cfg", "./dist", "configuration directory")
|
||||||
|
htopHandler, err := htop.NewHTopHandler()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mainPage, err := handlers.NewMainPage(&templatesFS)
|
mP, err := mainPage.NewMainPage(*cfgDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -36,13 +35,14 @@ func main() {
|
|||||||
|
|
||||||
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
|
||||||
|
|
||||||
http.HandleFunc("/taskmanager/htop", htop.UpdateHTop)
|
http.HandleFunc("/taskmanager/htop", htopHandler.UpdateHTop)
|
||||||
http.HandleFunc("/", mainPage.UpdateMainPage)
|
http.HandleFunc("/", mP.LoadMainPage)
|
||||||
http.HandleFunc("/start-process", mainPage.StartProcess)
|
http.HandleFunc("/start-process", mP.StartProcess)
|
||||||
http.HandleFunc("/stop-process", mainPage.StopProcess)
|
http.HandleFunc("/stop-process", mP.StopProcess)
|
||||||
http.HandleFunc("/restart-process", mainPage.RestartProcess)
|
http.HandleFunc("/restart-process", mP.RestartProcess)
|
||||||
http.HandleFunc("/taskmanager/kill", handlers.KillHandler)
|
http.HandleFunc("/processes", mP.UpdateMainPage)
|
||||||
http.HandleFunc("/taskmanager/usage", handlers.UsageHandler)
|
http.HandleFunc("/taskmanager/kill", htop.KillHandler)
|
||||||
|
http.HandleFunc("/taskmanager/usage", htop.UsageHandler)
|
||||||
|
|
||||||
log.Printf("Listening on http://localhost:%d\n", *port)
|
log.Printf("Listening on http://localhost:%d\n", *port)
|
||||||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
|
||||||
|
96
mainPage/mainPage.go
Normal file
96
mainPage/mainPage.go
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
package mainPage
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
"html/template"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"processSupervisor/supervisor"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed templates
|
||||||
|
var templatesFS embed.FS
|
||||||
|
|
||||||
|
type MainPage struct {
|
||||||
|
Supervisor *supervisor.Supervisor
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMainPage(cfgDir string) (*MainPage, error) {
|
||||||
|
var sv supervisor.Supervisor
|
||||||
|
file := filepath.Join(cfgDir, "supervisorTemplate.json")
|
||||||
|
if _, err := os.Stat(file); err == nil {
|
||||||
|
sv, err = supervisor.ReadTemplate(file)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := sv.StartProcesses(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
m := MainPage{
|
||||||
|
Supervisor: &sv,
|
||||||
|
}
|
||||||
|
|
||||||
|
return &m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MainPage) LoadMainPage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tmpl := template.Must(
|
||||||
|
template.New("index.html").ParseFS(
|
||||||
|
templatesFS,
|
||||||
|
"templates/index.html",
|
||||||
|
"templates/processes.html",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
tmpl.Execute(w, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MainPage) UpdateMainPage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tmpl := template.Must(
|
||||||
|
template.New("processes.html").ParseFS(
|
||||||
|
templatesFS,
|
||||||
|
"templates/processes.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)
|
||||||
|
}
|
||||||
|
m.UpdateMainPage(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
m.UpdateMainPage(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *MainPage) RestartProcess(w http.ResponseWriter, r *http.Request) {
|
||||||
|
name := r.PostFormValue("name")
|
||||||
|
|
||||||
|
err := m.Supervisor.StopProcessByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
err = m.Supervisor.StartProcessByName(name)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
m.UpdateMainPage(w, r)
|
||||||
|
}
|
56
mainPage/templates/index.html
Normal file
56
mainPage/templates/index.html
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Process Dashboard</title>
|
||||||
|
<script src="https://unpkg.com/htmx.org@1.9.5"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<ul id="process-page">
|
||||||
|
<div class="top-link-container">
|
||||||
|
<a href="/taskmanager/htop" class="top-link" target="_blank" rel="noopener noreferrer">
|
||||||
|
📈 Task Manager
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<h2>Processes</h2>
|
||||||
|
<ul id="process-list"
|
||||||
|
hx-get="/processes"
|
||||||
|
hx-trigger="every 5s"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
{{ template "processes.html" . }}
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</html>
|
135
mainPage/templates/processes.html
Normal file
135
mainPage/templates/processes.html
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
{{ range .Supervisor.GetProcesses }}
|
||||||
|
<li>
|
||||||
|
<span class="process-name">📦
|
||||||
|
{{ if .Running }}
|
||||||
|
🟢 {{ .Name }}{{if ne .Description ""}} <span class="process-description">{{.Description}}</span>{{end}}
|
||||||
|
{{ else }}
|
||||||
|
🔴 {{ .Name }}{{if ne .Description ""}} <span class="process-description">{{.Description}}</span>{{end}}
|
||||||
|
{{ end }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div class="dropdown">
|
||||||
|
<button class="dot-button">⋮</button>
|
||||||
|
<div class="dropdown-content">
|
||||||
|
{{ if not .Running }}
|
||||||
|
<button
|
||||||
|
hx-post="/start-process"
|
||||||
|
hx-vals='{"name": "{{ .Name }}"}'
|
||||||
|
hx-trigger="click"
|
||||||
|
hx-target="#process-list"
|
||||||
|
hx-swap="innerHTML">
|
||||||
|
▶️ Start
|
||||||
|
</button>
|
||||||
|
{{else}}
|
||||||
|
<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>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.process-description {
|
||||||
|
font-weight: 400; /* normal or lighter */
|
||||||
|
color: #2c3e50; /* optional: same color or adjust if needed */
|
||||||
|
}
|
||||||
|
|
||||||
|
.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>
|
@@ -1,92 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
93
supervisor/process.go
Normal file
93
supervisor/process.go
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
package supervisor
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Process struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
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:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var Init bool
|
||||||
|
|
||||||
|
func (p *Process) Start() error {
|
||||||
|
if p.Running {
|
||||||
|
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
|
||||||
|
|
||||||
|
p.Running = true
|
||||||
|
|
||||||
|
if !Init {
|
||||||
|
time.Sleep(time.Duration(p.StartDelay) * time.Millisecond)
|
||||||
|
Init = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := cmd.Start(); err != nil {
|
||||||
|
p.Running = false
|
||||||
|
p.process = nil
|
||||||
|
p.cancel = nil
|
||||||
|
return fmt.Errorf("failed to start process %s: %w", p.Name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err := cmd.Wait()
|
||||||
|
if err != nil {
|
||||||
|
} else {
|
||||||
|
p.Running = false
|
||||||
|
p.process = nil
|
||||||
|
p.cancel = nil
|
||||||
|
}
|
||||||
|
p.Running = false
|
||||||
|
}()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Process) Stop() error {
|
||||||
|
if !p.Running {
|
||||||
|
return fmt.Errorf("process %s is not running", p.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel the context
|
||||||
|
p.cancel()
|
||||||
|
|
||||||
|
err := p.process.Process.Kill()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to kill process %s: %w", p.Name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Running = false
|
||||||
|
p.process = nil
|
||||||
|
p.cancel = nil
|
||||||
|
return nil
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
package models
|
package supervisor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Supervisor struct {
|
type Supervisor struct {
|
||||||
Processes []*SupervisorProcess `json:"processes"`
|
Processes []*Process `json:"processes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadTemplate(path string) (supervisor Supervisor, err error) {
|
func ReadTemplate(path string) (supervisor Supervisor, err error) {
|
||||||
@@ -32,7 +32,7 @@ func (s *Supervisor) StartProcesses() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supervisor) GetProcesses() (processes []SupervisorProcess) {
|
func (s *Supervisor) GetProcesses() (processes []Process) {
|
||||||
for _, p := range s.Processes {
|
for _, p := range s.Processes {
|
||||||
processes = append(processes, *p)
|
processes = append(processes, *p)
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,6 @@ func (s *Supervisor) StopProcessByName(name string) error {
|
|||||||
for _, p := range s.Processes {
|
for _, p := range s.Processes {
|
||||||
if p.Name == name {
|
if p.Name == name {
|
||||||
return p.Stop()
|
return p.Stop()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf("process %s not found", name)
|
return fmt.Errorf("process %s not found", name)
|
@@ -1,177 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Process Dashboard</title>
|
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.5"></script>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Placeholder List for Future Processes -->
|
|
||||||
<ul id="process-list">
|
|
||||||
<div class="top-link-container">
|
|
||||||
<a href="/taskmanager/htop" class="top-link" target="_blank" rel="noopener noreferrer">
|
|
||||||
📈 Task Manager
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Header -->
|
|
||||||
<h2>Processes</h2>
|
|
||||||
{{ 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>
|
|
||||||
</body>
|
|
||||||
<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>
|
|
@@ -1,156 +0,0 @@
|
|||||||
<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