From 4f5f41a183dcc7d5a0c3e328a0ca5da48531b9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dalibor=20Markovi=C4=87?= Date: Sat, 20 Jun 2026 13:15:54 +0200 Subject: [PATCH] =?UTF-8?q?Admin:=20ispravke=20AJAX=20toast-a=20za=20sve?= =?UTF-8?q?=20akcije=20korisnika=20i=20dozvola=20-=20base.html:=20toast=20?= =?UTF-8?q?pri=20u=C4=8Ditavanju=20stranice=20ako=20URL=20sadr=C5=BEi=20?= =?UTF-8?q?=3Fsacuvano=3D1=20(pokriven=20i=20cross-page=20redirect)=20-=20?= =?UTF-8?q?admin.go:=20svih=209=20SetFlash(uspeh)=20zamenjeno=20sa=20redir?= =?UTF-8?q?ect=20=3Fsacuvano=3D1=20(korisnici,=20profil,=20dozvole)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/handler/admin.go | 27 ++++++++-------------- web/templates/teme/podrazumevana/base.html | 10 ++++++++ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/internal/handler/admin.go b/internal/handler/admin.go index b81d109..6c289af 100644 --- a/internal/handler/admin.go +++ b/internal/handler/admin.go @@ -126,8 +126,7 @@ func (h *Handler) AdminSacuvajKorisnika(w http.ResponseWriter, r *http.Request) return } - middleware.SetFlash(w, r, h.DB, "uspeh", "Korisnik je uspešno kreiran.") - http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther) + http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther) } // AdminToggleAktivan menja aktivan status korisnika @@ -172,8 +171,7 @@ func (h *Handler) AdminToggleAktivan(w http.ResponseWriter, r *http.Request) { return } - middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.") - http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther) + http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther) } // AdminPromeniUlogu menja ulogu korisnika @@ -234,8 +232,7 @@ func (h *Handler) AdminPromeniUlogu(w http.ResponseWriter, r *http.Request) { return } - middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.") - http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther) + http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther) } // AdminObrisiKorisnika briše korisnika sa ulogom radnik @@ -279,8 +276,7 @@ func (h *Handler) AdminObrisiKorisnika(w http.ResponseWriter, r *http.Request) { return } - middleware.SetFlash(w, r, h.DB, "uspeh", "Korisnik je obrisan.") - http.Redirect(w, r, "/admin/korisnici", http.StatusSeeOther) + http.Redirect(w, r, "/admin/korisnici?sacuvano=1", http.StatusSeeOther) } // AdminProfil prikazuje stranicu profila @@ -406,8 +402,7 @@ func (h *Handler) AdminPromeniLozinku(w http.ResponseWriter, r *http.Request) { return } - middleware.SetFlash(w, r, h.DB, "uspeh", "Lozinka je uspešno promenjena.") - http.Redirect(w, r, "/admin/profil", http.StatusSeeOther) + http.Redirect(w, r, "/admin/profil?sacuvano=1", http.StatusSeeOther) } // AdminTotpPokreni generiše TOTP tajnu i prikazuje QR kod @@ -529,8 +524,7 @@ func (h *Handler) AdminTotpDeaktivacija(w http.ResponseWriter, r *http.Request) // isključenjem 2FA brišemo i rezervne kodove _ = h.RezervniKodoviRepo.Obrisi(r.Context(), k.ID) - middleware.SetFlash(w, r, h.DB, "uspeh", "Dvostepena verifikacija je isključena.") - http.Redirect(w, r, "/admin/profil", http.StatusSeeOther) + http.Redirect(w, r, "/admin/profil?sacuvano=1", http.StatusSeeOther) } // AdminLoginIstorija prikazuje evidenciju prijava za datog korisnika @@ -679,8 +673,7 @@ func (h *Handler) AdminDozvolePromeniUlogu(w http.ResponseWriter, r *http.Reques return } - middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.") - http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther) + http.Redirect(w, r, "/admin/dozvole?sacuvano=1", http.StatusSeeOther) } // AdminDozvoleSacuvaj prima POST i čuva promene dozvola za radnik i admin uloge @@ -711,8 +704,7 @@ func (h *Handler) AdminDozvoleSacuvaj(w http.ResponseWriter, r *http.Request) { } } } - middleware.SetFlash(w, r, h.DB, "uspeh", "Promene su uspešno sačuvane.") - http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther) + http.Redirect(w, r, "/admin/dozvole?sacuvano=1", http.StatusSeeOther) } // AdminDozvoleReset vraća sve dozvole na podrazumevane vrednosti — samo superadmin @@ -727,6 +719,5 @@ func (h *Handler) AdminDozvoleReset(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther) return } - middleware.SetFlash(w, r, h.DB, "uspeh", "Dozvole su vraćene na podrazumevane vrednosti.") - http.Redirect(w, r, "/admin/dozvole", http.StatusSeeOther) + http.Redirect(w, r, "/admin/dozvole?sacuvano=1", http.StatusSeeOther) } diff --git a/web/templates/teme/podrazumevana/base.html b/web/templates/teme/podrazumevana/base.html index 1fcf1a6..60f2e55 100644 --- a/web/templates/teme/podrazumevana/base.html +++ b/web/templates/teme/podrazumevana/base.html @@ -318,6 +318,16 @@ f.appendChild(i); }); } + // toast pri učitavanju stranice ako URL sadrži ?sacuvano=1 (cross-page redirect) + if (!window._ntechSacuvanoPrikazano && location.search.indexOf('sacuvano=1') !== -1) { + window._ntechSacuvanoPrikazano = true; + window.ntechToast('Sačuvano', 'uspeh'); + var _p = new URLSearchParams(location.search); + _p.delete('sacuvano'); + var _q = _p.toString() ? '?' + _p.toString() : ''; + history.replaceState(null, '', location.pathname + _q + location.hash); + } + document.querySelectorAll('[data-potvrda]').forEach(function(el) { if (el._potvrda) return; el._potvrda = true;