forked from vganshin/aidbox-ui-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
141 deletions.
There are no files selected for viewing
Empty file.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(if (nil? (auth/user-info)) | ||
(box/redirect "/ui/auth/login") | ||
|
||
[:html | ||
[:meta {:charset "UTF-8"}] | ||
[:meta {:name "viewport", :content "width=device-width, initial-scale=1.0"}] | ||
[:title "Chat App"] | ||
|
||
#_[:script {:src "https://cdn.tailwindcss.com"}] | ||
|
||
[:script {:type "module" :src "https://unpkg.com/@hotwired/[email protected]/dist/turbo.es2017-esm.js"}] | ||
#_[:script {:src "/ui/$dev-mode"}] | ||
|
||
[:div "User: " (:id (auth/user-info)) | ||
[:form {:method "POST" :action "/ui/auth/logout" | ||
:style "display: inline; margin-left: 8px"} | ||
[:input {:type "hidden" :name "_csrf" :value (auth/csrf)}] | ||
[:button "Sign out"]] | ||
[:hr]] | ||
|
||
[:div "id: " (:id (box/route-params))] | ||
|
||
[:h1 "Chat"] | ||
|
||
[:turbo-stream-source {:src (format "/ui/chat/%s/$subscribe" (:id (box/route-params)))}] | ||
|
||
[:turbo-frame {:id "chat-form"} | ||
[:form {:action (format "/ui/chat/%s/$send-message" (:id (box/route-params))) :method "post"} | ||
#_[:input {:name "chat-id" :type "hidden" :value (:id (box/route-params))}] | ||
[:input {:name "message"}] | ||
[:button "Send"]]] | ||
|
||
(let [messages (map :resource (box/sql ["select resource || jsonb_build_object('id', id) resource from chatmessage where resource#>>'{chat,id}' = ?" (:id (box/route-params))]))] | ||
[:turbo-frame {:id "chat"} | ||
(for [msg (reverse messages)] | ||
[:div [:span {:style "font-weight: bold;"} (get-in msg [:author :id]) ": "] | ||
(:message msg)])]) | ||
|
||
|
||
|
||
[:div | ||
[:hr] | ||
[:div {:style "font-family: monospace"} (format "Aidbox version %s" (box/version))]] | ||
]) |
This file was deleted.
Oops, something went wrong.