From 6fe677ae182a6012b55725bb52cd40f638aac0df Mon Sep 17 00:00:00 2001 From: Mesut GENEZ Date: Sun, 7 Jul 2024 23:29:20 +0300 Subject: [PATCH] toast --- assets/css/custom.css | 13 +++++++++++++ assets/js/custom.js | 19 +++++++++++++++++++ handler/web/notification.go | 12 ++++++------ handler/web/request.go | 8 ++++---- handler/web/schedule.go | 4 ++-- handler/web/webhook.go | 4 ++-- views/components/group/list.gohtml | 3 +-- views/components/group/new.gohtml | 1 - views/components/notification/new.gohtml | 9 +++------ views/components/request/new.gohtml | 6 ++---- views/components/schedule/new.gohtml | 3 +-- views/components/setting/user-new.gohtml | 3 +-- views/index.gohtml | 2 ++ 13 files changed, 56 insertions(+), 31 deletions(-) diff --git a/assets/css/custom.css b/assets/css/custom.css index acdf7e2..7f84b66 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -1,3 +1,16 @@ * { box-shadow: none !important +} + +#toast { + position: fixed; + padding: 10px; + width: 30%; + left: 35%; + bottom: 20px; + border-radius: 10px; + border: solid 1px #ddd; + color: brown; + text-transform: lowercase; + display: none; } \ No newline at end of file diff --git a/assets/js/custom.js b/assets/js/custom.js index e69de29..5df2074 100644 --- a/assets/js/custom.js +++ b/assets/js/custom.js @@ -0,0 +1,19 @@ +let toastTimeout; +const toast = document.getElementById('toast'); +const observer = new MutationObserver((mutations) => { + for (const mutation of mutations) { + if (mutation.type === 'childList') { + // Display toast + toast.style.display = 'block'; + // Clear previous timeout if any + if (toastTimeout) { + clearTimeout(toastTimeout); + } + // Hide toast after 5 seconds + toastTimeout = setTimeout(() => { + toast.style.display = 'none'; + }, 5000); + } + } +}); +observer.observe(toast, { childList: true }); \ No newline at end of file diff --git a/handler/web/notification.go b/handler/web/notification.go index 89e303e..14f54c3 100644 --- a/handler/web/notification.go +++ b/handler/web/notification.go @@ -92,7 +92,7 @@ func (h *NotificationHandler) EditHandler(w http.ResponseWriter, r *http.Request } form := fmt.Sprintf(` - + %d @@ -112,7 +112,7 @@ func (h *NotificationHandler) EditHandler(w http.ResponseWriter, r *http.Request %s
- +
@@ -421,7 +421,7 @@ func (h *NotificationHandler) EmailEditHandler(w http.ResponseWriter, r *http.Re } form := fmt.Sprintf(` - + %d %s @@ -433,7 +433,7 @@ func (h *NotificationHandler) EmailEditHandler(w http.ResponseWriter, r *http.Re %s
- +
@@ -610,7 +610,7 @@ func (h *NotificationHandler) MessageEditHandler(w http.ResponseWriter, r *http. } form := fmt.Sprintf(` - + %d %s @@ -622,7 +622,7 @@ func (h *NotificationHandler) MessageEditHandler(w http.ResponseWriter, r *http. %s
- +
diff --git a/handler/web/request.go b/handler/web/request.go index fe84240..1939d20 100644 --- a/handler/web/request.go +++ b/handler/web/request.go @@ -83,7 +83,7 @@ func (h *RequestHandler) EditHandler(w http.ResponseWriter, r *http.Request) err } form := fmt.Sprintf(` - + %d @@ -410,7 +410,7 @@ func (h *RequestHandler) HeaderEditHandler(w http.ResponseWriter, r *http.Reques %s
- +
diff --git a/handler/web/schedule.go b/handler/web/schedule.go index 2290e59..9bec194 100644 --- a/handler/web/schedule.go +++ b/handler/web/schedule.go @@ -104,7 +104,7 @@ func (h *ScheduleHandler) EditHandler(w http.ResponseWriter, r *http.Request) er } form := fmt.Sprintf(` - + %d %s %s @@ -121,7 +121,7 @@ func (h *ScheduleHandler) EditHandler(w http.ResponseWriter, r *http.Request) er %s
- +
diff --git a/handler/web/webhook.go b/handler/web/webhook.go index c853fe1..c802e3e 100644 --- a/handler/web/webhook.go +++ b/handler/web/webhook.go @@ -81,7 +81,7 @@ func (h *WebhookHandler) EditHandler(w http.ResponseWriter, r *http.Request) err scheduleList += "" form := fmt.Sprintf(` - + %d %s %s @@ -93,7 +93,7 @@ func (h *WebhookHandler) EditHandler(w http.ResponseWriter, r *http.Request) err %s
- +
diff --git a/views/components/group/list.gohtml b/views/components/group/list.gohtml index cc2f122..b2d172e 100644 --- a/views/components/group/list.gohtml +++ b/views/components/group/list.gohtml @@ -41,7 +41,7 @@ -
+ -
diff --git a/views/components/notification/new.gohtml b/views/components/notification/new.gohtml index f2805f3..47bfdab 100644 --- a/views/components/notification/new.gohtml +++ b/views/components/notification/new.gohtml @@ -4,7 +4,7 @@
-
+
@@ -35,11 +35,10 @@
-
-
+
@@ -87,7 +85,6 @@
-
diff --git a/views/components/request/new.gohtml b/views/components/request/new.gohtml index fb632fe..54a14d3 100644 --- a/views/components/request/new.gohtml +++ b/views/components/request/new.gohtml @@ -3,7 +3,7 @@ {{define "requestNew" }}
-
+
@@ -30,11 +30,10 @@
-
-
+
@@ -51,7 +51,6 @@
-
diff --git a/views/components/setting/user-new.gohtml b/views/components/setting/user-new.gohtml index 45ba0ef..8791615 100644 --- a/views/components/setting/user-new.gohtml +++ b/views/components/setting/user-new.gohtml @@ -3,7 +3,7 @@ {{define "userNew" }}
-
+
@@ -21,7 +21,6 @@
-
diff --git a/views/index.gohtml b/views/index.gohtml index a922529..a186675 100644 --- a/views/index.gohtml +++ b/views/index.gohtml @@ -143,6 +143,8 @@ {{block "content" .}}{{end}} +
+