diff --git a/source/clog-gui.lisp b/source/clog-gui.lisp index d2e169f..76c3486 100644 --- a/source/clog-gui.lisp +++ b/source/clog-gui.lisp @@ -1227,8 +1227,10 @@ interactions. Use window-end-modal to undo.")) (defun alert-toast (obj title content &key (color-class "w3-red") (time-out nil) + (place-top nil) (html-id nil)) - "Create an alert toast with option :TIME-OUT" + "Create an alert toast with option :TIME-OUT. If place-top is t then alert +is placed in DOM at top of html body instead of bottom of html body." (unless html-id (setf html-id (clog-connection:generate-id))) (let* ((body (connection-data-item obj "clog-body")) @@ -1242,8 +1244,12 @@ interactions. Use window-end-modal to undo.")) color-class html-id title - content))) + content) + :auto-place nil)) (closer (attach-as-child body (format nil "~A-close" html-id)))) + (if place-top + (place-inside-top-of body win) + (place-inside-bottom-of body win)) (set-on-click closer (lambda (obj) (destroy win))) (when time-out diff --git a/tutorial/25-tutorial.lisp b/tutorial/25-tutorial.lisp index ad0d273..c187119 100644 --- a/tutorial/25-tutorial.lisp +++ b/tutorial/25-tutorial.lisp @@ -19,7 +19,7 @@ ;;;; --------------------------------------------------------- (defpackage #:clog-user - (:use #:cl #:clog #:clog-web) + (:use #:cl #:clog #:clog-web #:clog-gui) (:export start-tutorial)) (in-package :clog-user) @@ -40,14 +40,18 @@ (set-on-submit form (lambda (obj) (declare (ignore obj)) - (setf (inner-html results-section) - (format nil "~A
~A" - (inner-html results-section) - (lf-to-br (uiop/run-program:run-program - (value command) - :force-shell t :output :string)))) - (setf (scroll-top results-section) - (scroll-height results-section)) + (handler-case + (progn + (setf (inner-html results-section) + (format nil "~A
~A" + (inner-html results-section) + (lf-to-br (uiop/run-program:run-program + (value command) + :force-shell t :output :string)))) + (setf (scroll-top results-section) + (scroll-height results-section))) + (error (c) + (alert-toast body "Error" c :time-out 2 :place-top t))) (setf (value command) "")))) (setf (overflow results-section) :scroll) (set-border results-section :thin :solid :black)