mirror of
https://github.com/abhinavxd/libredesk.git
synced 2025-11-05 06:23:27 +00:00
Compare commits
253 Commits
v0.4.2-alp
...
fix/imap-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
beee4bace6 | ||
|
|
a29c707795 | ||
|
|
e2319714ca | ||
|
|
172f78262e | ||
|
|
f53d5f188f | ||
|
|
55ec962003 | ||
|
|
d3b1955cb2 | ||
|
|
fac496fef2 | ||
|
|
c36a425a1e | ||
|
|
f43ab5041e | ||
|
|
cd0ff1b67d | ||
|
|
5bc065469d | ||
|
|
77be86b1f4 | ||
|
|
dde84c65b0 | ||
|
|
f2d4969733 | ||
|
|
aeececd001 | ||
|
|
fdeeda8bca | ||
|
|
45bae57183 | ||
|
|
a345b2e322 | ||
|
|
490aaedb48 | ||
|
|
87361e5cda | ||
|
|
c039d5a20f | ||
|
|
53f15a3a7e | ||
|
|
a397d3d3ea | ||
|
|
4ca123e6a1 | ||
|
|
7dd5abdda6 | ||
|
|
c16144a2bf | ||
|
|
7f1c2c2f11 | ||
|
|
d8a681d17e | ||
|
|
f657a873bc | ||
|
|
88e07c324d | ||
|
|
6c9eca3d81 | ||
|
|
07b185050e | ||
|
|
66886c34e5 | ||
|
|
0af7265178 | ||
|
|
f722de2fe4 | ||
|
|
6b2be57049 | ||
|
|
e1b2ec8a4b | ||
|
|
8d47a7456d | ||
|
|
62023695a5 | ||
|
|
a212ed4afb | ||
|
|
8e6bea09fe | ||
|
|
71e2e3cd8a | ||
|
|
59f5084bec | ||
|
|
87e1477811 | ||
|
|
10d3da608c | ||
|
|
0de7c91641 | ||
|
|
61ec075bd6 | ||
|
|
0b2c607cd3 | ||
|
|
0556318714 | ||
|
|
7b35cf0abf | ||
|
|
8619aa8e17 | ||
|
|
25db57805e | ||
|
|
3b2d0d049f | ||
|
|
1c6d03a4c2 | ||
|
|
062e0c39da | ||
|
|
67090fb052 | ||
|
|
c434de130b | ||
|
|
4e4f07f2e8 | ||
|
|
19a507c88f | ||
|
|
ac61d43688 | ||
|
|
7f8e3ccbbc | ||
|
|
facce8bdad | ||
|
|
8acad27b75 | ||
|
|
24fbe14804 | ||
|
|
061677f2b0 | ||
|
|
450b609d47 | ||
|
|
971a433f3d | ||
|
|
220321bb8c | ||
|
|
d5ba70667d | ||
|
|
a9f9d368b9 | ||
|
|
2fc642c34e | ||
|
|
488f14e87c | ||
|
|
3702a61d74 | ||
|
|
b01f6f812d | ||
|
|
a0c77bc12e | ||
|
|
8bc511509c | ||
|
|
0254bab266 | ||
|
|
91372f5339 | ||
|
|
d69a8c58d1 | ||
|
|
4e893ef876 | ||
|
|
5770188e4d | ||
|
|
8bd7895ccf | ||
|
|
e10bb45582 | ||
|
|
a397bc059b | ||
|
|
4a305ff889 | ||
|
|
616410c0a9 | ||
|
|
408e1fc142 | ||
|
|
bc586fe775 | ||
|
|
a49038f965 | ||
|
|
4cfe0ccbd9 | ||
|
|
acbb94447c | ||
|
|
cd429b9751 | ||
|
|
78d073c499 | ||
|
|
8083ad93b4 | ||
|
|
ad99dee544 | ||
|
|
a5eeb03f0d | ||
|
|
c81f6496ea | ||
|
|
143a12e3c3 | ||
|
|
e2d6a214c4 | ||
|
|
4a3afc83a5 | ||
|
|
bb512d5ecd | ||
|
|
7957dbbd4a | ||
|
|
199778e771 | ||
|
|
b2a53b18d5 | ||
|
|
576c678403 | ||
|
|
9bfe014d1e | ||
|
|
1b536bdc69 | ||
|
|
c02339f311 | ||
|
|
1e7ab144b6 | ||
|
|
e998529827 | ||
|
|
0a57a2724e | ||
|
|
d2248d34c5 | ||
|
|
33f2f67ba8 | ||
|
|
7075ca214c | ||
|
|
e68325d609 | ||
|
|
2499df866f | ||
|
|
be5779e201 | ||
|
|
2d868b7df1 | ||
|
|
374aabcb10 | ||
|
|
e69b1c3e6d | ||
|
|
1821647695 | ||
|
|
b4f2186150 | ||
|
|
6d588f7a4e | ||
|
|
2a382d6036 | ||
|
|
c639bfba40 | ||
|
|
82aac02a97 | ||
|
|
c348a5c9b7 | ||
|
|
008f71d7b4 | ||
|
|
9b41aa0e9a | ||
|
|
c60a0788d9 | ||
|
|
013b5bf37e | ||
|
|
df0dfb480f | ||
|
|
2daefccd79 | ||
|
|
f69e8dd4f8 | ||
|
|
d171958223 | ||
|
|
3b7550fcf3 | ||
|
|
0de712762c | ||
|
|
6b6549cb03 | ||
|
|
cd4b9a9c23 | ||
|
|
e19f817c5f | ||
|
|
5ce8ed72ba | ||
|
|
4ec564ee2e | ||
|
|
19f08ec76a | ||
|
|
dd8053b2bb | ||
|
|
72b92d6c66 | ||
|
|
497b54fc49 | ||
|
|
9d18d3d08d | ||
|
|
6bea14e7a9 | ||
|
|
25f23735d5 | ||
|
|
3888793450 | ||
|
|
88e4a55952 | ||
|
|
9aa9a5e1b2 | ||
|
|
a3098a1dbd | ||
|
|
76a24467e7 | ||
|
|
4361250c73 | ||
|
|
7d9650be2e | ||
|
|
eb707fd8de | ||
|
|
36077b1837 | ||
|
|
d5499229b5 | ||
|
|
5e90dfee5a | ||
|
|
1875a62e00 | ||
|
|
f60c4e8cb6 | ||
|
|
495ff02067 | ||
|
|
5afec04c07 | ||
|
|
56f00e791e | ||
|
|
dcede8a461 | ||
|
|
39fd5c9165 | ||
|
|
4b8a954043 | ||
|
|
6ac9f28a32 | ||
|
|
8101c202fa | ||
|
|
09746fb365 | ||
|
|
f59ea59a2e | ||
|
|
a2cdd728c0 | ||
|
|
ac59a5defc | ||
|
|
05fbe39315 | ||
|
|
c7c65a3d83 | ||
|
|
5bf6b7df47 | ||
|
|
c034c21fa5 | ||
|
|
4ed241a03d | ||
|
|
6b00f70c37 | ||
|
|
c51073d289 | ||
|
|
d03d4477de | ||
|
|
3b211dc372 | ||
|
|
6b4f243b74 | ||
|
|
9ff5a53ebb | ||
|
|
9b9282dfd9 | ||
|
|
698e2d960e | ||
|
|
a8db8f64b5 | ||
|
|
a5a9d1304c | ||
|
|
f688be1c88 | ||
|
|
d3eb3499df | ||
|
|
721f7c811c | ||
|
|
a33e1453a8 | ||
|
|
b6ce6975c9 | ||
|
|
860b216e2b | ||
|
|
eaa2b1ddcf | ||
|
|
0f12b2a3f3 | ||
|
|
def0bb8e4c | ||
|
|
a41c360cdb | ||
|
|
159cca6866 | ||
|
|
83f553227a | ||
|
|
28a6a3d246 | ||
|
|
7e16cc1a74 | ||
|
|
aeef7d4ad7 | ||
|
|
f0358f67f0 | ||
|
|
12f2453f5a | ||
|
|
2742be5619 | ||
|
|
d837defbc9 | ||
|
|
5cc849e7eb | ||
|
|
729faf980c | ||
|
|
a36c81141b | ||
|
|
756147a2c9 | ||
|
|
88a641fe09 | ||
|
|
785da6715c | ||
|
|
32401fa231 | ||
|
|
83b891c92a | ||
|
|
f277f76a0a | ||
|
|
5f1a40acba | ||
|
|
d90b9c2be7 | ||
|
|
43184ec2f3 | ||
|
|
2fdcf68a22 | ||
|
|
4bef3e80a2 | ||
|
|
09703c1090 | ||
|
|
45541c221a | ||
|
|
fc0e0a8fff | ||
|
|
d1f931106d | ||
|
|
227aa26c35 | ||
|
|
79a3f0ff70 | ||
|
|
eefacdbda2 | ||
|
|
3783cce1be | ||
|
|
a4cb373f32 | ||
|
|
99e8949be6 | ||
|
|
1240051825 | ||
|
|
5398d4ec41 | ||
|
|
fd4e47dc68 | ||
|
|
1ff7317c4d | ||
|
|
d6449b9336 | ||
|
|
580fb76a39 | ||
|
|
91889423a2 | ||
|
|
f12efe5511 | ||
|
|
56187ddc46 | ||
|
|
47af51d0dd | ||
|
|
47a3985a51 | ||
|
|
3f11af13b8 | ||
|
|
da629c864c | ||
|
|
6fb35b90b3 | ||
|
|
9892f9dae7 | ||
|
|
277586f025 | ||
|
|
f3070e13a7 | ||
|
|
8ed29df11c | ||
|
|
36d91de8f7 | ||
|
|
57c1948379 |
45
.github/workflows/crowdin.yml
vendored
Normal file
45
.github/workflows/crowdin.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
name: Crowdin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
# Only trigger a Crowdin update when the source localization file is
|
||||||
|
# updated.
|
||||||
|
- 'i18n/en.json'
|
||||||
|
# Only watches for changes happening on "main" branch.
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
crowdin:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Crowdin push
|
||||||
|
uses: crowdin/github-action@v2
|
||||||
|
with:
|
||||||
|
# Send source (english) strings to Crowdin.
|
||||||
|
upload_sources: true
|
||||||
|
# See: https://crowdin.github.io/crowdin-cli/commands
|
||||||
|
# /crowdin-upload#options
|
||||||
|
upload_sources_args: '--preserve-hierarchy --delete-obsolete'
|
||||||
|
# Don't upload or download translations.
|
||||||
|
upload_translations: false
|
||||||
|
download_translations: false
|
||||||
|
# Source language file.
|
||||||
|
source: 'i18n/en.json'
|
||||||
|
# Translations files.
|
||||||
|
translation: 'i18n/%two_letters_code%.json'
|
||||||
|
env:
|
||||||
|
# Crowdin.com > Project > Tools > API > Project ID.
|
||||||
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||||
|
# When creating a personal token in Crowdin, you'll be asked to select
|
||||||
|
# the necessary scopes. The basic Crowdin Personal Token scopes are
|
||||||
|
# the following:
|
||||||
|
# - Projects (List, Get, Create, Edit) -> Read
|
||||||
|
# - Translation Status -> Read Only
|
||||||
|
# - Source files & strings -> Read and Write
|
||||||
|
# - Translations -> Read and Write
|
||||||
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||||
|
|
||||||
66
.github/workflows/cypress.yml
vendored
Normal file
66
.github/workflows/cypress.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: libredesk
|
||||||
|
POSTGRES_PASSWORD: libredesk
|
||||||
|
POSTGRES_DB: libredesk
|
||||||
|
options: >-
|
||||||
|
--health-cmd="pg_isready -U libredesk"
|
||||||
|
--health-interval=10s
|
||||||
|
--health-timeout=5s
|
||||||
|
--health-retries=5
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379:6379
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: "1.24.3"
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
run: npm install -g pnpm
|
||||||
|
|
||||||
|
- name: Install cypress deps
|
||||||
|
run: sudo apt-get update && sudo apt-get install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2t64 libxtst6 xauth xvfb
|
||||||
|
|
||||||
|
- name: Build binary and frontend
|
||||||
|
run: make build
|
||||||
|
|
||||||
|
- name: Configure app
|
||||||
|
run: |
|
||||||
|
cp config.sample.toml config.toml
|
||||||
|
|
||||||
|
- name: Install db schema and run tests
|
||||||
|
env:
|
||||||
|
LIBREDESK_SYSTEM_USER_PASSWORD: "StrongPass!123"
|
||||||
|
run: |
|
||||||
|
./libredesk --install --idempotent-install --yes --config ./config.toml
|
||||||
|
./libredesk --upgrade --yes --config ./config.toml
|
||||||
|
./libredesk --config ./config.toml &
|
||||||
|
sleep 10
|
||||||
|
cd frontend
|
||||||
|
pnpm run test:e2e:ci
|
||||||
22
.github/workflows/go.yml
vendored
Normal file
22
.github/workflows/go.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: Go
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.24.3"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: go get -v ./...
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: make test
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.21"
|
go-version: "1.24.3"
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Set up Node.js
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
# Install necessary packages
|
# Install necessary packages
|
||||||
RUN apk --no-cache add ca-certificates
|
RUN apk --no-cache add ca-certificates tzdata
|
||||||
|
|
||||||
# Set the working directory to /libredesk
|
# Set the working directory to /libredesk
|
||||||
WORKDIR /libredesk
|
WORKDIR /libredesk
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -72,3 +72,9 @@ stuff: $(STUFFBIN)
|
|||||||
demo-build:
|
demo-build:
|
||||||
@echo "→ Building in demo mode..."
|
@echo "→ Building in demo mode..."
|
||||||
@export VITE_DEMO_BUILD="true" && $(MAKE) build
|
@export VITE_DEMO_BUILD="true" && $(MAKE) build
|
||||||
|
|
||||||
|
# Run tests.
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
@echo "→ Running tests..."
|
||||||
|
go test -count=1 ./...
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -7,7 +7,8 @@ Open source, self-hosted customer support desk. Single binary app.
|
|||||||
|
|
||||||
Visit [libredesk.io](https://libredesk.io) for more info. Check out the [**Live demo**](https://demo.libredesk.io/).
|
Visit [libredesk.io](https://libredesk.io) for more info. Check out the [**Live demo**](https://demo.libredesk.io/).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
> **CAUTION:** This project is currently in **alpha**. Features and APIs may change and are not yet fully tested.
|
> **CAUTION:** This project is currently in **alpha**. Features and APIs may change and are not yet fully tested.
|
||||||
@@ -34,6 +35,8 @@ Visit [libredesk.io](https://libredesk.io) for more info. Check out the [**Live
|
|||||||
Connect your favorite BI tools like Metabase and create custom dashboards and reports with your support data—without lock-ins.
|
Connect your favorite BI tools like Metabase and create custom dashboards and reports with your support data—without lock-ins.
|
||||||
- **AI-Assisted Response Rewrite**
|
- **AI-Assisted Response Rewrite**
|
||||||
Instantly rewrite responses with AI to make them more friendly, professional, or polished.
|
Instantly rewrite responses with AI to make them more friendly, professional, or polished.
|
||||||
|
- **Activity logs**
|
||||||
|
Track all actions performed by agents and admins—updates and key events across the system—for auditing and accountability.
|
||||||
- **Command Bar**
|
- **Command Bar**
|
||||||
Opens with a simple shortcut (CTRL+k) and lets you quickly perform actions on conversations.
|
Opens with a simple shortcut (CTRL+k) and lets you quickly perform actions on conversations.
|
||||||
|
|
||||||
@@ -54,6 +57,8 @@ curl -LO https://github.com/abhinavxd/libredesk/raw/main/config.sample.toml
|
|||||||
# Copy the config.sample.toml to config.toml and edit it as needed.
|
# Copy the config.sample.toml to config.toml and edit it as needed.
|
||||||
cp config.sample.toml config.toml
|
cp config.sample.toml config.toml
|
||||||
|
|
||||||
|
# Edit config.toml and find commented lines containing "docker compose". Replace the values in the lines below those comments with service names instead of IP addresses.
|
||||||
|
|
||||||
# Run the services in the background.
|
# Run the services in the background.
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
@@ -80,3 +85,7 @@ __________________
|
|||||||
|
|
||||||
## Developers
|
## Developers
|
||||||
If you are interested in contributing, refer to the [developer setup](https://libredesk.io/docs/developer-setup/). The backend is written in Go and the frontend is Vue js 3 with Shadcn for UI components.
|
If you are interested in contributing, refer to the [developer setup](https://libredesk.io/docs/developer-setup/). The backend is written in Go and the frontend is Vue js 3 with Shadcn for UI components.
|
||||||
|
|
||||||
|
|
||||||
|
## Translators
|
||||||
|
You can help translate Libredesk into your language on [Crowdin](https://crowdin.com/project/libredesk).
|
||||||
|
|||||||
36
cmd/actvity_log.go
Normal file
36
cmd/actvity_log.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
|
"github.com/zerodha/fastglue"
|
||||||
|
)
|
||||||
|
|
||||||
|
// handleGetActivityLogs returns activity logs from the database.
|
||||||
|
func handleGetActivityLogs(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
order = string(r.RequestCtx.QueryArgs().Peek("order"))
|
||||||
|
orderBy = string(r.RequestCtx.QueryArgs().Peek("order_by"))
|
||||||
|
filters = string(r.RequestCtx.QueryArgs().Peek("filters"))
|
||||||
|
page, _ = strconv.Atoi(string(r.RequestCtx.QueryArgs().Peek("page")))
|
||||||
|
pageSize, _ = strconv.Atoi(string(r.RequestCtx.QueryArgs().Peek("page_size")))
|
||||||
|
total = 0
|
||||||
|
)
|
||||||
|
logs, err := app.activityLog.GetAll(order, orderBy, filters, page, pageSize)
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
if len(logs) > 0 {
|
||||||
|
total = logs[0].Total
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
|
Results: logs,
|
||||||
|
Total: total,
|
||||||
|
PerPage: pageSize,
|
||||||
|
TotalPages: (total + pageSize - 1) / pageSize,
|
||||||
|
Page: page,
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
@@ -43,7 +43,7 @@ func handleUpdateAIProvider(r *fastglue.Request) error {
|
|||||||
req providerUpdateReq
|
req providerUpdateReq
|
||||||
)
|
)
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, "Error unmarshalling request", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil))
|
||||||
}
|
}
|
||||||
if err := app.ai.UpdateProvider(req.Provider, req.APIKey); err != nil {
|
if err := app.ai.UpdateProvider(req.Provider, req.APIKey); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
|
|||||||
33
cmd/auth.go
33
cmd/auth.go
@@ -6,6 +6,7 @@ import (
|
|||||||
amodels "github.com/abhinavxd/libredesk/internal/auth/models"
|
amodels "github.com/abhinavxd/libredesk/internal/auth/models"
|
||||||
"github.com/abhinavxd/libredesk/internal/envelope"
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
"github.com/abhinavxd/libredesk/internal/stringutil"
|
"github.com/abhinavxd/libredesk/internal/stringutil"
|
||||||
|
realip "github.com/ferluci/fast-realip"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
@@ -22,20 +23,21 @@ func handleOIDCLogin(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error parsing provider id", "error", err)
|
app.lo.Error("error parsing provider id", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error parsing provider id.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a state and save it in the session, to prevent CSRF attacks.
|
// Set a state and save it in the session, to prevent CSRF attacks.
|
||||||
state, err := stringutil.RandomAlphanumeric(32)
|
state, err := stringutil.RandomAlphanumeric(32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error generating state", "error", err)
|
app.lo.Error("error generating state", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error generating state.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorGenerating", "name", "state"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.auth.SetSessionValues(r, map[string]interface{}{
|
if err = app.auth.SetSessionValues(r, map[string]interface{}{
|
||||||
oidcStateSessKey: state,
|
oidcStateSessKey: state,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
app.lo.Error("error saving state in session", "error", err)
|
app.lo.Error("error saving state in session", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error saving state in session.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorSaving", "name", "{globals.terms.session}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
authURL, err := app.auth.LoginURL(providerID, state)
|
authURL, err := app.auth.LoginURL(providerID, state)
|
||||||
@@ -52,30 +54,32 @@ func handleOIDCCallback(r *fastglue.Request) error {
|
|||||||
code = string(r.RequestCtx.QueryArgs().Peek("code"))
|
code = string(r.RequestCtx.QueryArgs().Peek("code"))
|
||||||
state = string(r.RequestCtx.QueryArgs().Peek("state"))
|
state = string(r.RequestCtx.QueryArgs().Peek("state"))
|
||||||
providerID, err = strconv.Atoi(string(r.RequestCtx.UserValue("id").(string)))
|
providerID, err = strconv.Atoi(string(r.RequestCtx.UserValue("id").(string)))
|
||||||
|
ip = realip.FromRequest(r.RequestCtx)
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error parsing provider id", "error", err)
|
app.lo.Error("error parsing provider id", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error parsing provider id.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare the state from the session with the state from the query.
|
// Compare the state from the session with the state from the query.
|
||||||
sessionState, err := app.auth.GetSessionValue(r, oidcStateSessKey)
|
sessionState, err := app.auth.GetSessionValue(r, oidcStateSessKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error getting state from session", "error", err)
|
app.lo.Error("error getting state from session", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error getting state from session.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.session}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
if state != sessionState {
|
if state != sessionState {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusForbidden, "Invalid state.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.mismatch", "name", "{globals.terms.state}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, claims, err := app.auth.ExchangeOIDCToken(r.RequestCtx, providerID, code)
|
_, claims, err := app.auth.ExchangeOIDCToken(r.RequestCtx, providerID, code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error exchanging oidc token", "error", err)
|
app.lo.Error("error exchanging oidc token", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error exchanging OIDC token.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError,
|
||||||
|
app.i18n.T("globals.messages.errorExchangingToken"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup the user by email and set the session.
|
// Lookup the user by email and set the session.
|
||||||
user, err := app.user.GetAgentByEmail(claims.Email)
|
user, err := app.user.GetAgent(0, claims.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -86,7 +90,18 @@ func handleOIDCCallback(r *fastglue.Request) error {
|
|||||||
FirstName: user.FirstName,
|
FirstName: user.FirstName,
|
||||||
LastName: user.LastName,
|
LastName: user.LastName,
|
||||||
}, r); err != nil {
|
}, r); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error saving session.", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError,
|
||||||
|
app.i18n.Ts("globals.messages.errorSaving", "name", "{globals.terms.session}"), nil, envelope.GeneralError)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update last login time.
|
||||||
|
if err := app.user.UpdateLastLoginAt(user.ID); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert activity log.
|
||||||
|
if err := app.activityLog.Login(user.ID, user.Email.String, ip); err != nil {
|
||||||
|
app.lo.Error("error creating login activity log", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.Redirect("/", fasthttp.StatusFound, nil, "")
|
return r.Redirect("/", fasthttp.StatusFound, nil, "")
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ func handleToggleAutomationRule(r *fastglue.Request) error {
|
|||||||
if err := app.automation.ToggleRule(id); err != nil {
|
if err := app.automation.ToggleRule(id); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Rule toggled successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateAutomationRule updates an automation rule
|
// handleUpdateAutomationRule updates an automation rule
|
||||||
@@ -55,18 +55,17 @@ func handleUpdateAutomationRule(r *fastglue.Request) error {
|
|||||||
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
)
|
)
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid rule `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&rule, "json"); err != nil {
|
if err := r.Decode(&rule, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.automation.UpdateRule(id, rule);err != nil {
|
if err = app.automation.UpdateRule(id, rule); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Rule updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleCreateAutomationRule creates a new automation rule
|
// handleCreateAutomationRule creates a new automation rule
|
||||||
@@ -76,12 +75,12 @@ func handleCreateAutomationRule(r *fastglue.Request) error {
|
|||||||
rule = amodels.RuleRecord{}
|
rule = amodels.RuleRecord{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&rule, "json"); err != nil {
|
if err := r.Decode(&rule, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err := app.automation.CreateRule(rule); err != nil {
|
if err := app.automation.CreateRule(rule); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Rule created successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleDeleteAutomationRule deletes an automation rule
|
// handleDeleteAutomationRule deletes an automation rule
|
||||||
@@ -92,15 +91,12 @@ func handleDeleteAutomationRule(r *fastglue.Request) error {
|
|||||||
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
)
|
)
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid rule `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
if err = app.automation.DeleteRule(id); err != nil {
|
||||||
err = app.automation.DeleteRule(id)
|
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Rule deleted successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateAutomationRuleWeights updates the weights of the automation rules
|
// handleUpdateAutomationRuleWeights updates the weights of the automation rules
|
||||||
@@ -110,13 +106,13 @@ func handleUpdateAutomationRuleWeights(r *fastglue.Request) error {
|
|||||||
weights = make(map[int]int)
|
weights = make(map[int]int)
|
||||||
)
|
)
|
||||||
if err := r.Decode(&weights, "json"); err != nil {
|
if err := r.Decode(&weights, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
err := app.automation.UpdateRuleWeights(weights)
|
err := app.automation.UpdateRuleWeights(weights)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Weights updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateAutomationRuleExecutionMode updates the execution mode of the automation rules for a given type
|
// handleUpdateAutomationRuleExecutionMode updates the execution mode of the automation rules for a given type
|
||||||
@@ -126,11 +122,11 @@ func handleUpdateAutomationRuleExecutionMode(r *fastglue.Request) error {
|
|||||||
mode = string(r.RequestCtx.PostArgs().Peek("mode"))
|
mode = string(r.RequestCtx.PostArgs().Peek("mode"))
|
||||||
)
|
)
|
||||||
if mode != amodels.ExecutionModeAll && mode != amodels.ExecutionModeFirstMatch {
|
if mode != amodels.ExecutionModeAll && mode != amodels.ExecutionModeFirstMatch {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid execution mode", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("automation.invalidRuleExecutionMode"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
// Only new conversation rules can be updated as they are the only ones that have execution mode.
|
// Only new conversation rules can be updated as they are the only ones that have execution mode.
|
||||||
if err := app.automation.UpdateRuleExecutionMode(amodels.RuleTypeNewConversation, mode); err != nil {
|
if err := app.automation.UpdateRuleExecutionMode(amodels.RuleTypeNewConversation, mode); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Execution mode updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ func handleGetBusinessHour(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid business hour `id`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
businessHour, err := app.businessHours.Get(id)
|
businessHour, err := app.businessHours.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == businessHours.ErrBusinessHoursNotFound {
|
if err == businessHours.ErrBusinessHoursNotFound {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusNotFound, err.Error(), nil, envelope.NotFoundError)
|
return r.SendErrorEnvelope(fasthttp.StatusNotFound, err.Error(), nil, envelope.NotFoundError)
|
||||||
}
|
}
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error fetching business hour", nil, "")
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.businessHour}"), nil, "")
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(businessHour)
|
return r.SendEnvelope(businessHour)
|
||||||
}
|
}
|
||||||
@@ -48,11 +48,11 @@ func handleCreateBusinessHours(r *fastglue.Request) error {
|
|||||||
businessHours = models.BusinessHours{}
|
businessHours = models.BusinessHours{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&businessHours, "json"); err != nil {
|
if err := r.Decode(&businessHours, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if businessHours.Name == "" {
|
if businessHours.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty business hour `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.businessHours.Create(businessHours.Name, businessHours.Description, businessHours.IsAlwaysOpen, businessHours.Hours, businessHours.Holidays); err != nil {
|
if err := app.businessHours.Create(businessHours.Name, businessHours.Description, businessHours.IsAlwaysOpen, businessHours.Hours, businessHours.Holidays); err != nil {
|
||||||
@@ -69,14 +69,11 @@ func handleDeleteBusinessHour(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid business hour `id`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
if err = app.businessHours.Delete(id); err != nil {
|
||||||
err = app.businessHours.Delete(id)
|
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,20 +85,16 @@ func handleUpdateBusinessHours(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid business hour `id`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&businessHours, "json"); err != nil {
|
if err := r.Decode(&businessHours, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if businessHours.Name == "" {
|
if businessHours.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty business hour `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.businessHours.Update(id, businessHours.Name, businessHours.Description, businessHours.IsAlwaysOpen, businessHours.Hours, businessHours.Holidays); err != nil {
|
if err := app.businessHours.Update(id, businessHours.Name, businessHours.Description, businessHours.IsAlwaysOpen, businessHours.Hours, businessHours.Holidays); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|||||||
250
cmd/contacts.go
Normal file
250
cmd/contacts.go
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
amodels "github.com/abhinavxd/libredesk/internal/auth/models"
|
||||||
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
|
"github.com/abhinavxd/libredesk/internal/stringutil"
|
||||||
|
"github.com/abhinavxd/libredesk/internal/user/models"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"github.com/volatiletech/null/v9"
|
||||||
|
"github.com/zerodha/fastglue"
|
||||||
|
)
|
||||||
|
|
||||||
|
// handleGetContacts returns a list of contacts from the database.
|
||||||
|
func handleGetContacts(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
order = string(r.RequestCtx.QueryArgs().Peek("order"))
|
||||||
|
orderBy = string(r.RequestCtx.QueryArgs().Peek("order_by"))
|
||||||
|
filters = string(r.RequestCtx.QueryArgs().Peek("filters"))
|
||||||
|
page, _ = strconv.Atoi(string(r.RequestCtx.QueryArgs().Peek("page")))
|
||||||
|
pageSize, _ = strconv.Atoi(string(r.RequestCtx.QueryArgs().Peek("page_size")))
|
||||||
|
total = 0
|
||||||
|
)
|
||||||
|
contacts, err := app.user.GetContacts(page, pageSize, order, orderBy, filters)
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
if len(contacts) > 0 {
|
||||||
|
total = contacts[0].Total
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
|
Results: contacts,
|
||||||
|
Total: total,
|
||||||
|
PerPage: pageSize,
|
||||||
|
TotalPages: (total + pageSize - 1) / pageSize,
|
||||||
|
Page: page,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleGetTags returns a contact from the database.
|
||||||
|
func handleGetContact(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
id, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
)
|
||||||
|
if id <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
c, err := app.user.GetContact(id, "")
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleUpdateContact updates a contact in the database.
|
||||||
|
func handleUpdateContact(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
id, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
)
|
||||||
|
if id <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
contact, err := app.user.GetContact(id, "")
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
form, err := r.RequestCtx.MultipartForm()
|
||||||
|
if err != nil {
|
||||||
|
app.lo.Error("error parsing form data", "error", err)
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.GeneralError)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse form data
|
||||||
|
firstName := ""
|
||||||
|
if v, ok := form.Value["first_name"]; ok && len(v) > 0 {
|
||||||
|
firstName = string(v[0])
|
||||||
|
}
|
||||||
|
lastName := ""
|
||||||
|
if v, ok := form.Value["last_name"]; ok && len(v) > 0 {
|
||||||
|
lastName = string(v[0])
|
||||||
|
}
|
||||||
|
email := ""
|
||||||
|
if v, ok := form.Value["email"]; ok && len(v) > 0 {
|
||||||
|
email = strings.TrimSpace(string(v[0]))
|
||||||
|
}
|
||||||
|
phoneNumber := ""
|
||||||
|
if v, ok := form.Value["phone_number"]; ok && len(v) > 0 {
|
||||||
|
phoneNumber = string(v[0])
|
||||||
|
}
|
||||||
|
phoneNumberCallingCode := ""
|
||||||
|
if v, ok := form.Value["phone_number_calling_code"]; ok && len(v) > 0 {
|
||||||
|
phoneNumberCallingCode = string(v[0])
|
||||||
|
}
|
||||||
|
avatarURL := ""
|
||||||
|
if v, ok := form.Value["avatar_url"]; ok && len(v) > 0 {
|
||||||
|
avatarURL = string(v[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set nulls to empty strings.
|
||||||
|
if avatarURL == "null" {
|
||||||
|
avatarURL = ""
|
||||||
|
}
|
||||||
|
if phoneNumberCallingCode == "null" {
|
||||||
|
phoneNumberCallingCode = ""
|
||||||
|
}
|
||||||
|
if phoneNumber == "null" {
|
||||||
|
phoneNumber = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate mandatory fields.
|
||||||
|
if email == "" {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "email"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if !stringutil.ValidEmail(email) {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "email"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if firstName == "" {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "first_name"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Another contact with same new email?
|
||||||
|
existingContact, _ := app.user.GetContact(0, email)
|
||||||
|
if existingContact.ID > 0 && existingContact.ID != id {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("contact.alreadyExistsWithEmail"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
contactToUpdate := models.User{
|
||||||
|
FirstName: firstName,
|
||||||
|
LastName: lastName,
|
||||||
|
Email: null.StringFrom(email),
|
||||||
|
AvatarURL: null.NewString(avatarURL, avatarURL != ""),
|
||||||
|
PhoneNumber: null.NewString(phoneNumber, phoneNumber != ""),
|
||||||
|
PhoneNumberCallingCode: null.NewString(phoneNumberCallingCode, phoneNumberCallingCode != ""),
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.user.UpdateContact(id, contactToUpdate); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete avatar?
|
||||||
|
if avatarURL == "" && contact.AvatarURL.Valid {
|
||||||
|
fileName := filepath.Base(contact.AvatarURL.String)
|
||||||
|
app.media.Delete(fileName)
|
||||||
|
contact.AvatarURL.Valid = false
|
||||||
|
contact.AvatarURL.String = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upload avatar?
|
||||||
|
files, ok := form.File["files"]
|
||||||
|
if ok && len(files) > 0 {
|
||||||
|
if err := uploadUserAvatar(r, &contact, files); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleGetContactNotes returns all notes for a contact.
|
||||||
|
func handleGetContactNotes(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
contactID, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
)
|
||||||
|
if contactID <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
notes, err := app.user.GetNotes(contactID)
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(notes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleCreateContactNote creates a note for a contact.
|
||||||
|
func handleCreateContactNote(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
contactID, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
|
note = string(r.RequestCtx.PostArgs().Peek("note"))
|
||||||
|
)
|
||||||
|
if len(note) == 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "note"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if err := app.user.CreateNote(contactID, auser.ID, note); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleDeleteContactNote deletes a note for a contact.
|
||||||
|
func handleDeleteContactNote(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
contactID, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
noteID, _ = strconv.Atoi(r.RequestCtx.UserValue("note_id").(string))
|
||||||
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
|
)
|
||||||
|
if contactID <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if noteID <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`note_id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
agent, err := app.user.GetAgent(auser.ID, "")
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow deletion of only own notes and not those created by others, but also allow `Admin` to delete any note.
|
||||||
|
if !agent.HasAdminRole() {
|
||||||
|
note, err := app.user.GetNote(noteID)
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
if note.UserID != auser.ID {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.canOnlyDeleteOwn", "name", "{globals.terms.note}"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.user.DeleteNote(noteID, contactID); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleBlockContact blocks a contact.
|
||||||
|
func handleBlockContact(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
contactID, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
enabled = r.RequestCtx.PostArgs().GetBool("enabled")
|
||||||
|
)
|
||||||
|
if contactID <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if err := app.user.ToggleEnabled(contactID, models.UserTypeContact, enabled); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/abhinavxd/libredesk/internal/automation/models"
|
"github.com/abhinavxd/libredesk/internal/automation/models"
|
||||||
cmodels "github.com/abhinavxd/libredesk/internal/conversation/models"
|
cmodels "github.com/abhinavxd/libredesk/internal/conversation/models"
|
||||||
"github.com/abhinavxd/libredesk/internal/envelope"
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
|
"github.com/abhinavxd/libredesk/internal/stringutil"
|
||||||
umodels "github.com/abhinavxd/libredesk/internal/user/models"
|
umodels "github.com/abhinavxd/libredesk/internal/user/models"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
"github.com/volatiletech/null/v9"
|
"github.com/volatiletech/null/v9"
|
||||||
@@ -38,13 +39,6 @@ func handleGetAllConversations(r *fastglue.Request) error {
|
|||||||
total = conversations[0].Total
|
total = conversations[0].Total
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set deadlines for SLA if conversation has a policy
|
|
||||||
for i := range conversations {
|
|
||||||
if conversations[i].SLAPolicyID.Int != 0 {
|
|
||||||
setSLADeadlines(app, &conversations[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.SendEnvelope(envelope.PageResults{
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
Results: conversations,
|
Results: conversations,
|
||||||
Total: total,
|
Total: total,
|
||||||
@@ -68,19 +62,12 @@ func handleGetAssignedConversations(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
conversations, err := app.conversation.GetAssignedConversationsList(user.ID, order, orderBy, filters, page, pageSize)
|
conversations, err := app.conversation.GetAssignedConversationsList(user.ID, order, orderBy, filters, page, pageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, "")
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
if len(conversations) > 0 {
|
if len(conversations) > 0 {
|
||||||
total = conversations[0].Total
|
total = conversations[0].Total
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set deadlines for SLA if conversation has a policy
|
|
||||||
for i := range conversations {
|
|
||||||
if conversations[i].SLAPolicyID.Int != 0 {
|
|
||||||
setSLADeadlines(app, &conversations[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.SendEnvelope(envelope.PageResults{
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
Results: conversations,
|
Results: conversations,
|
||||||
Total: total,
|
Total: total,
|
||||||
@@ -104,19 +91,12 @@ func handleGetUnassignedConversations(r *fastglue.Request) error {
|
|||||||
|
|
||||||
conversations, err := app.conversation.GetUnassignedConversationsList(order, orderBy, filters, page, pageSize)
|
conversations, err := app.conversation.GetUnassignedConversationsList(order, orderBy, filters, page, pageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, "")
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
if len(conversations) > 0 {
|
if len(conversations) > 0 {
|
||||||
total = conversations[0].Total
|
total = conversations[0].Total
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set deadlines for SLA if conversation has a policy
|
|
||||||
for i := range conversations {
|
|
||||||
if conversations[i].SLAPolicyID.Int != 0 {
|
|
||||||
setSLADeadlines(app, &conversations[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.SendEnvelope(envelope.PageResults{
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
Results: conversations,
|
Results: conversations,
|
||||||
Total: total,
|
Total: total,
|
||||||
@@ -139,7 +119,7 @@ func handleGetViewConversations(r *fastglue.Request) error {
|
|||||||
total = 0
|
total = 0
|
||||||
)
|
)
|
||||||
if viewID < 1 {
|
if viewID < 1 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `view_id`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`view_id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user has access to the view.
|
// Check if user has access to the view.
|
||||||
@@ -148,15 +128,15 @@ func handleGetViewConversations(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
if view.UserID != auser.ID {
|
if view.UserID != auser.ID {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusForbidden, "You don't have access to this view.", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.T("conversation.viewPermissionDenied"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare lists user has access to based on user permissions, internally this affects the SQL query.
|
// Prepare lists user has access to based on user permissions, internally this prepares the SQL query.
|
||||||
lists := []string{}
|
lists := []string{}
|
||||||
for _, perm := range user.Permissions {
|
for _, perm := range user.Permissions {
|
||||||
if perm == authzModels.PermConversationsReadAll {
|
if perm == authzModels.PermConversationsReadAll {
|
||||||
@@ -177,7 +157,7 @@ func handleGetViewConversations(r *fastglue.Request) error {
|
|||||||
|
|
||||||
// No lists found, user doesn't have access to any conversations.
|
// No lists found, user doesn't have access to any conversations.
|
||||||
if len(lists) == 0 {
|
if len(lists) == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusForbidden, "Permission denied", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.denied", "name", "{globals.terms.permission}"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
conversations, err := app.conversation.GetViewConversationsList(user.ID, user.Teams.IDs(), lists, order, orderBy, string(view.Filters), page, pageSize)
|
conversations, err := app.conversation.GetViewConversationsList(user.ID, user.Teams.IDs(), lists, order, orderBy, string(view.Filters), page, pageSize)
|
||||||
@@ -188,13 +168,6 @@ func handleGetViewConversations(r *fastglue.Request) error {
|
|||||||
total = conversations[0].Total
|
total = conversations[0].Total
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set deadlines for SLA if conversation has a policy
|
|
||||||
for i := range conversations {
|
|
||||||
if conversations[i].SLAPolicyID.Int != 0 {
|
|
||||||
setSLADeadlines(app, &conversations[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.SendEnvelope(envelope.PageResults{
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
Results: conversations,
|
Results: conversations,
|
||||||
Total: total,
|
Total: total,
|
||||||
@@ -219,7 +192,7 @@ func handleGetTeamUnassignedConversations(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
teamID, _ := strconv.Atoi(teamIDStr)
|
teamID, _ := strconv.Atoi(teamIDStr)
|
||||||
if teamID < 1 {
|
if teamID < 1 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `team_id`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`team_id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user belongs to the team.
|
// Check if user belongs to the team.
|
||||||
@@ -229,7 +202,7 @@ func handleGetTeamUnassignedConversations(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.PermissionError, "You're not a member of this team, Please refresh the page and try again.", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.PermissionError, app.i18n.T("conversation.notMemberOfTeam"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
conversations, err := app.conversation.GetTeamUnassignedConversationsList(teamID, order, orderBy, filters, page, pageSize)
|
conversations, err := app.conversation.GetTeamUnassignedConversationsList(teamID, order, orderBy, filters, page, pageSize)
|
||||||
@@ -240,13 +213,6 @@ func handleGetTeamUnassignedConversations(r *fastglue.Request) error {
|
|||||||
total = conversations[0].Total
|
total = conversations[0].Total
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set deadlines for SLA if conversation has a policy
|
|
||||||
for i := range conversations {
|
|
||||||
if conversations[i].SLAPolicyID.Int != 0 {
|
|
||||||
setSLADeadlines(app, &conversations[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.SendEnvelope(envelope.PageResults{
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
Results: conversations,
|
Results: conversations,
|
||||||
Total: total,
|
Total: total,
|
||||||
@@ -264,7 +230,7 @@ func handleGetConversation(r *fastglue.Request) error {
|
|||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -274,10 +240,6 @@ func handleGetConversation(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if conv.SLAPolicyID.Int != 0 {
|
|
||||||
setSLADeadlines(app, conv)
|
|
||||||
}
|
|
||||||
|
|
||||||
prev, _ := app.conversation.GetContactConversations(conv.ContactID)
|
prev, _ := app.conversation.GetContactConversations(conv.ContactID)
|
||||||
conv.PreviousConversations = filterCurrentConv(prev, conv.UUID)
|
conv.PreviousConversations = filterCurrentConv(prev, conv.UUID)
|
||||||
return r.SendEnvelope(conv)
|
return r.SendEnvelope(conv)
|
||||||
@@ -290,7 +252,7 @@ func handleUpdateConversationAssigneeLastSeen(r *fastglue.Request) error {
|
|||||||
uuid = r.RequestCtx.UserValue("uuid").(string)
|
uuid = r.RequestCtx.UserValue("uuid").(string)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -301,7 +263,7 @@ func handleUpdateConversationAssigneeLastSeen(r *fastglue.Request) error {
|
|||||||
if err = app.conversation.UpdateConversationAssigneeLastSeen(uuid); err != nil {
|
if err = app.conversation.UpdateConversationAssigneeLastSeen(uuid); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Last seen updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetConversationParticipants retrieves participants of a conversation.
|
// handleGetConversationParticipants retrieves participants of a conversation.
|
||||||
@@ -311,7 +273,7 @@ func handleGetConversationParticipants(r *fastglue.Request) error {
|
|||||||
uuid = r.RequestCtx.UserValue("uuid").(string)
|
uuid = r.RequestCtx.UserValue("uuid").(string)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -335,10 +297,10 @@ func handleUpdateUserAssignee(r *fastglue.Request) error {
|
|||||||
assigneeID = r.RequestCtx.PostArgs().GetUintOrZero("assignee_id")
|
assigneeID = r.RequestCtx.PostArgs().GetUintOrZero("assignee_id")
|
||||||
)
|
)
|
||||||
if assigneeID == 0 {
|
if assigneeID == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `assignee_id`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`assignee_id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -355,7 +317,7 @@ func handleUpdateUserAssignee(r *fastglue.Request) error {
|
|||||||
// Evaluate automation rules.
|
// Evaluate automation rules.
|
||||||
app.automation.EvaluateConversationUpdateRules(uuid, models.EventConversationUserAssigned)
|
app.automation.EvaluateConversationUpdateRules(uuid, models.EventConversationUserAssigned)
|
||||||
|
|
||||||
return r.SendEnvelope("User assigned successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateTeamAssignee updates the team assigned to a conversation.
|
// handleUpdateTeamAssignee updates the team assigned to a conversation.
|
||||||
@@ -367,10 +329,10 @@ func handleUpdateTeamAssignee(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
assigneeID, err := r.RequestCtx.PostArgs().GetUint("assignee_id")
|
assigneeID, err := r.RequestCtx.PostArgs().GetUint("assignee_id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid assignee `id`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`assignee_id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -380,7 +342,7 @@ func handleUpdateTeamAssignee(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
conversation, err := enforceConversationAccess(app, uuid, user)
|
_, err = enforceConversationAccess(app, uuid, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -391,19 +353,7 @@ func handleUpdateTeamAssignee(r *fastglue.Request) error {
|
|||||||
// Evaluate automation rules on team assignment.
|
// Evaluate automation rules on team assignment.
|
||||||
app.automation.EvaluateConversationUpdateRules(uuid, models.EventConversationTeamAssigned)
|
app.automation.EvaluateConversationUpdateRules(uuid, models.EventConversationTeamAssigned)
|
||||||
|
|
||||||
// Apply SLA policy if team has changed and the new team has an SLA policy.
|
return r.SendEnvelope(true)
|
||||||
if conversation.AssignedTeamID.Int != assigneeID && assigneeID != 0 {
|
|
||||||
team, err := app.team.Get(assigneeID)
|
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
|
||||||
}
|
|
||||||
if team.SLAPolicyID.Int != 0 {
|
|
||||||
if err := app.conversation.ApplySLA(*conversation, team.SLAPolicyID.Int, user); err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r.SendEnvelope("Team assigned successfully")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateConversationPriority updates the priority of a conversation.
|
// handleUpdateConversationPriority updates the priority of a conversation.
|
||||||
@@ -415,30 +365,25 @@ func handleUpdateConversationPriority(r *fastglue.Request) error {
|
|||||||
priority = string(r.RequestCtx.PostArgs().Peek("priority"))
|
priority = string(r.RequestCtx.PostArgs().Peek("priority"))
|
||||||
)
|
)
|
||||||
if priority == "" {
|
if priority == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `priority`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`priority`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
conversation, err := app.conversation.GetConversation(0, uuid)
|
|
||||||
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
_, err = enforceConversationAccess(app, uuid, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
allowed, err := app.authz.EnforceConversationAccess(user, conversation)
|
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
|
||||||
}
|
|
||||||
if !allowed {
|
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.PermissionError, "Permission denied", nil))
|
|
||||||
}
|
|
||||||
if err := app.conversation.UpdateConversationPriority(uuid, 0 /**priority_id**/, priority, user); err != nil {
|
if err := app.conversation.UpdateConversationPriority(uuid, 0 /**priority_id**/, priority, user); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate automation rules.
|
// Evaluate automation rules.
|
||||||
app.automation.EvaluateConversationUpdateRules(uuid, models.EventConversationPriorityChange)
|
app.automation.EvaluateConversationUpdateRules(uuid, models.EventConversationPriorityChange)
|
||||||
return r.SendEnvelope("Priority updated successfully")
|
|
||||||
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateConversationStatus updates the status of a conversation.
|
// handleUpdateConversationStatus updates the status of a conversation.
|
||||||
@@ -453,20 +398,20 @@ func handleUpdateConversationStatus(r *fastglue.Request) error {
|
|||||||
|
|
||||||
// Validate inputs
|
// Validate inputs
|
||||||
if status == "" {
|
if status == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `status`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`status`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if snoozedUntil == "" && status == cmodels.StatusSnoozed {
|
if snoozedUntil == "" && status == cmodels.StatusSnoozed {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `snoozed_until`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`snoozed_until`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if status == cmodels.StatusSnoozed {
|
if status == cmodels.StatusSnoozed {
|
||||||
_, err := time.ParseDuration(snoozedUntil)
|
_, err := time.ParseDuration(snoozedUntil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `snoozed_until`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`snoozed_until`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enforce conversation access.
|
// Enforce conversation access.
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -477,7 +422,7 @@ func handleUpdateConversationStatus(r *fastglue.Request) error {
|
|||||||
|
|
||||||
// Make sure a user is assigned before resolving conversation.
|
// Make sure a user is assigned before resolving conversation.
|
||||||
if status == cmodels.StatusResolved && conversation.AssignedUserID.Int == 0 {
|
if status == cmodels.StatusResolved && conversation.AssignedUserID.Int == 0 {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, "Cannot resolve the conversation without an assigned user, Please assign a user before attempting to resolve.", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, app.i18n.T("conversation.resolveWithoutAssignee"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update conversation status.
|
// Update conversation status.
|
||||||
@@ -501,7 +446,7 @@ func handleUpdateConversationStatus(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Status updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateConversationtags updates conversation tags.
|
// handleUpdateConversationtags updates conversation tags.
|
||||||
@@ -516,28 +461,80 @@ func handleUpdateConversationtags(r *fastglue.Request) error {
|
|||||||
|
|
||||||
if err := json.Unmarshal(tagJSON, &tagNames); err != nil {
|
if err := json.Unmarshal(tagJSON, &tagNames); err != nil {
|
||||||
app.lo.Error("error unmarshalling tags JSON", "error", err)
|
app.lo.Error("error unmarshalling tags JSON", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error unmarshalling tags JSON", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
conversation, err := app.conversation.GetConversation(0, uuid)
|
|
||||||
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
_, err = enforceConversationAccess(app, uuid, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
if err := app.conversation.SetConversationTags(uuid, models.ActionSetTags, tagNames, user); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleUpdateConversationCustomAttributes updates custom attributes of a conversation.
|
||||||
|
func handleUpdateConversationCustomAttributes(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
attributes = map[string]any{}
|
||||||
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
|
uuid = r.RequestCtx.UserValue("uuid").(string)
|
||||||
|
)
|
||||||
|
if err := r.Decode(&attributes, ""); err != nil {
|
||||||
|
app.lo.Error("error unmarshalling custom attributes JSON", "error", err)
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enforce conversation access.
|
||||||
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
_, err = enforceConversationAccess(app, uuid, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if allowed, err := app.authz.EnforceConversationAccess(user, conversation); err != nil {
|
// Update custom attributes.
|
||||||
|
if err := app.conversation.UpdateConversationCustomAttributes(uuid, attributes); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
} else if !allowed {
|
}
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.PermissionError, "Permission denied", nil))
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleUpdateContactCustomAttributes updates custom attributes of a contact.
|
||||||
|
func handleUpdateContactCustomAttributes(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
attributes = map[string]any{}
|
||||||
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
|
uuid = r.RequestCtx.UserValue("uuid").(string)
|
||||||
|
)
|
||||||
|
if err := r.Decode(&attributes, ""); err != nil {
|
||||||
|
app.lo.Error("error unmarshalling custom attributes JSON", "error", err)
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.conversation.UpsertConversationTags(uuid, tagNames, user); err != nil {
|
// Enforce conversation access.
|
||||||
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Tags added successfully")
|
conversation, err := enforceConversationAccess(app, uuid, user)
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
if err := app.user.UpdateCustomAttributes(conversation.ContactID, attributes); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleDashboardCounts retrieves general dashboard counts for all users.
|
// handleDashboardCounts retrieves general dashboard counts for all users.
|
||||||
@@ -572,7 +569,7 @@ func enforceConversationAccess(app *App, uuid string, user umodels.User) (*cmode
|
|||||||
}
|
}
|
||||||
allowed, err := app.authz.EnforceConversationAccess(user, conversation)
|
allowed, err := app.authz.EnforceConversationAccess(user, conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, envelope.NewError(envelope.GeneralError, "Error checking permissions", nil)
|
return nil, err
|
||||||
}
|
}
|
||||||
if !allowed {
|
if !allowed {
|
||||||
return nil, envelope.NewError(envelope.PermissionError, "Permission denied", nil)
|
return nil, envelope.NewError(envelope.PermissionError, "Permission denied", nil)
|
||||||
@@ -580,21 +577,6 @@ func enforceConversationAccess(app *App, uuid string, user umodels.User) (*cmode
|
|||||||
return &conversation, nil
|
return &conversation, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// setSLADeadlines gets the latest SLA deadlines for a conversation and sets them.
|
|
||||||
func setSLADeadlines(app *App, conversation *cmodels.Conversation) error {
|
|
||||||
if conversation.ID < 1 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
first, resolution, err := app.sla.GetLatestDeadlines(conversation.ID)
|
|
||||||
if err != nil {
|
|
||||||
app.lo.Error("error getting SLA deadlines", "id", conversation.ID, "error", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
conversation.FirstResponseDueAt = null.NewTime(first, first != time.Time{})
|
|
||||||
conversation.ResolutionDueAt = null.NewTime(resolution, resolution != time.Time{})
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// handleRemoveUserAssignee removes the user assigned to a conversation.
|
// handleRemoveUserAssignee removes the user assigned to a conversation.
|
||||||
func handleRemoveUserAssignee(r *fastglue.Request) error {
|
func handleRemoveUserAssignee(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
@@ -602,7 +584,7 @@ func handleRemoveUserAssignee(r *fastglue.Request) error {
|
|||||||
uuid = r.RequestCtx.UserValue("uuid").(string)
|
uuid = r.RequestCtx.UserValue("uuid").(string)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -623,7 +605,7 @@ func handleRemoveTeamAssignee(r *fastglue.Request) error {
|
|||||||
uuid = r.RequestCtx.UserValue("uuid").(string)
|
uuid = r.RequestCtx.UserValue("uuid").(string)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -659,26 +641,31 @@ func handleCreateConversation(r *fastglue.Request) error {
|
|||||||
firstName = strings.TrimSpace(string(r.RequestCtx.PostArgs().Peek("first_name")))
|
firstName = strings.TrimSpace(string(r.RequestCtx.PostArgs().Peek("first_name")))
|
||||||
lastName = strings.TrimSpace(string(r.RequestCtx.PostArgs().Peek("last_name")))
|
lastName = strings.TrimSpace(string(r.RequestCtx.PostArgs().Peek("last_name")))
|
||||||
subject = strings.TrimSpace(string(r.RequestCtx.PostArgs().Peek("subject")))
|
subject = strings.TrimSpace(string(r.RequestCtx.PostArgs().Peek("subject")))
|
||||||
content = string(r.RequestCtx.PostArgs().Peek("content"))
|
content = strings.TrimSpace(string(r.RequestCtx.PostArgs().Peek("content")))
|
||||||
|
to = []string{email}
|
||||||
)
|
)
|
||||||
|
|
||||||
// Validate required fields
|
// Validate required fields
|
||||||
if inboxID <= 0 {
|
if inboxID <= 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "inbox_id is required", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`inbox_id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if subject == "" {
|
if subject == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "subject is required", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`subject`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if content == "" {
|
if content == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "content is required", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`content`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if email == "" {
|
if email == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Contact email is required", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`contact_email`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if firstName == "" {
|
if firstName == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "First name is required when creating a new contact", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.fieldRequired", "name", "`first_name`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if !stringutil.ValidEmail(email) {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`contact_email`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -689,7 +676,7 @@ func handleCreateConversation(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
if !inbox.Enabled {
|
if !inbox.Enabled {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "The chosen inbox is disabled", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.disabled", "name", "inbox"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find or create contact.
|
// Find or create contact.
|
||||||
@@ -701,7 +688,7 @@ func handleCreateConversation(r *fastglue.Request) error {
|
|||||||
InboxID: inboxID,
|
InboxID: inboxID,
|
||||||
}
|
}
|
||||||
if err := app.user.CreateContact(&contact); err != nil {
|
if err := app.user.CreateContact(&contact); err != nil {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "Error creating contact", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorCreating", "name", "{globals.terms.contact}"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create conversation
|
// Create conversation
|
||||||
@@ -710,21 +697,22 @@ func handleCreateConversation(r *fastglue.Request) error {
|
|||||||
contact.ContactChannelID,
|
contact.ContactChannelID,
|
||||||
inboxID,
|
inboxID,
|
||||||
"", /** last_message **/
|
"", /** last_message **/
|
||||||
time.Now(),
|
time.Now(), /** last_message_at **/
|
||||||
subject,
|
subject,
|
||||||
true, /** append reference number to subject **/
|
true, /** append reference number to subject **/
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error creating conversation", "error", err)
|
app.lo.Error("error creating conversation", "error", err)
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "Error creating conversation", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorCreating", "name", "{globals.terms.conversation}"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send reply to the created conversation.
|
// Send reply to the created conversation.
|
||||||
if err := app.conversation.SendReply(nil /**media**/, inboxID, auser.ID, conversationUUID, content, nil /**cc**/, nil /**bcc**/, map[string]any{} /**meta**/); err != nil {
|
if err := app.conversation.SendReply(nil /**media**/, inboxID, auser.ID /**sender_id**/, conversationUUID, content, to, nil /**cc**/, nil /**bcc**/, map[string]any{} /**meta**/); err != nil {
|
||||||
|
// Delete the conversation if reply fails.
|
||||||
if err := app.conversation.DeleteConversation(conversationUUID); err != nil {
|
if err := app.conversation.DeleteConversation(conversationUUID); err != nil {
|
||||||
app.lo.Error("error deleting conversation", "error", err)
|
app.lo.Error("error deleting conversation", "error", err)
|
||||||
}
|
}
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "Error sending message", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorSending", "name", "{globals.terms.message}"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the conversation to the agent or team.
|
// Assign the conversation to the agent or team.
|
||||||
@@ -736,9 +724,6 @@ func handleCreateConversation(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send the created conversation back to the client.
|
// Send the created conversation back to the client.
|
||||||
conversation, err := app.conversation.GetConversation(conversationID, "")
|
conversation, _ := app.conversation.GetConversation(conversationID, "")
|
||||||
if err != nil {
|
|
||||||
app.lo.Error("error fetching created conversation", "error", err)
|
|
||||||
}
|
|
||||||
return r.SendEnvelope(conversation)
|
return r.SendEnvelope(conversation)
|
||||||
}
|
}
|
||||||
|
|||||||
137
cmd/custom_attributes.go
Normal file
137
cmd/custom_attributes.go
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"slices"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
cmodels "github.com/abhinavxd/libredesk/internal/custom_attribute/models"
|
||||||
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
"github.com/zerodha/fastglue"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// disallowedKeys contains keys that are not allowed for custom attributes as they're the default fields.
|
||||||
|
disallowedKeys = []string{
|
||||||
|
"contact_email",
|
||||||
|
"content",
|
||||||
|
"subject",
|
||||||
|
"status",
|
||||||
|
"priority",
|
||||||
|
"assigned_team",
|
||||||
|
"assigned_user",
|
||||||
|
"hours_since_created",
|
||||||
|
"hours_since_first_reply",
|
||||||
|
"hours_since_last_reply",
|
||||||
|
"hours_since_resolved",
|
||||||
|
"inbox",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// handleGetCustomAttribute retrieves a custom attribute by its ID.
|
||||||
|
func handleGetCustomAttribute(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
)
|
||||||
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
if err != nil || id <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
attribute, err := app.customAttribute.Get(id)
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(attribute)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleGetCustomAttributes retrieves all custom attributes from the database.
|
||||||
|
func handleGetCustomAttributes(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
appliesTo = string(r.RequestCtx.QueryArgs().Peek("applies_to"))
|
||||||
|
)
|
||||||
|
attributes, err := app.customAttribute.GetAll(appliesTo)
|
||||||
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(attributes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleCreateCustomAttribute creates a new custom attribute in the database.
|
||||||
|
func handleCreateCustomAttribute(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
attribute = cmodels.CustomAttribute{}
|
||||||
|
)
|
||||||
|
if err := r.Decode(&attribute, "json"); err != nil {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
|
}
|
||||||
|
if err := validateCustomAttribute(app, attribute); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
if err := app.customAttribute.Create(attribute); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleUpdateCustomAttribute updates an existing custom attribute in the database.
|
||||||
|
func handleUpdateCustomAttribute(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
attribute = cmodels.CustomAttribute{}
|
||||||
|
)
|
||||||
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
if err != nil || id <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if err := r.Decode(&attribute, "json"); err != nil {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
|
}
|
||||||
|
if err := validateCustomAttribute(app, attribute); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
if err = app.customAttribute.Update(id, attribute); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleDeleteCustomAttribute deletes a custom attribute from the database.
|
||||||
|
func handleDeleteCustomAttribute(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
)
|
||||||
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
if err != nil || id <= 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if err = app.customAttribute.Delete(id); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// validateCustomAttribute validates a custom attribute.
|
||||||
|
func validateCustomAttribute(app *App, attribute cmodels.CustomAttribute) error {
|
||||||
|
if attribute.Name == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil)
|
||||||
|
}
|
||||||
|
if attribute.AppliesTo == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`applies_to`"), nil)
|
||||||
|
}
|
||||||
|
if attribute.DataType == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`type`"), nil)
|
||||||
|
}
|
||||||
|
if attribute.Description == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`description`"), nil)
|
||||||
|
}
|
||||||
|
if attribute.Key == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`key`"), nil)
|
||||||
|
}
|
||||||
|
if slices.Contains(disallowedKeys, attribute.Key) {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.T("admin.customAttributes.keyNotAllowed"), nil)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
115
cmd/handlers.go
115
cmd/handlers.go
@@ -12,18 +12,17 @@ import (
|
|||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
slaReqFields = map[string][2]int{"name": {1, 255}, "description": {1, 255}, "first_response_time": {1, 255}, "resolution_time": {1, 255}}
|
|
||||||
)
|
|
||||||
|
|
||||||
// initHandlers initializes the HTTP routes and handlers for the application.
|
// initHandlers initializes the HTTP routes and handlers for the application.
|
||||||
func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
||||||
// Authentication.
|
// Authentication.
|
||||||
g.POST("/api/v1/login", handleLogin)
|
g.POST("/api/v1/login", handleLogin)
|
||||||
g.GET("/logout", handleLogout)
|
g.GET("/logout", auth(handleLogout))
|
||||||
g.GET("/api/v1/oidc/{id}/login", handleOIDCLogin)
|
g.GET("/api/v1/oidc/{id}/login", handleOIDCLogin)
|
||||||
g.GET("/api/v1/oidc/{id}/finish", handleOIDCCallback)
|
g.GET("/api/v1/oidc/{id}/finish", handleOIDCCallback)
|
||||||
|
|
||||||
|
// i18n.
|
||||||
|
g.GET("/api/v1/lang/{lang}", handleGetI18nLang)
|
||||||
|
|
||||||
// Media.
|
// Media.
|
||||||
g.GET("/uploads/{uuid}", auth(handleServeMedia))
|
g.GET("/uploads/{uuid}", auth(handleServeMedia))
|
||||||
g.POST("/api/v1/media", auth(handleMediaUpload))
|
g.POST("/api/v1/media", auth(handleMediaUpload))
|
||||||
@@ -64,11 +63,13 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
|||||||
g.POST("/api/v1/conversations/{cuuid}/messages", perm(handleSendMessage, "messages:write"))
|
g.POST("/api/v1/conversations/{cuuid}/messages", perm(handleSendMessage, "messages:write"))
|
||||||
g.PUT("/api/v1/conversations/{cuuid}/messages/{uuid}/retry", perm(handleRetryMessage, "messages:write"))
|
g.PUT("/api/v1/conversations/{cuuid}/messages/{uuid}/retry", perm(handleRetryMessage, "messages:write"))
|
||||||
g.POST("/api/v1/conversations", perm(handleCreateConversation, "conversations:write"))
|
g.POST("/api/v1/conversations", perm(handleCreateConversation, "conversations:write"))
|
||||||
|
g.PUT("/api/v1/conversations/{uuid}/custom-attributes", auth(handleUpdateConversationCustomAttributes))
|
||||||
|
g.PUT("/api/v1/conversations/{uuid}/contacts/custom-attributes", auth(handleUpdateContactCustomAttributes))
|
||||||
|
|
||||||
// Search.
|
// Search.
|
||||||
g.GET("/api/v1/conversations/search", perm(handleSearchConversations, "conversations:read"))
|
g.GET("/api/v1/conversations/search", perm(handleSearchConversations, "conversations:read"))
|
||||||
g.GET("/api/v1/messages/search", perm(handleSearchMessages, "messages:read"))
|
g.GET("/api/v1/messages/search", perm(handleSearchMessages, "messages:read"))
|
||||||
g.GET("/api/v1/contacts/search", perm(handleSearchContacts, "conversations:write"))
|
g.GET("/api/v1/contacts/search", perm(handleSearchContacts, "contacts:read"))
|
||||||
|
|
||||||
// Views.
|
// Views.
|
||||||
g.GET("/api/v1/views/me", perm(handleGetUserViews, "view:manage"))
|
g.GET("/api/v1/views/me", perm(handleGetUserViews, "view:manage"))
|
||||||
@@ -83,7 +84,7 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
|||||||
g.DELETE("/api/v1/statuses/{id}", perm(handleDeleteStatus, "status:manage"))
|
g.DELETE("/api/v1/statuses/{id}", perm(handleDeleteStatus, "status:manage"))
|
||||||
g.GET("/api/v1/priorities", auth(handleGetPriorities))
|
g.GET("/api/v1/priorities", auth(handleGetPriorities))
|
||||||
|
|
||||||
// Tag.
|
// Tags.
|
||||||
g.GET("/api/v1/tags", auth(handleGetTags))
|
g.GET("/api/v1/tags", auth(handleGetTags))
|
||||||
g.POST("/api/v1/tags", perm(handleCreateTag, "tags:manage"))
|
g.POST("/api/v1/tags", perm(handleCreateTag, "tags:manage"))
|
||||||
g.PUT("/api/v1/tags/{id}", perm(handleUpdateTag, "tags:manage"))
|
g.PUT("/api/v1/tags/{id}", perm(handleUpdateTag, "tags:manage"))
|
||||||
@@ -97,22 +98,34 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
|||||||
g.DELETE("/api/v1/macros/{id}", perm(handleDeleteMacro, "macros:manage"))
|
g.DELETE("/api/v1/macros/{id}", perm(handleDeleteMacro, "macros:manage"))
|
||||||
g.POST("/api/v1/conversations/{uuid}/macros/{id}/apply", auth(handleApplyMacro))
|
g.POST("/api/v1/conversations/{uuid}/macros/{id}/apply", auth(handleApplyMacro))
|
||||||
|
|
||||||
// User.
|
// Agents.
|
||||||
g.GET("/api/v1/users/me", auth(handleGetCurrentUser))
|
g.GET("/api/v1/agents/me", auth(handleGetCurrentAgent))
|
||||||
g.PUT("/api/v1/users/me", auth(handleUpdateCurrentUser))
|
g.PUT("/api/v1/agents/me", auth(handleUpdateCurrentAgent))
|
||||||
g.GET("/api/v1/users/me/teams", auth(handleGetCurrentUserTeams))
|
g.GET("/api/v1/agents/me/teams", auth(handleGetCurrentAgentTeams))
|
||||||
g.PUT("/api/v1/users/me/availability", auth(handleUpdateUserAvailability))
|
g.PUT("/api/v1/agents/me/availability", auth(handleUpdateAgentAvailability))
|
||||||
g.DELETE("/api/v1/users/me/avatar", auth(handleDeleteAvatar))
|
g.DELETE("/api/v1/agents/me/avatar", auth(handleDeleteCurrentAgentAvatar))
|
||||||
g.GET("/api/v1/users/compact", auth(handleGetUsersCompact))
|
|
||||||
g.GET("/api/v1/users", perm(handleGetUsers, "users:manage"))
|
|
||||||
g.GET("/api/v1/users/{id}", perm(handleGetUser, "users:manage"))
|
|
||||||
g.POST("/api/v1/users", perm(handleCreateUser, "users:manage"))
|
|
||||||
g.PUT("/api/v1/users/{id}", perm(handleUpdateUser, "users:manage"))
|
|
||||||
g.DELETE("/api/v1/users/{id}", perm(handleDeleteUser, "users:manage"))
|
|
||||||
g.POST("/api/v1/users/reset-password", tryAuth(handleResetPassword))
|
|
||||||
g.POST("/api/v1/users/set-password", tryAuth(handleSetPassword))
|
|
||||||
|
|
||||||
// Team.
|
g.GET("/api/v1/agents/compact", auth(handleGetAgentsCompact))
|
||||||
|
g.GET("/api/v1/agents", perm(handleGetAgents, "users:manage"))
|
||||||
|
g.GET("/api/v1/agents/{id}", perm(handleGetAgent, "users:manage"))
|
||||||
|
g.POST("/api/v1/agents", perm(handleCreateAgent, "users:manage"))
|
||||||
|
g.PUT("/api/v1/agents/{id}", perm(handleUpdateAgent, "users:manage"))
|
||||||
|
g.DELETE("/api/v1/agents/{id}", perm(handleDeleteAgent, "users:manage"))
|
||||||
|
g.POST("/api/v1/agents/reset-password", tryAuth(handleResetPassword))
|
||||||
|
g.POST("/api/v1/agents/set-password", tryAuth(handleSetPassword))
|
||||||
|
|
||||||
|
// Contacts.
|
||||||
|
g.GET("/api/v1/contacts", perm(handleGetContacts, "contacts:read_all"))
|
||||||
|
g.GET("/api/v1/contacts/{id}", perm(handleGetContact, "contacts:read"))
|
||||||
|
g.PUT("/api/v1/contacts/{id}", perm(handleUpdateContact, "contacts:write"))
|
||||||
|
g.PUT("/api/v1/contacts/{id}/block", perm(handleBlockContact, "contacts:block"))
|
||||||
|
|
||||||
|
// Contact notes.
|
||||||
|
g.GET("/api/v1/contacts/{id}/notes", perm(handleGetContactNotes, "contact_notes:read"))
|
||||||
|
g.POST("/api/v1/contacts/{id}/notes", perm(handleCreateContactNote, "contact_notes:write"))
|
||||||
|
g.DELETE("/api/v1/contacts/{id}/notes/{note_id}", perm(handleDeleteContactNote, "contact_notes:delete"))
|
||||||
|
|
||||||
|
// Teams.
|
||||||
g.GET("/api/v1/teams/compact", auth(handleGetTeamsCompact))
|
g.GET("/api/v1/teams/compact", auth(handleGetTeamsCompact))
|
||||||
g.GET("/api/v1/teams", perm(handleGetTeams, "teams:manage"))
|
g.GET("/api/v1/teams", perm(handleGetTeams, "teams:manage"))
|
||||||
g.GET("/api/v1/teams/{id}", perm(handleGetTeam, "teams:manage"))
|
g.GET("/api/v1/teams/{id}", perm(handleGetTeam, "teams:manage"))
|
||||||
@@ -120,20 +133,17 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
|||||||
g.PUT("/api/v1/teams/{id}", perm(handleUpdateTeam, "teams:manage"))
|
g.PUT("/api/v1/teams/{id}", perm(handleUpdateTeam, "teams:manage"))
|
||||||
g.DELETE("/api/v1/teams/{id}", perm(handleDeleteTeam, "teams:manage"))
|
g.DELETE("/api/v1/teams/{id}", perm(handleDeleteTeam, "teams:manage"))
|
||||||
|
|
||||||
// i18n.
|
// Automations.
|
||||||
g.GET("/api/v1/lang/{lang}", handleGetI18nLang)
|
g.GET("/api/v1/automations/rules", perm(handleGetAutomationRules, "automations:manage"))
|
||||||
|
g.GET("/api/v1/automations/rules/{id}", perm(handleGetAutomationRule, "automations:manage"))
|
||||||
|
g.POST("/api/v1/automations/rules", perm(handleCreateAutomationRule, "automations:manage"))
|
||||||
|
g.PUT("/api/v1/automations/rules/{id}/toggle", perm(handleToggleAutomationRule, "automations:manage"))
|
||||||
|
g.PUT("/api/v1/automations/rules/{id}", perm(handleUpdateAutomationRule, "automations:manage"))
|
||||||
|
g.PUT("/api/v1/automations/rules/weights", perm(handleUpdateAutomationRuleWeights, "automations:manage"))
|
||||||
|
g.PUT("/api/v1/automations/rules/execution-mode", perm(handleUpdateAutomationRuleExecutionMode, "automations:manage"))
|
||||||
|
g.DELETE("/api/v1/automations/rules/{id}", perm(handleDeleteAutomationRule, "automations:manage"))
|
||||||
|
|
||||||
// Automation.
|
// Inboxes.
|
||||||
g.GET("/api/v1/automation/rules", perm(handleGetAutomationRules, "automations:manage"))
|
|
||||||
g.GET("/api/v1/automation/rules/{id}", perm(handleGetAutomationRule, "automations:manage"))
|
|
||||||
g.POST("/api/v1/automation/rules", perm(handleCreateAutomationRule, "automations:manage"))
|
|
||||||
g.PUT("/api/v1/automation/rules/{id}/toggle", perm(handleToggleAutomationRule, "automations:manage"))
|
|
||||||
g.PUT("/api/v1/automation/rules/{id}", perm(handleUpdateAutomationRule, "automations:manage"))
|
|
||||||
g.PUT("/api/v1/automation/rules/weights", perm(handleUpdateAutomationRuleWeights, "automations:manage"))
|
|
||||||
g.PUT("/api/v1/automation/rules/execution-mode", perm(handleUpdateAutomationRuleExecutionMode, "automations:manage"))
|
|
||||||
g.DELETE("/api/v1/automation/rules/{id}", perm(handleDeleteAutomationRule, "automations:manage"))
|
|
||||||
|
|
||||||
// Inbox.
|
|
||||||
g.GET("/api/v1/inboxes", auth(handleGetInboxes))
|
g.GET("/api/v1/inboxes", auth(handleGetInboxes))
|
||||||
g.GET("/api/v1/inboxes/{id}", perm(handleGetInbox, "inboxes:manage"))
|
g.GET("/api/v1/inboxes/{id}", perm(handleGetInbox, "inboxes:manage"))
|
||||||
g.POST("/api/v1/inboxes", perm(handleCreateInbox, "inboxes:manage"))
|
g.POST("/api/v1/inboxes", perm(handleCreateInbox, "inboxes:manage"))
|
||||||
@@ -141,18 +151,18 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
|||||||
g.PUT("/api/v1/inboxes/{id}", perm(handleUpdateInbox, "inboxes:manage"))
|
g.PUT("/api/v1/inboxes/{id}", perm(handleUpdateInbox, "inboxes:manage"))
|
||||||
g.DELETE("/api/v1/inboxes/{id}", perm(handleDeleteInbox, "inboxes:manage"))
|
g.DELETE("/api/v1/inboxes/{id}", perm(handleDeleteInbox, "inboxes:manage"))
|
||||||
|
|
||||||
// Role.
|
// Roles.
|
||||||
g.GET("/api/v1/roles", perm(handleGetRoles, "roles:manage"))
|
g.GET("/api/v1/roles", perm(handleGetRoles, "roles:manage"))
|
||||||
g.GET("/api/v1/roles/{id}", perm(handleGetRole, "roles:manage"))
|
g.GET("/api/v1/roles/{id}", perm(handleGetRole, "roles:manage"))
|
||||||
g.POST("/api/v1/roles", perm(handleCreateRole, "roles:manage"))
|
g.POST("/api/v1/roles", perm(handleCreateRole, "roles:manage"))
|
||||||
g.PUT("/api/v1/roles/{id}", perm(handleUpdateRole, "roles:manage"))
|
g.PUT("/api/v1/roles/{id}", perm(handleUpdateRole, "roles:manage"))
|
||||||
g.DELETE("/api/v1/roles/{id}", perm(handleDeleteRole, "roles:manage"))
|
g.DELETE("/api/v1/roles/{id}", perm(handleDeleteRole, "roles:manage"))
|
||||||
|
|
||||||
// Dashboard.
|
// Reports.
|
||||||
g.GET("/api/v1/reports/overview/counts", perm(handleDashboardCounts, "reports:manage"))
|
g.GET("/api/v1/reports/overview/counts", perm(handleDashboardCounts, "reports:manage"))
|
||||||
g.GET("/api/v1/reports/overview/charts", perm(handleDashboardCharts, "reports:manage"))
|
g.GET("/api/v1/reports/overview/charts", perm(handleDashboardCharts, "reports:manage"))
|
||||||
|
|
||||||
// Template.
|
// Templates.
|
||||||
g.GET("/api/v1/templates", perm(handleGetTemplates, "templates:manage"))
|
g.GET("/api/v1/templates", perm(handleGetTemplates, "templates:manage"))
|
||||||
g.GET("/api/v1/templates/{id}", perm(handleGetTemplate, "templates:manage"))
|
g.GET("/api/v1/templates/{id}", perm(handleGetTemplate, "templates:manage"))
|
||||||
g.POST("/api/v1/templates", perm(handleCreateTemplate, "templates:manage"))
|
g.POST("/api/v1/templates", perm(handleCreateTemplate, "templates:manage"))
|
||||||
@@ -160,24 +170,34 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
|||||||
g.DELETE("/api/v1/templates/{id}", perm(handleDeleteTemplate, "templates:manage"))
|
g.DELETE("/api/v1/templates/{id}", perm(handleDeleteTemplate, "templates:manage"))
|
||||||
|
|
||||||
// Business hours.
|
// Business hours.
|
||||||
g.GET("/api/v1/business-hours", perm(handleGetBusinessHours, "business_hours:manage"))
|
g.GET("/api/v1/business-hours", auth(handleGetBusinessHours))
|
||||||
g.GET("/api/v1/business-hours/{id}", perm(handleGetBusinessHour, "business_hours:manage"))
|
g.GET("/api/v1/business-hours/{id}", perm(handleGetBusinessHour, "business_hours:manage"))
|
||||||
g.POST("/api/v1/business-hours", perm(handleCreateBusinessHours, "business_hours:manage"))
|
g.POST("/api/v1/business-hours", perm(handleCreateBusinessHours, "business_hours:manage"))
|
||||||
g.PUT("/api/v1/business-hours/{id}", perm(handleUpdateBusinessHours, "business_hours:manage"))
|
g.PUT("/api/v1/business-hours/{id}", perm(handleUpdateBusinessHours, "business_hours:manage"))
|
||||||
g.DELETE("/api/v1/business-hours/{id}", perm(handleDeleteBusinessHour, "business_hours:manage"))
|
g.DELETE("/api/v1/business-hours/{id}", perm(handleDeleteBusinessHour, "business_hours:manage"))
|
||||||
|
|
||||||
// SLA.
|
// SLAs.
|
||||||
g.GET("/api/v1/sla", perm(handleGetSLAs, "sla:manage"))
|
g.GET("/api/v1/sla", perm(handleGetSLAs, "sla:manage"))
|
||||||
g.GET("/api/v1/sla/{id}", perm(handleGetSLA, "sla:manage"))
|
g.GET("/api/v1/sla/{id}", perm(handleGetSLA, "sla:manage"))
|
||||||
g.POST("/api/v1/sla", perm(fastglue.ReqLenRangeParams(handleCreateSLA, slaReqFields), "sla:manage"))
|
g.POST("/api/v1/sla", perm(handleCreateSLA, "sla:manage"))
|
||||||
g.PUT("/api/v1/sla/{id}", perm(fastglue.ReqLenRangeParams(handleUpdateSLA, slaReqFields), "sla:manage"))
|
g.PUT("/api/v1/sla/{id}", perm(handleUpdateSLA, "sla:manage"))
|
||||||
g.DELETE("/api/v1/sla/{id}", perm(handleDeleteSLA, "sla:manage"))
|
g.DELETE("/api/v1/sla/{id}", perm(handleDeleteSLA, "sla:manage"))
|
||||||
|
|
||||||
// AI completion.
|
// AI completions.
|
||||||
g.GET("/api/v1/ai/prompts", auth(handleGetAIPrompts))
|
g.GET("/api/v1/ai/prompts", auth(handleGetAIPrompts))
|
||||||
g.POST("/api/v1/ai/completion", auth(handleAICompletion))
|
g.POST("/api/v1/ai/completion", auth(handleAICompletion))
|
||||||
g.PUT("/api/v1/ai/provider", perm(handleUpdateAIProvider, "ai:manage"))
|
g.PUT("/api/v1/ai/provider", perm(handleUpdateAIProvider, "ai:manage"))
|
||||||
|
|
||||||
|
// Custom attributes.
|
||||||
|
g.GET("/api/v1/custom-attributes", auth(handleGetCustomAttributes))
|
||||||
|
g.POST("/api/v1/custom-attributes", perm(handleCreateCustomAttribute, "custom_attributes:manage"))
|
||||||
|
g.GET("/api/v1/custom-attributes/{id}", perm(handleGetCustomAttribute, "custom_attributes:manage"))
|
||||||
|
g.PUT("/api/v1/custom-attributes/{id}", perm(handleUpdateCustomAttribute, "custom_attributes:manage"))
|
||||||
|
g.DELETE("/api/v1/custom-attributes/{id}", perm(handleDeleteCustomAttribute, "custom_attributes:manage"))
|
||||||
|
|
||||||
|
// Actvity logs.
|
||||||
|
g.GET("/api/v1/activity-logs", perm(handleGetActivityLogs, "activity_logs:manage"))
|
||||||
|
|
||||||
// WebSocket.
|
// WebSocket.
|
||||||
g.GET("/ws", auth(func(r *fastglue.Request) error {
|
g.GET("/ws", auth(func(r *fastglue.Request) error {
|
||||||
return handleWS(r, hub)
|
return handleWS(r, hub)
|
||||||
@@ -189,6 +209,7 @@ func initHandlers(g *fastglue.Fastglue, hub *ws.Hub) {
|
|||||||
g.GET("/teams/{all:*}", authPage(serveIndexPage))
|
g.GET("/teams/{all:*}", authPage(serveIndexPage))
|
||||||
g.GET("/views/{all:*}", authPage(serveIndexPage))
|
g.GET("/views/{all:*}", authPage(serveIndexPage))
|
||||||
g.GET("/admin/{all:*}", authPage(serveIndexPage))
|
g.GET("/admin/{all:*}", authPage(serveIndexPage))
|
||||||
|
g.GET("/contacts/{all:*}", authPage(serveIndexPage))
|
||||||
g.GET("/reports/{all:*}", authPage(serveIndexPage))
|
g.GET("/reports/{all:*}", authPage(serveIndexPage))
|
||||||
g.GET("/account/{all:*}", authPage(serveIndexPage))
|
g.GET("/account/{all:*}", authPage(serveIndexPage))
|
||||||
g.GET("/reset-password", notAuthPage(serveIndexPage))
|
g.GET("/reset-password", notAuthPage(serveIndexPage))
|
||||||
@@ -218,7 +239,7 @@ func serveIndexPage(r *fastglue.Request) error {
|
|||||||
// Serve the index.html file from the embedded filesystem.
|
// Serve the index.html file from the embedded filesystem.
|
||||||
file, err := app.fs.Get(path.Join(frontendDir, "index.html"))
|
file, err := app.fs.Get(path.Join(frontendDir, "index.html"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(http.StatusNotFound, "Page not found", nil, envelope.NotFoundError)
|
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.file}"), nil, envelope.NotFoundError)
|
||||||
}
|
}
|
||||||
r.RequestCtx.Response.Header.Set("Content-Type", "text/html")
|
r.RequestCtx.Response.Header.Set("Content-Type", "text/html")
|
||||||
r.RequestCtx.SetBody(file.ReadBytes())
|
r.RequestCtx.SetBody(file.ReadBytes())
|
||||||
@@ -226,7 +247,7 @@ func serveIndexPage(r *fastglue.Request) error {
|
|||||||
// Set CSRF cookie if not already set.
|
// Set CSRF cookie if not already set.
|
||||||
if err := app.auth.SetCSRFCookie(r); err != nil {
|
if err := app.auth.SetCSRFCookie(r); err != nil {
|
||||||
app.lo.Error("error setting csrf cookie", "error", err)
|
app.lo.Error("error setting csrf cookie", "error", err)
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.T("user.errorAcquiringSession"), nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorSaving", "name", "{globals.terms.session}"), nil))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -240,7 +261,7 @@ func serveStaticFiles(r *fastglue.Request) error {
|
|||||||
|
|
||||||
file, err := app.fs.Get(filePath)
|
file, err := app.fs.Get(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(http.StatusNotFound, "File not found", nil, envelope.NotFoundError)
|
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.file}"), nil, envelope.NotFoundError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the appropriate Content-Type based on the file extension.
|
// Set the appropriate Content-Type based on the file extension.
|
||||||
@@ -265,7 +286,7 @@ func serveFrontendStaticFiles(r *fastglue.Request) error {
|
|||||||
finalPath := filepath.Join(frontendDir, filePath)
|
finalPath := filepath.Join(frontendDir, filePath)
|
||||||
file, err := app.fs.Get(finalPath)
|
file, err := app.fs.Get(finalPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(http.StatusNotFound, "File not found", nil, envelope.NotFoundError)
|
return r.SendErrorEnvelope(http.StatusNotFound, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.file}"), nil, envelope.NotFoundError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the appropriate Content-Type based on the file extension.
|
// Set the appropriate Content-Type based on the file extension.
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ func handleGetI18nLang(r *fastglue.Request) error {
|
|||||||
return r.SendBytes(http.StatusOK, "application/json", i.JSON())
|
return r.SendBytes(http.StatusOK, "application/json", i.JSON())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// loadI18nLang loads the i18n language pack for the given language code.
|
||||||
func loadI18nLang(lang string, fs stuffbin.FileSystem) (*i18n.I18n, error) {
|
func loadI18nLang(lang string, fs stuffbin.FileSystem) (*i18n.I18n, error) {
|
||||||
// Helper function to read and initialize i18n language.
|
// Helper function to read and initialize i18n language.
|
||||||
readLang := func(lang string) ([]byte, error) {
|
readLang := func(lang string) ([]byte, error) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/mail"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/abhinavxd/libredesk/internal/envelope"
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
@@ -9,6 +10,7 @@ import (
|
|||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// handleGetInboxes returns all inboxes
|
||||||
func handleGetInboxes(r *fastglue.Request) error {
|
func handleGetInboxes(r *fastglue.Request) error {
|
||||||
var app = r.Context.(*App)
|
var app = r.Context.(*App)
|
||||||
inboxes, err := app.inbox.GetAll()
|
inboxes, err := app.inbox.GetAll()
|
||||||
@@ -18,6 +20,7 @@ func handleGetInboxes(r *fastglue.Request) error {
|
|||||||
return r.SendEnvelope(inboxes)
|
return r.SendEnvelope(inboxes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleGetInbox returns an inbox by ID
|
||||||
func handleGetInbox(r *fastglue.Request) error {
|
func handleGetInbox(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
@@ -25,30 +28,35 @@ func handleGetInbox(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
inbox, err := app.inbox.GetDBRecord(id)
|
inbox, err := app.inbox.GetDBRecord(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error fetching inbox", nil, envelope.GeneralError)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
if err := inbox.ClearPasswords(); err != nil {
|
if err := inbox.ClearPasswords(); err != nil {
|
||||||
app.lo.Error("error clearing out passwords", "error", err)
|
app.lo.Error("error clearing inbox passwords from response", "error", err)
|
||||||
return envelope.NewError(envelope.GeneralError, "Error fetching inbox", nil)
|
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.inbox}"), nil)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(inbox)
|
return r.SendEnvelope(inbox)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleCreateInbox creates a new inbox
|
||||||
func handleCreateInbox(r *fastglue.Request) error {
|
func handleCreateInbox(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
inb = imodels.Inbox{}
|
inbox = imodels.Inbox{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&inb, "json"); err != nil {
|
if err := r.Decode(&inbox, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
err := app.inbox.Create(inb)
|
|
||||||
if err != nil {
|
if err := app.inbox.Create(inbox); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validateInbox(app, inbox); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := reloadInboxes(app); err != nil {
|
if err := reloadInboxes(app); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error reloading inboxes", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
@@ -63,24 +71,30 @@ func handleUpdateInbox(r *fastglue.Request) error {
|
|||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
||||||
"Invalid inbox `id`.", nil, envelope.InputError)
|
app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&inbox, "json"); err != nil {
|
if err := r.Decode(&inbox, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := validateInbox(app, inbox); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
err = app.inbox.Update(id, inbox)
|
err = app.inbox.Update(id, inbox)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Could not update inbox.", nil, envelope.GeneralError)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := reloadInboxes(app); err != nil {
|
if err := reloadInboxes(app); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error reloading inboxes, Please restart the app if the issue persists", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(inbox)
|
return r.SendEnvelope(inbox)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleToggleInbox toggles an inbox
|
||||||
func handleToggleInbox(r *fastglue.Request) error {
|
func handleToggleInbox(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
@@ -88,7 +102,7 @@ func handleToggleInbox(r *fastglue.Request) error {
|
|||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
||||||
"Invalid inbox `id`.", nil, envelope.InputError)
|
app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.inbox.Toggle(id); err != nil {
|
if err = app.inbox.Toggle(id); err != nil {
|
||||||
@@ -96,12 +110,13 @@ func handleToggleInbox(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := reloadInboxes(app); err != nil {
|
if err := reloadInboxes(app); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error reloading inboxes", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleDeleteInbox deletes an inbox
|
||||||
func handleDeleteInbox(r *fastglue.Request) error {
|
func handleDeleteInbox(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
@@ -109,12 +124,28 @@ func handleDeleteInbox(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
err := app.inbox.SoftDelete(id)
|
err := app.inbox.SoftDelete(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Could not update inbox.", nil, envelope.GeneralError)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := reloadInboxes(app); err != nil {
|
if err := reloadInboxes(app); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error reloading inboxes", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "{globals.terms.inbox}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validateInbox validates the inbox
|
||||||
|
func validateInbox(app *App, inbox imodels.Inbox) error {
|
||||||
|
// Validate from address.
|
||||||
|
if _, err := mail.ParseAddress(inbox.From); err != nil {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalidFromAddress"), nil)
|
||||||
|
}
|
||||||
|
if len(inbox.Config) == 0 {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "config"), nil)
|
||||||
|
}
|
||||||
|
if inbox.Name == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "name"), nil)
|
||||||
|
}
|
||||||
|
if inbox.Channel == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "channel"), nil)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
114
cmd/init.go
114
cmd/init.go
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"html/template"
|
"html/template"
|
||||||
|
|
||||||
|
activitylog "github.com/abhinavxd/libredesk/internal/activity_log"
|
||||||
"github.com/abhinavxd/libredesk/internal/ai"
|
"github.com/abhinavxd/libredesk/internal/ai"
|
||||||
auth_ "github.com/abhinavxd/libredesk/internal/auth"
|
auth_ "github.com/abhinavxd/libredesk/internal/auth"
|
||||||
"github.com/abhinavxd/libredesk/internal/authz"
|
"github.com/abhinavxd/libredesk/internal/authz"
|
||||||
@@ -23,6 +24,7 @@ import (
|
|||||||
"github.com/abhinavxd/libredesk/internal/conversation/priority"
|
"github.com/abhinavxd/libredesk/internal/conversation/priority"
|
||||||
"github.com/abhinavxd/libredesk/internal/conversation/status"
|
"github.com/abhinavxd/libredesk/internal/conversation/status"
|
||||||
"github.com/abhinavxd/libredesk/internal/csat"
|
"github.com/abhinavxd/libredesk/internal/csat"
|
||||||
|
customAttribute "github.com/abhinavxd/libredesk/internal/custom_attribute"
|
||||||
"github.com/abhinavxd/libredesk/internal/inbox"
|
"github.com/abhinavxd/libredesk/internal/inbox"
|
||||||
"github.com/abhinavxd/libredesk/internal/inbox/channel/email"
|
"github.com/abhinavxd/libredesk/internal/inbox/channel/email"
|
||||||
imodels "github.com/abhinavxd/libredesk/internal/inbox/models"
|
imodels "github.com/abhinavxd/libredesk/internal/inbox/models"
|
||||||
@@ -231,11 +233,12 @@ func initConversations(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initTag inits tag manager.
|
// initTag inits tag manager.
|
||||||
func initTag(db *sqlx.DB) *tag.Manager {
|
func initTag(db *sqlx.DB, i18n *i18n.I18n) *tag.Manager {
|
||||||
var lo = initLogger("tag_manager")
|
var lo = initLogger("tag_manager")
|
||||||
mgr, err := tag.New(tag.Opts{
|
mgr, err := tag.New(tag.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing tags: %v", err)
|
log.Fatalf("error initializing tags: %v", err)
|
||||||
@@ -257,11 +260,12 @@ func initView(db *sqlx.DB) *view.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initMacro inits macro manager.
|
// initMacro inits macro manager.
|
||||||
func initMacro(db *sqlx.DB) *macro.Manager {
|
func initMacro(db *sqlx.DB, i18n *i18n.I18n) *macro.Manager {
|
||||||
var lo = initLogger("macro")
|
var lo = initLogger("macro")
|
||||||
m, err := macro.New(macro.Opts{
|
m, err := macro.New(macro.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing macro manager: %v", err)
|
log.Fatalf("error initializing macro manager: %v", err)
|
||||||
@@ -270,11 +274,12 @@ func initMacro(db *sqlx.DB) *macro.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initBusinessHours inits business hours manager.
|
// initBusinessHours inits business hours manager.
|
||||||
func initBusinessHours(db *sqlx.DB) *businesshours.Manager {
|
func initBusinessHours(db *sqlx.DB, i18n *i18n.I18n) *businesshours.Manager {
|
||||||
var lo = initLogger("business-hours")
|
var lo = initLogger("business-hours")
|
||||||
m, err := businesshours.New(businesshours.Opts{
|
m, err := businesshours.New(businesshours.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing business hours manager: %v", err)
|
log.Fatalf("error initializing business hours manager: %v", err)
|
||||||
@@ -283,12 +288,13 @@ func initBusinessHours(db *sqlx.DB) *businesshours.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initSLA inits SLA manager.
|
// initSLA inits SLA manager.
|
||||||
func initSLA(db *sqlx.DB, teamManager *team.Manager, settings *setting.Manager, businessHours *businesshours.Manager) *sla.Manager {
|
func initSLA(db *sqlx.DB, teamManager *team.Manager, settings *setting.Manager, businessHours *businesshours.Manager, notifier *notifier.Service, template *tmpl.Manager, userManager *user.Manager, i18n *i18n.I18n) *sla.Manager {
|
||||||
var lo = initLogger("sla")
|
var lo = initLogger("sla")
|
||||||
m, err := sla.New(sla.Opts{
|
m, err := sla.New(sla.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
}, teamManager, settings, businessHours)
|
I18n: i18n,
|
||||||
|
}, teamManager, settings, businessHours, notifier, template, userManager)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing SLA manager: %v", err)
|
log.Fatalf("error initializing SLA manager: %v", err)
|
||||||
}
|
}
|
||||||
@@ -296,11 +302,12 @@ func initSLA(db *sqlx.DB, teamManager *team.Manager, settings *setting.Manager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initCSAT inits CSAT manager.
|
// initCSAT inits CSAT manager.
|
||||||
func initCSAT(db *sqlx.DB) *csat.Manager {
|
func initCSAT(db *sqlx.DB, i18n *i18n.I18n) *csat.Manager {
|
||||||
var lo = initLogger("csat")
|
var lo = initLogger("csat")
|
||||||
m, err := csat.New(csat.Opts{
|
m, err := csat.New(csat.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing CSAT manager: %v", err)
|
log.Fatalf("error initializing CSAT manager: %v", err)
|
||||||
@@ -314,7 +321,7 @@ func initWS(user *user.Manager) *ws.Hub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initTemplates inits template manager.
|
// initTemplates inits template manager.
|
||||||
func initTemplate(db *sqlx.DB, fs stuffbin.FileSystem, consts *constants) *tmpl.Manager {
|
func initTemplate(db *sqlx.DB, fs stuffbin.FileSystem, consts *constants, i18n *i18n.I18n) *tmpl.Manager {
|
||||||
var (
|
var (
|
||||||
lo = initLogger("template")
|
lo = initLogger("template")
|
||||||
funcMap = getTmplFuncs(consts)
|
funcMap = getTmplFuncs(consts)
|
||||||
@@ -327,7 +334,7 @@ func initTemplate(db *sqlx.DB, fs stuffbin.FileSystem, consts *constants) *tmpl.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error parsing web templates: %v", err)
|
log.Fatalf("error parsing web templates: %v", err)
|
||||||
}
|
}
|
||||||
m, err := tmpl.New(lo, db, webTpls, tpls, funcMap)
|
m, err := tmpl.New(lo, db, webTpls, tpls, funcMap, i18n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing template manager: %v", err)
|
log.Fatalf("error initializing template manager: %v", err)
|
||||||
}
|
}
|
||||||
@@ -398,11 +405,12 @@ func reloadTemplates(app *App) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initTeam inits team manager.
|
// initTeam inits team manager.
|
||||||
func initTeam(db *sqlx.DB) *team.Manager {
|
func initTeam(db *sqlx.DB, i18n *i18n.I18n) *team.Manager {
|
||||||
var lo = initLogger("team-manager")
|
var lo = initLogger("team-manager")
|
||||||
mgr, err := team.New(team.Opts{
|
mgr, err := team.New(team.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing team manager: %v", err)
|
log.Fatalf("error initializing team manager: %v", err)
|
||||||
@@ -411,7 +419,7 @@ func initTeam(db *sqlx.DB) *team.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initMedia inits media manager.
|
// initMedia inits media manager.
|
||||||
func initMedia(db *sqlx.DB) *media.Manager {
|
func initMedia(db *sqlx.DB, i18n *i18n.I18n) *media.Manager {
|
||||||
var (
|
var (
|
||||||
store media.Store
|
store media.Store
|
||||||
err error
|
err error
|
||||||
@@ -452,6 +460,7 @@ func initMedia(db *sqlx.DB) *media.Manager {
|
|||||||
Store: store,
|
Store: store,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
DB: db,
|
DB: db,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing media: %v", err)
|
log.Fatalf("error initializing media: %v", err)
|
||||||
@@ -460,9 +469,9 @@ func initMedia(db *sqlx.DB) *media.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initInbox initializes the inbox manager without registering inboxes.
|
// initInbox initializes the inbox manager without registering inboxes.
|
||||||
func initInbox(db *sqlx.DB) *inbox.Manager {
|
func initInbox(db *sqlx.DB, i18n *i18n.I18n) *inbox.Manager {
|
||||||
var lo = initLogger("inbox-manager")
|
var lo = initLogger("inbox-manager")
|
||||||
mgr, err := inbox.New(lo, db)
|
mgr, err := inbox.New(lo, db, i18n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing inbox manager: %v", err)
|
log.Fatalf("error initializing inbox manager: %v", err)
|
||||||
}
|
}
|
||||||
@@ -470,11 +479,12 @@ func initInbox(db *sqlx.DB) *inbox.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initAutomationEngine initializes the automation engine.
|
// initAutomationEngine initializes the automation engine.
|
||||||
func initAutomationEngine(db *sqlx.DB) *automation.Engine {
|
func initAutomationEngine(db *sqlx.DB, i18n *i18n.I18n) *automation.Engine {
|
||||||
var lo = initLogger("automation_engine")
|
var lo = initLogger("automation_engine")
|
||||||
engine, err := automation.New(automation.Opts{
|
engine, err := automation.New(automation.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing automation engine: %v", err)
|
log.Fatalf("error initializing automation engine: %v", err)
|
||||||
@@ -496,13 +506,13 @@ func initAutoAssigner(teamManager *team.Manager, userManager *user.Manager, conv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initNotifier initializes the notifier service with available providers.
|
// initNotifier initializes the notifier service with available providers.
|
||||||
func initNotifier(userStore notifier.UserStore) *notifier.Service {
|
func initNotifier() *notifier.Service {
|
||||||
smtpCfg := email.SMTPConfig{}
|
smtpCfg := email.SMTPConfig{}
|
||||||
if err := ko.UnmarshalWithConf("notification.email", &smtpCfg, koanf.UnmarshalConf{Tag: "json"}); err != nil {
|
if err := ko.UnmarshalWithConf("notification.email", &smtpCfg, koanf.UnmarshalConf{Tag: "json"}); err != nil {
|
||||||
log.Fatalf("error unmarshalling email notification provider config: %v", err)
|
log.Fatalf("error unmarshalling email notification provider config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
emailNotifier, err := emailnotifier.New([]email.SMTPConfig{smtpCfg}, userStore, emailnotifier.Opts{
|
emailNotifier, err := emailnotifier.New([]email.SMTPConfig{smtpCfg}, emailnotifier.Opts{
|
||||||
Lo: initLogger("email-notifier"),
|
Lo: initLogger("email-notifier"),
|
||||||
FromEmail: ko.String("notification.email.email_address"),
|
FromEmail: ko.String("notification.email.email_address"),
|
||||||
})
|
})
|
||||||
@@ -518,7 +528,7 @@ func initNotifier(userStore notifier.UserStore) *notifier.Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initEmailInbox initializes the email inbox.
|
// initEmailInbox initializes the email inbox.
|
||||||
func initEmailInbox(inboxRecord imodels.Inbox, store inbox.MessageStore) (inbox.Inbox, error) {
|
func initEmailInbox(inboxRecord imodels.Inbox, msgStore inbox.MessageStore, usrStore inbox.UserStore) (inbox.Inbox, error) {
|
||||||
var config email.Config
|
var config email.Config
|
||||||
|
|
||||||
// Load JSON data into Koanf.
|
// Load JSON data into Koanf.
|
||||||
@@ -544,7 +554,7 @@ func initEmailInbox(inboxRecord imodels.Inbox, store inbox.MessageStore) (inbox.
|
|||||||
log.Printf("WARNING: No `from` email address set for `%s` inbox: Name: `%s`", inboxRecord.Channel, inboxRecord.Name)
|
log.Printf("WARNING: No `from` email address set for `%s` inbox: Name: `%s`", inboxRecord.Channel, inboxRecord.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
inbox, err := email.New(store, email.Opts{
|
inbox, err := email.New(msgStore, usrStore, email.Opts{
|
||||||
ID: inboxRecord.ID,
|
ID: inboxRecord.ID,
|
||||||
Config: config,
|
Config: config,
|
||||||
Lo: initLogger("email_inbox"),
|
Lo: initLogger("email_inbox"),
|
||||||
@@ -560,10 +570,10 @@ func initEmailInbox(inboxRecord imodels.Inbox, store inbox.MessageStore) (inbox.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initializeInboxes handles inbox initialization.
|
// initializeInboxes handles inbox initialization.
|
||||||
func initializeInboxes(inboxR imodels.Inbox, store inbox.MessageStore) (inbox.Inbox, error) {
|
func initializeInboxes(inboxR imodels.Inbox, msgStore inbox.MessageStore, usrStore inbox.UserStore) (inbox.Inbox, error) {
|
||||||
switch inboxR.Channel {
|
switch inboxR.Channel {
|
||||||
case "email":
|
case "email":
|
||||||
return initEmailInbox(inboxR, store)
|
return initEmailInbox(inboxR, msgStore, usrStore)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown inbox channel: %s", inboxR.Channel)
|
return nil, fmt.Errorf("unknown inbox channel: %s", inboxR.Channel)
|
||||||
}
|
}
|
||||||
@@ -576,8 +586,9 @@ func reloadInboxes(app *App) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// startInboxes registers the active inboxes and starts receiver for each.
|
// startInboxes registers the active inboxes and starts receiver for each.
|
||||||
func startInboxes(ctx context.Context, mgr *inbox.Manager, store inbox.MessageStore) {
|
func startInboxes(ctx context.Context, mgr *inbox.Manager, msgStore inbox.MessageStore, usrStore inbox.UserStore) {
|
||||||
mgr.SetMessageStore(store)
|
mgr.SetMessageStore(msgStore)
|
||||||
|
mgr.SetUserStore(usrStore)
|
||||||
|
|
||||||
if err := mgr.InitInboxes(initializeInboxes); err != nil {
|
if err := mgr.InitInboxes(initializeInboxes); err != nil {
|
||||||
log.Fatalf("error initializing inboxes: %v", err)
|
log.Fatalf("error initializing inboxes: %v", err)
|
||||||
@@ -589,8 +600,8 @@ func startInboxes(ctx context.Context, mgr *inbox.Manager, store inbox.MessageSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initAuthz initializes authorization enforcer.
|
// initAuthz initializes authorization enforcer.
|
||||||
func initAuthz() *authz.Enforcer {
|
func initAuthz(i18n *i18n.I18n) *authz.Enforcer {
|
||||||
enforcer, err := authz.NewEnforcer(initLogger("authz"))
|
enforcer, err := authz.NewEnforcer(initLogger("authz"), i18n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing authz: %v", err)
|
log.Fatalf("error initializing authz: %v", err)
|
||||||
}
|
}
|
||||||
@@ -598,7 +609,7 @@ func initAuthz() *authz.Enforcer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initAuth initializes the authentication manager.
|
// initAuth initializes the authentication manager.
|
||||||
func initAuth(o *oidc.Manager, rd *redis.Client) *auth_.Auth {
|
func initAuth(o *oidc.Manager, rd *redis.Client, i18n *i18n.I18n) *auth_.Auth {
|
||||||
lo := initLogger("auth")
|
lo := initLogger("auth")
|
||||||
|
|
||||||
providers, err := buildProviders(o)
|
providers, err := buildProviders(o)
|
||||||
@@ -606,7 +617,8 @@ func initAuth(o *oidc.Manager, rd *redis.Client) *auth_.Auth {
|
|||||||
log.Fatalf("error initializing auth: %v", err)
|
log.Fatalf("error initializing auth: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
auth, err := auth_.New(auth_.Config{Providers: providers}, rd, lo)
|
secure := !ko.Bool("app.server.disable_secure_cookies")
|
||||||
|
auth, err := auth_.New(auth_.Config{Providers: providers, SecureCookies: secure}, i18n, rd, lo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing auth: %v", err)
|
log.Fatalf("error initializing auth: %v", err)
|
||||||
}
|
}
|
||||||
@@ -653,11 +665,12 @@ func buildProviders(o *oidc.Manager) ([]auth_.Provider, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initOIDC initializes open id connect config manager.
|
// initOIDC initializes open id connect config manager.
|
||||||
func initOIDC(db *sqlx.DB, settings *setting.Manager) *oidc.Manager {
|
func initOIDC(db *sqlx.DB, settings *setting.Manager, i18n *i18n.I18n) *oidc.Manager {
|
||||||
lo := initLogger("oidc")
|
lo := initLogger("oidc")
|
||||||
o, err := oidc.New(oidc.Opts{
|
o, err := oidc.New(oidc.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
}, settings)
|
}, settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing oidc: %v", err)
|
log.Fatalf("error initializing oidc: %v", err)
|
||||||
@@ -667,9 +680,11 @@ func initOIDC(db *sqlx.DB, settings *setting.Manager) *oidc.Manager {
|
|||||||
|
|
||||||
// initI18n inits i18n.
|
// initI18n inits i18n.
|
||||||
func initI18n(fs stuffbin.FileSystem) *i18n.I18n {
|
func initI18n(fs stuffbin.FileSystem) *i18n.I18n {
|
||||||
file, err := fs.Get("i18n/" + cmp.Or(ko.String("app.lang"), defLang) + ".json")
|
fileName := cmp.Or(ko.String("app.lang"), defLang)
|
||||||
|
log.Printf("loading i18n language file: %s", fileName)
|
||||||
|
file, err := fs.Get("i18n/" + fileName + ".json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error reading i18n language file")
|
log.Fatalf("error reading i18n language file `%s` : %v", fileName, err)
|
||||||
}
|
}
|
||||||
i18n, err := i18n.New(file.ReadBytes())
|
i18n, err := i18n.New(file.ReadBytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -713,11 +728,12 @@ func initDB() *sqlx.DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initRedis inits role manager.
|
// initRedis inits role manager.
|
||||||
func initRole(db *sqlx.DB) *role.Manager {
|
func initRole(db *sqlx.DB, i18n *i18n.I18n) *role.Manager {
|
||||||
var lo = initLogger("role_manager")
|
var lo = initLogger("role_manager")
|
||||||
r, err := role.New(role.Opts{
|
r, err := role.New(role.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing role manager: %v", err)
|
log.Fatalf("error initializing role manager: %v", err)
|
||||||
@@ -726,10 +742,11 @@ func initRole(db *sqlx.DB) *role.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initStatus inits conversation status manager.
|
// initStatus inits conversation status manager.
|
||||||
func initStatus(db *sqlx.DB) *status.Manager {
|
func initStatus(db *sqlx.DB, i18n *i18n.I18n) *status.Manager {
|
||||||
manager, err := status.New(status.Opts{
|
manager, err := status.New(status.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: initLogger("status-manager"),
|
Lo: initLogger("status-manager"),
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing status manager: %v", err)
|
log.Fatalf("error initializing status manager: %v", err)
|
||||||
@@ -738,10 +755,11 @@ func initStatus(db *sqlx.DB) *status.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initPriority inits conversation priority manager.
|
// initPriority inits conversation priority manager.
|
||||||
func initPriority(db *sqlx.DB) *priority.Manager {
|
func initPriority(db *sqlx.DB, i18n *i18n.I18n) *priority.Manager {
|
||||||
manager, err := priority.New(priority.Opts{
|
manager, err := priority.New(priority.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: initLogger("priority-manager"),
|
Lo: initLogger("priority-manager"),
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing priority manager: %v", err)
|
log.Fatalf("error initializing priority manager: %v", err)
|
||||||
@@ -750,11 +768,12 @@ func initPriority(db *sqlx.DB) *priority.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initAI inits AI manager.
|
// initAI inits AI manager.
|
||||||
func initAI(db *sqlx.DB) *ai.Manager {
|
func initAI(db *sqlx.DB, i18n *i18n.I18n) *ai.Manager {
|
||||||
lo := initLogger("ai")
|
lo := initLogger("ai")
|
||||||
m, err := ai.New(ai.Opts{
|
m, err := ai.New(ai.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing AI manager: %v", err)
|
log.Fatalf("error initializing AI manager: %v", err)
|
||||||
@@ -763,11 +782,12 @@ func initAI(db *sqlx.DB) *ai.Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initSearch inits search manager.
|
// initSearch inits search manager.
|
||||||
func initSearch(db *sqlx.DB) *search.Manager {
|
func initSearch(db *sqlx.DB, i18n *i18n.I18n) *search.Manager {
|
||||||
lo := initLogger("search")
|
lo := initLogger("search")
|
||||||
m, err := search.New(search.Opts{
|
m, err := search.New(search.Opts{
|
||||||
DB: db,
|
DB: db,
|
||||||
Lo: lo,
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error initializing search manager: %v", err)
|
log.Fatalf("error initializing search manager: %v", err)
|
||||||
@@ -775,6 +795,34 @@ func initSearch(db *sqlx.DB) *search.Manager {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initCustomAttribute inits custom attribute manager.
|
||||||
|
func initCustomAttribute(db *sqlx.DB, i18n *i18n.I18n) *customAttribute.Manager {
|
||||||
|
lo := initLogger("custom-attribute")
|
||||||
|
m, err := customAttribute.New(customAttribute.Opts{
|
||||||
|
DB: db,
|
||||||
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error initializing custom attribute manager: %v", err)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
// initActivityLog inits activity log manager.
|
||||||
|
func initActivityLog(db *sqlx.DB, i18n *i18n.I18n) *activitylog.Manager {
|
||||||
|
lo := initLogger("activity-log")
|
||||||
|
m, err := activitylog.New(activitylog.Opts{
|
||||||
|
DB: db,
|
||||||
|
Lo: lo,
|
||||||
|
I18n: i18n,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error initializing activity log manager: %v", err)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
// initLogger initializes a logf logger.
|
// initLogger initializes a logf logger.
|
||||||
func initLogger(src string) *logf.Logger {
|
func initLogger(src string) *logf.Logger {
|
||||||
lvl, env := ko.MustString("app.log_level"), ko.MustString("app.env")
|
lvl, env := ko.MustString("app.log_level"), ko.MustString("app.env")
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ func install(ctx context.Context, db *sqlx.DB, fs stuffbin.FileSystem, idempoten
|
|||||||
|
|
||||||
// Make sure the system user password is strong enough.
|
// Make sure the system user password is strong enough.
|
||||||
password := os.Getenv("LIBREDESK_SYSTEM_USER_PASSWORD")
|
password := os.Getenv("LIBREDESK_SYSTEM_USER_PASSWORD")
|
||||||
if password != "" && !user.IsStrongSystemUserPassword(password) && !schemaInstalled {
|
if password != "" && !user.IsStrongPassword(password) && !schemaInstalled {
|
||||||
log.Fatalf("system user password is not strong, %s", user.SystemUserPasswordHint)
|
log.Fatalf("system user password is not strong, %s", user.PasswordHint)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !idempotentInstall {
|
if !idempotentInstall {
|
||||||
@@ -49,11 +49,10 @@ func install(ctx context.Context, db *sqlx.DB, fs stuffbin.FileSystem, idempoten
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log.Println("installing database schema...")
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("installing database schema...")
|
|
||||||
|
|
||||||
// Install schema.
|
// Install schema.
|
||||||
if err := installSchema(db, fs); err != nil {
|
if err := installSchema(db, fs); err != nil {
|
||||||
log.Fatalf("error installing schema: %v", err)
|
log.Fatalf("error installing schema: %v", err)
|
||||||
|
|||||||
35
cmd/login.go
35
cmd/login.go
@@ -4,24 +4,29 @@ import (
|
|||||||
amodels "github.com/abhinavxd/libredesk/internal/auth/models"
|
amodels "github.com/abhinavxd/libredesk/internal/auth/models"
|
||||||
"github.com/abhinavxd/libredesk/internal/envelope"
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
umodels "github.com/abhinavxd/libredesk/internal/user/models"
|
umodels "github.com/abhinavxd/libredesk/internal/user/models"
|
||||||
|
realip "github.com/ferluci/fast-realip"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
|
|
||||||
// handleLogin logs a user in.
|
// handleLogin logs in the user and returns the user.
|
||||||
func handleLogin(r *fastglue.Request) error {
|
func handleLogin(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
email = string(r.RequestCtx.PostArgs().Peek("email"))
|
email = string(r.RequestCtx.PostArgs().Peek("email"))
|
||||||
password = r.RequestCtx.PostArgs().Peek("password")
|
password = r.RequestCtx.PostArgs().Peek("password")
|
||||||
|
ip = realip.FromRequest(r.RequestCtx)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Verify email and password.
|
||||||
user, err := app.user.VerifyPassword(email, password)
|
user, err := app.user.VerifyPassword(email, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if user is enabled.
|
||||||
if !user.Enabled {
|
if !user.Enabled {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "Your account is disabled, please contact administrator", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.T("user.accountDisabled"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set user availability status to online.
|
// Set user availability status to online.
|
||||||
@@ -37,13 +42,24 @@ func handleLogin(r *fastglue.Request) error {
|
|||||||
LastName: user.LastName,
|
LastName: user.LastName,
|
||||||
}, r); err != nil {
|
}, r); err != nil {
|
||||||
app.lo.Error("error saving session", "error", err)
|
app.lo.Error("error saving session", "error", err)
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.T("user.errorAcquiringSession"), nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorSaving", "name", "{globals.terms.session}"), nil))
|
||||||
}
|
}
|
||||||
// Set CSRF cookie if not already set.
|
// Set CSRF cookie if not already set.
|
||||||
if err := app.auth.SetCSRFCookie(r); err != nil {
|
if err := app.auth.SetCSRFCookie(r); err != nil {
|
||||||
app.lo.Error("error setting csrf cookie", "error", err)
|
app.lo.Error("error setting csrf cookie", "error", err)
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.T("user.errorAcquiringSession"), nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorSaving", "name", "{globals.terms.session}"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update last login time.
|
||||||
|
if err := app.user.UpdateLastLoginAt(user.ID); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert activity log.
|
||||||
|
if err := app.activityLog.Login(user.ID, user.Email.String, ip); err != nil {
|
||||||
|
app.lo.Error("error creating login activity log", "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(user)
|
return r.SendEnvelope(user)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,11 +67,18 @@ func handleLogin(r *fastglue.Request) error {
|
|||||||
func handleLogout(r *fastglue.Request) error {
|
func handleLogout(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
|
ip = realip.FromRequest(r.RequestCtx)
|
||||||
)
|
)
|
||||||
if err := app.auth.DestroySession(r); err != nil {
|
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.T("user.errorAcquiringSession"), nil))
|
// Insert activity log.
|
||||||
|
if err := app.activityLog.Logout(auser.ID, auser.Email, ip); err != nil {
|
||||||
|
app.lo.Error("error creating logout activity log", "error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := app.auth.DestroySession(r); err != nil {
|
||||||
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorDestroying", "name", "{globals.terms.session}"), nil))
|
||||||
|
}
|
||||||
// Add no-cache headers.
|
// Add no-cache headers.
|
||||||
r.RequestCtx.Response.Header.Add("Cache-Control",
|
r.RequestCtx.Response.Header.Add("Cache-Control",
|
||||||
"no-store, no-cache, must-revalidate, post-check=0, pre-check=0")
|
"no-store, no-cache, must-revalidate, post-check=0, pre-check=0")
|
||||||
|
|||||||
56
cmd/macro.go
56
cmd/macro.go
@@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -24,14 +23,14 @@ func handleGetMacros(r *fastglue.Request) error {
|
|||||||
for i, m := range macros {
|
for i, m := range macros {
|
||||||
var actions []autoModels.RuleAction
|
var actions []autoModels.RuleAction
|
||||||
if err := json.Unmarshal(m.Actions, &actions); err != nil {
|
if err := json.Unmarshal(m.Actions, &actions); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error unmarshalling macro actions", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.macroAction}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
// Set display values for actions as the value field can contain DB IDs
|
// Set display values for actions as the value field can contain DB IDs
|
||||||
if err := setDisplayValues(app, actions); err != nil {
|
if err := setDisplayValues(app, actions); err != nil {
|
||||||
app.lo.Warn("error setting display values", "error", err)
|
app.lo.Warn("error setting display values", "error", err)
|
||||||
}
|
}
|
||||||
if macros[i].Actions, err = json.Marshal(actions); err != nil {
|
if macros[i].Actions, err = json.Marshal(actions); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "marshal failed", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.macroAction}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(macros)
|
return r.SendEnvelope(macros)
|
||||||
@@ -44,8 +43,7 @@ func handleGetMacro(r *fastglue.Request) error {
|
|||||||
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
)
|
)
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid macro `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
macro, err := app.macro.Get(id)
|
macro, err := app.macro.Get(id)
|
||||||
@@ -55,14 +53,14 @@ func handleGetMacro(r *fastglue.Request) error {
|
|||||||
|
|
||||||
var actions []autoModels.RuleAction
|
var actions []autoModels.RuleAction
|
||||||
if err := json.Unmarshal(macro.Actions, &actions); err != nil {
|
if err := json.Unmarshal(macro.Actions, &actions); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error unmarshalling macro actions", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.macroAction}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
// Set display values for actions as the value field can contain DB IDs
|
// Set display values for actions as the value field can contain DB IDs
|
||||||
if err := setDisplayValues(app, actions); err != nil {
|
if err := setDisplayValues(app, actions); err != nil {
|
||||||
app.lo.Warn("error setting display values", "error", err)
|
app.lo.Warn("error setting display values", "error", err)
|
||||||
}
|
}
|
||||||
if macro.Actions, err = json.Marshal(actions); err != nil {
|
if macro.Actions, err = json.Marshal(actions); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "marshal failed", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.macroAction}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(macro)
|
return r.SendEnvelope(macro)
|
||||||
@@ -76,10 +74,10 @@ func handleCreateMacro(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if err := r.Decode(¯o, "json"); err != nil {
|
if err := r.Decode(¯o, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateMacro(macro); err != nil {
|
if err := validateMacro(app, macro); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +106,7 @@ func handleUpdateMacro(r *fastglue.Request) error {
|
|||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := validateMacro(macro); err != nil {
|
if err := validateMacro(app, macro); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,18 +120,14 @@ func handleUpdateMacro(r *fastglue.Request) error {
|
|||||||
// handleDeleteMacro deletes macro.
|
// handleDeleteMacro deletes macro.
|
||||||
func handleDeleteMacro(r *fastglue.Request) error {
|
func handleDeleteMacro(r *fastglue.Request) error {
|
||||||
var app = r.Context.(*App)
|
var app = r.Context.(*App)
|
||||||
|
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid macro `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.macro.Delete(id); err != nil {
|
if err := app.macro.Delete(id); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
return r.SendEnvelope("Macro deleted successfully")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleApplyMacro applies macro actions to a conversation.
|
// handleApplyMacro applies macro actions to a conversation.
|
||||||
@@ -145,7 +139,7 @@ func handleApplyMacro(r *fastglue.Request) error {
|
|||||||
id, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
incomingActions = []autoModels.RuleAction{}
|
incomingActions = []autoModels.RuleAction{}
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -156,7 +150,7 @@ func handleApplyMacro(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
if allowed, err := app.authz.EnforceConversationAccess(user, conversation); err != nil || !allowed {
|
if allowed, err := app.authz.EnforceConversationAccess(user, conversation); err != nil || !allowed {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.PermissionError, "Permission denied", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.PermissionError, app.i18n.Ts("globals.messages.denied", "name", "{globals.terms.permission}"), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
macro, err := app.macro.Get(id)
|
macro, err := app.macro.Get(id)
|
||||||
@@ -167,7 +161,7 @@ func handleApplyMacro(r *fastglue.Request) error {
|
|||||||
// Decode incoming actions.
|
// Decode incoming actions.
|
||||||
if err := r.Decode(&incomingActions, "json"); err != nil {
|
if err := r.Decode(&incomingActions, "json"); err != nil {
|
||||||
app.lo.Error("error unmashalling incoming actions", "error", err)
|
app.lo.Error("error unmashalling incoming actions", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Failed to decode incoming actions", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.macroAction}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure no duplicate action types are present.
|
// Make sure no duplicate action types are present.
|
||||||
@@ -175,7 +169,7 @@ func handleApplyMacro(r *fastglue.Request) error {
|
|||||||
for _, act := range incomingActions {
|
for _, act := range incomingActions {
|
||||||
if actionTypes[act.Type] {
|
if actionTypes[act.Type] {
|
||||||
app.lo.Warn("duplicate action types found in macro apply apply request", "action", act.Type, "user_id", user.ID)
|
app.lo.Warn("duplicate action types found in macro apply apply request", "action", act.Type, "user_id", user.ID)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Duplicate actions are not allowed", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("macro.duplicateActionsNotAllowed"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
actionTypes[act.Type] = true
|
actionTypes[act.Type] = true
|
||||||
}
|
}
|
||||||
@@ -184,11 +178,11 @@ func handleApplyMacro(r *fastglue.Request) error {
|
|||||||
for _, act := range incomingActions {
|
for _, act := range incomingActions {
|
||||||
if !isMacroActionAllowed(act.Type) {
|
if !isMacroActionAllowed(act.Type) {
|
||||||
app.lo.Warn("action not allowed in macro", "action", act.Type, "user_id", user.ID)
|
app.lo.Warn("action not allowed in macro", "action", act.Type, "user_id", user.ID)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusForbidden, "Action not allowed in macro", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("macro.actionNotAllowed", "name", act.Type), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
if !hasActionPermission(act.Type, user.Permissions) {
|
if !hasActionPermission(act.Type, user.Permissions) {
|
||||||
app.lo.Warn("no permission to execute macro action", "action", act.Type, "user_id", user.ID)
|
app.lo.Warn("no permission to execute macro action", "action", act.Type, "user_id", user.ID)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusForbidden, "No permission to execute this macro", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.T("macro.permissionDenied"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +195,7 @@ func handleApplyMacro(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if successCount == 0 {
|
if successCount == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Failed to apply macro", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.T("macro.couldNotApply"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment usage count.
|
// Increment usage count.
|
||||||
@@ -209,12 +203,12 @@ func handleApplyMacro(r *fastglue.Request) error {
|
|||||||
|
|
||||||
if successCount < len(incomingActions) {
|
if successCount < len(incomingActions) {
|
||||||
return r.SendJSON(fasthttp.StatusMultiStatus, map[string]interface{}{
|
return r.SendJSON(fasthttp.StatusMultiStatus, map[string]interface{}{
|
||||||
"message": fmt.Sprintf("Macro executed with errors. %d actions succeeded out of %d", successCount, len(incomingActions)),
|
"message": app.i18n.T("macro.partiallyApplied"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendJSON(fasthttp.StatusOK, map[string]interface{}{
|
return r.SendJSON(fasthttp.StatusOK, map[string]interface{}{
|
||||||
"message": "Macro applied successfully",
|
"message": app.i18n.T("macro.applied"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +233,7 @@ func setDisplayValues(app *App, actions []autoModels.RuleAction) error {
|
|||||||
return t.Name, nil
|
return t.Name, nil
|
||||||
},
|
},
|
||||||
autoModels.ActionAssignUser: func(id int) (string, error) {
|
autoModels.ActionAssignUser: func(id int) (string, error) {
|
||||||
u, err := app.user.GetAgent(id)
|
u, err := app.user.GetAgent(id, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Warn("user not found for macro action", "user_id", id)
|
app.lo.Warn("user not found for macro action", "user_id", id)
|
||||||
return "", err
|
return "", err
|
||||||
@@ -276,18 +270,18 @@ func setDisplayValues(app *App, actions []autoModels.RuleAction) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validateMacro validates an incoming macro.
|
// validateMacro validates an incoming macro.
|
||||||
func validateMacro(macro models.Macro) error {
|
func validateMacro(app *App, macro models.Macro) error {
|
||||||
if macro.Name == "" {
|
if macro.Name == "" {
|
||||||
return envelope.NewError(envelope.InputError, "Empty macro `name`", nil)
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var act []autoModels.RuleAction
|
var act []autoModels.RuleAction
|
||||||
if err := json.Unmarshal(macro.Actions, &act); err != nil {
|
if err := json.Unmarshal(macro.Actions, &act); err != nil {
|
||||||
return envelope.NewError(envelope.InputError, "Could not parse macro actions", nil)
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.macroAction}"), nil)
|
||||||
}
|
}
|
||||||
for _, a := range act {
|
for _, a := range act {
|
||||||
if len(a.Value) == 0 {
|
if len(a.Value) == 0 {
|
||||||
return envelope.NewError(envelope.InputError, fmt.Sprintf("Empty value for action: %s", a.Type), nil)
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.emptyActionValue", "name", a.Type), nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -298,7 +292,7 @@ func isMacroActionAllowed(action string) bool {
|
|||||||
switch action {
|
switch action {
|
||||||
case autoModels.ActionSendPrivateNote, autoModels.ActionReply:
|
case autoModels.ActionSendPrivateNote, autoModels.ActionReply:
|
||||||
return false
|
return false
|
||||||
case autoModels.ActionAssignTeam, autoModels.ActionAssignUser, autoModels.ActionSetStatus, autoModels.ActionSetPriority, autoModels.ActionSetTags:
|
case autoModels.ActionAssignTeam, autoModels.ActionAssignUser, autoModels.ActionSetStatus, autoModels.ActionSetPriority, autoModels.ActionAddTags, autoModels.ActionSetTags, autoModels.ActionRemoveTags:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
|||||||
54
cmd/main.go
54
cmd/main.go
@@ -11,12 +11,16 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
_ "time/tzdata"
|
||||||
|
|
||||||
|
activitylog "github.com/abhinavxd/libredesk/internal/activity_log"
|
||||||
"github.com/abhinavxd/libredesk/internal/ai"
|
"github.com/abhinavxd/libredesk/internal/ai"
|
||||||
auth_ "github.com/abhinavxd/libredesk/internal/auth"
|
auth_ "github.com/abhinavxd/libredesk/internal/auth"
|
||||||
"github.com/abhinavxd/libredesk/internal/authz"
|
"github.com/abhinavxd/libredesk/internal/authz"
|
||||||
businesshours "github.com/abhinavxd/libredesk/internal/business_hours"
|
businesshours "github.com/abhinavxd/libredesk/internal/business_hours"
|
||||||
"github.com/abhinavxd/libredesk/internal/colorlog"
|
"github.com/abhinavxd/libredesk/internal/colorlog"
|
||||||
"github.com/abhinavxd/libredesk/internal/csat"
|
"github.com/abhinavxd/libredesk/internal/csat"
|
||||||
|
customAttribute "github.com/abhinavxd/libredesk/internal/custom_attribute"
|
||||||
"github.com/abhinavxd/libredesk/internal/macro"
|
"github.com/abhinavxd/libredesk/internal/macro"
|
||||||
notifier "github.com/abhinavxd/libredesk/internal/notification"
|
notifier "github.com/abhinavxd/libredesk/internal/notification"
|
||||||
"github.com/abhinavxd/libredesk/internal/search"
|
"github.com/abhinavxd/libredesk/internal/search"
|
||||||
@@ -83,7 +87,9 @@ type App struct {
|
|||||||
view *view.Manager
|
view *view.Manager
|
||||||
ai *ai.Manager
|
ai *ai.Manager
|
||||||
search *search.Manager
|
search *search.Manager
|
||||||
|
activityLog *activitylog.Manager
|
||||||
notifier *notifier.Service
|
notifier *notifier.Service
|
||||||
|
customAttribute *customAttribute.Manager
|
||||||
|
|
||||||
// Global state that stores data on an available app update.
|
// Global state that stores data on an available app update.
|
||||||
update *AppUpdate
|
update *AppUpdate
|
||||||
@@ -106,7 +112,6 @@ func main() {
|
|||||||
|
|
||||||
// Build string injected at build time.
|
// Build string injected at build time.
|
||||||
colorlog.Green("Build: %s", buildString)
|
colorlog.Green("Build: %s", buildString)
|
||||||
colorlog.Green("Version: %s", versionString)
|
|
||||||
|
|
||||||
// Load the config files into Koanf.
|
// Load the config files into Koanf.
|
||||||
initConfig(ko)
|
initConfig(ko)
|
||||||
@@ -164,33 +169,34 @@ func main() {
|
|||||||
rdb = initRedis()
|
rdb = initRedis()
|
||||||
constants = initConstants()
|
constants = initConstants()
|
||||||
i18n = initI18n(fs)
|
i18n = initI18n(fs)
|
||||||
csat = initCSAT(db)
|
csat = initCSAT(db, i18n)
|
||||||
oidc = initOIDC(db, settings)
|
oidc = initOIDC(db, settings, i18n)
|
||||||
status = initStatus(db)
|
status = initStatus(db, i18n)
|
||||||
priority = initPriority(db)
|
priority = initPriority(db, i18n)
|
||||||
auth = initAuth(oidc, rdb)
|
auth = initAuth(oidc, rdb, i18n)
|
||||||
template = initTemplate(db, fs, constants)
|
template = initTemplate(db, fs, constants, i18n)
|
||||||
media = initMedia(db)
|
media = initMedia(db, i18n)
|
||||||
inbox = initInbox(db)
|
inbox = initInbox(db, i18n)
|
||||||
team = initTeam(db)
|
team = initTeam(db, i18n)
|
||||||
businessHours = initBusinessHours(db)
|
businessHours = initBusinessHours(db, i18n)
|
||||||
user = initUser(i18n, db)
|
user = initUser(i18n, db)
|
||||||
wsHub = initWS(user)
|
wsHub = initWS(user)
|
||||||
notifier = initNotifier(user)
|
notifier = initNotifier()
|
||||||
automation = initAutomationEngine(db)
|
automation = initAutomationEngine(db, i18n)
|
||||||
sla = initSLA(db, team, settings, businessHours)
|
sla = initSLA(db, team, settings, businessHours, notifier, template, user, i18n)
|
||||||
conversation = initConversations(i18n, sla, status, priority, wsHub, notifier, db, inbox, user, team, media, settings, csat, automation, template)
|
conversation = initConversations(i18n, sla, status, priority, wsHub, notifier, db, inbox, user, team, media, settings, csat, automation, template)
|
||||||
autoassigner = initAutoAssigner(team, user, conversation)
|
autoassigner = initAutoAssigner(team, user, conversation)
|
||||||
)
|
)
|
||||||
automation.SetConversationStore(conversation)
|
automation.SetConversationStore(conversation)
|
||||||
|
|
||||||
startInboxes(ctx, inbox, conversation)
|
startInboxes(ctx, inbox, conversation, user)
|
||||||
go automation.Run(ctx, automationWorkers)
|
go automation.Run(ctx, automationWorkers)
|
||||||
go autoassigner.Run(ctx, autoAssignInterval)
|
go autoassigner.Run(ctx, autoAssignInterval)
|
||||||
go conversation.Run(ctx, messageIncomingQWorkers, messageOutgoingQWorkers, messageOutgoingScanInterval)
|
go conversation.Run(ctx, messageIncomingQWorkers, messageOutgoingQWorkers, messageOutgoingScanInterval)
|
||||||
go conversation.RunUnsnoozer(ctx, unsnoozeInterval)
|
go conversation.RunUnsnoozer(ctx, unsnoozeInterval)
|
||||||
go notifier.Run(ctx)
|
go notifier.Run(ctx)
|
||||||
go sla.Run(ctx, slaEvaluationInterval)
|
go sla.Run(ctx, slaEvaluationInterval)
|
||||||
|
go sla.SendNotifications(ctx)
|
||||||
go media.DeleteUnlinkedMedia(ctx)
|
go media.DeleteUnlinkedMedia(ctx)
|
||||||
go user.MonitorAgentAvailability(ctx)
|
go user.MonitorAgentAvailability(ctx)
|
||||||
|
|
||||||
@@ -214,14 +220,16 @@ func main() {
|
|||||||
conversation: conversation,
|
conversation: conversation,
|
||||||
automation: automation,
|
automation: automation,
|
||||||
businessHours: businessHours,
|
businessHours: businessHours,
|
||||||
authz: initAuthz(),
|
activityLog: initActivityLog(db, i18n),
|
||||||
|
customAttribute: initCustomAttribute(db, i18n),
|
||||||
|
authz: initAuthz(i18n),
|
||||||
view: initView(db),
|
view: initView(db),
|
||||||
csat: initCSAT(db),
|
csat: initCSAT(db, i18n),
|
||||||
search: initSearch(db),
|
search: initSearch(db, i18n),
|
||||||
role: initRole(db),
|
role: initRole(db, i18n),
|
||||||
tag: initTag(db),
|
tag: initTag(db, i18n),
|
||||||
macro: initMacro(db),
|
macro: initMacro(db, i18n),
|
||||||
ai: initAI(db),
|
ai: initAI(db, i18n),
|
||||||
}
|
}
|
||||||
app.consts.Store(constants)
|
app.consts.Store(constants)
|
||||||
|
|
||||||
@@ -235,7 +243,7 @@ func main() {
|
|||||||
WriteTimeout: ko.MustDuration("app.server.write_timeout"),
|
WriteTimeout: ko.MustDuration("app.server.write_timeout"),
|
||||||
MaxRequestBodySize: ko.MustInt("app.server.max_body_size"),
|
MaxRequestBodySize: ko.MustInt("app.server.max_body_size"),
|
||||||
MaxKeepaliveDuration: ko.MustDuration("app.server.keepalive_timeout"),
|
MaxKeepaliveDuration: ko.MustDuration("app.server.keepalive_timeout"),
|
||||||
ReadBufferSize: ko.MustInt("app.server.max_body_size"),
|
ReadBufferSize: ko.Int("app.server.read_buffer_size"),
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
30
cmd/media.go
30
cmd/media.go
@@ -24,6 +24,7 @@ const (
|
|||||||
thumbPrefix = "thumb_"
|
thumbPrefix = "thumb_"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// handleMediaUpload handles media uploads.
|
||||||
func handleMediaUpload(r *fastglue.Request) error {
|
func handleMediaUpload(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
@@ -33,19 +34,19 @@ func handleMediaUpload(r *fastglue.Request) error {
|
|||||||
form, err := r.RequestCtx.MultipartForm()
|
form, err := r.RequestCtx.MultipartForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error parsing form data.", "error", err)
|
app.lo.Error("error parsing form data.", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error parsing data", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
files, ok := form.File["files"]
|
files, ok := form.File["files"]
|
||||||
if !ok || len(files) == 0 {
|
if !ok || len(files) == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "File not found", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.notFound", "name", "{globals.terms.file}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileHeader := files[0]
|
fileHeader := files[0]
|
||||||
file, err := fileHeader.Open()
|
file, err := fileHeader.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error reading uploaded file", "error", err)
|
app.lo.Error("error reading uploaded file", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error reading file", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorReading", "name", "{globals.terms.file}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
@@ -74,15 +75,15 @@ func handleMediaUpload(r *fastglue.Request) error {
|
|||||||
if bytesToMegabytes(srcFileSize) > float64(consts.MaxFileUploadSizeMB) {
|
if bytesToMegabytes(srcFileSize) > float64(consts.MaxFileUploadSizeMB) {
|
||||||
app.lo.Error("error: uploaded file size is larger than max allowed", "size", bytesToMegabytes(srcFileSize), "max_allowed", consts.MaxFileUploadSizeMB)
|
app.lo.Error("error: uploaded file size is larger than max allowed", "size", bytesToMegabytes(srcFileSize), "max_allowed", consts.MaxFileUploadSizeMB)
|
||||||
return r.SendErrorEnvelope(
|
return r.SendErrorEnvelope(
|
||||||
http.StatusRequestEntityTooLarge,
|
fasthttp.StatusRequestEntityTooLarge,
|
||||||
fmt.Sprintf("File size is too large. Please upload file lesser than %d MB", consts.MaxFileUploadSizeMB),
|
app.i18n.Ts("media.fileSizeTooLarge", "size", fmt.Sprintf("%dMB", consts.MaxFileUploadSizeMB)),
|
||||||
nil,
|
nil,
|
||||||
envelope.GeneralError,
|
envelope.GeneralError,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !slices.Contains(consts.AllowedUploadFileExtensions, "*") && !slices.Contains(consts.AllowedUploadFileExtensions, srcExt) {
|
if !slices.Contains(consts.AllowedUploadFileExtensions, "*") && !slices.Contains(consts.AllowedUploadFileExtensions, srcExt) {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "File type not allowed", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("media.fileTypeNotAllowed"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete files on any error.
|
// Delete files on any error.
|
||||||
@@ -102,11 +103,10 @@ func handleMediaUpload(r *fastglue.Request) error {
|
|||||||
thumbFile, err := image.CreateThumb(image.DefThumbSize, file)
|
thumbFile, err := image.CreateThumb(image.DefThumbSize, file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error creating thumb image", "error", err)
|
app.lo.Error("error creating thumb image", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error creating image thumbnail", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorCreating", "name", "{globals.terms.thumbnail}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
thumbName, err = app.media.Upload(thumbName, srcContentType, thumbFile)
|
thumbName, err = app.media.Upload(thumbName, srcContentType, thumbFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error uploading thumbnail", "error", err)
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ func handleMediaUpload(r *fastglue.Request) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
cleanUp = true
|
cleanUp = true
|
||||||
app.lo.Error("error getting image dimensions", "error", err)
|
app.lo.Error("error getting image dimensions", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error uploading file", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorUploading", "name", "{globals.terms.media}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
meta, _ = json.Marshal(map[string]interface{}{
|
meta, _ = json.Marshal(map[string]interface{}{
|
||||||
"width": width,
|
"width": width,
|
||||||
@@ -129,7 +129,7 @@ func handleMediaUpload(r *fastglue.Request) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
cleanUp = true
|
cleanUp = true
|
||||||
app.lo.Error("error uploading file", "error", err)
|
app.lo.Error("error uploading file", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error uploading file", nil, envelope.GeneralError)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert in DB.
|
// Insert in DB.
|
||||||
@@ -137,7 +137,7 @@ func handleMediaUpload(r *fastglue.Request) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
cleanUp = true
|
cleanUp = true
|
||||||
app.lo.Error("error inserting metadata into database", "error", err)
|
app.lo.Error("error inserting metadata into database", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error inserting media", nil, envelope.GeneralError)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(media)
|
return r.SendEnvelope(media)
|
||||||
}
|
}
|
||||||
@@ -150,13 +150,13 @@ func handleServeMedia(r *fastglue.Request) error {
|
|||||||
uuid = r.RequestCtx.UserValue("uuid").(string)
|
uuid = r.RequestCtx.UserValue("uuid").(string)
|
||||||
)
|
)
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch media from DB.
|
// Fetch media from DB.
|
||||||
media, err := app.media.GetByUUID(strings.TrimPrefix(uuid, thumbPrefix))
|
media, err := app.media.Get(0, strings.TrimPrefix(uuid, thumbPrefix))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,6 @@ func handleServeMedia(r *fastglue.Request) error {
|
|||||||
// Check if the user has permission to access the linked model.
|
// Check if the user has permission to access the linked model.
|
||||||
allowed, err := app.authz.EnforceMediaAccess(user, media.Model.String)
|
allowed, err := app.authz.EnforceMediaAccess(user, media.Model.String)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error checking media permission", "error", err, "model", media.Model.String, "model_id", media.ModelID)
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +180,7 @@ func handleServeMedia(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !allowed {
|
if !allowed {
|
||||||
return r.SendErrorEnvelope(http.StatusUnauthorized, "Permission denied", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusUnauthorized, app.i18n.Ts("globals.messages.denied", "name", "{globals.terms.permission}"), nil, envelope.UnauthorizedError)
|
||||||
}
|
}
|
||||||
consts := app.consts.Load().(*constants)
|
consts := app.consts.Load().(*constants)
|
||||||
switch consts.UploadProvider {
|
switch consts.UploadProvider {
|
||||||
@@ -193,6 +192,7 @@ func handleServeMedia(r *fastglue.Request) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bytesToMegabytes converts bytes to megabytes.
|
||||||
func bytesToMegabytes(bytes int64) float64 {
|
func bytesToMegabytes(bytes int64) float64 {
|
||||||
return float64(bytes) / 1024 / 1024
|
return float64(bytes) / 1024 / 1024
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ type messageReq struct {
|
|||||||
Attachments []int `json:"attachments"`
|
Attachments []int `json:"attachments"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
Private bool `json:"private"`
|
Private bool `json:"private"`
|
||||||
|
To []string `json:"to"`
|
||||||
CC []string `json:"cc"`
|
CC []string `json:"cc"`
|
||||||
BCC []string `json:"bcc"`
|
BCC []string `json:"bcc"`
|
||||||
}
|
}
|
||||||
@@ -30,7 +31,7 @@ func handleGetMessages(r *fastglue.Request) error {
|
|||||||
total = 0
|
total = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -48,11 +49,14 @@ func handleGetMessages(r *fastglue.Request) error {
|
|||||||
|
|
||||||
for i := range messages {
|
for i := range messages {
|
||||||
total = messages[i].Total
|
total = messages[i].Total
|
||||||
|
// Populate attachment URLs
|
||||||
for j := range messages[i].Attachments {
|
for j := range messages[i].Attachments {
|
||||||
messages[i].Attachments[j].URL = app.media.GetURL(messages[i].Attachments[j].UUID)
|
messages[i].Attachments[j].URL = app.media.GetURL(messages[i].Attachments[j].UUID)
|
||||||
}
|
}
|
||||||
|
// Redact CSAT survey link
|
||||||
messages[i].CensorCSATContent()
|
messages[i].CensorCSATContent()
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(envelope.PageResults{
|
return r.SendEnvelope(envelope.PageResults{
|
||||||
Total: total,
|
Total: total,
|
||||||
Results: messages,
|
Results: messages,
|
||||||
@@ -70,7 +74,7 @@ func handleGetMessage(r *fastglue.Request) error {
|
|||||||
cuuid = r.RequestCtx.UserValue("cuuid").(string)
|
cuuid = r.RequestCtx.UserValue("cuuid").(string)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -105,7 +109,7 @@ func handleRetryMessage(r *fastglue.Request) error {
|
|||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -116,8 +120,7 @@ func handleRetryMessage(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.conversation.MarkMessageAsPending(uuid)
|
if err = app.conversation.MarkMessageAsPending(uuid); err != nil {
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
@@ -133,12 +136,12 @@ func handleSendMessage(r *fastglue.Request) error {
|
|||||||
req = messageReq{}
|
req = messageReq{}
|
||||||
)
|
)
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check permission
|
// Check access to conversation.
|
||||||
conv, err := enforceConversationAccess(app, cuuid, user)
|
conv, err := enforceConversationAccess(app, cuuid, user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
@@ -146,14 +149,15 @@ func handleSendMessage(r *fastglue.Request) error {
|
|||||||
|
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
app.lo.Error("error unmarshalling message request", "error", err)
|
app.lo.Error("error unmarshalling message request", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "error decoding request", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepare attachments.
|
||||||
for _, id := range req.Attachments {
|
for _, id := range req.Attachments {
|
||||||
m, err := app.media.Get(id)
|
m, err := app.media.Get(id, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error fetching media", "error", err)
|
app.lo.Error("error fetching media", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error fetching media", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorFetching", "name", "{globals.terms.media}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
media = append(media, m)
|
media = append(media, m)
|
||||||
}
|
}
|
||||||
@@ -163,17 +167,12 @@ func handleSendMessage(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := app.conversation.SendReply(media, conv.InboxID, user.ID, cuuid, req.Message, req.CC, req.BCC, map[string]any{} /**meta**/); err != nil {
|
if err := app.conversation.SendReply(media, conv.InboxID, user.ID, cuuid, req.Message, req.To, req.CC, req.BCC, map[string]any{} /**meta**/); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
// Evaluate automation rules.
|
// Evaluate automation rules.
|
||||||
app.automation.EvaluateConversationUpdateRules(cuuid, models.EventConversationMessageOutgoing)
|
app.automation.EvaluateConversationUpdateRules(cuuid, models.EventConversationMessageOutgoing)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reopen if snoozed/closed/resolved regardless of automation rules - this is the default behavior
|
return r.SendEnvelope(true)
|
||||||
if err := app.conversation.ReOpenConversation(cuuid, user); err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.SendEnvelope("Message sent successfully")
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/zerodha/simplesessions/v3"
|
"github.com/zerodha/simplesessions/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// tryAuth is a middleware that attempts to authenticate the user and add them to the context
|
// tryAuth attempts to authenticate the user and add them to the context but doesn't enforce authentication.
|
||||||
// but doesn't enforce authentication. Handlers can check if user exists in context optionally.
|
// Handlers can check if user exists in context optionally.
|
||||||
func tryAuth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
func tryAuth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
||||||
return func(r *fastglue.Request) error {
|
return func(r *fastglue.Request) error {
|
||||||
app := r.Context.(*App)
|
app := r.Context.(*App)
|
||||||
@@ -24,7 +24,7 @@ func tryAuth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to get user.
|
// Try to get user.
|
||||||
user, err := app.user.GetAgent(userSession.ID)
|
user, err := app.user.GetAgent(userSession.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return handler(r)
|
return handler(r)
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ func tryAuth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// auth makes sure the user is logged in.
|
// auth validates the session and adds the user to the request context.
|
||||||
func auth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
func auth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
||||||
return func(r *fastglue.Request) error {
|
return func(r *fastglue.Request) error {
|
||||||
var app = r.Context.(*App)
|
var app = r.Context.(*App)
|
||||||
@@ -50,11 +50,11 @@ func auth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
|||||||
userSession, err := app.auth.ValidateSession(r)
|
userSession, err := app.auth.ValidateSession(r)
|
||||||
if err != nil || userSession.ID <= 0 {
|
if err != nil || userSession.ID <= 0 {
|
||||||
app.lo.Error("error validating session", "error", err)
|
app.lo.Error("error validating session", "error", err)
|
||||||
return r.SendErrorEnvelope(http.StatusUnauthorized, "Invalid or expired session", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusUnauthorized, app.i18n.T("auth.invalidOrExpiredSession"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set user in the request context.
|
// Set user in the request context.
|
||||||
user, err := app.user.GetAgent(userSession.ID)
|
user, err := app.user.GetAgent(userSession.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,8 @@ func auth(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// perm does session validation, CSRF, and permission enforcement.
|
// perm matches the CSRF token and checks if the user has the required permission to access the endpoint.
|
||||||
|
// and sets the user in the request context.
|
||||||
func perm(handler fastglue.FastRequestHandler, perm string) fastglue.FastRequestHandler {
|
func perm(handler fastglue.FastRequestHandler, perm string) fastglue.FastRequestHandler {
|
||||||
return func(r *fastglue.Request) error {
|
return func(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
@@ -78,20 +79,21 @@ func perm(handler fastglue.FastRequestHandler, perm string) fastglue.FastRequest
|
|||||||
hdrToken = string(r.RequestCtx.Request.Header.Peek("X-CSRFTOKEN"))
|
hdrToken = string(r.RequestCtx.Request.Header.Peek("X-CSRFTOKEN"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Match CSRF token from cookie and header.
|
||||||
if cookieToken == "" || hdrToken == "" || cookieToken != hdrToken {
|
if cookieToken == "" || hdrToken == "" || cookieToken != hdrToken {
|
||||||
app.lo.Error("csrf token mismatch", "cookie_token", cookieToken, "header_token", hdrToken)
|
app.lo.Error("csrf token mismatch", "cookie_token", cookieToken, "header_token", hdrToken)
|
||||||
return r.SendErrorEnvelope(http.StatusForbidden, "Invalid CSRF token", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusForbidden, app.i18n.T("auth.csrfTokenMismatch"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate session and fetch user.
|
// Validate session and fetch user.
|
||||||
sessUser, err := app.auth.ValidateSession(r)
|
sessUser, err := app.auth.ValidateSession(r)
|
||||||
if err != nil || sessUser.ID <= 0 {
|
if err != nil || sessUser.ID <= 0 {
|
||||||
app.lo.Error("error validating session", "error", err)
|
app.lo.Error("error validating session", "error", err)
|
||||||
return r.SendErrorEnvelope(http.StatusUnauthorized, "Invalid or expired session", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusUnauthorized, app.i18n.T("auth.invalidOrExpiredSession"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user from DB.
|
// Get user from DB.
|
||||||
user, err := app.user.GetAgent(sessUser.ID)
|
user, err := app.user.GetAgent(sessUser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -101,21 +103,21 @@ func perm(handler fastglue.FastRequestHandler, perm string) fastglue.FastRequest
|
|||||||
if err := app.auth.DestroySession(r); err != nil {
|
if err := app.auth.DestroySession(r); err != nil {
|
||||||
app.lo.Error("error destroying session", "error", err)
|
app.lo.Error("error destroying session", "error", err)
|
||||||
}
|
}
|
||||||
return r.SendErrorEnvelope(http.StatusUnauthorized, "User account disabled", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusUnauthorized, app.i18n.T("user.accountDisabled"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split the permission string into object and action and enforce it.
|
// Split the permission string into object and action and enforce it.
|
||||||
parts := strings.Split(perm, ":")
|
parts := strings.Split(perm, ":")
|
||||||
if len(parts) != 2 {
|
if len(parts) != 2 {
|
||||||
return r.SendErrorEnvelope(http.StatusInternalServerError, "Invalid permission format", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(http.StatusInternalServerError, app.i18n.Ts("globals.messages.invalid", "name", "{globals.terms.permission}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
object, action := parts[0], parts[1]
|
object, action := parts[0], parts[1]
|
||||||
ok, err := app.authz.Enforce(user, object, action)
|
ok, err := app.authz.Enforce(user, object, action)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(http.StatusInternalServerError, "Error checking permissions", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(http.StatusInternalServerError, app.i18n.Ts("globals.messages.errorChecking", "name", "{globals.terms.permission}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
return r.SendErrorEnvelope(http.StatusForbidden, "Permission denied", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusForbidden, app.i18n.Ts("globals.messages.denied", "name", "{globals.terms.permission}"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set user in the request context.
|
// Set user in the request context.
|
||||||
@@ -141,7 +143,7 @@ func authPage(handler fastglue.FastRequestHandler) fastglue.FastRequestHandler {
|
|||||||
// Session is not valid, destroy it and redirect to login.
|
// Session is not valid, destroy it and redirect to login.
|
||||||
if err != simplesessions.ErrInvalidSession {
|
if err != simplesessions.ErrInvalidSession {
|
||||||
app.lo.Error("error validating session", "error", err)
|
app.lo.Error("error validating session", "error", err)
|
||||||
return r.SendErrorEnvelope(http.StatusUnauthorized, "Error validating session", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusUnauthorized, app.i18n.Ts("globals.messages.errorValidating", "name", "{globals.terms.session}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
if err := app.auth.DestroySession(r); err != nil {
|
if err := app.auth.DestroySession(r); err != nil {
|
||||||
app.lo.Error("error destroying session", "error", err)
|
app.lo.Error("error destroying session", "error", err)
|
||||||
@@ -172,7 +174,7 @@ func notAuthPage(handler fastglue.FastRequestHandler) fastglue.FastRequestHandle
|
|||||||
user, err := app.auth.ValidateSession(r)
|
user, err := app.auth.ValidateSession(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error validating session", "error", err)
|
app.lo.Error("error validating session", "error", err)
|
||||||
return r.SendErrorEnvelope(http.StatusUnauthorized, "Invalid or expired session", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(http.StatusUnauthorized, app.i18n.T("auth.invalidOrExpiredSessionClearCookie"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.ID != 0 {
|
if user.ID != 0 {
|
||||||
|
|||||||
22
cmd/oidc.go
22
cmd/oidc.go
@@ -41,7 +41,7 @@ func handleGetOIDC(r *fastglue.Request) error {
|
|||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id <= 0 {
|
if err != nil || id <= 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
||||||
"Invalid OIDC `id`", nil, envelope.InputError)
|
app.i18n.Ts("globals.messages.invalid", "name", "OIDC `id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
o, err := app.oidc.Get(id, false)
|
o, err := app.oidc.Get(id, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -59,7 +59,7 @@ func handleTestOIDC(r *fastglue.Request) error {
|
|||||||
if err := app.auth.TestProvider(providerURL); err != nil {
|
if err := app.auth.TestProvider(providerURL); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("OIDC provider discovered successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleCreateOIDC creates a new OIDC record.
|
// handleCreateOIDC creates a new OIDC record.
|
||||||
@@ -69,7 +69,7 @@ func handleCreateOIDC(r *fastglue.Request) error {
|
|||||||
req = models.OIDC{}
|
req = models.OIDC{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Bad request", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.oidc.Create(req); err != nil {
|
if err := app.oidc.Create(req); err != nil {
|
||||||
@@ -78,7 +78,7 @@ func handleCreateOIDC(r *fastglue.Request) error {
|
|||||||
|
|
||||||
// Reload the auth manager to update the OIDC providers.
|
// Reload the auth manager to update the OIDC providers.
|
||||||
if err := reloadAuth(app); err != nil {
|
if err := reloadAuth(app); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "OIDC"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("OIDC created successfully")
|
return r.SendEnvelope("OIDC created successfully")
|
||||||
}
|
}
|
||||||
@@ -91,12 +91,11 @@ func handleUpdateOIDC(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "OIDC `id`"), nil, envelope.InputError)
|
||||||
"Invalid oidc `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Bad request", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.oidc.Update(id, req); err != nil {
|
if err = app.oidc.Update(id, req); err != nil {
|
||||||
@@ -105,9 +104,9 @@ func handleUpdateOIDC(r *fastglue.Request) error {
|
|||||||
|
|
||||||
// Reload the auth manager to update the OIDC providers.
|
// Reload the auth manager to update the OIDC providers.
|
||||||
if err := reloadAuth(app); err != nil {
|
if err := reloadAuth(app); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.couldNotReload", "name", "OIDC"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("OIDC updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleDeleteOIDC deletes an OIDC record.
|
// handleDeleteOIDC deletes an OIDC record.
|
||||||
@@ -115,11 +114,10 @@ func handleDeleteOIDC(r *fastglue.Request) error {
|
|||||||
var app = r.Context.(*App)
|
var app = r.Context.(*App)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "OIDC `id`"), nil, envelope.InputError)
|
||||||
"Invalid oidc `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
if err = app.oidc.Delete(id); err != nil {
|
if err = app.oidc.Delete(id); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("OIDC deleted successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|||||||
16
cmd/roles.go
16
cmd/roles.go
@@ -14,11 +14,11 @@ func handleGetRoles(r *fastglue.Request) error {
|
|||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
agents, err := app.role.GetAll()
|
roles, err := app.role.GetAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(agents)
|
return r.SendEnvelope(roles)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetRole returns a single role
|
// handleGetRole returns a single role
|
||||||
@@ -43,7 +43,7 @@ func handleDeleteRole(r *fastglue.Request) error {
|
|||||||
if err := app.role.Delete(id); err != nil {
|
if err := app.role.Delete(id); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Role deleted successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleCreateRole creates a new role
|
// handleCreateRole creates a new role
|
||||||
@@ -53,12 +53,12 @@ func handleCreateRole(r *fastglue.Request) error {
|
|||||||
req = models.Role{}
|
req = models.Role{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err := app.role.Create(req); err != nil {
|
if err := app.role.Create(req); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Role created successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateRole updates a role
|
// handleUpdateRole updates a role
|
||||||
@@ -69,10 +69,10 @@ func handleUpdateRole(r *fastglue.Request) error {
|
|||||||
req = models.Role{}
|
req = models.Role{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err := app.role.Update(id, req);err != nil {
|
if err := app.role.Update(id, req); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Role updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/abhinavxd/libredesk/internal/envelope"
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
@@ -11,52 +13,45 @@ const (
|
|||||||
|
|
||||||
// handleSearchConversations searches conversations based on the query.
|
// handleSearchConversations searches conversations based on the query.
|
||||||
func handleSearchConversations(r *fastglue.Request) error {
|
func handleSearchConversations(r *fastglue.Request) error {
|
||||||
var (
|
app := r.Context.(*App)
|
||||||
app = r.Context.(*App)
|
wrapper := func(query string) (interface{}, error) {
|
||||||
q = string(r.RequestCtx.QueryArgs().Peek("query"))
|
return app.search.Conversations(query)
|
||||||
)
|
|
||||||
|
|
||||||
if len(q) < minSearchQueryLength {
|
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, "Query length should be at least 3 characters", nil))
|
|
||||||
}
|
}
|
||||||
|
return handleSearch(r, wrapper)
|
||||||
conversations, err := app.search.Conversations(q)
|
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
|
||||||
}
|
|
||||||
return r.SendEnvelope(conversations)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleSearchMessages searches messages based on the query.
|
// handleSearchMessages searches messages based on the query.
|
||||||
func handleSearchMessages(r *fastglue.Request) error {
|
func handleSearchMessages(r *fastglue.Request) error {
|
||||||
var (
|
app := r.Context.(*App)
|
||||||
app = r.Context.(*App)
|
wrapper := func(query string) (interface{}, error) {
|
||||||
q = string(r.RequestCtx.QueryArgs().Peek("query"))
|
return app.search.Messages(query)
|
||||||
)
|
|
||||||
|
|
||||||
if len(q) < minSearchQueryLength {
|
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, "Query length should be at least 3 characters", nil))
|
|
||||||
}
|
}
|
||||||
|
return handleSearch(r, wrapper)
|
||||||
messages, err := app.search.Messages(q)
|
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
|
||||||
}
|
|
||||||
return r.SendEnvelope(messages)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleSearchContacts searches contacts based on the query.
|
// handleSearchContacts searches contacts based on the query.
|
||||||
func handleSearchContacts(r *fastglue.Request) error {
|
func handleSearchContacts(r *fastglue.Request) error {
|
||||||
|
app := r.Context.(*App)
|
||||||
|
wrapper := func(query string) (interface{}, error) {
|
||||||
|
return app.search.Contacts(query)
|
||||||
|
}
|
||||||
|
return handleSearch(r, wrapper)
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleSearch searches for the given query using the provided search function.
|
||||||
|
func handleSearch(r *fastglue.Request, searchFunc func(string) (interface{}, error)) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
q = string(r.RequestCtx.QueryArgs().Peek("query"))
|
q = string(r.RequestCtx.QueryArgs().Peek("query"))
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(q) < minSearchQueryLength {
|
if len(q) < minSearchQueryLength {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, "Query length should be at least 3 characters", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.InputError, app.i18n.Ts("search.minQueryLength", "length", fmt.Sprintf("%d", minSearchQueryLength)), nil))
|
||||||
}
|
}
|
||||||
contacts, err := app.search.Contacts(q)
|
|
||||||
|
results, err := searchFunc(q)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(contacts)
|
return r.SendEnvelope(results)
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
|
|
||||||
// handleGetGeneralSettings fetches general settings.
|
// handleGetGeneralSettings fetches general settings, this endpoint is not behind auth as it has no sensitive data and is required for the app to function.
|
||||||
func handleGetGeneralSettings(r *fastglue.Request) error {
|
func handleGetGeneralSettings(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
@@ -25,7 +25,7 @@ func handleGetGeneralSettings(r *fastglue.Request) error {
|
|||||||
var settings map[string]interface{}
|
var settings map[string]interface{}
|
||||||
if err := json.Unmarshal(out, &settings); err != nil {
|
if err := json.Unmarshal(out, &settings); err != nil {
|
||||||
app.lo.Error("error unmarshalling settings", "err", err)
|
app.lo.Error("error unmarshalling settings", "err", err)
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "Error fetching settings", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorFetching", "name", app.i18n.T("globals.terms.setting")), nil))
|
||||||
}
|
}
|
||||||
// Set the app.update to the settings, adding `app` prefix to the key to match the settings structure in db.
|
// Set the app.update to the settings, adding `app` prefix to the key to match the settings structure in db.
|
||||||
settings["app.update"] = app.update
|
settings["app.update"] = app.update
|
||||||
@@ -42,20 +42,23 @@ func handleUpdateGeneralSettings(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Bad request", nil, "")
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("globals.messages.badRequest"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove any trailing slash `/` from the root url.
|
||||||
|
req.RootURL = strings.TrimRight(req.RootURL, "/")
|
||||||
|
|
||||||
if err := app.setting.Update(req); err != nil {
|
if err := app.setting.Update(req); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
// Reload the settings and templates.
|
// Reload the settings and templates.
|
||||||
if err := reloadSettings(app); err != nil {
|
if err := reloadSettings(app); err != nil {
|
||||||
return envelope.NewError(envelope.GeneralError, "Could not reload settings, Please restart the app.", nil)
|
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.couldNotReload", "name", app.i18n.T("globals.terms.setting")), nil)
|
||||||
}
|
}
|
||||||
if err := reloadTemplates(app); err != nil {
|
if err := reloadTemplates(app); err != nil {
|
||||||
return envelope.NewError(envelope.GeneralError, "Could not reload settings, Please restart the app.", nil)
|
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.couldNotReload", "name", app.i18n.T("globals.terms.setting")), nil)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Settings updated successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetEmailNotificationSettings fetches email notification settings.
|
// handleGetEmailNotificationSettings fetches email notification settings.
|
||||||
@@ -72,7 +75,7 @@ func handleGetEmailNotificationSettings(r *fastglue.Request) error {
|
|||||||
|
|
||||||
// Unmarshal and filter out password.
|
// Unmarshal and filter out password.
|
||||||
if err := json.Unmarshal(out, ¬if); err != nil {
|
if err := json.Unmarshal(out, ¬if); err != nil {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "Error fetching settings", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorFetching", "name", app.i18n.T("globals.terms.setting")), nil))
|
||||||
}
|
}
|
||||||
if notif.Password != "" {
|
if notif.Password != "" {
|
||||||
notif.Password = strings.Repeat(stringutil.PasswordDummy, 10)
|
notif.Password = strings.Repeat(stringutil.PasswordDummy, 10)
|
||||||
@@ -89,7 +92,7 @@ func handleUpdateEmailNotificationSettings(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Bad request", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("globals.messages.badRequest"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := app.setting.GetByPrefix("notification.email")
|
out, err := app.setting.GetByPrefix("notification.email")
|
||||||
@@ -98,12 +101,12 @@ func handleUpdateEmailNotificationSettings(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(out, &cur); err != nil {
|
if err := json.Unmarshal(out, &cur); err != nil {
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "Error updating settings", nil))
|
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorUpdating", "name", app.i18n.T("globals.terms.setting")), nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure it's a valid from email address.
|
// Make sure it's a valid from email address.
|
||||||
if _, err := mail.ParseAddress(req.EmailAddress); err != nil {
|
if _, err := mail.ParseAddress(req.EmailAddress); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid from email address format", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("globals.messages.invalidFromAddress"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Password == "" {
|
if req.Password == "" {
|
||||||
@@ -115,5 +118,5 @@ func handleUpdateEmailNotificationSettings(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No reload implemented, so user has to restart the app.
|
// No reload implemented, so user has to restart the app.
|
||||||
return r.SendEnvelope("Settings updated successfully, Please restart the app for changes to take effect.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|||||||
124
cmd/sla.go
124
cmd/sla.go
@@ -5,10 +5,12 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/abhinavxd/libredesk/internal/envelope"
|
"github.com/abhinavxd/libredesk/internal/envelope"
|
||||||
|
smodels "github.com/abhinavxd/libredesk/internal/sla/models"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// handleGetSLAs returns all SLAs.
|
||||||
func handleGetSLAs(r *fastglue.Request) error {
|
func handleGetSLAs(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
@@ -20,50 +22,80 @@ func handleGetSLAs(r *fastglue.Request) error {
|
|||||||
return r.SendEnvelope(slas)
|
return r.SendEnvelope(slas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleGetSLA returns the SLA with the given ID.
|
||||||
func handleGetSLA(r *fastglue.Request) error {
|
func handleGetSLA(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid SLA `id`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "SLA `id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
sla, err := app.sla.Get(id)
|
sla, err := app.sla.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, "")
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(sla)
|
return r.SendEnvelope(sla)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleCreateSLA creates a new SLA.
|
||||||
func handleCreateSLA(r *fastglue.Request) error {
|
func handleCreateSLA(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
name = string(r.RequestCtx.PostArgs().Peek("name"))
|
sla smodels.SLAPolicy
|
||||||
desc = string(r.RequestCtx.PostArgs().Peek("description"))
|
|
||||||
firstRespTime = string(r.RequestCtx.PostArgs().Peek("first_response_time"))
|
|
||||||
resTime = string(r.RequestCtx.PostArgs().Peek("resolution_time"))
|
|
||||||
)
|
)
|
||||||
// Validate time duration strings
|
|
||||||
if _, err := time.ParseDuration(firstRespTime); err != nil {
|
if err := r.Decode(&sla, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `first_response_time` duration.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
if _, err := time.ParseDuration(resTime); err != nil {
|
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `resolution_time` duration.", nil, envelope.InputError)
|
if err := validateSLA(app, &sla); err != nil {
|
||||||
}
|
|
||||||
if err := app.sla.Create(name, desc, firstRespTime, resTime); err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := app.sla.Create(sla.Name, sla.Description, sla.FirstResponseTime, sla.ResolutionTime, sla.Notifications); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
return r.SendEnvelope("SLA created successfully.")
|
return r.SendEnvelope("SLA created successfully.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleUpdateSLA updates the SLA with the given ID.
|
||||||
|
func handleUpdateSLA(r *fastglue.Request) error {
|
||||||
|
var (
|
||||||
|
app = r.Context.(*App)
|
||||||
|
sla smodels.SLAPolicy
|
||||||
|
)
|
||||||
|
|
||||||
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
if err != nil || id == 0 {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "SLA `id`"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := r.Decode(&sla, "json"); err != nil {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := validateSLA(app, &sla); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.sla.Update(id, sla.Name, sla.Description, sla.FirstResponseTime, sla.ResolutionTime, sla.Notifications); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.SendEnvelope("SLA updated successfully.")
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleDeleteSLA deletes the SLA with the given ID.
|
||||||
func handleDeleteSLA(r *fastglue.Request) error {
|
func handleDeleteSLA(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid SLA `id`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "SLA `id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.sla.Delete(id); err != nil {
|
if err = app.sla.Delete(id); err != nil {
|
||||||
@@ -73,31 +105,55 @@ func handleDeleteSLA(r *fastglue.Request) error {
|
|||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleUpdateSLA(r *fastglue.Request) error {
|
// validateSLA validates the SLA policy and returns an envelope.Error if any validation fails.
|
||||||
var (
|
func validateSLA(app *App, sla *smodels.SLAPolicy) error {
|
||||||
app = r.Context.(*App)
|
if sla.Name == "" {
|
||||||
name = string(r.RequestCtx.PostArgs().Peek("name"))
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "SLA `name`"), nil)
|
||||||
desc = string(r.RequestCtx.PostArgs().Peek("description"))
|
}
|
||||||
firstRespTime = string(r.RequestCtx.PostArgs().Peek("first_response_time"))
|
if sla.FirstResponseTime == "" {
|
||||||
resTime = string(r.RequestCtx.PostArgs().Peek("resolution_time"))
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "SLA `first_response_time`"), nil)
|
||||||
)
|
}
|
||||||
|
if sla.ResolutionTime == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "SLA `resolution_time`"), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate notifications if any
|
||||||
|
for _, n := range sla.Notifications {
|
||||||
|
if n.Type == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "SLA notification `type`"), nil)
|
||||||
|
}
|
||||||
|
if n.TimeDelayType == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "SLA notification `time_delay_type`"), nil)
|
||||||
|
}
|
||||||
|
if n.TimeDelayType != "immediately" {
|
||||||
|
if n.TimeDelay == "" {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "SLA notification `time_delay`"), nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(n.Recipients) == 0 {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.empty", "name", "SLA notification `recipients`"), nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Validate time duration strings
|
// Validate time duration strings
|
||||||
if _, err := time.ParseDuration(firstRespTime); err != nil {
|
frt, err := time.ParseDuration(sla.FirstResponseTime)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `first_response_time` duration.", nil, envelope.InputError)
|
if err != nil {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`first_response_time`"), nil)
|
||||||
}
|
}
|
||||||
if _, err := time.ParseDuration(resTime); err != nil {
|
if frt.Minutes() < 1 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `resolution_time` duration.", nil, envelope.InputError)
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`first_response_time`"), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
rt, err := time.ParseDuration(sla.ResolutionTime)
|
||||||
if err != nil || id == 0 {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid SLA `id`.", nil, envelope.InputError)
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`resolution_time`"), nil)
|
||||||
|
}
|
||||||
|
if rt.Minutes() < 1 {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.Ts("globals.messages.invalid", "name", "`resolution_time`"), nil)
|
||||||
|
}
|
||||||
|
if frt > rt {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.T("sla.firstResponseTimeAfterResolution"), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.sla.Update(id, name, desc, firstRespTime, resTime); err != nil {
|
return nil
|
||||||
return sendErrorEnvelope(r, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ func handleCreateStatus(r *fastglue.Request) error {
|
|||||||
status = cmodels.Status{}
|
status = cmodels.Status{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&status, "json"); err != nil {
|
if err := r.Decode(&status, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.Name == "" {
|
if status.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty status `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := app.status.Create(status.Name)
|
err := app.status.Create(status.Name)
|
||||||
@@ -46,20 +46,13 @@ func handleDeleteStatus(r *fastglue.Request) error {
|
|||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id <= 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid status `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if id <= 0 {
|
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty status `ID`", nil, envelope.InputError)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = app.status.Delete(id)
|
err = app.status.Delete(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,16 +63,15 @@ func handleUpdateStatus(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid status `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&status, "json"); err != nil {
|
if err := r.Decode(&status, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.Name == "" {
|
if status.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty status `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.status.Update(id, status.Name)
|
err = app.status.Update(id, status.Name)
|
||||||
|
|||||||
37
cmd/tags.go
37
cmd/tags.go
@@ -9,81 +9,76 @@ import (
|
|||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// handleGetTags returns all tags from the database.
|
||||||
func handleGetTags(r *fastglue.Request) error {
|
func handleGetTags(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
t, err := app.tag.GetAll()
|
t, err := app.tag.GetAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, "")
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(t)
|
return r.SendEnvelope(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleCreateTag creates a new tag in the database.
|
||||||
func handleCreateTag(r *fastglue.Request) error {
|
func handleCreateTag(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
tag = tmodels.Tag{}
|
tag = tmodels.Tag{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&tag, "json"); err != nil {
|
if err := r.Decode(&tag, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tag.Name == "" {
|
if tag.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty tag `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := app.tag.Create(tag.Name)
|
if err := app.tag.Create(tag.Name); err != nil {
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleDeleteTag deletes a tag from the database.
|
||||||
func handleDeleteTag(r *fastglue.Request) error {
|
func handleDeleteTag(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id <= 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid tag `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if id <= 0 {
|
if err = app.tag.Delete(id); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty tag `ID`", nil, envelope.InputError)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = app.tag.Delete(id)
|
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handleUpdateTag updates an existing tag in the database.
|
||||||
func handleUpdateTag(r *fastglue.Request) error {
|
func handleUpdateTag(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
tag = tmodels.Tag{}
|
tag = tmodels.Tag{}
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id <= 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid tag `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&tag, "json"); err != nil {
|
if err := r.Decode(&tag, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if tag.Name == "" {
|
if tag.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty tag `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = app.tag.Update(id, tag.Name)
|
if err = app.tag.Update(id, tag.Name); err != nil {
|
||||||
if err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
cmd/teams.go
11
cmd/teams.go
@@ -40,7 +40,7 @@ func handleGetTeam(r *fastglue.Request) error {
|
|||||||
id, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, _ = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
)
|
)
|
||||||
if id < 1 {
|
if id < 1 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid team `id`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
team, err := app.team.Get(id)
|
team, err := app.team.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -64,7 +64,7 @@ func handleCreateTeam(r *fastglue.Request) error {
|
|||||||
if err := app.team.Create(name, timezone, conversationAssignmentType, null.NewInt(businessHrsID, businessHrsID != 0), null.NewInt(slaPolicyID, slaPolicyID != 0), emoji, maxAutoAssignedConversations); err != nil {
|
if err := app.team.Create(name, timezone, conversationAssignmentType, null.NewInt(businessHrsID, businessHrsID != 0), null.NewInt(slaPolicyID, slaPolicyID != 0), emoji, maxAutoAssignedConversations); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Team created successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateTeam updates an existing team.
|
// handleUpdateTeam updates an existing team.
|
||||||
@@ -86,7 +86,7 @@ func handleUpdateTeam(r *fastglue.Request) error {
|
|||||||
if err := app.team.Update(id, name, timezone, conversationAssignmentType, null.NewInt(businessHrsID, businessHrsID != 0), null.NewInt(slaPolicyID, slaPolicyID != 0), emoji, maxAutoAssignedConversations); err != nil {
|
if err := app.team.Update(id, name, timezone, conversationAssignmentType, null.NewInt(businessHrsID, businessHrsID != 0), null.NewInt(slaPolicyID, slaPolicyID != 0), emoji, maxAutoAssignedConversations); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Team updated successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleDeleteTeam deletes a team
|
// handleDeleteTeam deletes a team
|
||||||
@@ -96,12 +96,11 @@ func handleDeleteTeam(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid team `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
err = app.team.Delete(id)
|
err = app.team.Delete(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Team deleted successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func handleGetTemplates(r *fastglue.Request) error {
|
|||||||
typ = string(r.RequestCtx.QueryArgs().Peek("type"))
|
typ = string(r.RequestCtx.QueryArgs().Peek("type"))
|
||||||
)
|
)
|
||||||
if typ == "" {
|
if typ == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Invalid `type`.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`type`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
t, err := app.tmpl.GetAll(typ)
|
t, err := app.tmpl.GetAll(typ)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -32,8 +32,7 @@ func handleGetTemplate(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid template `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
t, err := app.tmpl.Get(id)
|
t, err := app.tmpl.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -49,7 +48,10 @@ func handleCreateTemplate(r *fastglue.Request) error {
|
|||||||
req = models.Template{}
|
req = models.Template{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Bad request", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if req.Name == "" {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err := app.tmpl.Create(req); err != nil {
|
if err := app.tmpl.Create(req); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
@@ -69,7 +71,10 @@ func handleUpdateTemplate(r *fastglue.Request) error {
|
|||||||
"Invalid template `id`.", nil, envelope.InputError)
|
"Invalid template `id`.", nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Bad request", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
|
}
|
||||||
|
if req.Name == "" {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err = app.tmpl.Update(id, req); err != nil {
|
if err = app.tmpl.Update(id, req); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
@@ -89,7 +94,7 @@ func handleDeleteTemplate(r *fastglue.Request) error {
|
|||||||
"Invalid template `id`.", nil, envelope.InputError)
|
"Invalid template `id`.", nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err := r.Decode(&req, "json"); err != nil {
|
if err := r.Decode(&req, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Bad request", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
if err = app.tmpl.Delete(id); err != nil {
|
if err = app.tmpl.Delete(id); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ type migFunc struct {
|
|||||||
var migList = []migFunc{
|
var migList = []migFunc{
|
||||||
{"v0.3.0", migrations.V0_3_0},
|
{"v0.3.0", migrations.V0_3_0},
|
||||||
{"v0.4.0", migrations.V0_4_0},
|
{"v0.4.0", migrations.V0_4_0},
|
||||||
|
{"v0.5.0", migrations.V0_5_0},
|
||||||
|
{"v0.6.0", migrations.V0_6_0},
|
||||||
}
|
}
|
||||||
|
|
||||||
// upgrade upgrades the database to the current version by running SQL migration files
|
// upgrade upgrades the database to the current version by running SQL migration files
|
||||||
|
|||||||
316
cmd/users.go
316
cmd/users.go
@@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"mime/multipart"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -16,92 +16,101 @@ import (
|
|||||||
"github.com/abhinavxd/libredesk/internal/stringutil"
|
"github.com/abhinavxd/libredesk/internal/stringutil"
|
||||||
tmpl "github.com/abhinavxd/libredesk/internal/template"
|
tmpl "github.com/abhinavxd/libredesk/internal/template"
|
||||||
"github.com/abhinavxd/libredesk/internal/user/models"
|
"github.com/abhinavxd/libredesk/internal/user/models"
|
||||||
|
realip "github.com/ferluci/fast-realip"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
"github.com/volatiletech/null/v9"
|
"github.com/volatiletech/null/v9"
|
||||||
"github.com/zerodha/fastglue"
|
"github.com/zerodha/fastglue"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
maxAvatarSizeMB = 20
|
maxAvatarSizeMB = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// handleGetUsers returns all users.
|
// handleGetAgents returns all agents.
|
||||||
func handleGetUsers(r *fastglue.Request) error {
|
func handleGetAgents(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
agents, err := app.user.GetAll()
|
agents, err := app.user.GetAgents()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, "")
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(agents)
|
return r.SendEnvelope(agents)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetUsersCompact returns all users in a compact format.
|
// handleGetAgentsCompact returns all agents in a compact format.
|
||||||
func handleGetUsersCompact(r *fastglue.Request) error {
|
func handleGetAgentsCompact(r *fastglue.Request) error {
|
||||||
var app = r.Context.(*App)
|
var app = r.Context.(*App)
|
||||||
agents, err := app.user.GetAllCompact()
|
agents, err := app.user.GetAgentsCompact()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, err.Error(), nil, "")
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(agents)
|
return r.SendEnvelope(agents)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetUser returns a user.
|
// handleGetAgent returns an agent.
|
||||||
func handleGetUser(r *fastglue.Request) error {
|
func handleGetAgent(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id <= 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid user `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
user, err := app.user.GetAgent(id)
|
agent, err := app.user.GetAgent(id, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(user)
|
return r.SendEnvelope(agent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateUserAvailability updates the current user availability.
|
// handleUpdateAgentAvailability updates the current agent availability.
|
||||||
func handleUpdateUserAvailability(r *fastglue.Request) error {
|
func handleUpdateAgentAvailability(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
status = string(r.RequestCtx.PostArgs().Peek("status"))
|
status = string(r.RequestCtx.PostArgs().Peek("status"))
|
||||||
|
ip = realip.FromRequest(r.RequestCtx)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Update availability status.
|
||||||
if err := app.user.UpdateAvailability(auser.ID, status); err != nil {
|
if err := app.user.UpdateAvailability(auser.ID, status); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("User availability updated successfully.")
|
|
||||||
|
// Create activity log.
|
||||||
|
if err := app.activityLog.UserAvailability(auser.ID, auser.Email, status, ip, "", 0); err != nil {
|
||||||
|
app.lo.Error("error creating activity log", "error", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetCurrentUserTeams returns the teams of a user.
|
// handleGetCurrentAgentTeams returns the teams of an agent.
|
||||||
func handleGetCurrentUserTeams(r *fastglue.Request) error {
|
func handleGetCurrentAgentTeams(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
agent, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
teams, err := app.team.GetUserTeams(user.ID)
|
teams, err := app.team.GetUserTeams(agent.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(teams)
|
return r.SendEnvelope(teams)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateCurrentUser updates the current user.
|
// handleUpdateCurrentAgent updates the current agent.
|
||||||
func handleUpdateCurrentUser(r *fastglue.Request) error {
|
func handleUpdateCurrentAgent(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
agent, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -109,94 +118,40 @@ func handleUpdateCurrentUser(r *fastglue.Request) error {
|
|||||||
form, err := r.RequestCtx.MultipartForm()
|
form, err := r.RequestCtx.MultipartForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error parsing form data", "error", err)
|
app.lo.Error("error parsing form data", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error parsing data", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
files, ok := form.File["files"]
|
files, ok := form.File["files"]
|
||||||
|
|
||||||
// Upload avatar?
|
// Upload avatar?
|
||||||
if ok && len(files) > 0 {
|
if ok && len(files) > 0 {
|
||||||
fileHeader := files[0]
|
if err := uploadUserAvatar(r, &agent, files); err != nil {
|
||||||
file, err := fileHeader.Open()
|
|
||||||
if err != nil {
|
|
||||||
app.lo.Error("error reading uploaded", "error", err)
|
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error reading file", nil, envelope.GeneralError)
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
// Sanitize filename.
|
|
||||||
srcFileName := stringutil.SanitizeFilename(fileHeader.Filename)
|
|
||||||
srcContentType := fileHeader.Header.Get("Content-Type")
|
|
||||||
srcFileSize := fileHeader.Size
|
|
||||||
srcExt := strings.TrimPrefix(strings.ToLower(filepath.Ext(srcFileName)), ".")
|
|
||||||
|
|
||||||
if !slices.Contains(image.Exts, srcExt) {
|
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "File type is not an image", nil, envelope.InputError)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check file size
|
|
||||||
if bytesToMegabytes(srcFileSize) > maxAvatarSizeMB {
|
|
||||||
app.lo.Error("error uploaded file size is larger than max allowed", "size", bytesToMegabytes(srcFileSize), "max_allowed", maxAvatarSizeMB)
|
|
||||||
return r.SendErrorEnvelope(
|
|
||||||
http.StatusRequestEntityTooLarge,
|
|
||||||
fmt.Sprintf("File size is too large. Please upload file lesser than %d MB", maxAvatarSizeMB),
|
|
||||||
nil,
|
|
||||||
envelope.GeneralError,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset ptr.
|
|
||||||
file.Seek(0, 0)
|
|
||||||
linkedModel := null.StringFrom(mmodels.ModelUser)
|
|
||||||
linkedID := null.IntFrom(user.ID)
|
|
||||||
disposition := null.NewString("", false)
|
|
||||||
contentID := ""
|
|
||||||
meta := []byte("{}")
|
|
||||||
media, err := app.media.UploadAndInsert(srcFileName, srcContentType, contentID, linkedModel, linkedID, file, int(srcFileSize), disposition, meta)
|
|
||||||
if err != nil {
|
|
||||||
app.lo.Error("error uploading file", "error", err)
|
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error uploading file", nil, envelope.GeneralError)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete current avatar.
|
|
||||||
if user.AvatarURL.Valid {
|
|
||||||
fileName := filepath.Base(user.AvatarURL.String)
|
|
||||||
app.media.Delete(fileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save file path.
|
|
||||||
path, err := stringutil.GetPathFromURL(media.URL)
|
|
||||||
if err != nil {
|
|
||||||
app.lo.Debug("error getting path from URL", "url", media.URL, "error", err)
|
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error uploading file", nil, envelope.GeneralError)
|
|
||||||
}
|
|
||||||
if err := app.user.UpdateAvatar(user.ID, path); err != nil {
|
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("User updated successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleCreateUser creates a new user.
|
// handleCreateAgent creates a new agent.
|
||||||
func handleCreateUser(r *fastglue.Request) error {
|
func handleCreateAgent(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
user = models.User{}
|
user = models.User{}
|
||||||
)
|
)
|
||||||
if err := r.Decode(&user, "json"); err != nil {
|
if err := r.Decode(&user, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Email.String == "" {
|
if user.Email.String == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty `email`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`email`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Roles == nil {
|
if user.Roles == nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Please select at least one role", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`role`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.FirstName == "" {
|
if user.FirstName == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty `first_name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`first_name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Right now, only agents can be created.
|
// Right now, only agents can be created.
|
||||||
@@ -205,9 +160,11 @@ func handleCreateUser(r *fastglue.Request) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Upsert user teams.
|
// Upsert user teams.
|
||||||
|
if len(user.Teams) > 0 {
|
||||||
if err := app.team.UpsertUserTeams(user.ID, user.Teams.Names()); err != nil {
|
if err := app.team.UpsertUserTeams(user.ID, user.Teams.Names()); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if user.SendWelcomeEmail {
|
if user.SendWelcomeEmail {
|
||||||
// Generate reset token.
|
// Generate reset token.
|
||||||
@@ -223,76 +180,95 @@ func handleCreateUser(r *fastglue.Request) error {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error rendering template", "error", err)
|
app.lo.Error("error rendering template", "error", err)
|
||||||
return r.SendEnvelope("User created successfully, but error rendering welcome email.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.notifier.Send(notifier.Message{
|
if err := app.notifier.Send(notifier.Message{
|
||||||
UserIDs: []int{user.ID},
|
RecipientEmails: []string{user.Email.String},
|
||||||
Subject: "Welcome",
|
Subject: "Welcome to Libredesk",
|
||||||
Content: content,
|
Content: content,
|
||||||
Provider: notifier.ProviderEmail,
|
Provider: notifier.ProviderEmail,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
app.lo.Error("error sending notification message", "error", err)
|
app.lo.Error("error sending notification message", "error", err)
|
||||||
return sendErrorEnvelope(r, envelope.NewError(envelope.GeneralError, "User created successfully, but could not send welcome email.", nil))
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("User created successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateUser updates a user.
|
// handleUpdateAgent updates an agent.
|
||||||
func handleUpdateUser(r *fastglue.Request) error {
|
func handleUpdateAgent(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
user = models.User{}
|
user = models.User{}
|
||||||
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
|
ip = realip.FromRequest(r.RequestCtx)
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid user `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&user, "json"); err != nil {
|
if err := r.Decode(&user, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Email.String == "" {
|
if user.Email.String == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty `email`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`email`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Roles == nil {
|
if user.Roles == nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Please select at least one role", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`role`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.FirstName == "" {
|
if user.FirstName == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty `first_name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`first_name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update user.
|
agent, err := app.user.GetAgent(id, "")
|
||||||
if err = app.user.Update(id, user); err != nil {
|
if err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
oldAvailabilityStatus := agent.AvailabilityStatus
|
||||||
|
|
||||||
|
// Update agent.
|
||||||
|
if err = app.user.UpdateAgent(id, user); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upsert user teams.
|
// Create activity log if user availability status changed.
|
||||||
|
if oldAvailabilityStatus != user.AvailabilityStatus {
|
||||||
|
if err := app.activityLog.UserAvailability(auser.ID, auser.Email, user.AvailabilityStatus, ip, user.Email.String, id); err != nil {
|
||||||
|
app.lo.Error("error creating activity log", "error", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Upsert agent teams.
|
||||||
if err := app.team.UpsertUserTeams(id, user.Teams.Names()); err != nil {
|
if err := app.team.UpsertUserTeams(id, user.Teams.Names()); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope("User updated successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleDeleteUser soft deletes a user.
|
// handleDeleteAgent soft deletes an agent.
|
||||||
func handleDeleteUser(r *fastglue.Request) error {
|
func handleDeleteAgent(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err = strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "{globals.terms.user} `id`"), nil, envelope.InputError)
|
||||||
"Invalid user `id`.", nil, envelope.InputError)
|
}
|
||||||
|
|
||||||
|
// Disallow if self-deleting.
|
||||||
|
if id == auser.ID {
|
||||||
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("user.userCannotDeleteSelf"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Soft delete user.
|
// Soft delete user.
|
||||||
if err = app.user.SoftDelete(id); err != nil {
|
if err = app.user.SoftDeleteAgent(id); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,54 +277,54 @@ func handleDeleteUser(r *fastglue.Request) error {
|
|||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope("User deleted successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetCurrentUser returns the current logged in user.
|
// handleGetCurrentAgent returns the current logged in agent.
|
||||||
func handleGetCurrentUser(r *fastglue.Request) error {
|
func handleGetCurrentAgent(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
u, err := app.user.GetAgent(auser.ID)
|
u, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope(u)
|
return r.SendEnvelope(u)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleDeleteAvatar deletes a user avatar.
|
// handleDeleteCurrentAgentAvatar deletes the current agent's avatar.
|
||||||
func handleDeleteAvatar(r *fastglue.Request) error {
|
func handleDeleteCurrentAgentAvatar(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Get user
|
// Get user
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
agent, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valid str?
|
// Valid str?
|
||||||
if user.AvatarURL.String == "" {
|
if agent.AvatarURL.String == "" {
|
||||||
return r.SendEnvelope("Avatar deleted successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := filepath.Base(user.AvatarURL.String)
|
fileName := filepath.Base(agent.AvatarURL.String)
|
||||||
|
|
||||||
// Delete file from the store.
|
// Delete file from the store.
|
||||||
if err := app.media.Delete(fileName); err != nil {
|
if err := app.media.Delete(fileName); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.user.UpdateAvatar(user.ID, ""); err != nil {
|
if err = app.user.UpdateAvatar(agent.ID, ""); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("Avatar deleted successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleResetPassword generates a reset password token and sends an email to the user.
|
// handleResetPassword generates a reset password token and sends an email to the agent.
|
||||||
func handleResetPassword(r *fastglue.Request) error {
|
func handleResetPassword(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
@@ -357,20 +333,20 @@ func handleResetPassword(r *fastglue.Request) error {
|
|||||||
email = string(p.Peek("email"))
|
email = string(p.Peek("email"))
|
||||||
)
|
)
|
||||||
if ok && auser.ID > 0 {
|
if ok && auser.ID > 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "User is already logged in, Please logout to reset password.", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("user.userAlreadyLoggedIn"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if email == "" {
|
if email == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty `email`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`email`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := app.user.GetAgentByEmail(email)
|
agent, err := app.user.GetAgent(0, email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Send 200 even if user not found, to prevent email enumeration.
|
// Send 200 even if user not found, to prevent email enumeration.
|
||||||
return r.SendEnvelope("Reset password email sent successfully.")
|
return r.SendEnvelope("Reset password email sent successfully.")
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := app.user.SetResetPasswordToken(user.ID)
|
token, err := app.user.SetResetPasswordToken(agent.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -381,43 +357,107 @@ func handleResetPassword(r *fastglue.Request) error {
|
|||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.lo.Error("error rendering template", "error", err)
|
app.lo.Error("error rendering template", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error rendering template", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.T("globals.messages.errorSendingPasswordResetEmail"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.notifier.Send(notifier.Message{
|
if err := app.notifier.Send(notifier.Message{
|
||||||
UserIDs: []int{user.ID},
|
RecipientEmails: []string{agent.Email.String},
|
||||||
Subject: "Reset Password",
|
Subject: "Reset Password",
|
||||||
Content: content,
|
Content: content,
|
||||||
Provider: notifier.ProviderEmail,
|
Provider: notifier.ProviderEmail,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
app.lo.Error("error sending password reset email", "error", err)
|
app.lo.Error("error sending password reset email", "error", err)
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, "Error sending password reset email", nil, envelope.GeneralError)
|
return r.SendErrorEnvelope(fasthttp.StatusInternalServerError, app.i18n.T("globals.messages.errorSendingPasswordResetEmail"), nil, envelope.GeneralError)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope("Reset password email sent successfully.")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleSetPassword resets the password with the provided token.
|
// handleSetPassword resets the password with the provided token.
|
||||||
func handleSetPassword(r *fastglue.Request) error {
|
func handleSetPassword(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
user, ok = r.RequestCtx.UserValue("user").(amodels.User)
|
agent, ok = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
p = r.RequestCtx.PostArgs()
|
p = r.RequestCtx.PostArgs()
|
||||||
password = string(p.Peek("password"))
|
password = string(p.Peek("password"))
|
||||||
token = string(p.Peek("token"))
|
token = string(p.Peek("token"))
|
||||||
)
|
)
|
||||||
|
|
||||||
if ok && user.ID > 0 {
|
if ok && agent.ID > 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "User is already logged in", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.T("user.userAlreadyLoggedIn"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if password == "" {
|
if password == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty `password`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "{globals.terms.password}"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.user.ResetPassword(token, password); err != nil {
|
if err := app.user.ResetPassword(token, password); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope("Password reset successfully.")
|
return r.SendEnvelope(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// uploadUserAvatar uploads the user avatar.
|
||||||
|
func uploadUserAvatar(r *fastglue.Request, user *models.User, files []*multipart.FileHeader) error {
|
||||||
|
var app = r.Context.(*App)
|
||||||
|
|
||||||
|
fileHeader := files[0]
|
||||||
|
file, err := fileHeader.Open()
|
||||||
|
if err != nil {
|
||||||
|
app.lo.Error("error opening uploaded file", "error", err)
|
||||||
|
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorReading", "name", "{globals.terms.file}"), nil)
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
// Sanitize filename.
|
||||||
|
srcFileName := stringutil.SanitizeFilename(fileHeader.Filename)
|
||||||
|
srcContentType := fileHeader.Header.Get("Content-Type")
|
||||||
|
srcFileSize := fileHeader.Size
|
||||||
|
srcExt := strings.TrimPrefix(strings.ToLower(filepath.Ext(srcFileName)), ".")
|
||||||
|
|
||||||
|
if !slices.Contains(image.Exts, srcExt) {
|
||||||
|
return envelope.NewError(envelope.InputError, app.i18n.T("globals.messages.fileTypeisNotAnImage"), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check file size
|
||||||
|
if bytesToMegabytes(srcFileSize) > maxAvatarSizeMB {
|
||||||
|
app.lo.Error("error uploaded file size is larger than max allowed", "size", bytesToMegabytes(srcFileSize), "max_allowed", maxAvatarSizeMB)
|
||||||
|
return envelope.NewError(
|
||||||
|
envelope.InputError,
|
||||||
|
app.i18n.Ts("media.fileSizeTooLarge", "size", fmt.Sprintf("%dMB", maxAvatarSizeMB)),
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset ptr.
|
||||||
|
file.Seek(0, 0)
|
||||||
|
linkedModel := null.StringFrom(mmodels.ModelUser)
|
||||||
|
linkedID := null.IntFrom(user.ID)
|
||||||
|
disposition := null.NewString("", false)
|
||||||
|
contentID := ""
|
||||||
|
meta := []byte("{}")
|
||||||
|
media, err := app.media.UploadAndInsert(srcFileName, srcContentType, contentID, linkedModel, linkedID, file, int(srcFileSize), disposition, meta)
|
||||||
|
if err != nil {
|
||||||
|
app.lo.Error("error uploading file", "error", err)
|
||||||
|
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorUploading", "name", "{globals.terms.file}"), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete current avatar.
|
||||||
|
if user.AvatarURL.Valid {
|
||||||
|
fileName := filepath.Base(user.AvatarURL.String)
|
||||||
|
app.media.Delete(fileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save file path.
|
||||||
|
path, err := stringutil.GetPathFromURL(media.URL)
|
||||||
|
if err != nil {
|
||||||
|
app.lo.Debug("error getting path from URL", "url", media.URL, "error", err)
|
||||||
|
return envelope.NewError(envelope.GeneralError, app.i18n.Ts("globals.messages.errorUploading", "name", "{globals.terms.file}"), nil)
|
||||||
|
}
|
||||||
|
fmt.Println("path", path)
|
||||||
|
if err := app.user.UpdateAvatar(user.ID, path); err != nil {
|
||||||
|
return sendErrorEnvelope(r, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
57
cmd/views.go
57
cmd/views.go
@@ -16,7 +16,7 @@ func handleGetUserViews(r *fastglue.Request) error {
|
|||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
@@ -35,61 +35,49 @@ func handleCreateUserView(r *fastglue.Request) error {
|
|||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
if err := r.Decode(&view, "json"); err != nil {
|
if err := r.Decode(&view, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
if view.Name == "" {
|
if view.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty view `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`Name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if string(view.Filters) == "" {
|
if string(view.Filters) == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Please provide at least one filter", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`Filters`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.view.Create(view.Name, view.Filters, user.ID); err != nil {
|
if err := app.view.Create(view.Name, view.Filters, user.ID); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
return r.SendEnvelope("View created successfully")
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleGetUserView deletes a view for a user.
|
// handleDeleteUserView deletes a view for a user.
|
||||||
func handleDeleteUserView(r *fastglue.Request) error {
|
func handleDeleteUserView(r *fastglue.Request) error {
|
||||||
var (
|
var (
|
||||||
app = r.Context.(*App)
|
app = r.Context.(*App)
|
||||||
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
auser = r.RequestCtx.UserValue("user").(amodels.User)
|
||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id <= 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid view `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
if id <= 0 {
|
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty view `ID`", nil, envelope.InputError)
|
|
||||||
}
|
|
||||||
|
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
view, err := app.view.Get(id)
|
view, err := app.view.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if view.UserID != user.ID {
|
if view.UserID != user.ID {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusForbidden, "Forbidden", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.denied", "name", "{globals.terms.permission}"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.view.Delete(id); err != nil {
|
if err = app.view.Delete(id); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
return r.SendEnvelope(true)
|
||||||
return r.SendEnvelope("View deleted successfully")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUpdateUserView updates a view for a user.
|
// handleUpdateUserView updates a view for a user.
|
||||||
@@ -101,39 +89,30 @@ func handleUpdateUserView(r *fastglue.Request) error {
|
|||||||
)
|
)
|
||||||
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
id, err := strconv.Atoi(r.RequestCtx.UserValue("id").(string))
|
||||||
if err != nil || id == 0 {
|
if err != nil || id == 0 {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest,
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.invalid", "name", "`id`"), nil, envelope.InputError)
|
||||||
"Invalid view `id`.", nil, envelope.InputError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.Decode(&view, "json"); err != nil {
|
if err := r.Decode(&view, "json"); err != nil {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "decode failed", err.Error(), envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.errorParsing", "name", "{globals.terms.request}"), err.Error(), envelope.InputError)
|
||||||
}
|
}
|
||||||
|
user, err := app.user.GetAgent(auser.ID, "")
|
||||||
user, err := app.user.GetAgent(auser.ID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if view.Name == "" {
|
if view.Name == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty view `Name`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`name`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if string(view.Filters) == "" {
|
if string(view.Filters) == "" {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, "Empty view `Filter`", nil, envelope.InputError)
|
return r.SendErrorEnvelope(fasthttp.StatusBadRequest, app.i18n.Ts("globals.messages.empty", "name", "`filters`"), nil, envelope.InputError)
|
||||||
}
|
}
|
||||||
|
|
||||||
v, err := app.view.Get(id)
|
v, err := app.view.Get(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.UserID != user.ID {
|
if v.UserID != user.ID {
|
||||||
return r.SendErrorEnvelope(fasthttp.StatusForbidden, "Forbidden", nil, envelope.PermissionError)
|
return r.SendErrorEnvelope(fasthttp.StatusForbidden, app.i18n.Ts("globals.messages.denied", "name", "{globals.terms.permission}"), nil, envelope.PermissionError)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = app.view.Update(id, view.Name, view.Filters); err != nil {
|
if err = app.view.Update(id, view.Name, view.Filters); err != nil {
|
||||||
return sendErrorEnvelope(r, err)
|
return sendErrorEnvelope(r, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return r.SendEnvelope(true)
|
return r.SendEnvelope(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,13 @@ check_updates = true
|
|||||||
[app.server]
|
[app.server]
|
||||||
address = "0.0.0.0:9000"
|
address = "0.0.0.0:9000"
|
||||||
socket = ""
|
socket = ""
|
||||||
|
# Do NOT disable secure cookies in production environment if you don't know
|
||||||
|
# exactly what you're doing!
|
||||||
|
disable_secure_cookies = false
|
||||||
read_timeout = "5s"
|
read_timeout = "5s"
|
||||||
write_timeout = "5s"
|
write_timeout = "5s"
|
||||||
max_body_size = 500000000
|
max_body_size = 500000000
|
||||||
|
read_buffer_size = 4096
|
||||||
keepalive_timeout = "10s"
|
keepalive_timeout = "10s"
|
||||||
|
|
||||||
# File upload provider to use, either `fs` or `s3`.
|
# File upload provider to use, either `fs` or `s3`.
|
||||||
|
|||||||
@@ -28,14 +28,15 @@ services:
|
|||||||
networks:
|
networks:
|
||||||
- libredesk
|
- libredesk
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
# Only bind on the local interface. To connect to Postgres externally, change this to 0.0.0.0
|
||||||
|
- "127.0.0.1:5432:5432"
|
||||||
environment:
|
environment:
|
||||||
# Set these environment variables to configure the database, defaults to libredesk.
|
# Set these environment variables to configure the database, defaults to libredesk.
|
||||||
POSTGRES_USER: ${POSTGRES_USER:-libredesk}
|
POSTGRES_USER: ${POSTGRES_USER:-libredesk}
|
||||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-libredesk}
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-libredesk}
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-libredesk}
|
POSTGRES_DB: ${POSTGRES_DB:-libredesk}
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U libredesk"]
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-libredesk} -d ${POSTGRES_DB:-libredesk}"]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 6
|
retries: 6
|
||||||
@@ -48,7 +49,8 @@ services:
|
|||||||
container_name: libredesk_redis
|
container_name: libredesk_redis
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
# Only bind on the local interface.
|
||||||
|
- "127.0.0.1:6379:6379"
|
||||||
networks:
|
networks:
|
||||||
- libredesk
|
- libredesk
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ curl -LO https://github.com/abhinavxd/libredesk/raw/main/config.sample.toml
|
|||||||
# Copy the config.sample.toml to config.toml and edit it as needed.
|
# Copy the config.sample.toml to config.toml and edit it as needed.
|
||||||
cp config.sample.toml config.toml
|
cp config.sample.toml config.toml
|
||||||
|
|
||||||
|
# Edit config.toml and find commented lines containing "docker compose". Replace the values in the lines below those comments with service names instead of IP addresses.
|
||||||
|
|
||||||
# Run the services in the background.
|
# Run the services in the background.
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
@@ -36,8 +38,6 @@ docker exec -it libredesk_app ./libredesk --set-system-user-password
|
|||||||
|
|
||||||
Go to `http://localhost:9000` and login with the email `System` and the password you set using the `--set-system-user-password` command.
|
Go to `http://localhost:9000` and login with the email `System` and the password you set using the `--set-system-user-password` command.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
|
|
||||||
## Compiling from source
|
## Compiling from source
|
||||||
|
|
||||||
@@ -46,3 +46,22 @@ To compile the latest unreleased version (`main` branch):
|
|||||||
1. Make sure `go`, `nodejs`, and `pnpm` are installed on your system.
|
1. Make sure `go`, `nodejs`, and `pnpm` are installed on your system.
|
||||||
2. `git clone git@github.com:abhinavxd/libredesk.git`
|
2. `git clone git@github.com:abhinavxd/libredesk.git`
|
||||||
3. `cd libredesk && make`. This will generate the `libredesk` binary.
|
3. `cd libredesk && make`. This will generate the `libredesk` binary.
|
||||||
|
|
||||||
|
|
||||||
|
## Nginx
|
||||||
|
|
||||||
|
Libredesk uses websockets for real-time updates. If you are using Nginx, you need to add the following (or similar) configuration to your Nginx configuration file.
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
client_max_body_size 100M;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:9000;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection 'upgrade';
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
57
docs/docs/sso.md
Normal file
57
docs/docs/sso.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Setting up SSO
|
||||||
|
|
||||||
|
Libredesk supports external OpenID Connect providers (e.g., Google, Keycloak) for signing in users.
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
User accounts must be created in Libredesk manually; signup is not supported.
|
||||||
|
|
||||||
|
## Generic Configuration Steps
|
||||||
|
|
||||||
|
Since each provider’s configuration might differ, consult your provider’s documentation for any additional or divergent settings.
|
||||||
|
|
||||||
|
1. Provider setup:
|
||||||
|
In your provider’s admin console, create a new OpenID Connect application/client. Retrieve:
|
||||||
|
- Client ID
|
||||||
|
- Client Secret
|
||||||
|
|
||||||
|
2. Libredesk configuration:
|
||||||
|
In Libredesk, navigate to Security > SSO and click New SSO and enter the following details:
|
||||||
|
- Provider URL (e.g., the URL of your OpenID provider)
|
||||||
|
- Client ID
|
||||||
|
- Client Secret
|
||||||
|
- A descriptive name for the connection
|
||||||
|
|
||||||
|
3. Redirect URL:
|
||||||
|
After saving, copy the generated Callback URL from Libredesk and add it as a valid redirect URI in your provider’s client settings.
|
||||||
|
|
||||||
|
## Provider Examples
|
||||||
|
|
||||||
|
#### Keycloak
|
||||||
|
|
||||||
|
1. Log in to your Keycloak Admin Console.
|
||||||
|
|
||||||
|
2. In Keycloak, navigate to Clients and click Create:
|
||||||
|
|
||||||
|
- Client ID (e.g., `libredesk-app`)
|
||||||
|
- Client Protocol: `openid-connect`
|
||||||
|
- Root URL and Web Origins: your app domain (e.g., `https://ticket.example.com`)
|
||||||
|
- Under Authentication flow, uncheck everything except the standard flow
|
||||||
|
- Click save
|
||||||
|
|
||||||
|
3. Go to the credentials tab:
|
||||||
|
- Ensure client authenticator is set to `Client Id and Secret`
|
||||||
|
- Note down the generated client secret
|
||||||
|
|
||||||
|
4. In Libredesk, go to Admin > Security > SSO and click New SSO:
|
||||||
|
- Provider URL (e.g., `https://keycloak.example.com/realms/yourrealm`)
|
||||||
|
- Name (e.g., `Keycloak`)
|
||||||
|
- Client ID
|
||||||
|
- Client secret
|
||||||
|
- Click save
|
||||||
|
|
||||||
|
5. After saving, click on the three dots and choose Edit to open the new SSO entry.
|
||||||
|
|
||||||
|
6. Copy the generated Callback URL from Libredesk.
|
||||||
|
|
||||||
|
7. Back in Keycloak, edit the client and add the Callback URL to Valid Redirect URIs:
|
||||||
|
- e.g., `https://ticket.example.com/api/v1/oidc/1/finish`
|
||||||
43
docs/docs/templating.md
Normal file
43
docs/docs/templating.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Templating
|
||||||
|
|
||||||
|
Templating in outgoing emails allows you to personalize content by embedding dynamic expressions like `{{ .Recipient.FullName }}`. These expressions reference fields from the conversation, contact, and recipient objects.
|
||||||
|
|
||||||
|
## Outgoing Email Template Expressions
|
||||||
|
|
||||||
|
If you want to customize the look of outgoing emails, you can do so in the Admin > Templates -> Outgoing Email Templates section. This template will be used for all outgoing emails including replies to conversations, notifications, and other system-generated emails.
|
||||||
|
|
||||||
|
### Conversation Variables
|
||||||
|
|
||||||
|
| Variable | Value |
|
||||||
|
|---------------------------------|--------------------------------------------------------|
|
||||||
|
| {{ .Conversation.ReferenceNumber }} | The unique reference number of the conversation |
|
||||||
|
| {{ .Conversation.Subject }} | The subject of the conversation |
|
||||||
|
| {{ .Conversation.UUID }} | The unique identifier of the conversation |
|
||||||
|
|
||||||
|
### Contact Variables
|
||||||
|
| Variable | Value |
|
||||||
|
|------------------------------|------------------------------------|
|
||||||
|
| {{ .Contact.FirstName }} | First name of the contact/customer |
|
||||||
|
| {{ .Contact.LastName }} | Last name of the contact/customer |
|
||||||
|
| {{ .Contact.FullName }} | Full name of the contact/customer |
|
||||||
|
| {{ .Contact.Email }} | Email address of the contact/customer |
|
||||||
|
|
||||||
|
### Recipient Variables
|
||||||
|
| Variable | Value |
|
||||||
|
|--------------------------------|-----------------------------------|
|
||||||
|
| {{ .Recipient.FirstName }} | First name of the recipient |
|
||||||
|
| {{ .Recipient.LastName }} | Last name of the recipient |
|
||||||
|
| {{ .Recipient.FullName }} | Full name of the recipient |
|
||||||
|
| {{ .Recipient.Email }} | Email address of the recipient |
|
||||||
|
|
||||||
|
|
||||||
|
### Example outgoing email template
|
||||||
|
|
||||||
|
```html
|
||||||
|
Dear {{ .Recipient.FirstName }}
|
||||||
|
{{ template "content" . }}
|
||||||
|
Best regards,
|
||||||
|
```
|
||||||
|
Here, the `{{ template "content" . }}` serves as a placeholder for the body of the outgoing email. It will be replaced with the actual email content at the time of sending.
|
||||||
|
|
||||||
|
Similarly, the `{{ .Recipient.FirstName }}` expression will dynamically insert the recipient's first name when the email is sent.
|
||||||
3
docs/docs/translations.md
Normal file
3
docs/docs/translations.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Translations / Internationalization
|
||||||
|
|
||||||
|
You can help translate libreDesk into different languages by contributing here: [LibreDesk Translation Project](https://crowdin.com/project/libredesk)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# Upgrade
|
# Upgrade
|
||||||
|
|
||||||
!!! Warning
|
!!! warning "Warning"
|
||||||
Always take a backup of the Postgres database before upgrading Libredesk.
|
Always take a backup of the Postgres database before upgrading Libredesk.
|
||||||
|
|
||||||
## Binary
|
## Binary
|
||||||
|
|||||||
@@ -31,4 +31,8 @@ nav:
|
|||||||
- Getting Started:
|
- Getting Started:
|
||||||
- Installation: installation.md
|
- Installation: installation.md
|
||||||
- Upgrade: upgrade.md
|
- Upgrade: upgrade.md
|
||||||
- Developer Setup: developer-setup.md
|
- Templating: templating.md
|
||||||
|
- SSO: sso.md
|
||||||
|
- Contributors:
|
||||||
|
- Developer setup: developer-setup.md
|
||||||
|
- Translations: translations.md
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
"baseColor": "gray",
|
"baseColor": "gray",
|
||||||
"cssVariables": true
|
"cssVariables": true
|
||||||
},
|
},
|
||||||
"framework": "vite",
|
|
||||||
"aliases": {
|
"aliases": {
|
||||||
"components": "@/components",
|
"components": "@/components",
|
||||||
"utils": "@/lib/utils"
|
"utils": "@/lib/utils"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { defineConfig } from 'cypress'
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
e2e: {
|
e2e: {
|
||||||
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
|
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
|
||||||
baseUrl: 'http://localhost:4173'
|
baseUrl: 'http://localhost:9000'
|
||||||
},
|
},
|
||||||
component: {
|
component: {
|
||||||
specPattern: 'src/**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}',
|
specPattern: 'src/**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}',
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
// https://on.cypress.io/api
|
|
||||||
|
|
||||||
describe('My First Test', () => {
|
|
||||||
it('visits the app root url', () => {
|
|
||||||
cy.visit('/')
|
|
||||||
cy.contains('h1', 'You did it!')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
140
frontend/cypress/e2e/testLogin.cy.js
Normal file
140
frontend/cypress/e2e/testLogin.cy.js
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
// cypress/e2e/login.cy.js
|
||||||
|
|
||||||
|
describe('Login Component', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Visit the login page
|
||||||
|
cy.visit('/')
|
||||||
|
|
||||||
|
// Mock the API response for OIDC providers
|
||||||
|
cy.intercept('GET', '**/api/v1/oidc/enabled', {
|
||||||
|
statusCode: 200,
|
||||||
|
body: {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'Google',
|
||||||
|
logo_url: 'https://example.com/google-logo.png',
|
||||||
|
disabled: false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}).as('getOIDCProviders')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should display login form', () => {
|
||||||
|
cy.contains('h3', 'Libredesk').should('be.visible')
|
||||||
|
cy.contains('p', 'Sign in to your account').should('be.visible')
|
||||||
|
cy.get('#email').should('be.visible')
|
||||||
|
cy.get('#password').should('be.visible')
|
||||||
|
cy.contains('a', 'Forgot password?').should('be.visible')
|
||||||
|
cy.contains('button', 'Sign in').should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should display OIDC providers when loaded', () => {
|
||||||
|
cy.wait('@getOIDCProviders')
|
||||||
|
cy.contains('button', 'Google').should('be.visible')
|
||||||
|
cy.contains('div', 'Or continue with').should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should show error for invalid login attempt', () => {
|
||||||
|
// Mock failed login API call
|
||||||
|
cy.intercept('POST', '**/api/v1/login', {
|
||||||
|
statusCode: 401,
|
||||||
|
body: {
|
||||||
|
message: 'Invalid credentials'
|
||||||
|
}
|
||||||
|
}).as('loginFailure')
|
||||||
|
|
||||||
|
// Enter System username and wrong password
|
||||||
|
cy.get('#email').type('System')
|
||||||
|
cy.get('#password').type('WrongPassword')
|
||||||
|
|
||||||
|
// Submit form
|
||||||
|
cy.contains('button', 'Sign in').click()
|
||||||
|
|
||||||
|
// Wait for API call
|
||||||
|
cy.wait('@loginFailure')
|
||||||
|
|
||||||
|
// Verify error message appears
|
||||||
|
cy.contains('Invalid credentials').should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should login successfully with correct credentials', () => {
|
||||||
|
// Mock successful login API call
|
||||||
|
cy.intercept('POST', '**/api/v1/login', {
|
||||||
|
statusCode: 200,
|
||||||
|
body: {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
email: 'System',
|
||||||
|
name: 'System User'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).as('loginSuccess')
|
||||||
|
|
||||||
|
// Enter System username and correct password
|
||||||
|
cy.get('#email').type('System')
|
||||||
|
cy.get('#password').type('StrongPass!123')
|
||||||
|
|
||||||
|
// Submit form
|
||||||
|
cy.contains('button', 'Sign in').click()
|
||||||
|
|
||||||
|
// Wait for API call
|
||||||
|
cy.wait('@loginSuccess')
|
||||||
|
|
||||||
|
// Verify redirection to inboxes page
|
||||||
|
cy.url().should('include', '/inboxes/assigned')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should validate email format', () => {
|
||||||
|
// Enter invalid email and a password
|
||||||
|
cy.get('#email').type('invalid-email')
|
||||||
|
cy.get('#password').type('password')
|
||||||
|
|
||||||
|
// Submit form
|
||||||
|
cy.contains('button', 'Sign in').click()
|
||||||
|
|
||||||
|
// Check for validation error (matching the error message with a trailing period)
|
||||||
|
cy.contains('Invalid email address').should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should validate empty password', () => {
|
||||||
|
// Enter email but no password
|
||||||
|
cy.get('#email').type('valid@example.com')
|
||||||
|
|
||||||
|
// Submit form
|
||||||
|
cy.contains('button', 'Sign in').click()
|
||||||
|
|
||||||
|
// Check for validation error (matching the error message with a trailing period)
|
||||||
|
cy.contains('Password cannot be empty').should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should show loading state during login', () => {
|
||||||
|
// Mock slow API response
|
||||||
|
cy.intercept('POST', '**/api/v1/login', {
|
||||||
|
statusCode: 200,
|
||||||
|
body: {
|
||||||
|
data: {
|
||||||
|
id: 1,
|
||||||
|
email: 'System',
|
||||||
|
name: 'System User'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
delay: 1000
|
||||||
|
}).as('slowLogin')
|
||||||
|
|
||||||
|
// Enter credentials
|
||||||
|
cy.get('#email').type('System')
|
||||||
|
cy.get('#password').type('StrongPass!123')
|
||||||
|
|
||||||
|
// Submit form
|
||||||
|
cy.contains('button', 'Sign in').click()
|
||||||
|
|
||||||
|
// Check if loading state is shown
|
||||||
|
cy.contains('Logging in...').should('be.visible')
|
||||||
|
cy.get('svg.animate-spin').should('be.visible')
|
||||||
|
|
||||||
|
// Wait for API call to finish
|
||||||
|
cy.wait('@slowLogin')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "libredesk",
|
"name": "libredesk",
|
||||||
"version": "0.3.0",
|
"version": "0.6.0-alpha",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
|
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
|
||||||
|
"test:e2e:ci": "cypress run --e2e --headless",
|
||||||
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
|
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
|
||||||
"test:unit": "cypress run --component",
|
"test:unit": "cypress run --component",
|
||||||
"test:unit:dev": "cypress open --component",
|
"test:unit:dev": "cypress open --component",
|
||||||
@@ -21,8 +22,12 @@
|
|||||||
"@tailwindcss/typography": "^0.5.16",
|
"@tailwindcss/typography": "^0.5.16",
|
||||||
"@tanstack/vue-table": "^8.19.2",
|
"@tanstack/vue-table": "^8.19.2",
|
||||||
"@tiptap/extension-image": "^2.5.9",
|
"@tiptap/extension-image": "^2.5.9",
|
||||||
"@tiptap/extension-link": "^2.9.1",
|
"@tiptap/extension-link": "^2.11.2",
|
||||||
"@tiptap/extension-placeholder": "^2.4.0",
|
"@tiptap/extension-placeholder": "^2.4.0",
|
||||||
|
"@tiptap/extension-table": "^2.11.5",
|
||||||
|
"@tiptap/extension-table-cell": "^2.11.5",
|
||||||
|
"@tiptap/extension-table-header": "^2.11.5",
|
||||||
|
"@tiptap/extension-table-row": "^2.11.5",
|
||||||
"@tiptap/pm": "^2.4.0",
|
"@tiptap/pm": "^2.4.0",
|
||||||
"@tiptap/starter-kit": "^2.4.0",
|
"@tiptap/starter-kit": "^2.4.0",
|
||||||
"@tiptap/vue-3": "^2.4.0",
|
"@tiptap/vue-3": "^2.4.0",
|
||||||
@@ -30,7 +35,7 @@
|
|||||||
"@unovis/vue": "^1.4.4",
|
"@unovis/vue": "^1.4.4",
|
||||||
"@vee-validate/zod": "^4.13.2",
|
"@vee-validate/zod": "^4.13.2",
|
||||||
"@vueuse/core": "^12.4.0",
|
"@vueuse/core": "^12.4.0",
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.8.2",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"codeflask": "^1.4.1",
|
"codeflask": "^1.4.1",
|
||||||
@@ -39,7 +44,8 @@
|
|||||||
"mitt": "^3.0.1",
|
"mitt": "^3.0.1",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"qs": "^6.12.1",
|
"qs": "^6.12.1",
|
||||||
"radix-vue": "latest",
|
"radix-vue": "^1.9.17",
|
||||||
|
"reka-ui": "^2.2.0",
|
||||||
"tailwind-merge": "^2.3.0",
|
"tailwind-merge": "^2.3.0",
|
||||||
"vee-validate": "^4.13.2",
|
"vee-validate": "^4.13.2",
|
||||||
"vue": "^3.4.37",
|
"vue": "^3.4.37",
|
||||||
@@ -66,9 +72,9 @@
|
|||||||
"prettier": "^3.0.3",
|
"prettier": "^3.0.3",
|
||||||
"sass": "^1.70.0",
|
"sass": "^1.70.0",
|
||||||
"start-server-and-test": "^2.0.3",
|
"start-server-and-test": "^2.0.3",
|
||||||
"tailwindcss": "latest",
|
"tailwindcss": "^3.4.17",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
"vite": "^5.4.9"
|
"vite": "^5.4.18"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@9.15.3+sha512.1f79bc245a66eb0b07c5d4d83131240774642caaa86ef7d0434ab47c0d16f66b04e21e0c086eb61e62c77efc4d7f7ec071afad3796af64892fae66509173893a"
|
"packageManager": "pnpm@9.15.3+sha512.1f79bc245a66eb0b07c5d4d83131240774642caaa86ef7d0434ab47c0d16f66b04e21e0c086eb61e62c77efc4d7f7ec071afad3796af64892fae66509173893a"
|
||||||
}
|
}
|
||||||
|
|||||||
473
frontend/pnpm-lock.yaml
generated
473
frontend/pnpm-lock.yaml
generated
@@ -27,11 +27,23 @@ importers:
|
|||||||
specifier: ^2.5.9
|
specifier: ^2.5.9
|
||||||
version: 2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))
|
version: 2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))
|
||||||
'@tiptap/extension-link':
|
'@tiptap/extension-link':
|
||||||
specifier: ^2.9.1
|
specifier: ^2.11.2
|
||||||
version: 2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))(@tiptap/pm@2.11.2)
|
version: 2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))(@tiptap/pm@2.11.2)
|
||||||
'@tiptap/extension-placeholder':
|
'@tiptap/extension-placeholder':
|
||||||
specifier: ^2.4.0
|
specifier: ^2.4.0
|
||||||
version: 2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))(@tiptap/pm@2.11.2)
|
version: 2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))(@tiptap/pm@2.11.2)
|
||||||
|
'@tiptap/extension-table':
|
||||||
|
specifier: ^2.11.5
|
||||||
|
version: 2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))(@tiptap/pm@2.11.2)
|
||||||
|
'@tiptap/extension-table-cell':
|
||||||
|
specifier: ^2.11.5
|
||||||
|
version: 2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))
|
||||||
|
'@tiptap/extension-table-header':
|
||||||
|
specifier: ^2.11.5
|
||||||
|
version: 2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))
|
||||||
|
'@tiptap/extension-table-row':
|
||||||
|
specifier: ^2.11.5
|
||||||
|
version: 2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))
|
||||||
'@tiptap/pm':
|
'@tiptap/pm':
|
||||||
specifier: ^2.4.0
|
specifier: ^2.4.0
|
||||||
version: 2.11.2
|
version: 2.11.2
|
||||||
@@ -54,8 +66,8 @@ importers:
|
|||||||
specifier: ^12.4.0
|
specifier: ^12.4.0
|
||||||
version: 12.4.0(typescript@5.7.3)
|
version: 12.4.0(typescript@5.7.3)
|
||||||
axios:
|
axios:
|
||||||
specifier: ^1.7.9
|
specifier: ^1.8.2
|
||||||
version: 1.7.9(debug@4.4.0)
|
version: 1.8.2(debug@4.4.0)
|
||||||
class-variance-authority:
|
class-variance-authority:
|
||||||
specifier: ^0.7.0
|
specifier: ^0.7.0
|
||||||
version: 0.7.1
|
version: 0.7.1
|
||||||
@@ -81,8 +93,11 @@ importers:
|
|||||||
specifier: ^6.12.1
|
specifier: ^6.12.1
|
||||||
version: 6.13.1
|
version: 6.13.1
|
||||||
radix-vue:
|
radix-vue:
|
||||||
specifier: latest
|
specifier: ^1.9.17
|
||||||
version: 1.9.12(vue@3.5.13(typescript@5.7.3))
|
version: 1.9.17(vue@3.5.13(typescript@5.7.3))
|
||||||
|
reka-ui:
|
||||||
|
specifier: ^2.2.0
|
||||||
|
version: 2.2.0(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))
|
||||||
tailwind-merge:
|
tailwind-merge:
|
||||||
specifier: ^2.3.0
|
specifier: ^2.3.0
|
||||||
version: 2.6.0
|
version: 2.6.0
|
||||||
@@ -97,7 +112,7 @@ importers:
|
|||||||
version: 5.2.0(vue@3.5.13(typescript@5.7.3))
|
version: 5.2.0(vue@3.5.13(typescript@5.7.3))
|
||||||
vue-i18n:
|
vue-i18n:
|
||||||
specifier: '9'
|
specifier: '9'
|
||||||
version: 9.14.2(vue@3.5.13(typescript@5.7.3))
|
version: 9.14.3(vue@3.5.13(typescript@5.7.3))
|
||||||
vue-letter:
|
vue-letter:
|
||||||
specifier: ^0.2.0
|
specifier: ^0.2.0
|
||||||
version: 0.2.0
|
version: 0.2.0
|
||||||
@@ -125,7 +140,7 @@ importers:
|
|||||||
version: 1.10.5
|
version: 1.10.5
|
||||||
'@vitejs/plugin-vue':
|
'@vitejs/plugin-vue':
|
||||||
specifier: ^5.0.3
|
specifier: ^5.0.3
|
||||||
version: 5.2.1(vite@5.4.11(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0))(vue@3.5.13(typescript@5.7.3))
|
version: 5.2.1(vite@5.4.18(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0))(vue@3.5.13(typescript@5.7.3))
|
||||||
'@vue/eslint-config-prettier':
|
'@vue/eslint-config-prettier':
|
||||||
specifier: ^8.0.0
|
specifier: ^8.0.0
|
||||||
version: 8.0.0(eslint@8.57.1)(prettier@3.4.2)
|
version: 8.0.0(eslint@8.57.1)(prettier@3.4.2)
|
||||||
@@ -157,14 +172,14 @@ importers:
|
|||||||
specifier: ^2.0.3
|
specifier: ^2.0.3
|
||||||
version: 2.0.9
|
version: 2.0.9
|
||||||
tailwindcss:
|
tailwindcss:
|
||||||
specifier: latest
|
specifier: ^3.4.17
|
||||||
version: 3.4.17
|
version: 3.4.17
|
||||||
tailwindcss-animate:
|
tailwindcss-animate:
|
||||||
specifier: ^1.0.7
|
specifier: ^1.0.7
|
||||||
version: 1.0.7(tailwindcss@3.4.17)
|
version: 1.0.7(tailwindcss@3.4.17)
|
||||||
vite:
|
vite:
|
||||||
specifier: ^5.4.9
|
specifier: ^5.4.18
|
||||||
version: 5.4.11(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0)
|
version: 5.4.18(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0)
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -453,16 +468,16 @@ packages:
|
|||||||
'@internationalized/number@3.6.0':
|
'@internationalized/number@3.6.0':
|
||||||
resolution: {integrity: sha512-PtrRcJVy7nw++wn4W2OuePQQfTqDzfusSuY1QTtui4wa7r+rGVtR75pO8CyKvHvzyQYi3Q1uO5sY0AsB4e65Bw==}
|
resolution: {integrity: sha512-PtrRcJVy7nw++wn4W2OuePQQfTqDzfusSuY1QTtui4wa7r+rGVtR75pO8CyKvHvzyQYi3Q1uO5sY0AsB4e65Bw==}
|
||||||
|
|
||||||
'@intlify/core-base@9.14.2':
|
'@intlify/core-base@9.14.3':
|
||||||
resolution: {integrity: sha512-DZyQ4Hk22sC81MP4qiCDuU+LdaYW91A6lCjq8AWPvY3+mGMzhGDfOCzvyR6YBQxtlPjFqMoFk9ylnNYRAQwXtQ==}
|
resolution: {integrity: sha512-nbJ7pKTlXFnaXPblyfiH6awAx1C0PWNNuqXAR74yRwgi5A/Re/8/5fErLY0pv4R8+EHj3ZaThMHdnuC/5OBa6g==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
|
|
||||||
'@intlify/message-compiler@9.14.2':
|
'@intlify/message-compiler@9.14.3':
|
||||||
resolution: {integrity: sha512-YsKKuV4Qv4wrLNsvgWbTf0E40uRv+Qiw1BeLQ0LAxifQuhiMe+hfTIzOMdWj/ZpnTDj4RSZtkXjJM7JDiiB5LQ==}
|
resolution: {integrity: sha512-ANwC226BQdd+MpJ36rOYkChSESfPwu3Ss2Faw0RHTOknYLoHTX6V6e/JjIKVDMbzs0/H/df/rO6yU0SPiWHqNg==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
|
|
||||||
'@intlify/shared@9.14.2':
|
'@intlify/shared@9.14.3':
|
||||||
resolution: {integrity: sha512-uRAHAxYPeF+G5DBIboKpPgC/Waecd4Jz8ihtkpJQD5ycb5PwXp0k/+hBGl5dAjwF7w+l74kz/PKA8r8OK//RUw==}
|
resolution: {integrity: sha512-hJXz9LA5VG7qNE00t50bdzDv8Z4q9fpcL81wj4y4duKavrv0KM8YNLTwXNEFINHjTsfrG9TXvPuEjVaAvZ7yWg==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
|
|
||||||
'@isaacs/cliui@8.0.2':
|
'@isaacs/cliui@8.0.2':
|
||||||
@@ -630,98 +645,103 @@ packages:
|
|||||||
'@remirror/core-constants@3.0.0':
|
'@remirror/core-constants@3.0.0':
|
||||||
resolution: {integrity: sha512-42aWfPrimMfDKDi4YegyS7x+/0tlzaqwPQCULLanv3DMIlu96KTJR0fM5isWX2UViOqlGnX6YFgqWepcX+XMNg==}
|
resolution: {integrity: sha512-42aWfPrimMfDKDi4YegyS7x+/0tlzaqwPQCULLanv3DMIlu96KTJR0fM5isWX2UViOqlGnX6YFgqWepcX+XMNg==}
|
||||||
|
|
||||||
'@rollup/rollup-android-arm-eabi@4.30.1':
|
'@rollup/rollup-android-arm-eabi@4.40.1':
|
||||||
resolution: {integrity: sha512-pSWY+EVt3rJ9fQ3IqlrEUtXh3cGqGtPDH1FQlNZehO2yYxCHEX1SPsz1M//NXwYfbTlcKr9WObLnJX9FsS9K1Q==}
|
resolution: {integrity: sha512-kxz0YeeCrRUHz3zyqvd7n+TVRlNyTifBsmnmNPtk3hQURUyG9eAB+usz6DAwagMusjx/zb3AjvDUvhFGDAexGw==}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [android]
|
os: [android]
|
||||||
|
|
||||||
'@rollup/rollup-android-arm64@4.30.1':
|
'@rollup/rollup-android-arm64@4.40.1':
|
||||||
resolution: {integrity: sha512-/NA2qXxE3D/BRjOJM8wQblmArQq1YoBVJjrjoTSBS09jgUisq7bqxNHJ8kjCHeV21W/9WDGwJEWSN0KQ2mtD/w==}
|
resolution: {integrity: sha512-PPkxTOisoNC6TpnDKatjKkjRMsdaWIhyuMkA4UsBXT9WEZY4uHezBTjs6Vl4PbqQQeu6oION1w2voYZv9yquCw==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [android]
|
os: [android]
|
||||||
|
|
||||||
'@rollup/rollup-darwin-arm64@4.30.1':
|
'@rollup/rollup-darwin-arm64@4.40.1':
|
||||||
resolution: {integrity: sha512-r7FQIXD7gB0WJ5mokTUgUWPl0eYIH0wnxqeSAhuIwvnnpjdVB8cRRClyKLQr7lgzjctkbp5KmswWszlwYln03Q==}
|
resolution: {integrity: sha512-VWXGISWFY18v/0JyNUy4A46KCFCb9NVsH+1100XP31lud+TzlezBbz24CYzbnA4x6w4hx+NYCXDfnvDVO6lcAA==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
'@rollup/rollup-darwin-x64@4.30.1':
|
'@rollup/rollup-darwin-x64@4.40.1':
|
||||||
resolution: {integrity: sha512-x78BavIwSH6sqfP2xeI1hd1GpHL8J4W2BXcVM/5KYKoAD3nNsfitQhvWSw+TFtQTLZ9OmlF+FEInEHyubut2OA==}
|
resolution: {integrity: sha512-nIwkXafAI1/QCS7pxSpv/ZtFW6TXcNUEHAIA9EIyw5OzxJZQ1YDrX+CL6JAIQgZ33CInl1R6mHet9Y/UZTg2Bw==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
'@rollup/rollup-freebsd-arm64@4.30.1':
|
'@rollup/rollup-freebsd-arm64@4.40.1':
|
||||||
resolution: {integrity: sha512-HYTlUAjbO1z8ywxsDFWADfTRfTIIy/oUlfIDmlHYmjUP2QRDTzBuWXc9O4CXM+bo9qfiCclmHk1x4ogBjOUpUQ==}
|
resolution: {integrity: sha512-BdrLJ2mHTrIYdaS2I99mriyJfGGenSaP+UwGi1kB9BLOCu9SR8ZpbkmmalKIALnRw24kM7qCN0IOm6L0S44iWw==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
|
|
||||||
'@rollup/rollup-freebsd-x64@4.30.1':
|
'@rollup/rollup-freebsd-x64@4.40.1':
|
||||||
resolution: {integrity: sha512-1MEdGqogQLccphhX5myCJqeGNYTNcmTyaic9S7CG3JhwuIByJ7J05vGbZxsizQthP1xpVx7kd3o31eOogfEirw==}
|
resolution: {integrity: sha512-VXeo/puqvCG8JBPNZXZf5Dqq7BzElNJzHRRw3vjBE27WujdzuOPecDPc/+1DcdcTptNBep3861jNq0mYkT8Z6Q==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm-gnueabihf@4.30.1':
|
'@rollup/rollup-linux-arm-gnueabihf@4.40.1':
|
||||||
resolution: {integrity: sha512-PaMRNBSqCx7K3Wc9QZkFx5+CX27WFpAMxJNiYGAXfmMIKC7jstlr32UhTgK6T07OtqR+wYlWm9IxzennjnvdJg==}
|
resolution: {integrity: sha512-ehSKrewwsESPt1TgSE/na9nIhWCosfGSFqv7vwEtjyAqZcvbGIg4JAcV7ZEh2tfj/IlfBeZjgOXm35iOOjadcg==}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm-musleabihf@4.30.1':
|
'@rollup/rollup-linux-arm-musleabihf@4.40.1':
|
||||||
resolution: {integrity: sha512-B8Rcyj9AV7ZlEFqvB5BubG5iO6ANDsRKlhIxySXcF1axXYUyqwBok+XZPgIYGBgs7LDXfWfifxhw0Ik57T0Yug==}
|
resolution: {integrity: sha512-m39iO/aaurh5FVIu/F4/Zsl8xppd76S4qoID8E+dSRQvTyZTOI2gVk3T4oqzfq1PtcvOfAVlwLMK3KRQMaR8lg==}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm64-gnu@4.30.1':
|
'@rollup/rollup-linux-arm64-gnu@4.40.1':
|
||||||
resolution: {integrity: sha512-hqVyueGxAj3cBKrAI4aFHLV+h0Lv5VgWZs9CUGqr1z0fZtlADVV1YPOij6AhcK5An33EXaxnDLmJdQikcn5NEw==}
|
resolution: {integrity: sha512-Y+GHnGaku4aVLSgrT0uWe2o2Rq8te9hi+MwqGF9r9ORgXhmHK5Q71N757u0F8yU1OIwUIFy6YiJtKjtyktk5hg==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm64-musl@4.30.1':
|
'@rollup/rollup-linux-arm64-musl@4.40.1':
|
||||||
resolution: {integrity: sha512-i4Ab2vnvS1AE1PyOIGp2kXni69gU2DAUVt6FSXeIqUCPIR3ZlheMW3oP2JkukDfu3PsexYRbOiJrY+yVNSk9oA==}
|
resolution: {integrity: sha512-jEwjn3jCA+tQGswK3aEWcD09/7M5wGwc6+flhva7dsQNRZZTe30vkalgIzV4tjkopsTS9Jd7Y1Bsj6a4lzz8gQ==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-loongarch64-gnu@4.30.1':
|
'@rollup/rollup-linux-loongarch64-gnu@4.40.1':
|
||||||
resolution: {integrity: sha512-fARcF5g296snX0oLGkVxPmysetwUk2zmHcca+e9ObOovBR++9ZPOhqFUM61UUZ2EYpXVPN1redgqVoBB34nTpQ==}
|
resolution: {integrity: sha512-ySyWikVhNzv+BV/IDCsrraOAZ3UaC8SZB67FZlqVwXwnFhPihOso9rPOxzZbjp81suB1O2Topw+6Ug3JNegejQ==}
|
||||||
cpu: [loong64]
|
cpu: [loong64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-powerpc64le-gnu@4.30.1':
|
'@rollup/rollup-linux-powerpc64le-gnu@4.40.1':
|
||||||
resolution: {integrity: sha512-GLrZraoO3wVT4uFXh67ElpwQY0DIygxdv0BNW9Hkm3X34wu+BkqrDrkcsIapAY+N2ATEbvak0XQ9gxZtCIA5Rw==}
|
resolution: {integrity: sha512-BvvA64QxZlh7WZWqDPPdt0GH4bznuL6uOO1pmgPnnv86rpUpc8ZxgZwcEgXvo02GRIZX1hQ0j0pAnhwkhwPqWg==}
|
||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-riscv64-gnu@4.30.1':
|
'@rollup/rollup-linux-riscv64-gnu@4.40.1':
|
||||||
resolution: {integrity: sha512-0WKLaAUUHKBtll0wvOmh6yh3S0wSU9+yas923JIChfxOaaBarmb/lBKPF0w/+jTVozFnOXJeRGZ8NvOxvk/jcw==}
|
resolution: {integrity: sha512-EQSP+8+1VuSulm9RKSMKitTav89fKbHymTf25n5+Yr6gAPZxYWpj3DzAsQqoaHAk9YX2lwEyAf9S4W8F4l3VBQ==}
|
||||||
cpu: [riscv64]
|
cpu: [riscv64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-s390x-gnu@4.30.1':
|
'@rollup/rollup-linux-riscv64-musl@4.40.1':
|
||||||
resolution: {integrity: sha512-GWFs97Ruxo5Bt+cvVTQkOJ6TIx0xJDD/bMAOXWJg8TCSTEK8RnFeOeiFTxKniTc4vMIaWvCplMAFBt9miGxgkA==}
|
resolution: {integrity: sha512-n/vQ4xRZXKuIpqukkMXZt9RWdl+2zgGNx7Uda8NtmLJ06NL8jiHxUawbwC+hdSq1rrw/9CghCpEONor+l1e2gA==}
|
||||||
|
cpu: [riscv64]
|
||||||
|
os: [linux]
|
||||||
|
|
||||||
|
'@rollup/rollup-linux-s390x-gnu@4.40.1':
|
||||||
|
resolution: {integrity: sha512-h8d28xzYb98fMQKUz0w2fMc1XuGzLLjdyxVIbhbil4ELfk5/orZlSTpF/xdI9C8K0I8lCkq+1En2RJsawZekkg==}
|
||||||
cpu: [s390x]
|
cpu: [s390x]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-x64-gnu@4.30.1':
|
'@rollup/rollup-linux-x64-gnu@4.40.1':
|
||||||
resolution: {integrity: sha512-UtgGb7QGgXDIO+tqqJ5oZRGHsDLO8SlpE4MhqpY9Llpzi5rJMvrK6ZGhsRCST2abZdBqIBeXW6WPD5fGK5SDwg==}
|
resolution: {integrity: sha512-XiK5z70PEFEFqcNj3/zRSz/qX4bp4QIraTy9QjwJAb/Z8GM7kVUsD0Uk8maIPeTyPCP03ChdI+VVmJriKYbRHQ==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-linux-x64-musl@4.30.1':
|
'@rollup/rollup-linux-x64-musl@4.40.1':
|
||||||
resolution: {integrity: sha512-V9U8Ey2UqmQsBT+xTOeMzPzwDzyXmnAoO4edZhL7INkwQcaW1Ckv3WJX3qrrp/VHaDkEWIBWhRwP47r8cdrOow==}
|
resolution: {integrity: sha512-2BRORitq5rQ4Da9blVovzNCMaUlyKrzMSvkVR0D4qPuOy/+pMCrh1d7o01RATwVy+6Fa1WBw+da7QPeLWU/1mQ==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@rollup/rollup-win32-arm64-msvc@4.30.1':
|
'@rollup/rollup-win32-arm64-msvc@4.40.1':
|
||||||
resolution: {integrity: sha512-WabtHWiPaFF47W3PkHnjbmWawnX/aE57K47ZDT1BXTS5GgrBUEpvOzq0FI0V/UYzQJgdb8XlhVNH8/fwV8xDjw==}
|
resolution: {integrity: sha512-b2bcNm9Kbde03H+q+Jjw9tSfhYkzrDUf2d5MAd1bOJuVplXvFhWz7tRtWvD8/ORZi7qSCy0idW6tf2HgxSXQSg==}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@rollup/rollup-win32-ia32-msvc@4.30.1':
|
'@rollup/rollup-win32-ia32-msvc@4.40.1':
|
||||||
resolution: {integrity: sha512-pxHAU+Zv39hLUTdQQHUVHf4P+0C47y/ZloorHpzs2SXMRqeAWmGghzAhfOlzFHHwjvgokdFAhC4V+6kC1lRRfw==}
|
resolution: {integrity: sha512-DfcogW8N7Zg7llVEfpqWMZcaErKfsj9VvmfSyRjCyo4BI3wPEfrzTtJkZG6gKP/Z92wFm6rz2aDO7/JfiR/whA==}
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@rollup/rollup-win32-x64-msvc@4.30.1':
|
'@rollup/rollup-win32-x64-msvc@4.40.1':
|
||||||
resolution: {integrity: sha512-D6qjsXGcvhTjv0kI4fU8tUuBDF/Ueee4SVX79VfNDXZa64TfCW1Slkb6Z7O1p7vflqZjcmOVdZlqf8gvJxc6og==}
|
resolution: {integrity: sha512-ECyOuDeH3C1I8jH2MK1RtBJW+YPMvSfT0a5NN0nHfQYnDSJ6tUiZH3gzwVP5/Kfh/+Tt7tpWVF9LXNTnhTJ3kA==}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
@@ -752,6 +772,9 @@ packages:
|
|||||||
'@tanstack/virtual-core@3.11.2':
|
'@tanstack/virtual-core@3.11.2':
|
||||||
resolution: {integrity: sha512-vTtpNt7mKCiZ1pwU9hfKPhpdVO2sVzFQsxoVBGtOSHxlrRRzYr8iQ2TlwbAcRYCcEiZ9ECAM8kBzH0v2+VzfKw==}
|
resolution: {integrity: sha512-vTtpNt7mKCiZ1pwU9hfKPhpdVO2sVzFQsxoVBGtOSHxlrRRzYr8iQ2TlwbAcRYCcEiZ9ECAM8kBzH0v2+VzfKw==}
|
||||||
|
|
||||||
|
'@tanstack/virtual-core@3.13.6':
|
||||||
|
resolution: {integrity: sha512-cnQUeWnhNP8tJ4WsGcYiX24Gjkc9ALstLbHcBj1t3E7EimN6n6kHH+DPV4PpDnuw00NApQp+ViojMj1GRdwYQg==}
|
||||||
|
|
||||||
'@tanstack/vue-table@8.20.5':
|
'@tanstack/vue-table@8.20.5':
|
||||||
resolution: {integrity: sha512-2xixT3BEgSDw+jOSqPt6ylO/eutDI107t2WdFMVYIZZ45UmTHLySqNriNs0+dMaKR56K5z3t+97P6VuVnI2L+Q==}
|
resolution: {integrity: sha512-2xixT3BEgSDw+jOSqPt6ylO/eutDI107t2WdFMVYIZZ45UmTHLySqNriNs0+dMaKR56K5z3t+97P6VuVnI2L+Q==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
@@ -763,6 +786,11 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^2.7.0 || ^3.0.0
|
vue: ^2.7.0 || ^3.0.0
|
||||||
|
|
||||||
|
'@tanstack/vue-virtual@3.13.6':
|
||||||
|
resolution: {integrity: sha512-GYdZ3SJBQPzgxhuCE2fvpiH46qzHiVx5XzBSdtESgiqh4poj8UgckjGWYEhxaBbcVt1oLzh1m3Ql4TyH32TOzQ==}
|
||||||
|
peerDependencies:
|
||||||
|
vue: ^2.7.0 || ^3.0.0
|
||||||
|
|
||||||
'@tiptap/core@2.11.2':
|
'@tiptap/core@2.11.2':
|
||||||
resolution: {integrity: sha512-Z437c/sQg31yrRVgLJVkQuih+7Og5tjRx6FE/zE47QgEayqQ9yXH0LrTAbPiY6IfY1X+f2A0h3e5Y/WGD6rC3Q==}
|
resolution: {integrity: sha512-Z437c/sQg31yrRVgLJVkQuih+7Og5tjRx6FE/zE47QgEayqQ9yXH0LrTAbPiY6IfY1X+f2A0h3e5Y/WGD6rC3Q==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -887,6 +915,27 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tiptap/core': ^2.7.0
|
'@tiptap/core': ^2.7.0
|
||||||
|
|
||||||
|
'@tiptap/extension-table-cell@2.11.5':
|
||||||
|
resolution: {integrity: sha512-S967Au0pgeULstP3FaasOf/LEh72p61Ooh1PcUMF/az4x8EeGgpcEUARpVUxsGxLFvogv6LmhPHZdtcGgdHcBw==}
|
||||||
|
peerDependencies:
|
||||||
|
'@tiptap/core': ^2.7.0
|
||||||
|
|
||||||
|
'@tiptap/extension-table-header@2.11.5':
|
||||||
|
resolution: {integrity: sha512-O1iBtzZP1XZDi4h1Xmgq1T63il+fpKPvBIMZ0JJH9TyCw5i5rcrMLL2dyy5zaWK3BFRJuYBNSke4c+VWnr/g6w==}
|
||||||
|
peerDependencies:
|
||||||
|
'@tiptap/core': ^2.7.0
|
||||||
|
|
||||||
|
'@tiptap/extension-table-row@2.11.5':
|
||||||
|
resolution: {integrity: sha512-+/VWhCuW24BcM5aaIc/f0bC6ZR1Q5gnuqw13MIo7gyPx7iIY6BXK8roGiZSs8wYAN4uBEf3EKFm0bSZwQuAeyg==}
|
||||||
|
peerDependencies:
|
||||||
|
'@tiptap/core': ^2.7.0
|
||||||
|
|
||||||
|
'@tiptap/extension-table@2.11.5':
|
||||||
|
resolution: {integrity: sha512-NKXLhKWdAdURklm98YkCd2ai4fh8jY8HS/+X2s/2QiQt8Z98CU1keCm35fJEEExM234iB/hCqG5vY4JgTc0Tvw==}
|
||||||
|
peerDependencies:
|
||||||
|
'@tiptap/core': ^2.7.0
|
||||||
|
'@tiptap/pm': ^2.7.0
|
||||||
|
|
||||||
'@tiptap/extension-text-style@2.11.2':
|
'@tiptap/extension-text-style@2.11.2':
|
||||||
resolution: {integrity: sha512-RAa7BTwEOJRZN3EB2lg03KXyu7JC/Ce96cerh3D0Fo78yrtKOArPaiVHoTki6ZEIG43ccHEit1PPjMYxivPPeg==}
|
resolution: {integrity: sha512-RAa7BTwEOJRZN3EB2lg03KXyu7JC/Ce96cerh3D0Fo78yrtKOArPaiVHoTki6ZEIG43ccHEit1PPjMYxivPPeg==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -1018,8 +1067,8 @@ packages:
|
|||||||
'@types/dagre@0.7.52':
|
'@types/dagre@0.7.52':
|
||||||
resolution: {integrity: sha512-XKJdy+OClLk3hketHi9Qg6gTfe1F3y+UFnHxKA2rn9Dw+oXa4Gb378Ztz9HlMgZKSxpPmn4BNVh9wgkpvrK1uw==}
|
resolution: {integrity: sha512-XKJdy+OClLk3hketHi9Qg6gTfe1F3y+UFnHxKA2rn9Dw+oXa4Gb378Ztz9HlMgZKSxpPmn4BNVh9wgkpvrK1uw==}
|
||||||
|
|
||||||
'@types/estree@1.0.6':
|
'@types/estree@1.0.7':
|
||||||
resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
|
resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==}
|
||||||
|
|
||||||
'@types/geojson@7946.0.15':
|
'@types/geojson@7946.0.15':
|
||||||
resolution: {integrity: sha512-9oSxFzDCT2Rj6DfcHF8G++jxBKS7mBqXl5xrRW+Kbvjry6Uduya2iiwqHPhVXpasAVMBYKkEPGgKhd3+/HZ6xA==}
|
resolution: {integrity: sha512-9oSxFzDCT2Rj6DfcHF8G++jxBKS7mBqXl5xrRW+Kbvjry6Uduya2iiwqHPhVXpasAVMBYKkEPGgKhd3+/HZ6xA==}
|
||||||
@@ -1090,6 +1139,9 @@ packages:
|
|||||||
'@types/web-bluetooth@0.0.20':
|
'@types/web-bluetooth@0.0.20':
|
||||||
resolution: {integrity: sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==}
|
resolution: {integrity: sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==}
|
||||||
|
|
||||||
|
'@types/web-bluetooth@0.0.21':
|
||||||
|
resolution: {integrity: sha512-oIQLCGWtcFZy2JW77j9k8nHzAOpqMHLQejDA48XXMWH6tjCQHz5RCFz1bzsmROyL6PUm+LLnUiI4BCn221inxA==}
|
||||||
|
|
||||||
'@types/yauzl@2.10.3':
|
'@types/yauzl@2.10.3':
|
||||||
resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==}
|
resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==}
|
||||||
|
|
||||||
@@ -1176,18 +1228,27 @@ packages:
|
|||||||
'@vueuse/core@12.4.0':
|
'@vueuse/core@12.4.0':
|
||||||
resolution: {integrity: sha512-XnjQYcJwCsyXyIafyA6SvyN/OBtfPnjvJmbxNxQjCcyWD198urwm5TYvIUUyAxEAN0K7HJggOgT15cOlWFyLeA==}
|
resolution: {integrity: sha512-XnjQYcJwCsyXyIafyA6SvyN/OBtfPnjvJmbxNxQjCcyWD198urwm5TYvIUUyAxEAN0K7HJggOgT15cOlWFyLeA==}
|
||||||
|
|
||||||
|
'@vueuse/core@12.8.2':
|
||||||
|
resolution: {integrity: sha512-HbvCmZdzAu3VGi/pWYm5Ut+Kd9mn1ZHnn4L5G8kOQTPs/IwIAmJoBrmYk2ckLArgMXZj0AW3n5CAejLUO+PhdQ==}
|
||||||
|
|
||||||
'@vueuse/metadata@10.11.1':
|
'@vueuse/metadata@10.11.1':
|
||||||
resolution: {integrity: sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw==}
|
resolution: {integrity: sha512-IGa5FXd003Ug1qAZmyE8wF3sJ81xGLSqTqtQ6jaVfkeZ4i5kS2mwQF61yhVqojRnenVew5PldLyRgvdl4YYuSw==}
|
||||||
|
|
||||||
'@vueuse/metadata@12.4.0':
|
'@vueuse/metadata@12.4.0':
|
||||||
resolution: {integrity: sha512-AhPuHs/qtYrKHUlEoNO6zCXufu8OgbR8S/n2oMw1OQuBQJ3+HOLQ+EpvXs+feOlZMa0p8QVvDWNlmcJJY8rW2g==}
|
resolution: {integrity: sha512-AhPuHs/qtYrKHUlEoNO6zCXufu8OgbR8S/n2oMw1OQuBQJ3+HOLQ+EpvXs+feOlZMa0p8QVvDWNlmcJJY8rW2g==}
|
||||||
|
|
||||||
|
'@vueuse/metadata@12.8.2':
|
||||||
|
resolution: {integrity: sha512-rAyLGEuoBJ/Il5AmFHiziCPdQzRt88VxR+Y/A/QhJ1EWtWqPBBAxTAFaSkviwEuOEZNtW8pvkPgoCZQ+HxqW1A==}
|
||||||
|
|
||||||
'@vueuse/shared@10.11.1':
|
'@vueuse/shared@10.11.1':
|
||||||
resolution: {integrity: sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==}
|
resolution: {integrity: sha512-LHpC8711VFZlDaYUXEBbFBCQ7GS3dVU9mjOhhMhXP6txTV4EhYQg/KGnQuvt/sPAtoUKq7VVUnL6mVtFoL42sA==}
|
||||||
|
|
||||||
'@vueuse/shared@12.4.0':
|
'@vueuse/shared@12.4.0':
|
||||||
resolution: {integrity: sha512-9yLgbHVIF12OSCojnjTIoZL1+UA10+O4E1aD6Hpfo/DKVm5o3SZIwz6CupqGy3+IcKI8d6Jnl26EQj/YucnW0Q==}
|
resolution: {integrity: sha512-9yLgbHVIF12OSCojnjTIoZL1+UA10+O4E1aD6Hpfo/DKVm5o3SZIwz6CupqGy3+IcKI8d6Jnl26EQj/YucnW0Q==}
|
||||||
|
|
||||||
|
'@vueuse/shared@12.8.2':
|
||||||
|
resolution: {integrity: sha512-dznP38YzxZoNloI0qpEfpkms8knDtaoQ6Y/sfS0L7Yki4zh40LFHEhur0odJC6xTHG5dxWVPiUWBXn+wCG2s5w==}
|
||||||
|
|
||||||
'@withtypes/mime@0.1.2':
|
'@withtypes/mime@0.1.2':
|
||||||
resolution: {integrity: sha512-PB9BfZGzwblUONJY0LiOwsHCA6uV3DIPj/w9ReekdHxPOl0VdUFgI5s4avKycuuq9Gf5Nz2ZPA2O36GAUzlMPA==}
|
resolution: {integrity: sha512-PB9BfZGzwblUONJY0LiOwsHCA6uV3DIPj/w9ReekdHxPOl0VdUFgI5s4avKycuuq9Gf5Nz2ZPA2O36GAUzlMPA==}
|
||||||
|
|
||||||
@@ -1291,8 +1352,8 @@ packages:
|
|||||||
aws4@1.13.2:
|
aws4@1.13.2:
|
||||||
resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==}
|
resolution: {integrity: sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==}
|
||||||
|
|
||||||
axios@1.7.9:
|
axios@1.8.2:
|
||||||
resolution: {integrity: sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==}
|
resolution: {integrity: sha512-ls4GYBm5aig9vWx8AWDSGLpnpDQRtWAfrjU+EuytuODrFBkqesN2RkOQCBzrA1RQNHw1SmRMSDDDSwzNAYQ6Rg==}
|
||||||
|
|
||||||
babel-plugin-macros@3.1.0:
|
babel-plugin-macros@3.1.0:
|
||||||
resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}
|
resolution: {integrity: sha512-Cg7TFGpIr01vOQNODXOOaGz2NpCU5gl8x1qJFbb6hbZxR7XrcE2vtbAsTAbJ7/xwJtUuJEw8K8Zr/AE0LHlesg==}
|
||||||
@@ -1352,6 +1413,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==}
|
resolution: {integrity: sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
call-bind-apply-helpers@1.0.2:
|
||||||
|
resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==}
|
||||||
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
call-bound@1.0.3:
|
call-bound@1.0.3:
|
||||||
resolution: {integrity: sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==}
|
resolution: {integrity: sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
@@ -1761,6 +1826,14 @@ packages:
|
|||||||
resolution: {integrity: sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==}
|
resolution: {integrity: sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
es-object-atoms@1.1.1:
|
||||||
|
resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
|
||||||
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
es-set-tostringtag@2.1.0:
|
||||||
|
resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==}
|
||||||
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
esbuild@0.21.5:
|
esbuild@0.21.5:
|
||||||
resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==}
|
resolution: {integrity: sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
@@ -1933,15 +2006,15 @@ packages:
|
|||||||
debug:
|
debug:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
foreground-child@3.3.0:
|
foreground-child@3.3.1:
|
||||||
resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==}
|
resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==}
|
||||||
engines: {node: '>=14'}
|
engines: {node: '>=14'}
|
||||||
|
|
||||||
forever-agent@0.6.1:
|
forever-agent@0.6.1:
|
||||||
resolution: {integrity: sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==}
|
resolution: {integrity: sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==}
|
||||||
|
|
||||||
form-data@4.0.1:
|
form-data@4.0.2:
|
||||||
resolution: {integrity: sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==}
|
resolution: {integrity: sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
fraction.js@4.3.7:
|
fraction.js@4.3.7:
|
||||||
@@ -1976,6 +2049,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==}
|
resolution: {integrity: sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
get-intrinsic@1.3.0:
|
||||||
|
resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==}
|
||||||
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
get-proto@1.0.1:
|
get-proto@1.0.1:
|
||||||
resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==}
|
resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
@@ -2047,6 +2124,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==}
|
resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
has-tostringtag@1.0.2:
|
||||||
|
resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==}
|
||||||
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
hasown@2.0.2:
|
hasown@2.0.2:
|
||||||
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
|
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
@@ -2426,6 +2507,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==}
|
resolution: {integrity: sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
ohash@2.0.11:
|
||||||
|
resolution: {integrity: sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==}
|
||||||
|
|
||||||
once@1.4.0:
|
once@1.4.0:
|
||||||
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
|
||||||
|
|
||||||
@@ -2528,8 +2612,8 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
pirates@4.0.6:
|
pirates@4.0.7:
|
||||||
resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==}
|
resolution: {integrity: sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
postcss-import@15.1.0:
|
postcss-import@15.1.0:
|
||||||
@@ -2698,8 +2782,8 @@ packages:
|
|||||||
quickselect@2.0.0:
|
quickselect@2.0.0:
|
||||||
resolution: {integrity: sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==}
|
resolution: {integrity: sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==}
|
||||||
|
|
||||||
radix-vue@1.9.12:
|
radix-vue@1.9.17:
|
||||||
resolution: {integrity: sha512-zkr66Jqxbej4+oR6O/pZRzyM/VZi66ndbyIBZQjJKAXa1lIoYReZJse6W1EEDZKXknD7rXhpS+jM9Sr23lIqfg==}
|
resolution: {integrity: sha512-mVCu7I2vXt1L2IUYHTt0sZMz7s1K2ZtqKeTIxG3yC5mMFfLBG4FtE1FDeRMpDd+Hhg/ybi9+iXmAP1ISREndoQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: '>= 3.2.0'
|
vue: '>= 3.2.0'
|
||||||
|
|
||||||
@@ -2717,6 +2801,11 @@ packages:
|
|||||||
regenerator-runtime@0.14.1:
|
regenerator-runtime@0.14.1:
|
||||||
resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==}
|
resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==}
|
||||||
|
|
||||||
|
reka-ui@2.2.0:
|
||||||
|
resolution: {integrity: sha512-eeRrLI4LwJ6dkdwks6KFNKGs0+beqZlHO3JMHen7THDTh+yJ5Z0KNwONmOhhV/0hZC2uJCEExgG60QPzGstkQg==}
|
||||||
|
peerDependencies:
|
||||||
|
vue: '>= 3.2.0'
|
||||||
|
|
||||||
request-progress@3.0.0:
|
request-progress@3.0.0:
|
||||||
resolution: {integrity: sha512-MnWzEHHaxHO2iWiQuHrUPBi/1WeBf5PkxQqNyNvLl9VAYSdXkP8tQ3pBSeCPD+yw0v0Aq1zosWLz0BdeXpWwZg==}
|
resolution: {integrity: sha512-MnWzEHHaxHO2iWiQuHrUPBi/1WeBf5PkxQqNyNvLl9VAYSdXkP8tQ3pBSeCPD+yw0v0Aq1zosWLz0BdeXpWwZg==}
|
||||||
|
|
||||||
@@ -2751,8 +2840,8 @@ packages:
|
|||||||
robust-predicates@3.0.2:
|
robust-predicates@3.0.2:
|
||||||
resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==}
|
resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==}
|
||||||
|
|
||||||
rollup@4.30.1:
|
rollup@4.40.1:
|
||||||
resolution: {integrity: sha512-mlJ4glW020fPuLi7DkM/lN97mYEZGWeqBnrljzN0gs7GLctqX3lNWxKQ7Gl712UAX+6fog/L3jh4gb7R6aVi3w==}
|
resolution: {integrity: sha512-C5VvvgCCyfyotVITIAv+4efVytl5F7wt+/I2i9q9GZcEXW9BP52YYOXC58igUi+LFZVHukErIIqQSWwv/M3WRw==}
|
||||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
@@ -3075,8 +3164,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==}
|
resolution: {integrity: sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==}
|
||||||
engines: {'0': node >=0.6.0}
|
engines: {'0': node >=0.6.0}
|
||||||
|
|
||||||
vite@5.4.11:
|
vite@5.4.18:
|
||||||
resolution: {integrity: sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==}
|
resolution: {integrity: sha512-1oDcnEp3lVyHCuQ2YFelM4Alm2o91xNoMncRm1U7S+JdYfYOvbiGZ3/CxGttrOu2M/KcGz7cRC2DoNUA6urmMA==}
|
||||||
engines: {node: ^18.0.0 || >=20.0.0}
|
engines: {node: ^18.0.0 || >=20.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3131,8 +3220,8 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
eslint: '>=6.0.0'
|
eslint: '>=6.0.0'
|
||||||
|
|
||||||
vue-i18n@9.14.2:
|
vue-i18n@9.14.3:
|
||||||
resolution: {integrity: sha512-JK9Pm80OqssGJU2Y6F7DcM8RFHqVG4WkuCqOZTVsXkEzZME7ABejAUqUdA931zEBedc4thBgSUWxeQh4uocJAQ==}
|
resolution: {integrity: sha512-C+E0KE8ihKjdYCQx8oUkXX+8tBItrYNMnGJuzEPevBARQFUN2tKez6ZVOvBrWH0+KT5wEk3vOWjNk7ygb2u9ig==}
|
||||||
engines: {node: '>= 16'}
|
engines: {node: '>= 16'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.0.0
|
vue: ^3.0.0
|
||||||
@@ -3214,8 +3303,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
|
resolution: {integrity: sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==}
|
||||||
engines: {node: '>= 6'}
|
engines: {node: '>= 6'}
|
||||||
|
|
||||||
yaml@2.7.0:
|
yaml@2.7.1:
|
||||||
resolution: {integrity: sha512-+hSoy/QHluxmC9kCIJyL/uyFmLmc+e5CFR5Wa+bpIhIj85LVb9ZH2nVnqrHoSvKogwODv0ClqZkmiSSaIH5LTA==}
|
resolution: {integrity: sha512-10ULxpnOCQXxJvBgxsn9ptjq6uviG/htZKk9veJGhlqn3w/DxQ631zFF+nlQXLwmImeS5amR2dl2U8sg6U9jsQ==}
|
||||||
engines: {node: '>= 14'}
|
engines: {node: '>= 14'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
@@ -3304,7 +3393,7 @@ snapshots:
|
|||||||
combined-stream: 1.0.8
|
combined-stream: 1.0.8
|
||||||
extend: 3.0.2
|
extend: 3.0.2
|
||||||
forever-agent: 0.6.1
|
forever-agent: 0.6.1
|
||||||
form-data: 4.0.1
|
form-data: 4.0.2
|
||||||
http-signature: 1.4.0
|
http-signature: 1.4.0
|
||||||
is-typedarray: 1.0.0
|
is-typedarray: 1.0.0
|
||||||
isstream: 0.1.2
|
isstream: 0.1.2
|
||||||
@@ -3518,17 +3607,17 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@swc/helpers': 0.5.15
|
'@swc/helpers': 0.5.15
|
||||||
|
|
||||||
'@intlify/core-base@9.14.2':
|
'@intlify/core-base@9.14.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/message-compiler': 9.14.2
|
'@intlify/message-compiler': 9.14.3
|
||||||
'@intlify/shared': 9.14.2
|
'@intlify/shared': 9.14.3
|
||||||
|
|
||||||
'@intlify/message-compiler@9.14.2':
|
'@intlify/message-compiler@9.14.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/shared': 9.14.2
|
'@intlify/shared': 9.14.3
|
||||||
source-map-js: 1.2.1
|
source-map-js: 1.2.1
|
||||||
|
|
||||||
'@intlify/shared@9.14.2': {}
|
'@intlify/shared@9.14.3': {}
|
||||||
|
|
||||||
'@isaacs/cliui@8.0.2':
|
'@isaacs/cliui@8.0.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -3665,61 +3754,64 @@ snapshots:
|
|||||||
|
|
||||||
'@remirror/core-constants@3.0.0': {}
|
'@remirror/core-constants@3.0.0': {}
|
||||||
|
|
||||||
'@rollup/rollup-android-arm-eabi@4.30.1':
|
'@rollup/rollup-android-arm-eabi@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-android-arm64@4.30.1':
|
'@rollup/rollup-android-arm64@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-darwin-arm64@4.30.1':
|
'@rollup/rollup-darwin-arm64@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-darwin-x64@4.30.1':
|
'@rollup/rollup-darwin-x64@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-freebsd-arm64@4.30.1':
|
'@rollup/rollup-freebsd-arm64@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-freebsd-x64@4.30.1':
|
'@rollup/rollup-freebsd-x64@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm-gnueabihf@4.30.1':
|
'@rollup/rollup-linux-arm-gnueabihf@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm-musleabihf@4.30.1':
|
'@rollup/rollup-linux-arm-musleabihf@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm64-gnu@4.30.1':
|
'@rollup/rollup-linux-arm64-gnu@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-arm64-musl@4.30.1':
|
'@rollup/rollup-linux-arm64-musl@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-loongarch64-gnu@4.30.1':
|
'@rollup/rollup-linux-loongarch64-gnu@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-powerpc64le-gnu@4.30.1':
|
'@rollup/rollup-linux-powerpc64le-gnu@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-riscv64-gnu@4.30.1':
|
'@rollup/rollup-linux-riscv64-gnu@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-s390x-gnu@4.30.1':
|
'@rollup/rollup-linux-riscv64-musl@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-x64-gnu@4.30.1':
|
'@rollup/rollup-linux-s390x-gnu@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-linux-x64-musl@4.30.1':
|
'@rollup/rollup-linux-x64-gnu@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-win32-arm64-msvc@4.30.1':
|
'@rollup/rollup-linux-x64-musl@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-win32-ia32-msvc@4.30.1':
|
'@rollup/rollup-win32-arm64-msvc@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rollup/rollup-win32-x64-msvc@4.30.1':
|
'@rollup/rollup-win32-ia32-msvc@4.40.1':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@rollup/rollup-win32-x64-msvc@4.40.1':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@rushstack/eslint-patch@1.10.5': {}
|
'@rushstack/eslint-patch@1.10.5': {}
|
||||||
@@ -3748,6 +3840,8 @@ snapshots:
|
|||||||
|
|
||||||
'@tanstack/virtual-core@3.11.2': {}
|
'@tanstack/virtual-core@3.11.2': {}
|
||||||
|
|
||||||
|
'@tanstack/virtual-core@3.13.6': {}
|
||||||
|
|
||||||
'@tanstack/vue-table@8.20.5(vue@3.5.13(typescript@5.7.3))':
|
'@tanstack/vue-table@8.20.5(vue@3.5.13(typescript@5.7.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tanstack/table-core': 8.20.5
|
'@tanstack/table-core': 8.20.5
|
||||||
@@ -3758,6 +3852,11 @@ snapshots:
|
|||||||
'@tanstack/virtual-core': 3.11.2
|
'@tanstack/virtual-core': 3.11.2
|
||||||
vue: 3.5.13(typescript@5.7.3)
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
|
||||||
|
'@tanstack/vue-virtual@3.13.6(vue@3.5.13(typescript@5.7.3))':
|
||||||
|
dependencies:
|
||||||
|
'@tanstack/virtual-core': 3.13.6
|
||||||
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
|
||||||
'@tiptap/core@2.11.2(@tiptap/pm@2.11.2)':
|
'@tiptap/core@2.11.2(@tiptap/pm@2.11.2)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tiptap/pm': 2.11.2
|
'@tiptap/pm': 2.11.2
|
||||||
@@ -3862,6 +3961,23 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
||||||
|
|
||||||
|
'@tiptap/extension-table-cell@2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))':
|
||||||
|
dependencies:
|
||||||
|
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
||||||
|
|
||||||
|
'@tiptap/extension-table-header@2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))':
|
||||||
|
dependencies:
|
||||||
|
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
||||||
|
|
||||||
|
'@tiptap/extension-table-row@2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))':
|
||||||
|
dependencies:
|
||||||
|
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
||||||
|
|
||||||
|
'@tiptap/extension-table@2.11.5(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))(@tiptap/pm@2.11.2)':
|
||||||
|
dependencies:
|
||||||
|
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
||||||
|
'@tiptap/pm': 2.11.2
|
||||||
|
|
||||||
'@tiptap/extension-text-style@2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))':
|
'@tiptap/extension-text-style@2.11.2(@tiptap/core@2.11.2(@tiptap/pm@2.11.2))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
'@tiptap/core': 2.11.2(@tiptap/pm@2.11.2)
|
||||||
@@ -4054,7 +4170,7 @@ snapshots:
|
|||||||
|
|
||||||
'@types/dagre@0.7.52': {}
|
'@types/dagre@0.7.52': {}
|
||||||
|
|
||||||
'@types/estree@1.0.6': {}
|
'@types/estree@1.0.7': {}
|
||||||
|
|
||||||
'@types/geojson@7946.0.15': {}
|
'@types/geojson@7946.0.15': {}
|
||||||
|
|
||||||
@@ -4134,6 +4250,8 @@ snapshots:
|
|||||||
|
|
||||||
'@types/web-bluetooth@0.0.20': {}
|
'@types/web-bluetooth@0.0.20': {}
|
||||||
|
|
||||||
|
'@types/web-bluetooth@0.0.21': {}
|
||||||
|
|
||||||
'@types/yauzl@2.10.3':
|
'@types/yauzl@2.10.3':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 22.10.5
|
'@types/node': 22.10.5
|
||||||
@@ -4200,9 +4318,9 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- vue
|
- vue
|
||||||
|
|
||||||
'@vitejs/plugin-vue@5.2.1(vite@5.4.11(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0))(vue@3.5.13(typescript@5.7.3))':
|
'@vitejs/plugin-vue@5.2.1(vite@5.4.18(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0))(vue@3.5.13(typescript@5.7.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
vite: 5.4.11(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0)
|
vite: 5.4.18(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0)
|
||||||
vue: 3.5.13(typescript@5.7.3)
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
|
||||||
'@vue/compiler-core@3.5.13':
|
'@vue/compiler-core@3.5.13':
|
||||||
@@ -4307,10 +4425,21 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
|
'@vueuse/core@12.8.2(typescript@5.7.3)':
|
||||||
|
dependencies:
|
||||||
|
'@types/web-bluetooth': 0.0.21
|
||||||
|
'@vueuse/metadata': 12.8.2
|
||||||
|
'@vueuse/shared': 12.8.2(typescript@5.7.3)
|
||||||
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- typescript
|
||||||
|
|
||||||
'@vueuse/metadata@10.11.1': {}
|
'@vueuse/metadata@10.11.1': {}
|
||||||
|
|
||||||
'@vueuse/metadata@12.4.0': {}
|
'@vueuse/metadata@12.4.0': {}
|
||||||
|
|
||||||
|
'@vueuse/metadata@12.8.2': {}
|
||||||
|
|
||||||
'@vueuse/shared@10.11.1(vue@3.5.13(typescript@5.7.3))':
|
'@vueuse/shared@10.11.1(vue@3.5.13(typescript@5.7.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
vue-demi: 0.14.10(vue@3.5.13(typescript@5.7.3))
|
vue-demi: 0.14.10(vue@3.5.13(typescript@5.7.3))
|
||||||
@@ -4324,6 +4453,12 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- typescript
|
- typescript
|
||||||
|
|
||||||
|
'@vueuse/shared@12.8.2(typescript@5.7.3)':
|
||||||
|
dependencies:
|
||||||
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- typescript
|
||||||
|
|
||||||
'@withtypes/mime@0.1.2':
|
'@withtypes/mime@0.1.2':
|
||||||
dependencies:
|
dependencies:
|
||||||
mime: 3.0.0
|
mime: 3.0.0
|
||||||
@@ -4410,10 +4545,10 @@ snapshots:
|
|||||||
|
|
||||||
aws4@1.13.2: {}
|
aws4@1.13.2: {}
|
||||||
|
|
||||||
axios@1.7.9(debug@4.4.0):
|
axios@1.8.2(debug@4.4.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
follow-redirects: 1.15.9(debug@4.4.0)
|
follow-redirects: 1.15.9(debug@4.4.0)
|
||||||
form-data: 4.0.1
|
form-data: 4.0.2
|
||||||
proxy-from-env: 1.1.0
|
proxy-from-env: 1.1.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- debug
|
- debug
|
||||||
@@ -4476,6 +4611,11 @@ snapshots:
|
|||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
function-bind: 1.1.2
|
function-bind: 1.1.2
|
||||||
|
|
||||||
|
call-bind-apply-helpers@1.0.2:
|
||||||
|
dependencies:
|
||||||
|
es-errors: 1.3.0
|
||||||
|
function-bind: 1.1.2
|
||||||
|
|
||||||
call-bound@1.0.3:
|
call-bound@1.0.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
call-bind-apply-helpers: 1.0.1
|
call-bind-apply-helpers: 1.0.1
|
||||||
@@ -4878,7 +5018,7 @@ snapshots:
|
|||||||
|
|
||||||
dunder-proto@1.0.1:
|
dunder-proto@1.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
call-bind-apply-helpers: 1.0.1
|
call-bind-apply-helpers: 1.0.2
|
||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
gopd: 1.2.0
|
gopd: 1.2.0
|
||||||
|
|
||||||
@@ -4924,6 +5064,17 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
es-errors: 1.3.0
|
es-errors: 1.3.0
|
||||||
|
|
||||||
|
es-object-atoms@1.1.1:
|
||||||
|
dependencies:
|
||||||
|
es-errors: 1.3.0
|
||||||
|
|
||||||
|
es-set-tostringtag@2.1.0:
|
||||||
|
dependencies:
|
||||||
|
es-errors: 1.3.0
|
||||||
|
get-intrinsic: 1.3.0
|
||||||
|
has-tostringtag: 1.0.2
|
||||||
|
hasown: 2.0.2
|
||||||
|
|
||||||
esbuild@0.21.5:
|
esbuild@0.21.5:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@esbuild/aix-ppc64': 0.21.5
|
'@esbuild/aix-ppc64': 0.21.5
|
||||||
@@ -5167,17 +5318,18 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
debug: 4.4.0(supports-color@8.1.1)
|
debug: 4.4.0(supports-color@8.1.1)
|
||||||
|
|
||||||
foreground-child@3.3.0:
|
foreground-child@3.3.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
cross-spawn: 7.0.6
|
cross-spawn: 7.0.6
|
||||||
signal-exit: 4.1.0
|
signal-exit: 4.1.0
|
||||||
|
|
||||||
forever-agent@0.6.1: {}
|
forever-agent@0.6.1: {}
|
||||||
|
|
||||||
form-data@4.0.1:
|
form-data@4.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
asynckit: 0.4.0
|
asynckit: 0.4.0
|
||||||
combined-stream: 1.0.8
|
combined-stream: 1.0.8
|
||||||
|
es-set-tostringtag: 2.1.0
|
||||||
mime-types: 2.1.35
|
mime-types: 2.1.35
|
||||||
|
|
||||||
fraction.js@4.3.7: {}
|
fraction.js@4.3.7: {}
|
||||||
@@ -5215,10 +5367,23 @@ snapshots:
|
|||||||
hasown: 2.0.2
|
hasown: 2.0.2
|
||||||
math-intrinsics: 1.1.0
|
math-intrinsics: 1.1.0
|
||||||
|
|
||||||
|
get-intrinsic@1.3.0:
|
||||||
|
dependencies:
|
||||||
|
call-bind-apply-helpers: 1.0.2
|
||||||
|
es-define-property: 1.0.1
|
||||||
|
es-errors: 1.3.0
|
||||||
|
es-object-atoms: 1.1.1
|
||||||
|
function-bind: 1.1.2
|
||||||
|
get-proto: 1.0.1
|
||||||
|
gopd: 1.2.0
|
||||||
|
has-symbols: 1.1.0
|
||||||
|
hasown: 2.0.2
|
||||||
|
math-intrinsics: 1.1.0
|
||||||
|
|
||||||
get-proto@1.0.1:
|
get-proto@1.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
dunder-proto: 1.0.1
|
dunder-proto: 1.0.1
|
||||||
es-object-atoms: 1.0.0
|
es-object-atoms: 1.1.1
|
||||||
|
|
||||||
get-stream@5.2.0:
|
get-stream@5.2.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -5246,7 +5411,7 @@ snapshots:
|
|||||||
|
|
||||||
glob@10.4.5:
|
glob@10.4.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
foreground-child: 3.3.0
|
foreground-child: 3.3.1
|
||||||
jackspeak: 3.4.3
|
jackspeak: 3.4.3
|
||||||
minimatch: 9.0.5
|
minimatch: 9.0.5
|
||||||
minipass: 7.1.2
|
minipass: 7.1.2
|
||||||
@@ -5288,6 +5453,10 @@ snapshots:
|
|||||||
|
|
||||||
has-symbols@1.1.0: {}
|
has-symbols@1.1.0: {}
|
||||||
|
|
||||||
|
has-tostringtag@1.0.2:
|
||||||
|
dependencies:
|
||||||
|
has-symbols: 1.1.0
|
||||||
|
|
||||||
hasown@2.0.2:
|
hasown@2.0.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
function-bind: 1.1.2
|
function-bind: 1.1.2
|
||||||
@@ -5624,6 +5793,8 @@ snapshots:
|
|||||||
|
|
||||||
object-inspect@1.13.3: {}
|
object-inspect@1.13.3: {}
|
||||||
|
|
||||||
|
ohash@2.0.11: {}
|
||||||
|
|
||||||
once@1.4.0:
|
once@1.4.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
wrappy: 1.0.2
|
wrappy: 1.0.2
|
||||||
@@ -5718,7 +5889,7 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- '@vue/composition-api'
|
- '@vue/composition-api'
|
||||||
|
|
||||||
pirates@4.0.6: {}
|
pirates@4.0.7: {}
|
||||||
|
|
||||||
postcss-import@15.1.0(postcss@8.4.49):
|
postcss-import@15.1.0(postcss@8.4.49):
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -5735,7 +5906,7 @@ snapshots:
|
|||||||
postcss-load-config@4.0.2(postcss@8.4.49):
|
postcss-load-config@4.0.2(postcss@8.4.49):
|
||||||
dependencies:
|
dependencies:
|
||||||
lilconfig: 3.1.3
|
lilconfig: 3.1.3
|
||||||
yaml: 2.7.0
|
yaml: 2.7.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
postcss: 8.4.49
|
postcss: 8.4.49
|
||||||
|
|
||||||
@@ -5908,7 +6079,7 @@ snapshots:
|
|||||||
|
|
||||||
quickselect@2.0.0: {}
|
quickselect@2.0.0: {}
|
||||||
|
|
||||||
radix-vue@1.9.12(vue@3.5.13(typescript@5.7.3)):
|
radix-vue@1.9.17(vue@3.5.13(typescript@5.7.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@floating-ui/dom': 1.6.13
|
'@floating-ui/dom': 1.6.13
|
||||||
'@floating-ui/vue': 1.1.6(vue@3.5.13(typescript@5.7.3))
|
'@floating-ui/vue': 1.1.6(vue@3.5.13(typescript@5.7.3))
|
||||||
@@ -5937,6 +6108,23 @@ snapshots:
|
|||||||
|
|
||||||
regenerator-runtime@0.14.1: {}
|
regenerator-runtime@0.14.1: {}
|
||||||
|
|
||||||
|
reka-ui@2.2.0(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3)):
|
||||||
|
dependencies:
|
||||||
|
'@floating-ui/dom': 1.6.13
|
||||||
|
'@floating-ui/vue': 1.1.6(vue@3.5.13(typescript@5.7.3))
|
||||||
|
'@internationalized/date': 3.6.0
|
||||||
|
'@internationalized/number': 3.6.0
|
||||||
|
'@tanstack/vue-virtual': 3.13.6(vue@3.5.13(typescript@5.7.3))
|
||||||
|
'@vueuse/core': 12.8.2(typescript@5.7.3)
|
||||||
|
'@vueuse/shared': 12.8.2(typescript@5.7.3)
|
||||||
|
aria-hidden: 1.2.4
|
||||||
|
defu: 6.1.4
|
||||||
|
ohash: 2.0.11
|
||||||
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@vue/composition-api'
|
||||||
|
- typescript
|
||||||
|
|
||||||
request-progress@3.0.0:
|
request-progress@3.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
throttleit: 1.0.1
|
throttleit: 1.0.1
|
||||||
@@ -5968,29 +6156,30 @@ snapshots:
|
|||||||
|
|
||||||
robust-predicates@3.0.2: {}
|
robust-predicates@3.0.2: {}
|
||||||
|
|
||||||
rollup@4.30.1:
|
rollup@4.40.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/estree': 1.0.6
|
'@types/estree': 1.0.7
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@rollup/rollup-android-arm-eabi': 4.30.1
|
'@rollup/rollup-android-arm-eabi': 4.40.1
|
||||||
'@rollup/rollup-android-arm64': 4.30.1
|
'@rollup/rollup-android-arm64': 4.40.1
|
||||||
'@rollup/rollup-darwin-arm64': 4.30.1
|
'@rollup/rollup-darwin-arm64': 4.40.1
|
||||||
'@rollup/rollup-darwin-x64': 4.30.1
|
'@rollup/rollup-darwin-x64': 4.40.1
|
||||||
'@rollup/rollup-freebsd-arm64': 4.30.1
|
'@rollup/rollup-freebsd-arm64': 4.40.1
|
||||||
'@rollup/rollup-freebsd-x64': 4.30.1
|
'@rollup/rollup-freebsd-x64': 4.40.1
|
||||||
'@rollup/rollup-linux-arm-gnueabihf': 4.30.1
|
'@rollup/rollup-linux-arm-gnueabihf': 4.40.1
|
||||||
'@rollup/rollup-linux-arm-musleabihf': 4.30.1
|
'@rollup/rollup-linux-arm-musleabihf': 4.40.1
|
||||||
'@rollup/rollup-linux-arm64-gnu': 4.30.1
|
'@rollup/rollup-linux-arm64-gnu': 4.40.1
|
||||||
'@rollup/rollup-linux-arm64-musl': 4.30.1
|
'@rollup/rollup-linux-arm64-musl': 4.40.1
|
||||||
'@rollup/rollup-linux-loongarch64-gnu': 4.30.1
|
'@rollup/rollup-linux-loongarch64-gnu': 4.40.1
|
||||||
'@rollup/rollup-linux-powerpc64le-gnu': 4.30.1
|
'@rollup/rollup-linux-powerpc64le-gnu': 4.40.1
|
||||||
'@rollup/rollup-linux-riscv64-gnu': 4.30.1
|
'@rollup/rollup-linux-riscv64-gnu': 4.40.1
|
||||||
'@rollup/rollup-linux-s390x-gnu': 4.30.1
|
'@rollup/rollup-linux-riscv64-musl': 4.40.1
|
||||||
'@rollup/rollup-linux-x64-gnu': 4.30.1
|
'@rollup/rollup-linux-s390x-gnu': 4.40.1
|
||||||
'@rollup/rollup-linux-x64-musl': 4.30.1
|
'@rollup/rollup-linux-x64-gnu': 4.40.1
|
||||||
'@rollup/rollup-win32-arm64-msvc': 4.30.1
|
'@rollup/rollup-linux-x64-musl': 4.40.1
|
||||||
'@rollup/rollup-win32-ia32-msvc': 4.30.1
|
'@rollup/rollup-win32-arm64-msvc': 4.40.1
|
||||||
'@rollup/rollup-win32-x64-msvc': 4.30.1
|
'@rollup/rollup-win32-ia32-msvc': 4.40.1
|
||||||
|
'@rollup/rollup-win32-x64-msvc': 4.40.1
|
||||||
fsevents: 2.3.3
|
fsevents: 2.3.3
|
||||||
|
|
||||||
rope-sequence@1.3.4: {}
|
rope-sequence@1.3.4: {}
|
||||||
@@ -6172,7 +6361,7 @@ snapshots:
|
|||||||
glob: 10.4.5
|
glob: 10.4.5
|
||||||
lines-and-columns: 1.2.4
|
lines-and-columns: 1.2.4
|
||||||
mz: 2.7.0
|
mz: 2.7.0
|
||||||
pirates: 4.0.6
|
pirates: 4.0.7
|
||||||
ts-interface-checker: 0.1.13
|
ts-interface-checker: 0.1.13
|
||||||
|
|
||||||
supercluster@7.1.5:
|
supercluster@7.1.5:
|
||||||
@@ -6339,11 +6528,11 @@ snapshots:
|
|||||||
core-util-is: 1.0.2
|
core-util-is: 1.0.2
|
||||||
extsprintf: 1.3.0
|
extsprintf: 1.3.0
|
||||||
|
|
||||||
vite@5.4.11(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0):
|
vite@5.4.18(@types/node@22.10.5)(sass@1.83.1)(stylus@0.57.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
esbuild: 0.21.5
|
esbuild: 0.21.5
|
||||||
postcss: 8.4.49
|
postcss: 8.4.49
|
||||||
rollup: 4.30.1
|
rollup: 4.40.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@types/node': 22.10.5
|
'@types/node': 22.10.5
|
||||||
fsevents: 2.3.3
|
fsevents: 2.3.3
|
||||||
@@ -6378,10 +6567,10 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
vue-i18n@9.14.2(vue@3.5.13(typescript@5.7.3)):
|
vue-i18n@9.14.3(vue@3.5.13(typescript@5.7.3)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@intlify/core-base': 9.14.2
|
'@intlify/core-base': 9.14.3
|
||||||
'@intlify/shared': 9.14.2
|
'@intlify/shared': 9.14.3
|
||||||
'@vue/devtools-api': 6.6.4
|
'@vue/devtools-api': 6.6.4
|
||||||
vue: 3.5.13(typescript@5.7.3)
|
vue: 3.5.13(typescript@5.7.3)
|
||||||
|
|
||||||
@@ -6429,7 +6618,7 @@ snapshots:
|
|||||||
|
|
||||||
wait-on@8.0.1(debug@4.4.0):
|
wait-on@8.0.1(debug@4.4.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
axios: 1.7.9(debug@4.4.0)
|
axios: 1.8.2(debug@4.4.0)
|
||||||
joi: 17.13.3
|
joi: 17.13.3
|
||||||
lodash: 4.17.21
|
lodash: 4.17.21
|
||||||
minimist: 1.2.8
|
minimist: 1.2.8
|
||||||
@@ -6471,7 +6660,7 @@ snapshots:
|
|||||||
|
|
||||||
yaml@1.10.2: {}
|
yaml@1.10.2: {}
|
||||||
|
|
||||||
yaml@2.7.0: {}
|
yaml@2.7.1: {}
|
||||||
|
|
||||||
yauzl@2.10.0:
|
yauzl@2.10.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -14,10 +14,14 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
<SidebarMenuItem v-if="userStore.hasAdminTabPermissions">
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton asChild :isActive="route.path.startsWith('/admin')">
|
<SidebarMenuButton
|
||||||
<router-link :to="{ name: 'admin' }">
|
asChild
|
||||||
<Shield />
|
:isActive="route.path.startsWith('/contacts')"
|
||||||
|
v-if="userStore.can('contacts:read_all')"
|
||||||
|
>
|
||||||
|
<router-link :to="{ name: 'contacts' }">
|
||||||
|
<BookUser />
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
@@ -28,6 +32,15 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
|
<SidebarMenuItem v-if="userStore.hasAdminTabPermissions">
|
||||||
|
<SidebarMenuButton asChild :isActive="route.path.startsWith('/admin')">
|
||||||
|
<router-link
|
||||||
|
:to="{ name: userStore.can('general_settings:manage') ? 'general' : 'admin' }"
|
||||||
|
>
|
||||||
|
<Shield />
|
||||||
|
</router-link>
|
||||||
|
</SidebarMenuButton>
|
||||||
|
</SidebarMenuItem>
|
||||||
</SidebarMenu>
|
</SidebarMenu>
|
||||||
</SidebarGroupContent>
|
</SidebarGroupContent>
|
||||||
</SidebarGroup>
|
</SidebarGroup>
|
||||||
@@ -46,7 +59,7 @@
|
|||||||
@create-view="openCreateViewForm = true"
|
@create-view="openCreateViewForm = true"
|
||||||
@edit-view="editView"
|
@edit-view="editView"
|
||||||
@delete-view="deleteView"
|
@delete-view="deleteView"
|
||||||
@create-conversation="() => openCreateConversationDialog = true"
|
@create-conversation="() => (openCreateConversationDialog = true)"
|
||||||
>
|
>
|
||||||
<div class="flex flex-col h-screen">
|
<div class="flex flex-col h-screen">
|
||||||
<!-- Show app update only in admin routes -->
|
<!-- Show app update only in admin routes -->
|
||||||
@@ -85,6 +98,7 @@ import { useTeamStore } from '@/stores/team'
|
|||||||
import { useSlaStore } from '@/stores/sla'
|
import { useSlaStore } from '@/stores/sla'
|
||||||
import { useMacroStore } from '@/stores/macro'
|
import { useMacroStore } from '@/stores/macro'
|
||||||
import { useTagStore } from '@/stores/tag'
|
import { useTagStore } from '@/stores/tag'
|
||||||
|
import { useCustomAttributeStore } from '@/stores/customAttributes'
|
||||||
import { useIdleDetection } from '@/composables/useIdleDetection'
|
import { useIdleDetection } from '@/composables/useIdleDetection'
|
||||||
import PageHeader from './components/layout/PageHeader.vue'
|
import PageHeader from './components/layout/PageHeader.vue'
|
||||||
import ViewForm from '@/features/view/ViewForm.vue'
|
import ViewForm from '@/features/view/ViewForm.vue'
|
||||||
@@ -94,7 +108,8 @@ import { toast as sooner } from 'vue-sonner'
|
|||||||
import Sidebar from '@/components/sidebar/Sidebar.vue'
|
import Sidebar from '@/components/sidebar/Sidebar.vue'
|
||||||
import Command from '@/features/command/CommandBox.vue'
|
import Command from '@/features/command/CommandBox.vue'
|
||||||
import CreateConversation from '@/features/conversation/CreateConversation.vue'
|
import CreateConversation from '@/features/conversation/CreateConversation.vue'
|
||||||
import { Inbox, Shield, FileLineChart } from 'lucide-vue-next'
|
import { Inbox, Shield, FileLineChart, BookUser } from 'lucide-vue-next'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import {
|
import {
|
||||||
Sidebar as ShadcnSidebar,
|
Sidebar as ShadcnSidebar,
|
||||||
@@ -119,10 +134,12 @@ const inboxStore = useInboxStore()
|
|||||||
const slaStore = useSlaStore()
|
const slaStore = useSlaStore()
|
||||||
const macroStore = useMacroStore()
|
const macroStore = useMacroStore()
|
||||||
const tagStore = useTagStore()
|
const tagStore = useTagStore()
|
||||||
|
const customAttributeStore = useCustomAttributeStore()
|
||||||
const userViews = ref([])
|
const userViews = ref([])
|
||||||
const view = ref({})
|
const view = ref({})
|
||||||
const openCreateViewForm = ref(false)
|
const openCreateViewForm = ref(false)
|
||||||
const openCreateConversationDialog = ref(false)
|
const openCreateConversationDialog = ref(false)
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
initWS()
|
initWS()
|
||||||
useIdleDetection()
|
useIdleDetection()
|
||||||
@@ -133,7 +150,7 @@ onMounted(() => {
|
|||||||
initStores()
|
initStores()
|
||||||
})
|
})
|
||||||
|
|
||||||
// initialize data stores
|
// Initialize data stores
|
||||||
const initStores = async () => {
|
const initStores = async () => {
|
||||||
if (!userStore.userID) {
|
if (!userStore.userID) {
|
||||||
await userStore.getCurrentUser()
|
await userStore.getCurrentUser()
|
||||||
@@ -147,7 +164,8 @@ const initStores = async () => {
|
|||||||
inboxStore.fetchInboxes(),
|
inboxStore.fetchInboxes(),
|
||||||
slaStore.fetchSlas(),
|
slaStore.fetchSlas(),
|
||||||
macroStore.loadMacros(),
|
macroStore.loadMacros(),
|
||||||
tagStore.fetchTags()
|
tagStore.fetchTags(),
|
||||||
|
customAttributeStore.fetchCustomAttributes()
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,8 +179,9 @@ const deleteView = async (view) => {
|
|||||||
await api.deleteView(view.id)
|
await api.deleteView(view.id)
|
||||||
emitter.emit(EMITTER_EVENTS.REFRESH_LIST, { model: 'view' })
|
emitter.emit(EMITTER_EVENTS.REFRESH_LIST, { model: 'view' })
|
||||||
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
||||||
title: 'Success',
|
description: t('globals.messages.deletedSuccessfully', {
|
||||||
description: 'View deleted successfully'
|
name: t('globals.terms.view')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
||||||
@@ -179,7 +198,6 @@ const getUserViews = async () => {
|
|||||||
userViews.value = response.data.data
|
userViews.value = response.data.data
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
emitter.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
||||||
title: 'Error',
|
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
description: handleHTTPError(err).message
|
description: handleHTTPError(err).message
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,12 +33,26 @@ http.interceptors.request.use((request) => {
|
|||||||
return request
|
return request
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const getCustomAttributes = (appliesTo) => http.get('/api/v1/custom-attributes', {
|
||||||
|
params: { applies_to: appliesTo }
|
||||||
|
})
|
||||||
|
const createCustomAttribute = (data) =>
|
||||||
|
http.post('/api/v1/custom-attributes', data, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const getCustomAttribute = (id) => http.get(`/api/v1/custom-attributes/${id}`)
|
||||||
|
const updateCustomAttribute = (id, data) =>
|
||||||
|
http.put(`/api/v1/custom-attributes/${id}`, data, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const deleteCustomAttribute = (id) => http.delete(`/api/v1/custom-attributes/${id}`)
|
||||||
const searchConversations = (params) => http.get('/api/v1/conversations/search', { params })
|
const searchConversations = (params) => http.get('/api/v1/conversations/search', { params })
|
||||||
const searchMessages = (params) => http.get('/api/v1/messages/search', { params })
|
const searchMessages = (params) => http.get('/api/v1/messages/search', { params })
|
||||||
const searchContacts = (params) => http.get('/api/v1/contacts/search', { params })
|
const searchContacts = (params) => http.get('/api/v1/contacts/search', { params })
|
||||||
const resetPassword = (data) => http.post('/api/v1/users/reset-password', data)
|
|
||||||
const setPassword = (data) => http.post('/api/v1/users/set-password', data)
|
|
||||||
const deleteUser = (id) => http.delete(`/api/v1/users/${id}`)
|
|
||||||
const getEmailNotificationSettings = () => http.get('/api/v1/settings/notifications/email')
|
const getEmailNotificationSettings = () => http.get('/api/v1/settings/notifications/email')
|
||||||
const updateEmailNotificationSettings = (data) => http.put('/api/v1/settings/notifications/email', data)
|
const updateEmailNotificationSettings = (data) => http.put('/api/v1/settings/notifications/email', data)
|
||||||
const getPriorities = () => http.get('/api/v1/priorities')
|
const getPriorities = () => http.get('/api/v1/priorities')
|
||||||
@@ -82,8 +96,16 @@ const deleteBusinessHours = (id) => http.delete(`/api/v1/business-hours/${id}`)
|
|||||||
|
|
||||||
const getAllSLAs = () => http.get('/api/v1/sla')
|
const getAllSLAs = () => http.get('/api/v1/sla')
|
||||||
const getSLA = (id) => http.get(`/api/v1/sla/${id}`)
|
const getSLA = (id) => http.get(`/api/v1/sla/${id}`)
|
||||||
const createSLA = (data) => http.post('/api/v1/sla', data)
|
const createSLA = (data) => http.post('/api/v1/sla', data, {
|
||||||
const updateSLA = (id, data) => http.put(`/api/v1/sla/${id}`, data)
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const updateSLA = (id, data) => http.put(`/api/v1/sla/${id}`, data, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
const deleteSLA = (id) => http.delete(`/api/v1/sla/${id}`)
|
const deleteSLA = (id) => http.delete(`/api/v1/sla/${id}`)
|
||||||
const createOIDC = (data) =>
|
const createOIDC = (data) =>
|
||||||
http.post('/api/v1/oidc', data, {
|
http.post('/api/v1/oidc', data, {
|
||||||
@@ -111,31 +133,31 @@ const updateSettings = (key, data) =>
|
|||||||
const getSettings = (key) => http.get(`/api/v1/settings/${key}`)
|
const getSettings = (key) => http.get(`/api/v1/settings/${key}`)
|
||||||
const login = (data) => http.post(`/api/v1/login`, data)
|
const login = (data) => http.post(`/api/v1/login`, data)
|
||||||
const getAutomationRules = (type) =>
|
const getAutomationRules = (type) =>
|
||||||
http.get(`/api/v1/automation/rules`, {
|
http.get(`/api/v1/automations/rules`, {
|
||||||
params: { type: type }
|
params: { type: type }
|
||||||
})
|
})
|
||||||
const toggleAutomationRule = (id) => http.put(`/api/v1/automation/rules/${id}/toggle`)
|
const toggleAutomationRule = (id) => http.put(`/api/v1/automations/rules/${id}/toggle`)
|
||||||
const getAutomationRule = (id) => http.get(`/api/v1/automation/rules/${id}`)
|
const getAutomationRule = (id) => http.get(`/api/v1/automations/rules/${id}`)
|
||||||
const updateAutomationRule = (id, data) =>
|
const updateAutomationRule = (id, data) =>
|
||||||
http.put(`/api/v1/automation/rules/${id}`, data, {
|
http.put(`/api/v1/automations/rules/${id}`, data, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const createAutomationRule = (data) =>
|
const createAutomationRule = (data) =>
|
||||||
http.post(`/api/v1/automation/rules`, data, {
|
http.post(`/api/v1/automations/rules`, data, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const deleteAutomationRule = (id) => http.delete(`/api/v1/automation/rules/${id}`)
|
const deleteAutomationRule = (id) => http.delete(`/api/v1/automations/rules/${id}`)
|
||||||
const updateAutomationRuleWeights = (data) =>
|
const updateAutomationRuleWeights = (data) =>
|
||||||
http.put(`/api/v1/automation/rules/weights`, data, {
|
http.put(`/api/v1/automations/rules/weights`, data, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const updateAutomationRulesExecutionMode = (data) => http.put(`/api/v1/automation/rules/execution-mode`, data)
|
const updateAutomationRulesExecutionMode = (data) => http.put(`/api/v1/automations/rules/execution-mode`, data)
|
||||||
const getRoles = () => http.get('/api/v1/roles')
|
const getRoles = () => http.get('/api/v1/roles')
|
||||||
const getRole = (id) => http.get(`/api/v1/roles/${id}`)
|
const getRole = (id) => http.get(`/api/v1/roles/${id}`)
|
||||||
const createRole = (data) =>
|
const createRole = (data) =>
|
||||||
@@ -151,30 +173,64 @@ const updateRole = (id, data) =>
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const deleteRole = (id) => http.delete(`/api/v1/roles/${id}`)
|
const deleteRole = (id) => http.delete(`/api/v1/roles/${id}`)
|
||||||
const getUser = (id) => http.get(`/api/v1/users/${id}`)
|
const getContacts = (params) => http.get('/api/v1/contacts', { params })
|
||||||
|
const getContact = (id) => http.get(`/api/v1/contacts/${id}`)
|
||||||
|
const updateContact = (id, data) => http.put(`/api/v1/contacts/${id}`, data, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const blockContact = (id, data) => http.put(`/api/v1/contacts/${id}/block`, data)
|
||||||
const getTeam = (id) => http.get(`/api/v1/teams/${id}`)
|
const getTeam = (id) => http.get(`/api/v1/teams/${id}`)
|
||||||
const getTeams = () => http.get('/api/v1/teams')
|
const getTeams = () => http.get('/api/v1/teams')
|
||||||
const updateTeam = (id, data) => http.put(`/api/v1/teams/${id}`, data)
|
const updateTeam = (id, data) => http.put(`/api/v1/teams/${id}`, data)
|
||||||
const createTeam = (data) => http.post('/api/v1/teams', data)
|
const createTeam = (data) => http.post('/api/v1/teams', data)
|
||||||
const getTeamsCompact = () => http.get('/api/v1/teams/compact')
|
const getTeamsCompact = () => http.get('/api/v1/teams/compact')
|
||||||
const deleteTeam = (id) => http.delete(`/api/v1/teams/${id}`)
|
const deleteTeam = (id) => http.delete(`/api/v1/teams/${id}`)
|
||||||
|
const updateUser = (id, data) =>
|
||||||
const getUsers = () => http.get('/api/v1/users')
|
http.put(`/api/v1/agents/${id}`, data, {
|
||||||
const getUsersCompact = () => http.get('/api/v1/users/compact')
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const getUsers = () => http.get('/api/v1/agents')
|
||||||
|
const getUsersCompact = () => http.get('/api/v1/agents/compact')
|
||||||
const updateCurrentUser = (data) =>
|
const updateCurrentUser = (data) =>
|
||||||
http.put('/api/v1/users/me', data, {
|
http.put('/api/v1/agents/me', data, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data'
|
'Content-Type': 'multipart/form-data'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const deleteUserAvatar = () => http.delete('/api/v1/users/me/avatar')
|
const getUser = (id) => http.get(`/api/v1/agents/${id}`)
|
||||||
const getCurrentUser = () => http.get('/api/v1/users/me')
|
const deleteUserAvatar = () => http.delete('/api/v1/agents/me/avatar')
|
||||||
const getCurrentUserTeams = () => http.get('/api/v1/users/me/teams')
|
const getCurrentUser = () => http.get('/api/v1/agents/me')
|
||||||
const updateCurrentUserAvailability = (data) => http.put('/api/v1/users/me/availability', data)
|
const getCurrentUserTeams = () => http.get('/api/v1/agents/me/teams')
|
||||||
|
const updateCurrentUserAvailability = (data) => http.put('/api/v1/agents/me/availability', data)
|
||||||
|
const resetPassword = (data) => http.post('/api/v1/agents/reset-password', data)
|
||||||
|
const setPassword = (data) => http.post('/api/v1/agents/set-password', data)
|
||||||
|
const deleteUser = (id) => http.delete(`/api/v1/agents/${id}`)
|
||||||
|
const createUser = (data) =>
|
||||||
|
http.post('/api/v1/agents', data, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
const getTags = () => http.get('/api/v1/tags')
|
const getTags = () => http.get('/api/v1/tags')
|
||||||
const upsertTags = (uuid, data) => http.post(`/api/v1/conversations/${uuid}/tags`, data)
|
const upsertTags = (uuid, data) => http.post(`/api/v1/conversations/${uuid}/tags`, data)
|
||||||
const updateAssignee = (uuid, assignee_type, data) => http.put(`/api/v1/conversations/${uuid}/assignee/${assignee_type}`, data)
|
const updateAssignee = (uuid, assignee_type, data) => http.put(`/api/v1/conversations/${uuid}/assignee/${assignee_type}`, data)
|
||||||
const removeAssignee = (uuid, assignee_type) => http.put(`/api/v1/conversations/${uuid}/assignee/${assignee_type}/remove`)
|
const removeAssignee = (uuid, assignee_type) => http.put(`/api/v1/conversations/${uuid}/assignee/${assignee_type}/remove`)
|
||||||
|
const updateContactCustomAttribute = (uuid, data) => http.put(`/api/v1/conversations/${uuid}/contacts/custom-attributes`, data,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const updateConversationCustomAttribute = (uuid, data) => http.put(`/api/v1/conversations/${uuid}/custom-attributes`, data,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
const createConversation = (data) => http.post('/api/v1/conversations', data)
|
const createConversation = (data) => http.post('/api/v1/conversations', data)
|
||||||
const updateConversationStatus = (uuid, data) => http.put(`/api/v1/conversations/${uuid}/status`, data)
|
const updateConversationStatus = (uuid, data) => http.put(`/api/v1/conversations/${uuid}/status`, data)
|
||||||
const updateConversationPriority = (uuid, data) => http.put(`/api/v1/conversations/${uuid}/priority`, data)
|
const updateConversationPriority = (uuid, data) => http.put(`/api/v1/conversations/${uuid}/priority`, data)
|
||||||
@@ -223,18 +279,6 @@ const uploadMedia = (data) =>
|
|||||||
const getOverviewCounts = () => http.get('/api/v1/reports/overview/counts')
|
const getOverviewCounts = () => http.get('/api/v1/reports/overview/counts')
|
||||||
const getOverviewCharts = () => http.get('/api/v1/reports/overview/charts')
|
const getOverviewCharts = () => http.get('/api/v1/reports/overview/charts')
|
||||||
const getLanguage = (lang) => http.get(`/api/v1/lang/${lang}`)
|
const getLanguage = (lang) => http.get(`/api/v1/lang/${lang}`)
|
||||||
const createUser = (data) =>
|
|
||||||
http.post('/api/v1/users', data, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const updateUser = (id, data) =>
|
|
||||||
http.put(`/api/v1/users/${id}`, data, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const createInbox = (data) =>
|
const createInbox = (data) =>
|
||||||
http.post('/api/v1/inboxes', data, {
|
http.post('/api/v1/inboxes', data, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -268,6 +312,10 @@ const deleteView = (id) => http.delete(`/api/v1/views/me/${id}`)
|
|||||||
const getAiPrompts = () => http.get('/api/v1/ai/prompts')
|
const getAiPrompts = () => http.get('/api/v1/ai/prompts')
|
||||||
const aiCompletion = (data) => http.post('/api/v1/ai/completion', data)
|
const aiCompletion = (data) => http.post('/api/v1/ai/completion', data)
|
||||||
const updateAIProvider = (data) => http.put('/api/v1/ai/provider', data)
|
const updateAIProvider = (data) => http.put('/api/v1/ai/provider', data)
|
||||||
|
const getContactNotes = (id) => http.get(`/api/v1/contacts/${id}/notes`)
|
||||||
|
const createContactNote = (id, data) => http.post(`/api/v1/contacts/${id}/notes`, data)
|
||||||
|
const deleteContactNote = (id, noteId) => http.delete(`/api/v1/contacts/${id}/notes/${noteId}`)
|
||||||
|
const getActivityLogs = (params) => http.get('/api/v1/activity-logs', { params })
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
login,
|
login,
|
||||||
@@ -324,6 +372,8 @@ export default {
|
|||||||
updateConversationStatus,
|
updateConversationStatus,
|
||||||
updateConversationPriority,
|
updateConversationPriority,
|
||||||
upsertTags,
|
upsertTags,
|
||||||
|
updateConversationCustomAttribute,
|
||||||
|
updateContactCustomAttribute,
|
||||||
uploadMedia,
|
uploadMedia,
|
||||||
updateAssigneeLastSeen,
|
updateAssigneeLastSeen,
|
||||||
updateUser,
|
updateUser,
|
||||||
@@ -382,4 +432,17 @@ export default {
|
|||||||
searchMessages,
|
searchMessages,
|
||||||
searchContacts,
|
searchContacts,
|
||||||
removeAssignee,
|
removeAssignee,
|
||||||
|
getContacts,
|
||||||
|
getContact,
|
||||||
|
updateContact,
|
||||||
|
blockContact,
|
||||||
|
getCustomAttributes,
|
||||||
|
createCustomAttribute,
|
||||||
|
updateCustomAttribute,
|
||||||
|
deleteCustomAttribute,
|
||||||
|
getCustomAttribute,
|
||||||
|
getContactNotes,
|
||||||
|
createContactNote,
|
||||||
|
deleteContactNote,
|
||||||
|
getActivityLogs
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
--border: 240 5.9% 90%;
|
--border: 240 5.9% 90%;
|
||||||
--input: 240 5.9% 90%;
|
--input: 240 5.9% 90%;
|
||||||
--ring: 240 5.9% 10%;
|
--ring: 240 5.9% 10%;
|
||||||
--radius: 0.75rem;
|
--radius: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
.dark {
|
||||||
@@ -183,15 +183,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-bubble {
|
.message-bubble {
|
||||||
@apply flex
|
@apply flex flex-col px-4 pt-2 pb-3 w-fit min-w-[30%] max-w-full border overflow-x-auto rounded-xl;
|
||||||
flex-col
|
|
||||||
px-4
|
|
||||||
pt-2
|
|
||||||
pb-3
|
|
||||||
min-w-[30%] max-w-[70%]
|
|
||||||
border
|
|
||||||
overflow-x-auto
|
|
||||||
rounded-xl;
|
|
||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||||
table {
|
table {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
@@ -359,3 +351,10 @@ a[data-active='false']:hover {
|
|||||||
[data-radix-popper-content-wrapper] {
|
[data-radix-popper-content-wrapper] {
|
||||||
z-index: 9999 !important;
|
z-index: 9999 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Components
|
||||||
|
@layer components {
|
||||||
|
.link-style {
|
||||||
|
@apply text-blue-500 hover:underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,15 +5,22 @@
|
|||||||
<TableHeader>
|
<TableHeader>
|
||||||
<TableRow v-for="headerGroup in table.getHeaderGroups()" :key="headerGroup.id">
|
<TableRow v-for="headerGroup in table.getHeaderGroups()" :key="headerGroup.id">
|
||||||
<TableHead v-for="header in headerGroup.headers" :key="header.id" class="font-semibold">
|
<TableHead v-for="header in headerGroup.headers" :key="header.id" class="font-semibold">
|
||||||
<FlexRender v-if="!header.isPlaceholder" :render="header.column.columnDef.header"
|
<FlexRender
|
||||||
:props="header.getContext()" />
|
v-if="!header.isPlaceholder"
|
||||||
|
:render="header.column.columnDef.header"
|
||||||
|
:props="header.getContext()"
|
||||||
|
/>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<template v-if="table.getRowModel().rows?.length">
|
<template v-if="table.getRowModel().rows?.length">
|
||||||
<TableRow v-for="row in table.getRowModel().rows" :key="row.id"
|
<TableRow
|
||||||
:data-state="row.getIsSelected() ? 'selected' : undefined" class="hover:bg-muted/50">
|
v-for="row in table.getRowModel().rows"
|
||||||
|
:key="row.id"
|
||||||
|
:data-state="row.getIsSelected() ? 'selected' : undefined"
|
||||||
|
class="hover:bg-muted/50"
|
||||||
|
>
|
||||||
<TableCell v-for="cell in row.getVisibleCells()" :key="cell.id">
|
<TableCell v-for="cell in row.getVisibleCells()" :key="cell.id">
|
||||||
<FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
|
<FlexRender :render="cell.column.columnDef.cell" :props="cell.getContext()" />
|
||||||
</TableCell>
|
</TableCell>
|
||||||
@@ -32,9 +39,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { FlexRender, getCoreRowModel, useVueTable } from '@tanstack/vue-table'
|
import { FlexRender, getCoreRowModel, useVueTable } from '@tanstack/vue-table'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
@@ -45,20 +53,30 @@ import {
|
|||||||
TableRow
|
TableRow
|
||||||
} from '@/components/ui/table'
|
} from '@/components/ui/table'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
columns: Array,
|
columns: Array,
|
||||||
data: Array,
|
data: Array,
|
||||||
emptyText: {
|
emptyText: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'No results.'
|
default: ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Set the default value for emptyText if it's empty
|
||||||
|
const emptyText = computed(
|
||||||
|
() =>
|
||||||
|
props.emptyText ||
|
||||||
|
t('globals.messages.noResults', {
|
||||||
|
name: t('globals.terms.result', 2).toLowerCase()
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
const table = useVueTable({
|
const table = useVueTable({
|
||||||
get data () {
|
get data() {
|
||||||
return props.data
|
return props.data
|
||||||
},
|
},
|
||||||
get columns () {
|
get columns() {
|
||||||
return props.columns
|
return props.columns
|
||||||
},
|
},
|
||||||
getCoreRowModel: getCoreRowModel()
|
getCoreRowModel: getCoreRowModel()
|
||||||
|
|||||||
237
frontend/src/components/filter/FilterBuilder.vue
Normal file
237
frontend/src/components/filter/FilterBuilder.vue
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
<template>
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div class="w-[27rem]" v-if="modelValue.length === 0"></div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-for="(modelFilter, index) in modelValue"
|
||||||
|
:key="index"
|
||||||
|
class="group flex items-center gap-3"
|
||||||
|
>
|
||||||
|
<div class="flex gap-2 w-full">
|
||||||
|
<!-- Field -->
|
||||||
|
<div class="flex-1">
|
||||||
|
<Select v-model="modelFilter.field">
|
||||||
|
<SelectTrigger class="bg-transparent hover:bg-slate-100 w-full">
|
||||||
|
<SelectValue :placeholder="t('form.field.selectField')" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem v-for="field in fields" :key="field.field" :value="field.field">
|
||||||
|
{{ field.label }}
|
||||||
|
</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Operator -->
|
||||||
|
<div class="flex-1">
|
||||||
|
<Select v-model="modelFilter.operator" v-if="modelFilter.field">
|
||||||
|
<SelectTrigger class="bg-transparent hover:bg-slate-100 w-full">
|
||||||
|
<SelectValue :placeholder="t('form.field.selectOperator')" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem v-for="op in getFieldOperators(modelFilter)" :key="op" :value="op">
|
||||||
|
{{ op }}
|
||||||
|
</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Value -->
|
||||||
|
<div class="flex-1">
|
||||||
|
<div v-if="modelFilter.field && modelFilter.operator">
|
||||||
|
<template v-if="modelFilter.operator !== 'set' && modelFilter.operator !== 'not set'">
|
||||||
|
<ComboBox
|
||||||
|
v-if="getFieldOptions(modelFilter).length > 0"
|
||||||
|
v-model="modelFilter.value"
|
||||||
|
:items="getFieldOptions(modelFilter)"
|
||||||
|
:placeholder="t('form.field.select')"
|
||||||
|
>
|
||||||
|
<template #item="{ item }">
|
||||||
|
<div v-if="modelFilter.field === 'assigned_user_id'">
|
||||||
|
<div class="flex items-center gap-1">
|
||||||
|
<Avatar class="w-6 h-6">
|
||||||
|
<AvatarImage :src="item.avatar_url || ''" :alt="item.label.slice(0, 2)" />
|
||||||
|
<AvatarFallback>{{ item.label.slice(0, 2).toUpperCase() }} </AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
<span>{{ item.label }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="modelFilter.field === 'assigned_team_id'">
|
||||||
|
<div class="flex items-center gap-2 ml-2">
|
||||||
|
<span>{{ item.emoji }}</span>
|
||||||
|
<span>{{ item.label }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
{{ item.label }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #selected="{ selected }">
|
||||||
|
<div v-if="!selected">{{ $t('form.field.selectValue') }}</div>
|
||||||
|
<div v-if="modelFilter.field === 'assigned_user_id'">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div v-if="selected" class="flex items-center gap-1">
|
||||||
|
<Avatar class="w-6 h-6">
|
||||||
|
<AvatarImage
|
||||||
|
:src="selected.avatar_url || ''"
|
||||||
|
:alt="selected.label.slice(0, 2)"
|
||||||
|
/>
|
||||||
|
<AvatarFallback>{{
|
||||||
|
selected.label.slice(0, 2).toUpperCase()
|
||||||
|
}}</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
<span>{{ selected.label }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="modelFilter.field === 'assigned_team_id'">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span v-if="selected">
|
||||||
|
{{ selected.emoji }}
|
||||||
|
<span>{{ selected.label }}</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="selected">
|
||||||
|
{{ selected.label }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ComboBox>
|
||||||
|
<Input
|
||||||
|
v-else
|
||||||
|
v-model="modelFilter.value"
|
||||||
|
class="bg-transparent hover:bg-slate-100"
|
||||||
|
:placeholder="t('form.field.value')"
|
||||||
|
type="text"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button @click="removeFilter(index)" class="p-1 hover:bg-slate-100 rounded">
|
||||||
|
<X class="w-4 h-4 text-slate-500" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-between pt-3">
|
||||||
|
<Button variant="ghost" size="sm" @click="addFilter" class="text-slate-600">
|
||||||
|
<Plus class="w-3 h-3 mr-1" />
|
||||||
|
{{
|
||||||
|
$t('globals.messages.add', {
|
||||||
|
name: $t('globals.terms.filter')
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</Button>
|
||||||
|
<div class="flex gap-2" v-if="showButtons">
|
||||||
|
<Button variant="ghost" @click="clearFilters">{{ $t('globals.buttons.reset') }}</Button>
|
||||||
|
<Button @click="applyFilters">{{ $t('globals.buttons.apply') }}</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed, onMounted, watch } from 'vue'
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
import { Plus, X } from 'lucide-vue-next'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
|
import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import ComboBox from '@/components/ui/combobox/ComboBox.vue'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
fields: {
|
||||||
|
type: Array,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
showButtons: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const { t } = useI18n()
|
||||||
|
const emit = defineEmits(['apply', 'clear'])
|
||||||
|
const modelValue = defineModel('modelValue', { required: false, default: () => [] })
|
||||||
|
|
||||||
|
const createFilter = () => ({ field: '', operator: '', value: '' })
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (modelValue.value.length === 0) {
|
||||||
|
modelValue.value = [createFilter()]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const getModel = (field) => {
|
||||||
|
const fieldConfig = props.fields.find((f) => f.field === field)
|
||||||
|
return fieldConfig?.model || ''
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set model for each filter
|
||||||
|
watch(
|
||||||
|
() => modelValue.value,
|
||||||
|
(filters) => {
|
||||||
|
filters.forEach((filter) => {
|
||||||
|
if (filter.field && !filter.model) {
|
||||||
|
filter.model = getModel(filter.field)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
// Reset operator and value when field changes for a filter at a given index
|
||||||
|
watch(
|
||||||
|
() => modelValue.value.map((f) => f.field),
|
||||||
|
(newFields, oldFields) => {
|
||||||
|
newFields.forEach((field, index) => {
|
||||||
|
if (field !== oldFields[index]) {
|
||||||
|
modelValue.value[index].operator = ''
|
||||||
|
modelValue.value[index].value = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const addFilter = () => {
|
||||||
|
modelValue.value = [...modelValue.value, createFilter()]
|
||||||
|
}
|
||||||
|
const removeFilter = (index) => {
|
||||||
|
modelValue.value = modelValue.value.filter((_, i) => i !== index)
|
||||||
|
}
|
||||||
|
const applyFilters = () => {
|
||||||
|
modelValue.value = validFilters.value
|
||||||
|
emit('apply', modelValue.value)
|
||||||
|
}
|
||||||
|
const clearFilters = () => {
|
||||||
|
modelValue.value = []
|
||||||
|
emit('clear')
|
||||||
|
}
|
||||||
|
|
||||||
|
const validFilters = computed(() => {
|
||||||
|
return modelValue.value.filter((filter) => filter.field && filter.operator && filter.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getFieldOptions = (fieldValue) => {
|
||||||
|
const field = props.fields.find((f) => f.field === fieldValue.field)
|
||||||
|
return field?.options || []
|
||||||
|
}
|
||||||
|
|
||||||
|
const getFieldOperators = (modelFilter) => {
|
||||||
|
const field = props.fields.find((f) => f.field === modelFilter.field)
|
||||||
|
return field?.operators || []
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { adminNavItems, reportsNavItems, accountNavItems } from '@/constants/navigation'
|
import {
|
||||||
|
adminNavItems,
|
||||||
|
reportsNavItems,
|
||||||
|
accountNavItems,
|
||||||
|
contactNavItems
|
||||||
|
} from '@/constants/navigation'
|
||||||
import { RouterLink, useRoute } from 'vue-router'
|
import { RouterLink, useRoute } from 'vue-router'
|
||||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
|
||||||
import {
|
import {
|
||||||
@@ -22,11 +27,11 @@ import { useAppSettingsStore } from '@/stores/appSettings'
|
|||||||
import {
|
import {
|
||||||
ChevronRight,
|
ChevronRight,
|
||||||
EllipsisVertical,
|
EllipsisVertical,
|
||||||
Plus,
|
User,
|
||||||
CircleUserRound,
|
|
||||||
UserSearch,
|
UserSearch,
|
||||||
UsersRound,
|
UsersRound,
|
||||||
Search
|
Search,
|
||||||
|
Plus
|
||||||
} from 'lucide-vue-next'
|
} from 'lucide-vue-next'
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
@@ -37,6 +42,7 @@ import {
|
|||||||
import { filterNavItems } from '@/utils/nav-permissions'
|
import { filterNavItems } from '@/utils/nav-permissions'
|
||||||
import { useStorage } from '@vueuse/core'
|
import { useStorage } from '@vueuse/core'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
@@ -46,6 +52,7 @@ defineProps({
|
|||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const settingsStore = useAppSettingsStore()
|
const settingsStore = useAppSettingsStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const { t } = useI18n()
|
||||||
const emit = defineEmits(['createView', 'editView', 'deleteView', 'createConversation'])
|
const emit = defineEmits(['createView', 'editView', 'deleteView', 'createConversation'])
|
||||||
|
|
||||||
const openCreateViewDialog = () => {
|
const openCreateViewDialog = () => {
|
||||||
@@ -62,6 +69,7 @@ const deleteView = (view) => {
|
|||||||
|
|
||||||
const filteredAdminNavItems = computed(() => filterNavItems(adminNavItems, userStore.can))
|
const filteredAdminNavItems = computed(() => filterNavItems(adminNavItems, userStore.can))
|
||||||
const filteredReportsNavItems = computed(() => filterNavItems(reportsNavItems, userStore.can))
|
const filteredReportsNavItems = computed(() => filterNavItems(reportsNavItems, userStore.can))
|
||||||
|
const filteredContactsNavItems = computed(() => filterNavItems(contactNavItems, userStore.can))
|
||||||
|
|
||||||
const isActiveParent = (parentHref) => {
|
const isActiveParent = (parentHref) => {
|
||||||
return route.path.startsWith(parentHref)
|
return route.path.startsWith(parentHref)
|
||||||
@@ -82,6 +90,42 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
:default-open="sidebarOpen"
|
:default-open="sidebarOpen"
|
||||||
v-on:update:open="sidebarOpen = $event"
|
v-on:update:open="sidebarOpen = $event"
|
||||||
>
|
>
|
||||||
|
<!-- Contacts sidebar -->
|
||||||
|
<template
|
||||||
|
v-if="route.matched.some((record) => record.name && record.name.startsWith('contact'))"
|
||||||
|
>
|
||||||
|
<Sidebar collapsible="offcanvas" class="border-r ml-12">
|
||||||
|
<SidebarHeader>
|
||||||
|
<SidebarMenu>
|
||||||
|
<SidebarMenuItem>
|
||||||
|
<SidebarMenuButton :isActive="isActiveParent('/contacts')" asChild>
|
||||||
|
<div>
|
||||||
|
<span class="font-semibold text-xl">
|
||||||
|
{{ t('globals.terms.contact', 2) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</SidebarMenuButton>
|
||||||
|
</SidebarMenuItem>
|
||||||
|
</SidebarMenu>
|
||||||
|
</SidebarHeader>
|
||||||
|
<SidebarSeparator />
|
||||||
|
<SidebarContent>
|
||||||
|
<SidebarGroup>
|
||||||
|
<SidebarMenu>
|
||||||
|
<SidebarMenuItem v-for="item in filteredContactsNavItems" :key="item.titleKey">
|
||||||
|
<SidebarMenuButton :isActive="isActiveParent(item.href)" asChild>
|
||||||
|
<router-link :to="item.href">
|
||||||
|
<span>{{ t(item.titleKey) }}</span>
|
||||||
|
</router-link>
|
||||||
|
</SidebarMenuButton>
|
||||||
|
</SidebarMenuItem>
|
||||||
|
</SidebarMenu>
|
||||||
|
</SidebarGroup>
|
||||||
|
</SidebarContent>
|
||||||
|
<SidebarRail />
|
||||||
|
</Sidebar>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- Reports sidebar -->
|
<!-- Reports sidebar -->
|
||||||
<template
|
<template
|
||||||
v-if="
|
v-if="
|
||||||
@@ -95,7 +139,9 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton :isActive="isActiveParent('/reports/overview')" asChild>
|
<SidebarMenuButton :isActive="isActiveParent('/reports/overview')" asChild>
|
||||||
<div>
|
<div>
|
||||||
<span class="font-semibold text-xl">Reports</span>
|
<span class="font-semibold text-xl">
|
||||||
|
{{ t('navigation.reports') }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
@@ -105,10 +151,10 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarContent>
|
<SidebarContent>
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
<SidebarMenuItem v-for="item in filteredReportsNavItems" :key="item.title">
|
<SidebarMenuItem v-for="item in filteredReportsNavItems" :key="item.titleKey">
|
||||||
<SidebarMenuButton :isActive="isActiveParent(item.href)" asChild>
|
<SidebarMenuButton :isActive="isActiveParent(item.href)" asChild>
|
||||||
<router-link :to="item.href">
|
<router-link :to="item.href">
|
||||||
<span>{{ item.title }}</span>
|
<span>{{ t(item.titleKey) }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
@@ -127,7 +173,9 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton :isActive="isActiveParent('/admin')" asChild>
|
<SidebarMenuButton :isActive="isActiveParent('/admin')" asChild>
|
||||||
<div class="flex items-center justify-between w-full">
|
<div class="flex items-center justify-between w-full">
|
||||||
<span class="font-semibold text-xl">Admin</span>
|
<span class="font-semibold text-xl">
|
||||||
|
{{ t('navigation.admin') }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<!-- App version -->
|
<!-- App version -->
|
||||||
<div class="text-xs text-muted-foreground ml-2">
|
<div class="text-xs text-muted-foreground ml-2">
|
||||||
@@ -141,14 +189,14 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarContent>
|
<SidebarContent>
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
<SidebarMenuItem v-for="item in filteredAdminNavItems" :key="item.title">
|
<SidebarMenuItem v-for="item in filteredAdminNavItems" :key="item.titleKey">
|
||||||
<SidebarMenuButton
|
<SidebarMenuButton
|
||||||
v-if="!item.children"
|
v-if="!item.children"
|
||||||
:isActive="isActiveParent(item.href)"
|
:isActive="isActiveParent(item.href)"
|
||||||
asChild
|
asChild
|
||||||
>
|
>
|
||||||
<router-link :to="item.href">
|
<router-link :to="item.href">
|
||||||
<span>{{ item.title }}</span>
|
<span>{{ t(item.titleKey) }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
|
|
||||||
@@ -159,7 +207,7 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
>
|
>
|
||||||
<CollapsibleTrigger as-child>
|
<CollapsibleTrigger as-child>
|
||||||
<SidebarMenuButton :isActive="isActiveParent(item.href)">
|
<SidebarMenuButton :isActive="isActiveParent(item.href)">
|
||||||
<span>{{ item.title }}</span>
|
<span>{{ t(item.titleKey) }}</span>
|
||||||
<ChevronRight
|
<ChevronRight
|
||||||
class="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
|
class="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
|
||||||
/>
|
/>
|
||||||
@@ -167,10 +215,10 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
</CollapsibleTrigger>
|
</CollapsibleTrigger>
|
||||||
<CollapsibleContent>
|
<CollapsibleContent>
|
||||||
<SidebarMenuSub>
|
<SidebarMenuSub>
|
||||||
<SidebarMenuSubItem v-for="child in item.children" :key="child.title">
|
<SidebarMenuSubItem v-for="child in item.children" :key="child.titleKey">
|
||||||
<SidebarMenuButton size="sm" :isActive="isActiveParent(child.href)" asChild>
|
<SidebarMenuButton size="sm" :isActive="isActiveParent(child.href)" asChild>
|
||||||
<router-link :to="child.href">
|
<router-link :to="child.href">
|
||||||
<span>{{ child.title }}</span>
|
<span>{{ t(child.titleKey) }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuSubItem>
|
</SidebarMenuSubItem>
|
||||||
@@ -193,7 +241,9 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton :isActive="isActiveParent('/account/profile')" asChild>
|
<SidebarMenuButton :isActive="isActiveParent('/account/profile')" asChild>
|
||||||
<div>
|
<div>
|
||||||
<span class="font-semibold text-xl">Account</span>
|
<span class="font-semibold text-xl">
|
||||||
|
{{ t('navigation.account') }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
@@ -203,10 +253,10 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarContent>
|
<SidebarContent>
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
<SidebarMenuItem v-for="item in accountNavItems" :key="item.title">
|
<SidebarMenuItem v-for="item in accountNavItems" :key="item.titleKey">
|
||||||
<SidebarMenuButton :isActive="isActiveParent(item.href)" asChild>
|
<SidebarMenuButton :isActive="isActiveParent(item.href)" asChild>
|
||||||
<router-link :to="item.href">
|
<router-link :to="item.href">
|
||||||
<span>{{ item.title }}</span>
|
<span>{{ t(item.titleKey) }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
<SidebarMenuAction>
|
<SidebarMenuAction>
|
||||||
@@ -228,27 +278,17 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton asChild>
|
<SidebarMenuButton asChild>
|
||||||
<div class="flex items-center justify-between w-full">
|
<div class="flex items-center justify-between w-full">
|
||||||
<div class="font-semibold text-xl">Inbox</div>
|
<div class="font-semibold text-xl">
|
||||||
|
<span>{{ t('navigation.inbox') }}</span>
|
||||||
|
</div>
|
||||||
<div class="ml-auto">
|
<div class="ml-auto">
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<div
|
|
||||||
class="flex items-center bg-accent p-2 rounded-full cursor-pointer"
|
|
||||||
@click="emit('createConversation')"
|
|
||||||
>
|
|
||||||
<Plus
|
|
||||||
class="transition-transform duration-200 hover:scale-110"
|
|
||||||
size="15"
|
|
||||||
stroke-width="2.5"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<router-link :to="{ name: 'search' }">
|
<router-link :to="{ name: 'search' }">
|
||||||
<div class="flex items-center bg-accent p-2 rounded-full">
|
<button
|
||||||
<Search
|
class="flex items-center bg-accent p-2 rounded-full hover:scale-110 transition-transform duration-100"
|
||||||
class="transition-transform duration-200 hover:scale-110 cursor-pointer"
|
>
|
||||||
size="15"
|
<Search size="15" stroke-width="2.5" />
|
||||||
stroke-width="2.5"
|
</button>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -261,11 +301,25 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarContent>
|
<SidebarContent>
|
||||||
<SidebarGroup>
|
<SidebarGroup>
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
|
<SidebarMenuItem>
|
||||||
|
<SidebarMenuButton asChild>
|
||||||
|
<a href="#" @click="emit('createConversation')">
|
||||||
|
<Plus />
|
||||||
|
<span
|
||||||
|
>{{
|
||||||
|
t('globals.messages.new', {
|
||||||
|
name: t('globals.terms.conversation').toLowerCase()
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</SidebarMenuButton>
|
||||||
|
</SidebarMenuItem>
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton asChild :isActive="isActiveParent('/inboxes/assigned')">
|
<SidebarMenuButton asChild :isActive="isActiveParent('/inboxes/assigned')">
|
||||||
<router-link :to="{ name: 'inbox', params: { type: 'assigned' } }">
|
<router-link :to="{ name: 'inbox', params: { type: 'assigned' } }">
|
||||||
<CircleUserRound />
|
<User />
|
||||||
<span>My inbox</span>
|
<span>{{ t('navigation.myInbox') }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
@@ -274,7 +328,9 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuButton asChild :isActive="isActiveParent('/inboxes/unassigned')">
|
<SidebarMenuButton asChild :isActive="isActiveParent('/inboxes/unassigned')">
|
||||||
<router-link :to="{ name: 'inbox', params: { type: 'unassigned' } }">
|
<router-link :to="{ name: 'inbox', params: { type: 'unassigned' } }">
|
||||||
<UserSearch />
|
<UserSearch />
|
||||||
<span>Unassigned</span>
|
<span>
|
||||||
|
{{ t('navigation.unassigned') }}
|
||||||
|
</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
@@ -283,7 +339,9 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuButton asChild :isActive="isActiveParent('/inboxes/all')">
|
<SidebarMenuButton asChild :isActive="isActiveParent('/inboxes/all')">
|
||||||
<router-link :to="{ name: 'inbox', params: { type: 'all' } }">
|
<router-link :to="{ name: 'inbox', params: { type: 'all' } }">
|
||||||
<UsersRound />
|
<UsersRound />
|
||||||
<span>All</span>
|
<span>
|
||||||
|
{{ t('navigation.all') }}
|
||||||
|
</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
@@ -300,7 +358,9 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuButton asChild>
|
<SidebarMenuButton asChild>
|
||||||
<router-link to="#">
|
<router-link to="#">
|
||||||
<!-- <Users /> -->
|
<!-- <Users /> -->
|
||||||
<span>Team inboxes</span>
|
<span>
|
||||||
|
{{ t('navigation.teamInboxes') }}
|
||||||
|
</span>
|
||||||
<ChevronRight
|
<ChevronRight
|
||||||
class="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
|
class="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90"
|
||||||
/>
|
/>
|
||||||
@@ -330,14 +390,16 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<CollapsibleTrigger as-child>
|
<CollapsibleTrigger as-child>
|
||||||
<SidebarMenuButton asChild>
|
<SidebarMenuButton asChild>
|
||||||
<router-link to="#">
|
<router-link to="#" class="group/item">
|
||||||
<!-- <SlidersHorizontal /> -->
|
<!-- <SlidersHorizontal /> -->
|
||||||
<span>Views</span>
|
<span>
|
||||||
|
{{ t('navigation.views') }}
|
||||||
|
</span>
|
||||||
<div>
|
<div>
|
||||||
<Plus
|
<Plus
|
||||||
size="18"
|
size="18"
|
||||||
@click.stop="openCreateViewDialog"
|
@click.stop="openCreateViewDialog"
|
||||||
class="rounded-lg cursor-pointer opacity-0 transition-all duration-200 group-hover:opacity-100 hover:bg-gray-200 hover:shadow-sm text-gray-600 hover:text-gray-800 transform hover:scale-105 active:scale-100 p-1"
|
class="rounded-lg cursor-pointer opacity-0 transition-all duration-200 group-hover/item:opacity-100 hover:bg-gray-200 hover:shadow-sm text-gray-600 hover:text-gray-800 transform hover:scale-105 active:scale-100 p-1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<ChevronRight
|
<ChevronRight
|
||||||
@@ -365,10 +427,10 @@ const viewInboxOpen = useStorage('viewInboxOpen', true)
|
|||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem @click="() => editView(view)">
|
<DropdownMenuItem @click="() => editView(view)">
|
||||||
<span>Edit</span>
|
<span>{{ t('globals.buttons.edit') }}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem @click="() => deleteView(view)">
|
<DropdownMenuItem @click="() => deleteView(view)">
|
||||||
<span>Delete</span>
|
<span>{{ t('globals.buttons.delete') }}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
'bg-green-500': userStore.user.availability_status === 'online',
|
'bg-green-500': userStore.user.availability_status === 'online',
|
||||||
'bg-amber-500':
|
'bg-amber-500':
|
||||||
userStore.user.availability_status === 'away' ||
|
userStore.user.availability_status === 'away' ||
|
||||||
userStore.user.availability_status === 'away_manual',
|
userStore.user.availability_status === 'away_manual' ||
|
||||||
|
userStore.user.availability_status === 'away_and_reassigning',
|
||||||
'bg-gray-400': userStore.user.availability_status === 'offline'
|
'bg-gray-400': userStore.user.availability_status === 'offline'
|
||||||
}"
|
}"
|
||||||
></div>
|
></div>
|
||||||
@@ -36,7 +37,7 @@
|
|||||||
<DropdownMenuLabel class="p-0 font-normal space-y-1">
|
<DropdownMenuLabel class="p-0 font-normal space-y-1">
|
||||||
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
|
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
|
||||||
<Avatar class="h-8 w-8 rounded-lg">
|
<Avatar class="h-8 w-8 rounded-lg">
|
||||||
<AvatarImage :src="userStore.avatar" alt="Abhinav" />
|
<AvatarImage :src="userStore.avatar" alt="U" />
|
||||||
<AvatarFallback class="rounded-lg">
|
<AvatarFallback class="rounded-lg">
|
||||||
{{ userStore.getInitials }}
|
{{ userStore.getInitials }}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
@@ -46,34 +47,55 @@
|
|||||||
<span class="truncate text-xs">{{ userStore.email }}</span>
|
<span class="truncate text-xs">{{ userStore.email }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm justify-between">
|
<div class="space-y-2">
|
||||||
<span class="text-muted-foreground">Away</span>
|
<!-- Away switch is checked with 'away_manual' or 'away_and_reassigning' -->
|
||||||
|
<div class="flex items-center gap-2 px-1 text-left text-sm justify-between">
|
||||||
|
<span class="text-muted-foreground">{{ t('navigation.away') }}</span>
|
||||||
<Switch
|
<Switch
|
||||||
:checked="
|
:checked="
|
||||||
userStore.user.availability_status === 'away' ||
|
['away_manual', 'away_and_reassigning'].includes(userStore.user.availability_status)
|
||||||
userStore.user.availability_status === 'away_manual'
|
"
|
||||||
|
@update:checked="
|
||||||
|
(val) => {
|
||||||
|
const newStatus = val ? 'away_manual' : 'online'
|
||||||
|
userStore.updateUserAvailability(newStatus)
|
||||||
|
}
|
||||||
"
|
"
|
||||||
@update:checked="(val) => userStore.updateUserAvailability(val ? 'away' : 'online')"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Reassign Replies Switch is checked with 'away_and_reassigning' -->
|
||||||
|
<div class="flex items-center gap-2 px-1 text-left text-sm justify-between">
|
||||||
|
<span class="text-muted-foreground">{{ t('navigation.reassignReplies') }}</span>
|
||||||
|
<Switch
|
||||||
|
:checked="userStore.user.availability_status === 'away_and_reassigning'"
|
||||||
|
@update:checked="
|
||||||
|
(val) => {
|
||||||
|
const newStatus = val ? 'away_and_reassigning' : 'away_manual'
|
||||||
|
userStore.updateUserAvailability(newStatus)
|
||||||
|
}
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</DropdownMenuLabel>
|
</DropdownMenuLabel>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuGroup>
|
<DropdownMenuGroup>
|
||||||
<DropdownMenuItem @click.prevent="router.push({ name: 'account' })">
|
<DropdownMenuItem @click.prevent="router.push({ name: 'account' })">
|
||||||
<CircleUserRound size="18" class="mr-2" />
|
<CircleUserRound size="18" class="mr-2" />
|
||||||
Account
|
{{ t('navigation.account') }}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuGroup>
|
</DropdownMenuGroup>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItem @click="logout">
|
<DropdownMenuItem @click="logout">
|
||||||
<LogOut size="18" class="mr-2" />
|
<LogOut size="18" class="mr-2" />
|
||||||
Log out
|
{{ t('navigation.logout') }}
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import {
|
import {
|
||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
@@ -92,6 +114,7 @@ import { useRouter } from 'vue-router'
|
|||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
window.location.href = '/logout'
|
window.location.href = '/logout'
|
||||||
|
|||||||
@@ -1,31 +1,58 @@
|
|||||||
<template>
|
<template>
|
||||||
<table class="min-w-full divide-y divide-gray-200">
|
<table class="min-w-full table-fixed divide-y divide-gray-200">
|
||||||
<thead class="bg-gray-50">
|
<thead class="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th v-for="(header, index) in headers" :key="index" scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
<th
|
||||||
|
v-for="(header, index) in headers"
|
||||||
|
:key="index"
|
||||||
|
scope="col"
|
||||||
|
class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
|
||||||
|
>
|
||||||
{{ header }}
|
{{ header }}
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" class="relative px-6 py-3"></th>
|
<th scope="col" class="relative px-6 py-3"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="bg-white divide-y divide-gray-200">
|
<tbody class="bg-white divide-y divide-gray-200">
|
||||||
|
<template v-if="data.length === 0">
|
||||||
|
<tr>
|
||||||
|
<td :colspan="headers.length + 1" class="px-6 py-12 text-center">
|
||||||
|
<div class="flex flex-col items-center space-y-4">
|
||||||
|
<span class="text-md text-gray-500">
|
||||||
|
{{
|
||||||
|
$t('globals.messages.noResults', {
|
||||||
|
name: $t('globals.terms.result', 2).toLowerCase()
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
<tr v-for="(item, index) in data" :key="index">
|
<tr v-for="(item, index) in data" :key="index">
|
||||||
<td v-for="key in keys" :key="key" class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
|
<td
|
||||||
|
v-for="key in keys"
|
||||||
|
:key="key"
|
||||||
|
class="px-6 py-4 text-sm font-medium text-gray-900 whitespace-normal break-words"
|
||||||
|
>
|
||||||
{{ item[key] }}
|
{{ item[key] }}
|
||||||
</td>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
<td class="px-6 py-4 text-sm text-gray-500" v-if="showDelete">
|
||||||
<Button size="xs" variant="ghost" @click.prevent="deleteItem(item)">
|
<Button size="xs" variant="ghost" @click.prevent="deleteItem(item)">
|
||||||
<Trash2 class="h-4 w-4" />
|
<Trash2 class="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</template>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Trash2 } from 'lucide-vue-next';
|
import { Trash2 } from 'lucide-vue-next'
|
||||||
import { defineProps, defineEmits } from 'vue';
|
import { defineProps, defineEmits } from 'vue'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
headers: {
|
headers: {
|
||||||
@@ -42,12 +69,16 @@ defineProps({
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
default: () => []
|
default: () => []
|
||||||
|
},
|
||||||
|
showDelete: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['deleteItem']);
|
const emit = defineEmits(['deleteItem'])
|
||||||
|
|
||||||
function deleteItem(item) {
|
function deleteItem(item) {
|
||||||
emit('deleteItem', item);
|
emit('deleteItem', item)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import { AvatarImage } from 'radix-vue'
|
import { AvatarImage } from 'radix-vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
src: { type: String, required: true },
|
src: { type: String, required: false, default: '' },
|
||||||
asChild: { type: Boolean, required: false },
|
asChild: { type: Boolean, required: false },
|
||||||
as: { type: null, required: false }
|
as: { type: null, required: false }
|
||||||
})
|
})
|
||||||
|
|||||||
59
frontend/src/components/ui/avatar/AvatarUpload.vue
Normal file
59
frontend/src/components/ui/avatar/AvatarUpload.vue
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<template>
|
||||||
|
<div class="relative group w-28 h-28 cursor-pointer" @click="triggerFileInput">
|
||||||
|
<Avatar class="size-28">
|
||||||
|
<AvatarImage :src="src || ''" />
|
||||||
|
<AvatarFallback>{{ initials }}</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
|
||||||
|
<!-- Hover Overlay -->
|
||||||
|
<div
|
||||||
|
class="absolute inset-0 bg-black bg-opacity-50 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer rounded-full"
|
||||||
|
>
|
||||||
|
<span class="text-white font-semibold">{{ label }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Delete Icon -->
|
||||||
|
<X
|
||||||
|
class="absolute top-1 right-1 bg-white rounded-full p-1 shadow-md z-10 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||||
|
size="20"
|
||||||
|
@click.stop="emit('remove')"
|
||||||
|
v-if="src"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- File Input -->
|
||||||
|
<input
|
||||||
|
ref="fileInput"
|
||||||
|
type="file"
|
||||||
|
class="hidden"
|
||||||
|
accept="image/png,image/jpeg,image/jpg"
|
||||||
|
@change="handleChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'
|
||||||
|
import { X } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
src: String,
|
||||||
|
initials: String,
|
||||||
|
label: {
|
||||||
|
type: String,
|
||||||
|
default: 'Upload'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['upload', 'remove'])
|
||||||
|
const fileInput = ref(null)
|
||||||
|
|
||||||
|
function triggerFileInput() {
|
||||||
|
fileInput.value?.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleChange(e) {
|
||||||
|
const file = e.target.files[0]
|
||||||
|
if (file) emit('upload', file)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -3,6 +3,7 @@ import { cva } from 'class-variance-authority'
|
|||||||
export { default as Avatar } from './Avatar.vue'
|
export { default as Avatar } from './Avatar.vue'
|
||||||
export { default as AvatarImage } from './AvatarImage.vue'
|
export { default as AvatarImage } from './AvatarImage.vue'
|
||||||
export { default as AvatarFallback } from './AvatarFallback.vue'
|
export { default as AvatarFallback } from './AvatarFallback.vue'
|
||||||
|
export { default as AvatarUpload } from './AvatarUpload.vue'
|
||||||
|
|
||||||
export const avatarVariant = cva(
|
export const avatarVariant = cva(
|
||||||
'inline-flex items-center justify-center font-normal text-foreground select-none shrink-0 bg-secondary overflow-hidden',
|
'inline-flex items-center justify-center font-normal text-foreground select-none shrink-0 bg-secondary overflow-hidden',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
role="combobox"
|
role="combobox"
|
||||||
:aria-expanded="open"
|
:aria-expanded="open"
|
||||||
class="w-full justify-between"
|
:class="['w-full justify-between', buttonClass]"
|
||||||
>
|
>
|
||||||
<slot name="selected" :selected="selectedItem">{{ selectedLabel }}</slot>
|
<slot name="selected" :selected="selectedItem">{{ selectedLabel }}</slot>
|
||||||
<CaretSortIcon class="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
<CaretSortIcon class="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
||||||
@@ -58,7 +58,11 @@ const props = defineProps({
|
|||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
placeholder: String,
|
placeholder: String,
|
||||||
defaultLabel: String
|
defaultLabel: String,
|
||||||
|
buttonClass: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['select'])
|
const emit = defineEmits(['select'])
|
||||||
|
|||||||
29
frontend/src/components/ui/pagination/PaginationEllipsis.vue
Normal file
29
frontend/src/components/ui/pagination/PaginationEllipsis.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script setup>
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { DotsHorizontalIcon } from '@radix-icons/vue';
|
||||||
|
import { PaginationEllipsis } from 'reka-ui';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = computed(() => {
|
||||||
|
const { class: _, ...delegated } = props;
|
||||||
|
|
||||||
|
return delegated;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationEllipsis
|
||||||
|
v-bind="delegatedProps"
|
||||||
|
:class="cn('w-9 h-9 flex items-center justify-center', props.class)"
|
||||||
|
>
|
||||||
|
<slot>
|
||||||
|
<DotsHorizontalIcon />
|
||||||
|
</slot>
|
||||||
|
</PaginationEllipsis>
|
||||||
|
</template>
|
||||||
29
frontend/src/components/ui/pagination/PaginationFirst.vue
Normal file
29
frontend/src/components/ui/pagination/PaginationFirst.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script setup>
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { ChevronsLeft } from 'lucide-vue-next';
|
||||||
|
import { PaginationFirst } from 'reka-ui';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false, default: true },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = computed(() => {
|
||||||
|
const { class: _, ...delegated } = props;
|
||||||
|
|
||||||
|
return delegated;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationFirst v-bind="delegatedProps">
|
||||||
|
<Button :class="cn('w-9 h-9 p-0', props.class)" variant="outline">
|
||||||
|
<slot>
|
||||||
|
<ChevronsLeft />
|
||||||
|
</slot>
|
||||||
|
</Button>
|
||||||
|
</PaginationFirst>
|
||||||
|
</template>
|
||||||
29
frontend/src/components/ui/pagination/PaginationLast.vue
Normal file
29
frontend/src/components/ui/pagination/PaginationLast.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script setup>
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { ChevronsRight } from 'lucide-vue-next';
|
||||||
|
import { PaginationLast } from 'reka-ui';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false, default: true },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = computed(() => {
|
||||||
|
const { class: _, ...delegated } = props;
|
||||||
|
|
||||||
|
return delegated;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationLast v-bind="delegatedProps">
|
||||||
|
<Button :class="cn('w-9 h-9 p-0', props.class)" variant="outline">
|
||||||
|
<slot>
|
||||||
|
<ChevronsRight />
|
||||||
|
</slot>
|
||||||
|
</Button>
|
||||||
|
</PaginationLast>
|
||||||
|
</template>
|
||||||
29
frontend/src/components/ui/pagination/PaginationNext.vue
Normal file
29
frontend/src/components/ui/pagination/PaginationNext.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script setup>
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { ChevronRightIcon } from '@radix-icons/vue';
|
||||||
|
import { PaginationNext } from 'reka-ui';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false, default: true },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = computed(() => {
|
||||||
|
const { class: _, ...delegated } = props;
|
||||||
|
|
||||||
|
return delegated;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationNext v-bind="delegatedProps">
|
||||||
|
<Button :class="cn('w-9 h-9 p-0', props.class)" variant="outline">
|
||||||
|
<slot>
|
||||||
|
<ChevronRightIcon />
|
||||||
|
</slot>
|
||||||
|
</Button>
|
||||||
|
</PaginationNext>
|
||||||
|
</template>
|
||||||
29
frontend/src/components/ui/pagination/PaginationPrev.vue
Normal file
29
frontend/src/components/ui/pagination/PaginationPrev.vue
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<script setup>
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { ChevronLeftIcon } from '@radix-icons/vue';
|
||||||
|
import { PaginationPrev } from 'reka-ui';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
asChild: { type: Boolean, required: false, default: true },
|
||||||
|
as: { type: null, required: false },
|
||||||
|
class: { type: null, required: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const delegatedProps = computed(() => {
|
||||||
|
const { class: _, ...delegated } = props;
|
||||||
|
|
||||||
|
return delegated;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<PaginationPrev v-bind="delegatedProps">
|
||||||
|
<Button :class="cn('w-9 h-9 p-0', props.class)" variant="outline">
|
||||||
|
<slot>
|
||||||
|
<ChevronLeftIcon />
|
||||||
|
</slot>
|
||||||
|
</Button>
|
||||||
|
</PaginationPrev>
|
||||||
|
</template>
|
||||||
10
frontend/src/components/ui/pagination/index.js
Normal file
10
frontend/src/components/ui/pagination/index.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export { default as PaginationEllipsis } from './PaginationEllipsis.vue';
|
||||||
|
export { default as PaginationFirst } from './PaginationFirst.vue';
|
||||||
|
export { default as PaginationLast } from './PaginationLast.vue';
|
||||||
|
export { default as PaginationNext } from './PaginationNext.vue';
|
||||||
|
export { default as PaginationPrev } from './PaginationPrev.vue';
|
||||||
|
export {
|
||||||
|
PaginationRoot as Pagination,
|
||||||
|
PaginationList,
|
||||||
|
PaginationListItem,
|
||||||
|
} from 'reka-ui';
|
||||||
@@ -4,8 +4,8 @@ import { RadioGroupRoot, useForwardPropsEmits } from 'radix-vue'
|
|||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: { type: String, required: false },
|
modelValue: { type: [String, Boolean], required: false },
|
||||||
defaultValue: { type: String, required: false },
|
defaultValue: { type: [String, Boolean], required: false },
|
||||||
disabled: { type: Boolean, required: false },
|
disabled: { type: Boolean, required: false },
|
||||||
name: { type: String, required: false },
|
name: { type: String, required: false },
|
||||||
required: { type: Boolean, required: false },
|
required: { type: Boolean, required: false },
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { cn } from '@/lib/utils'
|
|||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
id: { type: String, required: false },
|
id: { type: String, required: false },
|
||||||
value: { type: String, required: false },
|
value: { type: [String, Boolean], required: false },
|
||||||
disabled: { type: Boolean, required: false },
|
disabled: { type: Boolean, required: false },
|
||||||
required: { type: Boolean, required: false },
|
required: { type: Boolean, required: false },
|
||||||
name: { type: String, required: false },
|
name: { type: String, required: false },
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { SelectRoot, useForwardPropsEmits } from 'radix-vue'
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
open: { type: Boolean, required: false },
|
open: { type: Boolean, required: false },
|
||||||
defaultOpen: { type: Boolean, required: false },
|
defaultOpen: { type: Boolean, required: false },
|
||||||
defaultValue: { type: String, required: false },
|
defaultValue: { type: [String, Number], required: false },
|
||||||
modelValue: { type: String, required: false },
|
modelValue: { type: [String, Number], required: false },
|
||||||
dir: { type: String, required: false },
|
dir: { type: String, required: false },
|
||||||
name: { type: String, required: false },
|
name: { type: String, required: false },
|
||||||
autocomplete: { type: String, required: false },
|
autocomplete: { type: String, required: false },
|
||||||
|
|||||||
@@ -1,26 +1,46 @@
|
|||||||
<template>
|
<template>
|
||||||
<TagsInput v-model="tags" class="px-0 gap-0">
|
<TagsInput v-model="tags" class="px-0 gap-0" :displayValue="getLabel">
|
||||||
|
<!-- Tags visible to the user -->
|
||||||
<div class="flex gap-2 flex-wrap items-center px-3">
|
<div class="flex gap-2 flex-wrap items-center px-3">
|
||||||
<TagsInputItem v-for="tag in tags" :key="tag" :value="tag">
|
<TagsInputItem v-for="tagValue in tags" :key="tagValue" :value="tagValue">
|
||||||
<TagsInputItemText>{{ tag }}</TagsInputItemText>
|
<TagsInputItemText/>
|
||||||
<TagsInputItemDelete />
|
<TagsInputItemDelete />
|
||||||
</TagsInputItem>
|
</TagsInputItem>
|
||||||
</div>
|
</div>
|
||||||
<ComboboxRoot :model-value="tags" v-model:open="open" v-model:search-term="searchTerm" class="w-full">
|
|
||||||
|
<!-- Combobox for selecting new tags -->
|
||||||
|
<ComboboxRoot
|
||||||
|
:model-value="tags"
|
||||||
|
v-model:open="open"
|
||||||
|
v-model:search-term="searchTerm"
|
||||||
|
:filterFunction="filterFunc"
|
||||||
|
class="w-full"
|
||||||
|
>
|
||||||
<ComboboxAnchor as-child>
|
<ComboboxAnchor as-child>
|
||||||
<ComboboxInput :placeholder="placeholder" as-child>
|
<ComboboxInput :placeholder="placeholder" as-child>
|
||||||
<TagsInputInput class="w-full px-3" :class="tags.length > 0 ? 'mt-2' : ''" @keydown.enter.prevent
|
<TagsInputInput
|
||||||
@blur="handleBlur" />
|
class="w-full px-3"
|
||||||
|
:class="tags.length > 0 ? 'mt-2' : ''"
|
||||||
|
@keydown.enter.prevent
|
||||||
|
@blur="handleBlur"
|
||||||
|
/>
|
||||||
</ComboboxInput>
|
</ComboboxInput>
|
||||||
</ComboboxAnchor>
|
</ComboboxAnchor>
|
||||||
<ComboboxPortal>
|
<ComboboxPortal>
|
||||||
<ComboboxContent>
|
<ComboboxContent>
|
||||||
<CommandList position="popper"
|
<CommandList
|
||||||
class="w-[--radix-popper-anchor-width] rounded-md mt-2 border bg-popover text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2">
|
position="popper"
|
||||||
<CommandEmpty />
|
class="w-[--radix-popper-anchor-width] rounded-md mt-2 border bg-popover text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2"
|
||||||
|
>
|
||||||
|
<CommandEmpty> No results found </CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
<CommandItem v-for="item in filteredOptions" :key="item" :value="item" @select="handleSelect">
|
<CommandItem
|
||||||
{{ item }}
|
v-for="item in filteredOptions"
|
||||||
|
:key="item.value"
|
||||||
|
:value="item.value"
|
||||||
|
@select="handleSelect"
|
||||||
|
>
|
||||||
|
{{ item.label }}
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
</CommandList>
|
</CommandList>
|
||||||
@@ -32,8 +52,20 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { CommandEmpty, CommandGroup, CommandItem, CommandList } from '@/components/ui/command'
|
import { CommandEmpty, CommandGroup, CommandItem, CommandList } from '@/components/ui/command'
|
||||||
import { TagsInput, TagsInputInput, TagsInputItem, TagsInputItemDelete, TagsInputItemText } from '@/components/ui/tags-input'
|
import {
|
||||||
import { ComboboxAnchor, ComboboxContent, ComboboxInput, ComboboxPortal, ComboboxRoot } from 'radix-vue'
|
TagsInput,
|
||||||
|
TagsInputInput,
|
||||||
|
TagsInputItem,
|
||||||
|
TagsInputItemDelete,
|
||||||
|
TagsInputItemText
|
||||||
|
} from '@/components/ui/tags-input'
|
||||||
|
import {
|
||||||
|
ComboboxAnchor,
|
||||||
|
ComboboxContent,
|
||||||
|
ComboboxInput,
|
||||||
|
ComboboxPortal,
|
||||||
|
ComboboxRoot
|
||||||
|
} from 'radix-vue'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useField } from 'vee-validate'
|
import { useField } from 'vee-validate'
|
||||||
|
|
||||||
@@ -54,7 +86,8 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
items: {
|
items: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true
|
required: true,
|
||||||
|
validator: (value) => value.every((item) => 'label' in item && 'value' in item)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -65,20 +98,35 @@ const { handleBlur } = useField(() => props.name, undefined, {
|
|||||||
const open = ref(false)
|
const open = ref(false)
|
||||||
const searchTerm = ref('')
|
const searchTerm = ref('')
|
||||||
|
|
||||||
const filteredOptions = computed(() =>
|
// Get all options that are not already selected and match the search term
|
||||||
props.items.filter(item => !tags.value.includes(item))
|
const filteredOptions = computed(() => {
|
||||||
)
|
return props.items.filter(
|
||||||
|
(item) =>
|
||||||
|
!tags.value.includes(item.value) &&
|
||||||
|
item.label.toLowerCase().includes(searchTerm.value.toLowerCase())
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getLabel = (value) => {
|
||||||
|
const item = props.items.find((item) => item.value === value)
|
||||||
|
return item?.label || value
|
||||||
|
}
|
||||||
|
|
||||||
const handleSelect = (event) => {
|
const handleSelect = (event) => {
|
||||||
if (event.detail.value) {
|
const selectedValue = event.detail.value
|
||||||
|
if (selectedValue) {
|
||||||
|
tags.value = [...tags.value, selectedValue]
|
||||||
searchTerm.value = ''
|
searchTerm.value = ''
|
||||||
const newTags = [...tags.value]
|
|
||||||
newTags.push(event.detail.value)
|
|
||||||
tags.value = newTags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filteredOptions.value.length === 0) {
|
if (filteredOptions.value.length === 0) {
|
||||||
open.value = false
|
open.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom filter function to filter items based on the search term
|
||||||
|
const filterFunc = (remainingItemValues, term) => {
|
||||||
|
const remainingItems = props.items.filter((item) => remainingItemValues.includes(item.value))
|
||||||
|
return remainingItems.filter((item) => item.label.toLowerCase().includes(term.toLowerCase())).map(item => item.value)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
import { SelectValue } from 'radix-vue'
|
import { SelectValue } from 'radix-vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
placeholder: { type: String, required: false },
|
placeholder: { type: [String, Number], required: false },
|
||||||
asChild: { type: Boolean, required: false },
|
asChild: { type: Boolean, required: false },
|
||||||
as: { type: null, required: false }
|
as: { type: null, required: false }
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
v-if="appSettingsStore.settings['app.update']?.update?.is_new"
|
v-if="appSettingsStore.settings['app.update']?.update?.is_new"
|
||||||
class="p-2 mb-2 border-b bg-secondary text-secondary-foreground"
|
class="p-2 mb-2 border-b bg-secondary text-secondary-foreground"
|
||||||
>
|
>
|
||||||
A new update is available:
|
{{ $t('update.newUpdateAvailable') }}:
|
||||||
{{ appSettingsStore.settings['app.update'].update.release_version }} ({{
|
{{ appSettingsStore.settings['app.update'].update.release_version }} ({{
|
||||||
appSettingsStore.settings['app.update'].update.release_date
|
appSettingsStore.settings['app.update'].update.release_date
|
||||||
}})
|
}})
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
noreferrer
|
noreferrer
|
||||||
class="underline ml-2"
|
class="underline ml-2"
|
||||||
>
|
>
|
||||||
View details
|
{{ $t('globals.messages.viewDetails') }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
39
frontend/src/composables/useActivityLogFilters.js
Normal file
39
frontend/src/composables/useActivityLogFilters.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { computed } from 'vue'
|
||||||
|
import { useUsersStore } from '@/stores/users'
|
||||||
|
import { FIELD_TYPE, FIELD_OPERATORS } from '@/constants/filterConfig'
|
||||||
|
|
||||||
|
export function useActivityLogFilters () {
|
||||||
|
const uStore = useUsersStore()
|
||||||
|
const activityLogListFilters = computed(() => ({
|
||||||
|
actor_id: {
|
||||||
|
label: 'Actor',
|
||||||
|
type: FIELD_TYPE.SELECT,
|
||||||
|
operators: FIELD_OPERATORS.SELECT,
|
||||||
|
options: uStore.options
|
||||||
|
},
|
||||||
|
activity_type: {
|
||||||
|
label: 'Activity type',
|
||||||
|
type: FIELD_TYPE.SELECT,
|
||||||
|
operators: FIELD_OPERATORS.SELECT,
|
||||||
|
options: [{
|
||||||
|
label: 'Agent login',
|
||||||
|
value: 'agent_login'
|
||||||
|
}, {
|
||||||
|
label: 'Agent logout',
|
||||||
|
value: 'agent_logout'
|
||||||
|
}, {
|
||||||
|
label: 'Agent away',
|
||||||
|
value: 'agent_away'
|
||||||
|
}, {
|
||||||
|
label: 'Agent away reassigned',
|
||||||
|
value: 'agent_away_reassigned'
|
||||||
|
}, {
|
||||||
|
label: 'Agent online',
|
||||||
|
value: 'agent_online'
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
return {
|
||||||
|
activityLogListFilters
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import { useInboxStore } from '@/stores/inbox'
|
|||||||
import { useUsersStore } from '@/stores/users'
|
import { useUsersStore } from '@/stores/users'
|
||||||
import { useTeamStore } from '@/stores/team'
|
import { useTeamStore } from '@/stores/team'
|
||||||
import { useSlaStore } from '@/stores/sla'
|
import { useSlaStore } from '@/stores/sla'
|
||||||
|
import { useCustomAttributeStore } from '@/stores/customAttributes'
|
||||||
import { FIELD_TYPE, FIELD_OPERATORS } from '@/constants/filterConfig'
|
import { FIELD_TYPE, FIELD_OPERATORS } from '@/constants/filterConfig'
|
||||||
|
|
||||||
export function useConversationFilters () {
|
export function useConversationFilters () {
|
||||||
@@ -12,6 +13,25 @@ export function useConversationFilters () {
|
|||||||
const uStore = useUsersStore()
|
const uStore = useUsersStore()
|
||||||
const tStore = useTeamStore()
|
const tStore = useTeamStore()
|
||||||
const slaStore = useSlaStore()
|
const slaStore = useSlaStore()
|
||||||
|
const customAttributeStore = useCustomAttributeStore()
|
||||||
|
|
||||||
|
const customAttributeDataTypeToFieldType = {
|
||||||
|
'text': FIELD_TYPE.TEXT,
|
||||||
|
'number': FIELD_TYPE.NUMBER,
|
||||||
|
'checkbox': FIELD_TYPE.BOOLEAN,
|
||||||
|
'date': FIELD_TYPE.DATE,
|
||||||
|
'link': FIELD_TYPE.TEXT,
|
||||||
|
'list': FIELD_TYPE.SELECT,
|
||||||
|
}
|
||||||
|
|
||||||
|
const customAttributeDataTypeToFieldOperators = {
|
||||||
|
'text': FIELD_OPERATORS.TEXT,
|
||||||
|
'number': FIELD_OPERATORS.NUMBER,
|
||||||
|
'checkbox': FIELD_OPERATORS.BOOLEAN,
|
||||||
|
'date': FIELD_OPERATORS.DATE,
|
||||||
|
'link': FIELD_OPERATORS.TEXT,
|
||||||
|
'list': FIELD_OPERATORS.SELECT,
|
||||||
|
}
|
||||||
|
|
||||||
const conversationsListFilters = computed(() => ({
|
const conversationsListFilters = computed(() => ({
|
||||||
status_id: {
|
status_id: {
|
||||||
@@ -46,6 +66,23 @@ export function useConversationFilters () {
|
|||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const contactCustomAttributes = computed(() => {
|
||||||
|
return customAttributeStore.contactAttributeOptions
|
||||||
|
.filter(attribute => attribute.applies_to === 'contact')
|
||||||
|
.reduce((acc, attribute) => {
|
||||||
|
acc[attribute.key] = {
|
||||||
|
label: attribute.label,
|
||||||
|
type: customAttributeDataTypeToFieldType[attribute.data_type] || FIELD_TYPE.TEXT,
|
||||||
|
operators: customAttributeDataTypeToFieldOperators[attribute.data_type] || FIELD_OPERATORS.TEXT,
|
||||||
|
options: attribute.values.map(value => ({
|
||||||
|
label: value,
|
||||||
|
value: value
|
||||||
|
})) || [],
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
})
|
||||||
|
|
||||||
const newConversationFilters = computed(() => ({
|
const newConversationFilters = computed(() => ({
|
||||||
contact_email: {
|
contact_email: {
|
||||||
label: 'Email',
|
label: 'Email',
|
||||||
@@ -86,16 +123,6 @@ export function useConversationFilters () {
|
|||||||
operators: FIELD_OPERATORS.SELECT,
|
operators: FIELD_OPERATORS.SELECT,
|
||||||
options: uStore.options
|
options: uStore.options
|
||||||
},
|
},
|
||||||
hours_since_created: {
|
|
||||||
label: 'Hours since created',
|
|
||||||
type: FIELD_TYPE.NUMBER,
|
|
||||||
operators: FIELD_OPERATORS.NUMBER
|
|
||||||
},
|
|
||||||
hours_since_resolved: {
|
|
||||||
label: 'Hours since resolved',
|
|
||||||
type: FIELD_TYPE.NUMBER,
|
|
||||||
operators: FIELD_OPERATORS.NUMBER
|
|
||||||
},
|
|
||||||
inbox: {
|
inbox: {
|
||||||
label: 'Inbox',
|
label: 'Inbox',
|
||||||
type: FIELD_TYPE.SELECT,
|
type: FIELD_TYPE.SELECT,
|
||||||
@@ -134,6 +161,16 @@ export function useConversationFilters () {
|
|||||||
type: FIELD_TYPE.NUMBER,
|
type: FIELD_TYPE.NUMBER,
|
||||||
operators: FIELD_OPERATORS.NUMBER
|
operators: FIELD_OPERATORS.NUMBER
|
||||||
},
|
},
|
||||||
|
hours_since_first_reply: {
|
||||||
|
label: 'Hours since first reply',
|
||||||
|
type: FIELD_TYPE.NUMBER,
|
||||||
|
operators: FIELD_OPERATORS.NUMBER
|
||||||
|
},
|
||||||
|
hours_since_last_reply: {
|
||||||
|
label: 'Hours since last reply',
|
||||||
|
type: FIELD_TYPE.NUMBER,
|
||||||
|
operators: FIELD_OPERATORS.NUMBER
|
||||||
|
},
|
||||||
hours_since_resolved: {
|
hours_since_resolved: {
|
||||||
label: 'Hours since resolved',
|
label: 'Hours since resolved',
|
||||||
type: FIELD_TYPE.NUMBER,
|
type: FIELD_TYPE.NUMBER,
|
||||||
@@ -184,9 +221,17 @@ export function useConversationFilters () {
|
|||||||
type: FIELD_TYPE.SELECT,
|
type: FIELD_TYPE.SELECT,
|
||||||
options: slaStore.options
|
options: slaStore.options
|
||||||
},
|
},
|
||||||
|
add_tags: {
|
||||||
|
label: 'Add tags',
|
||||||
|
type: FIELD_TYPE.TAG
|
||||||
|
},
|
||||||
set_tags: {
|
set_tags: {
|
||||||
label: 'Set tags',
|
label: 'Set tags',
|
||||||
type: FIELD_TYPE.TAG
|
type: FIELD_TYPE.TAG
|
||||||
|
},
|
||||||
|
remove_tags: {
|
||||||
|
label: 'Remove tags',
|
||||||
|
type: FIELD_TYPE.TAG
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -211,9 +256,17 @@ export function useConversationFilters () {
|
|||||||
type: FIELD_TYPE.SELECT,
|
type: FIELD_TYPE.SELECT,
|
||||||
options: cStore.priorityOptions
|
options: cStore.priorityOptions
|
||||||
},
|
},
|
||||||
|
add_tags: {
|
||||||
|
label: 'Add tags',
|
||||||
|
type: FIELD_TYPE.TAG
|
||||||
|
},
|
||||||
set_tags: {
|
set_tags: {
|
||||||
label: 'Set tags',
|
label: 'Set tags',
|
||||||
type: FIELD_TYPE.TAG
|
type: FIELD_TYPE.TAG
|
||||||
|
},
|
||||||
|
remove_tags: {
|
||||||
|
label: 'Remove tags',
|
||||||
|
type: FIELD_TYPE.TAG
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -223,6 +276,7 @@ export function useConversationFilters () {
|
|||||||
conversationFilters,
|
conversationFilters,
|
||||||
newConversationFilters,
|
newConversationFilters,
|
||||||
conversationActions,
|
conversationActions,
|
||||||
macroActions
|
macroActions,
|
||||||
|
contactCustomAttributes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,55 +5,52 @@ import { useStorage } from '@vueuse/core'
|
|||||||
|
|
||||||
export function useIdleDetection () {
|
export function useIdleDetection () {
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
// 4 minutes
|
|
||||||
const AWAY_THRESHOLD = 4 * 60 * 1000
|
const AWAY_THRESHOLD = 4 * 60 * 1000
|
||||||
// 1 minute
|
const CHECK_INTERVAL = 30 * 1000
|
||||||
const CHECK_INTERVAL = 60 * 1000
|
|
||||||
|
|
||||||
// Store last activity time in localStorage to sync across tabs
|
|
||||||
const lastActivity = useStorage('last_active', Date.now())
|
const lastActivity = useStorage('last_active', Date.now())
|
||||||
const timer = ref(null)
|
const timer = ref(null)
|
||||||
|
|
||||||
function resetTimer () {
|
// Debounce the goOnline to prevent it from being called too frequently
|
||||||
|
const goOnline = debounce(() => {
|
||||||
if (userStore.user.availability_status === 'away' || userStore.user.availability_status === 'offline') {
|
if (userStore.user.availability_status === 'away' || userStore.user.availability_status === 'offline') {
|
||||||
userStore.updateUserAvailability('online', false)
|
userStore.updateUserAvailability('online', false)
|
||||||
}
|
}
|
||||||
const now = Date.now()
|
}, 200)
|
||||||
if (lastActivity.value < now) {
|
|
||||||
lastActivity.value = now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const debouncedResetTimer = debounce(resetTimer, 200)
|
function resetTimer () {
|
||||||
|
lastActivity.value = Date.now()
|
||||||
|
}
|
||||||
|
|
||||||
function checkIdle () {
|
function checkIdle () {
|
||||||
if (Date.now() - lastActivity.value > AWAY_THRESHOLD &&
|
if (
|
||||||
userStore.user.availability_status === 'online') {
|
Date.now() - lastActivity.value > AWAY_THRESHOLD &&
|
||||||
|
userStore.user.availability_status === 'online'
|
||||||
|
) {
|
||||||
userStore.updateUserAvailability('away', false)
|
userStore.updateUserAvailability('away', false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
window.addEventListener('mousemove', debouncedResetTimer)
|
['mousemove', 'keypress', 'click'].forEach(evt =>
|
||||||
window.addEventListener('keypress', debouncedResetTimer)
|
window.addEventListener(evt, resetTimer)
|
||||||
window.addEventListener('click', debouncedResetTimer)
|
)
|
||||||
timer.value = setInterval(checkIdle, CHECK_INTERVAL)
|
timer.value = setInterval(checkIdle, CHECK_INTERVAL)
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
window.removeEventListener('mousemove', debouncedResetTimer)
|
['mousemove', 'keypress', 'click'].forEach(evt =>
|
||||||
window.removeEventListener('keypress', debouncedResetTimer)
|
window.removeEventListener(evt, resetTimer)
|
||||||
window.removeEventListener('click', debouncedResetTimer)
|
)
|
||||||
if (timer.value) {
|
|
||||||
clearInterval(timer.value)
|
clearInterval(timer.value)
|
||||||
timer.value = null
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Watch for lastActivity changes in localStorage to handle multi-tab sync
|
|
||||||
watch(lastActivity, (newVal, oldVal) => {
|
watch(lastActivity, (newVal, oldVal) => {
|
||||||
if (newVal > oldVal) {
|
if (
|
||||||
resetTimer()
|
newVal > oldVal &&
|
||||||
|
document.visibilityState === 'visible'
|
||||||
|
) {
|
||||||
|
goOnline()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
242
frontend/src/constants/countries.js
Normal file
242
frontend/src/constants/countries.js
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
const countries = [
|
||||||
|
{ calling_code: '+93', name: 'Afghanistan', emoji: '🇦🇫', iso_2: 'AF' },
|
||||||
|
{ calling_code: '+355', name: 'Albania', emoji: '🇦🇱', iso_2: 'AL' },
|
||||||
|
{ calling_code: '+213', name: 'Algeria', emoji: '🇩🇿', iso_2: 'DZ' },
|
||||||
|
{ calling_code: '+1-684', name: 'American Samoa', emoji: '🇦🇸', iso_2: 'AS' },
|
||||||
|
{ calling_code: '+376', name: 'Andorra', emoji: '🇦🇩', iso_2: 'AD' },
|
||||||
|
{ calling_code: '+244', name: 'Angola', emoji: '🇦🇴', iso_2: 'AO' },
|
||||||
|
{ calling_code: '+1-264', name: 'Anguilla', emoji: '🇦🇮', iso_2: 'AI' },
|
||||||
|
{ calling_code: '+1-268', name: 'Antigua and Barbuda', emoji: '🇦🇬', iso_2: 'AG' },
|
||||||
|
{ calling_code: '+54', name: 'Argentina', emoji: '🇦🇷', iso_2: 'AR' },
|
||||||
|
{ calling_code: '+374', name: 'Armenia', emoji: '🇦🇲', iso_2: 'AM' },
|
||||||
|
{ calling_code: '+297', name: 'Aruba', emoji: '🇦🇼', iso_2: 'AW' },
|
||||||
|
{ calling_code: '+61', name: 'Australia', emoji: '🇦🇺', iso_2: 'AU' },
|
||||||
|
{ calling_code: '+43', name: 'Austria', emoji: '🇦🇹', iso_2: 'AT' },
|
||||||
|
{ calling_code: '+994', name: 'Azerbaijan', emoji: '🇦🇿', iso_2: 'AZ' },
|
||||||
|
{ calling_code: '+1-242', name: 'Bahamas', emoji: '🇧🇸', iso_2: 'BS' },
|
||||||
|
{ calling_code: '+973', name: 'Bahrain', emoji: '🇧🇭', iso_2: 'BH' },
|
||||||
|
{ calling_code: '+880', name: 'Bangladesh', emoji: '🇧🇩', iso_2: 'BD' },
|
||||||
|
{ calling_code: '+1-246', name: 'Barbados', emoji: '🇧🇧', iso_2: 'BB' },
|
||||||
|
{ calling_code: '+375', name: 'Belarus', emoji: '🇧🇾', iso_2: 'BY' },
|
||||||
|
{ calling_code: '+32', name: 'Belgium', emoji: '🇧🇪', iso_2: 'BE' },
|
||||||
|
{ calling_code: '+501', name: 'Belize', emoji: '🇧🇿', iso_2: 'BZ' },
|
||||||
|
{ calling_code: '+229', name: 'Benin', emoji: '🇧🇯', iso_2: 'BJ' },
|
||||||
|
{ calling_code: '+1-441', name: 'Bermuda', emoji: '🇧🇲', iso_2: 'BM' },
|
||||||
|
{ calling_code: '+975', name: 'Bhutan', emoji: '🇧🇹', iso_2: 'BT' },
|
||||||
|
{ calling_code: '+591', name: 'Bolivia', emoji: '🇧🇴', iso_2: 'BO' },
|
||||||
|
{ calling_code: '+387', name: 'Bosnia and Herzegovina', emoji: '🇧🇦', iso_2: 'BA' },
|
||||||
|
{ calling_code: '+267', name: 'Botswana', emoji: '🇧🇼', iso_2: 'BW' },
|
||||||
|
{ calling_code: '+55', name: 'Brazil', emoji: '🇧🇷', iso_2: 'BR' },
|
||||||
|
{ calling_code: '+246', name: 'British Indian Ocean Territory', emoji: '🇮🇴', iso_2: 'IO' },
|
||||||
|
{ calling_code: '+673', name: 'Brunei', emoji: '🇧🇳', iso_2: 'BN' },
|
||||||
|
{ calling_code: '+359', name: 'Bulgaria', emoji: '🇧🇬', iso_2: 'BG' },
|
||||||
|
{ calling_code: '+226', name: 'Burkina Faso', emoji: '🇧🇫', iso_2: 'BF' },
|
||||||
|
{ calling_code: '+257', name: 'Burundi', emoji: '🇧🇮', iso_2: 'BI' },
|
||||||
|
{ calling_code: '+855', name: 'Cambodia', emoji: '🇰🇭', iso_2: 'KH' },
|
||||||
|
{ calling_code: '+237', name: 'Cameroon', emoji: '🇨🇲', iso_2: 'CM' },
|
||||||
|
{ calling_code: '+1', name: 'Canada', emoji: '🇨🇦', iso_2: 'CA' },
|
||||||
|
{ calling_code: '+238', name: 'Cape Verde', emoji: '🇨🇻', iso_2: 'CV' },
|
||||||
|
{ calling_code: '+1-345', name: 'Cayman Islands', emoji: '🇰🇾', iso_2: 'KY' },
|
||||||
|
{ calling_code: '+236', name: 'Central African Republic', emoji: '🇨🇫', iso_2: 'CF' },
|
||||||
|
{ calling_code: '+235', name: 'Chad', emoji: '🇹🇩', iso_2: 'TD' },
|
||||||
|
{ calling_code: '+56', name: 'Chile', emoji: '🇨🇱', iso_2: 'CL' },
|
||||||
|
{ calling_code: '+86', name: 'China', emoji: '🇨🇳', iso_2: 'CN' },
|
||||||
|
{ calling_code: '+61', name: 'Christmas Island', emoji: '🇨🇽', iso_2: 'CX' },
|
||||||
|
{ calling_code: '+61', name: 'Cocos (Keeling) Islands', emoji: '🇨🇨', iso_2: 'CC' },
|
||||||
|
{ calling_code: '+57', name: 'Colombia', emoji: '🇨🇴', iso_2: 'CO' },
|
||||||
|
{ calling_code: '+269', name: 'Comoros', emoji: '🇰🇲', iso_2: 'KM' },
|
||||||
|
{ calling_code: '+242', name: 'Congo', emoji: '🇨🇬', iso_2: 'CG' },
|
||||||
|
{ calling_code: '+243', name: 'Congo, Democratic Republic of the', emoji: '🇨🇩', iso_2: 'CD' },
|
||||||
|
{ calling_code: '+682', name: 'Cook Islands', emoji: '🇨🇰', iso_2: 'CK' },
|
||||||
|
{ calling_code: '+506', name: 'Costa Rica', emoji: '🇨🇷', iso_2: 'CR' },
|
||||||
|
{ calling_code: '+225', name: "Côte d'Ivoire", emoji: '🇨🇮', iso_2: 'CI' },
|
||||||
|
{ calling_code: '+385', name: 'Croatia', emoji: '🇭🇷', iso_2: 'HR' },
|
||||||
|
{ calling_code: '+53', name: 'Cuba', emoji: '🇨🇺', iso_2: 'CU' },
|
||||||
|
{ calling_code: '+599', name: 'Curaçao', emoji: '🇨🇼', iso_2: 'CW' },
|
||||||
|
{ calling_code: '+357', name: 'Cyprus', emoji: '🇨🇾', iso_2: 'CY' },
|
||||||
|
{ calling_code: '+420', name: 'Czech Republic', emoji: '🇨🇿', iso_2: 'CZ' },
|
||||||
|
{ calling_code: '+45', name: 'Denmark', emoji: '🇩🇰', iso_2: 'DK' },
|
||||||
|
{ calling_code: '+253', name: 'Djibouti', emoji: '🇩🇯', iso_2: 'DJ' },
|
||||||
|
{ calling_code: '+1-767', name: 'Dominica', emoji: '🇩🇲', iso_2: 'DM' },
|
||||||
|
{ calling_code: '+1-809', name: 'Dominican Republic', emoji: '🇩🇴', iso_2: 'DO' },
|
||||||
|
{ calling_code: '+593', name: 'Ecuador', emoji: '🇪🇨', iso_2: 'EC' },
|
||||||
|
{ calling_code: '+20', name: 'Egypt', emoji: '🇪🇬', iso_2: 'EG' },
|
||||||
|
{ calling_code: '+503', name: 'El Salvador', emoji: '🇸🇻', iso_2: 'SV' },
|
||||||
|
{ calling_code: '+240', name: 'Equatorial Guinea', emoji: '🇬🇶', iso_2: 'GQ' },
|
||||||
|
{ calling_code: '+291', name: 'Eritrea', emoji: '🇪🇷', iso_2: 'ER' },
|
||||||
|
{ calling_code: '+372', name: 'Estonia', emoji: '🇪🇪', iso_2: 'EE' },
|
||||||
|
{ calling_code: '+268', name: 'Eswatini', emoji: '🇸🇿', iso_2: 'SZ' },
|
||||||
|
{ calling_code: '+251', name: 'Ethiopia', emoji: '🇪🇹', iso_2: 'ET' },
|
||||||
|
{ calling_code: '+500', name: 'Falkland Islands', emoji: '🇫🇰', iso_2: 'FK' },
|
||||||
|
{ calling_code: '+298', name: 'Faroe Islands', emoji: '🇫🇴', iso_2: 'FO' },
|
||||||
|
{ calling_code: '+679', name: 'Fiji', emoji: '🇫🇯', iso_2: 'FJ' },
|
||||||
|
{ calling_code: '+358', name: 'Finland', emoji: '🇫🇮', iso_2: 'FI' },
|
||||||
|
{ calling_code: '+33', name: 'France', emoji: '🇫🇷', iso_2: 'FR' },
|
||||||
|
{ calling_code: '+594', name: 'French Guiana', emoji: '🇬🇫', iso_2: 'GF' },
|
||||||
|
{ calling_code: '+689', name: 'French Polynesia', emoji: '🇵🇫', iso_2: 'PF' },
|
||||||
|
{ calling_code: '+241', name: 'Gabon', emoji: '🇬🇦', iso_2: 'GA' },
|
||||||
|
{ calling_code: '+220', name: 'Gambia', emoji: '🇬🇲', iso_2: 'GM' },
|
||||||
|
{ calling_code: '+995', name: 'Georgia', emoji: '🇬🇪', iso_2: 'GE' },
|
||||||
|
{ calling_code: '+49', name: 'Germany', emoji: '🇩🇪', iso_2: 'DE' },
|
||||||
|
{ calling_code: '+233', name: 'Ghana', emoji: '🇬🇭', iso_2: 'GH' },
|
||||||
|
{ calling_code: '+350', name: 'Gibraltar', emoji: '🇬🇮', iso_2: 'GI' },
|
||||||
|
{ calling_code: '+30', name: 'Greece', emoji: '🇬🇷', iso_2: 'GR' },
|
||||||
|
{ calling_code: '+299', name: 'Greenland', emoji: '🇬🇱', iso_2: 'GL' },
|
||||||
|
{ calling_code: '+1-473', name: 'Grenada', emoji: '🇬🇩', iso_2: 'GD' },
|
||||||
|
{ calling_code: '+590', name: 'Guadeloupe', emoji: '🇬🇵', iso_2: 'GP' },
|
||||||
|
{ calling_code: '+1-671', name: 'Guam', emoji: '🇬🇺', iso_2: 'GU' },
|
||||||
|
{ calling_code: '+502', name: 'Guatemala', emoji: '🇬🇹', iso_2: 'GT' },
|
||||||
|
{ calling_code: '+44-1481', name: 'Guernsey', emoji: '🇬🇬', iso_2: 'GG' },
|
||||||
|
{ calling_code: '+224', name: 'Guinea', emoji: '🇬🇳', iso_2: 'GN' },
|
||||||
|
{ calling_code: '+245', name: 'Guinea-Bissau', emoji: '🇬🇼', iso_2: 'GW' },
|
||||||
|
{ calling_code: '+592', name: 'Guyana', emoji: '🇬🇾', iso_2: 'GY' },
|
||||||
|
{ calling_code: '+509', name: 'Haiti', emoji: '🇭🇹', iso_2: 'HT' },
|
||||||
|
{ calling_code: '+379', name: 'Vatican City', emoji: '🇻🇦', iso_2: 'VA' },
|
||||||
|
{ calling_code: '+504', name: 'Honduras', emoji: '🇭🇳', iso_2: 'HN' },
|
||||||
|
{ calling_code: '+852', name: 'Hong Kong', emoji: '🇭🇰', iso_2: 'HK' },
|
||||||
|
{ calling_code: '+36', name: 'Hungary', emoji: '🇭🇺', iso_2: 'HU' },
|
||||||
|
{ calling_code: '+354', name: 'Iceland', emoji: '🇮🇸', iso_2: 'IS' },
|
||||||
|
{ calling_code: '+91', name: 'India', emoji: '🇮🇳', iso_2: 'IN' },
|
||||||
|
{ calling_code: '+62', name: 'Indonesia', emoji: '🇮🇩', iso_2: 'ID' },
|
||||||
|
{ calling_code: '+98', name: 'Iran', emoji: '🇮🇷', iso_2: 'IR' },
|
||||||
|
{ calling_code: '+964', name: 'Iraq', emoji: '🇮🇶', iso_2: 'IQ' },
|
||||||
|
{ calling_code: '+353', name: 'Ireland', emoji: '🇮🇪', iso_2: 'IE' },
|
||||||
|
{ calling_code: '+44-1624', name: 'Isle of Man', emoji: '🇮🇲', iso_2: 'IM' },
|
||||||
|
{ calling_code: '+972', name: 'Israel', emoji: '🇮🇱', iso_2: 'IL' },
|
||||||
|
{ calling_code: '+39', name: 'Italy', emoji: '🇮🇹', iso_2: 'IT' },
|
||||||
|
{ calling_code: '+1-876', name: 'Jamaica', emoji: '🇯🇲', iso_2: 'JM' },
|
||||||
|
{ calling_code: '+81', name: 'Japan', emoji: '🇯🇵', iso_2: 'JP' },
|
||||||
|
{ calling_code: '+44-1534', name: 'Jersey', emoji: '🇯🇪', iso_2: 'JE' },
|
||||||
|
{ calling_code: '+962', name: 'Jordan', emoji: '🇯🇴', iso_2: 'JO' },
|
||||||
|
{ calling_code: '+7', name: 'Kazakhstan', emoji: '🇰🇿', iso_2: 'KZ' },
|
||||||
|
{ calling_code: '+254', name: 'Kenya', emoji: '🇰🇪', iso_2: 'KE' },
|
||||||
|
{ calling_code: '+686', name: 'Kiribati', emoji: '🇰🇮', iso_2: 'KI' },
|
||||||
|
{ calling_code: '+383', name: 'Kosovo', emoji: '🇽🇰', iso_2: 'XK' },
|
||||||
|
{ calling_code: '+965', name: 'Kuwait', emoji: '🇰🇼', iso_2: 'KW' },
|
||||||
|
{ calling_code: '+996', name: 'Kyrgyzstan', emoji: '🇰🇬', iso_2: 'KG' },
|
||||||
|
{ calling_code: '+856', name: 'Laos', emoji: '🇱🇦', iso_2: 'LA' },
|
||||||
|
{ calling_code: '+371', name: 'Latvia', emoji: '🇱🇻', iso_2: 'LV' },
|
||||||
|
{ calling_code: '+961', name: 'Lebanon', emoji: '🇱🇧', iso_2: 'LB' },
|
||||||
|
{ calling_code: '+266', name: 'Lesotho', emoji: '🇱🇸', iso_2: 'LS' },
|
||||||
|
{ calling_code: '+231', name: 'Liberia', emoji: '🇱🇷', iso_2: 'LR' },
|
||||||
|
{ calling_code: '+218', name: 'Libya', emoji: '🇱🇾', iso_2: 'LY' },
|
||||||
|
{ calling_code: '+423', name: 'Liechtenstein', emoji: '🇱🇮', iso_2: 'LI' },
|
||||||
|
{ calling_code: '+370', name: 'Lithuania', emoji: '🇱🇹', iso_2: 'LT' },
|
||||||
|
{ calling_code: '+352', name: 'Luxembourg', emoji: '🇱🇺', iso_2: 'LU' },
|
||||||
|
{ calling_code: '+853', name: 'Macao', emoji: '🇲🇴', iso_2: 'MO' },
|
||||||
|
{ calling_code: '+389', name: 'North Macedonia', emoji: '🇲🇰', iso_2: 'MK' },
|
||||||
|
{ calling_code: '+261', name: 'Madagascar', emoji: '🇲🇬', iso_2: 'MG' },
|
||||||
|
{ calling_code: '+265', name: 'Malawi', emoji: '🇲🇼', iso_2: 'MW' },
|
||||||
|
{ calling_code: '+60', name: 'Malaysia', emoji: '🇲🇾', iso_2: 'MY' },
|
||||||
|
{ calling_code: '+960', name: 'Maldives', emoji: '🇲🇻', iso_2: 'MV' },
|
||||||
|
{ calling_code: '+223', name: 'Mali', emoji: '🇲🇱', iso_2: 'ML' },
|
||||||
|
{ calling_code: '+356', name: 'Malta', emoji: '🇲🇹', iso_2: 'MT' },
|
||||||
|
{ calling_code: '+692', name: 'Marshall Islands', emoji: '🇲🇭', iso_2: 'MH' },
|
||||||
|
{ calling_code: '+596', name: 'Martinique', emoji: '🇲🇶', iso_2: 'MQ' },
|
||||||
|
{ calling_code: '+222', name: 'Mauritania', emoji: '🇲🇷', iso_2: 'MR' },
|
||||||
|
{ calling_code: '+230', name: 'Mauritius', emoji: '🇲🇺', iso_2: 'MU' },
|
||||||
|
{ calling_code: '+262', name: 'Mayotte', emoji: '🇾🇹', iso_2: 'YT' },
|
||||||
|
{ calling_code: '+52', name: 'Mexico', emoji: '🇲🇽', iso_2: 'MX' },
|
||||||
|
{ calling_code: '+691', name: 'Micronesia', emoji: '🇫🇲', iso_2: 'FM' },
|
||||||
|
{ calling_code: '+373', name: 'Moldova', emoji: '🇲🇩', iso_2: 'MD' },
|
||||||
|
{ calling_code: '+377', name: 'Monaco', emoji: '🇲🇨', iso_2: 'MC' },
|
||||||
|
{ calling_code: '+976', name: 'Mongolia', emoji: '🇲🇳', iso_2: 'MN' },
|
||||||
|
{ calling_code: '+382', name: 'Montenegro', emoji: '🇲🇪', iso_2: 'ME' },
|
||||||
|
{ calling_code: '+1-664', name: 'Montserrat', emoji: '🇲🇸', iso_2: 'MS' },
|
||||||
|
{ calling_code: '+212', name: 'Morocco', emoji: '🇲🇦', iso_2: 'MA' },
|
||||||
|
{ calling_code: '+258', name: 'Mozambique', emoji: '🇲🇿', iso_2: 'MZ' },
|
||||||
|
{ calling_code: '+95', name: 'Myanmar', emoji: '🇲🇲', iso_2: 'MM' },
|
||||||
|
{ calling_code: '+264', name: 'Namibia', emoji: '🇳🇦', iso_2: 'NA' },
|
||||||
|
{ calling_code: '+674', name: 'Nauru', emoji: '🇳🇷', iso_2: 'NR' },
|
||||||
|
{ calling_code: '+977', name: 'Nepal', emoji: '🇳🇵', iso_2: 'NP' },
|
||||||
|
{ calling_code: '+31', name: 'Netherlands', emoji: '🇳🇱', iso_2: 'NL' },
|
||||||
|
{ calling_code: '+687', name: 'New Caledonia', emoji: '🇳🇨', iso_2: 'NC' },
|
||||||
|
{ calling_code: '+64', name: 'New Zealand', emoji: '🇳🇿', iso_2: 'NZ' },
|
||||||
|
{ calling_code: '+505', name: 'Nicaragua', emoji: '🇳🇮', iso_2: 'NI' },
|
||||||
|
{ calling_code: '+227', name: 'Niger', emoji: '🇳🇪', iso_2: 'NE' },
|
||||||
|
{ calling_code: '+234', name: 'Nigeria', emoji: '🇳🇬', iso_2: 'NG' },
|
||||||
|
{ calling_code: '+683', name: 'Niue', emoji: '🇳🇺', iso_2: 'NU' },
|
||||||
|
{ calling_code: '+672', name: 'Norfolk Island', emoji: '🇳🇫', iso_2: 'NF' },
|
||||||
|
{ calling_code: '+850', name: 'North Korea', emoji: '🇰🇵', iso_2: 'KP' },
|
||||||
|
{ calling_code: '+47', name: 'Norway', emoji: '🇳🇴', iso_2: 'NO' },
|
||||||
|
{ calling_code: '+968', name: 'Oman', emoji: '🇴🇲', iso_2: 'OM' },
|
||||||
|
{ calling_code: '+92', name: 'Pakistan', emoji: '🇵🇰', iso_2: 'PK' },
|
||||||
|
{ calling_code: '+680', name: 'Palau', emoji: '🇵🇼', iso_2: 'PW' },
|
||||||
|
{ calling_code: '+970', name: 'Palestine', emoji: '🇵🇸', iso_2: 'PS' },
|
||||||
|
{ calling_code: '+507', name: 'Panama', emoji: '🇵🇦', iso_2: 'PA' },
|
||||||
|
{ calling_code: '+675', name: 'Papua New Guinea', emoji: '🇵🇬', iso_2: 'PG' },
|
||||||
|
{ calling_code: '+595', name: 'Paraguay', emoji: '🇵🇾', iso_2: 'PY' },
|
||||||
|
{ calling_code: '+51', name: 'Peru', emoji: '🇵🇪', iso_2: 'PE' },
|
||||||
|
{ calling_code: '+63', name: 'Philippines', emoji: '🇵🇭', iso_2: 'PH' },
|
||||||
|
{ calling_code: '+64', name: 'Pitcairn Islands', emoji: '🇵🇳', iso_2: 'PN' },
|
||||||
|
{ calling_code: '+48', name: 'Poland', emoji: '🇵🇱', iso_2: 'PL' },
|
||||||
|
{ calling_code: '+351', name: 'Portugal', emoji: '🇵🇹', iso_2: 'PT' },
|
||||||
|
{ calling_code: '+1-787', name: 'Puerto Rico', emoji: '🇵🇷', iso_2: 'PR' },
|
||||||
|
{ calling_code: '+974', name: 'Qatar', emoji: '🇶🇦', iso_2: 'QA' },
|
||||||
|
{ calling_code: '+40', name: 'Romania', emoji: '🇷🇴', iso_2: 'RO' },
|
||||||
|
{ calling_code: '+7', name: 'Russia', emoji: '🇷🇺', iso_2: 'RU' },
|
||||||
|
{ calling_code: '+250', name: 'Rwanda', emoji: '🇷🇼', iso_2: 'RW' },
|
||||||
|
{ calling_code: '+590', name: 'Saint Barthélemy', emoji: '🇧🇱', iso_2: 'BL' },
|
||||||
|
{ calling_code: '+290', name: 'Saint Helena, Ascension and Tristan da Cunha', emoji: '🇸🇭', iso_2: 'SH' },
|
||||||
|
{ calling_code: '+1-869', name: 'Saint Kitts and Nevis', emoji: '🇰🇳', iso_2: 'KN' },
|
||||||
|
{ calling_code: '+1-758', name: 'Saint Lucia', emoji: '🇱🇨', iso_2: 'LC' },
|
||||||
|
{ calling_code: '+590', name: 'Saint Martin', emoji: '🇲🇫', iso_2: 'MF' },
|
||||||
|
{ calling_code: '+508', name: 'Saint Pierre and Miquelon', emoji: '🇵🇲', iso_2: 'PM' },
|
||||||
|
{ calling_code: '+1-784', name: 'Saint Vincent and the Grenadines', emoji: '🇻🇨', iso_2: 'VC' },
|
||||||
|
{ calling_code: '+685', name: 'Samoa', emoji: '🇼🇸', iso_2: 'WS' },
|
||||||
|
{ calling_code: '+378', name: 'San Marino', emoji: '🇸🇲', iso_2: 'SM' },
|
||||||
|
{ calling_code: '+239', name: 'Sao Tome and Principe', emoji: '🇸🇹', iso_2: 'ST' },
|
||||||
|
{ calling_code: '+966', name: 'Saudi Arabia', emoji: '🇸🇦', iso_2: 'SA' },
|
||||||
|
{ calling_code: '+221', name: 'Senegal', emoji: '🇸🇳', iso_2: 'SN' },
|
||||||
|
{ calling_code: '+381', name: 'Serbia', emoji: '🇷🇸', iso_2: 'RS' },
|
||||||
|
{ calling_code: '+248', name: 'Seychelles', emoji: '🇸🇨', iso_2: 'SC' },
|
||||||
|
{ calling_code: '+232', name: 'Sierra Leone', emoji: '🇸🇱', iso_2: 'SL' },
|
||||||
|
{ calling_code: '+65', name: 'Singapore', emoji: '🇸🇬', iso_2: 'SG' },
|
||||||
|
{ calling_code: '+1-721', name: 'Sint Maarten', emoji: '🇸🇽', iso_2: 'SX' },
|
||||||
|
{ calling_code: '+421', name: 'Slovakia', emoji: '🇸🇰', iso_2: 'SK' },
|
||||||
|
{ calling_code: '+386', name: 'Slovenia', emoji: '🇸🇮', iso_2: 'SI' },
|
||||||
|
{ calling_code: '+677', name: 'Solomon Islands', emoji: '🇸🇧', iso_2: 'SB' },
|
||||||
|
{ calling_code: '+252', name: 'Somalia', emoji: '🇸🇴', iso_2: 'SO' },
|
||||||
|
{ calling_code: '+27', name: 'South Africa', emoji: '🇿🇦', iso_2: 'ZA' },
|
||||||
|
{ calling_code: '+82', name: 'South Korea', emoji: '🇰🇷', iso_2: 'KR' },
|
||||||
|
{ calling_code: '+211', name: 'South Sudan', emoji: '🇸🇸', iso_2: 'SS' },
|
||||||
|
{ calling_code: '+34', name: 'Spain', emoji: '🇪🇸', iso_2: 'ES' },
|
||||||
|
{ calling_code: '+94', name: 'Sri Lanka', emoji: '🇱🇰', iso_2: 'LK' },
|
||||||
|
{ calling_code: '+249', name: 'Sudan', emoji: '🇸🇩', iso_2: 'SD' },
|
||||||
|
{ calling_code: '+597', name: 'Suriname', emoji: '🇸🇷', iso_2: 'SR' },
|
||||||
|
{ calling_code: '+47', name: 'Svalbard and Jan Mayen', emoji: '🇸🇯', iso_2: 'SJ' },
|
||||||
|
{ calling_code: '+46', name: 'Sweden', emoji: '🇸🇪', iso_2: 'SE' },
|
||||||
|
{ calling_code: '+41', name: 'Switzerland', emoji: '🇨🇭', iso_2: 'CH' },
|
||||||
|
{ calling_code: '+963', name: 'Syria', emoji: '🇸🇾', iso_2: 'SY' },
|
||||||
|
{ calling_code: '+886', name: 'Taiwan', emoji: '🇹🇼', iso_2: 'TW' },
|
||||||
|
{ calling_code: '+992', name: 'Tajikistan', emoji: '🇹🇯', iso_2: 'TJ' },
|
||||||
|
{ calling_code: '+255', name: 'Tanzania', emoji: '🇹🇿', iso_2: 'TZ' },
|
||||||
|
{ calling_code: '+66', name: 'Thailand', emoji: '🇹🇭', iso_2: 'TH' },
|
||||||
|
{ calling_code: '+670', name: 'Timor-Leste', emoji: '🇹🇱', iso_2: 'TL' },
|
||||||
|
{ calling_code: '+228', name: 'Togo', emoji: '🇹🇬', iso_2: 'TG' },
|
||||||
|
{ calling_code: '+690', name: 'Tokelau', emoji: '🇹🇰', iso_2: 'TK' },
|
||||||
|
{ calling_code: '+676', name: 'Tonga', emoji: '🇹🇴', iso_2: 'TO' },
|
||||||
|
{ calling_code: '+1-868', name: 'Trinidad and Tobago', emoji: '🇹🇹', iso_2: 'TT' },
|
||||||
|
{ calling_code: '+216', name: 'Tunisia', emoji: '🇹🇳', iso_2: 'TN' },
|
||||||
|
{ calling_code: '+90', name: 'Turkey', emoji: '🇹🇷', iso_2: 'TR' },
|
||||||
|
{ calling_code: '+993', name: 'Turkmenistan', emoji: '🇹🇲', iso_2: 'TM' },
|
||||||
|
{ calling_code: '+1-649', name: 'Turks and Caicos Islands', emoji: '🇹🇨', iso_2: 'TC' },
|
||||||
|
{ calling_code: '+688', name: 'Tuvalu', emoji: '🇹🇻', iso_2: 'TV' },
|
||||||
|
{ calling_code: '+256', name: 'Uganda', emoji: '🇺🇬', iso_2: 'UG' },
|
||||||
|
{ calling_code: '+380', name: 'Ukraine', emoji: '🇺🇦', iso_2: 'UA' },
|
||||||
|
{ calling_code: '+971', name: 'United Arab Emirates', emoji: '🇦🇪', iso_2: 'AE' },
|
||||||
|
{ calling_code: '+44', name: 'United Kingdom', emoji: '🇬🇧', iso_2: 'GB' },
|
||||||
|
{ calling_code: '+1', name: 'United States', emoji: '🇺🇸', iso_2: 'US' },
|
||||||
|
{ calling_code: '+598', name: 'Uruguay', emoji: '🇺🇾', iso_2: 'UY' },
|
||||||
|
{ calling_code: '+998', name: 'Uzbekistan', emoji: '🇺🇿', iso_2: 'UZ' },
|
||||||
|
{ calling_code: '+678', name: 'Vanuatu', emoji: '🇻🇺', iso_2: 'VU' },
|
||||||
|
{ calling_code: '+58', name: 'Venezuela', emoji: '🇻🇪', iso_2: 'VE' },
|
||||||
|
{ calling_code: '+84', name: 'Vietnam', emoji: '🇻🇳', iso_2: 'VN' },
|
||||||
|
{ calling_code: '+681', name: 'Wallis and Futuna', emoji: '🇼🇫', iso_2: 'WF' },
|
||||||
|
{ calling_code: '+212', name: 'Western Sahara', emoji: '🇪🇭', iso_2: 'EH' },
|
||||||
|
{ calling_code: '+967', name: 'Yemen', emoji: '🇾🇪', iso_2: 'YE' },
|
||||||
|
{ calling_code: '+260', name: 'Zambia', emoji: '🇿🇲', iso_2: 'ZM' },
|
||||||
|
{ calling_code: '+263', name: 'Zimbabwe', emoji: '🇿🇼', iso_2: 'ZW' }
|
||||||
|
]
|
||||||
|
|
||||||
|
export default countries;
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export const EMITTER_EVENTS = {
|
export const EMITTER_EVENTS = {
|
||||||
|
EDIT_MODEL: 'edit-model',
|
||||||
REFRESH_LIST: 'refresh-list',
|
REFRESH_LIST: 'refresh-list',
|
||||||
SHOW_TOAST: 'show-toast',
|
SHOW_TOAST: 'show-toast',
|
||||||
SHOW_SOONER: 'show-sooner',
|
SHOW_SOONER: 'show-sooner',
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ export const FIELD_TYPE = {
|
|||||||
TAG: 'tag',
|
TAG: 'tag',
|
||||||
TEXT: 'text',
|
TEXT: 'text',
|
||||||
NUMBER: 'number',
|
NUMBER: 'number',
|
||||||
RICHTEXT: 'richtext'
|
RICHTEXT: 'richtext',
|
||||||
|
BOOLEAN: 'boolean',
|
||||||
|
DATE: 'date',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const OPERATOR = {
|
export const OPERATOR = {
|
||||||
@@ -19,6 +21,7 @@ export const OPERATOR = {
|
|||||||
|
|
||||||
export const FIELD_OPERATORS = {
|
export const FIELD_OPERATORS = {
|
||||||
SELECT: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS, OPERATOR.SET, OPERATOR.NOT_SET],
|
SELECT: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS, OPERATOR.SET, OPERATOR.NOT_SET],
|
||||||
|
BOOLEAN: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS],
|
||||||
TEXT: [
|
TEXT: [
|
||||||
OPERATOR.EQUALS,
|
OPERATOR.EQUALS,
|
||||||
OPERATOR.NOT_EQUALS,
|
OPERATOR.NOT_EQUALS,
|
||||||
@@ -27,5 +30,13 @@ export const FIELD_OPERATORS = {
|
|||||||
OPERATOR.CONTAINS,
|
OPERATOR.CONTAINS,
|
||||||
OPERATOR.NOT_CONTAINS
|
OPERATOR.NOT_CONTAINS
|
||||||
],
|
],
|
||||||
NUMBER: [OPERATOR.GREATER_THAN, OPERATOR.LESS_THAN]
|
DATE: [
|
||||||
|
OPERATOR.EQUALS,
|
||||||
|
OPERATOR.NOT_EQUALS,
|
||||||
|
OPERATOR.SET,
|
||||||
|
OPERATOR.NOT_SET,
|
||||||
|
OPERATOR.GREATER_THAN,
|
||||||
|
OPERATOR.LESS_THAN
|
||||||
|
],
|
||||||
|
NUMBER: [OPERATOR.EQUALS, OPERATOR.NOT_EQUALS, OPERATOR.GREATER_THAN, OPERATOR.LESS_THAN],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const reportsNavItems = [
|
export const reportsNavItems = [
|
||||||
{
|
{
|
||||||
title: 'Overview',
|
titleKey: 'navigation.overview',
|
||||||
href: '/reports/overview',
|
href: '/reports/overview',
|
||||||
permission: 'reports:manage'
|
permission: 'reports:manage'
|
||||||
}
|
}
|
||||||
@@ -8,121 +8,143 @@ export const reportsNavItems = [
|
|||||||
|
|
||||||
export const adminNavItems = [
|
export const adminNavItems = [
|
||||||
{
|
{
|
||||||
title: 'Workspace',
|
titleKey: 'navigation.workspace',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'General',
|
titleKey: 'navigation.generalSettings',
|
||||||
href: '/admin/general',
|
href: '/admin/general',
|
||||||
permission: 'general_settings:manage'
|
permission: 'general_settings:manage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Business Hours',
|
titleKey: 'navigation.businessHours',
|
||||||
href: '/admin/business-hours',
|
href: '/admin/business-hours',
|
||||||
permission: 'business_hours:manage'
|
permission: 'business_hours:manage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'SLA',
|
titleKey: 'navigation.slaPolicies',
|
||||||
href: '/admin/sla',
|
href: '/admin/sla',
|
||||||
permission: 'sla:manage'
|
permission: 'sla:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Conversations',
|
titleKey: 'navigation.conversations',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'Tags',
|
titleKey: 'navigation.tags',
|
||||||
href: '/admin/conversations/tags',
|
href: '/admin/conversations/tags',
|
||||||
permission: 'tags:manage'
|
permission: 'tags:manage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Macros',
|
titleKey: 'navigation.macros',
|
||||||
href: '/admin/conversations/macros',
|
href: '/admin/conversations/macros',
|
||||||
permission: 'macros:manage'
|
permission: 'macros:manage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Statuses',
|
titleKey: 'navigation.statuses',
|
||||||
href: '/admin/conversations/statuses',
|
href: '/admin/conversations/statuses',
|
||||||
permission: 'status:manage'
|
permission: 'status:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Inboxes',
|
titleKey: 'navigation.inboxes',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'Inboxes',
|
titleKey: 'navigation.inboxes',
|
||||||
href: '/admin/inboxes',
|
href: '/admin/inboxes',
|
||||||
permission: 'inboxes:manage'
|
permission: 'inboxes:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Teammates',
|
titleKey: 'navigation.teammates',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'Users',
|
titleKey: 'navigation.agents',
|
||||||
href: '/admin/teams/users',
|
href: '/admin/teams/agents',
|
||||||
permission: 'users:manage'
|
permission: 'users:manage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Teams',
|
titleKey: 'navigation.teams',
|
||||||
href: '/admin/teams/teams',
|
href: '/admin/teams/teams',
|
||||||
permission: 'teams:manage'
|
permission: 'teams:manage'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Roles',
|
titleKey: 'navigation.roles',
|
||||||
href: '/admin/teams/roles',
|
href: '/admin/teams/roles',
|
||||||
permission: 'roles:manage'
|
permission: 'roles:manage'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
titleKey: 'navigation.activityLog',
|
||||||
|
href: '/admin/teams/activity-log',
|
||||||
|
permission: 'activity_logs:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Automations',
|
titleKey: 'navigation.automations',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'Automations',
|
titleKey: 'navigation.automations',
|
||||||
href: '/admin/automations',
|
href: '/admin/automations',
|
||||||
permission: 'automations:manage'
|
permission: 'automations:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Notifications',
|
titleKey: 'navigation.customAttributes',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'Email',
|
titleKey: 'navigation.customAttributes',
|
||||||
|
href: '/admin/custom-attributes',
|
||||||
|
permission: 'custom_attributes:manage'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
titleKey: 'navigation.notifications',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
titleKey: 'navigation.email',
|
||||||
href: '/admin/notification',
|
href: '/admin/notification',
|
||||||
permission: 'notification_settings:manage'
|
permission: 'notification_settings:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Templates',
|
titleKey: 'navigation.templates',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'Templates',
|
titleKey: 'navigation.templates',
|
||||||
href: '/admin/templates',
|
href: '/admin/templates',
|
||||||
permission: 'templates:manage'
|
permission: 'templates:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Security',
|
titleKey: 'navigation.security',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
title: 'SSO',
|
titleKey: 'navigation.sso',
|
||||||
href: '/admin/sso',
|
href: '/admin/sso',
|
||||||
permission: 'oidc:manage'
|
permission: 'oidc:manage'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export const accountNavItems = [
|
export const accountNavItems = [
|
||||||
{
|
{
|
||||||
title: 'Profile',
|
titleKey: 'navigation.profile',
|
||||||
href: '/account/profile',
|
href: '/account/profile',
|
||||||
description: 'Update your profile'
|
description: 'Update your profile'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const contactNavItems = [
|
||||||
|
{
|
||||||
|
titleKey: 'navigation.allContacts',
|
||||||
|
href: '/contacts',
|
||||||
|
}
|
||||||
|
]
|
||||||
41
frontend/src/constants/permissions.js
Normal file
41
frontend/src/constants/permissions.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
export const permissions = {
|
||||||
|
CONVERSATIONS_READ: 'conversations:read',
|
||||||
|
CONVERSATIONS_WRITE: 'conversations:write',
|
||||||
|
CONVERSATIONS_READ_ASSIGNED: 'conversations:read_assigned',
|
||||||
|
CONVERSATIONS_READ_ALL: 'conversations:read_all',
|
||||||
|
CONVERSATIONS_READ_UNASSIGNED: 'conversations:read_unassigned',
|
||||||
|
CONVERSATIONS_READ_TEAM_INBOX: 'conversations:read_team_inbox',
|
||||||
|
CONVERSATIONS_UPDATE_USER_ASSIGNEE: 'conversations:update_user_assignee',
|
||||||
|
CONVERSATIONS_UPDATE_TEAM_ASSIGNEE: 'conversations:update_team_assignee',
|
||||||
|
CONVERSATIONS_UPDATE_PRIORITY: 'conversations:update_priority',
|
||||||
|
CONVERSATIONS_UPDATE_STATUS: 'conversations:update_status',
|
||||||
|
CONVERSATIONS_UPDATE_TAGS: 'conversations:update_tags',
|
||||||
|
MESSAGES_READ: 'messages:read',
|
||||||
|
MESSAGES_WRITE: 'messages:write',
|
||||||
|
VIEW_MANAGE: 'view:manage',
|
||||||
|
GENERAL_SETTINGS_MANAGE: 'general_settings:manage',
|
||||||
|
NOTIFICATION_SETTINGS_MANAGE: 'notification_settings:manage',
|
||||||
|
STATUS_MANAGE: 'status:manage',
|
||||||
|
OIDC_MANAGE: 'oidc:manage',
|
||||||
|
TAGS_MANAGE: 'tags:manage',
|
||||||
|
MACROS_MANAGE: 'macros:manage',
|
||||||
|
USERS_MANAGE: 'users:manage',
|
||||||
|
TEAMS_MANAGE: 'teams:manage',
|
||||||
|
AUTOMATIONS_MANAGE: 'automations:manage',
|
||||||
|
INBOXES_MANAGE: 'inboxes:manage',
|
||||||
|
ROLES_MANAGE: 'roles:manage',
|
||||||
|
TEMPLATES_MANAGE: 'templates:manage',
|
||||||
|
REPORTS_MANAGE: 'reports:manage',
|
||||||
|
BUSINESS_HOURS_MANAGE: 'business_hours:manage',
|
||||||
|
SLA_MANAGE: 'sla:manage',
|
||||||
|
AI_MANAGE: 'ai:manage',
|
||||||
|
CUSTOM_ATTRIBUTES_MANAGE: 'custom_attributes:manage',
|
||||||
|
CONTACTS_READ_ALL: 'contacts:read_all',
|
||||||
|
CONTACTS_READ: 'contacts:read',
|
||||||
|
CONTACTS_WRITE: 'contacts:write',
|
||||||
|
CONTACTS_BLOCK: 'contacts:block',
|
||||||
|
CONTACT_NOTES_READ: 'contact_notes:read',
|
||||||
|
CONTACT_NOTES_WRITE: 'contact_notes:write',
|
||||||
|
CONTACT_NOTES_DELETE: 'contact_notes:delete',
|
||||||
|
ACTIVITY_LOGS_MANAGE: 'activity_logs:manage',
|
||||||
|
};
|
||||||
36
frontend/src/constants/timezones.js
Normal file
36
frontend/src/constants/timezones.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
export const timeZones = {
|
||||||
|
"UTC (UTC+00:00)": "UTC",
|
||||||
|
"New York, America (UTC-05:00)": "America/New_York",
|
||||||
|
"Chicago, America (UTC-06:00)": "America/Chicago",
|
||||||
|
"Denver, America (UTC-07:00)": "America/Denver",
|
||||||
|
"Los Angeles, America (UTC-08:00)": "America/Los_Angeles",
|
||||||
|
"Toronto, America (UTC-05:00)": "America/Toronto",
|
||||||
|
"Mexico City, America (UTC-06:00)": "America/Mexico_City",
|
||||||
|
"Bogotá, America (UTC-05:00)": "America/Bogota",
|
||||||
|
"São Paulo, America (UTC-03:00)": "America/Sao_Paulo",
|
||||||
|
"Buenos Aires, America (UTC-03:00)": "America/Buenos_Aires",
|
||||||
|
"Santiago, America (UTC-04:00)": "America/Santiago",
|
||||||
|
"London, Europe (UTC+00:00)": "Europe/London",
|
||||||
|
"Berlin, Europe (UTC+01:00)": "Europe/Berlin",
|
||||||
|
"Paris, Europe (UTC+01:00)": "Europe/Paris",
|
||||||
|
"Rome, Europe (UTC+01:00)": "Europe/Rome",
|
||||||
|
"Madrid, Europe (UTC+01:00)": "Europe/Madrid",
|
||||||
|
"Moscow, Europe (UTC+03:00)": "Europe/Moscow",
|
||||||
|
"Istanbul, Europe (UTC+03:00)": "Europe/Istanbul",
|
||||||
|
"Dubai, Asia (UTC+04:00)": "Asia/Dubai",
|
||||||
|
"Kolkata, Asia (UTC+05:30)": "Asia/Kolkata",
|
||||||
|
"Bangkok, Asia (UTC+07:00)": "Asia/Bangkok",
|
||||||
|
"Singapore, Asia (UTC+08:00)": "Asia/Singapore",
|
||||||
|
"Shanghai, Asia (UTC+08:00)": "Asia/Shanghai",
|
||||||
|
"Seoul, Asia (UTC+09:00)": "Asia/Seoul",
|
||||||
|
"Tokyo, Asia (UTC+09:00)": "Asia/Tokyo",
|
||||||
|
"Sydney, Australia (UTC+10:00)": "Australia/Sydney",
|
||||||
|
"Melbourne, Australia (UTC+10:00)": "Australia/Melbourne",
|
||||||
|
"Perth, Australia (UTC+08:00)": "Australia/Perth",
|
||||||
|
"Auckland, Pacific (UTC+12:00)": "Pacific/Auckland",
|
||||||
|
"Honolulu, Pacific (UTC-10:00)": "Pacific/Honolulu",
|
||||||
|
"Cairo, Africa (UTC+02:00)": "Africa/Cairo",
|
||||||
|
"Lagos, Africa (UTC+01:00)": "Africa/Lagos",
|
||||||
|
"Nairobi, Africa (UTC+03:00)": "Africa/Nairobi",
|
||||||
|
"Johannesburg, Africa (UTC+02:00)": "Africa/Johannesburg"
|
||||||
|
}
|
||||||
264
frontend/src/features/admin/activity-log/ActivityLog.vue
Normal file
264
frontend/src/features/admin/activity-log/ActivityLog.vue
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
<template>
|
||||||
|
<div class="min-h-screen flex flex-col">
|
||||||
|
<div class="flex flex-wrap gap-4 pb-4">
|
||||||
|
<div class="flex items-center gap-2 mb-4">
|
||||||
|
<!-- Filter Popover -->
|
||||||
|
<Popover :open="filtersOpen" @update:open="filtersOpen = $event">
|
||||||
|
<PopoverTrigger @click="filtersOpen = !filtersOpen">
|
||||||
|
<Button variant="outline" size="sm" class="flex items-center gap-2 h-8">
|
||||||
|
<ListFilter size="14" />
|
||||||
|
<span>Filter</span>
|
||||||
|
<span
|
||||||
|
v-if="filters.length > 0"
|
||||||
|
class="flex items-center justify-center bg-primary text-primary-foreground rounded-full size-4 text-xs"
|
||||||
|
>
|
||||||
|
{{ filters.length }}
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent class="w-full p-4 flex flex-col gap-4">
|
||||||
|
<div class="w-[32rem]">
|
||||||
|
<FilterBuilder
|
||||||
|
:fields="filterFields"
|
||||||
|
:showButtons="true"
|
||||||
|
v-model="filters"
|
||||||
|
@apply="fetchActivityLogs"
|
||||||
|
@clear="fetchActivityLogs"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
|
||||||
|
<!-- Order By Popover -->
|
||||||
|
<Popover>
|
||||||
|
<PopoverTrigger>
|
||||||
|
<Button variant="outline" size="sm" class="flex items-center h-8">
|
||||||
|
<ArrowDownWideNarrow size="18" class="text-muted-foreground cursor-pointer" />
|
||||||
|
</Button>
|
||||||
|
</PopoverTrigger>
|
||||||
|
<PopoverContent class="w-[200px] p-4 flex flex-col gap-4">
|
||||||
|
<!-- order by field -->
|
||||||
|
<Select v-model="orderByField" @update:model-value="fetchActivityLogs">
|
||||||
|
<SelectTrigger class="h-8 w-full">
|
||||||
|
<SelectValue :placeholder="orderByField" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem :value="'activity_logs.created_at'">
|
||||||
|
{{ t('form.field.createdAt') }}
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
<!-- order by direction -->
|
||||||
|
<Select v-model="orderByDirection" @update:model-value="fetchActivityLogs">
|
||||||
|
<SelectTrigger class="h-8 w-full">
|
||||||
|
<SelectValue :placeholder="orderByDirection" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem :value="'asc'">Ascending</SelectItem>
|
||||||
|
<SelectItem :value="'desc'">Descending</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="loading" class="w-full">
|
||||||
|
<div class="flex border-b border-border p-4 font-medium bg-gray-50">
|
||||||
|
<div class="flex-1 text-muted-foreground">{{ t('form.field.name') }}</div>
|
||||||
|
<div class="w-[200px] text-muted-foreground">{{ t('form.field.date') }}</div>
|
||||||
|
<div class="w-[150px] text-muted-foreground">{{ t('globals.terms.ipAddress') }}</div>
|
||||||
|
</div>
|
||||||
|
<div v-for="i in perPage" :key="i" class="flex border-b border-border py-3 px-4">
|
||||||
|
<div class="flex-1">
|
||||||
|
<Skeleton class="h-4 w-[90%]" />
|
||||||
|
</div>
|
||||||
|
<div class="w-[200px]">
|
||||||
|
<Skeleton class="h-4 w-[120px]" />
|
||||||
|
</div>
|
||||||
|
<div class="w-[150px]">
|
||||||
|
<Skeleton class="h-4 w-[100px]" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<div class="w-full overflow-x-auto">
|
||||||
|
<SimpleTable
|
||||||
|
:headers="[t('form.field.name'), t('form.field.timestamp'), t('globals.terms.ipAddress')]"
|
||||||
|
:keys="['activity_description', 'created_at', 'ip']"
|
||||||
|
:data="activityLogs"
|
||||||
|
:showDelete="false"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- TODO: deduplicate this code, copied from contacts list -->
|
||||||
|
<div class="sticky bottom-0 bg-background p-4 mt-auto">
|
||||||
|
<div class="flex flex-col sm:flex-row items-center justify-between gap-4">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span class="text-sm text-muted-foreground">
|
||||||
|
{{ t('globals.terms.page') }} {{ page }} of {{ totalPages }}
|
||||||
|
</span>
|
||||||
|
<Select v-model="perPage" @update:model-value="handlePerPageChange">
|
||||||
|
<SelectTrigger class="h-8 w-[70px]">
|
||||||
|
<SelectValue :placeholder="perPage" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem :value="15">15</SelectItem>
|
||||||
|
<SelectItem :value="30">30</SelectItem>
|
||||||
|
<SelectItem :value="50">50</SelectItem>
|
||||||
|
<SelectItem :value="100">100</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Pagination>
|
||||||
|
<PaginationList class="flex items-center gap-1">
|
||||||
|
<PaginationListItem>
|
||||||
|
<PaginationFirst
|
||||||
|
:class="{ 'cursor-not-allowed opacity-50': page === 1 }"
|
||||||
|
@click.prevent="page > 1 ? goToPage(1) : null"
|
||||||
|
/>
|
||||||
|
</PaginationListItem>
|
||||||
|
<PaginationListItem>
|
||||||
|
<PaginationPrev
|
||||||
|
:class="{ 'cursor-not-allowed opacity-50': page === 1 }"
|
||||||
|
@click.prevent="page > 1 ? goToPage(page - 1) : null"
|
||||||
|
/>
|
||||||
|
</PaginationListItem>
|
||||||
|
<template v-for="pageNumber in visiblePages" :key="pageNumber">
|
||||||
|
<PaginationListItem v-if="pageNumber === '...'">
|
||||||
|
<PaginationEllipsis />
|
||||||
|
</PaginationListItem>
|
||||||
|
<PaginationListItem v-else>
|
||||||
|
<Button
|
||||||
|
:is-active="pageNumber === page"
|
||||||
|
@click.prevent="goToPage(pageNumber)"
|
||||||
|
:variant="pageNumber === page ? 'default' : 'outline'"
|
||||||
|
>
|
||||||
|
{{ pageNumber }}
|
||||||
|
</Button>
|
||||||
|
</PaginationListItem>
|
||||||
|
</template>
|
||||||
|
<PaginationListItem>
|
||||||
|
<PaginationNext
|
||||||
|
:class="{ 'cursor-not-allowed opacity-50': page === totalPages }"
|
||||||
|
@click.prevent="page < totalPages ? goToPage(page + 1) : null"
|
||||||
|
/>
|
||||||
|
</PaginationListItem>
|
||||||
|
<PaginationListItem>
|
||||||
|
<PaginationLast
|
||||||
|
:class="{ 'cursor-not-allowed opacity-50': page === totalPages }"
|
||||||
|
@click.prevent="page < totalPages ? goToPage(totalPages) : null"
|
||||||
|
/>
|
||||||
|
</PaginationListItem>
|
||||||
|
</PaginationList>
|
||||||
|
</Pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, computed, onMounted, watch } from 'vue'
|
||||||
|
import { Skeleton } from '@/components/ui/skeleton'
|
||||||
|
import SimpleTable from '@/components/table/SimpleTable.vue'
|
||||||
|
import {
|
||||||
|
Pagination,
|
||||||
|
PaginationEllipsis,
|
||||||
|
PaginationFirst,
|
||||||
|
PaginationLast,
|
||||||
|
PaginationList,
|
||||||
|
PaginationListItem,
|
||||||
|
PaginationNext,
|
||||||
|
PaginationPrev
|
||||||
|
} from '@/components/ui/pagination'
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
import FilterBuilder from '@/components/filter/FilterBuilder.vue'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { ListFilter, ArrowDownWideNarrow } from 'lucide-vue-next'
|
||||||
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||||
|
import { useActivityLogFilters } from '@/composables/useActivityLogFilters'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { format } from 'date-fns'
|
||||||
|
import { getVisiblePages } from '@/utils/pagination'
|
||||||
|
import api from '@/api'
|
||||||
|
|
||||||
|
const activityLogs = ref([])
|
||||||
|
const { t } = useI18n()
|
||||||
|
const loading = ref(true)
|
||||||
|
const page = ref(1)
|
||||||
|
const perPage = ref(15)
|
||||||
|
const orderByField = ref('activity_logs.created_at')
|
||||||
|
const orderByDirection = ref('desc')
|
||||||
|
const totalCount = ref(0)
|
||||||
|
const totalPages = ref(0)
|
||||||
|
const filters = ref([])
|
||||||
|
const filtersOpen = ref(false)
|
||||||
|
const { activityLogListFilters } = useActivityLogFilters()
|
||||||
|
|
||||||
|
const filterFields = computed(() =>
|
||||||
|
Object.entries(activityLogListFilters.value).map(([field, value]) => ({
|
||||||
|
model: 'activity_logs',
|
||||||
|
label: value.label,
|
||||||
|
field,
|
||||||
|
type: value.type,
|
||||||
|
operators: value.operators,
|
||||||
|
options: value.options ?? []
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
|
||||||
|
const visiblePages = computed(() => getVisiblePages(page.value, totalPages.value))
|
||||||
|
|
||||||
|
async function fetchActivityLogs() {
|
||||||
|
filtersOpen.value = false
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const resp = await api.getActivityLogs({
|
||||||
|
page: page.value,
|
||||||
|
page_size: perPage.value,
|
||||||
|
filters: JSON.stringify(filters.value),
|
||||||
|
order: orderByDirection.value,
|
||||||
|
order_by: orderByField.value
|
||||||
|
})
|
||||||
|
activityLogs.value = resp.data.data.results
|
||||||
|
totalCount.value = resp.data.data.count
|
||||||
|
totalPages.value = resp.data.data.total_pages
|
||||||
|
|
||||||
|
// Format the created_at field
|
||||||
|
activityLogs.value = activityLogs.value.map((log) => ({
|
||||||
|
...log,
|
||||||
|
created_at: format(new Date(log.created_at), 'PPpp')
|
||||||
|
}))
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching activity logs:', err)
|
||||||
|
activityLogs.value = []
|
||||||
|
totalCount.value = 0
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function goToPage(p) {
|
||||||
|
if (p >= 1 && p <= totalPages.value && p !== page.value) {
|
||||||
|
page.value = p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handlePerPageChange() {
|
||||||
|
page.value = 1
|
||||||
|
fetchActivityLogs()
|
||||||
|
}
|
||||||
|
|
||||||
|
watch([page, perPage, orderByField, orderByDirection], fetchActivityLogs)
|
||||||
|
|
||||||
|
onMounted(fetchActivityLogs)
|
||||||
|
</script>
|
||||||
306
frontend/src/features/admin/agents/AgentForm.vue
Normal file
306
frontend/src/features/admin/agents/AgentForm.vue
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
<template>
|
||||||
|
<form @submit.prevent="onSubmit" class="space-y-8">
|
||||||
|
<!-- Summary Section -->
|
||||||
|
<div class="bg-muted/30 box py-6 px-3" v-if="!isNewForm">
|
||||||
|
<div class="flex items-start gap-6">
|
||||||
|
<Avatar class="w-20 h-20">
|
||||||
|
<AvatarImage :src="props.initialValues.avatar_url || ''" :alt="Avatar" />
|
||||||
|
<AvatarFallback>
|
||||||
|
{{ getInitials(props.initialValues.first_name, props.initialValues.last_name) }}
|
||||||
|
</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
|
||||||
|
<div class="space-y-4 flex-2">
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<h3 class="text-lg font-semibold text-gray-900">
|
||||||
|
{{ props.initialValues.first_name }} {{ props.initialValues.last_name }}
|
||||||
|
</h3>
|
||||||
|
<Badge :class="['px-2 rounded-full text-xs font-medium', availabilityStatus.color]">
|
||||||
|
{{ availabilityStatus.text }}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap items-center gap-6">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<Clock class="w-5 h-5 text-gray-400" />
|
||||||
|
<div>
|
||||||
|
<p class="text-sm text-gray-500">{{ $t('form.field.lastActive') }}</p>
|
||||||
|
<p class="text-sm font-medium text-gray-700">
|
||||||
|
{{
|
||||||
|
props.initialValues.last_active_at
|
||||||
|
? format(new Date(props.initialValues.last_active_at), 'PPpp')
|
||||||
|
: 'N/A'
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<LogIn class="w-5 h-5 text-gray-400" />
|
||||||
|
<div>
|
||||||
|
<p class="text-sm text-gray-500">{{ $t('form.field.lastLogin') }}</p>
|
||||||
|
<p class="text-sm font-medium text-gray-700">
|
||||||
|
{{
|
||||||
|
props.initialValues.last_login_at
|
||||||
|
? format(new Date(props.initialValues.last_login_at), 'PPpp')
|
||||||
|
: 'N/A'
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Form Fields -->
|
||||||
|
<FormField v-slot="{ field }" name="first_name">
|
||||||
|
<FormItem v-auto-animate>
|
||||||
|
<FormLabel>{{ $t('form.field.firstName') }}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input type="text" placeholder="" v-bind="field" />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField v-slot="{ field }" name="last_name">
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>{{ $t('form.field.lastName') }}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input type="text" placeholder="" v-bind="field" />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField v-slot="{ field }" name="email">
|
||||||
|
<FormItem v-auto-animate>
|
||||||
|
<FormLabel>{{ $t('form.field.email') }}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input type="email" placeholder="" v-bind="field" />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField v-slot="{ componentField, handleChange }" name="teams">
|
||||||
|
<FormItem v-auto-animate>
|
||||||
|
<FormLabel>{{ $t('form.field.teams') }}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTag
|
||||||
|
:items="teamOptions"
|
||||||
|
:placeholder="t('form.field.selectTeams')"
|
||||||
|
v-model="componentField.modelValue"
|
||||||
|
@update:modelValue="handleChange"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField v-slot="{ componentField, handleChange }" name="roles">
|
||||||
|
<FormItem v-auto-animate>
|
||||||
|
<FormLabel>{{ $t('form.field.roles') }}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTag
|
||||||
|
:items="roleOptions"
|
||||||
|
:placeholder="t('form.field.selectRoles')"
|
||||||
|
v-model="componentField.modelValue"
|
||||||
|
@update:modelValue="handleChange"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField v-slot="{ componentField }" name="availability_status" v-if="!isNewForm">
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>{{ t('form.field.availabilityStatus') }}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Select v-bind="componentField" v-model="componentField.modelValue">
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue
|
||||||
|
:placeholder="
|
||||||
|
t('form.field.select', {
|
||||||
|
name: t('form.field.availabilityStatus')
|
||||||
|
})
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem value="active_group">{{ t('globals.terms.active') }}</SelectItem>
|
||||||
|
<SelectItem value="away_manual">{{ t('globals.terms.away') }}</SelectItem>
|
||||||
|
<SelectItem value="away_and_reassigning">
|
||||||
|
{{ t('form.field.awayReassigning') }}
|
||||||
|
</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField v-slot="{ field }" name="new_password" v-if="!isNewForm">
|
||||||
|
<FormItem v-auto-animate>
|
||||||
|
<FormLabel>{{ t('form.field.setPassword') }}</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input type="password" placeholder="" v-bind="field" />
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField name="send_welcome_email" v-slot="{ value, handleChange }" v-if="isNewForm">
|
||||||
|
<FormItem>
|
||||||
|
<FormControl>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<Checkbox :checked="value" @update:checked="handleChange" />
|
||||||
|
<Label>{{ $t('form.field.sendWelcomeEmail') }}</Label>
|
||||||
|
</div>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<FormField v-slot="{ value, handleChange }" type="checkbox" name="enabled" v-if="!isNewForm">
|
||||||
|
<FormItem class="flex flex-row items-start gap-x-3 space-y-0">
|
||||||
|
<FormControl>
|
||||||
|
<Checkbox :checked="value" @update:checked="handleChange" />
|
||||||
|
</FormControl>
|
||||||
|
<div class="space-y-1 leading-none">
|
||||||
|
<FormLabel> {{ $t('form.field.enabled') }} </FormLabel>
|
||||||
|
<FormMessage />
|
||||||
|
</div>
|
||||||
|
</FormItem>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
|
<Button type="submit" :isLoading="isLoading"> {{ submitLabel }} </Button>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { watch, onMounted, ref, computed } from 'vue'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { useForm } from 'vee-validate'
|
||||||
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
|
import { createFormSchema } from './formSchema.js'
|
||||||
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
|
import { Label } from '@/components/ui/label'
|
||||||
|
import { vAutoAnimate } from '@formkit/auto-animate/vue'
|
||||||
|
import { Badge } from '@/components/ui/badge'
|
||||||
|
import { Clock, LogIn } from 'lucide-vue-next'
|
||||||
|
import { FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form'
|
||||||
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectGroup,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue
|
||||||
|
} from '@/components/ui/select'
|
||||||
|
import { SelectTag } from '@/components/ui/select'
|
||||||
|
import { Input } from '@/components/ui/input'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { format } from 'date-fns'
|
||||||
|
import api from '@/api'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
initialValues: {
|
||||||
|
type: Object,
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
submitForm: {
|
||||||
|
type: Function,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
submitLabel: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: 'Submit'
|
||||||
|
},
|
||||||
|
isNewForm: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
isLoading: {
|
||||||
|
Type: Boolean,
|
||||||
|
required: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const { t } = useI18n()
|
||||||
|
const teams = ref([])
|
||||||
|
const roles = ref([])
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
const [teamsResp, rolesResp] = await Promise.allSettled([api.getTeams(), api.getRoles()])
|
||||||
|
teams.value = teamsResp.value.data.data
|
||||||
|
roles.value = rolesResp.value.data.data
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const availabilityStatus = computed(() => {
|
||||||
|
const status = form.values.availability_status
|
||||||
|
if (status === 'active_group') return { text: t('globals.terms.active'), color: 'bg-green-500' }
|
||||||
|
if (status === 'away_manual') return { text: t('globals.terms.away'), color: 'bg-yellow-500' }
|
||||||
|
if (status === 'away_and_reassigning')
|
||||||
|
return { text: t('form.field.awayReassigning'), color: 'bg-orange-500' }
|
||||||
|
return { text: t('globals.terms.offline'), color: 'bg-gray-400' }
|
||||||
|
})
|
||||||
|
|
||||||
|
const teamOptions = computed(() =>
|
||||||
|
teams.value.map((team) => ({ label: team.name, value: team.name }))
|
||||||
|
)
|
||||||
|
const roleOptions = computed(() =>
|
||||||
|
roles.value.map((role) => ({ label: role.name, value: role.name }))
|
||||||
|
)
|
||||||
|
|
||||||
|
const form = useForm({
|
||||||
|
validationSchema: toTypedSchema(createFormSchema(t))
|
||||||
|
})
|
||||||
|
|
||||||
|
const onSubmit = form.handleSubmit((values) => {
|
||||||
|
if (values.availability_status === 'active_group') {
|
||||||
|
values.availability_status = 'online'
|
||||||
|
}
|
||||||
|
values.teams = values.teams.map((team) => ({ name: team }))
|
||||||
|
props.submitForm(values)
|
||||||
|
})
|
||||||
|
|
||||||
|
const getInitials = (firstName, lastName) => {
|
||||||
|
if (!firstName && !lastName) return ''
|
||||||
|
if (!firstName) return lastName.charAt(0).toUpperCase()
|
||||||
|
if (!lastName) return firstName.charAt(0).toUpperCase()
|
||||||
|
return `${firstName.charAt(0).toUpperCase()}${lastName.charAt(0).toUpperCase()}`
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.initialValues,
|
||||||
|
(newValues) => {
|
||||||
|
// Hack.
|
||||||
|
if (Object.keys(newValues).length > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (
|
||||||
|
newValues.availability_status === 'away' ||
|
||||||
|
newValues.availability_status === 'offline' ||
|
||||||
|
newValues.availability_status === 'online'
|
||||||
|
) {
|
||||||
|
newValues.availability_status = 'active_group'
|
||||||
|
}
|
||||||
|
form.setValues(newValues)
|
||||||
|
form.setFieldValue(
|
||||||
|
'teams',
|
||||||
|
newValues.teams.map((team) => team.name)
|
||||||
|
)
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true }
|
||||||
|
)
|
||||||
|
</script>
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
import { h } from 'vue'
|
import { h } from 'vue'
|
||||||
import UserDataTableDropDown from '@/features/admin/users/dataTableDropdown.vue'
|
import UserDataTableDropDown from '@/features/admin/agents/dataTableDropdown.vue'
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
|
|
||||||
export const columns = [
|
export const createColumns = (t) => [
|
||||||
{
|
{
|
||||||
accessorKey: 'first_name',
|
accessorKey: 'first_name',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'First name')
|
return h('div', { class: 'text-center' }, t('form.field.firstName'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h('div', { class: 'text-center font-medium' }, row.getValue('first_name'))
|
return h('div', { class: 'text-center font-medium' }, row.getValue('first_name'))
|
||||||
@@ -15,7 +15,7 @@ export const columns = [
|
|||||||
{
|
{
|
||||||
accessorKey: 'last_name',
|
accessorKey: 'last_name',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Last name')
|
return h('div', { class: 'text-center' }, t('form.field.lastName'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h('div', { class: 'text-center font-medium' }, row.getValue('last_name'))
|
return h('div', { class: 'text-center font-medium' }, row.getValue('last_name'))
|
||||||
@@ -24,16 +24,16 @@ export const columns = [
|
|||||||
{
|
{
|
||||||
accessorKey: 'enabled',
|
accessorKey: 'enabled',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Enabled')
|
return h('div', { class: 'text-center' }, t('form.field.enabled'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h('div', { class: 'text-center font-medium' }, row.getValue('enabled') ? 'Yes' : 'No')
|
return h('div', { class: 'text-center font-medium' }, row.getValue('enabled') ? t('globals.messages.yes') : t('globals.messages.no'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'email',
|
accessorKey: 'email',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Email')
|
return h('div', { class: 'text-center' }, t('form.field.email'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h('div', { class: 'text-center font-medium' }, row.getValue('email'))
|
return h('div', { class: 'text-center font-medium' }, row.getValue('email'))
|
||||||
@@ -42,7 +42,7 @@ export const columns = [
|
|||||||
{
|
{
|
||||||
accessorKey: 'created_at',
|
accessorKey: 'created_at',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Created at')
|
return h('div', { class: 'text-center' }, t('form.field.createdAt'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h(
|
return h(
|
||||||
@@ -55,7 +55,7 @@ export const columns = [
|
|||||||
{
|
{
|
||||||
accessorKey: 'updated_at',
|
accessorKey: 'updated_at',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Updated at')
|
return h('div', { class: 'text-center' }, t('form.field.updatedAt'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h(
|
return h(
|
||||||
@@ -2,27 +2,31 @@
|
|||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger as-child>
|
<DropdownMenuTrigger as-child>
|
||||||
<Button variant="ghost" class="w-8 h-8 p-0">
|
<Button variant="ghost" class="w-8 h-8 p-0">
|
||||||
<span class="sr-only">Open menu</span>
|
<span class="sr-only"></span>
|
||||||
<MoreHorizontal class="w-4 h-4" />
|
<MoreHorizontal class="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem @click="editUser(props.user.id)">Edit</DropdownMenuItem>
|
<DropdownMenuItem @click="editUser(props.user.id)">{{
|
||||||
<DropdownMenuItem @click="() => (alertOpen = true)">Delete</DropdownMenuItem>
|
$t('globals.buttons.edit')
|
||||||
|
}}</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem @click="() => (alertOpen = true)">{{
|
||||||
|
$t('globals.buttons.delete')
|
||||||
|
}}</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
||||||
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
|
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>Delete User</AlertDialogTitle>
|
<AlertDialogTitle>{{ $t('globals.messages.areYouAbsolutelySure') }}</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>{{ $t('admin.user.deleteConfirmation') }}</AlertDialogDescription>
|
||||||
This action cannot be undone. This will permanently delete the user.
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
<AlertDialogCancel>{{ $t('globals.buttons.cancel') }}</AlertDialogCancel>
|
||||||
<AlertDialogAction @click="handleDelete">Delete</AlertDialogAction>
|
<AlertDialogAction @click="handleDelete">{{
|
||||||
|
$t('globals.buttons.delete')
|
||||||
|
}}</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
@@ -69,7 +73,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
function editUser(id) {
|
function editUser(id) {
|
||||||
router.push({ path: `/admin/teams/users/${id}/edit` })
|
router.push({ path: `/admin/teams/agents/${id}/edit` })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete() {
|
async function handleDelete() {
|
||||||
@@ -79,7 +83,6 @@ async function handleDelete() {
|
|||||||
emitRefreshUserList()
|
emitRefreshUserList()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
emit.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
emit.emit(EMITTER_EVENTS.SHOW_TOAST, {
|
||||||
title: 'Error',
|
|
||||||
variant: 'destructive',
|
variant: 'destructive',
|
||||||
description: handleHTTPError(error).message
|
description: handleHTTPError(error).message
|
||||||
})
|
})
|
||||||
@@ -88,7 +91,7 @@ async function handleDelete() {
|
|||||||
|
|
||||||
const emitRefreshUserList = () => {
|
const emitRefreshUserList = () => {
|
||||||
emit.emit(EMITTER_EVENTS.REFRESH_LIST, {
|
emit.emit(EMITTER_EVENTS.REFRESH_LIST, {
|
||||||
model: 'user'
|
model: 'agent'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
50
frontend/src/features/admin/agents/formSchema.js
Normal file
50
frontend/src/features/admin/agents/formSchema.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import * as z from 'zod'
|
||||||
|
|
||||||
|
export const createFormSchema = (t) => z.object({
|
||||||
|
first_name: z
|
||||||
|
.string({
|
||||||
|
required_error: t('globals.messages.required'),
|
||||||
|
})
|
||||||
|
.min(2, {
|
||||||
|
message: t('form.error.minmax', {
|
||||||
|
min: 2,
|
||||||
|
max: 50,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.max(50, {
|
||||||
|
message: t('form.error.minmax', {
|
||||||
|
min: 2,
|
||||||
|
max: 50,
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|
||||||
|
last_name: z.string().optional(),
|
||||||
|
|
||||||
|
email: z
|
||||||
|
.string({
|
||||||
|
required_error: t('globals.messages.required'),
|
||||||
|
})
|
||||||
|
.email({
|
||||||
|
message: t('globals.messages.invalidEmailAddress'),
|
||||||
|
}),
|
||||||
|
|
||||||
|
send_welcome_email: z.boolean().optional(),
|
||||||
|
|
||||||
|
teams: z.array(z.string()).default([]),
|
||||||
|
|
||||||
|
roles: z.array(z.string()).min(1, t('globals.messages.pleaseSelectAtLeastOne', {
|
||||||
|
name: t('globals.terms.role')
|
||||||
|
})),
|
||||||
|
|
||||||
|
new_password: z
|
||||||
|
.string()
|
||||||
|
.regex(/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[\W_]).{10,72}$/, {
|
||||||
|
message: t('globals.messages.strongPassword', {
|
||||||
|
min: 10,
|
||||||
|
max: 72,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
enabled: z.boolean().optional().default(true),
|
||||||
|
availability_status: z.string().optional().default('offline'),
|
||||||
|
})
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
@update:modelValue="(value) => handleFieldChange(value, index)"
|
@update:modelValue="(value) => handleFieldChange(value, index)"
|
||||||
>
|
>
|
||||||
<SelectTrigger class="m-auto">
|
<SelectTrigger class="m-auto">
|
||||||
<SelectValue placeholder="Select action" />
|
<SelectValue :placeholder="t('form.field.selectAction')" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
@@ -39,8 +39,8 @@
|
|||||||
>
|
>
|
||||||
<SelectTag
|
<SelectTag
|
||||||
v-model="action.value"
|
v-model="action.value"
|
||||||
:items="tagsStore.tagNames"
|
:items="tagsStore.tagNames.map((tag) => ({ label: tag, value: tag }))"
|
||||||
placeholder="Select tag"
|
:placeholder="t('form.field.selectTag')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -51,13 +51,13 @@
|
|||||||
<ComboBox
|
<ComboBox
|
||||||
v-model="action.value[0]"
|
v-model="action.value[0]"
|
||||||
:items="conversationActions[action.type]?.options"
|
:items="conversationActions[action.type]?.options"
|
||||||
placeholder="Select"
|
:placeholder="t('form.field.select')"
|
||||||
@select="handleValueChange($event, index)"
|
@select="handleValueChange($event, index)"
|
||||||
>
|
>
|
||||||
<template #item="{ item }">
|
<template #item="{ item }">
|
||||||
<div class="flex items-center gap-2 ml-2">
|
<div class="flex items-center gap-2 ml-2">
|
||||||
<Avatar v-if="action.type === 'assign_user'" class="w-7 h-7">
|
<Avatar v-if="action.type === 'assign_user'" class="w-7 h-7">
|
||||||
<AvatarImage :src="item.avatar_url ?? ''" :alt="item.label.slice(0, 2)" />
|
<AvatarImage :src="item.avatar_url || ''" :alt="item.label.slice(0, 2)" />
|
||||||
<AvatarFallback>
|
<AvatarFallback>
|
||||||
{{ item.label.slice(0, 2).toUpperCase() }}
|
{{ item.label.slice(0, 2).toUpperCase() }}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
{{ selected.emoji }}
|
{{ selected.emoji }}
|
||||||
<span>{{ selected.label }}</span>
|
<span>{{ selected.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>Select team</span>
|
<span v-else>{{ $t('form.field.selectTeam') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="action.type === 'assign_user'" class="flex items-center gap-2">
|
<div v-else-if="action.type === 'assign_user'" class="flex items-center gap-2">
|
||||||
@@ -91,10 +91,10 @@
|
|||||||
</Avatar>
|
</Avatar>
|
||||||
<span>{{ selected.label }}</span>
|
<span>{{ selected.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>Select user</span>
|
<span v-else>{{ $t('form.field.selectUser') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
<span v-if="!selected"> Select</span>
|
<span v-if="!selected"> {{ $t('form.field.select') }}</span>
|
||||||
<span v-else>{{ selected.label }} </span>
|
<span v-else>{{ selected.label }} </span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -114,14 +114,18 @@
|
|||||||
<Editor
|
<Editor
|
||||||
v-model:htmlContent="action.value[0]"
|
v-model:htmlContent="action.value[0]"
|
||||||
@update:htmlContent="(value) => handleEditorChange(value, index)"
|
@update:htmlContent="(value) => handleEditorChange(value, index)"
|
||||||
:placeholder="'Shift + Enter to add new line'"
|
:placeholder="t('editor.placeholder')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button variant="outline" @click.prevent="addAction">Add action</Button>
|
<Button variant="outline" @click.prevent="addAction">{{
|
||||||
|
$t('globals.messages.add', {
|
||||||
|
name: $t('globals.terms.action')
|
||||||
|
})
|
||||||
|
}}</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -144,6 +148,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
|||||||
import { SelectTag } from '@/components/ui/select'
|
import { SelectTag } from '@/components/ui/select'
|
||||||
import { useConversationFilters } from '@/composables/useConversationFilters'
|
import { useConversationFilters } from '@/composables/useConversationFilters'
|
||||||
import { getTextFromHTML } from '@/utils/strings.js'
|
import { getTextFromHTML } from '@/utils/strings.js'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import Editor from '@/features/conversation/ConversationTextEditor.vue'
|
import Editor from '@/features/conversation/ConversationTextEditor.vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -154,6 +159,7 @@ const props = defineProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const { actions } = toRefs(props)
|
const { actions } = toRefs(props)
|
||||||
|
const { t } = useI18n()
|
||||||
const emit = defineEmits(['update-actions', 'add-action', 'remove-action'])
|
const emit = defineEmits(['update-actions', 'add-action', 'remove-action'])
|
||||||
const tagsStore = useTagStore()
|
const tagsStore = useTagStore()
|
||||||
const { conversationActions } = useConversationFilters()
|
const { conversationActions } = useConversationFilters()
|
||||||
|
|||||||
@@ -1,26 +1,44 @@
|
|||||||
<template>
|
<template>
|
||||||
<Tabs default-value="new_conversation" v-model="selectedTab">
|
<Tabs default-value="new_conversation" v-model="selectedTab">
|
||||||
<TabsList class="grid w-full grid-cols-3 mb-5">
|
<TabsList class="grid w-full grid-cols-3 mb-5">
|
||||||
<TabsTrigger value="new_conversation">New conversation</TabsTrigger>
|
<TabsTrigger value="new_conversation">
|
||||||
<TabsTrigger value="conversation_update">Conversation update</TabsTrigger>
|
{{
|
||||||
<TabsTrigger value="time_trigger">Time triggers</TabsTrigger>
|
$t('globals.messages.new', {
|
||||||
|
name: $t('globals.terms.conversation')
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="conversation_update">
|
||||||
|
{{ $t('admin.automation.conversationUpdate') }}
|
||||||
|
</TabsTrigger>
|
||||||
|
<TabsTrigger value="time_trigger">
|
||||||
|
{{ $t('admin.automation.timeTriggers') }}
|
||||||
|
</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
<TabsContent value="new_conversation">
|
<TabsContent value="new_conversation">
|
||||||
<RuleTab type="new_conversation" helptext="Rules that run when a new conversation is created, drag and drop to reorder rules." />
|
<RuleTab
|
||||||
|
type="new_conversation"
|
||||||
|
:helptext="t('admin.automation.newConversation.description')"
|
||||||
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="conversation_update">
|
<TabsContent value="conversation_update">
|
||||||
<RuleTab type="conversation_update" helptext="Rules that run when a conversation is updated." />
|
<RuleTab
|
||||||
|
type="conversation_update"
|
||||||
|
:helptext="t('admin.automation.conversationUpdate.description')"
|
||||||
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="time_trigger">
|
<TabsContent value="time_trigger">
|
||||||
<RuleTab type="time_trigger" helptext="Rules that run once an hour." />
|
<RuleTab type="time_trigger" :helptext="t('admin.automation.timeTriggers.description')" />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import RuleTab from './RuleTab.vue'
|
import RuleTab from './RuleTab.vue'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
const selectedTab = defineModel('automationsTab', {
|
const selectedTab = defineModel('automationsTab', {
|
||||||
default: 'new_conversation',
|
default: 'new_conversation',
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -8,11 +8,17 @@
|
|||||||
>
|
>
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<RadioGroupItem value="OR" />
|
<RadioGroupItem value="OR" />
|
||||||
<Label>Match <b>ANY</b> of below.</Label>
|
<Label
|
||||||
|
>{{ $t('admin.automation.match') }} <b>{{ $t('admin.automation.any') }}</b>
|
||||||
|
{{ $t('admin.automation.below') }}.</Label
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center space-x-2">
|
<div class="flex items-center space-x-2">
|
||||||
<RadioGroupItem value="AND" />
|
<RadioGroupItem value="AND" />
|
||||||
<Label>Match <b>ALL</b> of below.</Label>
|
<Label
|
||||||
|
>{{ $t('admin.automation.match') }} <b>{{ $t('admin.automation.all') }}</b>
|
||||||
|
{{ $t('admin.automation.below') }}.</Label
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,14 +37,24 @@
|
|||||||
@update:modelValue="(value) => handleFieldChange(value, index)"
|
@update:modelValue="(value) => handleFieldChange(value, index)"
|
||||||
>
|
>
|
||||||
<SelectTrigger class="w-56">
|
<SelectTrigger class="w-56">
|
||||||
<SelectValue placeholder="Select field" />
|
<SelectValue :placeholder="t('form.field.selectField')" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
<SelectLabel>Conversation</SelectLabel>
|
<!-- Conversation fields -->
|
||||||
|
<SelectLabel>{{ $t('globals.terms.conversation') }}</SelectLabel>
|
||||||
<SelectItem v-for="(field, key) in currentFilters" :key="key" :value="key">
|
<SelectItem v-for="(field, key) in currentFilters" :key="key" :value="key">
|
||||||
{{ field.label }}
|
{{ field.label }}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
|
<!-- Contact custom attributes -->
|
||||||
|
<SelectLabel>{{ $t('globals.terms.contact') }}</SelectLabel>
|
||||||
|
<SelectItem
|
||||||
|
v-for="(field, key) in contactCustomAttributes"
|
||||||
|
:key="key"
|
||||||
|
:value="key"
|
||||||
|
>
|
||||||
|
{{ field.label }}
|
||||||
|
</SelectItem>
|
||||||
</SelectGroup>
|
</SelectGroup>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
@@ -49,12 +65,12 @@
|
|||||||
@update:modelValue="(value) => handleOperatorChange(value, index)"
|
@update:modelValue="(value) => handleOperatorChange(value, index)"
|
||||||
>
|
>
|
||||||
<SelectTrigger class="w-56">
|
<SelectTrigger class="w-56">
|
||||||
<SelectValue placeholder="Select operator" />
|
<SelectValue :placeholder="t('form.field.selectOperator')" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
<SelectItem
|
<SelectItem
|
||||||
v-for="(op, key) in getFieldOperators(rule.field)"
|
v-for="(op, key) in getFieldOperators(rule.field, rule.field_type)"
|
||||||
:key="key"
|
:key="key"
|
||||||
:value="op"
|
:value="op"
|
||||||
>
|
>
|
||||||
@@ -69,7 +85,7 @@
|
|||||||
<!-- Plain text input -->
|
<!-- Plain text input -->
|
||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Set value"
|
:placeholder="t('form.field.setValue')"
|
||||||
v-if="inputType(index) === 'text'"
|
v-if="inputType(index) === 'text'"
|
||||||
v-model="rule.value"
|
v-model="rule.value"
|
||||||
@update:modelValue="(value) => handleValueChange(value, index)"
|
@update:modelValue="(value) => handleValueChange(value, index)"
|
||||||
@@ -78,7 +94,7 @@
|
|||||||
<!-- Number input -->
|
<!-- Number input -->
|
||||||
<Input
|
<Input
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="Set value"
|
:placeholder="t('form.field.setValue')"
|
||||||
v-if="inputType(index) === 'number'"
|
v-if="inputType(index) === 'number'"
|
||||||
v-model="rule.value"
|
v-model="rule.value"
|
||||||
@update:modelValue="(value) => handleValueChange(value, index)"
|
@update:modelValue="(value) => handleValueChange(value, index)"
|
||||||
@@ -88,13 +104,13 @@
|
|||||||
<div v-if="inputType(index) === 'select'">
|
<div v-if="inputType(index) === 'select'">
|
||||||
<ComboBox
|
<ComboBox
|
||||||
v-model="rule.value"
|
v-model="rule.value"
|
||||||
:items="getFieldOptions(rule.field)"
|
:items="getFieldOptions(rule.field, rule.field_type)"
|
||||||
@select="handleValueChange($event, index)"
|
@select="handleValueChange($event, index)"
|
||||||
>
|
>
|
||||||
<template #item="{ item }">
|
<template #item="{ item }">
|
||||||
<div class="flex items-center gap-2 ml-2">
|
<div class="flex items-center gap-2 ml-2">
|
||||||
<Avatar v-if="rule.field === 'assigned_user'" class="w-7 h-7">
|
<Avatar v-if="rule.field === 'assigned_user'" class="w-7 h-7">
|
||||||
<AvatarImage :src="item.avatar_url ?? ''" :alt="item.label.slice(0, 2)" />
|
<AvatarImage :src="item.avatar_url || ''" :alt="item.label.slice(0, 2)" />
|
||||||
<AvatarFallback>
|
<AvatarFallback>
|
||||||
{{ item.label.slice(0, 2).toUpperCase() }}
|
{{ item.label.slice(0, 2).toUpperCase() }}
|
||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
@@ -112,7 +128,7 @@
|
|||||||
{{ selected.emoji }}
|
{{ selected.emoji }}
|
||||||
<span>{{ selected.label }}</span>
|
<span>{{ selected.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>Select team</span>
|
<span v-else>{{ $t('form.field.selectTeam') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -122,7 +138,7 @@
|
|||||||
<div v-if="selected" class="flex items-center gap-2">
|
<div v-if="selected" class="flex items-center gap-2">
|
||||||
<Avatar class="w-7 h-7">
|
<Avatar class="w-7 h-7">
|
||||||
<AvatarImage
|
<AvatarImage
|
||||||
:src="selected.avatar_url ?? ''"
|
:src="selected.avatar_url || ''"
|
||||||
:alt="selected.label.slice(0, 2)"
|
:alt="selected.label.slice(0, 2)"
|
||||||
/>
|
/>
|
||||||
<AvatarFallback>
|
<AvatarFallback>
|
||||||
@@ -131,10 +147,10 @@
|
|||||||
</Avatar>
|
</Avatar>
|
||||||
<span>{{ selected.label }}</span>
|
<span>{{ selected.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>Select user</span>
|
<span v-else>{{ $t('form.field.selectUser') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<span v-else>
|
<span v-else>
|
||||||
<span v-if="!selected"> Select</span>
|
<span v-if="!selected"> {{ $t('form.field.select') }}</span>
|
||||||
<span v-else>{{ selected.label }} </span>
|
<span v-else>{{ selected.label }} </span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
@@ -155,12 +171,43 @@
|
|||||||
<TagsInputItemText />
|
<TagsInputItemText />
|
||||||
<TagsInputItemDelete />
|
<TagsInputItemDelete />
|
||||||
</TagsInputItem>
|
</TagsInputItem>
|
||||||
<TagsInputInput placeholder="Select values" />
|
<TagsInputInput :placeholder="t('form.field.selectValue')" />
|
||||||
</TagsInput>
|
</TagsInput>
|
||||||
<p class="text-xs text-gray-500 mt-1">Press enter to select a value</p>
|
<p class="text-xs text-gray-500 mt-1">
|
||||||
|
{{ $t('globals.messages.pressEnterToSelectAValue') }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Date input -->
|
||||||
|
<Input
|
||||||
|
type="date"
|
||||||
|
:placeholder="t('form.field.setValue')"
|
||||||
|
v-if="inputType(index) === 'date'"
|
||||||
|
v-model="rule.value"
|
||||||
|
@update:modelValue="(value) => handleValueChange(value, index)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- Boolean / Checkbox input -->
|
||||||
|
<Select
|
||||||
|
v-model="rule.value"
|
||||||
|
@update:modelValue="(value) => handleValueChange(value, index)"
|
||||||
|
v-if="inputType(index) === 'boolean'"
|
||||||
|
>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue :placeholder="t('form.field.selectValue')" />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectGroup>
|
||||||
|
<SelectItem value="true">True</SelectItem>
|
||||||
|
<SelectItem value="false">False</SelectItem>
|
||||||
|
</SelectGroup>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Placeholder for spacing -->
|
||||||
|
<div v-else class="flex-1"></div>
|
||||||
|
|
||||||
<!-- Remove condition -->
|
<!-- Remove condition -->
|
||||||
<div class="cursor-pointer mt-2" @click.prevent="removeCondition(index)">
|
<div class="cursor-pointer mt-2" @click.prevent="removeCondition(index)">
|
||||||
<X size="16" />
|
<X size="16" />
|
||||||
@@ -173,12 +220,18 @@
|
|||||||
:defaultChecked="rule.case_sensitive_match"
|
:defaultChecked="rule.case_sensitive_match"
|
||||||
@update:checked="(value) => handleCaseSensitiveCheck(value, index)"
|
@update:checked="(value) => handleCaseSensitiveCheck(value, index)"
|
||||||
/>
|
/>
|
||||||
<label> Case sensitive match </label>
|
<label> {{ $t('globals.messages.caseSensitiveMatch') }} </label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button variant="outline" size="sm" @click.prevent="addCondition">Add condition</Button>
|
<Button variant="outline" size="sm" @click.prevent="addCondition">
|
||||||
|
{{
|
||||||
|
$t('globals.messages.add', {
|
||||||
|
name: $t('globals.terms.condition')
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -210,6 +263,7 @@ import { Label } from '@/components/ui/label'
|
|||||||
import { Input } from '@/components/ui/input'
|
import { Input } from '@/components/ui/input'
|
||||||
import ComboBox from '@/components/ui/combobox/ComboBox.vue'
|
import ComboBox from '@/components/ui/combobox/ComboBox.vue'
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useConversationFilters } from '@/composables/useConversationFilters'
|
import { useConversationFilters } from '@/composables/useConversationFilters'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -227,9 +281,15 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { conversationFilters, newConversationFilters } = useConversationFilters()
|
const fieldTypeConstants = {
|
||||||
|
conversation: 'conversation',
|
||||||
|
contact_custom_attribute: 'contact_custom_attribute'
|
||||||
|
}
|
||||||
|
const { conversationFilters, newConversationFilters, contactCustomAttributes } =
|
||||||
|
useConversationFilters()
|
||||||
const { ruleGroup } = toRefs(props)
|
const { ruleGroup } = toRefs(props)
|
||||||
const emit = defineEmits(['update-group', 'add-condition', 'remove-condition'])
|
const emit = defineEmits(['update-group', 'add-condition', 'remove-condition'])
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
// Computed property to get the correct filters based on type
|
// Computed property to get the correct filters based on type
|
||||||
const currentFilters = computed(() => {
|
const currentFilters = computed(() => {
|
||||||
@@ -256,9 +316,16 @@ const handleGroupOperator = (value) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handleFieldChange = (value, ruleIndex) => {
|
const handleFieldChange = (value, ruleIndex) => {
|
||||||
|
// Set the field type based on the selected field value.
|
||||||
|
let fieldType = fieldTypeConstants.conversation
|
||||||
|
if (contactCustomAttributes.value[value]) {
|
||||||
|
fieldType = fieldTypeConstants.contact_custom_attribute
|
||||||
|
}
|
||||||
|
|
||||||
ruleGroup.value.rules[ruleIndex].operator = ''
|
ruleGroup.value.rules[ruleIndex].operator = ''
|
||||||
ruleGroup.value.rules[ruleIndex].value = ''
|
ruleGroup.value.rules[ruleIndex].value = ''
|
||||||
ruleGroup.value.rules[ruleIndex].field = value
|
ruleGroup.value.rules[ruleIndex].field = value
|
||||||
|
ruleGroup.value.rules[ruleIndex].field_type = fieldType
|
||||||
emitUpdate()
|
emitUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,19 +377,52 @@ const emitUpdate = () => {
|
|||||||
emit('update-group', ruleGroup, props.groupIndex)
|
emit('update-group', ruleGroup, props.groupIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getFieldOperators = (field) => {
|
const getFieldOperators = (field, fieldType) => {
|
||||||
|
// Set default field type if not set for backwards compatibility as this field was added later.
|
||||||
|
if (!fieldType) {
|
||||||
|
fieldType = fieldTypeConstants.conversation
|
||||||
|
}
|
||||||
|
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
|
||||||
|
return contactCustomAttributes.value[field]?.operators || []
|
||||||
|
}
|
||||||
|
if (fieldType === fieldTypeConstants.conversation) {
|
||||||
return currentFilters.value[field]?.operators || []
|
return currentFilters.value[field]?.operators || []
|
||||||
|
}
|
||||||
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const getFieldOptions = (field) => {
|
const getFieldOptions = (field, fieldType) => {
|
||||||
|
// Set default field type if not set for backwards compatibility as this field was added later.
|
||||||
|
if (!fieldType) {
|
||||||
|
fieldType = fieldTypeConstants.conversation
|
||||||
|
}
|
||||||
|
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
|
||||||
|
return contactCustomAttributes.value[field]?.options || []
|
||||||
|
}
|
||||||
|
if (fieldType === fieldTypeConstants.conversation) {
|
||||||
return currentFilters.value[field]?.options || []
|
return currentFilters.value[field]?.options || []
|
||||||
|
}
|
||||||
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputType = (index) => {
|
const inputType = (index) => {
|
||||||
const field = ruleGroup.value.rules[index]?.field
|
const field = ruleGroup.value.rules[index]?.field
|
||||||
const operator = ruleGroup.value.rules[index]?.operator
|
const operator = ruleGroup.value.rules[index]?.operator
|
||||||
|
let fieldType = ruleGroup.value.rules[index]?.field_type
|
||||||
if (['contains', 'not contains'].includes(operator)) return 'tag'
|
if (['contains', 'not contains'].includes(operator)) return 'tag'
|
||||||
if (field) return currentFilters.value[field].type
|
|
||||||
|
// Set default field type if not set for backwards compatibility as this field was added later.
|
||||||
|
if (!fieldType) {
|
||||||
|
fieldType = fieldTypeConstants.conversation
|
||||||
|
}
|
||||||
|
if (field && fieldType) {
|
||||||
|
if (fieldType === fieldTypeConstants.contact_custom_attribute) {
|
||||||
|
return contactCustomAttributes.value[field]?.type || ''
|
||||||
|
}
|
||||||
|
if (fieldType === fieldTypeConstants.conversation) {
|
||||||
|
return currentFilters.value[field]?.type || ''
|
||||||
|
}
|
||||||
|
}
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
{{ rule.name }}
|
{{ rule.name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-1">
|
<div class="mb-1">
|
||||||
<Badge v-if="rule.enabled" class="text-[9px]">Enabled</Badge>
|
<Badge v-if="rule.enabled" class="text-[9px]">{{ $t('form.field.enabled') }}</Badge>
|
||||||
<Badge v-else variant="secondary">Disabled</Badge>
|
<Badge v-else variant="secondary">{{ $t('form.field.disabled') }}</Badge>
|
||||||
</div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -21,16 +21,16 @@
|
|||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem @click="navigateToEditRule(rule.id)">
|
<DropdownMenuItem @click="navigateToEditRule(rule.id)">
|
||||||
<span>Edit</span>
|
<span>{{ $t('globals.buttons.edit') }}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem @click="() => (alertOpen = true)">
|
<DropdownMenuItem @click="() => (alertOpen = true)">
|
||||||
<span>Delete</span>
|
<span>{{ $t('globals.buttons.delete') }}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem @click="$emit('toggle-rule', rule.id)" v-if="rule.enabled">
|
<DropdownMenuItem @click="$emit('toggle-rule', rule.id)" v-if="rule.enabled">
|
||||||
<span>Disable</span>
|
<span>{{ $t('globals.buttons.disable') }}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuItem @click="$emit('toggle-rule', rule.id)" v-else>
|
<DropdownMenuItem @click="$emit('toggle-rule', rule.id)" v-else>
|
||||||
<span>Enable</span>
|
<span>{{ $t('globals.buttons.enable') }}</span>
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
@@ -42,14 +42,16 @@
|
|||||||
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
|
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>Delete Rule</AlertDialogTitle>
|
<AlertDialogTitle>{{ $t('globals.messages.areYouAbsolutelySure') }}</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
This action cannot be undone. This will permanently delete the automation rule.
|
{{ $t('admin.automation.deleteConfirmation') }}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
<AlertDialogCancel>{{ $t('globals.buttons.cancel') }}</AlertDialogCancel>
|
||||||
<AlertDialogAction @click="handleDelete">Delete</AlertDialogAction>
|
<AlertDialogAction @click="handleDelete">{{
|
||||||
|
$t('globals.buttons.delete')
|
||||||
|
}}</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
|||||||
@@ -15,8 +15,10 @@
|
|||||||
}}</SelectValue>
|
}}</SelectValue>
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="first_match">Execute the first matching rule</SelectItem>
|
<SelectItem value="first_match">{{
|
||||||
<SelectItem value="all">Execute all matching rules</SelectItem>
|
$t('admin.automation.executeFirstMatchingRule')
|
||||||
|
}}</SelectItem>
|
||||||
|
<SelectItem value="all">{{ $t('admin.automation.executeAllMatchingRules') }}</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import * as z from 'zod';
|
import * as z from 'zod';
|
||||||
|
|
||||||
export const formSchema = z
|
export const createFormSchema = (t) => z
|
||||||
.object({
|
.object({
|
||||||
name: z.string({
|
name: z.string({
|
||||||
required_error: 'Rule name is required.',
|
required_error: t('globals.messages.required'),
|
||||||
}),
|
}),
|
||||||
description: z.string({
|
description: z.string({
|
||||||
required_error: 'Rule description is required.',
|
required_error: t('globals.messages.required'),
|
||||||
}),
|
}),
|
||||||
enabled: z.boolean().default(true),
|
enabled: z.boolean().default(true),
|
||||||
type: z.string({
|
type: z.string({
|
||||||
required_error: 'Rule type is required.',
|
required_error: t('globals.messages.required'),
|
||||||
}),
|
}),
|
||||||
events: z.array(z.string()).optional(),
|
events: z.array(z.string()).optional(),
|
||||||
})
|
})
|
||||||
@@ -18,7 +18,9 @@ export const formSchema = z
|
|||||||
if (data.type === 'conversation_update' && (!data.events || data.events.length === 0)) {
|
if (data.type === 'conversation_update' && (!data.events || data.events.length === 0)) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
path: ['events'],
|
path: ['events'],
|
||||||
message: 'Please select at least one event.',
|
message: t('globals.messages.pleaseSelectAtLeastOne', {
|
||||||
|
name: t('globals.terms.event')
|
||||||
|
}),
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
<form @submit="onSubmit" class="space-y-8">
|
<form @submit="onSubmit" class="space-y-8">
|
||||||
<FormField v-slot="{ componentField }" name="name">
|
<FormField v-slot="{ componentField }" name="name">
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Name</FormLabel>
|
<FormLabel>
|
||||||
|
{{ t('form.field.name') }}
|
||||||
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="text" placeholder="General working hours" v-bind="componentField" />
|
<Input type="text" placeholder="" v-bind="componentField" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -12,9 +14,11 @@
|
|||||||
|
|
||||||
<FormField v-slot="{ componentField }" name="description">
|
<FormField v-slot="{ componentField }" name="description">
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Description</FormLabel>
|
<FormLabel>
|
||||||
|
{{ t('form.field.description') }}
|
||||||
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input type="text" placeholder="General working hours for my company" v-bind="componentField" />
|
<Input type="text" placeholder="" v-bind="componentField" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@@ -23,18 +27,18 @@
|
|||||||
<FormField v-slot="{ componentField }" name="is_always_open">
|
<FormField v-slot="{ componentField }" name="is_always_open">
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>
|
<FormLabel>
|
||||||
Set business hours
|
{{ t('admin.businessHours.setBusinessHours') }}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<RadioGroup v-bind="componentField">
|
<RadioGroup v-bind="componentField">
|
||||||
<div class="flex flex-col space-y-2">
|
<div class="flex flex-col space-y-2">
|
||||||
<div class="flex items-center space-x-3">
|
<div class="flex items-center space-x-3">
|
||||||
<RadioGroupItem id="r1" value="true" />
|
<RadioGroupItem id="r1" :value="true" />
|
||||||
<Label for="r1">Always open (24x7)</Label>
|
<Label for="r1">{{ t('admin.businessHours.alwaysOpen24x7') }}</Label>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center space-x-3">
|
<div class="flex items-center space-x-3">
|
||||||
<RadioGroupItem id="r2" value="false" />
|
<RadioGroupItem id="r2" :value="false" />
|
||||||
<Label for="r2">Custom business hours</Label>
|
<Label for="r2">{{ t('admin.businessHours.customBusinessHours') }}</Label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
@@ -43,67 +47,105 @@
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<div v-if="form.values.is_always_open === 'false'">
|
<FormField name="hours">
|
||||||
|
<div v-if="form.values.is_always_open === false">
|
||||||
|
<FormItem>
|
||||||
<div>
|
<div>
|
||||||
<div v-for="day in WEEKDAYS" :key="day" class="flex items-center justify-between space-y-2">
|
<div
|
||||||
|
v-for="day in WEEKDAYS"
|
||||||
|
:key="day"
|
||||||
|
class="flex items-center justify-between space-y-2"
|
||||||
|
>
|
||||||
<div class="flex items-center space-x-3">
|
<div class="flex items-center space-x-3">
|
||||||
<Checkbox :id="day" :checked="!!selectedDays[day]"
|
<Checkbox
|
||||||
@update:checked="handleDayToggle(day, $event)" />
|
:id="day"
|
||||||
|
:checked="!!selectedDays[day]"
|
||||||
|
@update:checked="handleDayToggle(day, $event)"
|
||||||
|
/>
|
||||||
<Label :for="day" class="font-medium text-gray-800">{{ day }}</Label>
|
<Label :for="day" class="font-medium text-gray-800">{{ day }}</Label>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex space-x-2 items-center">
|
<div class="flex space-x-2 items-center">
|
||||||
<div class="flex flex-col items-start">
|
<div class="flex flex-col items-start">
|
||||||
<Input type="time" :defaultValue="hours[day]?.open || '09:00'"
|
<Input
|
||||||
|
type="time"
|
||||||
|
:modelValue="hours[day]?.open || '09:00'"
|
||||||
@update:modelValue="(val) => updateHours(day, 'open', val)"
|
@update:modelValue="(val) => updateHours(day, 'open', val)"
|
||||||
:disabled="!selectedDays[day]" />
|
:disabled="!selectedDays[day]"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<span class="text-gray-500">to</span>
|
<span class="text-gray-500">to</span>
|
||||||
<div class="flex flex-col items-start">
|
<div class="flex flex-col items-start">
|
||||||
<Input type="time" :defaultValue="hours[day]?.close || '17:00'"
|
<Input
|
||||||
|
type="time"
|
||||||
|
:modelValue="hours[day]?.close || '17:00'"
|
||||||
@update:modelValue="(val) => updateHours(day, 'close', val)"
|
@update:modelValue="(val) => updateHours(day, 'close', val)"
|
||||||
:disabled="!selectedDays[day]" />
|
:disabled="!selectedDays[day]"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
</div>
|
</div>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<Dialog >
|
<Dialog :open="openHolidayForm" @update:open="openHolidayForm = false">
|
||||||
<div>
|
<div>
|
||||||
<div class="flex justify-between items-center mb-4">
|
<div class="flex justify-between items-center mb-4">
|
||||||
<div></div>
|
<div></div>
|
||||||
<DialogTrigger as-child>
|
<DialogTrigger as-child>
|
||||||
<Button>New holiday</Button>
|
<Button @click="openHolidayForm = true">
|
||||||
|
{{
|
||||||
|
t('globals.messages.new', {
|
||||||
|
name: t('globals.terms.holiday')
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<SimpleTable :headers="['Name', 'Date']" :keys="['name', 'date']" :data="holidays" @deleteItem="deleteHoliday" />
|
<SimpleTable
|
||||||
|
:headers="[t('form.field.name'), t('form.field.date')]"
|
||||||
|
:keys="['name', 'date']"
|
||||||
|
:data="holidays"
|
||||||
|
@deleteItem="deleteHoliday"
|
||||||
|
/>
|
||||||
<DialogContent class="sm:max-w-[425px]">
|
<DialogContent class="sm:max-w-[425px]">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
<DialogTitle>New holiday</DialogTitle>
|
<DialogTitle>
|
||||||
<DialogDescription>
|
{{
|
||||||
</DialogDescription>
|
t('globals.messages.new', {
|
||||||
|
name: t('globals.terms.holiday')
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogDescription />
|
||||||
</DialogHeader>
|
</DialogHeader>
|
||||||
<div class="grid gap-4 py-4">
|
<div class="grid gap-4 py-4">
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label for="holiday_name" class="text-right">
|
<Label for="holiday_name" class="text-right"> {{ t('form.field.name') }} </Label>
|
||||||
Name
|
|
||||||
</Label>
|
|
||||||
<Input id="holiday_name" v-model="holidayName" class="col-span-3" />
|
<Input id="holiday_name" v-model="holidayName" class="col-span-3" />
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-4 items-center gap-4">
|
<div class="grid grid-cols-4 items-center gap-4">
|
||||||
<Label for="date" class="text-right">
|
<Label for="date" class="text-right"> {{ t('form.field.date') }} </Label>
|
||||||
Date
|
|
||||||
</Label>
|
|
||||||
<Popover>
|
<Popover>
|
||||||
<PopoverTrigger as-child>
|
<PopoverTrigger as-child>
|
||||||
<Button variant="outline" :class="cn(
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
:class="
|
||||||
|
cn(
|
||||||
'w-[280px] justify-start text-left font-normal',
|
'w-[280px] justify-start text-left font-normal',
|
||||||
!holidayDate && 'text-muted-foreground',
|
!holidayDate && 'text-muted-foreground'
|
||||||
)">
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
<CalendarIcon class="mr-2 h-4 w-4" />
|
<CalendarIcon class="mr-2 h-4 w-4" />
|
||||||
{{ holidayDate && !isNaN(new Date(holidayDate).getTime()) ? format(new
|
{{
|
||||||
Date(holidayDate), 'MMMM dd, yyyy') : "Pick a date" }}
|
holidayDate && !isNaN(new Date(holidayDate).getTime())
|
||||||
|
? format(new Date(holidayDate), 'MMMM dd, yyyy')
|
||||||
|
: t('form.field.pickDate')
|
||||||
|
}}
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent class="w-auto p-0">
|
<PopoverContent class="w-auto p-0">
|
||||||
@@ -113,9 +155,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button :disabled="!holidayName || !holidayDate"
|
<Button :disabled="!holidayName || !holidayDate" @click="saveHoliday">
|
||||||
@click="saveHoliday">
|
{{ t('globals.buttons.saveChanges') }}
|
||||||
Save changes
|
|
||||||
</Button>
|
</Button>
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
@@ -125,11 +166,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, reactive } from 'vue'
|
import { ref, watch, reactive, computed } from 'vue'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { useForm } from 'vee-validate'
|
import { useForm } from 'vee-validate'
|
||||||
import { toTypedSchema } from '@vee-validate/zod'
|
import { toTypedSchema } from '@vee-validate/zod'
|
||||||
import { formSchema } from './formSchema.js'
|
import { createFormSchema } from './formSchema.js'
|
||||||
import { Checkbox } from '@/components/ui/checkbox'
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { Label } from '@/components/ui/label'
|
import { Label } from '@/components/ui/label'
|
||||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
||||||
@@ -141,6 +182,7 @@ import { cn } from '@/lib/utils'
|
|||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
import { WEEKDAYS } from '@/constants/date'
|
import { WEEKDAYS } from '@/constants/date'
|
||||||
import { Calendar as CalendarIcon } from 'lucide-vue-next'
|
import { Calendar as CalendarIcon } from 'lucide-vue-next'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import SimpleTable from '@/components/table/SimpleTable.vue'
|
import SimpleTable from '@/components/table/SimpleTable.vue'
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@@ -149,7 +191,7 @@ import {
|
|||||||
DialogFooter,
|
DialogFooter,
|
||||||
DialogHeader,
|
DialogHeader,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
DialogTrigger,
|
DialogTrigger
|
||||||
} from '@/components/ui/dialog'
|
} from '@/components/ui/dialog'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -164,7 +206,7 @@ const props = defineProps({
|
|||||||
submitLabel: {
|
submitLabel: {
|
||||||
type: String,
|
type: String,
|
||||||
required: false,
|
required: false,
|
||||||
default: () => 'Save'
|
default: () => ''
|
||||||
},
|
},
|
||||||
isNewForm: {
|
isNewForm: {
|
||||||
type: Boolean
|
type: Boolean
|
||||||
@@ -172,7 +214,11 @@ const props = defineProps({
|
|||||||
isLoading: {
|
isLoading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false
|
required: false
|
||||||
},
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const submitLabel = computed(() => {
|
||||||
|
return props.submitLabel || t('globals.buttons.save')
|
||||||
})
|
})
|
||||||
|
|
||||||
let holidays = reactive([])
|
let holidays = reactive([])
|
||||||
@@ -180,14 +226,14 @@ const holidayName = ref('')
|
|||||||
const holidayDate = ref(null)
|
const holidayDate = ref(null)
|
||||||
const selectedDays = ref({})
|
const selectedDays = ref({})
|
||||||
const hours = ref({})
|
const hours = ref({})
|
||||||
|
const openHolidayForm = ref(false)
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
validationSchema: toTypedSchema(formSchema),
|
validationSchema: toTypedSchema(createFormSchema(t)),
|
||||||
initialValues: props.initialValues
|
initialValues: props.initialValues
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const saveHoliday = () => {
|
const saveHoliday = () => {
|
||||||
holidays.push({
|
holidays.push({
|
||||||
name: holidayName.value,
|
name: holidayName.value,
|
||||||
@@ -195,10 +241,14 @@ const saveHoliday = () => {
|
|||||||
})
|
})
|
||||||
holidayName.value = ''
|
holidayName.value = ''
|
||||||
holidayDate.value = null
|
holidayDate.value = null
|
||||||
|
openHolidayForm.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteHoliday = (item) => {
|
const deleteHoliday = (item) => {
|
||||||
holidays.splice(holidays.findIndex(h => h.name === item.name), 1)
|
holidays.splice(
|
||||||
|
holidays.findIndex((h) => h.name === item.name),
|
||||||
|
1
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleDayToggle = (day, checked) => {
|
const handleDayToggle = (day, checked) => {
|
||||||
@@ -214,6 +264,9 @@ const handleDayToggle = (day, checked) => {
|
|||||||
delete newHours[day]
|
delete newHours[day]
|
||||||
hours.value = newHours
|
hours.value = newHours
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync with form values
|
||||||
|
form.setFieldValue('hours', { ...hours.value })
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateHours = (day, type, value) => {
|
const updateHours = (day, type, value) => {
|
||||||
@@ -221,22 +274,24 @@ const updateHours = (day, type, value) => {
|
|||||||
hours.value[day] = { open: '09:00', close: '17:00' }
|
hours.value[day] = { open: '09:00', close: '17:00' }
|
||||||
}
|
}
|
||||||
hours.value[day][type] = value
|
hours.value[day][type] = value
|
||||||
|
|
||||||
|
// Sync with form values
|
||||||
|
form.setFieldValue('hours', { ...hours.value })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const onSubmit = form.handleSubmit((values) => {
|
const onSubmit = form.handleSubmit((values) => {
|
||||||
values.is_always_open = values.is_always_open === 'true'
|
const businessHours =
|
||||||
const businessHours = values.is_always_open === true
|
values.is_always_open === true
|
||||||
? {}
|
? {}
|
||||||
:
|
: Object.keys(selectedDays.value)
|
||||||
Object.keys(selectedDays.value)
|
.filter((day) => selectedDays.value[day])
|
||||||
.filter(day => selectedDays.value[day])
|
|
||||||
.reduce((acc, day) => {
|
.reduce((acc, day) => {
|
||||||
acc[day] = hours.value[day]
|
acc[day] = hours.value[day]
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
const finalValues = {
|
const finalValues = {
|
||||||
...values,
|
...values,
|
||||||
|
is_always_open: values.is_always_open,
|
||||||
hours: businessHours,
|
hours: businessHours,
|
||||||
holidays: holidays
|
holidays: holidays
|
||||||
}
|
}
|
||||||
@@ -251,8 +306,7 @@ watch(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Set business hours if provided
|
// Set business hours if provided
|
||||||
newValues.is_always_open = newValues.is_always_open.toString()
|
if (newValues.is_always_open === false) {
|
||||||
if (newValues.is_always_open === 'false') {
|
|
||||||
hours.value = newValues.hours || {}
|
hours.value = newValues.hours || {}
|
||||||
selectedDays.value = Object.keys(hours.value).reduce((acc, day) => {
|
selectedDays.value = Object.keys(hours.value).reduce((acc, day) => {
|
||||||
acc[day] = true
|
acc[day] = true
|
||||||
@@ -266,5 +320,4 @@ watch(
|
|||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -2,11 +2,11 @@ import { h } from 'vue'
|
|||||||
import dropdown from './dataTableDropdown.vue'
|
import dropdown from './dataTableDropdown.vue'
|
||||||
import { format } from 'date-fns'
|
import { format } from 'date-fns'
|
||||||
|
|
||||||
export const columns = [
|
export const createColumns = (t) => [
|
||||||
{
|
{
|
||||||
accessorKey: 'name',
|
accessorKey: 'name',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Name')
|
return h('div', { class: 'text-center' }, t('form.field.name'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h('div', { class: 'text-center font-medium' }, row.getValue('name'))
|
return h('div', { class: 'text-center font-medium' }, row.getValue('name'))
|
||||||
@@ -15,7 +15,7 @@ export const columns = [
|
|||||||
{
|
{
|
||||||
accessorKey: 'created_at',
|
accessorKey: 'created_at',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Created at')
|
return h('div', { class: 'text-center' }, t('form.field.createdAt'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h('div', { class: 'text-center font-medium' }, format(row.getValue('created_at'), 'PPpp'))
|
return h('div', { class: 'text-center font-medium' }, format(row.getValue('created_at'), 'PPpp'))
|
||||||
@@ -24,7 +24,7 @@ export const columns = [
|
|||||||
{
|
{
|
||||||
accessorKey: 'updated_at',
|
accessorKey: 'updated_at',
|
||||||
header: function () {
|
header: function () {
|
||||||
return h('div', { class: 'text-center' }, 'Updated at')
|
return h('div', { class: 'text-center' }, t('form.field.updatedAt'))
|
||||||
},
|
},
|
||||||
cell: function ({ row }) {
|
cell: function ({ row }) {
|
||||||
return h('div', { class: 'text-center font-medium' }, format(row.getValue('updated_at'), 'PPpp'))
|
return h('div', { class: 'text-center font-medium' }, format(row.getValue('updated_at'), 'PPpp'))
|
||||||
|
|||||||
@@ -2,27 +2,37 @@
|
|||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger as-child>
|
<DropdownMenuTrigger as-child>
|
||||||
<Button variant="ghost" class="w-8 h-8 p-0">
|
<Button variant="ghost" class="w-8 h-8 p-0">
|
||||||
<span class="sr-only">Open menu</span>
|
<span class="sr-only"></span>
|
||||||
<MoreHorizontal class="w-4 h-4" />
|
<MoreHorizontal class="w-4 h-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
<DropdownMenuItem @click="edit(props.role.id)">Edit</DropdownMenuItem>
|
<DropdownMenuItem @click="edit(props.role.id)">
|
||||||
<DropdownMenuItem @click="() => (alertOpen = true)">Delete</DropdownMenuItem>
|
{{ t('globals.buttons.edit') }}
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem @click="() => (alertOpen = true)">
|
||||||
|
{{ t('globals.buttons.delete') }}
|
||||||
|
</DropdownMenuItem>
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
||||||
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
|
<AlertDialog :open="alertOpen" @update:open="alertOpen = $event">
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>Delete Business Hours</AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
|
{{ t('globals.messages.areYouAbsolutelySure') }}
|
||||||
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
This action cannot be undone. This will permanently delete the business hours.
|
{{ t('admin.businessHours.deleteConfirmation') }}
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
<AlertDialogCancel>
|
||||||
<AlertDialogAction @click="handleDelete">Delete</AlertDialogAction>
|
{{ t('globals.buttons.cancel') }}
|
||||||
|
</AlertDialogCancel>
|
||||||
|
<AlertDialogAction @click="handleDelete">
|
||||||
|
{{ t('globals.buttons.delete') }}
|
||||||
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
@@ -51,8 +61,10 @@ import { Button } from '@/components/ui/button'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { useEmitter } from '@/composables/useEmitter'
|
import { useEmitter } from '@/composables/useEmitter'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
import { EMITTER_EVENTS } from '@/constants/emitterEvents.js'
|
import { EMITTER_EVENTS } from '@/constants/emitterEvents.js'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const emit = useEmitter()
|
const emit = useEmitter()
|
||||||
const alertOpen = ref(false)
|
const alertOpen = ref(false)
|
||||||
|
|||||||
@@ -1,13 +1,35 @@
|
|||||||
import * as z from 'zod'
|
import * as z from 'zod'
|
||||||
|
|
||||||
export const formSchema = z.object({
|
const timeRegex = /^([01]\d|2[0-3]):([0-5]\d)$/
|
||||||
name: z
|
|
||||||
.string({
|
export const createFormSchema = (t) => z.object({
|
||||||
required_error: 'Name is required.'
|
name: z.string().min(1, t('globals.messages.required')),
|
||||||
|
description: z.string().min(1, t('globals.messages.required')),
|
||||||
|
is_always_open: z.boolean().default(true),
|
||||||
|
hours: z.record(
|
||||||
|
z.object({
|
||||||
|
open: z.string().regex(timeRegex, t('form.error.time.invalid')),
|
||||||
|
close: z.string().regex(timeRegex, t('form.error.time.invalid')),
|
||||||
})
|
})
|
||||||
.min(1, {
|
).optional()
|
||||||
message: 'Name must be at least 1 character.'
|
}).superRefine((data, ctx) => {
|
||||||
}),
|
if (data.is_always_open === false) {
|
||||||
description: z.string(),
|
if (!data.hours || Object.keys(data.hours).length === 0) {
|
||||||
is_always_open: z.string().default('false'),
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: t('admin.business_hours.hours.required'),
|
||||||
|
path: ['hours']
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
for (const day in data.hours) {
|
||||||
|
if (!data.hours[day].open || !data.hours[day].close) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
message: t('admin.business_hours.open_close.required'),
|
||||||
|
path: ['hours', day]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user