From 42975ca85ff2f4b72d2ec65b27bcc783ee0c4e32 Mon Sep 17 00:00:00 2001 From: Florian Hoss Date: Tue, 12 Mar 2024 16:16:49 +0100 Subject: [PATCH] Move components in separate folder --- scripts/.air.toml => .air.toml | 0 .../{ => application}/application.templ | 2 +- components/{ => link}/link.templ | 2 +- components/{ => system}/system.templ | 6 ++-- components/{ => uptime}/uptime.templ | 5 +-- compose.yml | 3 +- views/home/home.templ | 33 ++++++++++--------- 7 files changed, 28 insertions(+), 23 deletions(-) rename scripts/.air.toml => .air.toml (100%) rename components/{ => application}/application.templ (95%) rename components/{ => link}/link.templ (91%) rename components/{ => system}/system.templ (81%) rename components/{ => uptime}/uptime.templ (87%) diff --git a/scripts/.air.toml b/.air.toml similarity index 100% rename from scripts/.air.toml rename to .air.toml diff --git a/components/application.templ b/components/application/application.templ similarity index 95% rename from components/application.templ rename to components/application/application.templ index 121ece3..b332439 100644 --- a/components/application.templ +++ b/components/application/application.templ @@ -1,4 +1,4 @@ -package components +package application import ( "gitlab.unjx.de/flohoss/godash/services" diff --git a/components/link.templ b/components/link/link.templ similarity index 91% rename from components/link.templ rename to components/link/link.templ index 102ceca..b871c43 100644 --- a/components/link.templ +++ b/components/link/link.templ @@ -1,4 +1,4 @@ -package components +package link import ( "gitlab.unjx.de/flohoss/godash/services" diff --git a/components/system.templ b/components/system/system.templ similarity index 81% rename from components/system.templ rename to components/system/system.templ index 562c7ee..16e8b06 100644 --- a/components/system.templ +++ b/components/system/system.templ @@ -1,8 +1,8 @@ -package components +package system import "html/template" -var barTemplate = template.Must(template.New("bar").Parse("
")) +var BarTemplate = template.Must(template.New("bar").Parse("
")) type Bar struct { Id string @@ -16,7 +16,7 @@ templ System(icon string, infoPre string, infoPost string, extraInfo string, per
{ extraInfo }
{ infoPre }{ infoPost }
- @templ.FromGoHTML(barTemplate, Bar{Id:percentageId, Percentage:percentage}) + @templ.FromGoHTML(BarTemplate, Bar{Id:percentageId, Percentage:percentage})
diff --git a/components/uptime.templ b/components/uptime/uptime.templ similarity index 87% rename from components/uptime.templ rename to components/uptime/uptime.templ index f56cd72..a0f6cc3 100644 --- a/components/uptime.templ +++ b/components/uptime/uptime.templ @@ -1,6 +1,7 @@ -package components +package uptime import "gitlab.unjx.de/flohoss/godash/services" +import "gitlab.unjx.de/flohoss/godash/components/system" import "fmt" import "html/template" @@ -31,7 +32,7 @@ templ Uptime(extraInfo string, id string, uptime services.Uptime) {
- @templ.FromGoHTML(barTemplate, Bar{Id:id, Percentage:float64(uptime.Percentage)}) + @templ.FromGoHTML(system.BarTemplate, system.Bar{Id:id, Percentage:float64(uptime.Percentage)})
diff --git a/compose.yml b/compose.yml index c5caf34..0959ecf 100644 --- a/compose.yml +++ b/compose.yml @@ -1,5 +1,6 @@ services: godash: + profiles: [build] image: ${CURRENT_IMAGE} build: context: . @@ -21,7 +22,7 @@ services: apk add tzdata RUN go install github.com/cosmtrek/air@latest - COPY scripts/.air.toml . + COPY .air.toml . WORKDIR /app COPY go.mod . diff --git a/views/home/home.templ b/views/home/home.templ index b873918..084d550 100644 --- a/views/home/home.templ +++ b/views/home/home.templ @@ -2,39 +2,42 @@ package home import "gitlab.unjx.de/flohoss/godash/services" import "gitlab.unjx.de/flohoss/godash/views/layout" -import "gitlab.unjx.de/flohoss/godash/components" +import "gitlab.unjx.de/flohoss/godash/components/system" +import "gitlab.unjx.de/flohoss/godash/components/uptime" +import "gitlab.unjx.de/flohoss/godash/components/application" +import "gitlab.unjx.de/flohoss/godash/components/link" import "fmt" templ Home(title string, bookmarks *services.Bookmarks, static *services.StaticInformation, live *services.LiveInformation) {
- @components.System("icon-[bi--cpu]",static.CPU.Name,"",static.CPU.Threads,"systemCpuPercentage","",live.CPU) - @components.System("icon-[bi--nvme]",live.Disk.Value,fmt.Sprintf(" | %s", static.Disk.Total),static.Disk.Partitions,"systemDiskPercentage","systemDiskValue",live.Disk.Percentage) - @components.System("icon-[bi--memory]",live.Ram.Value,fmt.Sprintf(" | %s", static.Ram.Total),static.Ram.Swap,"systemRamPercentage","systemRamValue",live.Ram.Percentage) - @components.Uptime(static.Host.Architecture,"systemUptimePercentage",live.Uptime) + @system.System("icon-[bi--cpu]",static.CPU.Name,"",static.CPU.Threads,"systemCpuPercentage","",live.CPU) + @system.System("icon-[bi--nvme]",live.Disk.Value,fmt.Sprintf(" | %s", static.Disk.Total),static.Disk.Partitions,"systemDiskPercentage","systemDiskValue",live.Disk.Percentage) + @system.System("icon-[bi--memory]",live.Ram.Value,fmt.Sprintf(" | %s", static.Ram.Total),static.Ram.Swap,"systemRamPercentage","systemRamValue",live.Ram.Percentage) + @uptime.Uptime(static.Host.Architecture,"systemUptimePercentage",live.Uptime)
- for _, app := range bookmarks.Applications { + for _, a := range bookmarks.Applications {
- if app.Category != "" { -
{ app.Category }
+ if a.Category != "" { +
{ a.Category }
}
- for _, entry := range app.Entries { - @components.Application(entry) + for _, entry := range a.Entries { + @application.Application(entry) }
}
- for _, link := range bookmarks.Links { + for _, l := range bookmarks.Links {
- if link.Category != "" { -
{ link.Category }
+ if l.Category != "" { +
{ l.Category }
} - for _, entry := range link.Entries { - @components.Link(entry) + for _, entry := range l.Entries { + @link.Link(entry) }
}