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
19 changed files
with
372 additions
and
177 deletions.
There are no files selected for viewing
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,16 @@ | ||
AIDBOX_LICENSE= | ||
|
||
PGHOSTPORT=5437 | ||
PGUSER=postgres | ||
PGPASSWORD=postgres | ||
PGDATABASE=aidbox | ||
|
||
AIDBOX_BASE_URL=http://localhost:8888 | ||
AIDBOX_PORT=8888 | ||
|
||
AIDBOX_CLIENT_SECRET=secret | ||
AIDBOX_ADMIN_PASSWORD=password | ||
|
||
BOX_AUTH_KEYS_SECRET=auth-key-secret | ||
BOX_AUTH_KEYS_PRIVATE="-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEApbUYGNmCz1P8G0j/FFOjx1d5GNssJ/jj6xasSwTIbjjt6FtY\nCDw8o7hayOc/u8aUqXCGhK3JD2T9gtKv9/rV30w4YzmHhA8OOuLJE7tfh/PJA4Hn\n4i2JJ30BuoZ7rPTlTRGdc1FS3XFdmBQtnplEkJ7y8qbdrVme3Kbtn+BR1BdtgwSy\nbpNH2yqh3bb6PwpgNSMH7BIkBWL4A6QDpaFf1/9jSNE1vO25ssLC+bhFQNWLYriu\n+HogzEf9NWIrR2W29mI1QiA7wqvEuhg1yx38ylWD8GhCGL6+2QLKBYgp7DIGv6Uo\nTnqcVISatdQ51lVcCPmU6L1BhmcXVti6dWBI+wIDAQABAoIBAFKMOcJbTKpKvLq8\n7PErz1lFDpreyArrlmKsy0ydx9j8vCt1oY+MrmqisnsFk/7PaIxV9XUP+6qTFSUA\nHtAKYVOZLTfk10jmlSCpjCCrxWW9AISiSKkoJPyKbfuE9gRNhRMU9NoXB5Av4r+Z\nQ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wQxjrWt8R7rPvaD2yqVKLP4liFj8RMdg==\n-----END RSA PRIVATE KEY-----\n" | ||
BOX_AUTH_KEYS_PUBLIC="-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApbUYGNmCz1P8G0j/FFOj\nx1d5GNssJ/jj6xasSwTIbjjt6FtYCDw8o7hayOc/u8aUqXCGhK3JD2T9gtKv9/rV\n30w4YzmHhA8OOuLJE7tfh/PJA4Hn4i2JJ30BuoZ7rPTlTRGdc1FS3XFdmBQtnplE\nkJ7y8qbdrVme3Kbtn+BR1BdtgwSybpNH2yqh3bb6PwpgNSMH7BIkBWL4A6QDpaFf\n1/9jSNE1vO25ssLC+bhFQNWLYriu+HogzEf9NWIrR2W29mI1QiA7wqvEuhg1yx38\nylWD8GhCGL6+2QLKBYgp7DIGv6UoTnqcVISatdQ51lVcCPmU6L1BhmcXVti6dWBI\n+wIDAQAB\n-----END PUBLIC KEY-----\n" |
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 |
---|---|---|
|
@@ -3,3 +3,5 @@ node_modules | |
.env | ||
.lsp | ||
.clj-kondo | ||
pgdata | ||
zen-packages |
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 @@ | ||
tbd |
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 |
---|---|---|
|
@@ -12,6 +12,18 @@ | |
npm run dev | ||
``` | ||
|
||
# Development | ||
|
||
|
||
Aidbox uses sci language (minified Clojure). [sci API](https://github.com/babashka/sci/blob/master/API.md) is fully available. | ||
|
||
In order to get access to Aidbox functions see [API.md](API.md). | ||
|
||
|
||
|
||
|
||
|
||
|
||
# Deploy | ||
|
||
1. Get Aidbox | ||
|
@@ -21,3 +33,31 @@ npm run dev | |
# todo | ||
|
||
- [ ] don't sync `.test.js` files in routes directory | ||
|
||
|
||
|
||
```clojure | ||
[:html | ||
#_[:script {:type "module"} | ||
"import hotwiredTurbo from 'https://cdn.skypack.dev/@hotwired/turbo';"] | ||
|
||
[:script {:type "module" :src "https://unpkg.com/@hotwired/[email protected]/dist/turbo.es2017-esm.js"}] | ||
|
||
[:script {:src "/ui/$dev-mode"}] | ||
|
||
|
||
[:form {:method "POST" :action "/ui/auth/logout"} | ||
[:input {:type "hidden" :name "_csrf" :value (auth/csrf)}] | ||
[:button "Sign out"]] | ||
|
||
[:div "chat"] | ||
|
||
[:turbo-frame {:id "chat"} | ||
[:div "message"]] | ||
|
||
[:turbo-frame {:id "chat-form"} | ||
[:form {:action "/ui/chat/$send-message" :method "post"} | ||
[:button "Generate new message"]]] | ||
|
||
] | ||
``` |
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
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,33 @@ | ||
version: '3.7' | ||
services: | ||
aidbox-db: | ||
image: healthsamurai/aidboxdb:15.3 | ||
pull_policy: always | ||
ports: | ||
- "${PGHOSTPORT}:5432" | ||
volumes: | ||
- "./pgdata:/data" | ||
environment: | ||
POSTGRES_USER: "${PGUSER}" | ||
POSTGRES_PASSWORD: "${PGPASSWORD}" | ||
POSTGRES_DB: "${PGDATABASE}" | ||
|
||
aidbox: | ||
image: healthsamurai/aidboxone:edge | ||
pull_policy: always | ||
depends_on: ["aidbox-db"] | ||
ports: | ||
- "${AIDBOX_PORT}:${AIDBOX_PORT}" | ||
volumes: | ||
- "./zrc:/aidbox-project/zrc" | ||
- "./zen-package.edn:/aidbox-project/zen-package.edn" | ||
- "./zen-packages:/aidbox-project/zen-packages" | ||
env_file: | ||
- .env | ||
environment: | ||
BOX_PROJECT_GIT_TARGET__PATH: /aidbox-project | ||
AIDBOX_ZEN_ENTRYPOINT: main/box | ||
AIDBOX_DEV_MODE: "true" | ||
AIDBOX_ZEN_DEV_MODE: "true" | ||
PGPORT: 5432 | ||
PGHOST: aidbox-db |
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
[:div "root page"] | ||
[:html | ||
[:h1 "UI operations"] | ||
|
||
(for [op (map :resource (box/sql "select * from operation where id like 'aidbox-%'"))] | ||
[:div | ||
(str (:request op))]) | ||
|
||
] |
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
(box/create | ||
{:resourceType "Chat" | ||
:participants [{:id (:id (auth/user-info)) | ||
:resourceType "User"}]}) | ||
|
||
(box/redirect "/ui/chat") |
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
(box/set-header! "Content-Type" "text/vnd.turbo-stream.html; charset=utf-8") | ||
|
||
(when (nil? (box/read {:id (:id (box/route-params)) :resourceType "Chat"})) | ||
(throw (ex-info "Not found" {:id (:id (box/route-params)) :resourceType "Chat"}))) | ||
|
||
(box/create {:resourceType "ChatMessage" | ||
:chat {:id (:id (box/route-params)) :resourceType "Chat"} | ||
:author {:id (:id (auth/user-info)) :resourceType "User"} | ||
:message (:message (box/form-params))}) | ||
|
||
[:<> | ||
|
||
[:turbo-stream {:action "append" :target "chat"} | ||
[:template | ||
[:div [:span {:style "font-weight: bold;"} (:id (auth/user-info)) ": "] | ||
(:message (box/form-params))]]] | ||
|
||
[:turbo-stream {:action "replace" :target "chat-form"} | ||
[:template | ||
[:turbo-frame {:id "chat-form"} | ||
[:form {:action "/ui/chat/$send-message" :method "post"} | ||
[:input {:name "message"}] | ||
[:button "Send"]]]]] | ||
|
||
] |
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 |
---|---|---|
@@ -1,11 +1,52 @@ | ||
(if (nil? (auth/user-info)) | ||
(box/redirect "/ui/chat/login") | ||
(box/redirect "/ui/auth/login") | ||
|
||
[:html | ||
[:meta {:charset "UTF-8"}] | ||
[:meta | ||
{:name "viewport", :content "width=device-width, initial-scale=1.0"}] | ||
[:title "Chat"] | ||
[: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"] | ||
|
||
(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 messages] | ||
[:div [:span {:style "font-weight: bold;"} (:id (auth/user-info)) ": "] | ||
(:message msg)])]) | ||
|
||
[: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"]]] | ||
|
||
[:div | ||
[:hr] | ||
[:div {:style "font-family: monospace"} (format "Aidbox version %s" (box/version))]] | ||
]) | ||
|
||
#_(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..."] | ||
|
||
[:script {:src "https://cdn.tailwindcss.com"}] | ||
|
||
[:script {:type "module" :src "https://unpkg.com/@hotwired/[email protected]/dist/turbo.es2017-esm.js"}] | ||
|
@@ -15,6 +56,7 @@ | |
[:div | ||
{:class | ||
"flex sm:items-center justify-between py-3 border-b-2 border-gray-200"} | ||
|
||
[:div | ||
{:class "relative flex items-center space-x-4"} | ||
[:div | ||
|
@@ -35,6 +77,7 @@ | |
{:class "text-2xl mt-1 flex items-center"} | ||
[:span {:class "text-gray-700 mr-3"} "Dr. Smith"]] | ||
[:span {:class "text-lg text-gray-600"} "Therapist"]]] | ||
|
||
[:div | ||
{:class "flex items-center space-x-2"} | ||
[:button | ||
|
@@ -360,32 +403,8 @@ | |
[:path | ||
{:d | ||
"M10.894 2.553a1 1 0 00-1.788 0l-7 14a1 1 0 001.169 1.409l5-1.429A1 1 0 009 15.571V11a1 1 0 112 0v4.571a1 1 0 00.725.962l5 1.428a1 1 0 001.17-1.408l-7-14z"}]]]]]]] | ||
|
||
[:style | ||
".scrollbar-w-2::-webkit-scrollbar {\n width: 0.25rem;\n height: 0.25rem;\n }\n\n .scrollbar-track-blue-lighter::-webkit-scrollbar-track {\n --bg-opacity: 1;\n background-color: #f7fafc;\n background-color: rgba(247, 250, 252, var(--bg-opacity));\n }\n\n .scrollbar-thumb-blue::-webkit-scrollbar-thumb {\n --bg-opacity: 1;\n background-color: #edf2f7;\n background-color: rgba(237, 242, 247, var(--bg-opacity));\n }\n\n .scrollbar-thumb-rounded::-webkit-scrollbar-thumb {\n border-radius: 0.25rem;\n }"] | ||
[:script | ||
"const el = document.getElementById('messages')\n el.scrollTop = el.scrollHeight"]]) | ||
|
||
|
||
#_[:html | ||
#_[:script {:type "module"} | ||
"import hotwiredTurbo from 'https://cdn.skypack.dev/@hotwired/turbo';"] | ||
|
||
[:script {:type "module" :src "https://unpkg.com/@hotwired/[email protected]/dist/turbo.es2017-esm.js"}] | ||
|
||
[:script {:src "/ui/$dev-mode"}] | ||
|
||
|
||
[:form {:method "POST" :action "/ui/chat/logout"} | ||
[:input {:type "hidden" :name "_csrf" :value (auth/csrf)}] | ||
[:button "Sign out"]] | ||
|
||
[:div "chat"] | ||
|
||
[:turbo-frame {:id "chat"} | ||
[:div "message"]] | ||
|
||
[:turbo-frame {:id "chat-form"} | ||
[:form {:action "/ui/chat/$send-message" :method "post"} | ||
[:button "Generate new message"]]] | ||
|
||
] |
Oops, something went wrong.