Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): add message history/editing to frontend #10

Merged
merged 61 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
17c5e60
feat(frontend): add messages page
RobertRosca Feb 19, 2024
4fab6b3
refactor: split models out into module
RobertRosca Feb 20, 2024
7c89975
feat(repositories): generalise repos, make async
RobertRosca Feb 20, 2024
10406ba
feat(mymdc): return bot id with credentials
RobertRosca Feb 20, 2024
e4d1c97
feat(frontend): set htmx/css path in Jinja env
RobertRosca Feb 20, 2024
f4702e5
feat(frontend): add client/messages route
RobertRosca Feb 20, 2024
757ea5d
feat(frontend): make navbar sticky
RobertRosca Feb 20, 2024
483c9e3
feat(frontend): add button to go to messages
RobertRosca Feb 20, 2024
74b68a5
fix(build): use raw url for htmx add
RobertRosca Feb 20, 2024
f75136b
build: add prettier/plugins to dev deps
RobertRosca Feb 20, 2024
bae3c28
build: remove typer, add mail dependency, add vcr
RobertRosca Feb 20, 2024
8bd1e94
fix(frontend): use function names in `url_for` calls
RobertRosca Feb 20, 2024
b1cc2e4
feat(frontend): disable delete button
RobertRosca Feb 20, 2024
76c0e71
feat(client): make propagate_mode optional in update_message
RobertRosca Feb 20, 2024
0453764
refactor(services): raise http exceptions in services.get_client
RobertRosca Feb 20, 2024
def1caa
fix(repositories): get lock when loading
RobertRosca Feb 20, 2024
1bddd69
feat(repositories): reload from disk on key miss
RobertRosca Feb 20, 2024
807c32a
feat(mymdc): fetch bot site from mymdc
RobertRosca Feb 20, 2024
8bf94c5
fix(services): fetch zulip bot id via zulip if missing
RobertRosca Feb 20, 2024
e354f5c
feat(frontend): use fetch api for comment updates
RobertRosca Feb 20, 2024
0a0daa2
style: apply formatting
RobertRosca Feb 20, 2024
63d8d43
style: typing fixes
RobertRosca Feb 20, 2024
41db021
feat(frontend): allow for true partial loading of pages
RobertRosca Feb 20, 2024
d9594e8
fix(deploy): use correct env var for proxy root
RobertRosca Feb 21, 2024
5140a6e
build: rename compose files
RobertRosca Feb 21, 2024
f234533
build: use taskfile instead of makefile
RobertRosca Feb 22, 2024
657551b
feat(frontend): remove redundant concent div wrap
RobertRosca Feb 22, 2024
01d8f6d
feat(frontend): split out list table row to fragments, partial load v…
RobertRosca Feb 22, 2024
bc272c9
feat(frontend): split out message table row to fragments, partial loa…
RobertRosca Feb 22, 2024
216dbaf
feat(frontend): fade animations on component load, update navbar style
RobertRosca Feb 22, 2024
df2588f
feat(frontend): adjust htmx load style for better partial updates
RobertRosca Feb 22, 2024
046a84e
feat: add gzipmiddleware, compress responses >1kb
RobertRosca Feb 22, 2024
8385bb9
feat: improve logging of uvicorn configuration
RobertRosca Feb 22, 2024
5dfef4b
build: simplify poe commands, up instead of dev
RobertRosca Feb 22, 2024
789fa35
revert: use `uvicorn.run` again
RobertRosca Feb 24, 2024
0af421e
feat(frontend): display message datetime instead of id
RobertRosca Feb 24, 2024
4b5aac3
chore(repositories): sort keys on write
RobertRosca Feb 24, 2024
a9d6cda
refactor(models): rename scoped client key to token
RobertRosca Feb 26, 2024
e7770d8
feat(models): add base model for common fields
RobertRosca Mar 11, 2024
90fb849
feat(repositories): store as list of objects, define index/key in model
RobertRosca Mar 11, 2024
e94c502
feat(frontend): warning sign if bot is not for main zulip elog
RobertRosca Mar 11, 2024
d8c5aae
test: refactor command updates
RobertRosca Mar 11, 2024
1152871
build(docker): split into prod and dev layers
RobertRosca Mar 11, 2024
ca84327
build(docker): use independent compose files instead of overrides
RobertRosca Mar 11, 2024
060c383
refactor(frontend): move updateMessage function to main messages page
RobertRosca Mar 11, 2024
059927e
feat(frontend): add delete button to edit modal
RobertRosca Mar 11, 2024
6d8e2ff
chore(frontend): remove debugger statement
RobertRosca Mar 11, 2024
d83bed0
chore: log trusted hosts and warn if localhost on app startp
RobertRosca Mar 11, 2024
5e3a893
build(docker): update env vars
RobertRosca Mar 11, 2024
4c92a1f
chore: remove unused nginx config file
RobertRosca Mar 11, 2024
0269e85
test(conftest): update conftest
RobertRosca Mar 12, 2024
10af37a
test(models): update model tests
RobertRosca Mar 12, 2024
449cbb9
feat(services): use new repository style
RobertRosca Mar 12, 2024
8449b3e
feat(frontend): generalise alert to info/warning
RobertRosca Mar 12, 2024
22f52fe
feat(frontend): display warning if no messages retrieved
RobertRosca Mar 12, 2024
a5948bc
feat(frontend): show created at and created by columns in list
RobertRosca Mar 12, 2024
62906e8
feat(repositories): return None on no entry instead of KeyError
RobertRosca Mar 12, 2024
d74dd75
feat(models): move defaults out of base models
RobertRosca Mar 12, 2024
5757cf1
feat(repositories): move sorting out of repository class
RobertRosca Mar 12, 2024
2edb89d
feat(services): split out create bot to function
RobertRosca Mar 12, 2024
dc42c4d
feat(mymdc): return full response dict from get zulip bot credentials
RobertRosca Mar 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.zuliprc
.env
.task
clients.json
zuliprc.json
node_modules
src/zulip_write_only_proxy/_version.py
src/zulip_write_only_proxy/frontend/static
Expand Down
19 changes: 15 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ COPY ./src/zulip_write_only_proxy/frontend/templates/ \

