diff --git a/cmd/ntech/main.go b/cmd/ntech/main.go
index 1bb8b74..2860337 100644
--- a/cmd/ntech/main.go
+++ b/cmd/ntech/main.go
@@ -1,13 +1,13 @@
package main
import (
- "fmt"
"log"
"net/http"
"os"
"ntech/internal/config"
"ntech/internal/db/sqlite"
+ "ntech/internal/handler"
"github.com/go-chi/chi/v5"
"github.com/joho/godotenv"
@@ -48,9 +48,15 @@ func main() {
log.Println("Migracije uspešno izvršene")
r := chi.NewRouter()
+
+ // statični fajlovi — CSS, JS, slike
+ r.Handle("/static/*", http.StripPrefix("/static/", http.FileServer(http.Dir("web/static"))))
+
+ // rute
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintln(w, "Zdravo iz NTech-a")
+ http.Redirect(w, r, "/dashboard", http.StatusFound)
})
+ r.Get("/dashboard", handler.Dashboard)
log.Printf("NTech pokrenut na portu %s", port)
err = http.ListenAndServe(":"+port, r)
diff --git a/internal/handler/dashboard.go b/internal/handler/dashboard.go
new file mode 100644
index 0000000..ff497c2
--- /dev/null
+++ b/internal/handler/dashboard.go
@@ -0,0 +1,46 @@
+package handler
+
+import (
+ "html/template"
+ "net/http"
+
+ "ntech/internal/model"
+)
+
+// Dashboard renderuje početnu stranicu
+func Dashboard(w http.ResponseWriter, r *http.Request) {
+ // za sad koristimo testne podatke — kasnije će ići iz baze
+ podaci := model.PodaciDashboarda{
+ PodaciStranice: model.PodaciStranice{
+ Stranica: "dashboard",
+ NaslovStranice: "Dashboard",
+ Tema: "tamna",
+ NazivFirme: "NTech",
+ Korisnik: "Admin",
+ },
+ BrojArtikala: 0,
+ AktivniServisi: 0,
+ ProdajaOvogMeseca: 0,
+ KriticnaZaliha: 0,
+ PoslednjiServisi: []model.StavkaServisa{},
+ KriticneZalihe: []model.StavkaZalihe{},
+ }
+
+ // učitavamo sve potrebne šablone zajedno
+ tmpl, err := template.ParseFiles(
+ "web/templates/teme/podrazumevana/base.html",
+ "web/templates/komponente/sidebar.html",
+ "web/templates/komponente/topbar.html",
+ "web/templates/stranice/dashboard.html",
+ )
+ if err != nil {
+ http.Error(w, "Greška pri učitavanju stranice", http.StatusInternalServerError)
+ return
+ }
+
+ // renderujemo base šablon sa podacima
+ if err := tmpl.ExecuteTemplate(w, "base", podaci); err != nil {
+ http.Error(w, "Greška pri prikazu stranice", http.StatusInternalServerError)
+ return
+ }
+}
diff --git a/internal/model/stranica.go b/internal/model/stranica.go
new file mode 100644
index 0000000..5b1330f
--- /dev/null
+++ b/internal/model/stranica.go
@@ -0,0 +1,36 @@
+package model
+
+// StavkaServisa prikazuje jedan servisni nalog na dashboardu
+type StavkaServisa struct {
+ Uredjaj string
+ Status string
+ BojaTacke string // "#16a34a" zelena, "#f59e0b" žuta, "#dc2626" crvena
+}
+
+// StavkaZalihe prikazuje jedan artikal sa kritičnom zalihom
+type StavkaZalihe struct {
+ Naziv string
+ Kolicina int
+ BojaTacke string
+}
+
+// PodaciStranice su zajednički podaci koje svaka stranica prima
+type PodaciStranice struct {
+ Stranica string // naziv aktivne stranice za sidebar
+ NaslovStranice string // naslov u topbaru
+ Tema string // aktivna tema: "tamna", "svetla", "zelena", "ljubicasta"
+ NazivFirme string // naziv firme za logo zonu
+ Logo string // putanja do logo fajla, opciono
+ Korisnik string // ime korisnika za avatar
+}
+
+// PodaciDashboarda su podaci specifični za dashboard stranicu
+type PodaciDashboarda struct {
+ PodaciStranice
+ BrojArtikala int
+ AktivniServisi int
+ ProdajaOvogMeseca int
+ KriticnaZaliha int
+ PoslednjiServisi []StavkaServisa
+ KriticneZalihe []StavkaZalihe
+}
diff --git a/web/templates/komponente/sidebar.html b/web/templates/komponente/sidebar.html
new file mode 100644
index 0000000..12b01c1
--- /dev/null
+++ b/web/templates/komponente/sidebar.html
@@ -0,0 +1,84 @@
+{{define "sidebar"}}
+
+{{end}}
diff --git a/web/templates/komponente/topbar.html b/web/templates/komponente/topbar.html
new file mode 100644
index 0000000..5e55e45
--- /dev/null
+++ b/web/templates/komponente/topbar.html
@@ -0,0 +1,18 @@
+{{define "topbar"}}
+