RUN pnpm build

ADD --link https://unpkg.com/browse/htmx.org@1.9.10/dist/htmx.js \
https://unpkg.com/browse/htmx.org@1.9.10/dist/htmx.min.js \
ADD --link https://unpkg.com/htmx.org@1.9.10/dist/htmx.js \
https://unpkg.com/htmx.org@1.9.10/dist/htmx.min.js \
./src/zulip_write_only_proxy/frontend/static/

FROM python:3.11-alpine
FROM python:3.11-alpine AS prod

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
Expand All @@ -46,7 +46,18 @@ COPY --link --from=frontend /app/src/zulip_write_only_proxy/frontend/static \

EXPOSE 8000

CMD ["poe", "prod"]
ENV ZWOP_ADDRESS=http://0.0.0.0:8000

CMD ["poe", "up"]

HEALTHCHECK --start-interval=1s --start-period=30s --interval=60s \
CMD wget --spider http://localhost:8000/api/health || exit 1

FROM prod AS dev

RUN --mount=type=cache,target=/root/.cache \
python3 -m pip install debugpy

EXPOSE 5678

CMD ["python3", "-Xfrozen_modules=off", "-m", "debugpy", "--listen", "0.0.0.0:5678", "-m", "zulip_write_only_proxy.main"]
11 changes: 0 additions & 11 deletions Makefile

This file was deleted.

45 changes: 45 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 3

tasks:
css:
cmds:
- |
pnpm exec tailwindcss \
-o src/zulip_write_only_proxy/frontend/static/main.css
sources:
- src/**/*.html
- ./tailwind.config.js
generates:
- src/zulip_write_only_proxy/frontend/static/main.css

css-watch: |
pnpm exec tailwindcss \
-o src/zulip_write_only_proxy/frontend/static/main.css \
--watch

htmx: |
cd ./src/zulip_write_only_proxy/frontend/static && \
wget -N https://unpkg.com/htmx.org@1.9.10/dist/htmx.js

poe-up: poe up

dev:
deps: [css-watch, htmx, poe-up]

docker:
cmds:
- defer: docker compose -p zwop-dev -f ./compose.yml down
- docker compose -p zwop-dev -f ./compose.yml watch
- sleep 10 && docker compose -p zwop-dev -f ./compose.yml logs -f
interactive: true

staging: |
docker compose -f ./compose.staging.yml config | \
sed '/published:/ s/"//g' | sed "/name:/d" | \
docker stack deploy -c - zwop-staging

prod: |
docker compose -f ./compose.prod.yml config | \
sed '/published:/ s/"//g' | sed "/name:/d" | \
docker stack deploy -c - zwop-prod
18 changes: 11 additions & 7 deletions docker-compose.prod.yml → compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ networks:
services:
zwop:
image: ${IMAGE:-ghcr.io/european-xfel/zulip-write-only-proxy}:${TAG:?error}
volumes:
- ./config:/app/config
env_file:
- .env
environment:
ZWOP_PROXY_ROOT: /zwop
- ZWOP_PROXY_ROOT=/zwop
networks:
- proxy
labels:
traefik.http.routers.zwop.entryPoints: https
traefik.enable: true
traefik.http.middlewares.zwop.stripprefix.forceSlash: false
traefik.http.middlewares.zwop.stripprefix.prefixes: /zwop
traefik.http.routers.zwop.middlewares: zwop
traefik.http.routers.zwop.rule: PathPrefix(`/zwop`)
traefik.http.middlewares.zwop-strip-prefix.stripprefix.prefixes: /zwop
traefik.docker.network: proxy
command: !reset null
traefik.http.services.zwop.loadbalancer.server.port: 8000
command: ["poe", "prod"]
deploy:
update_config:
parallelism: 1
Expand All @@ -25,5 +31,3 @@ services:
order: start-first
monitor: 10s
max_failure_ratio: 0

traefik: !reset null
25 changes: 25 additions & 0 deletions compose.staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: "3.8"

networks:
proxy:
external: true

services:
zwop-staging:
build: .
volumes:
- ./config:/app/config
env_file:
- .env
environment:
- ZWOP_PROXY_ROOT=/zwop-staging
networks:
- proxy
labels:
traefik.enable: true
traefik.http.middlewares.zwop-staging.stripprefix.forceSlash: false
traefik.http.middlewares.zwop-staging.stripprefix.prefixes: /zwop-staging
traefik.http.routers.zwop-staging.middlewares: zwop-staging
traefik.http.routers.zwop-staging.rule: PathPrefix(`/zwop-staging`)
traefik.http.services.zwop-staging.loadbalancer.server.port: 8000
command: ["poe", "staging"]
15 changes: 3 additions & 12 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
version: "3.8"

services:
zwop:
zwop-dev:
build: .
volumes:
- ./config:/app/config
environment:
ZWOP_ADDRESS: http://0.0.0.0:8000
ZWOP_PROXY: /zwop
env_file:
- .env
environment:
- ZWOP_PROXY_ROOT=/zwop
labels:
traefik.enable: true
traefik.http.middlewares.zwop-dev.stripprefix.forceSlash: false
Expand All @@ -29,17 +28,9 @@ services:
target: /app/docker-compose.yml
ports:
- 5678:5678
command: [
"sh",
"-c",
"python3 -m pip install debugpy &&
python3 -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678
-m zulip_write_only_proxy.main",
]

traefik:
image: "traefik:v2.10"
container_name: "traefik"
command:
- "--api.insecure=true"
- "--providers.docker=true"
Expand Down
21 changes: 0 additions & 21 deletions docker-compose.staging.yml

This file was deleted.

11 changes: 0 additions & 11 deletions nginx.conf

This file was deleted.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@
"htmx": "cd src/zulip_write_only_proxy/frontend/static/; wget -N https://unpkg.com/browse/htmx.org@1.9.10/dist/htmx.js; wget -N https://unpkg.com/browse/htmx.org@1.9.10/dist/htmx.min.js",
"build": "tailwindcss -o src/zulip_write_only_proxy/frontend/static/main.css",
"watch": "tailwindcss -o src/zulip_write_only_proxy/frontend/static/main.css --watch"
},
"devDependencies": {
"prettier": "^3.2.5",
"prettier-plugin-jinja-template": "^1.3.2",
"prettier-plugin-tailwindcss": "^0.5.11"
}
}
77 changes: 77 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading