Compare commits
28 Commits
fix/home-p
...
imp/recurr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7aeaaa1fee | ||
|
|
474f1afe66 | ||
|
|
a112d39321 | ||
|
|
4788294bc4 | ||
|
|
737f7cada2 | ||
|
|
833879e0e8 | ||
|
|
cb5610d99b | ||
|
|
0434bbb73b | ||
|
|
6e911d79fc | ||
|
|
0bb748cf89 | ||
|
|
ba5d4975af | ||
|
|
d4620148bd | ||
|
|
8d7d54be78 | ||
|
|
c34b94c7db | ||
|
|
55a0028e26 | ||
|
|
17371200ca | ||
|
|
83044077d3 | ||
|
|
a03d9ef6a4 | ||
|
|
fca8ace10d | ||
|
|
d970cbb626 | ||
|
|
6d8c475e67 | ||
|
|
a1c0cef149 | ||
|
|
8f098143fd | ||
|
|
407dc416ec | ||
|
|
3d67145af7 | ||
|
|
1c981312d4 | ||
|
|
02d814b935 | ||
|
|
d3023618e1 |
11
.claude/settings.local.json
Normal file
11
.claude/settings.local.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"permissions": {
|
||||||
|
"allow": [
|
||||||
|
"Bash(find:*)",
|
||||||
|
"Bash(npm run build:*)",
|
||||||
|
"Bash(npm run type-check:*)",
|
||||||
|
"Bash(npm run:*)"
|
||||||
|
],
|
||||||
|
"deny": []
|
||||||
|
}
|
||||||
|
}
|
||||||
111
docs/job-queue-dependencies.md
Normal file
111
docs/job-queue-dependencies.md
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
# Job Queue Dependencies
|
||||||
|
|
||||||
|
To use the job queue implementation for recurring tasks, add these dependencies to your package.json:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"bull": "^4.12.2",
|
||||||
|
"ioredis": "^5.3.2"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bull": "^4.10.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install bull ioredis
|
||||||
|
npm install --save-dev @types/bull
|
||||||
|
```
|
||||||
|
|
||||||
|
## Redis Setup
|
||||||
|
|
||||||
|
1. Install Redis on your system:
|
||||||
|
- **Ubuntu/Debian**: `sudo apt install redis-server`
|
||||||
|
- **macOS**: `brew install redis`
|
||||||
|
- **Windows**: Use WSL or Redis for Windows
|
||||||
|
- **Docker**: `docker run -d -p 6379:6379 redis:alpine`
|
||||||
|
|
||||||
|
2. Configure Redis connection in your environment variables:
|
||||||
|
```env
|
||||||
|
REDIS_HOST=localhost
|
||||||
|
REDIS_PORT=6379
|
||||||
|
REDIS_PASSWORD=your_password # Optional
|
||||||
|
REDIS_DB=0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Add these environment variables to control the recurring tasks behavior:
|
||||||
|
|
||||||
|
```env
|
||||||
|
# Service configuration
|
||||||
|
RECURRING_TASKS_ENABLED=true
|
||||||
|
RECURRING_TASKS_MODE=queue # or 'cron'
|
||||||
|
|
||||||
|
# Queue configuration
|
||||||
|
RECURRING_TASKS_MAX_CONCURRENCY=5
|
||||||
|
RECURRING_TASKS_RETRY_ATTEMPTS=3
|
||||||
|
RECURRING_TASKS_RETRY_DELAY=2000
|
||||||
|
|
||||||
|
# Notifications
|
||||||
|
RECURRING_TASKS_NOTIFICATIONS_ENABLED=true
|
||||||
|
RECURRING_TASKS_EMAIL_NOTIFICATIONS=true
|
||||||
|
RECURRING_TASKS_PUSH_NOTIFICATIONS=true
|
||||||
|
RECURRING_TASKS_IN_APP_NOTIFICATIONS=true
|
||||||
|
|
||||||
|
# Audit logging
|
||||||
|
RECURRING_TASKS_AUDIT_LOG_ENABLED=true
|
||||||
|
RECURRING_TASKS_AUDIT_RETENTION_DAYS=90
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
In your main application file, start the service:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { RecurringTasksService } from './src/services/recurring-tasks-service';
|
||||||
|
|
||||||
|
// Start the service
|
||||||
|
await RecurringTasksService.start();
|
||||||
|
|
||||||
|
// Get status
|
||||||
|
const status = await RecurringTasksService.getStatus();
|
||||||
|
console.log('Recurring tasks status:', status);
|
||||||
|
|
||||||
|
// Health check
|
||||||
|
const health = await RecurringTasksService.healthCheck();
|
||||||
|
console.log('Health check:', health);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Benefits of Job Queue vs Cron
|
||||||
|
|
||||||
|
### Job Queue (Bull/BullMQ) Benefits:
|
||||||
|
- **Better scalability**: Can run multiple workers
|
||||||
|
- **Retry logic**: Built-in retry with exponential backoff
|
||||||
|
- **Monitoring**: Redis-based job monitoring and UI
|
||||||
|
- **Priority queues**: Handle urgent tasks first
|
||||||
|
- **Rate limiting**: Control processing rate
|
||||||
|
- **Persistence**: Jobs survive server restarts
|
||||||
|
|
||||||
|
### Cron Job Benefits:
|
||||||
|
- **Simplicity**: No external dependencies
|
||||||
|
- **Lower resource usage**: No Redis required
|
||||||
|
- **Predictable timing**: Runs exactly on schedule
|
||||||
|
- **Easier debugging**: Simpler execution model
|
||||||
|
|
||||||
|
## Monitoring
|
||||||
|
|
||||||
|
You can monitor the job queues using:
|
||||||
|
- **Bull Dashboard**: Web UI for monitoring jobs
|
||||||
|
- **Redis CLI**: Direct Redis monitoring
|
||||||
|
- **Application logs**: Built-in audit logging
|
||||||
|
- **Health checks**: Built-in health check endpoint
|
||||||
|
|
||||||
|
Install Bull Dashboard for monitoring:
|
||||||
|
```bash
|
||||||
|
npm install -g bull-board
|
||||||
|
```
|
||||||
382
package-lock.json
generated
382
package-lock.json
generated
@@ -2,5 +2,385 @@
|
|||||||
"name": "worklenz",
|
"name": "worklenz",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {}
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"dependencies": {
|
||||||
|
"bull": "^4.16.5",
|
||||||
|
"ioredis": "^5.6.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bull": "^3.15.9"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@ioredis/commands": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-arm64/-/msgpackr-extract-darwin-arm64-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-QZHtlVgbAdy2zAqNA9Gu1UpIuI8Xvsd1v8ic6B2pZmeFnFcMWiPLfWXh7TVw4eGEZ/C9TH281KwhVoeQUKbyjw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-darwin-x64/-/msgpackr-extract-darwin-x64-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-mdzd3AVzYKuUmiWOQ8GNhl64/IoFGol569zNRdkLReh6LRLHOXxU4U8eq0JwaD8iFHdVGqSy4IjFL4reoWCDFw==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@msgpackr-extract/msgpackr-extract-linux-arm": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm/-/msgpackr-extract-linux-arm-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-fg0uy/dG/nZEXfYilKoRe7yALaNmHoYeIoJuJ7KJ+YyU2bvY8vPv27f7UKhGRpY6euFYqEVhxCFZgAUNQBM3nw==",
|
||||||
|
"cpu": [
|
||||||
|
"arm"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-arm64/-/msgpackr-extract-linux-arm64-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-YxQL+ax0XqBJDZiKimS2XQaf+2wDGVa1enVRGzEvLLVFeqa5kx2bWbtcSXgsxjQB7nRqqIGFIcLteF/sHeVtQg==",
|
||||||
|
"cpu": [
|
||||||
|
"arm64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@msgpackr-extract/msgpackr-extract-linux-x64": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-linux-x64/-/msgpackr-extract-linux-x64-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-cvwNfbP07pKUfq1uH+S6KJ7dT9K8WOE4ZiAcsrSes+UY55E/0jLYc+vq+DO7jlmqRb5zAggExKm0H7O/CBaesg==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@msgpackr-extract/msgpackr-extract-win32-x64": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@msgpackr-extract/msgpackr-extract-win32-x64/-/msgpackr-extract-win32-x64-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-x0fWaQtYp4E6sktbsdAqnehxDgEc/VwM7uLsRCYWaiGu0ykYdZPiS8zCWdnjHwyiumousxfBm4SO31eXqwEZhQ==",
|
||||||
|
"cpu": [
|
||||||
|
"x64"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"win32"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"node_modules/@types/bull": {
|
||||||
|
"version": "3.15.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/bull/-/bull-3.15.9.tgz",
|
||||||
|
"integrity": "sha512-MPUcyPPQauAmynoO3ezHAmCOhbB0pWmYyijr/5ctaCqhbKWsjW0YCod38ZcLzUBprosfZ9dPqfYIcfdKjk7RNQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/ioredis": "*",
|
||||||
|
"@types/redis": "^2.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/ioredis": {
|
||||||
|
"version": "4.28.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-4.28.10.tgz",
|
||||||
|
"integrity": "sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/node": {
|
||||||
|
"version": "24.0.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.15.tgz",
|
||||||
|
"integrity": "sha512-oaeTSbCef7U/z7rDeJA138xpG3NuKc64/rZ2qmUFkFJmnMsAPaluIifqyWd8hSSMxyP9oie3dLAqYPblag9KgA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"undici-types": "~7.8.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/redis": {
|
||||||
|
"version": "2.8.32",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.32.tgz",
|
||||||
|
"integrity": "sha512-7jkMKxcGq9p242exlbsVzuJb57KqHRhNl4dHoQu2Y5v9bCAbtIXXH0R3HleSQW4CTOqpHIYUW3t6tpUj4BVQ+w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/bull": {
|
||||||
|
"version": "4.16.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/bull/-/bull-4.16.5.tgz",
|
||||||
|
"integrity": "sha512-lDsx2BzkKe7gkCYiT5Acj02DpTwDznl/VNN7Psn7M3USPG7Vs/BaClZJJTAG+ufAR9++N1/NiUTdaFBWDIl5TQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"cron-parser": "^4.9.0",
|
||||||
|
"get-port": "^5.1.1",
|
||||||
|
"ioredis": "^5.3.2",
|
||||||
|
"lodash": "^4.17.21",
|
||||||
|
"msgpackr": "^1.11.2",
|
||||||
|
"semver": "^7.5.2",
|
||||||
|
"uuid": "^8.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/cluster-key-slot": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/cron-parser": {
|
||||||
|
"version": "4.9.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cron-parser/-/cron-parser-4.9.0.tgz",
|
||||||
|
"integrity": "sha512-p0SaNjrHOnQeR8/VnfGbmg9te2kfyYSQ7Sc/j/6DtPL3JQvKxmjO9TSjNFpujqV3vEYYBvNNvXSxzyksBWAx1Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"luxon": "^3.2.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/debug": {
|
||||||
|
"version": "4.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
|
||||||
|
"integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"ms": "^2.1.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"supports-color": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/denque": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/detect-libc": {
|
||||||
|
"version": "2.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz",
|
||||||
|
"integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"optional": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/get-port": {
|
||||||
|
"version": "5.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/get-port/-/get-port-5.1.1.tgz",
|
||||||
|
"integrity": "sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ioredis": {
|
||||||
|
"version": "5.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.6.1.tgz",
|
||||||
|
"integrity": "sha512-UxC0Yv1Y4WRJiGQxQkP0hfdL0/5/6YvdfOOClRgJ0qppSarkhneSa6UvkMkms0AkdGimSH3Ikqm+6mkMmX7vGA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@ioredis/commands": "^1.1.1",
|
||||||
|
"cluster-key-slot": "^1.1.0",
|
||||||
|
"debug": "^4.3.4",
|
||||||
|
"denque": "^2.1.0",
|
||||||
|
"lodash.defaults": "^4.2.0",
|
||||||
|
"lodash.isarguments": "^3.1.0",
|
||||||
|
"redis-errors": "^1.2.0",
|
||||||
|
"redis-parser": "^3.0.0",
|
||||||
|
"standard-as-callback": "^2.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.22.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/ioredis"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/lodash": {
|
||||||
|
"version": "4.17.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/lodash.defaults": {
|
||||||
|
"version": "4.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
|
||||||
|
"integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/lodash.isarguments": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/luxon": {
|
||||||
|
"version": "3.7.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/luxon/-/luxon-3.7.1.tgz",
|
||||||
|
"integrity": "sha512-RkRWjA926cTvz5rAb1BqyWkKbbjzCGchDUIKMCUvNi17j6f6j8uHGDV82Aqcqtzd+icoYpELmG3ksgGiFNNcNg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/ms": {
|
||||||
|
"version": "2.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/msgpackr": {
|
||||||
|
"version": "1.11.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/msgpackr/-/msgpackr-1.11.5.tgz",
|
||||||
|
"integrity": "sha512-UjkUHN0yqp9RWKy0Lplhh+wlpdt9oQBYgULZOiFhV3VclSF1JnSQWZ5r9gORQlNYaUKQoR8itv7g7z1xDDuACA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"optionalDependencies": {
|
||||||
|
"msgpackr-extract": "^3.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/msgpackr-extract": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/msgpackr-extract/-/msgpackr-extract-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-P0efT1C9jIdVRefqjzOQ9Xml57zpOXnIuS+csaB4MdZbTdmGDLo8XhzBG1N7aO11gKDDkJvBLULeFTo46wwreA==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"dependencies": {
|
||||||
|
"node-gyp-build-optional-packages": "5.2.2"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"download-msgpackr-prebuilds": "bin/download-prebuilds.js"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@msgpackr-extract/msgpackr-extract-darwin-arm64": "3.0.3",
|
||||||
|
"@msgpackr-extract/msgpackr-extract-darwin-x64": "3.0.3",
|
||||||
|
"@msgpackr-extract/msgpackr-extract-linux-arm": "3.0.3",
|
||||||
|
"@msgpackr-extract/msgpackr-extract-linux-arm64": "3.0.3",
|
||||||
|
"@msgpackr-extract/msgpackr-extract-linux-x64": "3.0.3",
|
||||||
|
"@msgpackr-extract/msgpackr-extract-win32-x64": "3.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/node-gyp-build-optional-packages": {
|
||||||
|
"version": "5.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/node-gyp-build-optional-packages/-/node-gyp-build-optional-packages-5.2.2.tgz",
|
||||||
|
"integrity": "sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"dependencies": {
|
||||||
|
"detect-libc": "^2.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"node-gyp-build-optional-packages": "bin.js",
|
||||||
|
"node-gyp-build-optional-packages-optional": "optional.js",
|
||||||
|
"node-gyp-build-optional-packages-test": "build-test.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/redis-errors": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
|
||||||
|
"integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/redis-parser": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"redis-errors": "^1.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/semver": {
|
||||||
|
"version": "7.7.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
|
||||||
|
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
|
||||||
|
"license": "ISC",
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/standard-as-callback": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/undici-types": {
|
||||||
|
"version": "7.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
||||||
|
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
9
package.json
Normal file
9
package.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"bull": "^4.16.5",
|
||||||
|
"ioredis": "^5.6.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/bull": "^3.15.9"
|
||||||
|
}
|
||||||
|
}
|
||||||
41
test_sort_fix.sql
Normal file
41
test_sort_fix.sql
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
-- Test script to verify the sort order constraint fix
|
||||||
|
|
||||||
|
-- Test the helper function
|
||||||
|
SELECT get_sort_column_name('status'); -- Should return 'status_sort_order'
|
||||||
|
SELECT get_sort_column_name('priority'); -- Should return 'priority_sort_order'
|
||||||
|
SELECT get_sort_column_name('phase'); -- Should return 'phase_sort_order'
|
||||||
|
SELECT get_sort_column_name('members'); -- Should return 'member_sort_order'
|
||||||
|
SELECT get_sort_column_name('unknown'); -- Should return 'status_sort_order' (default)
|
||||||
|
|
||||||
|
-- Test bulk update function (example - would need real project_id and task_ids)
|
||||||
|
/*
|
||||||
|
SELECT update_task_sort_orders_bulk(
|
||||||
|
'[
|
||||||
|
{"task_id": "example-uuid", "sort_order": 1, "status_id": "status-uuid"},
|
||||||
|
{"task_id": "example-uuid-2", "sort_order": 2, "status_id": "status-uuid"}
|
||||||
|
]'::json,
|
||||||
|
'status'
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- Verify that sort_order constraint still exists and works
|
||||||
|
SELECT
|
||||||
|
tc.constraint_name,
|
||||||
|
tc.table_name,
|
||||||
|
kcu.column_name
|
||||||
|
FROM information_schema.table_constraints tc
|
||||||
|
JOIN information_schema.key_column_usage kcu
|
||||||
|
ON tc.constraint_name = kcu.constraint_name
|
||||||
|
WHERE tc.constraint_name = 'tasks_sort_order_unique';
|
||||||
|
|
||||||
|
-- Check that new sort order columns don't have unique constraints (which is correct)
|
||||||
|
SELECT
|
||||||
|
tc.constraint_name,
|
||||||
|
tc.table_name,
|
||||||
|
kcu.column_name
|
||||||
|
FROM information_schema.table_constraints tc
|
||||||
|
JOIN information_schema.key_column_usage kcu
|
||||||
|
ON tc.constraint_name = kcu.constraint_name
|
||||||
|
WHERE kcu.table_name = 'tasks'
|
||||||
|
AND kcu.column_name IN ('status_sort_order', 'priority_sort_order', 'phase_sort_order', 'member_sort_order')
|
||||||
|
AND tc.constraint_type = 'UNIQUE';
|
||||||
30
test_sort_orders.sql
Normal file
30
test_sort_orders.sql
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
-- Test script to validate the separate sort order implementation
|
||||||
|
|
||||||
|
-- Check if new columns exist
|
||||||
|
SELECT column_name, data_type, is_nullable, column_default
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'tasks'
|
||||||
|
AND column_name IN ('status_sort_order', 'priority_sort_order', 'phase_sort_order', 'member_sort_order')
|
||||||
|
ORDER BY column_name;
|
||||||
|
|
||||||
|
-- Check if helper function exists
|
||||||
|
SELECT routine_name, routine_type
|
||||||
|
FROM information_schema.routines
|
||||||
|
WHERE routine_name IN ('get_sort_column_name', 'update_task_sort_orders_bulk', 'handle_task_list_sort_order_change');
|
||||||
|
|
||||||
|
-- Sample test data to verify different sort orders work
|
||||||
|
-- (This would be run after the migrations)
|
||||||
|
/*
|
||||||
|
-- Test: Tasks should have different orders for different groupings
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
sort_order,
|
||||||
|
status_sort_order,
|
||||||
|
priority_sort_order,
|
||||||
|
phase_sort_order,
|
||||||
|
member_sort_order
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id = '<test-project-id>'
|
||||||
|
ORDER BY status_sort_order;
|
||||||
|
*/
|
||||||
@@ -0,0 +1,300 @@
|
|||||||
|
-- Fix Duplicate Sort Orders Script
|
||||||
|
-- This script detects and fixes duplicate sort order values that break task ordering
|
||||||
|
|
||||||
|
-- 1. DETECTION QUERIES - Run these first to see the scope of the problem
|
||||||
|
|
||||||
|
-- Check for duplicates in main sort_order column
|
||||||
|
SELECT
|
||||||
|
project_id,
|
||||||
|
sort_order,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
STRING_AGG(id::text, ', ') as task_ids
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
GROUP BY project_id, sort_order
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
ORDER BY project_id, sort_order;
|
||||||
|
|
||||||
|
-- Check for duplicates in status_sort_order
|
||||||
|
SELECT
|
||||||
|
project_id,
|
||||||
|
status_sort_order,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
STRING_AGG(id::text, ', ') as task_ids
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
GROUP BY project_id, status_sort_order
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
ORDER BY project_id, status_sort_order;
|
||||||
|
|
||||||
|
-- Check for duplicates in priority_sort_order
|
||||||
|
SELECT
|
||||||
|
project_id,
|
||||||
|
priority_sort_order,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
STRING_AGG(id::text, ', ') as task_ids
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
GROUP BY project_id, priority_sort_order
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
ORDER BY project_id, priority_sort_order;
|
||||||
|
|
||||||
|
-- Check for duplicates in phase_sort_order
|
||||||
|
SELECT
|
||||||
|
project_id,
|
||||||
|
phase_sort_order,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
STRING_AGG(id::text, ', ') as task_ids
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
GROUP BY project_id, phase_sort_order
|
||||||
|
HAVING COUNT(*) > 1
|
||||||
|
ORDER BY project_id, phase_sort_order;
|
||||||
|
|
||||||
|
-- Note: member_sort_order removed - no longer used
|
||||||
|
|
||||||
|
-- 2. CLEANUP FUNCTIONS
|
||||||
|
|
||||||
|
-- Fix duplicates in main sort_order column
|
||||||
|
CREATE OR REPLACE FUNCTION fix_sort_order_duplicates() RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_project RECORD;
|
||||||
|
_task RECORD;
|
||||||
|
_counter INTEGER;
|
||||||
|
BEGIN
|
||||||
|
-- For each project, reassign sort_order values to ensure uniqueness
|
||||||
|
FOR _project IN
|
||||||
|
SELECT DISTINCT project_id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
LOOP
|
||||||
|
_counter := 0;
|
||||||
|
|
||||||
|
-- Reassign sort_order values sequentially for this project
|
||||||
|
FOR _task IN
|
||||||
|
SELECT id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id = _project.project_id
|
||||||
|
ORDER BY sort_order, created_at
|
||||||
|
LOOP
|
||||||
|
UPDATE tasks
|
||||||
|
SET sort_order = _counter
|
||||||
|
WHERE id = _task.id;
|
||||||
|
|
||||||
|
_counter := _counter + 1;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RAISE NOTICE 'Fixed sort_order duplicates for all projects';
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Fix duplicates in status_sort_order column
|
||||||
|
CREATE OR REPLACE FUNCTION fix_status_sort_order_duplicates() RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_project RECORD;
|
||||||
|
_task RECORD;
|
||||||
|
_counter INTEGER;
|
||||||
|
BEGIN
|
||||||
|
FOR _project IN
|
||||||
|
SELECT DISTINCT project_id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
LOOP
|
||||||
|
_counter := 0;
|
||||||
|
|
||||||
|
FOR _task IN
|
||||||
|
SELECT id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id = _project.project_id
|
||||||
|
ORDER BY status_sort_order, created_at
|
||||||
|
LOOP
|
||||||
|
UPDATE tasks
|
||||||
|
SET status_sort_order = _counter
|
||||||
|
WHERE id = _task.id;
|
||||||
|
|
||||||
|
_counter := _counter + 1;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RAISE NOTICE 'Fixed status_sort_order duplicates for all projects';
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Fix duplicates in priority_sort_order column
|
||||||
|
CREATE OR REPLACE FUNCTION fix_priority_sort_order_duplicates() RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_project RECORD;
|
||||||
|
_task RECORD;
|
||||||
|
_counter INTEGER;
|
||||||
|
BEGIN
|
||||||
|
FOR _project IN
|
||||||
|
SELECT DISTINCT project_id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
LOOP
|
||||||
|
_counter := 0;
|
||||||
|
|
||||||
|
FOR _task IN
|
||||||
|
SELECT id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id = _project.project_id
|
||||||
|
ORDER BY priority_sort_order, created_at
|
||||||
|
LOOP
|
||||||
|
UPDATE tasks
|
||||||
|
SET priority_sort_order = _counter
|
||||||
|
WHERE id = _task.id;
|
||||||
|
|
||||||
|
_counter := _counter + 1;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RAISE NOTICE 'Fixed priority_sort_order duplicates for all projects';
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Fix duplicates in phase_sort_order column
|
||||||
|
CREATE OR REPLACE FUNCTION fix_phase_sort_order_duplicates() RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_project RECORD;
|
||||||
|
_task RECORD;
|
||||||
|
_counter INTEGER;
|
||||||
|
BEGIN
|
||||||
|
FOR _project IN
|
||||||
|
SELECT DISTINCT project_id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
LOOP
|
||||||
|
_counter := 0;
|
||||||
|
|
||||||
|
FOR _task IN
|
||||||
|
SELECT id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id = _project.project_id
|
||||||
|
ORDER BY phase_sort_order, created_at
|
||||||
|
LOOP
|
||||||
|
UPDATE tasks
|
||||||
|
SET phase_sort_order = _counter
|
||||||
|
WHERE id = _task.id;
|
||||||
|
|
||||||
|
_counter := _counter + 1;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RAISE NOTICE 'Fixed phase_sort_order duplicates for all projects';
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Note: fix_member_sort_order_duplicates() removed - no longer needed
|
||||||
|
|
||||||
|
-- Master function to fix all sort order duplicates
|
||||||
|
CREATE OR REPLACE FUNCTION fix_all_duplicate_sort_orders() RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
RAISE NOTICE 'Starting sort order cleanup for all columns...';
|
||||||
|
|
||||||
|
PERFORM fix_sort_order_duplicates();
|
||||||
|
PERFORM fix_status_sort_order_duplicates();
|
||||||
|
PERFORM fix_priority_sort_order_duplicates();
|
||||||
|
PERFORM fix_phase_sort_order_duplicates();
|
||||||
|
|
||||||
|
RAISE NOTICE 'Completed sort order cleanup for all columns';
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- 3. VERIFICATION FUNCTION
|
||||||
|
|
||||||
|
-- Verify that duplicates have been fixed
|
||||||
|
CREATE OR REPLACE FUNCTION verify_sort_order_integrity() RETURNS TABLE(
|
||||||
|
column_name text,
|
||||||
|
project_id uuid,
|
||||||
|
duplicate_count bigint,
|
||||||
|
status text
|
||||||
|
)
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
-- Check sort_order duplicates
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT
|
||||||
|
'sort_order'::text as column_name,
|
||||||
|
t.project_id,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
CASE WHEN COUNT(*) > 1 THEN 'DUPLICATES FOUND' ELSE 'OK' END as status
|
||||||
|
FROM tasks t
|
||||||
|
WHERE t.project_id IS NOT NULL
|
||||||
|
GROUP BY t.project_id, t.sort_order
|
||||||
|
HAVING COUNT(*) > 1;
|
||||||
|
|
||||||
|
-- Check status_sort_order duplicates
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT
|
||||||
|
'status_sort_order'::text as column_name,
|
||||||
|
t.project_id,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
CASE WHEN COUNT(*) > 1 THEN 'DUPLICATES FOUND' ELSE 'OK' END as status
|
||||||
|
FROM tasks t
|
||||||
|
WHERE t.project_id IS NOT NULL
|
||||||
|
GROUP BY t.project_id, t.status_sort_order
|
||||||
|
HAVING COUNT(*) > 1;
|
||||||
|
|
||||||
|
-- Check priority_sort_order duplicates
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT
|
||||||
|
'priority_sort_order'::text as column_name,
|
||||||
|
t.project_id,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
CASE WHEN COUNT(*) > 1 THEN 'DUPLICATES FOUND' ELSE 'OK' END as status
|
||||||
|
FROM tasks t
|
||||||
|
WHERE t.project_id IS NOT NULL
|
||||||
|
GROUP BY t.project_id, t.priority_sort_order
|
||||||
|
HAVING COUNT(*) > 1;
|
||||||
|
|
||||||
|
-- Check phase_sort_order duplicates
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT
|
||||||
|
'phase_sort_order'::text as column_name,
|
||||||
|
t.project_id,
|
||||||
|
COUNT(*) as duplicate_count,
|
||||||
|
CASE WHEN COUNT(*) > 1 THEN 'DUPLICATES FOUND' ELSE 'OK' END as status
|
||||||
|
FROM tasks t
|
||||||
|
WHERE t.project_id IS NOT NULL
|
||||||
|
GROUP BY t.project_id, t.phase_sort_order
|
||||||
|
HAVING COUNT(*) > 1;
|
||||||
|
|
||||||
|
-- Note: member_sort_order verification removed - column no longer used
|
||||||
|
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- 4. USAGE INSTRUCTIONS
|
||||||
|
|
||||||
|
/*
|
||||||
|
USAGE:
|
||||||
|
|
||||||
|
1. First, run the detection queries to see which projects have duplicates
|
||||||
|
2. Then run this to fix all duplicates:
|
||||||
|
SELECT fix_all_duplicate_sort_orders();
|
||||||
|
3. Finally, verify the fix worked:
|
||||||
|
SELECT * FROM verify_sort_order_integrity();
|
||||||
|
|
||||||
|
If verification returns no rows, all duplicates have been fixed successfully.
|
||||||
|
|
||||||
|
WARNING: This will reassign sort order values based on current order + creation time.
|
||||||
|
Make sure to backup your database before running these functions.
|
||||||
|
*/
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
-- Migration: Add separate sort order columns for different grouping types
|
||||||
|
-- This allows users to maintain different task orders when switching between grouping views
|
||||||
|
|
||||||
|
-- Add new sort order columns
|
||||||
|
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS status_sort_order INTEGER DEFAULT 0;
|
||||||
|
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS priority_sort_order INTEGER DEFAULT 0;
|
||||||
|
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS phase_sort_order INTEGER DEFAULT 0;
|
||||||
|
ALTER TABLE tasks ADD COLUMN IF NOT EXISTS member_sort_order INTEGER DEFAULT 0;
|
||||||
|
|
||||||
|
-- Initialize new columns with current sort_order values
|
||||||
|
UPDATE tasks SET
|
||||||
|
status_sort_order = sort_order,
|
||||||
|
priority_sort_order = sort_order,
|
||||||
|
phase_sort_order = sort_order,
|
||||||
|
member_sort_order = sort_order
|
||||||
|
WHERE status_sort_order = 0
|
||||||
|
OR priority_sort_order = 0
|
||||||
|
OR phase_sort_order = 0
|
||||||
|
OR member_sort_order = 0;
|
||||||
|
|
||||||
|
-- Add constraints to ensure non-negative values
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_status_sort_order_check CHECK (status_sort_order >= 0);
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_priority_sort_order_check CHECK (priority_sort_order >= 0);
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_phase_sort_order_check CHECK (phase_sort_order >= 0);
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_member_sort_order_check CHECK (member_sort_order >= 0);
|
||||||
|
|
||||||
|
-- Add indexes for performance (since these will be used for ordering)
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_tasks_status_sort_order ON tasks(project_id, status_sort_order);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_tasks_priority_sort_order ON tasks(project_id, priority_sort_order);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_tasks_phase_sort_order ON tasks(project_id, phase_sort_order);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_tasks_member_sort_order ON tasks(project_id, member_sort_order);
|
||||||
|
|
||||||
|
-- Update comments for documentation
|
||||||
|
COMMENT ON COLUMN tasks.status_sort_order IS 'Sort order when grouped by status';
|
||||||
|
COMMENT ON COLUMN tasks.priority_sort_order IS 'Sort order when grouped by priority';
|
||||||
|
COMMENT ON COLUMN tasks.phase_sort_order IS 'Sort order when grouped by phase';
|
||||||
|
COMMENT ON COLUMN tasks.member_sort_order IS 'Sort order when grouped by members/assignees';
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
-- Migration: Update database functions to handle grouping-specific sort orders
|
||||||
|
|
||||||
|
-- Function to get the appropriate sort column name based on grouping type
|
||||||
|
CREATE OR REPLACE FUNCTION get_sort_column_name(_group_by TEXT) RETURNS TEXT
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
CASE _group_by
|
||||||
|
WHEN 'status' THEN RETURN 'status_sort_order';
|
||||||
|
WHEN 'priority' THEN RETURN 'priority_sort_order';
|
||||||
|
WHEN 'phase' THEN RETURN 'phase_sort_order';
|
||||||
|
WHEN 'members' THEN RETURN 'member_sort_order';
|
||||||
|
ELSE RETURN 'sort_order'; -- fallback to general sort_order
|
||||||
|
END CASE;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Updated bulk sort order function to handle different sort columns
|
||||||
|
CREATE OR REPLACE FUNCTION update_task_sort_orders_bulk(_updates json, _group_by text DEFAULT 'status') RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_update_record RECORD;
|
||||||
|
_sort_column TEXT;
|
||||||
|
_sql TEXT;
|
||||||
|
BEGIN
|
||||||
|
-- Get the appropriate sort column based on grouping
|
||||||
|
_sort_column := get_sort_column_name(_group_by);
|
||||||
|
|
||||||
|
-- Simple approach: update each task's sort_order from the provided array
|
||||||
|
FOR _update_record IN
|
||||||
|
SELECT
|
||||||
|
(item->>'task_id')::uuid as task_id,
|
||||||
|
(item->>'sort_order')::int as sort_order,
|
||||||
|
(item->>'status_id')::uuid as status_id,
|
||||||
|
(item->>'priority_id')::uuid as priority_id,
|
||||||
|
(item->>'phase_id')::uuid as phase_id
|
||||||
|
FROM json_array_elements(_updates) as item
|
||||||
|
LOOP
|
||||||
|
-- Update the appropriate sort column and other fields using dynamic SQL
|
||||||
|
-- Only update sort_order if we're using the default sorting
|
||||||
|
IF _sort_column = 'sort_order' THEN
|
||||||
|
UPDATE tasks SET
|
||||||
|
sort_order = _update_record.sort_order,
|
||||||
|
status_id = COALESCE(_update_record.status_id, status_id),
|
||||||
|
priority_id = COALESCE(_update_record.priority_id, priority_id)
|
||||||
|
WHERE id = _update_record.task_id;
|
||||||
|
ELSE
|
||||||
|
-- Update only the grouping-specific sort column, not the main sort_order
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = $1, ' ||
|
||||||
|
'status_id = COALESCE($2, status_id), ' ||
|
||||||
|
'priority_id = COALESCE($3, priority_id) ' ||
|
||||||
|
'WHERE id = $4';
|
||||||
|
|
||||||
|
EXECUTE _sql USING
|
||||||
|
_update_record.sort_order,
|
||||||
|
_update_record.status_id,
|
||||||
|
_update_record.priority_id,
|
||||||
|
_update_record.task_id;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Handle phase updates separately since it's in a different table
|
||||||
|
IF _update_record.phase_id IS NOT NULL THEN
|
||||||
|
INSERT INTO task_phase (task_id, phase_id)
|
||||||
|
VALUES (_update_record.task_id, _update_record.phase_id)
|
||||||
|
ON CONFLICT (task_id) DO UPDATE SET phase_id = _update_record.phase_id;
|
||||||
|
END IF;
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Updated main sort order change handler
|
||||||
|
CREATE OR REPLACE FUNCTION handle_task_list_sort_order_change(_body json) RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_from_index INT;
|
||||||
|
_to_index INT;
|
||||||
|
_task_id UUID;
|
||||||
|
_project_id UUID;
|
||||||
|
_from_group UUID;
|
||||||
|
_to_group UUID;
|
||||||
|
_group_by TEXT;
|
||||||
|
_batch_size INT := 100;
|
||||||
|
_sort_column TEXT;
|
||||||
|
_sql TEXT;
|
||||||
|
BEGIN
|
||||||
|
_project_id = (_body ->> 'project_id')::UUID;
|
||||||
|
_task_id = (_body ->> 'task_id')::UUID;
|
||||||
|
_from_index = (_body ->> 'from_index')::INT;
|
||||||
|
_to_index = (_body ->> 'to_index')::INT;
|
||||||
|
_from_group = (_body ->> 'from_group')::UUID;
|
||||||
|
_to_group = (_body ->> 'to_group')::UUID;
|
||||||
|
_group_by = (_body ->> 'group_by')::TEXT;
|
||||||
|
|
||||||
|
-- Get the appropriate sort column
|
||||||
|
_sort_column := get_sort_column_name(_group_by);
|
||||||
|
|
||||||
|
-- Handle group changes
|
||||||
|
IF (_from_group <> _to_group OR (_from_group <> _to_group) IS NULL) THEN
|
||||||
|
IF (_group_by = 'status') THEN
|
||||||
|
UPDATE tasks
|
||||||
|
SET status_id = _to_group
|
||||||
|
WHERE id = _task_id
|
||||||
|
AND status_id = _from_group
|
||||||
|
AND project_id = _project_id;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF (_group_by = 'priority') THEN
|
||||||
|
UPDATE tasks
|
||||||
|
SET priority_id = _to_group
|
||||||
|
WHERE id = _task_id
|
||||||
|
AND priority_id = _from_group
|
||||||
|
AND project_id = _project_id;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF (_group_by = 'phase') THEN
|
||||||
|
IF (is_null_or_empty(_to_group) IS FALSE) THEN
|
||||||
|
INSERT INTO task_phase (task_id, phase_id)
|
||||||
|
VALUES (_task_id, _to_group)
|
||||||
|
ON CONFLICT (task_id) DO UPDATE SET phase_id = _to_group;
|
||||||
|
ELSE
|
||||||
|
DELETE FROM task_phase WHERE task_id = _task_id;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Handle sort order changes using dynamic SQL
|
||||||
|
IF (_from_index <> _to_index) THEN
|
||||||
|
-- For the main sort_order column, we need to be careful about unique constraints
|
||||||
|
IF _sort_column = 'sort_order' THEN
|
||||||
|
-- Use a transaction-safe approach for the main sort_order column
|
||||||
|
IF (_to_index > _from_index) THEN
|
||||||
|
-- Moving down: decrease sort_order for items between old and new position
|
||||||
|
UPDATE tasks SET sort_order = sort_order - 1
|
||||||
|
WHERE project_id = _project_id
|
||||||
|
AND sort_order > _from_index
|
||||||
|
AND sort_order <= _to_index;
|
||||||
|
ELSE
|
||||||
|
-- Moving up: increase sort_order for items between new and old position
|
||||||
|
UPDATE tasks SET sort_order = sort_order + 1
|
||||||
|
WHERE project_id = _project_id
|
||||||
|
AND sort_order >= _to_index
|
||||||
|
AND sort_order < _from_index;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Set the new sort_order for the moved task
|
||||||
|
UPDATE tasks SET sort_order = _to_index WHERE id = _task_id;
|
||||||
|
ELSE
|
||||||
|
-- For grouping-specific columns, use dynamic SQL since there's no unique constraint
|
||||||
|
IF (_to_index > _from_index) THEN
|
||||||
|
-- Moving down: decrease sort_order for items between old and new position
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = ' || _sort_column || ' - 1 ' ||
|
||||||
|
'WHERE project_id = $1 AND ' || _sort_column || ' > $2 AND ' || _sort_column || ' <= $3';
|
||||||
|
EXECUTE _sql USING _project_id, _from_index, _to_index;
|
||||||
|
ELSE
|
||||||
|
-- Moving up: increase sort_order for items between new and old position
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = ' || _sort_column || ' + 1 ' ||
|
||||||
|
'WHERE project_id = $1 AND ' || _sort_column || ' >= $2 AND ' || _sort_column || ' < $3';
|
||||||
|
EXECUTE _sql USING _project_id, _to_index, _from_index;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Set the new sort_order for the moved task
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = $1 WHERE id = $2';
|
||||||
|
EXECUTE _sql USING _to_index, _task_id;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
-- Migration: Fix sort order constraint violations
|
||||||
|
|
||||||
|
-- First, let's ensure all existing tasks have unique sort_order values within each project
|
||||||
|
-- This is a one-time fix to ensure data consistency
|
||||||
|
|
||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
_project RECORD;
|
||||||
|
_task RECORD;
|
||||||
|
_counter INTEGER;
|
||||||
|
BEGIN
|
||||||
|
-- For each project, reassign sort_order values to ensure uniqueness
|
||||||
|
FOR _project IN
|
||||||
|
SELECT DISTINCT project_id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id IS NOT NULL
|
||||||
|
LOOP
|
||||||
|
_counter := 0;
|
||||||
|
|
||||||
|
-- Reassign sort_order values sequentially for this project
|
||||||
|
FOR _task IN
|
||||||
|
SELECT id
|
||||||
|
FROM tasks
|
||||||
|
WHERE project_id = _project.project_id
|
||||||
|
ORDER BY sort_order, created_at
|
||||||
|
LOOP
|
||||||
|
UPDATE tasks
|
||||||
|
SET sort_order = _counter
|
||||||
|
WHERE id = _task.id;
|
||||||
|
|
||||||
|
_counter := _counter + 1;
|
||||||
|
END LOOP;
|
||||||
|
END LOOP;
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Now create a better version of our functions that properly handles the constraints
|
||||||
|
|
||||||
|
-- Updated bulk sort order function that avoids sort_order conflicts
|
||||||
|
CREATE OR REPLACE FUNCTION update_task_sort_orders_bulk(_updates json, _group_by text DEFAULT 'status') RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_update_record RECORD;
|
||||||
|
_sort_column TEXT;
|
||||||
|
_sql TEXT;
|
||||||
|
BEGIN
|
||||||
|
-- Get the appropriate sort column based on grouping
|
||||||
|
_sort_column := get_sort_column_name(_group_by);
|
||||||
|
|
||||||
|
-- Process each update record
|
||||||
|
FOR _update_record IN
|
||||||
|
SELECT
|
||||||
|
(item->>'task_id')::uuid as task_id,
|
||||||
|
(item->>'sort_order')::int as sort_order,
|
||||||
|
(item->>'status_id')::uuid as status_id,
|
||||||
|
(item->>'priority_id')::uuid as priority_id,
|
||||||
|
(item->>'phase_id')::uuid as phase_id
|
||||||
|
FROM json_array_elements(_updates) as item
|
||||||
|
LOOP
|
||||||
|
-- Update the grouping-specific sort column and other fields
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = $1, ' ||
|
||||||
|
'status_id = COALESCE($2, status_id), ' ||
|
||||||
|
'priority_id = COALESCE($3, priority_id), ' ||
|
||||||
|
'updated_at = CURRENT_TIMESTAMP ' ||
|
||||||
|
'WHERE id = $4';
|
||||||
|
|
||||||
|
EXECUTE _sql USING
|
||||||
|
_update_record.sort_order,
|
||||||
|
_update_record.status_id,
|
||||||
|
_update_record.priority_id,
|
||||||
|
_update_record.task_id;
|
||||||
|
|
||||||
|
-- Handle phase updates separately since it's in a different table
|
||||||
|
IF _update_record.phase_id IS NOT NULL THEN
|
||||||
|
INSERT INTO task_phase (task_id, phase_id)
|
||||||
|
VALUES (_update_record.task_id, _update_record.phase_id)
|
||||||
|
ON CONFLICT (task_id) DO UPDATE SET phase_id = _update_record.phase_id;
|
||||||
|
END IF;
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Also update the helper function to be more explicit
|
||||||
|
CREATE OR REPLACE FUNCTION get_sort_column_name(_group_by TEXT) RETURNS TEXT
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
CASE _group_by
|
||||||
|
WHEN 'status' THEN RETURN 'status_sort_order';
|
||||||
|
WHEN 'priority' THEN RETURN 'priority_sort_order';
|
||||||
|
WHEN 'phase' THEN RETURN 'phase_sort_order';
|
||||||
|
WHEN 'members' THEN RETURN 'member_sort_order';
|
||||||
|
-- For backward compatibility, still support general sort_order but be explicit
|
||||||
|
WHEN 'general' THEN RETURN 'sort_order';
|
||||||
|
ELSE RETURN 'status_sort_order'; -- Default to status sorting
|
||||||
|
END CASE;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Updated main sort order change handler that avoids conflicts
|
||||||
|
CREATE OR REPLACE FUNCTION handle_task_list_sort_order_change(_body json) RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_from_index INT;
|
||||||
|
_to_index INT;
|
||||||
|
_task_id UUID;
|
||||||
|
_project_id UUID;
|
||||||
|
_from_group UUID;
|
||||||
|
_to_group UUID;
|
||||||
|
_group_by TEXT;
|
||||||
|
_sort_column TEXT;
|
||||||
|
_sql TEXT;
|
||||||
|
BEGIN
|
||||||
|
_project_id = (_body ->> 'project_id')::UUID;
|
||||||
|
_task_id = (_body ->> 'task_id')::UUID;
|
||||||
|
_from_index = (_body ->> 'from_index')::INT;
|
||||||
|
_to_index = (_body ->> 'to_index')::INT;
|
||||||
|
_from_group = (_body ->> 'from_group')::UUID;
|
||||||
|
_to_group = (_body ->> 'to_group')::UUID;
|
||||||
|
_group_by = (_body ->> 'group_by')::TEXT;
|
||||||
|
|
||||||
|
-- Get the appropriate sort column
|
||||||
|
_sort_column := get_sort_column_name(_group_by);
|
||||||
|
|
||||||
|
-- Handle group changes first
|
||||||
|
IF (_from_group <> _to_group OR (_from_group <> _to_group) IS NULL) THEN
|
||||||
|
IF (_group_by = 'status') THEN
|
||||||
|
UPDATE tasks
|
||||||
|
SET status_id = _to_group, updated_at = CURRENT_TIMESTAMP
|
||||||
|
WHERE id = _task_id
|
||||||
|
AND project_id = _project_id;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF (_group_by = 'priority') THEN
|
||||||
|
UPDATE tasks
|
||||||
|
SET priority_id = _to_group, updated_at = CURRENT_TIMESTAMP
|
||||||
|
WHERE id = _task_id
|
||||||
|
AND project_id = _project_id;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
IF (_group_by = 'phase') THEN
|
||||||
|
IF (is_null_or_empty(_to_group) IS FALSE) THEN
|
||||||
|
INSERT INTO task_phase (task_id, phase_id)
|
||||||
|
VALUES (_task_id, _to_group)
|
||||||
|
ON CONFLICT (task_id) DO UPDATE SET phase_id = _to_group;
|
||||||
|
ELSE
|
||||||
|
DELETE FROM task_phase WHERE task_id = _task_id;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Handle sort order changes for the grouping-specific column only
|
||||||
|
IF (_from_index <> _to_index) THEN
|
||||||
|
-- Update the grouping-specific sort order (no unique constraint issues)
|
||||||
|
IF (_to_index > _from_index) THEN
|
||||||
|
-- Moving down: decrease sort order for items between old and new position
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = ' || _sort_column || ' - 1, ' ||
|
||||||
|
'updated_at = CURRENT_TIMESTAMP ' ||
|
||||||
|
'WHERE project_id = $1 AND ' || _sort_column || ' > $2 AND ' || _sort_column || ' <= $3';
|
||||||
|
EXECUTE _sql USING _project_id, _from_index, _to_index;
|
||||||
|
ELSE
|
||||||
|
-- Moving up: increase sort order for items between new and old position
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = ' || _sort_column || ' + 1, ' ||
|
||||||
|
'updated_at = CURRENT_TIMESTAMP ' ||
|
||||||
|
'WHERE project_id = $1 AND ' || _sort_column || ' >= $2 AND ' || _sort_column || ' < $3';
|
||||||
|
EXECUTE _sql USING _project_id, _to_index, _from_index;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
-- Set the new sort order for the moved task
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2';
|
||||||
|
EXECUTE _sql USING _to_index, _task_id;
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
@@ -1410,6 +1410,9 @@ CREATE TABLE IF NOT EXISTS tasks (
|
|||||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
||||||
sort_order INTEGER DEFAULT 0 NOT NULL,
|
sort_order INTEGER DEFAULT 0 NOT NULL,
|
||||||
roadmap_sort_order INTEGER DEFAULT 0 NOT NULL,
|
roadmap_sort_order INTEGER DEFAULT 0 NOT NULL,
|
||||||
|
status_sort_order INTEGER DEFAULT 0 NOT NULL,
|
||||||
|
priority_sort_order INTEGER DEFAULT 0 NOT NULL,
|
||||||
|
phase_sort_order INTEGER DEFAULT 0 NOT NULL,
|
||||||
billable BOOLEAN DEFAULT TRUE,
|
billable BOOLEAN DEFAULT TRUE,
|
||||||
schedule_id UUID
|
schedule_id UUID
|
||||||
);
|
);
|
||||||
@@ -1499,6 +1502,21 @@ ALTER TABLE tasks
|
|||||||
ADD CONSTRAINT tasks_total_minutes_check
|
ADD CONSTRAINT tasks_total_minutes_check
|
||||||
CHECK ((total_minutes >= (0)::NUMERIC) AND (total_minutes <= (999999)::NUMERIC));
|
CHECK ((total_minutes >= (0)::NUMERIC) AND (total_minutes <= (999999)::NUMERIC));
|
||||||
|
|
||||||
|
-- Add constraints for new sort order columns
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_status_sort_order_check CHECK (status_sort_order >= 0);
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_priority_sort_order_check CHECK (priority_sort_order >= 0);
|
||||||
|
ALTER TABLE tasks ADD CONSTRAINT tasks_phase_sort_order_check CHECK (phase_sort_order >= 0);
|
||||||
|
|
||||||
|
-- Add indexes for performance on new sort order columns
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_tasks_status_sort_order ON tasks(project_id, status_sort_order);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_tasks_priority_sort_order ON tasks(project_id, priority_sort_order);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_tasks_phase_sort_order ON tasks(project_id, phase_sort_order);
|
||||||
|
|
||||||
|
-- Add comments for documentation
|
||||||
|
COMMENT ON COLUMN tasks.status_sort_order IS 'Sort order when grouped by status';
|
||||||
|
COMMENT ON COLUMN tasks.priority_sort_order IS 'Sort order when grouped by priority';
|
||||||
|
COMMENT ON COLUMN tasks.phase_sort_order IS 'Sort order when grouped by phase';
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS tasks_assignees (
|
CREATE TABLE IF NOT EXISTS tasks_assignees (
|
||||||
task_id UUID NOT NULL,
|
task_id UUID NOT NULL,
|
||||||
project_member_id UUID NOT NULL,
|
project_member_id UUID NOT NULL,
|
||||||
|
|||||||
@@ -4313,6 +4313,24 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
-- Helper function to get the appropriate sort column name based on grouping type
|
||||||
|
CREATE OR REPLACE FUNCTION get_sort_column_name(_group_by TEXT) RETURNS TEXT
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
CASE _group_by
|
||||||
|
WHEN 'status' THEN RETURN 'status_sort_order';
|
||||||
|
WHEN 'priority' THEN RETURN 'priority_sort_order';
|
||||||
|
WHEN 'phase' THEN RETURN 'phase_sort_order';
|
||||||
|
WHEN 'members' THEN RETURN 'member_sort_order';
|
||||||
|
-- For backward compatibility, still support general sort_order but be explicit
|
||||||
|
WHEN 'general' THEN RETURN 'sort_order';
|
||||||
|
ELSE RETURN 'status_sort_order'; -- Default to status sorting
|
||||||
|
END CASE;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION handle_task_list_sort_order_change(_body json) RETURNS void
|
CREATE OR REPLACE FUNCTION handle_task_list_sort_order_change(_body json) RETURNS void
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS
|
AS
|
||||||
@@ -4325,66 +4343,67 @@ DECLARE
|
|||||||
_from_group UUID;
|
_from_group UUID;
|
||||||
_to_group UUID;
|
_to_group UUID;
|
||||||
_group_by TEXT;
|
_group_by TEXT;
|
||||||
_batch_size INT := 100; -- PERFORMANCE OPTIMIZATION: Batch size for large updates
|
_sort_column TEXT;
|
||||||
|
_sql TEXT;
|
||||||
BEGIN
|
BEGIN
|
||||||
_project_id = (_body ->> 'project_id')::UUID;
|
_project_id = (_body ->> 'project_id')::UUID;
|
||||||
_task_id = (_body ->> 'task_id')::UUID;
|
_task_id = (_body ->> 'task_id')::UUID;
|
||||||
|
_from_index = (_body ->> 'from_index')::INT;
|
||||||
_from_index = (_body ->> 'from_index')::INT; -- from sort_order
|
_to_index = (_body ->> 'to_index')::INT;
|
||||||
_to_index = (_body ->> 'to_index')::INT; -- to sort_order
|
|
||||||
|
|
||||||
_from_group = (_body ->> 'from_group')::UUID;
|
_from_group = (_body ->> 'from_group')::UUID;
|
||||||
_to_group = (_body ->> 'to_group')::UUID;
|
_to_group = (_body ->> 'to_group')::UUID;
|
||||||
|
|
||||||
_group_by = (_body ->> 'group_by')::TEXT;
|
_group_by = (_body ->> 'group_by')::TEXT;
|
||||||
|
|
||||||
-- PERFORMANCE OPTIMIZATION: Use CTE for better query planning
|
-- Get the appropriate sort column
|
||||||
IF (_from_group <> _to_group OR (_from_group <> _to_group) IS NULL)
|
_sort_column := get_sort_column_name(_group_by);
|
||||||
THEN
|
|
||||||
-- PERFORMANCE OPTIMIZATION: Batch update group changes
|
-- Handle group changes first
|
||||||
IF (_group_by = 'status')
|
IF (_from_group <> _to_group OR (_from_group <> _to_group) IS NULL) THEN
|
||||||
THEN
|
IF (_group_by = 'status') THEN
|
||||||
UPDATE tasks
|
UPDATE tasks
|
||||||
SET status_id = _to_group
|
SET status_id = _to_group, updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE id = _task_id
|
WHERE id = _task_id
|
||||||
AND status_id = _from_group
|
|
||||||
AND project_id = _project_id;
|
AND project_id = _project_id;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF (_group_by = 'priority')
|
IF (_group_by = 'priority') THEN
|
||||||
THEN
|
|
||||||
UPDATE tasks
|
UPDATE tasks
|
||||||
SET priority_id = _to_group
|
SET priority_id = _to_group, updated_at = CURRENT_TIMESTAMP
|
||||||
WHERE id = _task_id
|
WHERE id = _task_id
|
||||||
AND priority_id = _from_group
|
|
||||||
AND project_id = _project_id;
|
AND project_id = _project_id;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
IF (_group_by = 'phase')
|
IF (_group_by = 'phase') THEN
|
||||||
THEN
|
IF (is_null_or_empty(_to_group) IS FALSE) THEN
|
||||||
IF (is_null_or_empty(_to_group) IS FALSE)
|
|
||||||
THEN
|
|
||||||
INSERT INTO task_phase (task_id, phase_id)
|
INSERT INTO task_phase (task_id, phase_id)
|
||||||
VALUES (_task_id, _to_group)
|
VALUES (_task_id, _to_group)
|
||||||
ON CONFLICT (task_id) DO UPDATE SET phase_id = _to_group;
|
ON CONFLICT (task_id) DO UPDATE SET phase_id = _to_group;
|
||||||
|
ELSE
|
||||||
|
DELETE FROM task_phase WHERE task_id = _task_id;
|
||||||
END IF;
|
END IF;
|
||||||
IF (is_null_or_empty(_to_group) IS TRUE)
|
|
||||||
THEN
|
|
||||||
DELETE
|
|
||||||
FROM task_phase
|
|
||||||
WHERE task_id = _task_id;
|
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- PERFORMANCE OPTIMIZATION: Optimized sort order handling
|
-- Handle sort order changes for the grouping-specific column only
|
||||||
IF ((_body ->> 'to_last_index')::BOOLEAN IS TRUE AND _from_index < _to_index)
|
IF (_from_index <> _to_index) THEN
|
||||||
THEN
|
-- Update the grouping-specific sort order (no unique constraint issues)
|
||||||
PERFORM handle_task_list_sort_inside_group_optimized(_from_index, _to_index, _task_id, _project_id, _batch_size);
|
IF (_to_index > _from_index) THEN
|
||||||
|
-- Moving down: decrease sort order for items between old and new position
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = ' || _sort_column || ' - 1, ' ||
|
||||||
|
'updated_at = CURRENT_TIMESTAMP ' ||
|
||||||
|
'WHERE project_id = $1 AND ' || _sort_column || ' > $2 AND ' || _sort_column || ' <= $3';
|
||||||
|
EXECUTE _sql USING _project_id, _from_index, _to_index;
|
||||||
ELSE
|
ELSE
|
||||||
PERFORM handle_task_list_sort_between_groups_optimized(_from_index, _to_index, _task_id, _project_id, _batch_size);
|
-- Moving up: increase sort order for items between new and old position
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = ' || _sort_column || ' + 1, ' ||
|
||||||
|
'updated_at = CURRENT_TIMESTAMP ' ||
|
||||||
|
'WHERE project_id = $1 AND ' || _sort_column || ' >= $2 AND ' || _sort_column || ' < $3';
|
||||||
|
EXECUTE _sql USING _project_id, _to_index, _from_index;
|
||||||
END IF;
|
END IF;
|
||||||
ELSE
|
|
||||||
PERFORM handle_task_list_sort_inside_group_optimized(_from_index, _to_index, _task_id, _project_id, _batch_size);
|
-- Set the new sort order for the moved task
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2';
|
||||||
|
EXECUTE _sql USING _to_index, _task_id;
|
||||||
END IF;
|
END IF;
|
||||||
END
|
END
|
||||||
$$;
|
$$;
|
||||||
@@ -4589,31 +4608,31 @@ BEGIN
|
|||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Progress', 'PROGRESS', 3, TRUE);
|
VALUES (_project_id, 'Progress', 'PROGRESS', 3, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Members', 'ASSIGNEES', 4, TRUE);
|
VALUES (_project_id, 'Status', 'STATUS', 4, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Labels', 'LABELS', 5, TRUE);
|
VALUES (_project_id, 'Members', 'ASSIGNEES', 5, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Status', 'STATUS', 6, TRUE);
|
VALUES (_project_id, 'Labels', 'LABELS', 6, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Priority', 'PRIORITY', 7, TRUE);
|
VALUES (_project_id, 'Phase', 'PHASE', 7, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Time Tracking', 'TIME_TRACKING', 8, TRUE);
|
VALUES (_project_id, 'Priority', 'PRIORITY', 8, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Estimation', 'ESTIMATION', 9, FALSE);
|
VALUES (_project_id, 'Time Tracking', 'TIME_TRACKING', 9, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Start Date', 'START_DATE', 10, FALSE);
|
VALUES (_project_id, 'Estimation', 'ESTIMATION', 10, FALSE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Due Date', 'DUE_DATE', 11, TRUE);
|
VALUES (_project_id, 'Start Date', 'START_DATE', 11, FALSE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Completed Date', 'COMPLETED_DATE', 12, FALSE);
|
VALUES (_project_id, 'Due Date', 'DUE_DATE', 12, TRUE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Created Date', 'CREATED_DATE', 13, FALSE);
|
VALUES (_project_id, 'Completed Date', 'COMPLETED_DATE', 13, FALSE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Last Updated', 'LAST_UPDATED', 14, FALSE);
|
VALUES (_project_id, 'Created Date', 'CREATED_DATE', 14, FALSE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Reporter', 'REPORTER', 15, FALSE);
|
VALUES (_project_id, 'Last Updated', 'LAST_UPDATED', 15, FALSE);
|
||||||
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
INSERT INTO project_task_list_cols (project_id, name, key, index, pinned)
|
||||||
VALUES (_project_id, 'Phase', 'PHASE', 16, FALSE);
|
VALUES (_project_id, 'Reporter', 'REPORTER', 16, FALSE);
|
||||||
END
|
END
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
@@ -6521,15 +6540,20 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
-- Simple function to update task sort orders in bulk
|
-- Updated bulk sort order function that avoids sort_order conflicts
|
||||||
CREATE OR REPLACE FUNCTION update_task_sort_orders_bulk(_updates json) RETURNS void
|
CREATE OR REPLACE FUNCTION update_task_sort_orders_bulk(_updates json, _group_by text DEFAULT 'status') RETURNS void
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS
|
AS
|
||||||
$$
|
$$
|
||||||
DECLARE
|
DECLARE
|
||||||
_update_record RECORD;
|
_update_record RECORD;
|
||||||
|
_sort_column TEXT;
|
||||||
|
_sql TEXT;
|
||||||
BEGIN
|
BEGIN
|
||||||
-- Simple approach: update each task's sort_order from the provided array
|
-- Get the appropriate sort column based on grouping
|
||||||
|
_sort_column := get_sort_column_name(_group_by);
|
||||||
|
|
||||||
|
-- Process each update record
|
||||||
FOR _update_record IN
|
FOR _update_record IN
|
||||||
SELECT
|
SELECT
|
||||||
(item->>'task_id')::uuid as task_id,
|
(item->>'task_id')::uuid as task_id,
|
||||||
@@ -6539,12 +6563,18 @@ BEGIN
|
|||||||
(item->>'phase_id')::uuid as phase_id
|
(item->>'phase_id')::uuid as phase_id
|
||||||
FROM json_array_elements(_updates) as item
|
FROM json_array_elements(_updates) as item
|
||||||
LOOP
|
LOOP
|
||||||
UPDATE tasks
|
-- Update the grouping-specific sort column and other fields
|
||||||
SET
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = $1, ' ||
|
||||||
sort_order = _update_record.sort_order,
|
'status_id = COALESCE($2, status_id), ' ||
|
||||||
status_id = COALESCE(_update_record.status_id, status_id),
|
'priority_id = COALESCE($3, priority_id), ' ||
|
||||||
priority_id = COALESCE(_update_record.priority_id, priority_id)
|
'updated_at = CURRENT_TIMESTAMP ' ||
|
||||||
WHERE id = _update_record.task_id;
|
'WHERE id = $4';
|
||||||
|
|
||||||
|
EXECUTE _sql USING
|
||||||
|
_update_record.sort_order,
|
||||||
|
_update_record.status_id,
|
||||||
|
_update_record.priority_id,
|
||||||
|
_update_record.task_id;
|
||||||
|
|
||||||
-- Handle phase updates separately since it's in a different table
|
-- Handle phase updates separately since it's in a different table
|
||||||
IF _update_record.phase_id IS NOT NULL THEN
|
IF _update_record.phase_id IS NOT NULL THEN
|
||||||
@@ -6555,3 +6585,66 @@ BEGIN
|
|||||||
END LOOP;
|
END LOOP;
|
||||||
END
|
END
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
-- Function to get the appropriate sort column name based on grouping type
|
||||||
|
CREATE OR REPLACE FUNCTION get_sort_column_name(_group_by TEXT) RETURNS TEXT
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
CASE _group_by
|
||||||
|
WHEN 'status' THEN RETURN 'status_sort_order';
|
||||||
|
WHEN 'priority' THEN RETURN 'priority_sort_order';
|
||||||
|
WHEN 'phase' THEN RETURN 'phase_sort_order';
|
||||||
|
-- For backward compatibility, still support general sort_order but be explicit
|
||||||
|
WHEN 'general' THEN RETURN 'sort_order';
|
||||||
|
ELSE RETURN 'status_sort_order'; -- Default to status sorting
|
||||||
|
END CASE;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
-- Updated bulk sort order function to handle different sort columns
|
||||||
|
CREATE OR REPLACE FUNCTION update_task_sort_orders_bulk(_updates json, _group_by text DEFAULT 'status') RETURNS void
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
AS
|
||||||
|
$$
|
||||||
|
DECLARE
|
||||||
|
_update_record RECORD;
|
||||||
|
_sort_column TEXT;
|
||||||
|
_sql TEXT;
|
||||||
|
BEGIN
|
||||||
|
-- Get the appropriate sort column based on grouping
|
||||||
|
_sort_column := get_sort_column_name(_group_by);
|
||||||
|
|
||||||
|
-- Process each update record
|
||||||
|
FOR _update_record IN
|
||||||
|
SELECT
|
||||||
|
(item->>'task_id')::uuid as task_id,
|
||||||
|
(item->>'sort_order')::int as sort_order,
|
||||||
|
(item->>'status_id')::uuid as status_id,
|
||||||
|
(item->>'priority_id')::uuid as priority_id,
|
||||||
|
(item->>'phase_id')::uuid as phase_id
|
||||||
|
FROM json_array_elements(_updates) as item
|
||||||
|
LOOP
|
||||||
|
-- Update the grouping-specific sort column and other fields
|
||||||
|
_sql := 'UPDATE tasks SET ' || _sort_column || ' = $1, ' ||
|
||||||
|
'status_id = COALESCE($2, status_id), ' ||
|
||||||
|
'priority_id = COALESCE($3, priority_id), ' ||
|
||||||
|
'updated_at = CURRENT_TIMESTAMP ' ||
|
||||||
|
'WHERE id = $4';
|
||||||
|
|
||||||
|
EXECUTE _sql USING
|
||||||
|
_update_record.sort_order,
|
||||||
|
_update_record.status_id,
|
||||||
|
_update_record.priority_id,
|
||||||
|
_update_record.task_id;
|
||||||
|
|
||||||
|
-- Handle phase updates separately since it's in a different table
|
||||||
|
IF _update_record.phase_id IS NOT NULL THEN
|
||||||
|
INSERT INTO task_phase (task_id, phase_id)
|
||||||
|
VALUES (_update_record.task_id, _update_record.phase_id)
|
||||||
|
ON CONFLICT (task_id) DO UPDATE SET phase_id = _update_record.phase_id;
|
||||||
|
END IF;
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|||||||
@@ -0,0 +1,185 @@
|
|||||||
|
-- Function to create multiple recurring tasks in bulk
|
||||||
|
CREATE OR REPLACE FUNCTION create_bulk_recurring_tasks(
|
||||||
|
p_tasks JSONB
|
||||||
|
)
|
||||||
|
RETURNS TABLE (
|
||||||
|
task_id UUID,
|
||||||
|
task_name TEXT,
|
||||||
|
created BOOLEAN,
|
||||||
|
error_message TEXT
|
||||||
|
) AS $$
|
||||||
|
DECLARE
|
||||||
|
v_task JSONB;
|
||||||
|
v_task_id UUID;
|
||||||
|
v_existing_id UUID;
|
||||||
|
v_error_message TEXT;
|
||||||
|
BEGIN
|
||||||
|
-- Create a temporary table to store results
|
||||||
|
CREATE TEMP TABLE IF NOT EXISTS bulk_task_results (
|
||||||
|
task_id UUID,
|
||||||
|
task_name TEXT,
|
||||||
|
created BOOLEAN,
|
||||||
|
error_message TEXT
|
||||||
|
) ON COMMIT DROP;
|
||||||
|
|
||||||
|
-- Iterate through each task in the array
|
||||||
|
FOR v_task IN SELECT * FROM jsonb_array_elements(p_tasks)
|
||||||
|
LOOP
|
||||||
|
BEGIN
|
||||||
|
-- Check if task already exists for this schedule and date
|
||||||
|
SELECT id INTO v_existing_id
|
||||||
|
FROM tasks
|
||||||
|
WHERE schedule_id = (v_task->>'schedule_id')::UUID
|
||||||
|
AND end_date::DATE = (v_task->>'end_date')::DATE
|
||||||
|
LIMIT 1;
|
||||||
|
|
||||||
|
IF v_existing_id IS NOT NULL THEN
|
||||||
|
-- Task already exists
|
||||||
|
INSERT INTO bulk_task_results (task_id, task_name, created, error_message)
|
||||||
|
VALUES (v_existing_id, v_task->>'name', FALSE, 'Task already exists for this date');
|
||||||
|
ELSE
|
||||||
|
-- Create the task using existing function
|
||||||
|
SELECT (create_quick_task(v_task::TEXT)::JSONB)->>'id' INTO v_task_id;
|
||||||
|
|
||||||
|
IF v_task_id IS NOT NULL THEN
|
||||||
|
INSERT INTO bulk_task_results (task_id, task_name, created, error_message)
|
||||||
|
VALUES (v_task_id::UUID, v_task->>'name', TRUE, NULL);
|
||||||
|
ELSE
|
||||||
|
INSERT INTO bulk_task_results (task_id, task_name, created, error_message)
|
||||||
|
VALUES (NULL, v_task->>'name', FALSE, 'Failed to create task');
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
EXCEPTION WHEN OTHERS THEN
|
||||||
|
-- Capture any errors
|
||||||
|
v_error_message := SQLERRM;
|
||||||
|
INSERT INTO bulk_task_results (task_id, task_name, created, error_message)
|
||||||
|
VALUES (NULL, v_task->>'name', FALSE, v_error_message);
|
||||||
|
END;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
-- Return all results
|
||||||
|
RETURN QUERY SELECT * FROM bulk_task_results;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
-- Function to bulk assign team members to tasks
|
||||||
|
CREATE OR REPLACE FUNCTION bulk_assign_team_members(
|
||||||
|
p_assignments JSONB
|
||||||
|
)
|
||||||
|
RETURNS TABLE (
|
||||||
|
task_id UUID,
|
||||||
|
team_member_id UUID,
|
||||||
|
assigned BOOLEAN,
|
||||||
|
error_message TEXT
|
||||||
|
) AS $$
|
||||||
|
DECLARE
|
||||||
|
v_assignment JSONB;
|
||||||
|
v_result RECORD;
|
||||||
|
BEGIN
|
||||||
|
CREATE TEMP TABLE IF NOT EXISTS bulk_assignment_results (
|
||||||
|
task_id UUID,
|
||||||
|
team_member_id UUID,
|
||||||
|
assigned BOOLEAN,
|
||||||
|
error_message TEXT
|
||||||
|
) ON COMMIT DROP;
|
||||||
|
|
||||||
|
FOR v_assignment IN SELECT * FROM jsonb_array_elements(p_assignments)
|
||||||
|
LOOP
|
||||||
|
BEGIN
|
||||||
|
-- Check if assignment already exists
|
||||||
|
IF EXISTS (
|
||||||
|
SELECT 1 FROM tasks_assignees
|
||||||
|
WHERE task_id = (v_assignment->>'task_id')::UUID
|
||||||
|
AND team_member_id = (v_assignment->>'team_member_id')::UUID
|
||||||
|
) THEN
|
||||||
|
INSERT INTO bulk_assignment_results
|
||||||
|
VALUES (
|
||||||
|
(v_assignment->>'task_id')::UUID,
|
||||||
|
(v_assignment->>'team_member_id')::UUID,
|
||||||
|
FALSE,
|
||||||
|
'Assignment already exists'
|
||||||
|
);
|
||||||
|
ELSE
|
||||||
|
-- Create the assignment
|
||||||
|
INSERT INTO tasks_assignees (task_id, team_member_id, assigned_by)
|
||||||
|
VALUES (
|
||||||
|
(v_assignment->>'task_id')::UUID,
|
||||||
|
(v_assignment->>'team_member_id')::UUID,
|
||||||
|
(v_assignment->>'assigned_by')::UUID
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO bulk_assignment_results
|
||||||
|
VALUES (
|
||||||
|
(v_assignment->>'task_id')::UUID,
|
||||||
|
(v_assignment->>'team_member_id')::UUID,
|
||||||
|
TRUE,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
END IF;
|
||||||
|
EXCEPTION WHEN OTHERS THEN
|
||||||
|
INSERT INTO bulk_assignment_results
|
||||||
|
VALUES (
|
||||||
|
(v_assignment->>'task_id')::UUID,
|
||||||
|
(v_assignment->>'team_member_id')::UUID,
|
||||||
|
FALSE,
|
||||||
|
SQLERRM
|
||||||
|
);
|
||||||
|
END;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RETURN QUERY SELECT * FROM bulk_assignment_results;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
-- Function to bulk assign labels to tasks
|
||||||
|
CREATE OR REPLACE FUNCTION bulk_assign_labels(
|
||||||
|
p_label_assignments JSONB
|
||||||
|
)
|
||||||
|
RETURNS TABLE (
|
||||||
|
task_id UUID,
|
||||||
|
label_id UUID,
|
||||||
|
assigned BOOLEAN,
|
||||||
|
error_message TEXT
|
||||||
|
) AS $$
|
||||||
|
DECLARE
|
||||||
|
v_assignment JSONB;
|
||||||
|
v_labels JSONB;
|
||||||
|
BEGIN
|
||||||
|
CREATE TEMP TABLE IF NOT EXISTS bulk_label_results (
|
||||||
|
task_id UUID,
|
||||||
|
label_id UUID,
|
||||||
|
assigned BOOLEAN,
|
||||||
|
error_message TEXT
|
||||||
|
) ON COMMIT DROP;
|
||||||
|
|
||||||
|
FOR v_assignment IN SELECT * FROM jsonb_array_elements(p_label_assignments)
|
||||||
|
LOOP
|
||||||
|
BEGIN
|
||||||
|
-- Use existing function to add label
|
||||||
|
SELECT add_or_remove_task_label(
|
||||||
|
(v_assignment->>'task_id')::UUID,
|
||||||
|
(v_assignment->>'label_id')::UUID
|
||||||
|
) INTO v_labels;
|
||||||
|
|
||||||
|
INSERT INTO bulk_label_results
|
||||||
|
VALUES (
|
||||||
|
(v_assignment->>'task_id')::UUID,
|
||||||
|
(v_assignment->>'label_id')::UUID,
|
||||||
|
TRUE,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
EXCEPTION WHEN OTHERS THEN
|
||||||
|
INSERT INTO bulk_label_results
|
||||||
|
VALUES (
|
||||||
|
(v_assignment->>'task_id')::UUID,
|
||||||
|
(v_assignment->>'label_id')::UUID,
|
||||||
|
FALSE,
|
||||||
|
SQLERRM
|
||||||
|
);
|
||||||
|
END;
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
RETURN QUERY SELECT * FROM bulk_label_results;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
-- Create notifications table if it doesn't exist
|
||||||
|
CREATE TABLE IF NOT EXISTS notifications (
|
||||||
|
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||||
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
message TEXT NOT NULL,
|
||||||
|
data JSONB,
|
||||||
|
read BOOLEAN DEFAULT FALSE,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
read_at TIMESTAMP WITH TIME ZONE
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Create user_push_tokens table if it doesn't exist (for future push notifications)
|
||||||
|
CREATE TABLE IF NOT EXISTS user_push_tokens (
|
||||||
|
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||||
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
push_token TEXT NOT NULL,
|
||||||
|
device_type VARCHAR(20),
|
||||||
|
active BOOLEAN DEFAULT TRUE,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
UNIQUE(user_id, push_token)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Add notification preferences to users table if they don't exist
|
||||||
|
ALTER TABLE users
|
||||||
|
ADD COLUMN IF NOT EXISTS email_notifications BOOLEAN DEFAULT TRUE,
|
||||||
|
ADD COLUMN IF NOT EXISTS push_notifications BOOLEAN DEFAULT TRUE,
|
||||||
|
ADD COLUMN IF NOT EXISTS in_app_notifications BOOLEAN DEFAULT TRUE;
|
||||||
|
|
||||||
|
-- Create indexes for better performance
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_notifications_user_id ON notifications(user_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_notifications_created_at ON notifications(created_at);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_notifications_unread ON notifications(user_id, read) WHERE read = FALSE;
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_push_tokens_user_id ON user_push_tokens(user_id);
|
||||||
|
|
||||||
|
-- Comments
|
||||||
|
COMMENT ON TABLE notifications IS 'In-app notifications for users';
|
||||||
|
COMMENT ON TABLE user_push_tokens IS 'Push notification tokens for mobile devices';
|
||||||
|
COMMENT ON COLUMN notifications.data IS 'Additional notification data in JSON format';
|
||||||
|
COMMENT ON COLUMN user_push_tokens.device_type IS 'Device type: ios, android, web';
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
-- Create audit log table for recurring task operations
|
||||||
|
CREATE TABLE IF NOT EXISTS recurring_tasks_audit_log (
|
||||||
|
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
|
||||||
|
operation_type VARCHAR(50) NOT NULL,
|
||||||
|
template_id UUID,
|
||||||
|
schedule_id UUID,
|
||||||
|
task_id UUID,
|
||||||
|
template_name TEXT,
|
||||||
|
success BOOLEAN DEFAULT TRUE,
|
||||||
|
error_message TEXT,
|
||||||
|
details JSONB,
|
||||||
|
created_tasks_count INTEGER DEFAULT 0,
|
||||||
|
failed_tasks_count INTEGER DEFAULT 0,
|
||||||
|
execution_time_ms INTEGER,
|
||||||
|
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
created_by UUID REFERENCES users(id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Create indexes for better query performance
|
||||||
|
CREATE INDEX idx_recurring_tasks_audit_log_template_id ON recurring_tasks_audit_log(template_id);
|
||||||
|
CREATE INDEX idx_recurring_tasks_audit_log_schedule_id ON recurring_tasks_audit_log(schedule_id);
|
||||||
|
CREATE INDEX idx_recurring_tasks_audit_log_created_at ON recurring_tasks_audit_log(created_at);
|
||||||
|
CREATE INDEX idx_recurring_tasks_audit_log_operation_type ON recurring_tasks_audit_log(operation_type);
|
||||||
|
|
||||||
|
-- Add comments
|
||||||
|
COMMENT ON TABLE recurring_tasks_audit_log IS 'Audit log for all recurring task operations';
|
||||||
|
COMMENT ON COLUMN recurring_tasks_audit_log.operation_type IS 'Type of operation: cron_job_run, manual_trigger, schedule_created, schedule_updated, schedule_deleted, etc.';
|
||||||
|
COMMENT ON COLUMN recurring_tasks_audit_log.details IS 'Additional details about the operation in JSON format';
|
||||||
|
|
||||||
|
-- Create a function to log recurring task operations
|
||||||
|
CREATE OR REPLACE FUNCTION log_recurring_task_operation(
|
||||||
|
p_operation_type VARCHAR(50),
|
||||||
|
p_template_id UUID DEFAULT NULL,
|
||||||
|
p_schedule_id UUID DEFAULT NULL,
|
||||||
|
p_task_id UUID DEFAULT NULL,
|
||||||
|
p_template_name TEXT DEFAULT NULL,
|
||||||
|
p_success BOOLEAN DEFAULT TRUE,
|
||||||
|
p_error_message TEXT DEFAULT NULL,
|
||||||
|
p_details JSONB DEFAULT NULL,
|
||||||
|
p_created_tasks_count INTEGER DEFAULT 0,
|
||||||
|
p_failed_tasks_count INTEGER DEFAULT 0,
|
||||||
|
p_execution_time_ms INTEGER DEFAULT NULL,
|
||||||
|
p_created_by UUID DEFAULT NULL
|
||||||
|
)
|
||||||
|
RETURNS UUID AS $$
|
||||||
|
DECLARE
|
||||||
|
v_log_id UUID;
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO recurring_tasks_audit_log (
|
||||||
|
operation_type,
|
||||||
|
template_id,
|
||||||
|
schedule_id,
|
||||||
|
task_id,
|
||||||
|
template_name,
|
||||||
|
success,
|
||||||
|
error_message,
|
||||||
|
details,
|
||||||
|
created_tasks_count,
|
||||||
|
failed_tasks_count,
|
||||||
|
execution_time_ms,
|
||||||
|
created_by
|
||||||
|
) VALUES (
|
||||||
|
p_operation_type,
|
||||||
|
p_template_id,
|
||||||
|
p_schedule_id,
|
||||||
|
p_task_id,
|
||||||
|
p_template_name,
|
||||||
|
p_success,
|
||||||
|
p_error_message,
|
||||||
|
p_details,
|
||||||
|
p_created_tasks_count,
|
||||||
|
p_failed_tasks_count,
|
||||||
|
p_execution_time_ms,
|
||||||
|
p_created_by
|
||||||
|
) RETURNING id INTO v_log_id;
|
||||||
|
|
||||||
|
RETURN v_log_id;
|
||||||
|
END;
|
||||||
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
-- Create a view for recent audit logs
|
||||||
|
CREATE OR REPLACE VIEW v_recent_recurring_tasks_audit AS
|
||||||
|
SELECT
|
||||||
|
l.*,
|
||||||
|
u.name as created_by_name,
|
||||||
|
t.name as current_template_name,
|
||||||
|
s.schedule_type,
|
||||||
|
s.timezone
|
||||||
|
FROM recurring_tasks_audit_log l
|
||||||
|
LEFT JOIN users u ON l.created_by = u.id
|
||||||
|
LEFT JOIN task_recurring_templates t ON l.template_id = t.id
|
||||||
|
LEFT JOIN task_recurring_schedules s ON l.schedule_id = s.id
|
||||||
|
WHERE l.created_at >= CURRENT_TIMESTAMP - INTERVAL '30 days'
|
||||||
|
ORDER BY l.created_at DESC;
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
-- Add timezone support to recurring tasks
|
||||||
|
|
||||||
|
-- Add timezone column to task_recurring_schedules
|
||||||
|
ALTER TABLE task_recurring_schedules
|
||||||
|
ADD COLUMN IF NOT EXISTS timezone VARCHAR(50) DEFAULT 'UTC';
|
||||||
|
|
||||||
|
-- Add timezone column to task_recurring_templates
|
||||||
|
ALTER TABLE task_recurring_templates
|
||||||
|
ADD COLUMN IF NOT EXISTS reporter_timezone VARCHAR(50);
|
||||||
|
|
||||||
|
-- Add date_of_month column if not exists (for monthly schedules)
|
||||||
|
ALTER TABLE task_recurring_schedules
|
||||||
|
ADD COLUMN IF NOT EXISTS date_of_month INTEGER;
|
||||||
|
|
||||||
|
-- Add last_checked_at and last_created_task_end_date columns for tracking
|
||||||
|
ALTER TABLE task_recurring_schedules
|
||||||
|
ADD COLUMN IF NOT EXISTS last_checked_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
ADD COLUMN IF NOT EXISTS last_created_task_end_date TIMESTAMP WITH TIME ZONE;
|
||||||
|
|
||||||
|
-- Add end_date and excluded_dates columns for schedule control
|
||||||
|
ALTER TABLE task_recurring_schedules
|
||||||
|
ADD COLUMN IF NOT EXISTS end_date DATE,
|
||||||
|
ADD COLUMN IF NOT EXISTS excluded_dates TEXT[];
|
||||||
|
|
||||||
|
-- Create index on timezone for better query performance
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_task_recurring_schedules_timezone
|
||||||
|
ON task_recurring_schedules(timezone);
|
||||||
|
|
||||||
|
-- Update existing records to use user's timezone if available
|
||||||
|
UPDATE task_recurring_schedules trs
|
||||||
|
SET timezone = COALESCE(
|
||||||
|
(SELECT u.timezone
|
||||||
|
FROM task_recurring_templates trt
|
||||||
|
JOIN tasks t ON trt.task_id = t.id
|
||||||
|
JOIN users u ON t.reporter_id = u.id
|
||||||
|
WHERE trt.schedule_id = trs.id
|
||||||
|
LIMIT 1),
|
||||||
|
'UTC'
|
||||||
|
)
|
||||||
|
WHERE trs.timezone IS NULL OR trs.timezone = 'UTC';
|
||||||
|
|
||||||
|
-- Add comment to explain timezone field
|
||||||
|
COMMENT ON COLUMN task_recurring_schedules.timezone IS 'IANA timezone identifier for schedule calculations';
|
||||||
|
COMMENT ON COLUMN task_recurring_templates.reporter_timezone IS 'Original reporter timezone for reference';
|
||||||
57
worklenz-backend/src/config/recurring-tasks-config.ts
Normal file
57
worklenz-backend/src/config/recurring-tasks-config.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
export interface RecurringTasksConfig {
|
||||||
|
enabled: boolean;
|
||||||
|
mode: 'cron' | 'queue';
|
||||||
|
cronInterval: string;
|
||||||
|
redisConfig: {
|
||||||
|
host: string;
|
||||||
|
port: number;
|
||||||
|
password?: string;
|
||||||
|
db: number;
|
||||||
|
};
|
||||||
|
queueOptions: {
|
||||||
|
maxConcurrency: number;
|
||||||
|
retryAttempts: number;
|
||||||
|
retryDelay: number;
|
||||||
|
};
|
||||||
|
notifications: {
|
||||||
|
enabled: boolean;
|
||||||
|
email: boolean;
|
||||||
|
push: boolean;
|
||||||
|
inApp: boolean;
|
||||||
|
};
|
||||||
|
auditLog: {
|
||||||
|
enabled: boolean;
|
||||||
|
retentionDays: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const recurringTasksConfig: RecurringTasksConfig = {
|
||||||
|
enabled: process.env.RECURRING_TASKS_ENABLED !== 'false',
|
||||||
|
mode: (process.env.RECURRING_TASKS_MODE as 'cron' | 'queue') || 'cron',
|
||||||
|
cronInterval: process.env.RECURRING_JOBS_INTERVAL || '0 * * * *',
|
||||||
|
|
||||||
|
redisConfig: {
|
||||||
|
host: process.env.REDIS_HOST || 'localhost',
|
||||||
|
port: parseInt(process.env.REDIS_PORT || '6379'),
|
||||||
|
password: process.env.REDIS_PASSWORD,
|
||||||
|
db: parseInt(process.env.REDIS_DB || '0'),
|
||||||
|
},
|
||||||
|
|
||||||
|
queueOptions: {
|
||||||
|
maxConcurrency: parseInt(process.env.RECURRING_TASKS_MAX_CONCURRENCY || '5'),
|
||||||
|
retryAttempts: parseInt(process.env.RECURRING_TASKS_RETRY_ATTEMPTS || '3'),
|
||||||
|
retryDelay: parseInt(process.env.RECURRING_TASKS_RETRY_DELAY || '2000'),
|
||||||
|
},
|
||||||
|
|
||||||
|
notifications: {
|
||||||
|
enabled: process.env.RECURRING_TASKS_NOTIFICATIONS_ENABLED !== 'false',
|
||||||
|
email: process.env.RECURRING_TASKS_EMAIL_NOTIFICATIONS !== 'false',
|
||||||
|
push: process.env.RECURRING_TASKS_PUSH_NOTIFICATIONS !== 'false',
|
||||||
|
inApp: process.env.RECURRING_TASKS_IN_APP_NOTIFICATIONS !== 'false',
|
||||||
|
},
|
||||||
|
|
||||||
|
auditLog: {
|
||||||
|
enabled: process.env.RECURRING_TASKS_AUDIT_LOG_ENABLED !== 'false',
|
||||||
|
retentionDays: parseInt(process.env.RECURRING_TASKS_AUDIT_RETENTION_DAYS || '90'),
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { IWorkLenzRequest } from "../interfaces/worklenz-request";
|
||||||
|
import { IWorkLenzResponse } from "../interfaces/worklenz-response";
|
||||||
|
import { ServerResponse } from "../models/server-response";
|
||||||
|
import WorklenzControllerBase from "./worklenz-controller-base";
|
||||||
|
import HandleExceptions from "../decorators/handle-exceptions";
|
||||||
|
import { RecurringTasksPermissions } from "../utils/recurring-tasks-permissions";
|
||||||
|
import { RecurringTasksAuditLogger } from "../utils/recurring-tasks-audit-logger";
|
||||||
|
|
||||||
|
export default class RecurringTasksAdminController extends WorklenzControllerBase {
|
||||||
|
/**
|
||||||
|
* Get templates with permission issues
|
||||||
|
*/
|
||||||
|
@HandleExceptions()
|
||||||
|
public static async getPermissionIssues(req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
|
||||||
|
const issues = await RecurringTasksPermissions.getTemplatesWithPermissionIssues();
|
||||||
|
return res.status(200).send(new ServerResponse(true, issues));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get audit log summary
|
||||||
|
*/
|
||||||
|
@HandleExceptions()
|
||||||
|
public static async getAuditSummary(req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
|
||||||
|
const { days = 7 } = req.query;
|
||||||
|
const summary = await RecurringTasksAuditLogger.getAuditSummary(Number(days));
|
||||||
|
return res.status(200).send(new ServerResponse(true, summary));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get recent errors from audit log
|
||||||
|
*/
|
||||||
|
@HandleExceptions()
|
||||||
|
public static async getRecentErrors(req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
|
||||||
|
const { limit = 10 } = req.query;
|
||||||
|
const errors = await RecurringTasksAuditLogger.getRecentErrors(Number(limit));
|
||||||
|
return res.status(200).send(new ServerResponse(true, errors));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate a specific template
|
||||||
|
*/
|
||||||
|
@HandleExceptions()
|
||||||
|
public static async validateTemplate(req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
|
||||||
|
const { templateId } = req.params;
|
||||||
|
const result = await RecurringTasksPermissions.validateTemplatePermissions(templateId);
|
||||||
|
return res.status(200).send(new ServerResponse(true, result));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import { IWorkLenzRequest } from "../interfaces/worklenz-request";
|
|||||||
import { IWorkLenzResponse } from "../interfaces/worklenz-response";
|
import { IWorkLenzResponse } from "../interfaces/worklenz-response";
|
||||||
import { ServerResponse } from "../models/server-response";
|
import { ServerResponse } from "../models/server-response";
|
||||||
import { calculateNextEndDate, log_error } from "../shared/utils";
|
import { calculateNextEndDate, log_error } from "../shared/utils";
|
||||||
|
import { RecurringTasksAuditLogger, RecurringTaskOperationType } from "../utils/recurring-tasks-audit-logger";
|
||||||
|
|
||||||
export default class TaskRecurringController extends WorklenzControllerBase {
|
export default class TaskRecurringController extends WorklenzControllerBase {
|
||||||
@HandleExceptions()
|
@HandleExceptions()
|
||||||
@@ -34,7 +35,7 @@ export default class TaskRecurringController extends WorklenzControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@HandleExceptions()
|
@HandleExceptions()
|
||||||
public static async createTaskSchedule(taskId: string) {
|
public static async createTaskSchedule(taskId: string, userId?: string) {
|
||||||
const q = `INSERT INTO task_recurring_schedules (schedule_type) VALUES ('daily') RETURNING id, schedule_type;`;
|
const q = `INSERT INTO task_recurring_schedules (schedule_type) VALUES ('daily') RETURNING id, schedule_type;`;
|
||||||
const result = await db.query(q, []);
|
const result = await db.query(q, []);
|
||||||
const [data] = result.rows;
|
const [data] = result.rows;
|
||||||
@@ -44,6 +45,15 @@ export default class TaskRecurringController extends WorklenzControllerBase {
|
|||||||
|
|
||||||
await TaskRecurringController.insertTaskRecurringTemplate(taskId, data.id);
|
await TaskRecurringController.insertTaskRecurringTemplate(taskId, data.id);
|
||||||
|
|
||||||
|
// Log schedule creation
|
||||||
|
await RecurringTasksAuditLogger.logScheduleChange(
|
||||||
|
RecurringTaskOperationType.SCHEDULE_CREATED,
|
||||||
|
data.id,
|
||||||
|
taskId,
|
||||||
|
userId,
|
||||||
|
{ schedule_type: data.schedule_type }
|
||||||
|
);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,9 +66,9 @@ export default class TaskRecurringController extends WorklenzControllerBase {
|
|||||||
@HandleExceptions()
|
@HandleExceptions()
|
||||||
public static async updateSchedule(req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
|
public static async updateSchedule(req: IWorkLenzRequest, res: IWorkLenzResponse): Promise<IWorkLenzResponse> {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
const { schedule_type, days_of_week, day_of_month, week_of_month, interval_days, interval_weeks, interval_months, date_of_month } = req.body;
|
const { schedule_type, days_of_week, day_of_month, week_of_month, interval_days, interval_weeks, interval_months, date_of_month, timezone, end_date, excluded_dates } = req.body;
|
||||||
|
|
||||||
const deleteQ = `UPDATE task_recurring_schedules
|
const updateQ = `UPDATE task_recurring_schedules
|
||||||
SET schedule_type = $1,
|
SET schedule_type = $1,
|
||||||
days_of_week = $2,
|
days_of_week = $2,
|
||||||
date_of_month = $3,
|
date_of_month = $3,
|
||||||
@@ -66,9 +76,27 @@ export default class TaskRecurringController extends WorklenzControllerBase {
|
|||||||
week_of_month = $5,
|
week_of_month = $5,
|
||||||
interval_days = $6,
|
interval_days = $6,
|
||||||
interval_weeks = $7,
|
interval_weeks = $7,
|
||||||
interval_months = $8
|
interval_months = $8,
|
||||||
WHERE id = $9;`;
|
timezone = COALESCE($9, timezone, 'UTC'),
|
||||||
await db.query(deleteQ, [schedule_type, days_of_week, date_of_month, day_of_month, week_of_month, interval_days, interval_weeks, interval_months, id]);
|
end_date = $10,
|
||||||
|
excluded_dates = $11
|
||||||
|
WHERE id = $12;`;
|
||||||
|
await db.query(updateQ, [schedule_type, days_of_week, date_of_month, day_of_month, week_of_month, interval_days, interval_weeks, interval_months, timezone, end_date, excluded_dates, id]);
|
||||||
|
|
||||||
|
// Log schedule update
|
||||||
|
await RecurringTasksAuditLogger.logScheduleChange(
|
||||||
|
RecurringTaskOperationType.SCHEDULE_UPDATED,
|
||||||
|
id,
|
||||||
|
undefined,
|
||||||
|
req.user?.id,
|
||||||
|
{
|
||||||
|
schedule_type,
|
||||||
|
timezone,
|
||||||
|
end_date,
|
||||||
|
excluded_dates_count: excluded_dates?.length || 0
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return res.status(200).send(new ServerResponse(true, null));
|
return res.status(200).send(new ServerResponse(true, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,12 +109,29 @@ export default class TasksControllerV2 extends TasksControllerBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static getQuery(userId: string, options: ParsedQs) {
|
private static getQuery(userId: string, options: ParsedQs) {
|
||||||
const searchField = options.search ? ["t.name", "CONCAT((SELECT key FROM projects WHERE id = t.project_id), '-', task_no)"] : "sort_order";
|
// Determine which sort column to use based on grouping
|
||||||
|
const groupBy = options.group || 'status';
|
||||||
|
let defaultSortColumn = 'sort_order';
|
||||||
|
switch (groupBy) {
|
||||||
|
case 'status':
|
||||||
|
defaultSortColumn = 'status_sort_order';
|
||||||
|
break;
|
||||||
|
case 'priority':
|
||||||
|
defaultSortColumn = 'priority_sort_order';
|
||||||
|
break;
|
||||||
|
case 'phase':
|
||||||
|
defaultSortColumn = 'phase_sort_order';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
defaultSortColumn = 'sort_order';
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchField = options.search ? ["t.name", "CONCAT((SELECT key FROM projects WHERE id = t.project_id), '-', task_no)"] : defaultSortColumn;
|
||||||
const { searchQuery, sortField } = TasksControllerV2.toPaginationOptions(options, searchField);
|
const { searchQuery, sortField } = TasksControllerV2.toPaginationOptions(options, searchField);
|
||||||
|
|
||||||
const isSubTasks = !!options.parent_task;
|
const isSubTasks = !!options.parent_task;
|
||||||
|
|
||||||
const sortFields = sortField.replace(/ascend/g, "ASC").replace(/descend/g, "DESC") || "sort_order";
|
const sortFields = sortField.replace(/ascend/g, "ASC").replace(/descend/g, "DESC") || defaultSortColumn;
|
||||||
|
|
||||||
// Filter tasks by statuses
|
// Filter tasks by statuses
|
||||||
const statusesFilter = TasksControllerV2.getFilterByStatusWhereClosure(options.statuses as string);
|
const statusesFilter = TasksControllerV2.getFilterByStatusWhereClosure(options.statuses as string);
|
||||||
@@ -196,6 +213,9 @@ export default class TasksControllerV2 extends TasksControllerBase {
|
|||||||
t.archived,
|
t.archived,
|
||||||
t.description,
|
t.description,
|
||||||
t.sort_order,
|
t.sort_order,
|
||||||
|
t.status_sort_order,
|
||||||
|
t.priority_sort_order,
|
||||||
|
t.phase_sort_order,
|
||||||
t.progress_value,
|
t.progress_value,
|
||||||
t.manual_progress,
|
t.manual_progress,
|
||||||
t.weight,
|
t.weight,
|
||||||
@@ -1088,7 +1108,7 @@ export default class TasksControllerV2 extends TasksControllerBase {
|
|||||||
custom_column_values: task.custom_column_values || {}, // Include custom column values
|
custom_column_values: task.custom_column_values || {}, // Include custom column values
|
||||||
createdAt: task.created_at || new Date().toISOString(),
|
createdAt: task.created_at || new Date().toISOString(),
|
||||||
updatedAt: task.updated_at || new Date().toISOString(),
|
updatedAt: task.updated_at || new Date().toISOString(),
|
||||||
order: typeof task.sort_order === "number" ? task.sort_order : 0,
|
order: TasksControllerV2.getTaskSortOrder(task, groupBy),
|
||||||
// Additional metadata for frontend
|
// Additional metadata for frontend
|
||||||
originalStatusId: task.status,
|
originalStatusId: task.status,
|
||||||
originalPriorityId: task.priority,
|
originalPriorityId: task.priority,
|
||||||
@@ -1292,6 +1312,19 @@ export default class TasksControllerV2 extends TasksControllerBase {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static getTaskSortOrder(task: any, groupBy: string): number {
|
||||||
|
switch (groupBy) {
|
||||||
|
case GroupBy.STATUS:
|
||||||
|
return typeof task.status_sort_order === "number" ? task.status_sort_order : 0;
|
||||||
|
case GroupBy.PRIORITY:
|
||||||
|
return typeof task.priority_sort_order === "number" ? task.priority_sort_order : 0;
|
||||||
|
case GroupBy.PHASE:
|
||||||
|
return typeof task.phase_sort_order === "number" ? task.phase_sort_order : 0;
|
||||||
|
default:
|
||||||
|
return typeof task.sort_order === "number" ? task.sort_order : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static getDefaultGroupColor(groupBy: string, groupValue: string): string {
|
private static getDefaultGroupColor(groupBy: string, groupValue: string): string {
|
||||||
const colorMaps: Record<string, Record<string, string>> = {
|
const colorMaps: Record<string, Record<string, string>> = {
|
||||||
[GroupBy.STATUS]: {
|
[GroupBy.STATUS]: {
|
||||||
|
|||||||
@@ -2,12 +2,16 @@ import { CronJob } from "cron";
|
|||||||
import { calculateNextEndDate, log_error } from "../shared/utils";
|
import { calculateNextEndDate, log_error } from "../shared/utils";
|
||||||
import db from "../config/db";
|
import db from "../config/db";
|
||||||
import { IRecurringSchedule, ITaskTemplate } from "../interfaces/recurring-tasks";
|
import { IRecurringSchedule, ITaskTemplate } from "../interfaces/recurring-tasks";
|
||||||
import moment from "moment";
|
import moment from "moment-timezone";
|
||||||
import TasksController from "../controllers/tasks-controller";
|
import TasksController from "../controllers/tasks-controller";
|
||||||
|
import { TimezoneUtils } from "../utils/timezone-utils";
|
||||||
|
import { RetryUtils } from "../utils/retry-utils";
|
||||||
|
import { RecurringTasksAuditLogger, RecurringTaskOperationType } from "../utils/recurring-tasks-audit-logger";
|
||||||
|
import { RecurringTasksPermissions } from "../utils/recurring-tasks-permissions";
|
||||||
|
import { RecurringTasksNotifications } from "../utils/recurring-tasks-notifications";
|
||||||
|
|
||||||
// At 11:00+00 (4.30pm+530) on every day-of-month if it's on every day-of-week from Monday through Friday.
|
// Run every hour to process tasks in different timezones
|
||||||
// const TIME = "0 11 */1 * 1-5";
|
const TIME = process.env.RECURRING_JOBS_INTERVAL || "0 * * * *";
|
||||||
const TIME = process.env.RECURRING_JOBS_INTERVAL || "0 11 */1 * 1-5";
|
|
||||||
const TIME_FORMAT = "YYYY-MM-DD";
|
const TIME_FORMAT = "YYYY-MM-DD";
|
||||||
// const TIME = "0 0 * * *"; // Runs at midnight every day
|
// const TIME = "0 0 * * *"; // Runs at midnight every day
|
||||||
|
|
||||||
@@ -44,8 +48,129 @@ function getFutureLimit(scheduleType: string, interval?: number): moment.Duratio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to batch create tasks
|
// Helper function to batch create tasks using bulk operations
|
||||||
async function createBatchTasks(template: ITaskTemplate & IRecurringSchedule, endDates: moment.Moment[]) {
|
async function createBatchTasks(template: ITaskTemplate & IRecurringSchedule, endDates: moment.Moment[]) {
|
||||||
|
if (endDates.length === 0) return [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Prepare bulk task data
|
||||||
|
const tasksData = endDates.map(endDate => ({
|
||||||
|
name: template.name,
|
||||||
|
priority_id: template.priority_id,
|
||||||
|
project_id: template.project_id,
|
||||||
|
reporter_id: template.reporter_id,
|
||||||
|
status_id: template.status_id || null,
|
||||||
|
end_date: endDate.format(TIME_FORMAT),
|
||||||
|
schedule_id: template.schedule_id
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Create all tasks in bulk with retry logic
|
||||||
|
const createTasksResult = await RetryUtils.withDatabaseRetry(async () => {
|
||||||
|
const createTasksQuery = `SELECT * FROM create_bulk_recurring_tasks($1::JSONB);`;
|
||||||
|
return await db.query(createTasksQuery, [JSON.stringify(tasksData)]);
|
||||||
|
}, `create_bulk_recurring_tasks for template ${template.name}`);
|
||||||
|
|
||||||
|
const createdTasks = createTasksResult.rows.filter(row => row.created);
|
||||||
|
const failedTasks = createTasksResult.rows.filter(row => !row.created);
|
||||||
|
|
||||||
|
// Log results
|
||||||
|
if (createdTasks.length > 0) {
|
||||||
|
console.log(`Created ${createdTasks.length} tasks for template ${template.name}`);
|
||||||
|
}
|
||||||
|
if (failedTasks.length > 0) {
|
||||||
|
failedTasks.forEach(task => {
|
||||||
|
console.log(`Failed to create task for template ${template.name}: ${task.error_message}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only process assignments for successfully created tasks
|
||||||
|
if (createdTasks.length > 0 && (template.assignees?.length > 0 || template.labels?.length > 0)) {
|
||||||
|
// Validate assignee permissions
|
||||||
|
let validAssignees = template.assignees || [];
|
||||||
|
if (validAssignees.length > 0) {
|
||||||
|
const invalidAssignees = await RecurringTasksPermissions.validateAssigneePermissions(
|
||||||
|
validAssignees,
|
||||||
|
template.project_id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (invalidAssignees.length > 0) {
|
||||||
|
console.log(`Warning: ${invalidAssignees.length} assignees do not have permissions for project ${template.project_id}`);
|
||||||
|
// Filter out invalid assignees
|
||||||
|
validAssignees = validAssignees.filter(
|
||||||
|
a => !invalidAssignees.includes(a.team_member_id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare bulk assignments
|
||||||
|
const assignments = [];
|
||||||
|
const labelAssignments = [];
|
||||||
|
|
||||||
|
for (const task of createdTasks) {
|
||||||
|
// Prepare team member assignments with validated assignees
|
||||||
|
if (validAssignees.length > 0) {
|
||||||
|
for (const assignee of validAssignees) {
|
||||||
|
assignments.push({
|
||||||
|
task_id: task.task_id,
|
||||||
|
team_member_id: assignee.team_member_id,
|
||||||
|
assigned_by: assignee.assigned_by
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare label assignments
|
||||||
|
if (template.labels?.length > 0) {
|
||||||
|
for (const label of template.labels) {
|
||||||
|
labelAssignments.push({
|
||||||
|
task_id: task.task_id,
|
||||||
|
label_id: label.label_id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bulk assign team members with retry logic
|
||||||
|
if (assignments.length > 0) {
|
||||||
|
await RetryUtils.withDatabaseRetry(async () => {
|
||||||
|
const assignQuery = `SELECT * FROM bulk_assign_team_members($1::JSONB);`;
|
||||||
|
return await db.query(assignQuery, [JSON.stringify(assignments)]);
|
||||||
|
}, `bulk_assign_team_members for template ${template.name}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bulk assign labels with retry logic
|
||||||
|
if (labelAssignments.length > 0) {
|
||||||
|
await RetryUtils.withDatabaseRetry(async () => {
|
||||||
|
const labelQuery = `SELECT * FROM bulk_assign_labels($1::JSONB);`;
|
||||||
|
return await db.query(labelQuery, [JSON.stringify(labelAssignments)]);
|
||||||
|
}, `bulk_assign_labels for template ${template.name}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send notifications for created tasks
|
||||||
|
if (createdTasks.length > 0) {
|
||||||
|
const taskData = createdTasks.map(task => ({ id: task.task_id, name: task.task_name }));
|
||||||
|
const assigneeIds = template.assignees?.map(a => a.team_member_id) || [];
|
||||||
|
|
||||||
|
await RecurringTasksNotifications.notifyRecurringTasksCreated(
|
||||||
|
template.name,
|
||||||
|
template.project_id,
|
||||||
|
taskData,
|
||||||
|
assigneeIds,
|
||||||
|
template.reporter_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return createdTasks.map(task => ({ id: task.task_id, name: task.task_name }));
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Error in bulk task creation:", error);
|
||||||
|
// Fallback to sequential creation if bulk operation fails
|
||||||
|
console.log("Falling back to sequential task creation");
|
||||||
|
return createBatchTasksSequential(template, endDates);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback function for sequential task creation
|
||||||
|
async function createBatchTasksSequential(template: ITaskTemplate & IRecurringSchedule, endDates: moment.Moment[]) {
|
||||||
const createdTasks = [];
|
const createdTasks = [];
|
||||||
|
|
||||||
for (const nextEndDate of endDates) {
|
for (const nextEndDate of endDates) {
|
||||||
@@ -92,69 +217,162 @@ async function createBatchTasks(template: ITaskTemplate & IRecurringSchedule, en
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function onRecurringTaskJobTick() {
|
async function onRecurringTaskJobTick() {
|
||||||
|
const errors: any[] = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log("(cron) Recurring tasks job started.");
|
log("(cron) Recurring tasks job started.");
|
||||||
|
RecurringTasksAuditLogger.startTimer();
|
||||||
|
|
||||||
|
// Get all active timezones where it's currently the scheduled hour
|
||||||
|
const activeTimezones = TimezoneUtils.getActiveTimezones();
|
||||||
|
log(`Processing recurring tasks for ${activeTimezones.length} timezones`);
|
||||||
|
|
||||||
|
// Fetch templates with retry logic
|
||||||
|
const templatesResult = await RetryUtils.withDatabaseRetry(async () => {
|
||||||
const templatesQuery = `
|
const templatesQuery = `
|
||||||
SELECT t.*, s.*, (SELECT MAX(end_date) FROM tasks WHERE schedule_id = s.id) as last_task_end_date
|
SELECT t.*, s.*,
|
||||||
|
(SELECT MAX(end_date) FROM tasks WHERE schedule_id = s.id) as last_task_end_date,
|
||||||
|
u.timezone as user_timezone
|
||||||
FROM task_recurring_templates t
|
FROM task_recurring_templates t
|
||||||
JOIN task_recurring_schedules s ON t.schedule_id = s.id;
|
JOIN task_recurring_schedules s ON t.schedule_id = s.id
|
||||||
|
LEFT JOIN tasks orig_task ON t.task_id = orig_task.id
|
||||||
|
LEFT JOIN users u ON orig_task.reporter_id = u.id
|
||||||
|
WHERE s.end_date IS NULL OR s.end_date >= CURRENT_DATE;
|
||||||
`;
|
`;
|
||||||
const templatesResult = await db.query(templatesQuery);
|
return await db.query(templatesQuery);
|
||||||
const templates = templatesResult.rows as (ITaskTemplate & IRecurringSchedule)[];
|
}, "fetch_recurring_templates");
|
||||||
|
|
||||||
|
const templates = templatesResult.rows as (ITaskTemplate & IRecurringSchedule & { user_timezone?: string })[];
|
||||||
|
|
||||||
const now = moment();
|
|
||||||
let createdTaskCount = 0;
|
let createdTaskCount = 0;
|
||||||
|
|
||||||
for (const template of templates) {
|
for (const template of templates) {
|
||||||
|
// Check template permissions before processing
|
||||||
|
const permissionCheck = await RecurringTasksPermissions.validateTemplatePermissions(template.task_id);
|
||||||
|
if (!permissionCheck.hasPermission) {
|
||||||
|
console.log(`Skipping template ${template.name}: ${permissionCheck.reason}`);
|
||||||
|
|
||||||
|
// Log permission issue
|
||||||
|
await RecurringTasksAuditLogger.log({
|
||||||
|
operationType: RecurringTaskOperationType.TASKS_CREATION_FAILED,
|
||||||
|
templateId: template.task_id,
|
||||||
|
scheduleId: template.schedule_id,
|
||||||
|
templateName: template.name,
|
||||||
|
success: false,
|
||||||
|
errorMessage: `Permission denied: ${permissionCheck.reason}`,
|
||||||
|
details: { permissionCheck }
|
||||||
|
});
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use template timezone or user timezone or default to UTC
|
||||||
|
const timezone = template.timezone || TimezoneUtils.getUserTimezone(template.user_timezone);
|
||||||
|
|
||||||
|
// Check if this template should run in the current hour for its timezone
|
||||||
|
if (!activeTimezones.includes(timezone) && timezone !== 'UTC') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = TimezoneUtils.nowInTimezone(timezone);
|
||||||
const lastTaskEndDate = template.last_task_end_date
|
const lastTaskEndDate = template.last_task_end_date
|
||||||
? moment(template.last_task_end_date)
|
? moment.tz(template.last_task_end_date, timezone)
|
||||||
: moment(template.created_at);
|
: moment.tz(template.created_at, timezone);
|
||||||
|
|
||||||
// Calculate future limit based on schedule type
|
// Calculate future limit based on schedule type
|
||||||
const futureLimit = moment(template.last_checked_at || template.created_at)
|
const futureLimit = moment.tz(template.last_checked_at || template.created_at, timezone)
|
||||||
.add(getFutureLimit(
|
.add(getFutureLimit(
|
||||||
template.schedule_type,
|
template.schedule_type,
|
||||||
template.interval_days || template.interval_weeks || template.interval_months || 1
|
template.interval_days || template.interval_weeks || template.interval_months || 1
|
||||||
));
|
));
|
||||||
|
|
||||||
let nextEndDate = calculateNextEndDate(template, lastTaskEndDate);
|
let nextEndDate = TimezoneUtils.calculateNextEndDateWithTimezone(template, lastTaskEndDate, timezone);
|
||||||
const endDatesToCreate: moment.Moment[] = [];
|
const endDatesToCreate: moment.Moment[] = [];
|
||||||
|
|
||||||
// Find all future occurrences within the limit
|
// Find all future occurrences within the limit
|
||||||
while (nextEndDate.isSameOrBefore(futureLimit)) {
|
while (nextEndDate.isSameOrBefore(futureLimit)) {
|
||||||
if (nextEndDate.isAfter(now)) {
|
if (nextEndDate.isAfter(now)) {
|
||||||
|
// Check if date is not in excluded dates
|
||||||
|
if (!template.excluded_dates || !template.excluded_dates.includes(nextEndDate.format(TIME_FORMAT))) {
|
||||||
endDatesToCreate.push(moment(nextEndDate));
|
endDatesToCreate.push(moment(nextEndDate));
|
||||||
}
|
}
|
||||||
nextEndDate = calculateNextEndDate(template, nextEndDate);
|
}
|
||||||
|
nextEndDate = TimezoneUtils.calculateNextEndDateWithTimezone(template, nextEndDate, timezone);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Batch create tasks for all future dates
|
// Batch create tasks for all future dates
|
||||||
if (endDatesToCreate.length > 0) {
|
if (endDatesToCreate.length > 0) {
|
||||||
|
try {
|
||||||
const createdTasks = await createBatchTasks(template, endDatesToCreate);
|
const createdTasks = await createBatchTasks(template, endDatesToCreate);
|
||||||
createdTaskCount += createdTasks.length;
|
createdTaskCount += createdTasks.length;
|
||||||
|
|
||||||
// Update the last_checked_at in the schedule
|
// Log successful template processing
|
||||||
|
await RecurringTasksAuditLogger.logTemplateProcessing(
|
||||||
|
template.task_id,
|
||||||
|
template.name,
|
||||||
|
template.schedule_id,
|
||||||
|
createdTasks.length,
|
||||||
|
endDatesToCreate.length - createdTasks.length,
|
||||||
|
{
|
||||||
|
timezone,
|
||||||
|
endDates: endDatesToCreate.map(d => d.format(TIME_FORMAT))
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Update the last_checked_at in the schedule with retry logic
|
||||||
|
await RetryUtils.withDatabaseRetry(async () => {
|
||||||
const updateScheduleQuery = `
|
const updateScheduleQuery = `
|
||||||
UPDATE task_recurring_schedules
|
UPDATE task_recurring_schedules
|
||||||
SET last_checked_at = $1::DATE,
|
SET last_checked_at = $1,
|
||||||
last_created_task_end_date = $2
|
last_created_task_end_date = $2
|
||||||
WHERE id = $3;
|
WHERE id = $3;
|
||||||
`;
|
`;
|
||||||
await db.query(updateScheduleQuery, [
|
return await db.query(updateScheduleQuery, [
|
||||||
moment().format(TIME_FORMAT),
|
now.toDate(),
|
||||||
endDatesToCreate[endDatesToCreate.length - 1].format(TIME_FORMAT),
|
endDatesToCreate[endDatesToCreate.length - 1].toDate(),
|
||||||
template.schedule_id
|
template.schedule_id
|
||||||
]);
|
]);
|
||||||
|
}, `update_schedule for template ${template.name}`);
|
||||||
|
} catch (error) {
|
||||||
|
errors.push({ template: template.name, error });
|
||||||
|
|
||||||
|
// Log failed template processing
|
||||||
|
await RecurringTasksAuditLogger.logTemplateProcessing(
|
||||||
|
template.task_id,
|
||||||
|
template.name,
|
||||||
|
template.schedule_id,
|
||||||
|
0,
|
||||||
|
endDatesToCreate.length,
|
||||||
|
{
|
||||||
|
timezone,
|
||||||
|
error: error.message || error.toString()
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`No tasks created for template ${template.name} - next occurrence is beyond the future limit`);
|
console.log(`No tasks created for template ${template.name} (${timezone}) - next occurrence is beyond the future limit or excluded`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log(`(cron) Recurring tasks job ended with ${createdTaskCount} new tasks created.`);
|
log(`(cron) Recurring tasks job ended with ${createdTaskCount} new tasks created.`);
|
||||||
|
|
||||||
|
// Log cron job completion
|
||||||
|
await RecurringTasksAuditLogger.logCronJobRun(
|
||||||
|
templates.length,
|
||||||
|
createdTaskCount,
|
||||||
|
errors
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log_error(error);
|
log_error(error);
|
||||||
log("(cron) Recurring task job ended with errors.");
|
log("(cron) Recurring task job ended with errors.");
|
||||||
|
|
||||||
|
// Log cron job failure
|
||||||
|
await RecurringTasksAuditLogger.log({
|
||||||
|
operationType: RecurringTaskOperationType.CRON_JOB_ERROR,
|
||||||
|
success: false,
|
||||||
|
errorMessage: error.message || error.toString(),
|
||||||
|
details: { error: error.stack || error }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ export interface IRecurringSchedule {
|
|||||||
last_checked_at: Date | null;
|
last_checked_at: Date | null;
|
||||||
last_task_end_date: Date | null;
|
last_task_end_date: Date | null;
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
|
timezone?: string;
|
||||||
|
end_date?: Date | null;
|
||||||
|
excluded_dates?: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ITaskTemplateAssignee {
|
interface ITaskTemplateAssignee {
|
||||||
|
|||||||
322
worklenz-backend/src/jobs/recurring-tasks-queue.ts
Normal file
322
worklenz-backend/src/jobs/recurring-tasks-queue.ts
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
import Bull from 'bull';
|
||||||
|
import { TimezoneUtils } from '../utils/timezone-utils';
|
||||||
|
import { RetryUtils } from '../utils/retry-utils';
|
||||||
|
import { RecurringTasksAuditLogger, RecurringTaskOperationType } from '../utils/recurring-tasks-audit-logger';
|
||||||
|
import { RecurringTasksPermissions } from '../utils/recurring-tasks-permissions';
|
||||||
|
import { RecurringTasksNotifications } from '../utils/recurring-tasks-notifications';
|
||||||
|
import { calculateNextEndDate, log_error } from '../shared/utils';
|
||||||
|
import { IRecurringSchedule, ITaskTemplate } from '../interfaces/recurring-tasks';
|
||||||
|
import moment from 'moment-timezone';
|
||||||
|
import db from '../config/db';
|
||||||
|
|
||||||
|
// Configure Redis connection
|
||||||
|
const redisConfig = {
|
||||||
|
host: process.env.REDIS_HOST || 'localhost',
|
||||||
|
port: parseInt(process.env.REDIS_PORT || '6379'),
|
||||||
|
password: process.env.REDIS_PASSWORD,
|
||||||
|
db: parseInt(process.env.REDIS_DB || '0'),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create job queues
|
||||||
|
export const recurringTasksQueue = new Bull('recurring-tasks', {
|
||||||
|
redis: redisConfig,
|
||||||
|
defaultJobOptions: {
|
||||||
|
removeOnComplete: 100, // Keep last 100 completed jobs
|
||||||
|
removeOnFail: 50, // Keep last 50 failed jobs
|
||||||
|
attempts: 3,
|
||||||
|
backoff: {
|
||||||
|
type: 'exponential',
|
||||||
|
delay: 2000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const taskCreationQueue = new Bull('task-creation', {
|
||||||
|
redis: redisConfig,
|
||||||
|
defaultJobOptions: {
|
||||||
|
removeOnComplete: 200,
|
||||||
|
removeOnFail: 100,
|
||||||
|
attempts: 5,
|
||||||
|
backoff: {
|
||||||
|
type: 'exponential',
|
||||||
|
delay: 1000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Job data interfaces
|
||||||
|
interface RecurringTaskJobData {
|
||||||
|
templateId: string;
|
||||||
|
scheduleId: string;
|
||||||
|
timezone: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TaskCreationJobData {
|
||||||
|
template: ITaskTemplate & IRecurringSchedule;
|
||||||
|
endDates: string[];
|
||||||
|
timezone: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Job processors
|
||||||
|
recurringTasksQueue.process('process-template', async (job) => {
|
||||||
|
const { templateId, scheduleId, timezone }: RecurringTaskJobData = job.data;
|
||||||
|
|
||||||
|
try {
|
||||||
|
RecurringTasksAuditLogger.startTimer();
|
||||||
|
|
||||||
|
// Fetch template data
|
||||||
|
const templateQuery = `
|
||||||
|
SELECT t.*, s.*,
|
||||||
|
(SELECT MAX(end_date) FROM tasks WHERE schedule_id = s.id) as last_task_end_date,
|
||||||
|
u.timezone as user_timezone
|
||||||
|
FROM task_recurring_templates t
|
||||||
|
JOIN task_recurring_schedules s ON t.schedule_id = s.id
|
||||||
|
LEFT JOIN tasks orig_task ON t.task_id = orig_task.id
|
||||||
|
LEFT JOIN users u ON orig_task.reporter_id = u.id
|
||||||
|
WHERE t.id = $1 AND s.id = $2
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await RetryUtils.withDatabaseRetry(async () => {
|
||||||
|
return await db.query(templateQuery, [templateId, scheduleId]);
|
||||||
|
}, 'fetch_template_for_job');
|
||||||
|
|
||||||
|
if (result.rows.length === 0) {
|
||||||
|
throw new Error(`Template ${templateId} not found`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const template = result.rows[0] as ITaskTemplate & IRecurringSchedule & { user_timezone?: string };
|
||||||
|
|
||||||
|
// Check permissions
|
||||||
|
const permissionCheck = await RecurringTasksPermissions.validateTemplatePermissions(template.task_id);
|
||||||
|
if (!permissionCheck.hasPermission) {
|
||||||
|
await RecurringTasksAuditLogger.log({
|
||||||
|
operationType: RecurringTaskOperationType.TASKS_CREATION_FAILED,
|
||||||
|
templateId: template.task_id,
|
||||||
|
scheduleId: template.schedule_id,
|
||||||
|
templateName: template.name,
|
||||||
|
success: false,
|
||||||
|
errorMessage: `Permission denied: ${permissionCheck.reason}`,
|
||||||
|
details: { permissionCheck, processedBy: 'job_queue' }
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate dates to create
|
||||||
|
const now = TimezoneUtils.nowInTimezone(timezone);
|
||||||
|
const lastTaskEndDate = template.last_task_end_date
|
||||||
|
? moment.tz(template.last_task_end_date, timezone)
|
||||||
|
: moment.tz(template.created_at, timezone);
|
||||||
|
|
||||||
|
const futureLimit = moment.tz(template.last_checked_at || template.created_at, timezone)
|
||||||
|
.add(getFutureLimit(
|
||||||
|
template.schedule_type,
|
||||||
|
template.interval_days || template.interval_weeks || template.interval_months || 1
|
||||||
|
));
|
||||||
|
|
||||||
|
let nextEndDate = TimezoneUtils.calculateNextEndDateWithTimezone(template, lastTaskEndDate, timezone);
|
||||||
|
const endDatesToCreate: string[] = [];
|
||||||
|
|
||||||
|
while (nextEndDate.isSameOrBefore(futureLimit)) {
|
||||||
|
if (nextEndDate.isAfter(now)) {
|
||||||
|
if (!template.excluded_dates || !template.excluded_dates.includes(nextEndDate.format('YYYY-MM-DD'))) {
|
||||||
|
endDatesToCreate.push(nextEndDate.format('YYYY-MM-DD'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nextEndDate = TimezoneUtils.calculateNextEndDateWithTimezone(template, nextEndDate, timezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endDatesToCreate.length > 0) {
|
||||||
|
// Add task creation job
|
||||||
|
await taskCreationQueue.add('create-tasks', {
|
||||||
|
template,
|
||||||
|
endDates: endDatesToCreate,
|
||||||
|
timezone
|
||||||
|
}, {
|
||||||
|
priority: 10, // Higher priority for task creation
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update schedule
|
||||||
|
await RetryUtils.withDatabaseRetry(async () => {
|
||||||
|
const updateQuery = `
|
||||||
|
UPDATE task_recurring_schedules
|
||||||
|
SET last_checked_at = $1
|
||||||
|
WHERE id = $2;
|
||||||
|
`;
|
||||||
|
return await db.query(updateQuery, [now.toDate(), scheduleId]);
|
||||||
|
}, `update_schedule_for_template_${templateId}`);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error('Error processing recurring task template:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
taskCreationQueue.process('create-tasks', async (job) => {
|
||||||
|
const { template, endDates, timezone }: TaskCreationJobData = job.data;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Create tasks using the bulk function from the cron job
|
||||||
|
const tasksData = endDates.map(endDate => ({
|
||||||
|
name: template.name,
|
||||||
|
priority_id: template.priority_id,
|
||||||
|
project_id: template.project_id,
|
||||||
|
reporter_id: template.reporter_id,
|
||||||
|
status_id: template.status_id || null,
|
||||||
|
end_date: endDate,
|
||||||
|
schedule_id: template.schedule_id
|
||||||
|
}));
|
||||||
|
|
||||||
|
const createTasksResult = await RetryUtils.withDatabaseRetry(async () => {
|
||||||
|
const createTasksQuery = `SELECT * FROM create_bulk_recurring_tasks($1::JSONB);`;
|
||||||
|
return await db.query(createTasksQuery, [JSON.stringify(tasksData)]);
|
||||||
|
}, `create_bulk_tasks_queue_${template.name}`);
|
||||||
|
|
||||||
|
const createdTasks = createTasksResult.rows.filter(row => row.created);
|
||||||
|
const failedTasks = createTasksResult.rows.filter(row => !row.created);
|
||||||
|
|
||||||
|
// Handle assignments and labels (similar to cron job implementation)
|
||||||
|
if (createdTasks.length > 0 && (template.assignees?.length > 0 || template.labels?.length > 0)) {
|
||||||
|
// ... (assignment logic from cron job)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send notifications
|
||||||
|
if (createdTasks.length > 0) {
|
||||||
|
const taskData = createdTasks.map(task => ({ id: task.task_id, name: task.task_name }));
|
||||||
|
const assigneeIds = template.assignees?.map(a => a.team_member_id) || [];
|
||||||
|
|
||||||
|
await RecurringTasksNotifications.notifyRecurringTasksCreated(
|
||||||
|
template.name,
|
||||||
|
template.project_id,
|
||||||
|
taskData,
|
||||||
|
assigneeIds,
|
||||||
|
template.reporter_id
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log results
|
||||||
|
await RecurringTasksAuditLogger.logTemplateProcessing(
|
||||||
|
template.task_id,
|
||||||
|
template.name,
|
||||||
|
template.schedule_id,
|
||||||
|
createdTasks.length,
|
||||||
|
failedTasks.length,
|
||||||
|
{
|
||||||
|
timezone,
|
||||||
|
endDates,
|
||||||
|
processedBy: 'job_queue'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
created: createdTasks.length,
|
||||||
|
failed: failedTasks.length
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error('Error creating tasks in queue:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Helper function (copied from cron job)
|
||||||
|
function getFutureLimit(scheduleType: string, interval?: number): moment.Duration {
|
||||||
|
const FUTURE_LIMITS = {
|
||||||
|
daily: moment.duration(3, "days"),
|
||||||
|
weekly: moment.duration(1, "week"),
|
||||||
|
monthly: moment.duration(1, "month"),
|
||||||
|
every_x_days: (interval: number) => moment.duration(interval, "days"),
|
||||||
|
every_x_weeks: (interval: number) => moment.duration(interval, "weeks"),
|
||||||
|
every_x_months: (interval: number) => moment.duration(interval, "months")
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (scheduleType) {
|
||||||
|
case "daily":
|
||||||
|
return FUTURE_LIMITS.daily;
|
||||||
|
case "weekly":
|
||||||
|
return FUTURE_LIMITS.weekly;
|
||||||
|
case "monthly":
|
||||||
|
return FUTURE_LIMITS.monthly;
|
||||||
|
case "every_x_days":
|
||||||
|
return FUTURE_LIMITS.every_x_days(interval || 1);
|
||||||
|
case "every_x_weeks":
|
||||||
|
return FUTURE_LIMITS.every_x_weeks(interval || 1);
|
||||||
|
case "every_x_months":
|
||||||
|
return FUTURE_LIMITS.every_x_months(interval || 1);
|
||||||
|
default:
|
||||||
|
return moment.duration(3, "days");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Job schedulers
|
||||||
|
export class RecurringTasksJobScheduler {
|
||||||
|
/**
|
||||||
|
* Schedule recurring task processing for all templates
|
||||||
|
*/
|
||||||
|
static async scheduleRecurringTasks(): Promise<void> {
|
||||||
|
try {
|
||||||
|
// Get all active templates
|
||||||
|
const templatesQuery = `
|
||||||
|
SELECT t.id as template_id, s.id as schedule_id,
|
||||||
|
COALESCE(s.timezone, u.timezone, 'UTC') as timezone
|
||||||
|
FROM task_recurring_templates t
|
||||||
|
JOIN task_recurring_schedules s ON t.schedule_id = s.id
|
||||||
|
LEFT JOIN tasks orig_task ON t.task_id = orig_task.id
|
||||||
|
LEFT JOIN users u ON orig_task.reporter_id = u.id
|
||||||
|
WHERE s.end_date IS NULL OR s.end_date >= CURRENT_DATE
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(templatesQuery);
|
||||||
|
|
||||||
|
// Schedule a job for each template
|
||||||
|
for (const template of result.rows) {
|
||||||
|
await recurringTasksQueue.add('process-template', {
|
||||||
|
templateId: template.template_id,
|
||||||
|
scheduleId: template.schedule_id,
|
||||||
|
timezone: template.timezone
|
||||||
|
}, {
|
||||||
|
delay: Math.random() * 60000, // Random delay up to 1 minute to spread load
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error('Error scheduling recurring tasks:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the job queue system
|
||||||
|
*/
|
||||||
|
static async start(): Promise<void> {
|
||||||
|
console.log('Starting recurring tasks job queue...');
|
||||||
|
|
||||||
|
// Schedule recurring task processing every hour
|
||||||
|
await recurringTasksQueue.add('schedule-all', {}, {
|
||||||
|
repeat: { cron: '0 * * * *' }, // Every hour
|
||||||
|
removeOnComplete: 1,
|
||||||
|
removeOnFail: 1,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Process the schedule-all job
|
||||||
|
recurringTasksQueue.process('schedule-all', async () => {
|
||||||
|
await this.scheduleRecurringTasks();
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('Recurring tasks job queue started');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get queue statistics
|
||||||
|
*/
|
||||||
|
static async getStats(): Promise<any> {
|
||||||
|
const [recurringStats, creationStats] = await Promise.all([
|
||||||
|
recurringTasksQueue.getJobCounts(),
|
||||||
|
taskCreationQueue.getJobCounts()
|
||||||
|
]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
recurringTasks: recurringStats,
|
||||||
|
taskCreation: creationStats
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
162
worklenz-backend/src/services/recurring-tasks-service.ts
Normal file
162
worklenz-backend/src/services/recurring-tasks-service.ts
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
import { recurringTasksConfig } from '../config/recurring-tasks-config';
|
||||||
|
import { startRecurringTasksJob } from '../cron_jobs/recurring-tasks';
|
||||||
|
import { RecurringTasksJobScheduler } from '../jobs/recurring-tasks-queue';
|
||||||
|
import { log_error } from '../shared/utils';
|
||||||
|
|
||||||
|
export class RecurringTasksService {
|
||||||
|
private static isStarted = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the recurring tasks service based on configuration
|
||||||
|
*/
|
||||||
|
static async start(): Promise<void> {
|
||||||
|
if (this.isStarted) {
|
||||||
|
console.log('Recurring tasks service already started');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recurringTasksConfig.enabled) {
|
||||||
|
console.log('Recurring tasks service disabled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log(`Starting recurring tasks service in ${recurringTasksConfig.mode} mode...`);
|
||||||
|
|
||||||
|
switch (recurringTasksConfig.mode) {
|
||||||
|
case 'cron':
|
||||||
|
startRecurringTasksJob();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'queue':
|
||||||
|
await RecurringTasksJobScheduler.start();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown recurring tasks mode: ${recurringTasksConfig.mode}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isStarted = true;
|
||||||
|
console.log(`Recurring tasks service started successfully in ${recurringTasksConfig.mode} mode`);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error('Failed to start recurring tasks service:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the recurring tasks service
|
||||||
|
*/
|
||||||
|
static async stop(): Promise<void> {
|
||||||
|
if (!this.isStarted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log('Stopping recurring tasks service...');
|
||||||
|
|
||||||
|
if (recurringTasksConfig.mode === 'queue') {
|
||||||
|
// Close queue connections
|
||||||
|
const { recurringTasksQueue, taskCreationQueue } = await import('../jobs/recurring-tasks-queue');
|
||||||
|
await recurringTasksQueue.close();
|
||||||
|
await taskCreationQueue.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isStarted = false;
|
||||||
|
console.log('Recurring tasks service stopped');
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error('Error stopping recurring tasks service:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get service status and statistics
|
||||||
|
*/
|
||||||
|
static async getStatus(): Promise<any> {
|
||||||
|
const status = {
|
||||||
|
enabled: recurringTasksConfig.enabled,
|
||||||
|
mode: recurringTasksConfig.mode,
|
||||||
|
started: this.isStarted,
|
||||||
|
config: recurringTasksConfig
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.isStarted && recurringTasksConfig.mode === 'queue') {
|
||||||
|
try {
|
||||||
|
const stats = await RecurringTasksJobScheduler.getStats();
|
||||||
|
return { ...status, queueStats: stats };
|
||||||
|
} catch (error) {
|
||||||
|
return { ...status, queueStatsError: error.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manually trigger recurring tasks processing
|
||||||
|
*/
|
||||||
|
static async triggerManual(): Promise<void> {
|
||||||
|
if (!this.isStarted) {
|
||||||
|
throw new Error('Recurring tasks service is not started');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (recurringTasksConfig.mode === 'queue') {
|
||||||
|
await RecurringTasksJobScheduler.scheduleRecurringTasks();
|
||||||
|
} else {
|
||||||
|
// For cron mode, we can't manually trigger easily
|
||||||
|
// Could implement a manual trigger function in the cron job file
|
||||||
|
throw new Error('Manual trigger not supported in cron mode');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
log_error('Error manually triggering recurring tasks:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Health check for the service
|
||||||
|
*/
|
||||||
|
static async healthCheck(): Promise<{ healthy: boolean; message: string; details?: any }> {
|
||||||
|
try {
|
||||||
|
if (!recurringTasksConfig.enabled) {
|
||||||
|
return {
|
||||||
|
healthy: true,
|
||||||
|
message: 'Recurring tasks service is disabled'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isStarted) {
|
||||||
|
return {
|
||||||
|
healthy: false,
|
||||||
|
message: 'Recurring tasks service is not started'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recurringTasksConfig.mode === 'queue') {
|
||||||
|
const stats = await RecurringTasksJobScheduler.getStats();
|
||||||
|
const hasFailures = stats.recurringTasks.failed > 0 || stats.taskCreation.failed > 0;
|
||||||
|
|
||||||
|
return {
|
||||||
|
healthy: !hasFailures,
|
||||||
|
message: hasFailures ? 'Some jobs are failing' : 'All systems operational',
|
||||||
|
details: stats
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
healthy: true,
|
||||||
|
message: `Running in ${recurringTasksConfig.mode} mode`
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
return {
|
||||||
|
healthy: false,
|
||||||
|
message: 'Health check failed',
|
||||||
|
details: { error: error.message }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,11 +53,27 @@ function notifyStatusChange(socket: Socket, config: Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function emitSortOrderChange(data: ChangeRequest, socket: Socket) {
|
async function emitSortOrderChange(data: ChangeRequest, socket: Socket) {
|
||||||
|
// Determine which sort column to use based on group_by
|
||||||
|
let sortColumn = "sort_order";
|
||||||
|
switch (data.group_by) {
|
||||||
|
case "status":
|
||||||
|
sortColumn = "status_sort_order";
|
||||||
|
break;
|
||||||
|
case "priority":
|
||||||
|
sortColumn = "priority_sort_order";
|
||||||
|
break;
|
||||||
|
case "phase":
|
||||||
|
sortColumn = "phase_sort_order";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sortColumn = "sort_order";
|
||||||
|
}
|
||||||
|
|
||||||
const q = `
|
const q = `
|
||||||
SELECT id, sort_order, completed_at
|
SELECT id, sort_order, ${sortColumn} as current_sort_order, completed_at
|
||||||
FROM tasks
|
FROM tasks
|
||||||
WHERE project_id = $1
|
WHERE project_id = $1
|
||||||
ORDER BY sort_order;
|
ORDER BY ${sortColumn};
|
||||||
`;
|
`;
|
||||||
const tasks = await db.query(q, [data.project_id]);
|
const tasks = await db.query(q, [data.project_id]);
|
||||||
socket.emit(SocketEvents.TASK_SORT_ORDER_CHANGE.toString(), tasks.rows);
|
socket.emit(SocketEvents.TASK_SORT_ORDER_CHANGE.toString(), tasks.rows);
|
||||||
@@ -84,9 +100,9 @@ export async function on_task_sort_order_change(_io: Server, socket: Socket, dat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the simple bulk update function
|
// Use the simple bulk update function with group_by parameter
|
||||||
const q = `SELECT update_task_sort_orders_bulk($1);`;
|
const q = `SELECT update_task_sort_orders_bulk($1, $2);`;
|
||||||
await db.query(q, [JSON.stringify(data.task_updates)]);
|
await db.query(q, [JSON.stringify(data.task_updates), data.group_by || "status"]);
|
||||||
await emitSortOrderChange(data, socket);
|
await emitSortOrderChange(data, socket);
|
||||||
|
|
||||||
// Handle notifications and logging
|
// Handle notifications and logging
|
||||||
|
|||||||
189
worklenz-backend/src/utils/recurring-tasks-audit-logger.ts
Normal file
189
worklenz-backend/src/utils/recurring-tasks-audit-logger.ts
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
import db from "../config/db";
|
||||||
|
import { log_error } from "../shared/utils";
|
||||||
|
|
||||||
|
export enum RecurringTaskOperationType {
|
||||||
|
CRON_JOB_RUN = "cron_job_run",
|
||||||
|
CRON_JOB_ERROR = "cron_job_error",
|
||||||
|
TEMPLATE_CREATED = "template_created",
|
||||||
|
TEMPLATE_UPDATED = "template_updated",
|
||||||
|
TEMPLATE_DELETED = "template_deleted",
|
||||||
|
SCHEDULE_CREATED = "schedule_created",
|
||||||
|
SCHEDULE_UPDATED = "schedule_updated",
|
||||||
|
SCHEDULE_DELETED = "schedule_deleted",
|
||||||
|
TASKS_CREATED = "tasks_created",
|
||||||
|
TASKS_CREATION_FAILED = "tasks_creation_failed",
|
||||||
|
MANUAL_TRIGGER = "manual_trigger",
|
||||||
|
BULK_OPERATION = "bulk_operation"
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AuditLogEntry {
|
||||||
|
operationType: RecurringTaskOperationType;
|
||||||
|
templateId?: string;
|
||||||
|
scheduleId?: string;
|
||||||
|
taskId?: string;
|
||||||
|
templateName?: string;
|
||||||
|
success?: boolean;
|
||||||
|
errorMessage?: string;
|
||||||
|
details?: any;
|
||||||
|
createdTasksCount?: number;
|
||||||
|
failedTasksCount?: number;
|
||||||
|
executionTimeMs?: number;
|
||||||
|
createdBy?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RecurringTasksAuditLogger {
|
||||||
|
private static startTime: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start timing an operation
|
||||||
|
*/
|
||||||
|
static startTimer(): void {
|
||||||
|
this.startTime = Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get elapsed time since timer started
|
||||||
|
*/
|
||||||
|
static getElapsedTime(): number {
|
||||||
|
return this.startTime ? Date.now() - this.startTime : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a recurring task operation
|
||||||
|
*/
|
||||||
|
static async log(entry: AuditLogEntry): Promise<void> {
|
||||||
|
try {
|
||||||
|
const query = `SELECT log_recurring_task_operation($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);`;
|
||||||
|
|
||||||
|
await db.query(query, [
|
||||||
|
entry.operationType,
|
||||||
|
entry.templateId || null,
|
||||||
|
entry.scheduleId || null,
|
||||||
|
entry.taskId || null,
|
||||||
|
entry.templateName || null,
|
||||||
|
entry.success !== false, // Default to true
|
||||||
|
entry.errorMessage || null,
|
||||||
|
entry.details ? JSON.stringify(entry.details) : null,
|
||||||
|
entry.createdTasksCount || 0,
|
||||||
|
entry.failedTasksCount || 0,
|
||||||
|
entry.executionTimeMs || this.getElapsedTime(),
|
||||||
|
entry.createdBy || null
|
||||||
|
]);
|
||||||
|
} catch (error) {
|
||||||
|
// Don't let audit logging failures break the main flow
|
||||||
|
log_error("Failed to log recurring task audit entry:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log cron job execution
|
||||||
|
*/
|
||||||
|
static async logCronJobRun(
|
||||||
|
totalTemplates: number,
|
||||||
|
createdTasksCount: number,
|
||||||
|
errors: any[] = []
|
||||||
|
): Promise<void> {
|
||||||
|
await this.log({
|
||||||
|
operationType: RecurringTaskOperationType.CRON_JOB_RUN,
|
||||||
|
success: errors.length === 0,
|
||||||
|
errorMessage: errors.length > 0 ? `${errors.length} errors occurred` : undefined,
|
||||||
|
details: {
|
||||||
|
totalTemplates,
|
||||||
|
errors: errors.map(e => e.message || e.toString())
|
||||||
|
},
|
||||||
|
createdTasksCount,
|
||||||
|
executionTimeMs: this.getElapsedTime()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log template processing
|
||||||
|
*/
|
||||||
|
static async logTemplateProcessing(
|
||||||
|
templateId: string,
|
||||||
|
templateName: string,
|
||||||
|
scheduleId: string,
|
||||||
|
createdCount: number,
|
||||||
|
failedCount: number,
|
||||||
|
details?: any
|
||||||
|
): Promise<void> {
|
||||||
|
await this.log({
|
||||||
|
operationType: RecurringTaskOperationType.TASKS_CREATED,
|
||||||
|
templateId,
|
||||||
|
scheduleId,
|
||||||
|
templateName,
|
||||||
|
success: failedCount === 0,
|
||||||
|
createdTasksCount: createdCount,
|
||||||
|
failedTasksCount: failedCount,
|
||||||
|
details
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log schedule changes
|
||||||
|
*/
|
||||||
|
static async logScheduleChange(
|
||||||
|
operationType: RecurringTaskOperationType,
|
||||||
|
scheduleId: string,
|
||||||
|
templateId?: string,
|
||||||
|
userId?: string,
|
||||||
|
details?: any
|
||||||
|
): Promise<void> {
|
||||||
|
await this.log({
|
||||||
|
operationType,
|
||||||
|
scheduleId,
|
||||||
|
templateId,
|
||||||
|
createdBy: userId,
|
||||||
|
details
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get audit log summary
|
||||||
|
*/
|
||||||
|
static async getAuditSummary(days: number = 7): Promise<any> {
|
||||||
|
try {
|
||||||
|
const query = `
|
||||||
|
SELECT
|
||||||
|
operation_type,
|
||||||
|
COUNT(*) as count,
|
||||||
|
SUM(CASE WHEN success THEN 1 ELSE 0 END) as success_count,
|
||||||
|
SUM(CASE WHEN NOT success THEN 1 ELSE 0 END) as failure_count,
|
||||||
|
SUM(created_tasks_count) as total_tasks_created,
|
||||||
|
SUM(failed_tasks_count) as total_tasks_failed,
|
||||||
|
AVG(execution_time_ms) as avg_execution_time_ms
|
||||||
|
FROM recurring_tasks_audit_log
|
||||||
|
WHERE created_at >= CURRENT_TIMESTAMP - INTERVAL '${days} days'
|
||||||
|
GROUP BY operation_type
|
||||||
|
ORDER BY count DESC;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(query);
|
||||||
|
return result.rows;
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to get audit summary:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get recent errors
|
||||||
|
*/
|
||||||
|
static async getRecentErrors(limit: number = 10): Promise<any[]> {
|
||||||
|
try {
|
||||||
|
const query = `
|
||||||
|
SELECT *
|
||||||
|
FROM v_recent_recurring_tasks_audit
|
||||||
|
WHERE NOT success
|
||||||
|
ORDER BY created_at DESC
|
||||||
|
LIMIT $1;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(query, [limit]);
|
||||||
|
return result.rows;
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to get recent errors:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
260
worklenz-backend/src/utils/recurring-tasks-notifications.ts
Normal file
260
worklenz-backend/src/utils/recurring-tasks-notifications.ts
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
import db from "../config/db";
|
||||||
|
import { log_error } from "../shared/utils";
|
||||||
|
|
||||||
|
export interface NotificationData {
|
||||||
|
userId: string;
|
||||||
|
projectId: string;
|
||||||
|
taskId: string;
|
||||||
|
taskName: string;
|
||||||
|
templateName: string;
|
||||||
|
scheduleId: string;
|
||||||
|
createdBy?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RecurringTasksNotifications {
|
||||||
|
/**
|
||||||
|
* Send notification to user about a new recurring task
|
||||||
|
*/
|
||||||
|
static async notifyTaskCreated(data: NotificationData): Promise<void> {
|
||||||
|
try {
|
||||||
|
// Create notification in the database
|
||||||
|
const notificationQuery = `
|
||||||
|
INSERT INTO notifications (
|
||||||
|
user_id,
|
||||||
|
message,
|
||||||
|
data,
|
||||||
|
created_at
|
||||||
|
) VALUES ($1, $2, $3, NOW())
|
||||||
|
`;
|
||||||
|
|
||||||
|
const message = `New recurring task "${data.taskName}" has been created from template "${data.templateName}"`;
|
||||||
|
const notificationData = {
|
||||||
|
type: 'recurring_task_created',
|
||||||
|
task_id: data.taskId,
|
||||||
|
project_id: data.projectId,
|
||||||
|
schedule_id: data.scheduleId,
|
||||||
|
task_name: data.taskName,
|
||||||
|
template_name: data.templateName
|
||||||
|
};
|
||||||
|
|
||||||
|
await db.query(notificationQuery, [
|
||||||
|
data.userId,
|
||||||
|
message,
|
||||||
|
JSON.stringify(notificationData)
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to create notification:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send notifications to all assignees of created tasks
|
||||||
|
*/
|
||||||
|
static async notifyAssignees(
|
||||||
|
taskIds: string[],
|
||||||
|
templateName: string,
|
||||||
|
projectId: string
|
||||||
|
): Promise<void> {
|
||||||
|
if (taskIds.length === 0) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Get all assignees for the created tasks
|
||||||
|
const assigneesQuery = `
|
||||||
|
SELECT DISTINCT ta.team_member_id, t.id as task_id, t.name as task_name
|
||||||
|
FROM tasks_assignees ta
|
||||||
|
JOIN tasks t ON ta.task_id = t.id
|
||||||
|
WHERE t.id = ANY($1)
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(assigneesQuery, [taskIds]);
|
||||||
|
|
||||||
|
// Send notification to each assignee
|
||||||
|
for (const assignee of result.rows) {
|
||||||
|
await this.notifyTaskCreated({
|
||||||
|
userId: assignee.team_member_id,
|
||||||
|
projectId,
|
||||||
|
taskId: assignee.task_id,
|
||||||
|
taskName: assignee.task_name,
|
||||||
|
templateName,
|
||||||
|
scheduleId: '' // Not needed for assignee notifications
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to notify assignees:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send email notifications (if email system is configured)
|
||||||
|
*/
|
||||||
|
static async sendEmailNotifications(
|
||||||
|
userIds: string[],
|
||||||
|
subject: string,
|
||||||
|
message: string
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
// Get user email addresses
|
||||||
|
const usersQuery = `
|
||||||
|
SELECT id, email, name, email_notifications
|
||||||
|
FROM users
|
||||||
|
WHERE id = ANY($1) AND email_notifications = true AND email IS NOT NULL
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(usersQuery, [userIds]);
|
||||||
|
|
||||||
|
// TODO: Integrate with your email service (SendGrid, AWS SES, etc.)
|
||||||
|
// For now, just log the email notifications that would be sent
|
||||||
|
for (const user of result.rows) {
|
||||||
|
console.log(`Email notification would be sent to ${user.email}: ${subject}`);
|
||||||
|
|
||||||
|
// Example: await emailService.send({
|
||||||
|
// to: user.email,
|
||||||
|
// subject,
|
||||||
|
// html: message
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to send email notifications:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send push notifications (if push notification system is configured)
|
||||||
|
*/
|
||||||
|
static async sendPushNotifications(
|
||||||
|
userIds: string[],
|
||||||
|
title: string,
|
||||||
|
body: string,
|
||||||
|
data?: any
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
// Get user push tokens
|
||||||
|
const tokensQuery = `
|
||||||
|
SELECT user_id, push_token
|
||||||
|
FROM user_push_tokens
|
||||||
|
WHERE user_id = ANY($1) AND push_token IS NOT NULL
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(tokensQuery, [userIds]);
|
||||||
|
|
||||||
|
// TODO: Integrate with your push notification service (FCM, APNs, etc.)
|
||||||
|
// For now, just log the push notifications that would be sent
|
||||||
|
for (const token of result.rows) {
|
||||||
|
console.log(`Push notification would be sent to ${token.push_token}: ${title}`);
|
||||||
|
|
||||||
|
// Example: await pushService.send({
|
||||||
|
// token: token.push_token,
|
||||||
|
// title,
|
||||||
|
// body,
|
||||||
|
// data
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to send push notifications:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get notification preferences for users
|
||||||
|
*/
|
||||||
|
static async getNotificationPreferences(userIds: string[]): Promise<any[]> {
|
||||||
|
try {
|
||||||
|
const query = `
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
email_notifications,
|
||||||
|
push_notifications,
|
||||||
|
in_app_notifications
|
||||||
|
FROM users
|
||||||
|
WHERE id = ANY($1)
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(query, [userIds]);
|
||||||
|
return result.rows;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to get notification preferences:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comprehensive notification for recurring task creation
|
||||||
|
*/
|
||||||
|
static async notifyRecurringTasksCreated(
|
||||||
|
templateName: string,
|
||||||
|
projectId: string,
|
||||||
|
createdTasks: Array<{ id: string; name: string }>,
|
||||||
|
assignees: string[] = [],
|
||||||
|
reporterId?: string
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const taskIds = createdTasks.map(t => t.id);
|
||||||
|
const allUserIds = [...new Set([...assignees, reporterId].filter(Boolean))];
|
||||||
|
|
||||||
|
if (allUserIds.length === 0) return;
|
||||||
|
|
||||||
|
// Get notification preferences
|
||||||
|
const preferences = await this.getNotificationPreferences(allUserIds);
|
||||||
|
|
||||||
|
// Send in-app notifications
|
||||||
|
const inAppUsers = preferences.filter(p => p.in_app_notifications !== false);
|
||||||
|
for (const user of inAppUsers) {
|
||||||
|
for (const task of createdTasks) {
|
||||||
|
await this.notifyTaskCreated({
|
||||||
|
userId: user.id,
|
||||||
|
projectId,
|
||||||
|
taskId: task.id,
|
||||||
|
taskName: task.name,
|
||||||
|
templateName,
|
||||||
|
scheduleId: '',
|
||||||
|
createdBy: 'system'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send email notifications
|
||||||
|
const emailUsers = preferences
|
||||||
|
.filter(p => p.email_notifications === true)
|
||||||
|
.map(p => p.id);
|
||||||
|
|
||||||
|
if (emailUsers.length > 0) {
|
||||||
|
const subject = `New Recurring Tasks Created: ${templateName}`;
|
||||||
|
const message = `
|
||||||
|
<h3>Recurring Tasks Created</h3>
|
||||||
|
<p>${createdTasks.length} new tasks have been created from template "${templateName}":</p>
|
||||||
|
<ul>
|
||||||
|
${createdTasks.map(t => `<li>${t.name}</li>`).join('')}
|
||||||
|
</ul>
|
||||||
|
`;
|
||||||
|
|
||||||
|
await this.sendEmailNotifications(emailUsers, subject, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send push notifications
|
||||||
|
const pushUsers = preferences
|
||||||
|
.filter(p => p.push_notifications !== false)
|
||||||
|
.map(p => p.id);
|
||||||
|
|
||||||
|
if (pushUsers.length > 0) {
|
||||||
|
await this.sendPushNotifications(
|
||||||
|
pushUsers,
|
||||||
|
'New Recurring Tasks',
|
||||||
|
`${createdTasks.length} tasks created from ${templateName}`,
|
||||||
|
{
|
||||||
|
type: 'recurring_tasks_created',
|
||||||
|
project_id: projectId,
|
||||||
|
task_count: createdTasks.length
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Failed to send comprehensive notifications:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
187
worklenz-backend/src/utils/recurring-tasks-permissions.ts
Normal file
187
worklenz-backend/src/utils/recurring-tasks-permissions.ts
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
import db from "../config/db";
|
||||||
|
import { log_error } from "../shared/utils";
|
||||||
|
|
||||||
|
export interface PermissionCheckResult {
|
||||||
|
hasPermission: boolean;
|
||||||
|
reason?: string;
|
||||||
|
projectRole?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RecurringTasksPermissions {
|
||||||
|
/**
|
||||||
|
* Check if a user has permission to create tasks in a project
|
||||||
|
*/
|
||||||
|
static async canCreateTasksInProject(
|
||||||
|
userId: string,
|
||||||
|
projectId: string
|
||||||
|
): Promise<PermissionCheckResult> {
|
||||||
|
try {
|
||||||
|
// Check if user is a member of the project
|
||||||
|
const memberQuery = `
|
||||||
|
SELECT pm.role_id, pr.name as role_name, pr.permissions
|
||||||
|
FROM project_members pm
|
||||||
|
JOIN project_member_roles pr ON pm.role_id = pr.id
|
||||||
|
WHERE pm.user_id = $1 AND pm.project_id = $2
|
||||||
|
LIMIT 1;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(memberQuery, [userId, projectId]);
|
||||||
|
|
||||||
|
if (result.rows.length === 0) {
|
||||||
|
return {
|
||||||
|
hasPermission: false,
|
||||||
|
reason: "User is not a member of the project"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const member = result.rows[0];
|
||||||
|
|
||||||
|
// Check if role has task creation permission
|
||||||
|
if (member.permissions && member.permissions.create_tasks === false) {
|
||||||
|
return {
|
||||||
|
hasPermission: false,
|
||||||
|
reason: "User role does not have permission to create tasks",
|
||||||
|
projectRole: member.role_name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasPermission: true,
|
||||||
|
projectRole: member.role_name
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Error checking project permissions:", error);
|
||||||
|
return {
|
||||||
|
hasPermission: false,
|
||||||
|
reason: "Error checking permissions"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a template has valid permissions
|
||||||
|
*/
|
||||||
|
static async validateTemplatePermissions(templateId: string): Promise<PermissionCheckResult> {
|
||||||
|
try {
|
||||||
|
const query = `
|
||||||
|
SELECT
|
||||||
|
t.reporter_id,
|
||||||
|
t.project_id,
|
||||||
|
p.is_active as project_active,
|
||||||
|
p.archived as project_archived,
|
||||||
|
u.is_active as user_active
|
||||||
|
FROM task_recurring_templates trt
|
||||||
|
JOIN tasks t ON trt.task_id = t.id
|
||||||
|
JOIN projects p ON t.project_id = p.id
|
||||||
|
JOIN users u ON t.reporter_id = u.id
|
||||||
|
WHERE trt.id = $1
|
||||||
|
LIMIT 1;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(query, [templateId]);
|
||||||
|
|
||||||
|
if (result.rows.length === 0) {
|
||||||
|
return {
|
||||||
|
hasPermission: false,
|
||||||
|
reason: "Template not found"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const template = result.rows[0];
|
||||||
|
|
||||||
|
// Check if project is active
|
||||||
|
if (!template.project_active || template.project_archived) {
|
||||||
|
return {
|
||||||
|
hasPermission: false,
|
||||||
|
reason: "Project is not active or archived"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if reporter is still active
|
||||||
|
if (!template.user_active) {
|
||||||
|
return {
|
||||||
|
hasPermission: false,
|
||||||
|
reason: "Original task reporter is no longer active"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if reporter still has permissions in the project
|
||||||
|
const permissionCheck = await this.canCreateTasksInProject(
|
||||||
|
template.reporter_id,
|
||||||
|
template.project_id
|
||||||
|
);
|
||||||
|
|
||||||
|
return permissionCheck;
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Error validating template permissions:", error);
|
||||||
|
return {
|
||||||
|
hasPermission: false,
|
||||||
|
reason: "Error validating template permissions"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all templates with permission issues
|
||||||
|
*/
|
||||||
|
static async getTemplatesWithPermissionIssues(): Promise<any[]> {
|
||||||
|
try {
|
||||||
|
const query = `
|
||||||
|
SELECT
|
||||||
|
trt.id as template_id,
|
||||||
|
trt.name as template_name,
|
||||||
|
t.reporter_id,
|
||||||
|
u.name as reporter_name,
|
||||||
|
t.project_id,
|
||||||
|
p.name as project_name,
|
||||||
|
CASE
|
||||||
|
WHEN NOT p.is_active THEN 'Project inactive'
|
||||||
|
WHEN p.archived THEN 'Project archived'
|
||||||
|
WHEN NOT u.is_active THEN 'User inactive'
|
||||||
|
WHEN NOT EXISTS (
|
||||||
|
SELECT 1 FROM project_members
|
||||||
|
WHERE user_id = t.reporter_id AND project_id = t.project_id
|
||||||
|
) THEN 'User not in project'
|
||||||
|
ELSE NULL
|
||||||
|
END as issue
|
||||||
|
FROM task_recurring_templates trt
|
||||||
|
JOIN tasks t ON trt.task_id = t.id
|
||||||
|
JOIN projects p ON t.project_id = p.id
|
||||||
|
JOIN users u ON t.reporter_id = u.id
|
||||||
|
WHERE
|
||||||
|
NOT p.is_active
|
||||||
|
OR p.archived
|
||||||
|
OR NOT u.is_active
|
||||||
|
OR NOT EXISTS (
|
||||||
|
SELECT 1 FROM project_members
|
||||||
|
WHERE user_id = t.reporter_id AND project_id = t.project_id
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const result = await db.query(query);
|
||||||
|
return result.rows;
|
||||||
|
} catch (error) {
|
||||||
|
log_error("Error getting templates with permission issues:", error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate all assignees have permissions
|
||||||
|
*/
|
||||||
|
static async validateAssigneePermissions(
|
||||||
|
assignees: Array<{ team_member_id: string }>,
|
||||||
|
projectId: string
|
||||||
|
): Promise<string[]> {
|
||||||
|
const invalidAssignees: string[] = [];
|
||||||
|
|
||||||
|
for (const assignee of assignees) {
|
||||||
|
const check = await this.canCreateTasksInProject(assignee.team_member_id, projectId);
|
||||||
|
if (!check.hasPermission) {
|
||||||
|
invalidAssignees.push(assignee.team_member_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return invalidAssignees;
|
||||||
|
}
|
||||||
|
}
|
||||||
134
worklenz-backend/src/utils/retry-utils.ts
Normal file
134
worklenz-backend/src/utils/retry-utils.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
import { log_error } from "../shared/utils";
|
||||||
|
|
||||||
|
export interface RetryOptions {
|
||||||
|
maxRetries: number;
|
||||||
|
delayMs: number;
|
||||||
|
backoffFactor?: number;
|
||||||
|
onRetry?: (error: any, attempt: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RetryUtils {
|
||||||
|
/**
|
||||||
|
* Execute a function with retry logic
|
||||||
|
*/
|
||||||
|
static async withRetry<T>(
|
||||||
|
fn: () => Promise<T>,
|
||||||
|
options: RetryOptions
|
||||||
|
): Promise<T> {
|
||||||
|
const { maxRetries, delayMs, backoffFactor = 1.5, onRetry } = options;
|
||||||
|
let lastError: any;
|
||||||
|
|
||||||
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
|
try {
|
||||||
|
return await fn();
|
||||||
|
} catch (error) {
|
||||||
|
lastError = error;
|
||||||
|
|
||||||
|
if (attempt === maxRetries) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const delay = delayMs * Math.pow(backoffFactor, attempt - 1);
|
||||||
|
|
||||||
|
if (onRetry) {
|
||||||
|
onRetry(error, attempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_error(`Attempt ${attempt} failed. Retrying in ${delay}ms...`, error);
|
||||||
|
|
||||||
|
await new Promise(resolve => setTimeout(resolve, delay));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw lastError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute database operations with retry logic
|
||||||
|
*/
|
||||||
|
static async withDatabaseRetry<T>(
|
||||||
|
operation: () => Promise<T>,
|
||||||
|
operationName: string
|
||||||
|
): Promise<T> {
|
||||||
|
return this.withRetry(operation, {
|
||||||
|
maxRetries: 3,
|
||||||
|
delayMs: 1000,
|
||||||
|
backoffFactor: 2,
|
||||||
|
onRetry: (error, attempt) => {
|
||||||
|
log_error(`Database operation '${operationName}' failed on attempt ${attempt}:`, error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an error is retryable
|
||||||
|
*/
|
||||||
|
static isRetryableError(error: any): boolean {
|
||||||
|
// PostgreSQL error codes that are retryable
|
||||||
|
const retryableErrorCodes = [
|
||||||
|
'40001', // serialization_failure
|
||||||
|
'40P01', // deadlock_detected
|
||||||
|
'55P03', // lock_not_available
|
||||||
|
'57P01', // admin_shutdown
|
||||||
|
'57P02', // crash_shutdown
|
||||||
|
'57P03', // cannot_connect_now
|
||||||
|
'58000', // system_error
|
||||||
|
'58030', // io_error
|
||||||
|
'53000', // insufficient_resources
|
||||||
|
'53100', // disk_full
|
||||||
|
'53200', // out_of_memory
|
||||||
|
'53300', // too_many_connections
|
||||||
|
'53400', // configuration_limit_exceeded
|
||||||
|
];
|
||||||
|
|
||||||
|
if (error.code && retryableErrorCodes.includes(error.code)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Network-related errors
|
||||||
|
if (error.message && (
|
||||||
|
error.message.includes('ECONNRESET') ||
|
||||||
|
error.message.includes('ETIMEDOUT') ||
|
||||||
|
error.message.includes('ECONNREFUSED')
|
||||||
|
)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute with conditional retry based on error type
|
||||||
|
*/
|
||||||
|
static async withConditionalRetry<T>(
|
||||||
|
fn: () => Promise<T>,
|
||||||
|
options: RetryOptions
|
||||||
|
): Promise<T> {
|
||||||
|
const { maxRetries, delayMs, backoffFactor = 1.5, onRetry } = options;
|
||||||
|
let lastError: any;
|
||||||
|
|
||||||
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||||
|
try {
|
||||||
|
return await fn();
|
||||||
|
} catch (error) {
|
||||||
|
lastError = error;
|
||||||
|
|
||||||
|
if (!this.isRetryableError(error) || attempt === maxRetries) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const delay = delayMs * Math.pow(backoffFactor, attempt - 1);
|
||||||
|
|
||||||
|
if (onRetry) {
|
||||||
|
onRetry(error, attempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_error(`Retryable error on attempt ${attempt}. Retrying in ${delay}ms...`, error);
|
||||||
|
|
||||||
|
await new Promise(resolve => setTimeout(resolve, delay));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw lastError;
|
||||||
|
}
|
||||||
|
}
|
||||||
156
worklenz-backend/src/utils/timezone-utils.ts
Normal file
156
worklenz-backend/src/utils/timezone-utils.ts
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
import moment from "moment-timezone";
|
||||||
|
import { IRecurringSchedule } from "../interfaces/recurring-tasks";
|
||||||
|
|
||||||
|
export class TimezoneUtils {
|
||||||
|
/**
|
||||||
|
* Convert a date from one timezone to another
|
||||||
|
*/
|
||||||
|
static convertTimezone(date: moment.Moment | Date | string, fromTz: string, toTz: string): moment.Moment {
|
||||||
|
return moment.tz(date, fromTz).tz(toTz);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current time in a specific timezone
|
||||||
|
*/
|
||||||
|
static nowInTimezone(timezone: string): moment.Moment {
|
||||||
|
return moment.tz(timezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a recurring task should run based on timezone
|
||||||
|
*/
|
||||||
|
static shouldRunInTimezone(schedule: IRecurringSchedule, timezone: string): boolean {
|
||||||
|
const now = this.nowInTimezone(timezone);
|
||||||
|
const scheduleTime = moment.tz(schedule.created_at, timezone);
|
||||||
|
|
||||||
|
// Check if it's the right time of day (within a 1-hour window)
|
||||||
|
const hourDiff = Math.abs(now.hour() - scheduleTime.hour());
|
||||||
|
return hourDiff < 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate next end date considering timezone
|
||||||
|
*/
|
||||||
|
static calculateNextEndDateWithTimezone(
|
||||||
|
schedule: IRecurringSchedule,
|
||||||
|
lastDate: moment.Moment | Date | string,
|
||||||
|
timezone: string
|
||||||
|
): moment.Moment {
|
||||||
|
const lastMoment = moment.tz(lastDate, timezone);
|
||||||
|
|
||||||
|
switch (schedule.schedule_type) {
|
||||||
|
case "daily":
|
||||||
|
return lastMoment.clone().add(1, "day");
|
||||||
|
|
||||||
|
case "weekly":
|
||||||
|
if (schedule.days_of_week && schedule.days_of_week.length > 0) {
|
||||||
|
// Find next occurrence based on selected days
|
||||||
|
let nextDate = lastMoment.clone();
|
||||||
|
let daysChecked = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
nextDate.add(1, "day");
|
||||||
|
daysChecked++;
|
||||||
|
if (schedule.days_of_week.includes(nextDate.day())) {
|
||||||
|
return nextDate;
|
||||||
|
}
|
||||||
|
} while (daysChecked < 7);
|
||||||
|
|
||||||
|
// If no valid day found, return next week's first selected day
|
||||||
|
const sortedDays = [...schedule.days_of_week].sort((a, b) => a - b);
|
||||||
|
nextDate = lastMoment.clone().add(1, "week").day(sortedDays[0]);
|
||||||
|
return nextDate;
|
||||||
|
}
|
||||||
|
return lastMoment.clone().add(1, "week");
|
||||||
|
|
||||||
|
case "monthly":
|
||||||
|
if (schedule.date_of_month) {
|
||||||
|
// Specific date of month
|
||||||
|
let nextDate = lastMoment.clone().add(1, "month").date(schedule.date_of_month);
|
||||||
|
|
||||||
|
// Handle months with fewer days
|
||||||
|
if (nextDate.date() !== schedule.date_of_month) {
|
||||||
|
nextDate = nextDate.endOf("month");
|
||||||
|
}
|
||||||
|
|
||||||
|
return nextDate;
|
||||||
|
} else if (schedule.week_of_month && schedule.day_of_month !== undefined) {
|
||||||
|
// Nth occurrence of a day in month
|
||||||
|
const nextMonth = lastMoment.clone().add(1, "month").startOf("month");
|
||||||
|
const targetDay = schedule.day_of_month;
|
||||||
|
const targetWeek = schedule.week_of_month;
|
||||||
|
|
||||||
|
// Find first occurrence of the target day
|
||||||
|
let firstOccurrence = nextMonth.clone();
|
||||||
|
while (firstOccurrence.day() !== targetDay) {
|
||||||
|
firstOccurrence.add(1, "day");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate nth occurrence
|
||||||
|
if (targetWeek === 5) {
|
||||||
|
// Last occurrence
|
||||||
|
let lastOccurrence = firstOccurrence.clone();
|
||||||
|
let temp = firstOccurrence.clone().add(7, "days");
|
||||||
|
|
||||||
|
while (temp.month() === nextMonth.month()) {
|
||||||
|
lastOccurrence = temp.clone();
|
||||||
|
temp.add(7, "days");
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastOccurrence;
|
||||||
|
} else {
|
||||||
|
// Specific week number
|
||||||
|
return firstOccurrence.add((targetWeek - 1) * 7, "days");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lastMoment.clone().add(1, "month");
|
||||||
|
|
||||||
|
case "every_x_days":
|
||||||
|
return lastMoment.clone().add(schedule.interval_days || 1, "days");
|
||||||
|
|
||||||
|
case "every_x_weeks":
|
||||||
|
return lastMoment.clone().add(schedule.interval_weeks || 1, "weeks");
|
||||||
|
|
||||||
|
case "every_x_months":
|
||||||
|
return lastMoment.clone().add(schedule.interval_months || 1, "months");
|
||||||
|
|
||||||
|
default:
|
||||||
|
return lastMoment.clone().add(1, "day");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all timezones that should be processed in the current hour
|
||||||
|
*/
|
||||||
|
static getActiveTimezones(): string[] {
|
||||||
|
const activeTimezones: string[] = [];
|
||||||
|
const allTimezones = moment.tz.names();
|
||||||
|
|
||||||
|
for (const tz of allTimezones) {
|
||||||
|
const tzTime = moment.tz(tz);
|
||||||
|
// Check if it's 11:00 AM in this timezone (matching the cron schedule)
|
||||||
|
if (tzTime.hour() === 11) {
|
||||||
|
activeTimezones.push(tz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return activeTimezones;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate timezone string
|
||||||
|
*/
|
||||||
|
static isValidTimezone(timezone: string): boolean {
|
||||||
|
return moment.tz.zone(timezone) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get user's timezone or default to UTC
|
||||||
|
*/
|
||||||
|
static getUserTimezone(userTimezone?: string): string {
|
||||||
|
if (userTimezone && this.isValidTimezone(userTimezone)) {
|
||||||
|
return userTimezone;
|
||||||
|
}
|
||||||
|
return "UTC";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +1,43 @@
|
|||||||
{
|
{
|
||||||
"taskHeader": {
|
"taskHeader": {
|
||||||
"taskNamePlaceholder": "Shkruani Detyrën tuaj",
|
"taskNamePlaceholder": "Shkruani detyrën tuaj",
|
||||||
"deleteTask": "Fshi Detyrën"
|
"deleteTask": "Fshi detyrën",
|
||||||
|
"parentTask": "Detyra kryesore",
|
||||||
|
"currentTask": "Detyra aktuale",
|
||||||
|
"back": "Kthehu",
|
||||||
|
"backToParent": "Kthehu te detyra kryesore",
|
||||||
|
"toParentTask": "te detyra kryesore",
|
||||||
|
"loadingHierarchy": "Duke ngarkuar hierarkinë..."
|
||||||
},
|
},
|
||||||
"taskInfoTab": {
|
"taskInfoTab": {
|
||||||
"title": "Informacioni",
|
"title": "Informacioni",
|
||||||
"details": {
|
"details": {
|
||||||
"title": "Detajet",
|
"title": "Detajet",
|
||||||
"task-key": "Çelësi i Detyrës",
|
"task-key": "Çelësi i detyrës",
|
||||||
"phase": "Faza",
|
"phase": "Faza",
|
||||||
"assignees": "Të Caktuar",
|
"assignees": "Të caktuarit",
|
||||||
"due-date": "Data e Përfundimit",
|
"due-date": "Data e përfundimit",
|
||||||
"time-estimation": "Vlerësimi i Kohës",
|
"time-estimation": "Vlerësimi i kohës",
|
||||||
"priority": "Prioriteti",
|
"priority": "Prioriteti",
|
||||||
"labels": "Etiketat",
|
"labels": "Etiketat",
|
||||||
"billable": "E Faturueshme",
|
"billable": "I faturueshëm",
|
||||||
"notify": "Njofto",
|
"notify": "Njofto",
|
||||||
"when-done-notify": "Kur përfundon, njofto",
|
"when-done-notify": "Kur përfundon, njofto",
|
||||||
"start-date": "Data e Fillimit",
|
"start-date": "Data e fillimit",
|
||||||
"end-date": "Data e Përfundimit",
|
"end-date": "Data e përfundimit",
|
||||||
"hide-start-date": "Fshih Datën e Fillimit",
|
"hide-start-date": "Fshih datën e fillimit",
|
||||||
"show-start-date": "Shfaq Datën e Fillimit",
|
"show-start-date": "Shfaq datën e fillimit",
|
||||||
"hours": "Orë",
|
"hours": "Orë",
|
||||||
"minutes": "Minuta",
|
"minutes": "Minuta",
|
||||||
"progressValue": "Vlera e Progresit",
|
"progressValue": "Vlera e progresit",
|
||||||
"progressValueTooltip": "Vendosni përqindjen e progresit (0-100%)",
|
"progressValueTooltip": "Vendos përqindjen e progresit (0-100%)",
|
||||||
"progressValueRequired": "Ju lutemi vendosni një vlerë progresi",
|
"progressValueRequired": "Ju lutemi vendosni një vlerë progresi",
|
||||||
"progressValueRange": "Progresi duhet të jetë midis 0 dhe 100",
|
"progressValueRange": "Progresi duhet të jetë midis 0 dhe 100",
|
||||||
"taskWeight": "Pesha e Detyrës",
|
"taskWeight": "Pesha e detyrës",
|
||||||
"taskWeightTooltip": "Vendosni peshën e kësaj nëndetyre (përqindje)",
|
"taskWeightTooltip": "Vendos peshën e kësaj nëndetyre (përqindje)",
|
||||||
"taskWeightRequired": "Ju lutemi vendosni një peshë detyre",
|
"taskWeightRequired": "Ju lutemi vendosni një peshë detyre",
|
||||||
"taskWeightRange": "Pesha duhet të jetë midis 0 dhe 100",
|
"taskWeightRange": "Pesha duhet të jetë midis 0 dhe 100",
|
||||||
"recurring": "E Përsëritur"
|
"recurring": "Përsëritëse"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"labelInputPlaceholder": "Kërko ose krijo",
|
"labelInputPlaceholder": "Kërko ose krijo",
|
||||||
@@ -43,71 +49,71 @@
|
|||||||
},
|
},
|
||||||
"subTasks": {
|
"subTasks": {
|
||||||
"title": "Nëndetyrat",
|
"title": "Nëndetyrat",
|
||||||
"addSubTask": "Shto Nëndetyrë",
|
"addSubTask": "Shto nëndetyrë",
|
||||||
"addSubTaskInputPlaceholder": "Shkruani detyrën tuaj dhe shtypni enter",
|
"addSubTaskInputPlaceholder": "Shkruani detyrën tuaj dhe shtypni enter",
|
||||||
"refreshSubTasks": "Rifresko Nëndetyrat",
|
"refreshSubTasks": "Rifresko nëndetyrat",
|
||||||
"edit": "Modifiko",
|
"edit": "Redakto",
|
||||||
"delete": "Fshi",
|
"delete": "Fshi",
|
||||||
"confirmDeleteSubTask": "Jeni i sigurt që doni të fshini këtë nëndetyrë?",
|
"confirmDeleteSubTask": "Jeni i sigurt që dëshironi ta fshini këtë nëndetyrë?",
|
||||||
"deleteSubTask": "Fshi Nëndetyrën"
|
"deleteSubTask": "Fshi nëndetyrën"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"title": "Varësitë",
|
"title": "Varësitë",
|
||||||
"addDependency": "+ Shto varësi të re",
|
"addDependency": "+ Shto varësi të re",
|
||||||
"blockedBy": "Bllokuar nga",
|
"blockedBy": "Bllokuar nga",
|
||||||
"searchTask": "Shkruani për të kërkuar detyrë",
|
"searchTask": "Shkruaj për të kërkuar detyrën",
|
||||||
"noTasksFound": "Nuk u gjetën detyra",
|
"noTasksFound": "Nuk u gjetën detyra",
|
||||||
"confirmDeleteDependency": "Jeni i sigurt që doni të fshini?"
|
"confirmDeleteDependency": "Jeni i sigurt që dëshironi ta fshini?"
|
||||||
},
|
},
|
||||||
"attachments": {
|
"attachments": {
|
||||||
"title": "Bashkëngjitjet",
|
"title": "Bashkëngjitjet",
|
||||||
"chooseOrDropFileToUpload": "Zgjidhni ose hidhni skedar për të ngarkuar",
|
"chooseOrDropFileToUpload": "Zgjidh ose lësho skedarin për ta ngarkuar",
|
||||||
"uploading": "Duke ngarkuar..."
|
"uploading": "Duke ngarkuar..."
|
||||||
},
|
},
|
||||||
"comments": {
|
"comments": {
|
||||||
"title": "Komentet",
|
"title": "Komentet",
|
||||||
"addComment": "+ Shto koment të ri",
|
"addComment": "+ Shto koment të ri",
|
||||||
"noComments": "Ende pa komente. Bëhu i pari që komenton!",
|
"noComments": "Ende pa komente. Bëhu i pari që komentoni!",
|
||||||
"delete": "Fshi",
|
"delete": "Fshi",
|
||||||
"confirmDeleteComment": "Jeni i sigurt që doni të fshini këtë koment?",
|
"confirmDeleteComment": "Jeni i sigurt që dëshironi ta fshini këtë koment?",
|
||||||
"addCommentPlaceholder": "Shto një koment...",
|
"addCommentPlaceholder": "Shto një koment...",
|
||||||
"cancel": "Anulo",
|
"cancel": "Anulo",
|
||||||
"commentButton": "Komento",
|
"commentButton": "Komento",
|
||||||
"attachFiles": "Bashkëngjit skedarë",
|
"attachFiles": "Bashkëngjit skedarë",
|
||||||
"addMoreFiles": "Shto më shumë skedarë",
|
"addMoreFiles": "Shto më shumë skedarë",
|
||||||
"selectedFiles": "Skedarët e Zgjedhur (Deri në 25MB, Maksimumi {count})",
|
"selectedFiles": "Skedarët e zgjedhur (Deri në 25MB, Maksimumi {count})",
|
||||||
"maxFilesError": "Mund të ngarkoni maksimum {count} skedarë",
|
"maxFilesError": "Mund të ngarkoni maksimumi {count} skedarë",
|
||||||
"processFilesError": "Dështoi përpunimi i skedarëve",
|
"processFilesError": "Dështoi në përpunimin e skedarëve",
|
||||||
"addCommentError": "Ju lutemi shtoni një koment ose bashkëngjitni skedarë",
|
"addCommentError": "Ju lutemi shtoni një koment ose bashkëngjitni skedarë",
|
||||||
"createdBy": "Krijuar {{time}} nga {{user}}",
|
"createdBy": "Krijuar {{time}} nga {{user}}",
|
||||||
"updatedTime": "Përditësuar {{time}}"
|
"updatedTime": "Përditësuar {{time}}"
|
||||||
},
|
},
|
||||||
"searchInputPlaceholder": "Kërko sipas emrit",
|
"searchInputPlaceholder": "Kërko sipas emrit",
|
||||||
"pendingInvitation": "Ftesë në Pritje"
|
"pendingInvitation": "Ftesë në pritje"
|
||||||
},
|
},
|
||||||
"taskTimeLogTab": {
|
"taskTimeLogTab": {
|
||||||
"title": "Regjistri i Kohës",
|
"title": "Regjistri i kohës",
|
||||||
"addTimeLog": "Shto regjistrim të ri kohe",
|
"addTimeLog": "Shto regjistër të ri kohe",
|
||||||
"totalLogged": "Totali i Regjistruar",
|
"totalLogged": "Totali i regjistruar",
|
||||||
"exportToExcel": "Eksporto në Excel",
|
"exportToExcel": "Eksporto në Excel",
|
||||||
"noTimeLogsFound": "Nuk u gjetën regjistra kohe",
|
"noTimeLogsFound": "Nuk u gjetën regjistrime kohe",
|
||||||
"timeLogForm": {
|
"timeLogForm": {
|
||||||
"date": "Data",
|
"date": "Data",
|
||||||
"startTime": "Koha e Fillimit",
|
"startTime": "Ora e fillimit",
|
||||||
"endTime": "Koha e Përfundimit",
|
"endTime": "Ora e përfundimit",
|
||||||
"workDescription": "Përshkrimi i Punës",
|
"workDescription": "Përshkrimi i punës",
|
||||||
"descriptionPlaceholder": "Shto një përshkrim",
|
"descriptionPlaceholder": "Shto një përshkrim",
|
||||||
"logTime": "Regjistro kohën",
|
"logTime": "Regjistro kohën",
|
||||||
"updateTime": "Përditëso kohën",
|
"updateTime": "Përditëso kohën",
|
||||||
"cancel": "Anulo",
|
"cancel": "Anulo",
|
||||||
"selectDateError": "Ju lutemi zgjidhni një datë",
|
"selectDateError": "Ju lutemi zgjidhni një datë",
|
||||||
"selectStartTimeError": "Ju lutemi zgjidhni kohën e fillimit",
|
"selectStartTimeError": "Ju lutemi zgjidhni orën e fillimit",
|
||||||
"selectEndTimeError": "Ju lutemi zgjidhni kohën e përfundimit",
|
"selectEndTimeError": "Ju lutemi zgjidhni orën e përfundimit",
|
||||||
"endTimeAfterStartError": "Koha e përfundimit duhet të jetë pas kohës së fillimit"
|
"endTimeAfterStartError": "Ora e përfundimit duhet të jetë pas orës së fillimit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"taskActivityLogTab": {
|
"taskActivityLogTab": {
|
||||||
"title": "Regjistri i Aktivitetit",
|
"title": "Regjistri i aktivitetit",
|
||||||
"add": "SHTO",
|
"add": "SHTO",
|
||||||
"remove": "HIQE",
|
"remove": "HIQE",
|
||||||
"none": "Asnjë",
|
"none": "Asnjë",
|
||||||
@@ -115,9 +121,9 @@
|
|||||||
"createdTask": "krijoi detyrën."
|
"createdTask": "krijoi detyrën."
|
||||||
},
|
},
|
||||||
"taskProgress": {
|
"taskProgress": {
|
||||||
"markAsDoneTitle": "Shëno Detyrën si të Kryer?",
|
"markAsDoneTitle": "Shëno detyrën si të përfunduar?",
|
||||||
"confirmMarkAsDone": "Po, shëno si të kryer",
|
"confirmMarkAsDone": "Po, shënoje si të përfunduar",
|
||||||
"cancelMarkAsDone": "Jo, mbaj statusin aktual",
|
"cancelMarkAsDone": "Jo, mbaj gjendjen aktuale",
|
||||||
"markAsDoneDescription": "Keni vendosur progresin në 100%. Doni të përditësoni statusin e detyrës në \"Kryer\"?"
|
"markAsDoneDescription": "Keni vendosur progresin në 100%. Dëshironi ta përditësoni gjendjen e detyrës në \"Përfunduar\"?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"addTaskText": "Shto Detyrë",
|
"addTaskText": "Shto Detyrë",
|
||||||
"addSubTaskText": "+ Shto Nën-Detyrë",
|
"addSubTaskText": "+ Shto Nën-Detyrë",
|
||||||
"noTasksInGroup": "Nuk ka detyra në këtë grup",
|
"noTasksInGroup": "Nuk ka detyra në këtë grup",
|
||||||
|
"dropTaskHere": "Lëshoje detyrën këtu",
|
||||||
"addTaskInputPlaceholder": "Shkruaj detyrën dhe shtyp Enter",
|
"addTaskInputPlaceholder": "Shkruaj detyrën dhe shtyp Enter",
|
||||||
|
|
||||||
"openButton": "Hap",
|
"openButton": "Hap",
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
{
|
{
|
||||||
"taskHeader": {
|
"taskHeader": {
|
||||||
"taskNamePlaceholder": "Geben Sie Ihre Aufgabe ein",
|
"taskNamePlaceholder": "Geben Sie Ihre Aufgabe ein",
|
||||||
"deleteTask": "Aufgabe löschen"
|
"deleteTask": "Aufgabe löschen",
|
||||||
|
"parentTask": "Übergeordnete Aufgabe",
|
||||||
|
"currentTask": "Aktuelle Aufgabe",
|
||||||
|
"back": "Zurück",
|
||||||
|
"backToParent": "Zurück zur übergeordneten Aufgabe",
|
||||||
|
"toParentTask": "zur übergeordneten Aufgabe",
|
||||||
|
"loadingHierarchy": "Hierarchie wird geladen..."
|
||||||
},
|
},
|
||||||
"taskInfoTab": {
|
"taskInfoTab": {
|
||||||
"title": "Info",
|
"title": "Info",
|
||||||
"details": {
|
"details": {
|
||||||
"title": "Details",
|
"title": "Details",
|
||||||
"task-key": "Aufgaben-Schlüssel",
|
"task-key": "Aufgabenschlüssel",
|
||||||
"phase": "Phase",
|
"phase": "Phase",
|
||||||
"assignees": "Beauftragte",
|
"assignees": "Zugewiesene",
|
||||||
"due-date": "Fälligkeitsdatum",
|
"due-date": "Fälligkeitsdatum",
|
||||||
"time-estimation": "Zeitschätzung",
|
"time-estimation": "Zeitschätzung",
|
||||||
"priority": "Priorität",
|
"priority": "Priorität",
|
||||||
"labels": "Labels",
|
"labels": "Labels",
|
||||||
"billable": "Abrechenbar",
|
"billable": "Abrechenbar",
|
||||||
"notify": "Benachrichtigen",
|
"notify": "Benachrichtigen",
|
||||||
"when-done-notify": "Bei Abschluss benachrichtigen",
|
"when-done-notify": "Bei Fertigstellung benachrichtigen",
|
||||||
"start-date": "Startdatum",
|
"start-date": "Startdatum",
|
||||||
"end-date": "Enddatum",
|
"end-date": "Enddatum",
|
||||||
"hide-start-date": "Startdatum ausblenden",
|
"hide-start-date": "Startdatum ausblenden",
|
||||||
@@ -24,50 +30,50 @@
|
|||||||
"hours": "Stunden",
|
"hours": "Stunden",
|
||||||
"minutes": "Minuten",
|
"minutes": "Minuten",
|
||||||
"progressValue": "Fortschrittswert",
|
"progressValue": "Fortschrittswert",
|
||||||
"progressValueTooltip": "Fortschritt in Prozent einstellen (0-100%)",
|
"progressValueTooltip": "Setzen Sie den Fortschrittsprozentsatz (0-100%)",
|
||||||
"progressValueRequired": "Bitte geben Sie einen Fortschrittswert ein",
|
"progressValueRequired": "Bitte geben Sie einen Fortschrittswert ein",
|
||||||
"progressValueRange": "Fortschritt muss zwischen 0 und 100 liegen",
|
"progressValueRange": "Fortschritt muss zwischen 0 und 100 liegen",
|
||||||
"taskWeight": "Aufgabengewicht",
|
"taskWeight": "Aufgabengewicht",
|
||||||
"taskWeightTooltip": "Gewicht dieser Teilaufgabe festlegen (Prozent)",
|
"taskWeightTooltip": "Setzen Sie das Gewicht dieser Unteraufgabe (Prozentsatz)",
|
||||||
"taskWeightRequired": "Bitte geben Sie ein Aufgabengewicht ein",
|
"taskWeightRequired": "Bitte geben Sie ein Aufgabengewicht ein",
|
||||||
"taskWeightRange": "Gewicht muss zwischen 0 und 100 liegen",
|
"taskWeightRange": "Gewicht muss zwischen 0 und 100 liegen",
|
||||||
"recurring": "Wiederkehrend"
|
"recurring": "Wiederkehrend"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"labelInputPlaceholder": "Suchen oder erstellen",
|
"labelInputPlaceholder": "Suchen oder erstellen",
|
||||||
"labelsSelectorInputTip": "Enter drücken zum Erstellen"
|
"labelsSelectorInputTip": "Drücken Sie Enter zum Erstellen"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"title": "Beschreibung",
|
"title": "Beschreibung",
|
||||||
"placeholder": "Detailliertere Beschreibung hinzufügen..."
|
"placeholder": "Fügen Sie eine detailliertere Beschreibung hinzu..."
|
||||||
},
|
},
|
||||||
"subTasks": {
|
"subTasks": {
|
||||||
"title": "Teilaufgaben",
|
"title": "Unteraufgaben",
|
||||||
"addSubTask": "Teilaufgabe hinzufügen",
|
"addSubTask": "Unteraufgabe hinzufügen",
|
||||||
"addSubTaskInputPlaceholder": "Geben Sie Ihre Aufgabe ein und drücken Sie Enter",
|
"addSubTaskInputPlaceholder": "Geben Sie Ihre Aufgabe ein und drücken Sie Enter",
|
||||||
"refreshSubTasks": "Teilaufgaben aktualisieren",
|
"refreshSubTasks": "Unteraufgaben aktualisieren",
|
||||||
"edit": "Bearbeiten",
|
"edit": "Bearbeiten",
|
||||||
"delete": "Löschen",
|
"delete": "Löschen",
|
||||||
"confirmDeleteSubTask": "Sind Sie sicher, dass Sie diese Teilaufgabe löschen möchten?",
|
"confirmDeleteSubTask": "Sind Sie sicher, dass Sie diese Unteraufgabe löschen möchten?",
|
||||||
"deleteSubTask": "Teilaufgabe löschen"
|
"deleteSubTask": "Unteraufgabe löschen"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"title": "Abhängigkeiten",
|
"title": "Abhängigkeiten",
|
||||||
"addDependency": "+ Neue Abhängigkeit hinzufügen",
|
"addDependency": "+ Neue Abhängigkeit hinzufügen",
|
||||||
"blockedBy": "Blockiert von",
|
"blockedBy": "Blockiert von",
|
||||||
"searchTask": "Aufgabe suchen",
|
"searchTask": "Zum Suchen der Aufgabe eingeben",
|
||||||
"noTasksFound": "Keine Aufgaben gefunden",
|
"noTasksFound": "Keine Aufgaben gefunden",
|
||||||
"confirmDeleteDependency": "Sind Sie sicher, dass Sie löschen möchten?"
|
"confirmDeleteDependency": "Sind Sie sicher, dass Sie löschen möchten?"
|
||||||
},
|
},
|
||||||
"attachments": {
|
"attachments": {
|
||||||
"title": "Anhänge",
|
"title": "Anhänge",
|
||||||
"chooseOrDropFileToUpload": "Datei zum Hochladen wählen oder ablegen",
|
"chooseOrDropFileToUpload": "Datei zum Hochladen auswählen oder ablegen",
|
||||||
"uploading": "Wird hochgeladen..."
|
"uploading": "Wird hochgeladen..."
|
||||||
},
|
},
|
||||||
"comments": {
|
"comments": {
|
||||||
"title": "Kommentare",
|
"title": "Kommentare",
|
||||||
"addComment": "+ Neuen Kommentar hinzufügen",
|
"addComment": "+ Neuen Kommentar hinzufügen",
|
||||||
"noComments": "Noch keine Kommentare. Seien Sie der Erste!",
|
"noComments": "Noch keine Kommentare. Seien Sie der Erste, der kommentiert!",
|
||||||
"delete": "Löschen",
|
"delete": "Löschen",
|
||||||
"confirmDeleteComment": "Sind Sie sicher, dass Sie diesen Kommentar löschen möchten?",
|
"confirmDeleteComment": "Sind Sie sicher, dass Sie diesen Kommentar löschen möchten?",
|
||||||
"addCommentPlaceholder": "Kommentar hinzufügen...",
|
"addCommentPlaceholder": "Kommentar hinzufügen...",
|
||||||
@@ -75,9 +81,9 @@
|
|||||||
"commentButton": "Kommentieren",
|
"commentButton": "Kommentieren",
|
||||||
"attachFiles": "Dateien anhängen",
|
"attachFiles": "Dateien anhängen",
|
||||||
"addMoreFiles": "Weitere Dateien hinzufügen",
|
"addMoreFiles": "Weitere Dateien hinzufügen",
|
||||||
"selectedFiles": "Ausgewählte Dateien (Bis zu 25MB, Maximum {count})",
|
"selectedFiles": "Ausgewählte Dateien (Bis zu 25MB, Maximum von {count})",
|
||||||
"maxFilesError": "Sie können maximal {count} Dateien hochladen",
|
"maxFilesError": "Sie können maximal {count} Dateien hochladen",
|
||||||
"processFilesError": "Fehler beim Verarbeiten der Dateien",
|
"processFilesError": "Dateien konnten nicht verarbeitet werden",
|
||||||
"addCommentError": "Bitte fügen Sie einen Kommentar hinzu oder hängen Sie Dateien an",
|
"addCommentError": "Bitte fügen Sie einen Kommentar hinzu oder hängen Sie Dateien an",
|
||||||
"createdBy": "Erstellt {{time}} von {{user}}",
|
"createdBy": "Erstellt {{time}} von {{user}}",
|
||||||
"updatedTime": "Aktualisiert {{time}}"
|
"updatedTime": "Aktualisiert {{time}}"
|
||||||
@@ -86,18 +92,18 @@
|
|||||||
"pendingInvitation": "Ausstehende Einladung"
|
"pendingInvitation": "Ausstehende Einladung"
|
||||||
},
|
},
|
||||||
"taskTimeLogTab": {
|
"taskTimeLogTab": {
|
||||||
"title": "Zeiterfassung",
|
"title": "Zeitprotokoll",
|
||||||
"addTimeLog": "Neuen Zeiteintrag hinzufügen",
|
"addTimeLog": "Neues Zeitprotokoll hinzufügen",
|
||||||
"totalLogged": "Gesamt erfasst",
|
"totalLogged": "Gesamt protokolliert",
|
||||||
"exportToExcel": "Nach Excel exportieren",
|
"exportToExcel": "Nach Excel exportieren",
|
||||||
"noTimeLogsFound": "Keine Zeiteinträge gefunden",
|
"noTimeLogsFound": "Keine Zeitprotokolle gefunden",
|
||||||
"timeLogForm": {
|
"timeLogForm": {
|
||||||
"date": "Datum",
|
"date": "Datum",
|
||||||
"startTime": "Startzeit",
|
"startTime": "Startzeit",
|
||||||
"endTime": "Endzeit",
|
"endTime": "Endzeit",
|
||||||
"workDescription": "Arbeitsbeschreibung",
|
"workDescription": "Arbeitsbeschreibung",
|
||||||
"descriptionPlaceholder": "Beschreibung hinzufügen",
|
"descriptionPlaceholder": "Beschreibung hinzufügen",
|
||||||
"logTime": "Zeit erfassen",
|
"logTime": "Zeit protokollieren",
|
||||||
"updateTime": "Zeit aktualisieren",
|
"updateTime": "Zeit aktualisieren",
|
||||||
"cancel": "Abbrechen",
|
"cancel": "Abbrechen",
|
||||||
"selectDateError": "Bitte wählen Sie ein Datum",
|
"selectDateError": "Bitte wählen Sie ein Datum",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
"addSubTaskText": "+ Unteraufgabe hinzufügen",
|
"addSubTaskText": "+ Unteraufgabe hinzufügen",
|
||||||
"addTaskInputPlaceholder": "Aufgabe eingeben und Enter drücken",
|
"addTaskInputPlaceholder": "Aufgabe eingeben und Enter drücken",
|
||||||
"noTasksInGroup": "Keine Aufgaben in dieser Gruppe",
|
"noTasksInGroup": "Keine Aufgaben in dieser Gruppe",
|
||||||
|
"dropTaskHere": "Aufgabe hier ablegen",
|
||||||
|
|
||||||
"openButton": "Öffnen",
|
"openButton": "Öffnen",
|
||||||
"okButton": "OK",
|
"okButton": "OK",
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
{
|
{
|
||||||
"taskHeader": {
|
"taskHeader": {
|
||||||
"taskNamePlaceholder": "Type your Task",
|
"taskNamePlaceholder": "Type your Task",
|
||||||
"deleteTask": "Delete Task"
|
"deleteTask": "Delete Task",
|
||||||
|
"parentTask": "Parent Task",
|
||||||
|
"currentTask": "Current Task",
|
||||||
|
"back": "Back",
|
||||||
|
"backToParent": "Back to Parent Task",
|
||||||
|
"toParentTask": "to parent task",
|
||||||
|
"loadingHierarchy": "Loading hierarchy..."
|
||||||
},
|
},
|
||||||
"taskInfoTab": {
|
"taskInfoTab": {
|
||||||
"title": "Info",
|
"title": "Info",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
"addSubTaskText": "Add Sub Task",
|
"addSubTaskText": "Add Sub Task",
|
||||||
"addTaskInputPlaceholder": "Type your task and hit enter",
|
"addTaskInputPlaceholder": "Type your task and hit enter",
|
||||||
"noTasksInGroup": "No tasks in this group",
|
"noTasksInGroup": "No tasks in this group",
|
||||||
|
"dropTaskHere": "Drop task here",
|
||||||
|
|
||||||
"openButton": "Open",
|
"openButton": "Open",
|
||||||
"okButton": "Ok",
|
"okButton": "Ok",
|
||||||
|
|||||||
@@ -1,35 +1,41 @@
|
|||||||
{
|
{
|
||||||
"taskHeader": {
|
"taskHeader": {
|
||||||
"taskNamePlaceholder": "Escriba su Tarea",
|
"taskNamePlaceholder": "Escribe tu tarea",
|
||||||
"deleteTask": "Eliminar Tarea"
|
"deleteTask": "Eliminar tarea",
|
||||||
|
"parentTask": "Tarea principal",
|
||||||
|
"currentTask": "Tarea actual",
|
||||||
|
"back": "Volver",
|
||||||
|
"backToParent": "Volver a la tarea principal",
|
||||||
|
"toParentTask": "a la tarea principal",
|
||||||
|
"loadingHierarchy": "Cargando jerarquía..."
|
||||||
},
|
},
|
||||||
"taskInfoTab": {
|
"taskInfoTab": {
|
||||||
"title": "Información",
|
"title": "Información",
|
||||||
"details": {
|
"details": {
|
||||||
"title": "Detalles",
|
"title": "Detalles",
|
||||||
"task-key": "Clave de Tarea",
|
"task-key": "Clave de tarea",
|
||||||
"phase": "Fase",
|
"phase": "Fase",
|
||||||
"assignees": "Asignados",
|
"assignees": "Asignados",
|
||||||
"due-date": "Fecha de Vencimiento",
|
"due-date": "Fecha de vencimiento",
|
||||||
"time-estimation": "Estimación de Tiempo",
|
"time-estimation": "Estimación de tiempo",
|
||||||
"priority": "Prioridad",
|
"priority": "Prioridad",
|
||||||
"labels": "Etiquetas",
|
"labels": "Etiquetas",
|
||||||
"billable": "Facturable",
|
"billable": "Facturable",
|
||||||
"notify": "Notificar",
|
"notify": "Notificar",
|
||||||
"when-done-notify": "Al terminar, notificar",
|
"when-done-notify": "Al finalizar, notificar",
|
||||||
"start-date": "Fecha de Inicio",
|
"start-date": "Fecha de inicio",
|
||||||
"end-date": "Fecha de Fin",
|
"end-date": "Fecha de finalización",
|
||||||
"hide-start-date": "Ocultar Fecha de Inicio",
|
"hide-start-date": "Ocultar fecha de inicio",
|
||||||
"show-start-date": "Mostrar Fecha de Inicio",
|
"show-start-date": "Mostrar fecha de inicio",
|
||||||
"hours": "Horas",
|
"hours": "Horas",
|
||||||
"minutes": "Minutos",
|
"minutes": "Minutos",
|
||||||
"progressValue": "Valor de Progreso",
|
"progressValue": "Valor de progreso",
|
||||||
"progressValueTooltip": "Establecer el porcentaje de progreso (0-100%)",
|
"progressValueTooltip": "Establecer el porcentaje de progreso (0-100%)",
|
||||||
"progressValueRequired": "Por favor, introduzca un valor de progreso",
|
"progressValueRequired": "Por favor ingrese un valor de progreso",
|
||||||
"progressValueRange": "El progreso debe estar entre 0 y 100",
|
"progressValueRange": "El progreso debe estar entre 0 y 100",
|
||||||
"taskWeight": "Peso de la Tarea",
|
"taskWeight": "Peso de la tarea",
|
||||||
"taskWeightTooltip": "Establecer el peso de esta subtarea (porcentaje)",
|
"taskWeightTooltip": "Establecer el peso de esta subtarea (porcentaje)",
|
||||||
"taskWeightRequired": "Por favor, introduzca un peso de tarea",
|
"taskWeightRequired": "Por favor ingrese un peso de tarea",
|
||||||
"taskWeightRange": "El peso debe estar entre 0 y 100",
|
"taskWeightRange": "El peso debe estar entre 0 y 100",
|
||||||
"recurring": "Recurrente"
|
"recurring": "Recurrente"
|
||||||
},
|
},
|
||||||
@@ -39,85 +45,85 @@
|
|||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"title": "Descripción",
|
"title": "Descripción",
|
||||||
"placeholder": "Añadir una descripción más detallada..."
|
"placeholder": "Añade una descripción más detallada..."
|
||||||
},
|
},
|
||||||
"subTasks": {
|
"subTasks": {
|
||||||
"title": "Sub Tareas",
|
"title": "Subtareas",
|
||||||
"addSubTask": "Agregar Sub Tarea",
|
"addSubTask": "Añadir subtarea",
|
||||||
"addSubTaskInputPlaceholder": "Escriba su tarea y presione enter",
|
"addSubTaskInputPlaceholder": "Escribe tu tarea y presiona enter",
|
||||||
"refreshSubTasks": "Actualizar Sub Tareas",
|
"refreshSubTasks": "Actualizar subtareas",
|
||||||
"edit": "Editar",
|
"edit": "Editar",
|
||||||
"delete": "Eliminar",
|
"delete": "Eliminar",
|
||||||
"confirmDeleteSubTask": "¿Está seguro de que desea eliminar esta subtarea?",
|
"confirmDeleteSubTask": "¿Estás seguro de que quieres eliminar esta subtarea?",
|
||||||
"deleteSubTask": "Eliminar Sub Tarea"
|
"deleteSubTask": "Eliminar subtarea"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"title": "Dependencias",
|
"title": "Dependencias",
|
||||||
"addDependency": "+ Agregar nueva dependencia",
|
"addDependency": "+ Añadir nueva dependencia",
|
||||||
"blockedBy": "Bloqueado por",
|
"blockedBy": "Bloqueado por",
|
||||||
"searchTask": "Escribir para buscar tarea",
|
"searchTask": "Escribe para buscar tarea",
|
||||||
"noTasksFound": "No se encontraron tareas",
|
"noTasksFound": "No se encontraron tareas",
|
||||||
"confirmDeleteDependency": "¿Está seguro de que desea eliminar?"
|
"confirmDeleteDependency": "¿Estás seguro de que quieres eliminar?"
|
||||||
},
|
},
|
||||||
"attachments": {
|
"attachments": {
|
||||||
"title": "Adjuntos",
|
"title": "Adjuntos",
|
||||||
"chooseOrDropFileToUpload": "Elija o arrastre un archivo para subir",
|
"chooseOrDropFileToUpload": "Elige o arrastra archivo para subir",
|
||||||
"uploading": "Subiendo..."
|
"uploading": "Subiendo..."
|
||||||
},
|
},
|
||||||
"comments": {
|
"comments": {
|
||||||
"title": "Comentarios",
|
"title": "Comentarios",
|
||||||
"addComment": "+ Agregar nuevo comentario",
|
"addComment": "+ Añadir nuevo comentario",
|
||||||
"noComments": "Aún no hay comentarios. ¡Sé el primero en comentar!",
|
"noComments": "Aún no hay comentarios. ¡Sé el primero en comentar!",
|
||||||
"delete": "Eliminar",
|
"delete": "Eliminar",
|
||||||
"confirmDeleteComment": "¿Está seguro de que desea eliminar este comentario?",
|
"confirmDeleteComment": "¿Estás seguro de que quieres eliminar este comentario?",
|
||||||
"addCommentPlaceholder": "Agregar un comentario...",
|
"addCommentPlaceholder": "Añadir un comentario...",
|
||||||
"cancel": "Cancelar",
|
"cancel": "Cancelar",
|
||||||
"commentButton": "Comentar",
|
"commentButton": "Comentar",
|
||||||
"attachFiles": "Adjuntar archivos",
|
"attachFiles": "Adjuntar archivos",
|
||||||
"addMoreFiles": "Agregar más archivos",
|
"addMoreFiles": "Añadir más archivos",
|
||||||
"selectedFiles": "Archivos Seleccionados (Hasta 25MB, Máximo {count})",
|
"selectedFiles": "Archivos seleccionados (Hasta 25MB, Máximo de {count})",
|
||||||
"maxFilesError": "Solo puede subir un máximo de {count} archivos",
|
"maxFilesError": "Solo puedes subir un máximo de {count} archivos",
|
||||||
"processFilesError": "Error al procesar archivos",
|
"processFilesError": "Error al procesar archivos",
|
||||||
"addCommentError": "Por favor agregue un comentario o adjunte archivos",
|
"addCommentError": "Por favor añade un comentario o adjunta archivos",
|
||||||
"createdBy": "Creado {{time}} por {{user}}",
|
"createdBy": "Creado {{time}} por {{user}}",
|
||||||
"updatedTime": "Actualizado {{time}}"
|
"updatedTime": "Actualizado {{time}}"
|
||||||
},
|
},
|
||||||
"searchInputPlaceholder": "Buscar por nombre",
|
"searchInputPlaceholder": "Buscar por nombre",
|
||||||
"pendingInvitation": "Invitación Pendiente"
|
"pendingInvitation": "Invitación pendiente"
|
||||||
},
|
},
|
||||||
"taskTimeLogTab": {
|
"taskTimeLogTab": {
|
||||||
"title": "Registro de Tiempo",
|
"title": "Registro de tiempo",
|
||||||
"addTimeLog": "Añadir nuevo registro de tiempo",
|
"addTimeLog": "Añadir nuevo registro de tiempo",
|
||||||
"totalLogged": "Total Registrado",
|
"totalLogged": "Total registrado",
|
||||||
"exportToExcel": "Exportar a Excel",
|
"exportToExcel": "Exportar a Excel",
|
||||||
"noTimeLogsFound": "No se encontraron registros de tiempo",
|
"noTimeLogsFound": "No se encontraron registros de tiempo",
|
||||||
"timeLogForm": {
|
"timeLogForm": {
|
||||||
"date": "Fecha",
|
"date": "Fecha",
|
||||||
"startTime": "Hora de Inicio",
|
"startTime": "Hora de inicio",
|
||||||
"endTime": "Hora de Fin",
|
"endTime": "Hora de finalización",
|
||||||
"workDescription": "Descripción del Trabajo",
|
"workDescription": "Descripción del trabajo",
|
||||||
"descriptionPlaceholder": "Agregar una descripción",
|
"descriptionPlaceholder": "Añadir una descripción",
|
||||||
"logTime": "Registrar tiempo",
|
"logTime": "Registrar tiempo",
|
||||||
"updateTime": "Actualizar tiempo",
|
"updateTime": "Actualizar tiempo",
|
||||||
"cancel": "Cancelar",
|
"cancel": "Cancelar",
|
||||||
"selectDateError": "Por favor seleccione una fecha",
|
"selectDateError": "Por favor selecciona una fecha",
|
||||||
"selectStartTimeError": "Por favor seleccione la hora de inicio",
|
"selectStartTimeError": "Por favor selecciona hora de inicio",
|
||||||
"selectEndTimeError": "Por favor seleccione la hora de fin",
|
"selectEndTimeError": "Por favor selecciona hora de finalización",
|
||||||
"endTimeAfterStartError": "La hora de fin debe ser posterior a la hora de inicio"
|
"endTimeAfterStartError": "La hora de finalización debe ser posterior a la de inicio"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"taskActivityLogTab": {
|
"taskActivityLogTab": {
|
||||||
"title": "Registro de Actividad",
|
"title": "Registro de actividad",
|
||||||
"add": "AGREGAR",
|
"add": "AÑADIR",
|
||||||
"remove": "QUITAR",
|
"remove": "ELIMINAR",
|
||||||
"none": "Ninguno",
|
"none": "Ninguno",
|
||||||
"weight": "Peso",
|
"weight": "Peso",
|
||||||
"createdTask": "creó la tarea."
|
"createdTask": "creó la tarea."
|
||||||
},
|
},
|
||||||
"taskProgress": {
|
"taskProgress": {
|
||||||
"markAsDoneTitle": "¿Marcar Tarea como Completada?",
|
"markAsDoneTitle": "¿Marcar tarea como completada?",
|
||||||
"confirmMarkAsDone": "Sí, marcar como completada",
|
"confirmMarkAsDone": "Sí, marcar como completada",
|
||||||
"cancelMarkAsDone": "No, mantener estado actual",
|
"cancelMarkAsDone": "No, mantener estado actual",
|
||||||
"markAsDoneDescription": "Ha establecido el progreso al 100%. ¿Le gustaría actualizar el estado de la tarea a \"Completada\"?"
|
"markAsDoneDescription": "Has establecido el progreso al 100%. ¿Te gustaría actualizar el estado de la tarea a \"Completada\"?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"addTaskText": "Agregar tarea",
|
"addTaskText": "Agregar tarea",
|
||||||
"addSubTaskText": "Agregar subtarea",
|
"addSubTaskText": "Agregar subtarea",
|
||||||
"noTasksInGroup": "No hay tareas en este grupo",
|
"noTasksInGroup": "No hay tareas en este grupo",
|
||||||
|
"dropTaskHere": "Soltar tarea aquí",
|
||||||
"addTaskInputPlaceholder": "Escribe tu tarea y presiona enter",
|
"addTaskInputPlaceholder": "Escribe tu tarea y presiona enter",
|
||||||
|
|
||||||
"openButton": "Abrir",
|
"openButton": "Abrir",
|
||||||
|
|||||||
@@ -1,33 +1,39 @@
|
|||||||
{
|
{
|
||||||
"taskHeader": {
|
"taskHeader": {
|
||||||
"taskNamePlaceholder": "Digite sua Tarefa",
|
"taskNamePlaceholder": "Digite sua tarefa",
|
||||||
"deleteTask": "Deletar Tarefa"
|
"deleteTask": "Excluir tarefa",
|
||||||
|
"parentTask": "Tarefa principal",
|
||||||
|
"currentTask": "Tarefa atual",
|
||||||
|
"back": "Voltar",
|
||||||
|
"backToParent": "Voltar à tarefa principal",
|
||||||
|
"toParentTask": "à tarefa principal",
|
||||||
|
"loadingHierarchy": "Carregando hierarquia..."
|
||||||
},
|
},
|
||||||
"taskInfoTab": {
|
"taskInfoTab": {
|
||||||
"title": "Informações",
|
"title": "Informações",
|
||||||
"details": {
|
"details": {
|
||||||
"title": "Detalhes",
|
"title": "Detalhes",
|
||||||
"task-key": "Chave da Tarefa",
|
"task-key": "Chave da tarefa",
|
||||||
"phase": "Fase",
|
"phase": "Fase",
|
||||||
"assignees": "Responsáveis",
|
"assignees": "Responsáveis",
|
||||||
"due-date": "Data de Vencimento",
|
"due-date": "Data de vencimento",
|
||||||
"time-estimation": "Estimativa de Tempo",
|
"time-estimation": "Estimativa de tempo",
|
||||||
"priority": "Prioridade",
|
"priority": "Prioridade",
|
||||||
"labels": "Etiquetas",
|
"labels": "Etiquetas",
|
||||||
"billable": "Faturável",
|
"billable": "Faturável",
|
||||||
"notify": "Notificar",
|
"notify": "Notificar",
|
||||||
"when-done-notify": "Quando concluído, notificar",
|
"when-done-notify": "Ao concluir, notificar",
|
||||||
"start-date": "Data de Início",
|
"start-date": "Data de início",
|
||||||
"end-date": "Data de Fim",
|
"end-date": "Data de término",
|
||||||
"hide-start-date": "Ocultar Data de Início",
|
"hide-start-date": "Ocultar data de início",
|
||||||
"show-start-date": "Mostrar Data de Início",
|
"show-start-date": "Mostrar data de início",
|
||||||
"hours": "Horas",
|
"hours": "Horas",
|
||||||
"minutes": "Minutos",
|
"minutes": "Minutos",
|
||||||
"progressValue": "Valor do Progresso",
|
"progressValue": "Valor do progresso",
|
||||||
"progressValueTooltip": "Definir a porcentagem de progresso (0-100%)",
|
"progressValueTooltip": "Definir a porcentagem de progresso (0-100%)",
|
||||||
"progressValueRequired": "Por favor, insira um valor de progresso",
|
"progressValueRequired": "Por favor, insira um valor de progresso",
|
||||||
"progressValueRange": "O progresso deve estar entre 0 e 100",
|
"progressValueRange": "O progresso deve estar entre 0 e 100",
|
||||||
"taskWeight": "Peso da Tarefa",
|
"taskWeight": "Peso da tarefa",
|
||||||
"taskWeightTooltip": "Definir o peso desta subtarefa (porcentagem)",
|
"taskWeightTooltip": "Definir o peso desta subtarefa (porcentagem)",
|
||||||
"taskWeightRequired": "Por favor, insira um peso da tarefa",
|
"taskWeightRequired": "Por favor, insira um peso da tarefa",
|
||||||
"taskWeightRange": "O peso deve estar entre 0 e 100",
|
"taskWeightRange": "O peso deve estar entre 0 e 100",
|
||||||
@@ -39,17 +45,17 @@
|
|||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"title": "Descrição",
|
"title": "Descrição",
|
||||||
"placeholder": "Adicionar uma descrição mais detalhada..."
|
"placeholder": "Adicione uma descrição mais detalhada..."
|
||||||
},
|
},
|
||||||
"subTasks": {
|
"subTasks": {
|
||||||
"title": "Sub Tarefas",
|
"title": "Subtarefas",
|
||||||
"addSubTask": "Adicionar Sub Tarefa",
|
"addSubTask": "Adicionar subtarefa",
|
||||||
"addSubTaskInputPlaceholder": "Digite sua tarefa e pressione enter",
|
"addSubTaskInputPlaceholder": "Digite sua tarefa e pressione enter",
|
||||||
"refreshSubTasks": "Atualizar Sub Tarefas",
|
"refreshSubTasks": "Atualizar subtarefas",
|
||||||
"edit": "Editar",
|
"edit": "Editar",
|
||||||
"delete": "Deletar",
|
"delete": "Excluir",
|
||||||
"confirmDeleteSubTask": "Tem certeza de que deseja deletar esta subtarefa?",
|
"confirmDeleteSubTask": "Tem certeza de que deseja excluir esta subtarefa?",
|
||||||
"deleteSubTask": "Deletar Sub Tarefa"
|
"deleteSubTask": "Excluir subtarefa"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"title": "Dependências",
|
"title": "Dependências",
|
||||||
@@ -57,57 +63,57 @@
|
|||||||
"blockedBy": "Bloqueado por",
|
"blockedBy": "Bloqueado por",
|
||||||
"searchTask": "Digite para pesquisar tarefa",
|
"searchTask": "Digite para pesquisar tarefa",
|
||||||
"noTasksFound": "Nenhuma tarefa encontrada",
|
"noTasksFound": "Nenhuma tarefa encontrada",
|
||||||
"confirmDeleteDependency": "Tem certeza de que deseja deletar?"
|
"confirmDeleteDependency": "Tem certeza de que deseja excluir?"
|
||||||
},
|
},
|
||||||
"attachments": {
|
"attachments": {
|
||||||
"title": "Anexos",
|
"title": "Anexos",
|
||||||
"chooseOrDropFileToUpload": "Escolha ou arraste um arquivo para upload",
|
"chooseOrDropFileToUpload": "Escolha ou arraste arquivo para enviar",
|
||||||
"uploading": "Enviando..."
|
"uploading": "Enviando..."
|
||||||
},
|
},
|
||||||
"comments": {
|
"comments": {
|
||||||
"title": "Comentários",
|
"title": "Comentários",
|
||||||
"addComment": "+ Adicionar novo comentário",
|
"addComment": "+ Adicionar novo comentário",
|
||||||
"noComments": "Ainda não há comentários. Seja o primeiro a comentar!",
|
"noComments": "Ainda não há comentários. Seja o primeiro a comentar!",
|
||||||
"delete": "Deletar",
|
"delete": "Excluir",
|
||||||
"confirmDeleteComment": "Tem certeza de que deseja deletar este comentário?",
|
"confirmDeleteComment": "Tem certeza de que deseja excluir este comentário?",
|
||||||
"addCommentPlaceholder": "Adicionar um comentário...",
|
"addCommentPlaceholder": "Adicionar um comentário...",
|
||||||
"cancel": "Cancelar",
|
"cancel": "Cancelar",
|
||||||
"commentButton": "Comentar",
|
"commentButton": "Comentar",
|
||||||
"attachFiles": "Anexar arquivos",
|
"attachFiles": "Anexar arquivos",
|
||||||
"addMoreFiles": "Adicionar mais arquivos",
|
"addMoreFiles": "Adicionar mais arquivos",
|
||||||
"selectedFiles": "Arquivos Selecionados (Até 25MB, Máximo {count})",
|
"selectedFiles": "Arquivos selecionados (Até 25MB, Máximo de {count})",
|
||||||
"maxFilesError": "Você pode fazer upload de no máximo {count} arquivos",
|
"maxFilesError": "Você pode enviar no máximo {count} arquivos",
|
||||||
"processFilesError": "Falha ao processar arquivos",
|
"processFilesError": "Falha ao processar arquivos",
|
||||||
"addCommentError": "Por favor adicione um comentário ou anexe arquivos",
|
"addCommentError": "Por favor, adicione um comentário ou anexe arquivos",
|
||||||
"createdBy": "Criado {{time}} por {{user}}",
|
"createdBy": "Criado {{time}} por {{user}}",
|
||||||
"updatedTime": "Atualizado {{time}}"
|
"updatedTime": "Atualizado {{time}}"
|
||||||
},
|
},
|
||||||
"searchInputPlaceholder": "Pesquisar por nome",
|
"searchInputPlaceholder": "Pesquisar por nome",
|
||||||
"pendingInvitation": "Convite Pendente"
|
"pendingInvitation": "Convite pendente"
|
||||||
},
|
},
|
||||||
"taskTimeLogTab": {
|
"taskTimeLogTab": {
|
||||||
"title": "Registro de Tempo",
|
"title": "Registro de tempo",
|
||||||
"addTimeLog": "Adicionar novo registro de tempo",
|
"addTimeLog": "Adicionar novo registro de tempo",
|
||||||
"totalLogged": "Total Registrado",
|
"totalLogged": "Total registrado",
|
||||||
"exportToExcel": "Exportar para Excel",
|
"exportToExcel": "Exportar para Excel",
|
||||||
"noTimeLogsFound": "Nenhum registro de tempo encontrado",
|
"noTimeLogsFound": "Nenhum registro de tempo encontrado",
|
||||||
"timeLogForm": {
|
"timeLogForm": {
|
||||||
"date": "Data",
|
"date": "Data",
|
||||||
"startTime": "Hora de Início",
|
"startTime": "Hora de início",
|
||||||
"endTime": "Hora de Fim",
|
"endTime": "Hora de término",
|
||||||
"workDescription": "Descrição do Trabalho",
|
"workDescription": "Descrição do trabalho",
|
||||||
"descriptionPlaceholder": "Adicionar uma descrição",
|
"descriptionPlaceholder": "Adicionar uma descrição",
|
||||||
"logTime": "Registrar tempo",
|
"logTime": "Registrar tempo",
|
||||||
"updateTime": "Atualizar tempo",
|
"updateTime": "Atualizar tempo",
|
||||||
"cancel": "Cancelar",
|
"cancel": "Cancelar",
|
||||||
"selectDateError": "Por favor selecione uma data",
|
"selectDateError": "Por favor, selecione uma data",
|
||||||
"selectStartTimeError": "Por favor selecione a hora de início",
|
"selectStartTimeError": "Por favor, selecione a hora de início",
|
||||||
"selectEndTimeError": "Por favor selecione a hora de fim",
|
"selectEndTimeError": "Por favor, selecione a hora de término",
|
||||||
"endTimeAfterStartError": "A hora de fim deve ser posterior à hora de início"
|
"endTimeAfterStartError": "A hora de término deve ser posterior à hora de início"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"taskActivityLogTab": {
|
"taskActivityLogTab": {
|
||||||
"title": "Registro de Atividade",
|
"title": "Registro de atividade",
|
||||||
"add": "ADICIONAR",
|
"add": "ADICIONAR",
|
||||||
"remove": "REMOVER",
|
"remove": "REMOVER",
|
||||||
"none": "Nenhum",
|
"none": "Nenhum",
|
||||||
@@ -115,7 +121,7 @@
|
|||||||
"createdTask": "criou a tarefa."
|
"createdTask": "criou a tarefa."
|
||||||
},
|
},
|
||||||
"taskProgress": {
|
"taskProgress": {
|
||||||
"markAsDoneTitle": "Marcar Tarefa como Concluída?",
|
"markAsDoneTitle": "Marcar tarefa como concluída?",
|
||||||
"confirmMarkAsDone": "Sim, marcar como concluída",
|
"confirmMarkAsDone": "Sim, marcar como concluída",
|
||||||
"cancelMarkAsDone": "Não, manter status atual",
|
"cancelMarkAsDone": "Não, manter status atual",
|
||||||
"markAsDoneDescription": "Você definiu o progresso para 100%. Gostaria de atualizar o status da tarefa para \"Concluída\"?"
|
"markAsDoneDescription": "Você definiu o progresso para 100%. Gostaria de atualizar o status da tarefa para \"Concluída\"?"
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"addTaskText": "Adicionar Tarefa",
|
"addTaskText": "Adicionar Tarefa",
|
||||||
"addSubTaskText": "+ Adicionar Subtarefa",
|
"addSubTaskText": "+ Adicionar Subtarefa",
|
||||||
"noTasksInGroup": "Nenhuma tarefa neste grupo",
|
"noTasksInGroup": "Nenhuma tarefa neste grupo",
|
||||||
|
"dropTaskHere": "Soltar tarefa aqui",
|
||||||
"addTaskInputPlaceholder": "Digite sua tarefa e pressione enter",
|
"addTaskInputPlaceholder": "Digite sua tarefa e pressione enter",
|
||||||
|
|
||||||
"openButton": "Abrir",
|
"openButton": "Abrir",
|
||||||
|
|||||||
@@ -1,22 +1,28 @@
|
|||||||
{
|
{
|
||||||
"taskHeader": {
|
"taskHeader": {
|
||||||
"taskNamePlaceholder": "输入您的任务",
|
"taskNamePlaceholder": "输入您的任务",
|
||||||
"deleteTask": "删除任务"
|
"deleteTask": "删除任务",
|
||||||
|
"parentTask": "父任务",
|
||||||
|
"currentTask": "当前任务",
|
||||||
|
"back": "返回",
|
||||||
|
"backToParent": "返回父任务",
|
||||||
|
"toParentTask": "到父任务",
|
||||||
|
"loadingHierarchy": "加载层次结构..."
|
||||||
},
|
},
|
||||||
"taskInfoTab": {
|
"taskInfoTab": {
|
||||||
"title": "信息",
|
"title": "信息",
|
||||||
"details": {
|
"details": {
|
||||||
"title": "详情",
|
"title": "详细信息",
|
||||||
"task-key": "任务键",
|
"task-key": "任务键",
|
||||||
"phase": "阶段",
|
"phase": "阶段",
|
||||||
"assignees": "受让人",
|
"assignees": "受理人",
|
||||||
"due-date": "截止日期",
|
"due-date": "截止日期",
|
||||||
"time-estimation": "时间估算",
|
"time-estimation": "时间估算",
|
||||||
"priority": "优先级",
|
"priority": "优先级",
|
||||||
"labels": "标签",
|
"labels": "标签",
|
||||||
"billable": "可计费",
|
"billable": "可计费",
|
||||||
"notify": "通知",
|
"notify": "通知",
|
||||||
"when-done-notify": "完成时,通知",
|
"when-done-notify": "完成时通知",
|
||||||
"start-date": "开始日期",
|
"start-date": "开始日期",
|
||||||
"end-date": "结束日期",
|
"end-date": "结束日期",
|
||||||
"hide-start-date": "隐藏开始日期",
|
"hide-start-date": "隐藏开始日期",
|
||||||
@@ -24,18 +30,18 @@
|
|||||||
"hours": "小时",
|
"hours": "小时",
|
||||||
"minutes": "分钟",
|
"minutes": "分钟",
|
||||||
"progressValue": "进度值",
|
"progressValue": "进度值",
|
||||||
"progressValueTooltip": "设置进度百分比(0-100%)",
|
"progressValueTooltip": "设置进度百分比 (0-100%)",
|
||||||
"progressValueRequired": "请输入进度值",
|
"progressValueRequired": "请输入进度值",
|
||||||
"progressValueRange": "进度必须在0到100之间",
|
"progressValueRange": "进度必须在 0 到 100 之间",
|
||||||
"taskWeight": "任务权重",
|
"taskWeight": "任务权重",
|
||||||
"taskWeightTooltip": "设置此子任务的权重(百分比)",
|
"taskWeightTooltip": "设置此子任务的权重 (百分比)",
|
||||||
"taskWeightRequired": "请输入任务权重",
|
"taskWeightRequired": "请输入任务权重",
|
||||||
"taskWeightRange": "权重必须在0到100之间",
|
"taskWeightRange": "权重必须在 0 到 100 之间",
|
||||||
"recurring": "重复"
|
"recurring": "重复"
|
||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"labelInputPlaceholder": "搜索或创建",
|
"labelInputPlaceholder": "搜索或创建",
|
||||||
"labelsSelectorInputTip": "按回车创建"
|
"labelsSelectorInputTip": "按 Enter 键创建"
|
||||||
},
|
},
|
||||||
"description": {
|
"description": {
|
||||||
"title": "描述",
|
"title": "描述",
|
||||||
@@ -44,7 +50,7 @@
|
|||||||
"subTasks": {
|
"subTasks": {
|
||||||
"title": "子任务",
|
"title": "子任务",
|
||||||
"addSubTask": "添加子任务",
|
"addSubTask": "添加子任务",
|
||||||
"addSubTaskInputPlaceholder": "输入您的任务并按回车",
|
"addSubTaskInputPlaceholder": "输入您的任务并按回车键",
|
||||||
"refreshSubTasks": "刷新子任务",
|
"refreshSubTasks": "刷新子任务",
|
||||||
"edit": "编辑",
|
"edit": "编辑",
|
||||||
"delete": "删除",
|
"delete": "删除",
|
||||||
@@ -52,10 +58,10 @@
|
|||||||
"deleteSubTask": "删除子任务"
|
"deleteSubTask": "删除子任务"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"title": "依赖关系",
|
"title": "依赖项",
|
||||||
"addDependency": "+ 添加新依赖",
|
"addDependency": "+ 添加新依赖项",
|
||||||
"blockedBy": "被阻止",
|
"blockedBy": "被阻止",
|
||||||
"searchTask": "输入搜索任务",
|
"searchTask": "输入以搜索任务",
|
||||||
"noTasksFound": "未找到任务",
|
"noTasksFound": "未找到任务",
|
||||||
"confirmDeleteDependency": "您确定要删除吗?"
|
"confirmDeleteDependency": "您确定要删除吗?"
|
||||||
},
|
},
|
||||||
@@ -67,7 +73,7 @@
|
|||||||
"comments": {
|
"comments": {
|
||||||
"title": "评论",
|
"title": "评论",
|
||||||
"addComment": "+ 添加新评论",
|
"addComment": "+ 添加新评论",
|
||||||
"noComments": "还没有评论。成为第一个评论的人!",
|
"noComments": "还没有评论。成为第一个评论者!",
|
||||||
"delete": "删除",
|
"delete": "删除",
|
||||||
"confirmDeleteComment": "您确定要删除此评论吗?",
|
"confirmDeleteComment": "您确定要删除此评论吗?",
|
||||||
"addCommentPlaceholder": "添加评论...",
|
"addCommentPlaceholder": "添加评论...",
|
||||||
@@ -75,12 +81,12 @@
|
|||||||
"commentButton": "评论",
|
"commentButton": "评论",
|
||||||
"attachFiles": "附加文件",
|
"attachFiles": "附加文件",
|
||||||
"addMoreFiles": "添加更多文件",
|
"addMoreFiles": "添加更多文件",
|
||||||
"selectedFiles": "已选择的文件(最多25MB,最大{count}个)",
|
"selectedFiles": "选定文件 (最多 25MB,最多 {count} 个)",
|
||||||
"maxFilesError": "您最多只能上传{count}个文件",
|
"maxFilesError": "您最多只能上传 {count} 个文件",
|
||||||
"processFilesError": "处理文件失败",
|
"processFilesError": "处理文件失败",
|
||||||
"addCommentError": "请添加评论或附加文件",
|
"addCommentError": "请添加评论或附加文件",
|
||||||
"createdBy": "{{time}}由{{user}}创建",
|
"createdBy": "由 {{user}} 在 {{time}} 创建",
|
||||||
"updatedTime": "更新于{{time}}"
|
"updatedTime": "更新于 {{time}}"
|
||||||
},
|
},
|
||||||
"searchInputPlaceholder": "按名称搜索",
|
"searchInputPlaceholder": "按名称搜索",
|
||||||
"pendingInvitation": "待处理邀请"
|
"pendingInvitation": "待处理邀请"
|
||||||
@@ -88,8 +94,8 @@
|
|||||||
"taskTimeLogTab": {
|
"taskTimeLogTab": {
|
||||||
"title": "时间日志",
|
"title": "时间日志",
|
||||||
"addTimeLog": "添加新时间日志",
|
"addTimeLog": "添加新时间日志",
|
||||||
"totalLogged": "总记录时间",
|
"totalLogged": "总计记录",
|
||||||
"exportToExcel": "导出到Excel",
|
"exportToExcel": "导出到 Excel",
|
||||||
"noTimeLogsFound": "未找到时间日志",
|
"noTimeLogsFound": "未找到时间日志",
|
||||||
"timeLogForm": {
|
"timeLogForm": {
|
||||||
"date": "日期",
|
"date": "日期",
|
||||||
@@ -103,7 +109,7 @@
|
|||||||
"selectDateError": "请选择日期",
|
"selectDateError": "请选择日期",
|
||||||
"selectStartTimeError": "请选择开始时间",
|
"selectStartTimeError": "请选择开始时间",
|
||||||
"selectEndTimeError": "请选择结束时间",
|
"selectEndTimeError": "请选择结束时间",
|
||||||
"endTimeAfterStartError": "结束时间必须在开始时间之后"
|
"endTimeAfterStartError": "结束时间必须晚于开始时间"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"taskActivityLogTab": {
|
"taskActivityLogTab": {
|
||||||
@@ -116,8 +122,8 @@
|
|||||||
},
|
},
|
||||||
"taskProgress": {
|
"taskProgress": {
|
||||||
"markAsDoneTitle": "将任务标记为完成?",
|
"markAsDoneTitle": "将任务标记为完成?",
|
||||||
"confirmMarkAsDone": "是的,标记为完成",
|
"confirmMarkAsDone": "是,标记为完成",
|
||||||
"cancelMarkAsDone": "不,保持当前状态",
|
"cancelMarkAsDone": "否,保持当前状态",
|
||||||
"markAsDoneDescription": "您已将进度设置为100%。您想将任务状态更新为\"完成\"吗?"
|
"markAsDoneDescription": "您已将进度设置为 100%。您想将任务状态更新为\"完成\"吗?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
"addSubTaskText": "+ 添加子任务",
|
"addSubTaskText": "+ 添加子任务",
|
||||||
"addTaskInputPlaceholder": "输入任务并按回车键",
|
"addTaskInputPlaceholder": "输入任务并按回车键",
|
||||||
"noTasksInGroup": "此组中没有任务",
|
"noTasksInGroup": "此组中没有任务",
|
||||||
|
"dropTaskHere": "将任务拖到这里",
|
||||||
"openButton": "打开",
|
"openButton": "打开",
|
||||||
"okButton": "确定",
|
"okButton": "确定",
|
||||||
"noLabelsFound": "未找到标签",
|
"noLabelsFound": "未找到标签",
|
||||||
|
|||||||
@@ -331,6 +331,13 @@ self.addEventListener('message', event => {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'LOGOUT':
|
||||||
|
// Special handler for logout - clear all caches and unregister
|
||||||
|
handleLogout().then(() => {
|
||||||
|
event.ports[0].postMessage({ success: true });
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
console.log('Service Worker: Unknown message type', type);
|
console.log('Service Worker: Unknown message type', type);
|
||||||
}
|
}
|
||||||
@@ -342,4 +349,19 @@ async function clearAllCaches() {
|
|||||||
console.log('Service Worker: All caches cleared');
|
console.log('Service Worker: All caches cleared');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleLogout() {
|
||||||
|
try {
|
||||||
|
// Clear all caches
|
||||||
|
await clearAllCaches();
|
||||||
|
|
||||||
|
// Unregister the service worker to force fresh registration on next visit
|
||||||
|
await self.registration.unregister();
|
||||||
|
|
||||||
|
console.log('Service Worker: Logout handled - caches cleared and unregistered');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Service Worker: Error during logout handling', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Service Worker: Loaded successfully');
|
console.log('Service Worker: Loaded successfully');
|
||||||
@@ -5,6 +5,7 @@ import i18next from 'i18next';
|
|||||||
|
|
||||||
// Components
|
// Components
|
||||||
import ThemeWrapper from './features/theme/ThemeWrapper';
|
import ThemeWrapper from './features/theme/ThemeWrapper';
|
||||||
|
import ModuleErrorBoundary from './components/ModuleErrorBoundary';
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
import router from './app/routes';
|
import router from './app/routes';
|
||||||
@@ -13,6 +14,7 @@ import router from './app/routes';
|
|||||||
import { useAppSelector } from './hooks/useAppSelector';
|
import { useAppSelector } from './hooks/useAppSelector';
|
||||||
import { initMixpanel } from './utils/mixpanelInit';
|
import { initMixpanel } from './utils/mixpanelInit';
|
||||||
import { initializeCsrfToken } from './api/api-client';
|
import { initializeCsrfToken } from './api/api-client';
|
||||||
|
import CacheCleanup from './utils/cache-cleanup';
|
||||||
|
|
||||||
// Types & Constants
|
// Types & Constants
|
||||||
import { Language } from './features/i18n/localesSlice';
|
import { Language } from './features/i18n/localesSlice';
|
||||||
@@ -113,6 +115,56 @@ const App: React.FC = memo(() => {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Global error handlers for module loading issues
|
||||||
|
useEffect(() => {
|
||||||
|
const handleUnhandledRejection = (event: PromiseRejectionEvent) => {
|
||||||
|
const error = event.reason;
|
||||||
|
|
||||||
|
// Check if this is a module loading error
|
||||||
|
if (
|
||||||
|
error?.message?.includes('Failed to fetch dynamically imported module') ||
|
||||||
|
error?.message?.includes('Loading chunk') ||
|
||||||
|
error?.name === 'ChunkLoadError'
|
||||||
|
) {
|
||||||
|
console.error('Unhandled module loading error:', error);
|
||||||
|
event.preventDefault(); // Prevent default browser error handling
|
||||||
|
|
||||||
|
// Clear caches and reload
|
||||||
|
CacheCleanup.clearAllCaches()
|
||||||
|
.then(() => CacheCleanup.forceReload('/auth/login'))
|
||||||
|
.catch(() => window.location.reload());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleError = (event: ErrorEvent) => {
|
||||||
|
const error = event.error;
|
||||||
|
|
||||||
|
// Check if this is a module loading error
|
||||||
|
if (
|
||||||
|
error?.message?.includes('Failed to fetch dynamically imported module') ||
|
||||||
|
error?.message?.includes('Loading chunk') ||
|
||||||
|
error?.name === 'ChunkLoadError'
|
||||||
|
) {
|
||||||
|
console.error('Global module loading error:', error);
|
||||||
|
event.preventDefault(); // Prevent default browser error handling
|
||||||
|
|
||||||
|
// Clear caches and reload
|
||||||
|
CacheCleanup.clearAllCaches()
|
||||||
|
.then(() => CacheCleanup.forceReload('/auth/login'))
|
||||||
|
.catch(() => window.location.reload());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add global error handlers
|
||||||
|
window.addEventListener('unhandledrejection', handleUnhandledRejection);
|
||||||
|
window.addEventListener('error', handleError);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('unhandledrejection', handleUnhandledRejection);
|
||||||
|
window.removeEventListener('error', handleError);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Register service worker
|
// Register service worker
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
registerSW({
|
registerSW({
|
||||||
@@ -150,12 +202,14 @@ const App: React.FC = memo(() => {
|
|||||||
return (
|
return (
|
||||||
<Suspense fallback={<SuspenseFallback />}>
|
<Suspense fallback={<SuspenseFallback />}>
|
||||||
<ThemeWrapper>
|
<ThemeWrapper>
|
||||||
|
<ModuleErrorBoundary>
|
||||||
<RouterProvider
|
<RouterProvider
|
||||||
router={router}
|
router={router}
|
||||||
future={{
|
future={{
|
||||||
v7_startTransition: true,
|
v7_startTransition: true,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</ModuleErrorBoundary>
|
||||||
</ThemeWrapper>
|
</ThemeWrapper>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -90,6 +90,23 @@ export const SetupGuard = memo(({ children }: GuardProps) => {
|
|||||||
|
|
||||||
SetupGuard.displayName = 'SetupGuard';
|
SetupGuard.displayName = 'SetupGuard';
|
||||||
|
|
||||||
|
// Combined guard for routes that require both authentication and setup completion
|
||||||
|
export const AuthAndSetupGuard = memo(({ children }: GuardProps) => {
|
||||||
|
const { isAuthenticated, isSetupComplete, location } = useAuthStatus();
|
||||||
|
|
||||||
|
if (!isAuthenticated) {
|
||||||
|
return <Navigate to="/auth" state={{ from: location }} replace />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isSetupComplete) {
|
||||||
|
return <Navigate to="/worklenz/setup" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
return <>{children}</>;
|
||||||
|
});
|
||||||
|
|
||||||
|
AuthAndSetupGuard.displayName = 'AuthAndSetupGuard';
|
||||||
|
|
||||||
// Optimized route wrapping function with Suspense boundaries
|
// Optimized route wrapping function with Suspense boundaries
|
||||||
const wrapRoutes = (
|
const wrapRoutes = (
|
||||||
routes: RouteObject[],
|
routes: RouteObject[],
|
||||||
@@ -171,9 +188,11 @@ StaticLicenseExpired.displayName = 'StaticLicenseExpired';
|
|||||||
// Create route arrays (moved outside of useMemo to avoid hook violations)
|
// Create route arrays (moved outside of useMemo to avoid hook violations)
|
||||||
const publicRoutes = [...rootRoutes, ...authRoutes, notFoundRoute];
|
const publicRoutes = [...rootRoutes, ...authRoutes, notFoundRoute];
|
||||||
|
|
||||||
const protectedMainRoutes = wrapRoutes(mainRoutes, AuthGuard);
|
// Apply combined guard to main routes that require both auth and setup completion
|
||||||
|
const protectedMainRoutes = wrapRoutes(mainRoutes, AuthAndSetupGuard);
|
||||||
const adminRoutes = wrapRoutes(reportingRoutes, AdminGuard);
|
const adminRoutes = wrapRoutes(reportingRoutes, AdminGuard);
|
||||||
const setupRoutes = wrapRoutes([accountSetupRoute], SetupGuard);
|
// Setup route should be accessible without setup completion, only requires authentication
|
||||||
|
const setupRoutes = wrapRoutes([accountSetupRoute], AuthGuard);
|
||||||
|
|
||||||
// License expiry check function
|
// License expiry check function
|
||||||
const withLicenseExpiryCheck = (routes: RouteObject[]): RouteObject[] => {
|
const withLicenseExpiryCheck = (routes: RouteObject[]): RouteObject[] => {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ const CustomColordLabel = React.forwardRef<HTMLSpanElement, CustomColordLabelPro
|
|||||||
<Tooltip title={label.name}>
|
<Tooltip title={label.name}>
|
||||||
<span
|
<span
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className="inline-flex items-center px-2 py-0.5 rounded-sm text-xs font-medium shrink-0 max-w-[120px]"
|
className="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium shrink-0 max-w-[100px]"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
color: textColor,
|
color: textColor,
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ const CustomNumberLabel = React.forwardRef<HTMLSpanElement, CustomNumberLabelPro
|
|||||||
<Tooltip title={labelList.join(', ')}>
|
<Tooltip title={labelList.join(', ')}>
|
||||||
<span
|
<span
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium text-white cursor-help"
|
className="inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium cursor-help"
|
||||||
style={{ backgroundColor }}
|
style={{ backgroundColor, color: 'white' }}
|
||||||
>
|
>
|
||||||
{namesString}
|
{namesString}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
110
worklenz-frontend/src/components/ModuleErrorBoundary.tsx
Normal file
110
worklenz-frontend/src/components/ModuleErrorBoundary.tsx
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
||||||
|
import { Button, Result } from 'antd';
|
||||||
|
import CacheCleanup from '@/utils/cache-cleanup';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
hasError: boolean;
|
||||||
|
error?: Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ModuleErrorBoundary extends Component<Props, State> {
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDerivedStateFromError(error: Error): State {
|
||||||
|
// Check if this is a module loading error
|
||||||
|
const isModuleError =
|
||||||
|
error.message.includes('Failed to fetch dynamically imported module') ||
|
||||||
|
error.message.includes('Loading chunk') ||
|
||||||
|
error.message.includes('Loading CSS chunk') ||
|
||||||
|
error.name === 'ChunkLoadError';
|
||||||
|
|
||||||
|
if (isModuleError) {
|
||||||
|
return { hasError: true, error };
|
||||||
|
}
|
||||||
|
|
||||||
|
// For other errors, let them bubble up
|
||||||
|
return { hasError: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||||
|
console.error('Module Error Boundary caught an error:', error, errorInfo);
|
||||||
|
|
||||||
|
// If this is a module loading error, clear caches and reload
|
||||||
|
if (this.state.hasError) {
|
||||||
|
this.handleModuleError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async handleModuleError() {
|
||||||
|
try {
|
||||||
|
console.log('Handling module loading error - clearing caches...');
|
||||||
|
|
||||||
|
// Clear all caches
|
||||||
|
await CacheCleanup.clearAllCaches();
|
||||||
|
|
||||||
|
// Force reload to login page
|
||||||
|
CacheCleanup.forceReload('/auth/login');
|
||||||
|
} catch (cacheError) {
|
||||||
|
console.error('Failed to handle module error:', cacheError);
|
||||||
|
// Fallback: just reload the page
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private handleRetry = async () => {
|
||||||
|
try {
|
||||||
|
await CacheCleanup.clearAllCaches();
|
||||||
|
CacheCleanup.forceReload('/auth/login');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Retry failed:', error);
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
minHeight: '100vh',
|
||||||
|
padding: '20px'
|
||||||
|
}}>
|
||||||
|
<Result
|
||||||
|
status="error"
|
||||||
|
title="Module Loading Error"
|
||||||
|
subTitle="There was an issue loading the application. This usually happens after updates or during logout."
|
||||||
|
extra={[
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
key="retry"
|
||||||
|
onClick={this.handleRetry}
|
||||||
|
loading={false}
|
||||||
|
>
|
||||||
|
Retry
|
||||||
|
</Button>,
|
||||||
|
<Button
|
||||||
|
key="reload"
|
||||||
|
onClick={() => window.location.reload()}
|
||||||
|
>
|
||||||
|
Reload Page
|
||||||
|
</Button>
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ModuleErrorBoundary;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { startTransition, useEffect, useRef, useState } from 'react';
|
import React, { startTransition, useEffect, useRef, useState } from 'react';
|
||||||
import { useDispatch, useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
@@ -18,6 +18,11 @@ import { IAccountSetupRequest } from '@/types/project-templates/project-template
|
|||||||
import { evt_account_setup_template_complete } from '@/shared/worklenz-analytics-events';
|
import { evt_account_setup_template_complete } from '@/shared/worklenz-analytics-events';
|
||||||
import { useMixpanelTracking } from '@/hooks/useMixpanelTracking';
|
import { useMixpanelTracking } from '@/hooks/useMixpanelTracking';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
|
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||||
|
import { verifyAuthentication } from '@/features/auth/authSlice';
|
||||||
|
import { setUser } from '@/features/user/userSlice';
|
||||||
|
import { setSession } from '@/utils/session-helper';
|
||||||
|
import { IAuthorizeResponse } from '@/types/auth/login.types';
|
||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
@@ -29,7 +34,7 @@ interface Props {
|
|||||||
|
|
||||||
export const ProjectStep: React.FC<Props> = ({ onEnter, styles, isDarkMode = false }) => {
|
export const ProjectStep: React.FC<Props> = ({ onEnter, styles, isDarkMode = false }) => {
|
||||||
const { t } = useTranslation('account-setup');
|
const { t } = useTranslation('account-setup');
|
||||||
const dispatch = useDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { trackMixpanelEvent } = useMixpanelTracking();
|
const { trackMixpanelEvent } = useMixpanelTracking();
|
||||||
|
|
||||||
@@ -69,6 +74,18 @@ export const ProjectStep: React.FC<Props> = ({ onEnter, styles, isDarkMode = fal
|
|||||||
if (res.done && res.body.id) {
|
if (res.done && res.body.id) {
|
||||||
toggleTemplateSelector(false);
|
toggleTemplateSelector(false);
|
||||||
trackMixpanelEvent(evt_account_setup_template_complete);
|
trackMixpanelEvent(evt_account_setup_template_complete);
|
||||||
|
|
||||||
|
// Refresh user session to update setup_completed status
|
||||||
|
try {
|
||||||
|
const authResponse = await dispatch(verifyAuthentication()).unwrap() as IAuthorizeResponse;
|
||||||
|
if (authResponse?.authenticated && authResponse?.user) {
|
||||||
|
setSession(authResponse.user);
|
||||||
|
dispatch(setUser(authResponse.user));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Failed to refresh user session after template setup completion', error);
|
||||||
|
}
|
||||||
|
|
||||||
navigate(`/worklenz/projects/${res.body.id}?tab=tasks-list&pinned_tab=tasks-list`);
|
navigate(`/worklenz/projects/${res.body.id}?tab=tasks-list&pinned_tab=tasks-list`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import { useAuthService } from '@/hooks/useAuth';
|
|||||||
import { statusApiService } from '@/api/taskAttributes/status/status.api.service';
|
import { statusApiService } from '@/api/taskAttributes/status/status.api.service';
|
||||||
import alertService from '@/services/alerts/alertService';
|
import alertService from '@/services/alerts/alertService';
|
||||||
import logger from '@/utils/errorLogger';
|
import logger from '@/utils/errorLogger';
|
||||||
import Skeleton from 'antd/es/skeleton/Skeleton';
|
|
||||||
import { checkTaskDependencyStatus } from '@/utils/check-task-dependency-status';
|
import { checkTaskDependencyStatus } from '@/utils/check-task-dependency-status';
|
||||||
import { useTaskSocketHandlers } from '@/hooks/useTaskSocketHandlers';
|
import { useTaskSocketHandlers } from '@/hooks/useTaskSocketHandlers';
|
||||||
|
|
||||||
@@ -148,11 +147,11 @@ const EnhancedKanbanBoardNativeDnD: React.FC<{ projectId: string }> = ({ project
|
|||||||
const targetGroup = taskGroups.find(g => g.id === targetGroupId);
|
const targetGroup = taskGroups.find(g => g.id === targetGroupId);
|
||||||
if (!sourceGroup || !targetGroup) return;
|
if (!sourceGroup || !targetGroup) return;
|
||||||
|
|
||||||
|
|
||||||
const taskIdx = sourceGroup.tasks.findIndex(t => t.id === draggedTaskId);
|
const taskIdx = sourceGroup.tasks.findIndex(t => t.id === draggedTaskId);
|
||||||
if (taskIdx === -1) return;
|
if (taskIdx === -1) return;
|
||||||
|
|
||||||
const movedTask = sourceGroup.tasks[taskIdx];
|
const movedTask = sourceGroup.tasks[taskIdx];
|
||||||
|
let didStatusChange = false;
|
||||||
if (groupBy === 'status' && movedTask.id) {
|
if (groupBy === 'status' && movedTask.id) {
|
||||||
if (sourceGroup.id !== targetGroup.id) {
|
if (sourceGroup.id !== targetGroup.id) {
|
||||||
const canContinue = await checkTaskDependencyStatus(movedTask.id, targetGroupId);
|
const canContinue = await checkTaskDependencyStatus(movedTask.id, targetGroupId);
|
||||||
@@ -163,6 +162,7 @@ const EnhancedKanbanBoardNativeDnD: React.FC<{ projectId: string }> = ({ project
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
didStatusChange = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let insertIdx = hoveredTaskIdx;
|
let insertIdx = hoveredTaskIdx;
|
||||||
@@ -259,6 +259,18 @@ const EnhancedKanbanBoardNativeDnD: React.FC<{ projectId: string }> = ({ project
|
|||||||
team_id: teamId,
|
team_id: teamId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Emit progress update if status changed
|
||||||
|
if (didStatusChange) {
|
||||||
|
socket.emit(
|
||||||
|
SocketEvents.TASK_STATUS_CHANGE.toString(),
|
||||||
|
JSON.stringify({
|
||||||
|
task_id: movedTask.id,
|
||||||
|
status_id: targetGroupId,
|
||||||
|
parent_task: movedTask.parent_task_id || null,
|
||||||
|
team_id: teamId,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setDraggedTaskId(null);
|
setDraggedTaskId(null);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { SocketEvents } from '@/shared/socket-events';
|
|||||||
import { getUserSession } from '@/utils/session-helper';
|
import { getUserSession } from '@/utils/session-helper';
|
||||||
import { themeWiseColor } from '@/utils/themeWiseColor';
|
import { themeWiseColor } from '@/utils/themeWiseColor';
|
||||||
import { toggleTaskExpansion, fetchBoardSubTasks } from '@/features/enhanced-kanban/enhanced-kanban.slice';
|
import { toggleTaskExpansion, fetchBoardSubTasks } from '@/features/enhanced-kanban/enhanced-kanban.slice';
|
||||||
|
import TaskProgressCircle from './TaskProgressCircle';
|
||||||
|
|
||||||
// Simple Portal component
|
// Simple Portal component
|
||||||
const Portal: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
const Portal: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||||
@@ -69,7 +70,6 @@ const TaskCard: React.FC<TaskCardProps> = memo(({
|
|||||||
const d = selectedDate || new Date();
|
const d = selectedDate || new Date();
|
||||||
return new Date(d.getFullYear(), d.getMonth(), 1);
|
return new Date(d.getFullYear(), d.getMonth(), 1);
|
||||||
});
|
});
|
||||||
const [showSubtasks, setShowSubtasks] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedDate(task.end_date ? new Date(task.end_date) : null);
|
setSelectedDate(task.end_date ? new Date(task.end_date) : null);
|
||||||
@@ -202,7 +202,11 @@ const TaskCard: React.FC<TaskCardProps> = memo(({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="enhanced-kanban-task-card" style={{ background, color, display: 'block' }} >
|
<div className="enhanced-kanban-task-card" style={{ background, color, display: 'block', position: 'relative' }} >
|
||||||
|
{/* Progress circle at top right */}
|
||||||
|
<div style={{ position: 'absolute', top: 6, right: 6, zIndex: 2 }}>
|
||||||
|
<TaskProgressCircle task={task} size={20} />
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
draggable
|
draggable
|
||||||
onDragStart={e => onTaskDragStart(e, task.id!, groupId)}
|
onDragStart={e => onTaskDragStart(e, task.id!, groupId)}
|
||||||
@@ -450,7 +454,7 @@ const TaskCard: React.FC<TaskCardProps> = memo(({
|
|||||||
style={{ backgroundColor: themeMode === 'dark' ? (sub.priority_color_dark || sub.priority_color || '#d9d9d9') : (sub.priority_color || '#d9d9d9') }}
|
style={{ backgroundColor: themeMode === 'dark' ? (sub.priority_color_dark || sub.priority_color || '#d9d9d9') : (sub.priority_color || '#d9d9d9') }}
|
||||||
></span>
|
></span>
|
||||||
) : null}
|
) : null}
|
||||||
<span className="flex-1 truncate text-xs text-gray-800 dark:text-gray-100">{sub.name}</span>
|
<span className="flex-1 truncate text-xs text-gray-800 dark:text-gray-100" title={sub.name}>{sub.name}</span>
|
||||||
<span
|
<span
|
||||||
className="task-due-date ml-2 text-[10px] text-gray-500 dark:text-gray-400"
|
className="task-due-date ml-2 text-[10px] text-gray-500 dark:text-gray-400"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { IProjectTask } from "@/types/project/projectTasksViewModel.types";
|
||||||
|
|
||||||
|
// Add a simple circular progress component
|
||||||
|
const TaskProgressCircle: React.FC<{ task: IProjectTask; size?: number }> = ({ task, size = 28 }) => {
|
||||||
|
const progress = typeof task.complete_ratio === 'number'
|
||||||
|
? task.complete_ratio
|
||||||
|
: (typeof task.progress === 'number' ? task.progress : 0);
|
||||||
|
const strokeWidth = 1.5;
|
||||||
|
const radius = (size - strokeWidth) / 2;
|
||||||
|
const circumference = 2 * Math.PI * radius;
|
||||||
|
const offset = circumference - (progress / 100) * circumference;
|
||||||
|
return (
|
||||||
|
<svg width={size} height={size} style={{ display: 'block' }}>
|
||||||
|
|
||||||
|
<circle
|
||||||
|
cx={size / 2}
|
||||||
|
cy={size / 2}
|
||||||
|
r={radius}
|
||||||
|
stroke={progress === 100 ? "#22c55e" : "#3b82f6"}
|
||||||
|
strokeWidth={strokeWidth}
|
||||||
|
fill="none"
|
||||||
|
strokeDasharray={circumference}
|
||||||
|
strokeDashoffset={offset}
|
||||||
|
strokeLinecap="round"
|
||||||
|
style={{ transition: 'stroke-dashoffset 0.3s' }}
|
||||||
|
/>
|
||||||
|
{progress === 100 ? (
|
||||||
|
// Green checkmark icon
|
||||||
|
<g>
|
||||||
|
<circle cx={size / 2} cy={size / 2} r={radius} fill="#22c55e" opacity="0.15" />
|
||||||
|
<svg x={(size/2)-(size*0.22)} y={(size/2)-(size*0.22)} width={size*0.44} height={size*0.44} viewBox="0 0 24 24">
|
||||||
|
<path d="M5 13l4 4L19 7" stroke="#22c55e" strokeWidth="2.2" fill="none" strokeLinecap="round" strokeLinejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
</g>
|
||||||
|
) : progress > 0 && (
|
||||||
|
<text
|
||||||
|
x="50%"
|
||||||
|
y="50%"
|
||||||
|
textAnchor="middle"
|
||||||
|
dominantBaseline="central"
|
||||||
|
fontSize={size * 0.38}
|
||||||
|
fill="#3b82f6"
|
||||||
|
fontWeight="bold"
|
||||||
|
>
|
||||||
|
{Math.round(progress)}
|
||||||
|
</text>
|
||||||
|
)}
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TaskProgressCircle;
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
.performance-monitor {
|
|
||||||
position: fixed;
|
|
||||||
top: 80px;
|
|
||||||
right: 16px;
|
|
||||||
width: 280px;
|
|
||||||
z-index: 1000;
|
|
||||||
background: var(--ant-color-bg-elevated);
|
|
||||||
border: 1px solid var(--ant-color-border);
|
|
||||||
box-shadow: 0 4px 12px var(--ant-color-shadow);
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-monitor-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--ant-color-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-status {
|
|
||||||
font-size: 10px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-metrics {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
gap: 12px;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-metrics .ant-statistic {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-metrics .ant-statistic-title {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--ant-color-text-secondary);
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-metrics .ant-statistic-content {
|
|
||||||
font-size: 14px;
|
|
||||||
color: var(--ant-color-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.virtualization-status {
|
|
||||||
grid-column: 1 / -1;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 8px 0;
|
|
||||||
border-top: 1px solid var(--ant-color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.status-label {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--ant-color-text-secondary);
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-tips {
|
|
||||||
margin-top: 12px;
|
|
||||||
padding-top: 12px;
|
|
||||||
border-top: 1px solid var(--ant-color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-tips h4 {
|
|
||||||
font-size: 12px;
|
|
||||||
color: var(--ant-color-text);
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-tips ul {
|
|
||||||
margin: 0;
|
|
||||||
padding-left: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-tips li {
|
|
||||||
font-size: 11px;
|
|
||||||
color: var(--ant-color-text-secondary);
|
|
||||||
margin-bottom: 4px;
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Responsive design */
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.performance-monitor {
|
|
||||||
position: static;
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.performance-metrics {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Card, Statistic, Tooltip, Badge } from 'antd';
|
|
||||||
import { useSelector } from 'react-redux';
|
|
||||||
import { RootState } from '@/app/store';
|
|
||||||
import './PerformanceMonitor.css';
|
|
||||||
|
|
||||||
const PerformanceMonitor: React.FC = () => {
|
|
||||||
const { performanceMetrics } = useSelector((state: RootState) => state.enhancedKanbanReducer);
|
|
||||||
|
|
||||||
// Only show if there are tasks loaded
|
|
||||||
if (performanceMetrics.totalTasks === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const getPerformanceStatus = () => {
|
|
||||||
if (performanceMetrics.totalTasks > 1000) return 'critical';
|
|
||||||
if (performanceMetrics.totalTasks > 500) return 'warning';
|
|
||||||
if (performanceMetrics.totalTasks > 100) return 'good';
|
|
||||||
return 'excellent';
|
|
||||||
};
|
|
||||||
|
|
||||||
const getStatusColor = (status: string) => {
|
|
||||||
switch (status) {
|
|
||||||
case 'critical':
|
|
||||||
return 'red';
|
|
||||||
case 'warning':
|
|
||||||
return 'orange';
|
|
||||||
case 'good':
|
|
||||||
return 'blue';
|
|
||||||
case 'excellent':
|
|
||||||
return 'green';
|
|
||||||
default:
|
|
||||||
return 'default';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const status = getPerformanceStatus();
|
|
||||||
const statusColor = getStatusColor(status);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Card
|
|
||||||
size="small"
|
|
||||||
className="performance-monitor"
|
|
||||||
title={
|
|
||||||
<div className="performance-monitor-header">
|
|
||||||
<span>Performance Monitor</span>
|
|
||||||
<Badge
|
|
||||||
status={statusColor as any}
|
|
||||||
text={status.toUpperCase()}
|
|
||||||
className="performance-status"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div className="performance-metrics">
|
|
||||||
<Tooltip title="Total number of tasks across all groups">
|
|
||||||
<Statistic
|
|
||||||
title="Total Tasks"
|
|
||||||
value={performanceMetrics.totalTasks}
|
|
||||||
suffix="tasks"
|
|
||||||
valueStyle={{ fontSize: '16px' }}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip title="Largest group by number of tasks">
|
|
||||||
<Statistic
|
|
||||||
title="Largest Group"
|
|
||||||
value={performanceMetrics.largestGroupSize}
|
|
||||||
suffix="tasks"
|
|
||||||
valueStyle={{ fontSize: '16px' }}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip title="Average tasks per group">
|
|
||||||
<Statistic
|
|
||||||
title="Average Group"
|
|
||||||
value={Math.round(performanceMetrics.averageGroupSize)}
|
|
||||||
suffix="tasks"
|
|
||||||
valueStyle={{ fontSize: '16px' }}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
<Tooltip title="Virtualization is enabled for groups with more than 50 tasks">
|
|
||||||
<div className="virtualization-status">
|
|
||||||
<span className="status-label">Virtualization:</span>
|
|
||||||
<Badge
|
|
||||||
status={performanceMetrics.virtualizationEnabled ? 'success' : 'default'}
|
|
||||||
text={performanceMetrics.virtualizationEnabled ? 'Enabled' : 'Disabled'}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</Tooltip>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{performanceMetrics.totalTasks > 500 && (
|
|
||||||
<div className="performance-tips">
|
|
||||||
<h4>Performance Tips:</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Use filters to reduce the number of visible tasks</li>
|
|
||||||
<li>Consider grouping by different criteria</li>
|
|
||||||
<li>Virtualization is automatically enabled for large groups</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default React.memo(PerformanceMonitor);
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
.virtualized-task-list {
|
|
||||||
background: transparent;
|
|
||||||
border-radius: 6px;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.virtualized-task-row {
|
|
||||||
padding: 4px 0;
|
|
||||||
display: flex;
|
|
||||||
align-items: stretch;
|
|
||||||
}
|
|
||||||
|
|
||||||
.virtualized-empty-state {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: var(--ant-color-bg-container);
|
|
||||||
border-radius: 6px;
|
|
||||||
border: 2px dashed var(--ant-color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.empty-message {
|
|
||||||
color: var(--ant-color-text-secondary);
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure virtualized list works well with drag and drop */
|
|
||||||
.virtualized-task-list .react-window__inner {
|
|
||||||
overflow: visible !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Performance optimizations */
|
|
||||||
.virtualized-task-list * {
|
|
||||||
will-change: transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Smooth scrolling */
|
|
||||||
.virtualized-task-list {
|
|
||||||
scroll-behavior: smooth;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Custom scrollbar for better UX */
|
|
||||||
.virtualized-task-list::-webkit-scrollbar {
|
|
||||||
width: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.virtualized-task-list::-webkit-scrollbar-track {
|
|
||||||
background: var(--ant-color-bg-container);
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.virtualized-task-list::-webkit-scrollbar-thumb {
|
|
||||||
background: var(--ant-color-border);
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.virtualized-task-list::-webkit-scrollbar-thumb:hover {
|
|
||||||
background: var(--ant-color-text-tertiary);
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
import React, { useMemo, useCallback } from 'react';
|
|
||||||
import { FixedSizeList as List } from 'react-window';
|
|
||||||
import { IProjectTask } from '@/types/project/projectTasksViewModel.types';
|
|
||||||
import EnhancedKanbanTaskCard from './EnhancedKanbanTaskCard';
|
|
||||||
import './VirtualizedTaskList.css';
|
|
||||||
|
|
||||||
interface VirtualizedTaskListProps {
|
|
||||||
tasks: IProjectTask[];
|
|
||||||
height: number;
|
|
||||||
itemHeight?: number;
|
|
||||||
activeTaskId?: string | null;
|
|
||||||
overId?: string | null;
|
|
||||||
onTaskRender?: (task: IProjectTask, index: number) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const VirtualizedTaskList: React.FC<VirtualizedTaskListProps> = ({
|
|
||||||
tasks,
|
|
||||||
height,
|
|
||||||
itemHeight = 80,
|
|
||||||
activeTaskId,
|
|
||||||
overId,
|
|
||||||
onTaskRender,
|
|
||||||
}) => {
|
|
||||||
// Memoize task data to prevent unnecessary re-renders
|
|
||||||
const taskData = useMemo(
|
|
||||||
() => ({
|
|
||||||
tasks,
|
|
||||||
activeTaskId,
|
|
||||||
overId,
|
|
||||||
onTaskRender,
|
|
||||||
}),
|
|
||||||
[tasks, activeTaskId, overId, onTaskRender]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Row renderer for virtualized list
|
|
||||||
const Row = useCallback(
|
|
||||||
({ index, style }: { index: number; style: React.CSSProperties }) => {
|
|
||||||
const task = tasks[index];
|
|
||||||
if (!task) return null;
|
|
||||||
|
|
||||||
// Call onTaskRender callback if provided
|
|
||||||
onTaskRender?.(task, index);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<EnhancedKanbanTaskCard
|
|
||||||
task={task}
|
|
||||||
isActive={task.id === activeTaskId}
|
|
||||||
isDropTarget={overId === task.id}
|
|
||||||
sectionId={task.status || 'default'}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
[tasks, activeTaskId, overId, onTaskRender]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Memoize the list component to prevent unnecessary re-renders
|
|
||||||
const VirtualizedList = useMemo(
|
|
||||||
() => (
|
|
||||||
<List
|
|
||||||
height={height}
|
|
||||||
width="100%"
|
|
||||||
itemCount={tasks.length}
|
|
||||||
itemSize={itemHeight}
|
|
||||||
itemData={taskData}
|
|
||||||
overscanCount={10} // Increased overscan for smoother scrolling experience
|
|
||||||
className="virtualized-task-list"
|
|
||||||
>
|
|
||||||
{Row}
|
|
||||||
</List>
|
|
||||||
),
|
|
||||||
[height, tasks.length, itemHeight, taskData, Row]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (tasks.length === 0) {
|
|
||||||
return (
|
|
||||||
<div className="virtualized-empty-state" style={{ height, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
|
||||||
<div className="empty-message" style={{
|
|
||||||
padding: '32px 24px',
|
|
||||||
color: '#8c8c8c',
|
|
||||||
fontSize: '14px',
|
|
||||||
backgroundColor: '#fafafa',
|
|
||||||
borderRadius: '8px',
|
|
||||||
border: '1px solid #f0f0f0'
|
|
||||||
}}>
|
|
||||||
No tasks in this group
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return VirtualizedList;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default React.memo(VirtualizedTaskList);
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useSocket } from '@/socket/socketContext';
|
import { useSocket } from '@/socket/socketContext';
|
||||||
import { ITaskPhase } from '@/types/tasks/taskPhase.types';
|
import { ITaskPhase } from '@/types/tasks/taskPhase.types';
|
||||||
import { IProjectTask } from '@/types/project/projectTasksViewModel.types';
|
|
||||||
import { Select } from 'antd';
|
import { Select } from 'antd';
|
||||||
|
|
||||||
import { Form } from 'antd';
|
import { Form } from 'antd';
|
||||||
@@ -27,12 +26,6 @@ const TaskDrawerPhaseSelector = ({ phases, task }: TaskDrawerPhaseSelectorProps)
|
|||||||
phase_id: value,
|
phase_id: value,
|
||||||
parent_task: task.parent_task_id || null,
|
parent_task: task.parent_task_id || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
// socket?.once(SocketEvents.TASK_PHASE_CHANGE.toString(), () => {
|
|
||||||
// if(list.getCurrentGroup().value === this.list.GROUP_BY_PHASE_VALUE && this.list.isSubtasksIncluded) {
|
|
||||||
// this.list.emitRefreshSubtasksIncluded();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -41,8 +34,11 @@ const TaskDrawerPhaseSelector = ({ phases, task }: TaskDrawerPhaseSelectorProps)
|
|||||||
allowClear
|
allowClear
|
||||||
placeholder="Select Phase"
|
placeholder="Select Phase"
|
||||||
options={phaseMenuItems}
|
options={phaseMenuItems}
|
||||||
style={{ width: 'fit-content' }}
|
styles={{
|
||||||
dropdownStyle={{ width: 'fit-content' }}
|
root: {
|
||||||
|
width: 'fit-content',
|
||||||
|
},
|
||||||
|
}}
|
||||||
onChange={handlePhaseChange}
|
onChange={handlePhaseChange}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -11,7 +11,11 @@ import {
|
|||||||
Skeleton,
|
Skeleton,
|
||||||
Row,
|
Row,
|
||||||
Col,
|
Col,
|
||||||
|
DatePicker,
|
||||||
|
Tag,
|
||||||
|
Space,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
|
import { CloseOutlined } from '@ant-design/icons';
|
||||||
import { SettingOutlined } from '@ant-design/icons';
|
import { SettingOutlined } from '@ant-design/icons';
|
||||||
import { useSocket } from '@/socket/socketContext';
|
import { useSocket } from '@/socket/socketContext';
|
||||||
import { SocketEvents } from '@/shared/socket-events';
|
import { SocketEvents } from '@/shared/socket-events';
|
||||||
@@ -29,6 +33,7 @@ import { updateTaskCounts } from '@/features/task-management/task-management.sli
|
|||||||
import { taskRecurringApiService } from '@/api/tasks/task-recurring.api.service';
|
import { taskRecurringApiService } from '@/api/tasks/task-recurring.api.service';
|
||||||
import logger from '@/utils/errorLogger';
|
import logger from '@/utils/errorLogger';
|
||||||
import { setTaskRecurringSchedule } from '@/features/task-drawer/task-drawer.slice';
|
import { setTaskRecurringSchedule } from '@/features/task-drawer/task-drawer.slice';
|
||||||
|
import moment from 'moment-timezone';
|
||||||
|
|
||||||
const monthlyDateOptions = Array.from({ length: 28 }, (_, i) => i + 1);
|
const monthlyDateOptions = Array.from({ length: 28 }, (_, i) => i + 1);
|
||||||
|
|
||||||
@@ -66,6 +71,21 @@ const TaskDrawerRecurringConfig = ({ task }: { task: ITaskViewModel }) => {
|
|||||||
|
|
||||||
const dayOptions = daysOfWeek.map(d => ({ label: d.label, value: d.value }));
|
const dayOptions = daysOfWeek.map(d => ({ label: d.label, value: d.value }));
|
||||||
|
|
||||||
|
// Get common timezones
|
||||||
|
const timezoneOptions = [
|
||||||
|
{ label: 'UTC', value: 'UTC' },
|
||||||
|
{ label: 'US Eastern', value: 'America/New_York' },
|
||||||
|
{ label: 'US Central', value: 'America/Chicago' },
|
||||||
|
{ label: 'US Mountain', value: 'America/Denver' },
|
||||||
|
{ label: 'US Pacific', value: 'America/Los_Angeles' },
|
||||||
|
{ label: 'Europe/London', value: 'Europe/London' },
|
||||||
|
{ label: 'Europe/Paris', value: 'Europe/Paris' },
|
||||||
|
{ label: 'Asia/Tokyo', value: 'Asia/Tokyo' },
|
||||||
|
{ label: 'Asia/Shanghai', value: 'Asia/Shanghai' },
|
||||||
|
{ label: 'Asia/Kolkata', value: 'Asia/Kolkata' },
|
||||||
|
{ label: 'Australia/Sydney', value: 'Australia/Sydney' },
|
||||||
|
];
|
||||||
|
|
||||||
const [recurring, setRecurring] = useState(false);
|
const [recurring, setRecurring] = useState(false);
|
||||||
const [showConfig, setShowConfig] = useState(false);
|
const [showConfig, setShowConfig] = useState(false);
|
||||||
const [repeatOption, setRepeatOption] = useState<IRepeatOption>({});
|
const [repeatOption, setRepeatOption] = useState<IRepeatOption>({});
|
||||||
@@ -80,6 +100,10 @@ const TaskDrawerRecurringConfig = ({ task }: { task: ITaskViewModel }) => {
|
|||||||
const [loadingData, setLoadingData] = useState(false);
|
const [loadingData, setLoadingData] = useState(false);
|
||||||
const [updatingData, setUpdatingData] = useState(false);
|
const [updatingData, setUpdatingData] = useState(false);
|
||||||
const [scheduleData, setScheduleData] = useState<ITaskRecurringSchedule>({});
|
const [scheduleData, setScheduleData] = useState<ITaskRecurringSchedule>({});
|
||||||
|
const [timezone, setTimezone] = useState('UTC');
|
||||||
|
const [endDate, setEndDate] = useState<moment.Moment | null>(null);
|
||||||
|
const [excludedDates, setExcludedDates] = useState<string[]>([]);
|
||||||
|
const [newExcludeDate, setNewExcludeDate] = useState<moment.Moment | null>(null);
|
||||||
|
|
||||||
const handleChange = (checked: boolean) => {
|
const handleChange = (checked: boolean) => {
|
||||||
if (!task.id) return;
|
if (!task.id) return;
|
||||||
@@ -140,6 +164,9 @@ const TaskDrawerRecurringConfig = ({ task }: { task: ITaskViewModel }) => {
|
|||||||
const body: ITaskRecurringSchedule = {
|
const body: ITaskRecurringSchedule = {
|
||||||
id: task.id,
|
id: task.id,
|
||||||
schedule_type: repeatOption.value,
|
schedule_type: repeatOption.value,
|
||||||
|
timezone: timezone,
|
||||||
|
end_date: endDate ? endDate.format('YYYY-MM-DD') : null,
|
||||||
|
excluded_dates: excludedDates,
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (repeatOption.value) {
|
switch (repeatOption.value) {
|
||||||
@@ -213,13 +240,16 @@ const TaskDrawerRecurringConfig = ({ task }: { task: ITaskViewModel }) => {
|
|||||||
const selected = repeatOptions.find(e => e.value == res.body.schedule_type);
|
const selected = repeatOptions.find(e => e.value == res.body.schedule_type);
|
||||||
if (selected) {
|
if (selected) {
|
||||||
setRepeatOption(selected);
|
setRepeatOption(selected);
|
||||||
setSelectedMonthlyDate(scheduleData.date_of_month || 1);
|
setSelectedMonthlyDate(res.body.date_of_month || 1);
|
||||||
setSelectedMonthlyDay(scheduleData.day_of_month || 0);
|
setSelectedMonthlyDay(res.body.day_of_month || 0);
|
||||||
setSelectedMonthlyWeek(scheduleData.week_of_month || 0);
|
setSelectedMonthlyWeek(res.body.week_of_month || 0);
|
||||||
setIntervalDays(scheduleData.interval_days || 1);
|
setIntervalDays(res.body.interval_days || 1);
|
||||||
setIntervalWeeks(scheduleData.interval_weeks || 1);
|
setIntervalWeeks(res.body.interval_weeks || 1);
|
||||||
setIntervalMonths(scheduleData.interval_months || 1);
|
setIntervalMonths(res.body.interval_months || 1);
|
||||||
setMonthlyOption(selectedMonthlyDate ? 'date' : 'day');
|
setTimezone(res.body.timezone || 'UTC');
|
||||||
|
setEndDate(res.body.end_date ? moment(res.body.end_date) : null);
|
||||||
|
setExcludedDates(res.body.excluded_dates || []);
|
||||||
|
setMonthlyOption(res.body.date_of_month ? 'date' : 'day');
|
||||||
updateDaysOfWeek();
|
updateDaysOfWeek();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,6 +395,69 @@ const TaskDrawerRecurringConfig = ({ task }: { task: ITaskViewModel }) => {
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Timezone Selection */}
|
||||||
|
<Form.Item label={t('timezone')}>
|
||||||
|
<Select
|
||||||
|
value={timezone}
|
||||||
|
onChange={setTimezone}
|
||||||
|
options={timezoneOptions}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
{/* End Date */}
|
||||||
|
<Form.Item label={t('endDate')}>
|
||||||
|
<DatePicker
|
||||||
|
value={endDate}
|
||||||
|
onChange={setEndDate}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
placeholder={t('selectEndDate')}
|
||||||
|
disabledDate={(current) => current && current < moment().endOf('day')}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
{/* Excluded Dates */}
|
||||||
|
<Form.Item label={t('excludedDates')}>
|
||||||
|
<Space direction="vertical" style={{ width: '100%' }}>
|
||||||
|
<DatePicker
|
||||||
|
value={newExcludeDate}
|
||||||
|
onChange={setNewExcludeDate}
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
placeholder={t('selectDateToExclude')}
|
||||||
|
disabledDate={(current) => current && current < moment().endOf('day')}
|
||||||
|
/>
|
||||||
|
{newExcludeDate && (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
const dateStr = newExcludeDate.format('YYYY-MM-DD');
|
||||||
|
if (!excludedDates.includes(dateStr)) {
|
||||||
|
setExcludedDates([...excludedDates, dateStr]);
|
||||||
|
setNewExcludeDate(null);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('addExcludedDate')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<div style={{ marginTop: 8 }}>
|
||||||
|
{excludedDates.map((date) => (
|
||||||
|
<Tag
|
||||||
|
key={date}
|
||||||
|
closable
|
||||||
|
onClose={() => {
|
||||||
|
setExcludedDates(excludedDates.filter(d => d !== date));
|
||||||
|
}}
|
||||||
|
style={{ marginBottom: 4 }}
|
||||||
|
>
|
||||||
|
{date}
|
||||||
|
</Tag>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Space>
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item style={{ marginBottom: 0, textAlign: 'right' }}>
|
<Form.Item style={{ marginBottom: 0, textAlign: 'right' }}>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
|||||||
@@ -7,3 +7,28 @@
|
|||||||
outline: 1px solid #d9d9d9;
|
outline: 1px solid #d9d9d9;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Task name display styles */
|
||||||
|
.task-name-display {
|
||||||
|
margin: 0;
|
||||||
|
padding: 2px 8px;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
min-height: 20px;
|
||||||
|
line-height: 1.4;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-name-display:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.02);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='dark'] .task-name-display:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Button, Dropdown, Flex, Input, InputRef, MenuProps } from 'antd';
|
import { Button, Dropdown, Flex, Input, InputRef, MenuProps, Tooltip } from 'antd';
|
||||||
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
|
import React, { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||||
import { EllipsisOutlined } from '@ant-design/icons';
|
import { EllipsisOutlined } from '@ant-design/icons';
|
||||||
import { TFunction } from 'i18next';
|
import { TFunction } from 'i18next';
|
||||||
@@ -21,12 +21,19 @@ import { deleteBoardTask } from '@/features/board/board-slice';
|
|||||||
import { deleteTask as deleteKanbanTask, updateEnhancedKanbanSubtask } from '@/features/enhanced-kanban/enhanced-kanban.slice';
|
import { deleteTask as deleteKanbanTask, updateEnhancedKanbanSubtask } from '@/features/enhanced-kanban/enhanced-kanban.slice';
|
||||||
import useTabSearchParam from '@/hooks/useTabSearchParam';
|
import useTabSearchParam from '@/hooks/useTabSearchParam';
|
||||||
import { ITaskViewModel } from '@/types/tasks/task.types';
|
import { ITaskViewModel } from '@/types/tasks/task.types';
|
||||||
|
import TaskHierarchyBreadcrumb from '../task-hierarchy-breadcrumb/task-hierarchy-breadcrumb';
|
||||||
|
|
||||||
type TaskDrawerHeaderProps = {
|
type TaskDrawerHeaderProps = {
|
||||||
inputRef: React.RefObject<InputRef | null>;
|
inputRef: React.RefObject<InputRef | null>;
|
||||||
t: TFunction;
|
t: TFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Utility function to truncate text
|
||||||
|
const truncateText = (text: string, maxLength: number = 50): string => {
|
||||||
|
if (!text || text.length <= maxLength) return text;
|
||||||
|
return `${text.substring(0, maxLength)}...`;
|
||||||
|
};
|
||||||
|
|
||||||
const TaskDrawerHeader = ({ inputRef, t }: TaskDrawerHeaderProps) => {
|
const TaskDrawerHeader = ({ inputRef, t }: TaskDrawerHeaderProps) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { socket, connected } = useSocket();
|
const { socket, connected } = useSocket();
|
||||||
@@ -38,6 +45,9 @@ const TaskDrawerHeader = ({ inputRef, t }: TaskDrawerHeaderProps) => {
|
|||||||
const [taskName, setTaskName] = useState<string>(taskFormViewModel?.task?.name ?? '');
|
const [taskName, setTaskName] = useState<string>(taskFormViewModel?.task?.name ?? '');
|
||||||
const currentSession = useAuthService().getCurrentSession();
|
const currentSession = useAuthService().getCurrentSession();
|
||||||
|
|
||||||
|
// Check if current task is a sub-task
|
||||||
|
const isSubTask = taskFormViewModel?.task?.is_sub_task || !!taskFormViewModel?.task?.parent_task_id;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTaskName(taskFormViewModel?.task?.name ?? '');
|
setTaskName(taskFormViewModel?.task?.name ?? '');
|
||||||
}, [taskFormViewModel?.task?.name]);
|
}, [taskFormViewModel?.task?.name]);
|
||||||
@@ -126,9 +136,17 @@ const TaskDrawerHeader = ({ inputRef, t }: TaskDrawerHeaderProps) => {
|
|||||||
// No need for local socket listeners that could interfere with global handlers
|
// No need for local socket listeners that could interfere with global handlers
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const displayTaskName = taskName || t('taskHeader.taskNamePlaceholder');
|
||||||
|
const truncatedTaskName = truncateText(displayTaskName, 50);
|
||||||
|
const shouldShowTooltip = displayTaskName.length > 50;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex gap={12} align="center" style={{ marginBlockEnd: 6 }}>
|
<div>
|
||||||
<Flex style={{ position: 'relative', width: '100%' }}>
|
{/* Show breadcrumb for sub-tasks */}
|
||||||
|
{isSubTask && <TaskHierarchyBreadcrumb t={t} />}
|
||||||
|
|
||||||
|
<Flex gap={8} align="center" style={{ marginBlockEnd: 2 }}>
|
||||||
|
<Flex style={{ position: 'relative', width: '100%', alignItems: 'center' }}>
|
||||||
{isEditing ? (
|
{isEditing ? (
|
||||||
<Input
|
<Input
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
@@ -147,20 +165,14 @@ const TaskDrawerHeader = ({ inputRef, t }: TaskDrawerHeaderProps) => {
|
|||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
|
<Tooltip title={shouldShowTooltip ? displayTaskName : ''} trigger="hover">
|
||||||
<p
|
<p
|
||||||
onClick={() => setIsEditing(true)}
|
onClick={() => setIsEditing(true)}
|
||||||
style={{
|
className="task-name-display"
|
||||||
margin: 0,
|
|
||||||
padding: '4px 11px',
|
|
||||||
fontSize: '16px',
|
|
||||||
cursor: 'pointer',
|
|
||||||
wordWrap: 'break-word',
|
|
||||||
overflowWrap: 'break-word',
|
|
||||||
width: '100%',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{taskName || t('taskHeader.taskNamePlaceholder')}
|
{truncatedTaskName}
|
||||||
</p>
|
</p>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
@@ -174,6 +186,7 @@ const TaskDrawerHeader = ({ inputRef, t }: TaskDrawerHeaderProps) => {
|
|||||||
<Button type="text" icon={<EllipsisOutlined />} />
|
<Button type="text" icon={<EllipsisOutlined />} />
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Drawer from 'antd/es/drawer';
|
|||||||
import { InputRef } from 'antd/es/input';
|
import { InputRef } from 'antd/es/input';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined, CloseOutlined, ArrowLeftOutlined } from '@ant-design/icons';
|
||||||
|
|
||||||
import { useAppSelector } from '@/hooks/useAppSelector';
|
import { useAppSelector } from '@/hooks/useAppSelector';
|
||||||
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
setTaskFormViewModel,
|
setTaskFormViewModel,
|
||||||
setTaskSubscribers,
|
setTaskSubscribers,
|
||||||
setTimeLogEditing,
|
setTimeLogEditing,
|
||||||
|
fetchTask,
|
||||||
} from '@/features/task-drawer/task-drawer.slice';
|
} from '@/features/task-drawer/task-drawer.slice';
|
||||||
|
|
||||||
import './task-drawer.css';
|
import './task-drawer.css';
|
||||||
@@ -33,6 +34,7 @@ const TaskDrawer = () => {
|
|||||||
|
|
||||||
const { showTaskDrawer, timeLogEditing } = useAppSelector(state => state.taskDrawerReducer);
|
const { showTaskDrawer, timeLogEditing } = useAppSelector(state => state.taskDrawerReducer);
|
||||||
const { taskFormViewModel, selectedTaskId } = useAppSelector(state => state.taskDrawerReducer);
|
const { taskFormViewModel, selectedTaskId } = useAppSelector(state => state.taskDrawerReducer);
|
||||||
|
const { projectId } = useAppSelector(state => state.projectReducer);
|
||||||
const taskNameInputRef = useRef<InputRef>(null);
|
const taskNameInputRef = useRef<InputRef>(null);
|
||||||
const isClosingManually = useRef(false);
|
const isClosingManually = useRef(false);
|
||||||
|
|
||||||
@@ -54,6 +56,17 @@ const TaskDrawer = () => {
|
|||||||
dispatch(setTaskSubscribers([]));
|
dispatch(setTaskSubscribers([]));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleBackToParent = () => {
|
||||||
|
if (taskFormViewModel?.task?.parent_task_id && projectId) {
|
||||||
|
// Navigate to parent task
|
||||||
|
dispatch(setSelectedTaskId(taskFormViewModel.task.parent_task_id));
|
||||||
|
dispatch(fetchTask({
|
||||||
|
taskId: taskFormViewModel.task.parent_task_id,
|
||||||
|
projectId
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleOnClose = (
|
const handleOnClose = (
|
||||||
e?: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>
|
e?: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>
|
||||||
) => {
|
) => {
|
||||||
@@ -68,10 +81,8 @@ const TaskDrawer = () => {
|
|||||||
if (isClickOutsideDrawer || !taskFormViewModel?.task?.is_sub_task) {
|
if (isClickOutsideDrawer || !taskFormViewModel?.task?.is_sub_task) {
|
||||||
resetTaskState();
|
resetTaskState();
|
||||||
} else {
|
} else {
|
||||||
dispatch(setSelectedTaskId(null));
|
// For sub-tasks, navigate to parent instead of closing
|
||||||
dispatch(setTaskFormViewModel({}));
|
handleBackToParent();
|
||||||
dispatch(setTaskSubscribers([]));
|
|
||||||
dispatch(setSelectedTaskId(taskFormViewModel?.task?.parent_task_id || null));
|
|
||||||
}
|
}
|
||||||
// Reset the flag after a short delay
|
// Reset the flag after a short delay
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -205,6 +216,17 @@ const TaskDrawer = () => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Check if current task is a sub-task
|
||||||
|
const isSubTask = taskFormViewModel?.task?.is_sub_task || !!taskFormViewModel?.task?.parent_task_id;
|
||||||
|
|
||||||
|
// Custom close icon based on whether it's a sub-task
|
||||||
|
const getCloseIcon = () => {
|
||||||
|
if (isSubTask) {
|
||||||
|
return <ArrowLeftOutlined />;
|
||||||
|
}
|
||||||
|
return <CloseOutlined />;
|
||||||
|
};
|
||||||
|
|
||||||
const drawerProps = {
|
const drawerProps = {
|
||||||
open: showTaskDrawer,
|
open: showTaskDrawer,
|
||||||
onClose: handleOnClose,
|
onClose: handleOnClose,
|
||||||
@@ -215,6 +237,7 @@ const TaskDrawer = () => {
|
|||||||
footer: renderFooter(),
|
footer: renderFooter(),
|
||||||
bodyStyle: getBodyStyle(),
|
bodyStyle: getBodyStyle(),
|
||||||
footerStyle: getFooterStyle(),
|
footerStyle: getFooterStyle(),
|
||||||
|
closeIcon: getCloseIcon(),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
.task-hierarchy-breadcrumb {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-hierarchy-breadcrumb .ant-breadcrumb {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-hierarchy-breadcrumb .ant-breadcrumb-link {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-hierarchy-breadcrumb .ant-breadcrumb-separator {
|
||||||
|
color: #8c8c8c;
|
||||||
|
margin: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dark mode styles */
|
||||||
|
[data-theme='dark'] .task-hierarchy-breadcrumb .ant-breadcrumb-separator {
|
||||||
|
color: #595959;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Back button styles */
|
||||||
|
.task-hierarchy-breadcrumb .ant-btn-link {
|
||||||
|
padding: 0;
|
||||||
|
height: auto;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.3;
|
||||||
|
max-width: 200px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-hierarchy-breadcrumb .ant-btn-link .anticon {
|
||||||
|
margin-right: 0; /* Remove default margin */
|
||||||
|
}
|
||||||
|
|
||||||
|
.task-hierarchy-breadcrumb .ant-btn-link:hover {
|
||||||
|
color: #40a9ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='dark'] .task-hierarchy-breadcrumb .ant-btn-link:hover {
|
||||||
|
color: #40a9ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Current task name styles */
|
||||||
|
.task-hierarchy-breadcrumb .current-task-name {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #000000d9;
|
||||||
|
font-weight: 500;
|
||||||
|
max-width: 200px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
display: inline-block;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-theme='dark'] .task-hierarchy-breadcrumb .current-task-name {
|
||||||
|
color: #ffffffd9;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Breadcrumb item container */
|
||||||
|
.task-hierarchy-breadcrumb .ant-breadcrumb-item {
|
||||||
|
max-width: 220px;
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure breadcrumb items don't break the layout */
|
||||||
|
.task-hierarchy-breadcrumb .ant-breadcrumb ol {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Better alignment for breadcrumb items */
|
||||||
|
.task-hierarchy-breadcrumb .ant-breadcrumb-item .ant-breadcrumb-link {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
@@ -0,0 +1,189 @@
|
|||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { Breadcrumb, Button, Typography, Tooltip } from 'antd';
|
||||||
|
import { HomeOutlined } from '@ant-design/icons';
|
||||||
|
import { useAppSelector } from '@/hooks/useAppSelector';
|
||||||
|
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||||
|
import { fetchTask, setSelectedTaskId } from '@/features/task-drawer/task-drawer.slice';
|
||||||
|
import { tasksApiService } from '@/api/tasks/tasks.api.service';
|
||||||
|
import { TFunction } from 'i18next';
|
||||||
|
import './task-hierarchy-breadcrumb.css';
|
||||||
|
|
||||||
|
interface TaskHierarchyBreadcrumbProps {
|
||||||
|
t: TFunction;
|
||||||
|
onBackClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TaskHierarchyItem {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
parent_task_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility function to truncate text
|
||||||
|
const truncateText = (text: string, maxLength: number = 25): string => {
|
||||||
|
if (!text || text.length <= maxLength) return text;
|
||||||
|
return `${text.substring(0, maxLength)}...`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const TaskHierarchyBreadcrumb: React.FC<TaskHierarchyBreadcrumbProps> = ({ t, onBackClick }) => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const { taskFormViewModel } = useAppSelector(state => state.taskDrawerReducer);
|
||||||
|
const { projectId } = useAppSelector(state => state.projectReducer);
|
||||||
|
const themeMode = useAppSelector(state => state.themeReducer.mode);
|
||||||
|
const [hierarchyPath, setHierarchyPath] = useState<TaskHierarchyItem[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const task = taskFormViewModel?.task;
|
||||||
|
const isSubTask = task?.is_sub_task || !!task?.parent_task_id;
|
||||||
|
|
||||||
|
// Recursively fetch the complete hierarchy path
|
||||||
|
const fetchHierarchyPath = async (currentTaskId: string): Promise<TaskHierarchyItem[]> => {
|
||||||
|
if (!projectId) return [];
|
||||||
|
|
||||||
|
const path: TaskHierarchyItem[] = [];
|
||||||
|
let taskId = currentTaskId;
|
||||||
|
|
||||||
|
// Traverse up the hierarchy until we reach the root
|
||||||
|
while (taskId) {
|
||||||
|
try {
|
||||||
|
const response = await tasksApiService.getFormViewModel(taskId, projectId);
|
||||||
|
if (response.done && response.body.task) {
|
||||||
|
const taskData = response.body.task;
|
||||||
|
path.unshift({
|
||||||
|
id: taskData.id,
|
||||||
|
name: taskData.name || '',
|
||||||
|
parent_task_id: taskData.parent_task_id || undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
// Move to parent task
|
||||||
|
taskId = taskData.parent_task_id || '';
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching task in hierarchy:', error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fetch the complete hierarchy when component mounts or task changes
|
||||||
|
useEffect(() => {
|
||||||
|
const loadHierarchy = async () => {
|
||||||
|
if (!isSubTask || !task?.parent_task_id || !projectId) {
|
||||||
|
setHierarchyPath([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const path = await fetchHierarchyPath(task.parent_task_id);
|
||||||
|
setHierarchyPath(path);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error loading task hierarchy:', error);
|
||||||
|
setHierarchyPath([]);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
loadHierarchy();
|
||||||
|
}, [task?.parent_task_id, projectId, isSubTask]);
|
||||||
|
|
||||||
|
const handleNavigateToTask = (taskId: string) => {
|
||||||
|
if (projectId) {
|
||||||
|
if (onBackClick) {
|
||||||
|
onBackClick();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigate to the selected task
|
||||||
|
dispatch(setSelectedTaskId(taskId));
|
||||||
|
dispatch(fetchTask({ taskId, projectId }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!isSubTask || hierarchyPath.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create breadcrumb items from the hierarchy path
|
||||||
|
const breadcrumbItems = [
|
||||||
|
// Add all parent tasks in the hierarchy
|
||||||
|
...hierarchyPath.map((hierarchyTask, index) => {
|
||||||
|
const truncatedName = truncateText(hierarchyTask.name, 25);
|
||||||
|
const shouldShowTooltip = hierarchyTask.name.length > 25;
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: (
|
||||||
|
<Tooltip title={shouldShowTooltip ? hierarchyTask.name : ''} trigger="hover">
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
icon={index === 0 ? <HomeOutlined /> : undefined}
|
||||||
|
onClick={() => handleNavigateToTask(hierarchyTask.id)}
|
||||||
|
style={{
|
||||||
|
padding: 0,
|
||||||
|
height: 'auto',
|
||||||
|
color: themeMode === 'dark' ? '#1890ff' : '#1890ff',
|
||||||
|
fontSize: '14px',
|
||||||
|
marginRight: '0px',
|
||||||
|
maxWidth: '200px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: index === 0 ? '6px' : '0px', // Add gap between icon and text for root task
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{truncatedName}
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
// Add the current task as the last item (non-clickable)
|
||||||
|
{
|
||||||
|
title: (() => {
|
||||||
|
const currentTaskName = task?.name || t('taskHeader.currentTask', 'Current Task');
|
||||||
|
const truncatedCurrentName = truncateText(currentTaskName, 25);
|
||||||
|
const shouldShowCurrentTooltip = currentTaskName.length > 25;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip title={shouldShowCurrentTooltip ? currentTaskName : ''} trigger="hover">
|
||||||
|
<Typography.Text
|
||||||
|
className="current-task-name"
|
||||||
|
style={{
|
||||||
|
color: themeMode === 'dark' ? '#ffffffd9' : '#000000d9',
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: 500,
|
||||||
|
maxWidth: '200px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
display: 'inline-block',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{truncatedCurrentName}
|
||||||
|
</Typography.Text>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="task-hierarchy-breadcrumb">
|
||||||
|
{loading ? (
|
||||||
|
<Typography.Text style={{ color: themeMode === 'dark' ? '#ffffffd9' : '#000000d9' }}>
|
||||||
|
{t('taskHeader.loadingHierarchy', 'Loading hierarchy...')}
|
||||||
|
</Typography.Text>
|
||||||
|
) : (
|
||||||
|
<Breadcrumb items={breadcrumbItems} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TaskHierarchyBreadcrumb;
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
KeyboardSensor,
|
KeyboardSensor,
|
||||||
TouchSensor,
|
TouchSensor,
|
||||||
closestCenter,
|
closestCenter,
|
||||||
|
useDroppable,
|
||||||
} from '@dnd-kit/core';
|
} from '@dnd-kit/core';
|
||||||
import {
|
import {
|
||||||
SortableContext,
|
SortableContext,
|
||||||
@@ -67,6 +68,101 @@ import { AddCustomColumnButton, CustomColumnHeader } from './components/CustomCo
|
|||||||
import TaskListSkeleton from './components/TaskListSkeleton';
|
import TaskListSkeleton from './components/TaskListSkeleton';
|
||||||
import ConvertToSubtaskDrawer from '@/components/task-list-common/convert-to-subtask-drawer/convert-to-subtask-drawer';
|
import ConvertToSubtaskDrawer from '@/components/task-list-common/convert-to-subtask-drawer/convert-to-subtask-drawer';
|
||||||
|
|
||||||
|
// Empty Group Drop Zone Component
|
||||||
|
const EmptyGroupDropZone: React.FC<{
|
||||||
|
groupId: string;
|
||||||
|
visibleColumns: any[];
|
||||||
|
t: (key: string) => string;
|
||||||
|
}> = ({ groupId, visibleColumns, t }) => {
|
||||||
|
const { setNodeRef, isOver, active } = useDroppable({
|
||||||
|
id: `empty-group-${groupId}`,
|
||||||
|
data: {
|
||||||
|
type: 'group',
|
||||||
|
groupId: groupId,
|
||||||
|
isEmpty: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={setNodeRef}
|
||||||
|
className={`relative w-full transition-colors duration-200 ${
|
||||||
|
isOver && active ? 'bg-blue-50 dark:bg-blue-900/20' : ''
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div className="flex items-center min-w-max px-1 py-6">
|
||||||
|
{visibleColumns.map((column, index) => {
|
||||||
|
const emptyColumnStyle = {
|
||||||
|
width: column.width,
|
||||||
|
flexShrink: 0,
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`empty-${column.id}`}
|
||||||
|
className="border-r border-gray-200 dark:border-gray-700"
|
||||||
|
style={emptyColumnStyle}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<div className="absolute left-4 top-1/2 transform -translate-y-1/2 flex items-center">
|
||||||
|
<div
|
||||||
|
className={`text-sm px-4 py-3 rounded-md border shadow-sm transition-colors duration-200 ${
|
||||||
|
isOver && active
|
||||||
|
? 'text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30 border-blue-300 dark:border-blue-600'
|
||||||
|
: 'text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{isOver && active ? t('dropTaskHere') || 'Drop task here' : t('noTasksInGroup')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{isOver && active && (
|
||||||
|
<div className="absolute inset-0 border-2 border-dashed border-blue-400 dark:border-blue-500 rounded-md pointer-events-none" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Placeholder Drop Indicator Component
|
||||||
|
const PlaceholderDropIndicator: React.FC<{
|
||||||
|
isVisible: boolean;
|
||||||
|
visibleColumns: any[];
|
||||||
|
}> = ({ isVisible, visibleColumns }) => {
|
||||||
|
if (!isVisible) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="flex items-center min-w-max px-1 border-2 border-dashed border-blue-400 dark:border-blue-500 bg-blue-50 dark:bg-blue-900/20 rounded-md mx-1 my-1 transition-all duration-200 ease-in-out"
|
||||||
|
style={{ minWidth: 'max-content', height: '40px' }}
|
||||||
|
>
|
||||||
|
{visibleColumns.map((column, index) => {
|
||||||
|
const columnStyle = {
|
||||||
|
width: column.width,
|
||||||
|
flexShrink: 0,
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`placeholder-${column.id}`}
|
||||||
|
className="flex items-center justify-center h-full"
|
||||||
|
style={columnStyle}
|
||||||
|
>
|
||||||
|
{/* Show "Drop task here" message in the title column */}
|
||||||
|
{column.id === 'title' && (
|
||||||
|
<div className="text-xs text-blue-600 dark:text-blue-400 font-medium opacity-75">
|
||||||
|
Drop task here
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{/* Show subtle placeholder content in other columns */}
|
||||||
|
{column.id !== 'title' && column.id !== 'dragHandle' && (
|
||||||
|
<div className="w-full h-4 mx-1 bg-white dark:bg-gray-700 rounded opacity-50" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
// Hooks and utilities
|
// Hooks and utilities
|
||||||
import { useTaskSocketHandlers } from '@/hooks/useTaskSocketHandlers';
|
import { useTaskSocketHandlers } from '@/hooks/useTaskSocketHandlers';
|
||||||
import { useSocket } from '@/socket/socketContext';
|
import { useSocket } from '@/socket/socketContext';
|
||||||
@@ -127,7 +223,7 @@ const TaskListV2Section: React.FC = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Custom hooks
|
// Custom hooks
|
||||||
const { activeId, handleDragStart, handleDragOver, handleDragEnd } = useDragAndDrop(
|
const { activeId, overId, handleDragStart, handleDragOver, handleDragEnd } = useDragAndDrop(
|
||||||
allTasks,
|
allTasks,
|
||||||
groups
|
groups
|
||||||
);
|
);
|
||||||
@@ -465,31 +561,11 @@ const TaskListV2Section: React.FC = () => {
|
|||||||
projectId={urlProjectId || ''}
|
projectId={urlProjectId || ''}
|
||||||
/>
|
/>
|
||||||
{isGroupEmpty && !isGroupCollapsed && (
|
{isGroupEmpty && !isGroupCollapsed && (
|
||||||
<div className="relative w-full">
|
<EmptyGroupDropZone
|
||||||
<div className="flex items-center min-w-max px-1 py-6">
|
groupId={group.id}
|
||||||
{visibleColumns.map((column, index) => {
|
visibleColumns={visibleColumns}
|
||||||
const emptyColumnStyle = {
|
t={t}
|
||||||
width: column.width,
|
|
||||||
flexShrink: 0,
|
|
||||||
...(column.id === 'labels' && column.width === 'auto'
|
|
||||||
? { minWidth: '200px', flexGrow: 1 }
|
|
||||||
: {}),
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={`empty-${column.id}`}
|
|
||||||
className="border-r border-gray-200 dark:border-gray-700"
|
|
||||||
style={emptyColumnStyle}
|
|
||||||
/>
|
/>
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
<div className="absolute left-4 top-1/2 transform -translate-y-1/2 flex items-center">
|
|
||||||
<div className="text-sm text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-900 px-4 py-3 rounded-md border border-gray-200 dark:border-gray-700 shadow-sm">
|
|
||||||
{t('noTasksInGroup')}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -546,12 +622,6 @@ const TaskListV2Section: React.FC = () => {
|
|||||||
const columnStyle: ColumnStyle = {
|
const columnStyle: ColumnStyle = {
|
||||||
width: column.width,
|
width: column.width,
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
...(column.id === 'labels' && column.width === 'auto'
|
|
||||||
? {
|
|
||||||
minWidth: '200px',
|
|
||||||
flexGrow: 1,
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
...((column as any).minWidth && { minWidth: (column as any).minWidth }),
|
...((column as any).minWidth && { minWidth: (column as any).minWidth }),
|
||||||
...((column as any).maxWidth && { maxWidth: (column as any).maxWidth }),
|
...((column as any).maxWidth && { maxWidth: (column as any).maxWidth }),
|
||||||
};
|
};
|
||||||
@@ -687,7 +757,8 @@ const TaskListV2Section: React.FC = () => {
|
|||||||
{renderGroup(groupIndex)}
|
{renderGroup(groupIndex)}
|
||||||
|
|
||||||
{/* Group Tasks */}
|
{/* Group Tasks */}
|
||||||
{!collapsedGroups.has(group.id) &&
|
{!collapsedGroups.has(group.id) && (
|
||||||
|
group.tasks.length > 0 ? (
|
||||||
group.tasks.map((task, taskIndex) => {
|
group.tasks.map((task, taskIndex) => {
|
||||||
const globalTaskIndex =
|
const globalTaskIndex =
|
||||||
virtuosoGroups.slice(0, groupIndex).reduce((sum, g) => sum + g.count, 0) +
|
virtuosoGroups.slice(0, groupIndex).reduce((sum, g) => sum + g.count, 0) +
|
||||||
@@ -696,12 +767,41 @@ const TaskListV2Section: React.FC = () => {
|
|||||||
// Check if this is the first actual task in the group (not AddTaskRow)
|
// Check if this is the first actual task in the group (not AddTaskRow)
|
||||||
const isFirstTaskInGroup = taskIndex === 0 && !('isAddTaskRow' in task);
|
const isFirstTaskInGroup = taskIndex === 0 && !('isAddTaskRow' in task);
|
||||||
|
|
||||||
|
// Check if we should show drop indicators
|
||||||
|
const isTaskBeingDraggedOver = overId === task.id;
|
||||||
|
const isGroupBeingDraggedOver = overId === group.id;
|
||||||
|
const isFirstTaskInGroupBeingDraggedOver = isFirstTaskInGroup && isTaskBeingDraggedOver;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={task.id || `add-task-${group.id}-${taskIndex}`}>
|
<div key={task.id || `add-task-${group.id}-${taskIndex}`}>
|
||||||
|
{/* Placeholder drop indicator before first task in group */}
|
||||||
|
{isFirstTaskInGroupBeingDraggedOver && (
|
||||||
|
<PlaceholderDropIndicator isVisible={true} visibleColumns={visibleColumns} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Placeholder drop indicator between tasks */}
|
||||||
|
{isTaskBeingDraggedOver && !isFirstTaskInGroup && (
|
||||||
|
<PlaceholderDropIndicator isVisible={true} visibleColumns={visibleColumns} />
|
||||||
|
)}
|
||||||
|
|
||||||
{renderTask(globalTaskIndex, isFirstTaskInGroup)}
|
{renderTask(globalTaskIndex, isFirstTaskInGroup)}
|
||||||
|
|
||||||
|
{/* Placeholder drop indicator at end of group when dragging over group */}
|
||||||
|
{isGroupBeingDraggedOver && taskIndex === group.tasks.length - 1 && (
|
||||||
|
<PlaceholderDropIndicator isVisible={true} visibleColumns={visibleColumns} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})
|
||||||
|
) : (
|
||||||
|
// Handle empty groups with placeholder drop indicator
|
||||||
|
overId === group.id && (
|
||||||
|
<div style={{ minWidth: 'max-content' }}>
|
||||||
|
<PlaceholderDropIndicator isVisible={true} visibleColumns={visibleColumns} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -710,12 +810,12 @@ const TaskListV2Section: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Drag Overlay */}
|
{/* Drag Overlay */}
|
||||||
<DragOverlay dropAnimation={null}>
|
<DragOverlay dropAnimation={{ duration: 200, easing: 'ease-in-out' }}>
|
||||||
{activeId ? (
|
{activeId ? (
|
||||||
<div className="bg-white dark:bg-gray-800 shadow-xl rounded-md border-2 border-blue-400 opacity-95">
|
<div className="bg-white dark:bg-gray-800 shadow-2xl rounded-lg border-2 border-blue-500 dark:border-blue-400 scale-105">
|
||||||
<div className="px-4 py-3">
|
<div className="px-4 py-3">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<HolderOutlined className="text-blue-500" />
|
<HolderOutlined className="text-blue-500 dark:text-blue-400" />
|
||||||
<div>
|
<div>
|
||||||
<div className="text-sm font-medium text-gray-900 dark:text-white">
|
<div className="text-sm font-medium text-gray-900 dark:text-white">
|
||||||
{allTasks.find(task => task.id === activeId)?.name ||
|
{allTasks.find(task => task.id === activeId)?.name ||
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ interface TaskRowProps {
|
|||||||
isSubtask?: boolean;
|
isSubtask?: boolean;
|
||||||
isFirstInGroup?: boolean;
|
isFirstInGroup?: boolean;
|
||||||
updateTaskCustomColumnValue?: (taskId: string, columnKey: string, value: string) => void;
|
updateTaskCustomColumnValue?: (taskId: string, columnKey: string, value: string) => void;
|
||||||
|
depth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TaskRow: React.FC<TaskRowProps> = memo(({
|
const TaskRow: React.FC<TaskRowProps> = memo(({
|
||||||
@@ -32,7 +33,8 @@ const TaskRow: React.FC<TaskRowProps> = memo(({
|
|||||||
visibleColumns,
|
visibleColumns,
|
||||||
isSubtask = false,
|
isSubtask = false,
|
||||||
isFirstInGroup = false,
|
isFirstInGroup = false,
|
||||||
updateTaskCustomColumnValue
|
updateTaskCustomColumnValue,
|
||||||
|
depth = 0
|
||||||
}) => {
|
}) => {
|
||||||
// Get task data and selection state from Redux
|
// Get task data and selection state from Redux
|
||||||
const task = useAppSelector(state => selectTaskById(state, taskId));
|
const task = useAppSelector(state => selectTaskById(state, taskId));
|
||||||
@@ -107,13 +109,14 @@ const TaskRow: React.FC<TaskRowProps> = memo(({
|
|||||||
handleTaskNameEdit,
|
handleTaskNameEdit,
|
||||||
attributes,
|
attributes,
|
||||||
listeners,
|
listeners,
|
||||||
|
depth,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Memoize style object to prevent unnecessary re-renders
|
// Memoize style object to prevent unnecessary re-renders
|
||||||
const style = useMemo(() => ({
|
const style = useMemo(() => ({
|
||||||
transform: CSS.Transform.toString(transform),
|
transform: CSS.Transform.toString(transform),
|
||||||
transition,
|
transition,
|
||||||
opacity: isDragging ? 0.5 : 1,
|
opacity: isDragging ? 0 : 1, // Completely hide the original task while dragging
|
||||||
}), [transform, transition, isDragging]);
|
}), [transform, transition, isDragging]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ interface TaskRowWithSubtasksProps {
|
|||||||
}>;
|
}>;
|
||||||
isFirstInGroup?: boolean;
|
isFirstInGroup?: boolean;
|
||||||
updateTaskCustomColumnValue?: (taskId: string, columnKey: string, value: string) => void;
|
updateTaskCustomColumnValue?: (taskId: string, columnKey: string, value: string) => void;
|
||||||
|
depth?: number; // Add depth prop to track nesting level
|
||||||
|
maxDepth?: number; // Add maxDepth prop to limit nesting
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AddSubtaskRowProps {
|
interface AddSubtaskRowProps {
|
||||||
@@ -32,11 +34,12 @@ interface AddSubtaskRowProps {
|
|||||||
width: string;
|
width: string;
|
||||||
isSticky?: boolean;
|
isSticky?: boolean;
|
||||||
}>;
|
}>;
|
||||||
onSubtaskAdded: () => void; // Simplified - no rowId needed
|
onSubtaskAdded: () => void;
|
||||||
rowId: string; // Unique identifier for this add subtask row
|
rowId: string;
|
||||||
autoFocus?: boolean; // Whether this row should auto-focus on mount
|
autoFocus?: boolean;
|
||||||
isActive?: boolean; // Whether this row should show the input/button
|
isActive?: boolean;
|
||||||
onActivate?: () => void; // Simplified - no rowId needed
|
onActivate?: () => void;
|
||||||
|
depth?: number; // Add depth prop for proper indentation
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddSubtaskRow: React.FC<AddSubtaskRowProps> = memo(({
|
const AddSubtaskRow: React.FC<AddSubtaskRowProps> = memo(({
|
||||||
@@ -47,25 +50,20 @@ const AddSubtaskRow: React.FC<AddSubtaskRowProps> = memo(({
|
|||||||
rowId,
|
rowId,
|
||||||
autoFocus = false,
|
autoFocus = false,
|
||||||
isActive = true,
|
isActive = true,
|
||||||
onActivate
|
onActivate,
|
||||||
|
depth = 0
|
||||||
}) => {
|
}) => {
|
||||||
const [isAdding, setIsAdding] = useState(autoFocus);
|
const { t } = useTranslation('task-list-table');
|
||||||
|
const [isAdding, setIsAdding] = useState(false);
|
||||||
const [subtaskName, setSubtaskName] = useState('');
|
const [subtaskName, setSubtaskName] = useState('');
|
||||||
const inputRef = useRef<any>(null);
|
const inputRef = useRef<any>(null);
|
||||||
const { socket, connected } = useSocket();
|
|
||||||
const { t } = useTranslation('task-list-table');
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const { socket, connected } = useSocket();
|
||||||
// Get session data for reporter_id and team_id
|
|
||||||
const currentSession = useAuthService().getCurrentSession();
|
const currentSession = useAuthService().getCurrentSession();
|
||||||
|
|
||||||
// Auto-focus when autoFocus prop is true
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (autoFocus && inputRef.current) {
|
if (autoFocus && inputRef.current) {
|
||||||
setIsAdding(true);
|
inputRef.current.focus();
|
||||||
setTimeout(() => {
|
|
||||||
inputRef.current?.focus();
|
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
@@ -141,9 +139,13 @@ const AddSubtaskRow: React.FC<AddSubtaskRowProps> = memo(({
|
|||||||
return (
|
return (
|
||||||
<div className="flex items-center h-full" style={baseStyle}>
|
<div className="flex items-center h-full" style={baseStyle}>
|
||||||
<div className="flex items-center w-full h-full">
|
<div className="flex items-center w-full h-full">
|
||||||
{/* Match subtask indentation pattern - tighter spacing */}
|
{/* Match subtask indentation pattern - reduced spacing for level 1 */}
|
||||||
<div className="w-4" />
|
|
||||||
<div className="w-2" />
|
<div className="w-2" />
|
||||||
|
{/* Add additional indentation for deeper levels - increased spacing for level 2+ */}
|
||||||
|
{Array.from({ length: depth }).map((_, i) => (
|
||||||
|
<div key={i} className="w-6" />
|
||||||
|
))}
|
||||||
|
<div className="w-1" />
|
||||||
|
|
||||||
{isActive ? (
|
{isActive ? (
|
||||||
!isAdding ? (
|
!isAdding ? (
|
||||||
@@ -188,7 +190,7 @@ const AddSubtaskRow: React.FC<AddSubtaskRowProps> = memo(({
|
|||||||
default:
|
default:
|
||||||
return <div style={baseStyle} />;
|
return <div style={baseStyle} />;
|
||||||
}
|
}
|
||||||
}, [isAdding, subtaskName, handleAddSubtask, handleCancel, handleBlur, handleKeyDown, t, isActive, onActivate]);
|
}, [isAdding, subtaskName, handleAddSubtask, handleCancel, handleBlur, handleKeyDown, t, isActive, onActivate, depth]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center min-w-max px-1 py-0.5 hover:bg-gray-50 dark:hover:bg-gray-800 min-h-[36px] border-b border-gray-200 dark:border-gray-700">
|
<div className="flex items-center min-w-max px-1 py-0.5 hover:bg-gray-50 dark:hover:bg-gray-800 min-h-[36px] border-b border-gray-200 dark:border-gray-700">
|
||||||
@@ -203,12 +205,42 @@ const AddSubtaskRow: React.FC<AddSubtaskRowProps> = memo(({
|
|||||||
|
|
||||||
AddSubtaskRow.displayName = 'AddSubtaskRow';
|
AddSubtaskRow.displayName = 'AddSubtaskRow';
|
||||||
|
|
||||||
|
// Helper function to get background color based on depth
|
||||||
|
const getSubtaskBackgroundColor = (depth: number) => {
|
||||||
|
switch (depth) {
|
||||||
|
case 1:
|
||||||
|
return 'bg-gray-50 dark:bg-gray-800/50';
|
||||||
|
case 2:
|
||||||
|
return 'bg-blue-50 dark:bg-blue-900/20';
|
||||||
|
case 3:
|
||||||
|
return 'bg-green-50 dark:bg-green-900/20';
|
||||||
|
default:
|
||||||
|
return 'bg-gray-50 dark:bg-gray-800/50';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper function to get border color based on depth
|
||||||
|
const getBorderColor = (depth: number) => {
|
||||||
|
switch (depth) {
|
||||||
|
case 1:
|
||||||
|
return 'border-blue-200 dark:border-blue-700';
|
||||||
|
case 2:
|
||||||
|
return 'border-green-200 dark:border-green-700';
|
||||||
|
case 3:
|
||||||
|
return 'border-purple-200 dark:border-purple-700';
|
||||||
|
default:
|
||||||
|
return 'border-blue-200 dark:border-blue-700';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const TaskRowWithSubtasks: React.FC<TaskRowWithSubtasksProps> = memo(({
|
const TaskRowWithSubtasks: React.FC<TaskRowWithSubtasksProps> = memo(({
|
||||||
taskId,
|
taskId,
|
||||||
projectId,
|
projectId,
|
||||||
visibleColumns,
|
visibleColumns,
|
||||||
isFirstInGroup = false,
|
isFirstInGroup = false,
|
||||||
updateTaskCustomColumnValue
|
updateTaskCustomColumnValue,
|
||||||
|
depth = 0,
|
||||||
|
maxDepth = 3
|
||||||
}) => {
|
}) => {
|
||||||
const task = useAppSelector(state => selectTaskById(state, taskId));
|
const task = useAppSelector(state => selectTaskById(state, taskId));
|
||||||
const isLoadingSubtasks = useAppSelector(state => selectSubtaskLoading(state, taskId));
|
const isLoadingSubtasks = useAppSelector(state => selectSubtaskLoading(state, taskId));
|
||||||
@@ -223,6 +255,9 @@ const TaskRowWithSubtasks: React.FC<TaskRowWithSubtasksProps> = memo(({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't render subtasks if we've reached the maximum depth
|
||||||
|
const canHaveSubtasks = depth < maxDepth;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Main task row */}
|
{/* Main task row */}
|
||||||
@@ -232,10 +267,12 @@ const TaskRowWithSubtasks: React.FC<TaskRowWithSubtasksProps> = memo(({
|
|||||||
visibleColumns={visibleColumns}
|
visibleColumns={visibleColumns}
|
||||||
isFirstInGroup={isFirstInGroup}
|
isFirstInGroup={isFirstInGroup}
|
||||||
updateTaskCustomColumnValue={updateTaskCustomColumnValue}
|
updateTaskCustomColumnValue={updateTaskCustomColumnValue}
|
||||||
|
isSubtask={depth > 0}
|
||||||
|
depth={depth}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Subtasks and add subtask row when expanded */}
|
{/* Subtasks and add subtask row when expanded */}
|
||||||
{task.show_sub_tasks && (
|
{canHaveSubtasks && task.show_sub_tasks && (
|
||||||
<>
|
<>
|
||||||
{/* Show loading skeleton while fetching subtasks */}
|
{/* Show loading skeleton while fetching subtasks */}
|
||||||
{isLoadingSubtasks && (
|
{isLoadingSubtasks && (
|
||||||
@@ -244,22 +281,23 @@ const TaskRowWithSubtasks: React.FC<TaskRowWithSubtasksProps> = memo(({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Render existing subtasks when not loading */}
|
{/* Render existing subtasks when not loading - RECURSIVELY */}
|
||||||
{!isLoadingSubtasks && task.sub_tasks?.map((subtask: Task) => (
|
{!isLoadingSubtasks && task.sub_tasks?.map((subtask: Task) => (
|
||||||
<div key={subtask.id} className="bg-gray-50 dark:bg-gray-800/50 border-l-2 border-blue-200 dark:border-blue-700">
|
<div key={subtask.id} className={`${getSubtaskBackgroundColor(depth + 1)} border-l-2 ${getBorderColor(depth + 1)}`}>
|
||||||
<TaskRow
|
<TaskRowWithSubtasks
|
||||||
taskId={subtask.id}
|
taskId={subtask.id}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
visibleColumns={visibleColumns}
|
visibleColumns={visibleColumns}
|
||||||
isSubtask={true}
|
|
||||||
updateTaskCustomColumnValue={updateTaskCustomColumnValue}
|
updateTaskCustomColumnValue={updateTaskCustomColumnValue}
|
||||||
|
depth={depth + 1}
|
||||||
|
maxDepth={maxDepth}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* Add subtask row - only show when not loading */}
|
{/* Add subtask row - only show when not loading */}
|
||||||
{!isLoadingSubtasks && (
|
{!isLoadingSubtasks && (
|
||||||
<div className="bg-gray-50 dark:bg-gray-800/50 border-l-2 border-blue-200 dark:border-blue-700">
|
<div className={`${getSubtaskBackgroundColor(depth + 1)} border-l-2 ${getBorderColor(depth + 1)}`}>
|
||||||
<AddSubtaskRow
|
<AddSubtaskRow
|
||||||
parentTaskId={taskId}
|
parentTaskId={taskId}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
@@ -267,8 +305,9 @@ const TaskRowWithSubtasks: React.FC<TaskRowWithSubtasksProps> = memo(({
|
|||||||
onSubtaskAdded={handleSubtaskAdded}
|
onSubtaskAdded={handleSubtaskAdded}
|
||||||
rowId={`add-subtask-${taskId}`}
|
rowId={`add-subtask-${taskId}`}
|
||||||
autoFocus={false}
|
autoFocus={false}
|
||||||
isActive={true} // Always show the add subtask row
|
isActive={true}
|
||||||
onActivate={undefined} // Not needed anymore
|
onActivate={undefined}
|
||||||
|
depth={depth + 1}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -252,10 +252,9 @@ interface LabelsColumnProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const LabelsColumn: React.FC<LabelsColumnProps> = memo(({ width, task, labelsAdapter, isDarkMode, visibleColumns }) => {
|
export const LabelsColumn: React.FC<LabelsColumnProps> = memo(({ width, task, labelsAdapter, isDarkMode, visibleColumns }) => {
|
||||||
const labelsColumn = visibleColumns.find(col => col.id === 'labels');
|
|
||||||
const labelsStyle = {
|
const labelsStyle = {
|
||||||
width,
|
width,
|
||||||
...(labelsColumn?.width === 'auto' ? { minWidth: '200px', flexGrow: 1 } : {})
|
flexShrink: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ interface TitleColumnProps {
|
|||||||
onEditTaskName: (editing: boolean) => void;
|
onEditTaskName: (editing: boolean) => void;
|
||||||
onTaskNameChange: (name: string) => void;
|
onTaskNameChange: (name: string) => void;
|
||||||
onTaskNameSave: () => void;
|
onTaskNameSave: () => void;
|
||||||
|
depth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TitleColumn: React.FC<TitleColumnProps> = memo(({
|
export const TitleColumn: React.FC<TitleColumnProps> = memo(({
|
||||||
@@ -36,7 +37,8 @@ export const TitleColumn: React.FC<TitleColumnProps> = memo(({
|
|||||||
taskName,
|
taskName,
|
||||||
onEditTaskName,
|
onEditTaskName,
|
||||||
onTaskNameChange,
|
onTaskNameChange,
|
||||||
onTaskNameSave
|
onTaskNameSave,
|
||||||
|
depth = 0
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { socket, connected } = useSocket();
|
const { socket, connected } = useSocket();
|
||||||
@@ -150,11 +152,16 @@ export const TitleColumn: React.FC<TitleColumnProps> = memo(({
|
|||||||
/* Normal layout when not editing */
|
/* Normal layout when not editing */
|
||||||
<>
|
<>
|
||||||
<div className="flex items-center flex-1 min-w-0">
|
<div className="flex items-center flex-1 min-w-0">
|
||||||
{/* Indentation for subtasks - tighter spacing */}
|
{/* Indentation for subtasks - reduced spacing for level 1 */}
|
||||||
{isSubtask && <div className="w-4 flex-shrink-0" />}
|
{isSubtask && <div className="w-2 flex-shrink-0" />}
|
||||||
|
|
||||||
{/* Expand/Collapse button - only show for parent tasks */}
|
{/* Additional indentation for deeper levels - increased spacing for level 2+ */}
|
||||||
{!isSubtask && (
|
{Array.from({ length: depth }).map((_, i) => (
|
||||||
|
<div key={i} className="w-6 flex-shrink-0" />
|
||||||
|
))}
|
||||||
|
|
||||||
|
{/* Expand/Collapse button - show for any task that can have sub-tasks */}
|
||||||
|
{depth < 2 && ( // Only show if not at maximum depth (can still have children)
|
||||||
<button
|
<button
|
||||||
onClick={handleToggleExpansion}
|
onClick={handleToggleExpansion}
|
||||||
className={`flex h-4 w-4 items-center justify-center rounded-sm text-xs mr-1 hover:border hover:border-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 hover:scale-110 transition-all duration-300 ease-out flex-shrink-0 ${
|
className={`flex h-4 w-4 items-center justify-center rounded-sm text-xs mr-1 hover:border hover:border-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20 hover:scale-110 transition-all duration-300 ease-out flex-shrink-0 ${
|
||||||
@@ -175,8 +182,8 @@ export const TitleColumn: React.FC<TitleColumnProps> = memo(({
|
|||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Additional indentation for subtasks after the expand button space */}
|
{/* Additional indentation for subtasks after the expand button space - reduced for level 1 */}
|
||||||
{isSubtask && <div className="w-2 flex-shrink-0" />}
|
{isSubtask && <div className="w-1 flex-shrink-0" />}
|
||||||
|
|
||||||
<div className="flex items-center gap-2 flex-1 min-w-0">
|
<div className="flex items-center gap-2 flex-1 min-w-0">
|
||||||
{/* Task name with dynamic width */}
|
{/* Task name with dynamic width */}
|
||||||
@@ -202,8 +209,8 @@ export const TitleColumn: React.FC<TitleColumnProps> = memo(({
|
|||||||
|
|
||||||
{/* Indicators container - flex-shrink-0 to prevent compression */}
|
{/* Indicators container - flex-shrink-0 to prevent compression */}
|
||||||
<div className="flex items-center gap-1 flex-shrink-0">
|
<div className="flex items-center gap-1 flex-shrink-0">
|
||||||
{/* Subtask count indicator - only show if count > 0 */}
|
{/* Subtask count indicator - show for any task that can have sub-tasks */}
|
||||||
{!isSubtask && task.sub_tasks_count != null && task.sub_tasks_count > 0 && (
|
{depth < 2 && task.sub_tasks_count != null && task.sub_tasks_count > 0 && (
|
||||||
<Tooltip title={t(`indicators.tooltips.subtasks${task.sub_tasks_count === 1 ? '' : '_plural'}`, { count: task.sub_tasks_count })}>
|
<Tooltip title={t(`indicators.tooltips.subtasks${task.sub_tasks_count === 1 ? '' : '_plural'}`, { count: task.sub_tasks_count })}>
|
||||||
<div className="flex items-center gap-1 px-1.5 py-0.5 bg-blue-50 dark:bg-blue-900/20 rounded text-xs">
|
<div className="flex items-center gap-1 px-1.5 py-0.5 bg-blue-50 dark:bg-blue-900/20 rounded text-xs">
|
||||||
<span className="text-blue-600 dark:text-blue-400 font-medium">
|
<span className="text-blue-600 dark:text-blue-400 font-medium">
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ export const BASE_COLUMNS = [
|
|||||||
{ id: 'title', label: 'taskColumn', width: '470px', isSticky: true, key: COLUMN_KEYS.NAME },
|
{ id: 'title', label: 'taskColumn', width: '470px', isSticky: true, key: COLUMN_KEYS.NAME },
|
||||||
{ id: 'description', label: 'descriptionColumn', width: '260px', key: COLUMN_KEYS.DESCRIPTION },
|
{ id: 'description', label: 'descriptionColumn', width: '260px', key: COLUMN_KEYS.DESCRIPTION },
|
||||||
{ id: 'progress', label: 'progressColumn', width: '120px', key: COLUMN_KEYS.PROGRESS },
|
{ id: 'progress', label: 'progressColumn', width: '120px', key: COLUMN_KEYS.PROGRESS },
|
||||||
{ id: 'assignees', label: 'assigneesColumn', width: '150px', key: COLUMN_KEYS.ASSIGNEES },
|
|
||||||
{ id: 'labels', label: 'labelsColumn', width: 'auto', key: COLUMN_KEYS.LABELS },
|
|
||||||
{ id: 'phase', label: 'phaseColumn', width: '120px', key: COLUMN_KEYS.PHASE },
|
|
||||||
{ id: 'status', label: 'statusColumn', width: '120px', key: COLUMN_KEYS.STATUS },
|
{ id: 'status', label: 'statusColumn', width: '120px', key: COLUMN_KEYS.STATUS },
|
||||||
|
{ id: 'assignees', label: 'assigneesColumn', width: '150px', key: COLUMN_KEYS.ASSIGNEES },
|
||||||
|
{ id: 'labels', label: 'labelsColumn', width: '250px', key: COLUMN_KEYS.LABELS },
|
||||||
|
{ id: 'phase', label: 'phaseColumn', width: '120px', key: COLUMN_KEYS.PHASE },
|
||||||
{ id: 'priority', label: 'priorityColumn', width: '120px', key: COLUMN_KEYS.PRIORITY },
|
{ id: 'priority', label: 'priorityColumn', width: '120px', key: COLUMN_KEYS.PRIORITY },
|
||||||
{ id: 'timeTracking', label: 'timeTrackingColumn', width: '120px', key: COLUMN_KEYS.TIME_TRACKING },
|
{ id: 'timeTracking', label: 'timeTrackingColumn', width: '120px', key: COLUMN_KEYS.TIME_TRACKING },
|
||||||
{ id: 'estimation', label: 'estimationColumn', width: '120px', key: COLUMN_KEYS.ESTIMATION },
|
{ id: 'estimation', label: 'estimationColumn', width: '120px', key: COLUMN_KEYS.ESTIMATION },
|
||||||
|
|||||||
@@ -1,12 +1,142 @@
|
|||||||
import { useState, useCallback } from 'react';
|
import { useState, useCallback } from 'react';
|
||||||
import { DragEndEvent, DragOverEvent, DragStartEvent } from '@dnd-kit/core';
|
import { DragEndEvent, DragOverEvent, DragStartEvent } from '@dnd-kit/core';
|
||||||
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||||
import { reorderTasksInGroup, moveTaskBetweenGroups } from '@/features/task-management/task-management.slice';
|
import { useAppSelector } from '@/hooks/useAppSelector';
|
||||||
import { Task, TaskGroup } from '@/types/task-management.types';
|
import { reorderTasksInGroup } from '@/features/task-management/task-management.slice';
|
||||||
|
import { selectCurrentGrouping } from '@/features/task-management/grouping.slice';
|
||||||
|
import { Task, TaskGroup, getSortOrderField } from '@/types/task-management.types';
|
||||||
|
import { useSocket } from '@/socket/socketContext';
|
||||||
|
import { SocketEvents } from '@/shared/socket-events';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
import { useAuthService } from '@/hooks/useAuth';
|
||||||
|
import logger from '@/utils/errorLogger';
|
||||||
|
|
||||||
export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
const { socket, connected } = useSocket();
|
||||||
|
const { projectId } = useParams();
|
||||||
|
const currentGrouping = useAppSelector(selectCurrentGrouping);
|
||||||
|
const currentSession = useAuthService().getCurrentSession();
|
||||||
const [activeId, setActiveId] = useState<string | null>(null);
|
const [activeId, setActiveId] = useState<string | null>(null);
|
||||||
|
const [overId, setOverId] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Helper function to emit socket event for persistence
|
||||||
|
const emitTaskSortChange = useCallback(
|
||||||
|
(taskId: string, sourceGroup: TaskGroup, targetGroup: TaskGroup, insertIndex: number) => {
|
||||||
|
if (!socket || !connected || !projectId) {
|
||||||
|
logger.warning('Socket not connected or missing project ID');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const task = allTasks.find(t => t.id === taskId);
|
||||||
|
if (!task) {
|
||||||
|
logger.error('Task not found for socket emission:', taskId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get team_id from current session
|
||||||
|
const teamId = currentSession?.team_id || '';
|
||||||
|
|
||||||
|
// Use new bulk update approach - recalculate ALL task orders to prevent duplicates
|
||||||
|
const taskUpdates: any[] = [];
|
||||||
|
|
||||||
|
// Create a copy of all groups and perform the move operation
|
||||||
|
const updatedGroups = groups.map(group => ({
|
||||||
|
...group,
|
||||||
|
taskIds: [...group.taskIds]
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Find the source and target groups in our copy
|
||||||
|
const sourceGroupCopy = updatedGroups.find(g => g.id === sourceGroup.id)!;
|
||||||
|
const targetGroupCopy = updatedGroups.find(g => g.id === targetGroup.id)!;
|
||||||
|
|
||||||
|
if (sourceGroup.id === targetGroup.id) {
|
||||||
|
// Same group - reorder within the group
|
||||||
|
const sourceIndex = sourceGroupCopy.taskIds.indexOf(taskId);
|
||||||
|
// Remove task from old position
|
||||||
|
sourceGroupCopy.taskIds.splice(sourceIndex, 1);
|
||||||
|
// Insert at new position
|
||||||
|
sourceGroupCopy.taskIds.splice(insertIndex, 0, taskId);
|
||||||
|
} else {
|
||||||
|
// Different groups - move task between groups
|
||||||
|
// Remove from source group
|
||||||
|
const sourceIndex = sourceGroupCopy.taskIds.indexOf(taskId);
|
||||||
|
sourceGroupCopy.taskIds.splice(sourceIndex, 1);
|
||||||
|
|
||||||
|
// Add to target group
|
||||||
|
targetGroupCopy.taskIds.splice(insertIndex, 0, taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now assign sequential sort orders to ALL tasks across ALL groups
|
||||||
|
let currentSortOrder = 0;
|
||||||
|
updatedGroups.forEach(group => {
|
||||||
|
group.taskIds.forEach(id => {
|
||||||
|
const update: any = {
|
||||||
|
task_id: id,
|
||||||
|
sort_order: currentSortOrder
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add group-specific fields for the moved task if it changed groups
|
||||||
|
if (id === taskId && sourceGroup.id !== targetGroup.id) {
|
||||||
|
if (currentGrouping === 'status') {
|
||||||
|
update.status_id = targetGroup.id;
|
||||||
|
} else if (currentGrouping === 'priority') {
|
||||||
|
update.priority_id = targetGroup.id;
|
||||||
|
} else if (currentGrouping === 'phase') {
|
||||||
|
update.phase_id = targetGroup.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
taskUpdates.push(update);
|
||||||
|
currentSortOrder++;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const socketData = {
|
||||||
|
project_id: projectId,
|
||||||
|
group_by: currentGrouping || 'status',
|
||||||
|
task_updates: taskUpdates,
|
||||||
|
from_group: sourceGroup.id,
|
||||||
|
to_group: targetGroup.id,
|
||||||
|
task: {
|
||||||
|
id: task.id,
|
||||||
|
project_id: projectId,
|
||||||
|
status: task.status || '',
|
||||||
|
priority: task.priority || '',
|
||||||
|
},
|
||||||
|
team_id: teamId,
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.emit(SocketEvents.TASK_SORT_ORDER_CHANGE.toString(), socketData);
|
||||||
|
|
||||||
|
// Also emit the specific grouping field change event for the moved task
|
||||||
|
if (sourceGroup.id !== targetGroup.id) {
|
||||||
|
if (currentGrouping === 'phase') {
|
||||||
|
// Emit phase change event
|
||||||
|
socket.emit(SocketEvents.TASK_PHASE_CHANGE.toString(), {
|
||||||
|
task_id: taskId,
|
||||||
|
phase_id: targetGroup.id,
|
||||||
|
parent_task: task.parent_task_id || null,
|
||||||
|
});
|
||||||
|
} else if (currentGrouping === 'priority') {
|
||||||
|
// Emit priority change event
|
||||||
|
socket.emit(SocketEvents.TASK_PRIORITY_CHANGE.toString(), JSON.stringify({
|
||||||
|
task_id: taskId,
|
||||||
|
priority_id: targetGroup.id,
|
||||||
|
team_id: teamId,
|
||||||
|
}));
|
||||||
|
} else if (currentGrouping === 'status') {
|
||||||
|
// Emit status change event
|
||||||
|
socket.emit(SocketEvents.TASK_STATUS_CHANGE.toString(), JSON.stringify({
|
||||||
|
task_id: taskId,
|
||||||
|
status_id: targetGroup.id,
|
||||||
|
team_id: teamId,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[socket, connected, projectId, allTasks, groups, currentGrouping, currentSession]
|
||||||
|
);
|
||||||
|
|
||||||
const handleDragStart = useCallback((event: DragStartEvent) => {
|
const handleDragStart = useCallback((event: DragStartEvent) => {
|
||||||
setActiveId(event.active.id as string);
|
setActiveId(event.active.id as string);
|
||||||
@@ -16,11 +146,17 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
(event: DragOverEvent) => {
|
(event: DragOverEvent) => {
|
||||||
const { active, over } = event;
|
const { active, over } = event;
|
||||||
|
|
||||||
if (!over) return;
|
if (!over) {
|
||||||
|
setOverId(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const activeId = active.id;
|
const activeId = active.id;
|
||||||
const overId = over.id;
|
const overId = over.id;
|
||||||
|
|
||||||
|
// Set the overId for drop indicators
|
||||||
|
setOverId(overId as string);
|
||||||
|
|
||||||
// Find the active task and the item being dragged over
|
// Find the active task and the item being dragged over
|
||||||
const activeTask = allTasks.find(task => task.id === activeId);
|
const activeTask = allTasks.find(task => task.id === activeId);
|
||||||
if (!activeTask) return;
|
if (!activeTask) return;
|
||||||
@@ -38,15 +174,6 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!activeGroup || !targetGroup) return;
|
if (!activeGroup || !targetGroup) return;
|
||||||
|
|
||||||
// If dragging to a different group, we need to handle cross-group movement
|
|
||||||
if (activeGroup.id !== targetGroup.id) {
|
|
||||||
console.log('Cross-group drag detected:', {
|
|
||||||
activeTask: activeTask.id,
|
|
||||||
fromGroup: activeGroup.id,
|
|
||||||
toGroup: targetGroup.id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[allTasks, groups]
|
[allTasks, groups]
|
||||||
);
|
);
|
||||||
@@ -55,6 +182,7 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
(event: DragEndEvent) => {
|
(event: DragEndEvent) => {
|
||||||
const { active, over } = event;
|
const { active, over } = event;
|
||||||
setActiveId(null);
|
setActiveId(null);
|
||||||
|
setOverId(null);
|
||||||
|
|
||||||
if (!over || active.id === over.id) {
|
if (!over || active.id === over.id) {
|
||||||
return;
|
return;
|
||||||
@@ -66,22 +194,27 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
// Find the active task
|
// Find the active task
|
||||||
const activeTask = allTasks.find(task => task.id === activeId);
|
const activeTask = allTasks.find(task => task.id === activeId);
|
||||||
if (!activeTask) {
|
if (!activeTask) {
|
||||||
console.error('Active task not found:', activeId);
|
logger.error('Active task not found:', activeId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the groups
|
// Find the groups
|
||||||
const activeGroup = groups.find(group => group.taskIds.includes(activeTask.id));
|
const activeGroup = groups.find(group => group.taskIds.includes(activeTask.id));
|
||||||
if (!activeGroup) {
|
if (!activeGroup) {
|
||||||
console.error('Could not find active group for task:', activeId);
|
logger.error('Could not find active group for task:', activeId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we're dropping on a task or a group
|
// Check if we're dropping on a task, group, or empty group
|
||||||
const overTask = allTasks.find(task => task.id === overId);
|
const overTask = allTasks.find(task => task.id === overId);
|
||||||
const overGroup = groups.find(group => group.id === overId);
|
const overGroup = groups.find(group => group.id === overId);
|
||||||
|
|
||||||
let targetGroup = overGroup;
|
// Check if dropping on empty group drop zone
|
||||||
|
const isEmptyGroupDrop = typeof overId === 'string' && overId.startsWith('empty-group-');
|
||||||
|
const emptyGroupId = isEmptyGroupDrop ? overId.replace('empty-group-', '') : null;
|
||||||
|
const emptyGroup = emptyGroupId ? groups.find(group => group.id === emptyGroupId) : null;
|
||||||
|
|
||||||
|
let targetGroup = overGroup || emptyGroup;
|
||||||
let insertIndex = 0;
|
let insertIndex = 0;
|
||||||
|
|
||||||
if (overTask) {
|
if (overTask) {
|
||||||
@@ -94,27 +227,20 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
// Dropping on a group (at the end)
|
// Dropping on a group (at the end)
|
||||||
targetGroup = overGroup;
|
targetGroup = overGroup;
|
||||||
insertIndex = targetGroup.taskIds.length;
|
insertIndex = targetGroup.taskIds.length;
|
||||||
|
} else if (emptyGroup) {
|
||||||
|
// Dropping on an empty group
|
||||||
|
targetGroup = emptyGroup;
|
||||||
|
insertIndex = 0; // First position in empty group
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!targetGroup) {
|
if (!targetGroup) {
|
||||||
console.error('Could not find target group');
|
logger.error('Could not find target group');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCrossGroup = activeGroup.id !== targetGroup.id;
|
const isCrossGroup = activeGroup.id !== targetGroup.id;
|
||||||
const activeIndex = activeGroup.taskIds.indexOf(activeTask.id);
|
const activeIndex = activeGroup.taskIds.indexOf(activeTask.id);
|
||||||
|
|
||||||
console.log('Drag operation:', {
|
|
||||||
activeId,
|
|
||||||
overId,
|
|
||||||
activeTask: activeTask.name || activeTask.title,
|
|
||||||
activeGroup: activeGroup.id,
|
|
||||||
targetGroup: targetGroup.id,
|
|
||||||
activeIndex,
|
|
||||||
insertIndex,
|
|
||||||
isCrossGroup,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isCrossGroup) {
|
if (isCrossGroup) {
|
||||||
// Moving task between groups
|
// Moving task between groups
|
||||||
console.log('Moving task between groups:', {
|
console.log('Moving task between groups:', {
|
||||||
@@ -124,16 +250,8 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
newPosition: insertIndex,
|
newPosition: insertIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Move task to the target group
|
// reorderTasksInGroup handles both same-group and cross-group moves
|
||||||
dispatch(
|
// No need for separate moveTaskBetweenGroups call
|
||||||
moveTaskBetweenGroups({
|
|
||||||
taskId: activeId as string,
|
|
||||||
sourceGroupId: activeGroup.id,
|
|
||||||
targetGroupId: targetGroup.id,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// Reorder task within target group at drop position
|
|
||||||
dispatch(
|
dispatch(
|
||||||
reorderTasksInGroup({
|
reorderTasksInGroup({
|
||||||
sourceTaskId: activeId as string,
|
sourceTaskId: activeId as string,
|
||||||
@@ -142,15 +260,10 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
destinationGroupId: targetGroup.id,
|
destinationGroupId: targetGroup.id,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
// Reordering within the same group
|
|
||||||
console.log('Reordering task within same group:', {
|
|
||||||
task: activeTask.name || activeTask.title,
|
|
||||||
group: activeGroup.title,
|
|
||||||
from: activeIndex,
|
|
||||||
to: insertIndex,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// Emit socket event for persistence
|
||||||
|
emitTaskSortChange(activeId as string, activeGroup, targetGroup, insertIndex);
|
||||||
|
} else {
|
||||||
if (activeIndex !== insertIndex) {
|
if (activeIndex !== insertIndex) {
|
||||||
// Reorder task within same group at drop position
|
// Reorder task within same group at drop position
|
||||||
dispatch(
|
dispatch(
|
||||||
@@ -161,14 +274,18 @@ export const useDragAndDrop = (allTasks: Task[], groups: TaskGroup[]) => {
|
|||||||
destinationGroupId: activeGroup.id,
|
destinationGroupId: activeGroup.id,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Emit socket event for persistence
|
||||||
|
emitTaskSortChange(activeId as string, activeGroup, targetGroup, insertIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[allTasks, groups, dispatch]
|
[allTasks, groups, dispatch, emitTaskSortChange]
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeId,
|
activeId,
|
||||||
|
overId,
|
||||||
handleDragStart,
|
handleDragStart,
|
||||||
handleDragOver,
|
handleDragOver,
|
||||||
handleDragEnd,
|
handleDragEnd,
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ interface UseTaskRowColumnsProps {
|
|||||||
// Drag and drop
|
// Drag and drop
|
||||||
attributes: any;
|
attributes: any;
|
||||||
listeners: any;
|
listeners: any;
|
||||||
|
|
||||||
|
// Depth for nested subtasks
|
||||||
|
depth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useTaskRowColumns = ({
|
export const useTaskRowColumns = ({
|
||||||
@@ -84,6 +87,7 @@ export const useTaskRowColumns = ({
|
|||||||
handleTaskNameEdit,
|
handleTaskNameEdit,
|
||||||
attributes,
|
attributes,
|
||||||
listeners,
|
listeners,
|
||||||
|
depth = 0,
|
||||||
}: UseTaskRowColumnsProps) => {
|
}: UseTaskRowColumnsProps) => {
|
||||||
|
|
||||||
const renderColumn = useCallback((columnId: string, width: string, isSticky?: boolean, index?: number) => {
|
const renderColumn = useCallback((columnId: string, width: string, isSticky?: boolean, index?: number) => {
|
||||||
@@ -128,6 +132,7 @@ export const useTaskRowColumns = ({
|
|||||||
onEditTaskName={setEditTaskName}
|
onEditTaskName={setEditTaskName}
|
||||||
onTaskNameChange={setTaskName}
|
onTaskNameChange={setTaskName}
|
||||||
onTaskNameSave={handleTaskNameSave}
|
onTaskNameSave={handleTaskNameSave}
|
||||||
|
depth={depth}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
EntityId,
|
EntityId,
|
||||||
createSelector,
|
createSelector,
|
||||||
} from '@reduxjs/toolkit';
|
} from '@reduxjs/toolkit';
|
||||||
import { Task, TaskManagementState, TaskGroup, TaskGrouping } from '@/types/task-management.types';
|
import { Task, TaskManagementState, TaskGroup, TaskGrouping, getSortOrderField } from '@/types/task-management.types';
|
||||||
import { ITaskListColumn } from '@/types/tasks/taskList.types';
|
import { ITaskListColumn } from '@/types/tasks/taskList.types';
|
||||||
import { RootState } from '@/app/store';
|
import { RootState } from '@/app/store';
|
||||||
import {
|
import {
|
||||||
@@ -661,11 +661,11 @@ const taskManagementSlice = createSlice({
|
|||||||
newTasks.splice(newTasks.indexOf(destinationTaskId), 0, removed);
|
newTasks.splice(newTasks.indexOf(destinationTaskId), 0, removed);
|
||||||
group.taskIds = newTasks;
|
group.taskIds = newTasks;
|
||||||
|
|
||||||
// Update order for affected tasks. Assuming simple reordering affects order.
|
// Update order for affected tasks using the appropriate sort field
|
||||||
// This might need more sophisticated logic based on how `order` is used.
|
const sortField = getSortOrderField(state.grouping?.id);
|
||||||
newTasks.forEach((id, index) => {
|
newTasks.forEach((id, index) => {
|
||||||
if (newEntities[id]) {
|
if (newEntities[id]) {
|
||||||
newEntities[id] = { ...newEntities[id], order: index };
|
newEntities[id] = { ...newEntities[id], [sortField]: index };
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -686,49 +686,16 @@ const taskManagementSlice = createSlice({
|
|||||||
destinationGroup.taskIds.push(sourceTaskId); // Add to end if destination task not found
|
destinationGroup.taskIds.push(sourceTaskId); // Add to end if destination task not found
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update task's grouping field to reflect new group (e.g., status, priority, phase)
|
// Do NOT update the task's grouping field (priority, phase, status) here.
|
||||||
// This assumes the group ID directly corresponds to the task's field value
|
// This will be handled by the socket event handler after backend confirmation.
|
||||||
if (sourceTask) {
|
|
||||||
let updatedTask = { ...sourceTask };
|
|
||||||
switch (state.grouping?.id) {
|
|
||||||
case IGroupBy.STATUS:
|
|
||||||
updatedTask.status = destinationGroup.id;
|
|
||||||
break;
|
|
||||||
case IGroupBy.PRIORITY:
|
|
||||||
updatedTask.priority = destinationGroup.id;
|
|
||||||
break;
|
|
||||||
case IGroupBy.PHASE:
|
|
||||||
// Handle unmapped group specially
|
|
||||||
if (destinationGroup.id === 'Unmapped' || destinationGroup.title === 'Unmapped') {
|
|
||||||
updatedTask.phase = ''; // Clear phase for unmapped group
|
|
||||||
} else {
|
|
||||||
updatedTask.phase = destinationGroup.id;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IGroupBy.MEMBERS:
|
|
||||||
// If moving to a member group, ensure task is assigned to that member
|
|
||||||
// This assumes the group ID is the member ID
|
|
||||||
if (!updatedTask.assignees) {
|
|
||||||
updatedTask.assignees = [];
|
|
||||||
}
|
|
||||||
if (!updatedTask.assignees.includes(destinationGroup.id)) {
|
|
||||||
updatedTask.assignees.push(destinationGroup.id);
|
|
||||||
}
|
|
||||||
// If moving from a member group, and the task is no longer in any member group,
|
|
||||||
// consider removing the assignment (more complex logic might be needed here)
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
newEntities[sourceTaskId] = updatedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update order for affected tasks in both groups if necessary
|
// Update order for affected tasks in both groups using the appropriate sort field
|
||||||
|
const sortField = getSortOrderField(state.grouping?.id);
|
||||||
sourceGroup.taskIds.forEach((id, index) => {
|
sourceGroup.taskIds.forEach((id, index) => {
|
||||||
if (newEntities[id]) newEntities[id] = { ...newEntities[id], order: index };
|
if (newEntities[id]) newEntities[id] = { ...newEntities[id], [sortField]: index };
|
||||||
});
|
});
|
||||||
destinationGroup.taskIds.forEach((id, index) => {
|
destinationGroup.taskIds.forEach((id, index) => {
|
||||||
if (newEntities[id]) newEntities[id] = { ...newEntities[id], order: index };
|
if (newEntities[id]) newEntities[id] = { ...newEntities[id], [sortField]: index };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -958,8 +925,26 @@ const taskManagementSlice = createSlice({
|
|||||||
.addCase(fetchTasksV3.fulfilled, (state, action) => {
|
.addCase(fetchTasksV3.fulfilled, (state, action) => {
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
const { allTasks, groups, grouping } = action.payload;
|
const { allTasks, groups, grouping } = action.payload;
|
||||||
tasksAdapter.setAll(state as EntityState<Task, string>, allTasks || []); // Ensure allTasks is an array
|
|
||||||
state.ids = (allTasks || []).map(task => task.id); // Also update ids
|
// Preserve existing timer state from old tasks before replacing
|
||||||
|
const oldTasks = state.entities;
|
||||||
|
const tasksWithTimers = (allTasks || []).map(task => {
|
||||||
|
const oldTask = oldTasks[task.id];
|
||||||
|
if (oldTask?.timeTracking?.activeTimer) {
|
||||||
|
// Preserve the timer state from the old task
|
||||||
|
return {
|
||||||
|
...task,
|
||||||
|
timeTracking: {
|
||||||
|
...task.timeTracking,
|
||||||
|
activeTimer: oldTask.timeTracking.activeTimer
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return task;
|
||||||
|
});
|
||||||
|
|
||||||
|
tasksAdapter.setAll(state as EntityState<Task, string>, tasksWithTimers); // Ensure allTasks is an array
|
||||||
|
state.ids = tasksWithTimers.map(task => task.id); // Also update ids
|
||||||
state.groups = groups;
|
state.groups = groups;
|
||||||
state.grouping = grouping;
|
state.grouping = grouping;
|
||||||
})
|
})
|
||||||
@@ -1010,7 +995,7 @@ const taskManagementSlice = createSlice({
|
|||||||
order: subtask.sort_order || subtask.order || 0,
|
order: subtask.sort_order || subtask.order || 0,
|
||||||
parent_task_id: parentTaskId,
|
parent_task_id: parentTaskId,
|
||||||
is_sub_task: true,
|
is_sub_task: true,
|
||||||
sub_tasks_count: 0,
|
sub_tasks_count: subtask.sub_tasks_count || 0, // Use actual count from backend
|
||||||
show_sub_tasks: false,
|
show_sub_tasks: false,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ const DEFAULT_FIELDS: TaskListField[] = [
|
|||||||
{ key: 'KEY', label: 'Key', visible: false, order: 1 },
|
{ key: 'KEY', label: 'Key', visible: false, order: 1 },
|
||||||
{ key: 'DESCRIPTION', label: 'Description', visible: false, order: 2 },
|
{ key: 'DESCRIPTION', label: 'Description', visible: false, order: 2 },
|
||||||
{ key: 'PROGRESS', label: 'Progress', visible: true, order: 3 },
|
{ key: 'PROGRESS', label: 'Progress', visible: true, order: 3 },
|
||||||
{ key: 'ASSIGNEES', label: 'Assignees', visible: true, order: 4 },
|
{ key: 'STATUS', label: 'Status', visible: true, order: 4 },
|
||||||
{ key: 'LABELS', label: 'Labels', visible: true, order: 5 },
|
{ key: 'ASSIGNEES', label: 'Assignees', visible: true, order: 5 },
|
||||||
{ key: 'PHASE', label: 'Phase', visible: true, order: 6 },
|
{ key: 'LABELS', label: 'Labels', visible: true, order: 6 },
|
||||||
{ key: 'STATUS', label: 'Status', visible: true, order: 7 },
|
{ key: 'PHASE', label: 'Phase', visible: true, order: 7 },
|
||||||
{ key: 'PRIORITY', label: 'Priority', visible: true, order: 8 },
|
{ key: 'PRIORITY', label: 'Priority', visible: true, order: 8 },
|
||||||
{ key: 'TIME_TRACKING', label: 'Time Tracking', visible: true, order: 9 },
|
{ key: 'TIME_TRACKING', label: 'Time Tracking', visible: true, order: 9 },
|
||||||
{ key: 'ESTIMATION', label: 'Estimation', visible: false, order: 10 },
|
{ key: 'ESTIMATION', label: 'Estimation', visible: false, order: 10 },
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
updateTaskDescription,
|
updateTaskDescription,
|
||||||
updateSubTasks,
|
updateSubTasks,
|
||||||
updateTaskProgress,
|
updateTaskProgress,
|
||||||
|
updateTaskTimeTracking,
|
||||||
} from '@/features/tasks/tasks.slice';
|
} from '@/features/tasks/tasks.slice';
|
||||||
import {
|
import {
|
||||||
addTask,
|
addTask,
|
||||||
@@ -936,6 +937,8 @@ export const useTaskSocketHandlers = () => {
|
|||||||
const { task_id, start_time } = typeof data === 'string' ? JSON.parse(data) : data;
|
const { task_id, start_time } = typeof data === 'string' ? JSON.parse(data) : data;
|
||||||
if (!task_id) return;
|
if (!task_id) return;
|
||||||
|
|
||||||
|
const timerTimestamp = start_time ? (typeof start_time === 'number' ? start_time : parseInt(start_time)) : Date.now();
|
||||||
|
|
||||||
// Update the task-management slice to include timer state
|
// Update the task-management slice to include timer state
|
||||||
const currentTask = store.getState().taskManagement.entities[task_id];
|
const currentTask = store.getState().taskManagement.entities[task_id];
|
||||||
if (currentTask) {
|
if (currentTask) {
|
||||||
@@ -943,13 +946,16 @@ export const useTaskSocketHandlers = () => {
|
|||||||
...currentTask,
|
...currentTask,
|
||||||
timeTracking: {
|
timeTracking: {
|
||||||
...currentTask.timeTracking,
|
...currentTask.timeTracking,
|
||||||
activeTimer: start_time ? (typeof start_time === 'number' ? start_time : parseInt(start_time)) : Date.now(),
|
activeTimer: timerTimestamp,
|
||||||
},
|
},
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
updated_at: new Date().toISOString(),
|
updated_at: new Date().toISOString(),
|
||||||
};
|
};
|
||||||
dispatch(updateTask(updatedTask));
|
dispatch(updateTask(updatedTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also update the tasks slice activeTimers to keep both slices in sync
|
||||||
|
dispatch(updateTaskTimeTracking({ taskId: task_id, timeTracking: timerTimestamp }));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error handling timer start event:', error);
|
logger.error('Error handling timer start event:', error);
|
||||||
}
|
}
|
||||||
@@ -975,11 +981,79 @@ export const useTaskSocketHandlers = () => {
|
|||||||
};
|
};
|
||||||
dispatch(updateTask(updatedTask));
|
dispatch(updateTask(updatedTask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Also update the tasks slice activeTimers to keep both slices in sync
|
||||||
|
dispatch(updateTaskTimeTracking({ taskId: task_id, timeTracking: null }));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Error handling timer stop event:', error);
|
logger.error('Error handling timer stop event:', error);
|
||||||
}
|
}
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
|
// Handler for task sort order change events
|
||||||
|
const handleTaskSortOrderChange = useCallback((data: any[]) => {
|
||||||
|
try {
|
||||||
|
if (!Array.isArray(data) || data.length === 0) return;
|
||||||
|
|
||||||
|
// DEBUG: Log the data received from the backend
|
||||||
|
console.log('[TASK_SORT_ORDER_CHANGE] Received data:', data);
|
||||||
|
|
||||||
|
// Get canonical lists from Redux
|
||||||
|
const state = store.getState();
|
||||||
|
const priorityList = state.priorityReducer?.priorities || [];
|
||||||
|
const phaseList = state.phaseReducer?.phaseList || [];
|
||||||
|
const statusList = state.taskStatusReducer?.status || [];
|
||||||
|
|
||||||
|
// The backend sends an array of tasks with updated sort orders and possibly grouping fields
|
||||||
|
data.forEach((taskData: any) => {
|
||||||
|
const currentTask = state.taskManagement.entities[taskData.id];
|
||||||
|
if (currentTask) {
|
||||||
|
let updatedTask: Task = {
|
||||||
|
...currentTask,
|
||||||
|
order: taskData.sort_order || taskData.current_sort_order || currentTask.order,
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
updated_at: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Update grouping fields if present
|
||||||
|
if (typeof taskData.priority_id !== 'undefined') {
|
||||||
|
const found = priorityList.find(p => p.id === taskData.priority_id);
|
||||||
|
if (found) {
|
||||||
|
updatedTask.priority = found.name;
|
||||||
|
// updatedTask.priority_id = found.id; // Only if Task type has priority_id
|
||||||
|
} else {
|
||||||
|
updatedTask.priority = taskData.priority_id || '';
|
||||||
|
// updatedTask.priority_id = taskData.priority_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof taskData.phase_id !== 'undefined') {
|
||||||
|
const found = phaseList.find(p => p.id === taskData.phase_id);
|
||||||
|
if (found) {
|
||||||
|
updatedTask.phase = found.name;
|
||||||
|
// updatedTask.phase_id = found.id; // Only if Task type has phase_id
|
||||||
|
} else {
|
||||||
|
updatedTask.phase = taskData.phase_id || '';
|
||||||
|
// updatedTask.phase_id = taskData.phase_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (typeof taskData.status_id !== 'undefined') {
|
||||||
|
const found = statusList.find(s => s.id === taskData.status_id);
|
||||||
|
if (found) {
|
||||||
|
updatedTask.status = found.name;
|
||||||
|
// updatedTask.status_id = found.id; // Only if Task type has status_id
|
||||||
|
} else {
|
||||||
|
updatedTask.status = taskData.status_id || '';
|
||||||
|
// updatedTask.status_id = taskData.status_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dispatch(updateTask(updatedTask));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Error handling task sort order change event:', error);
|
||||||
|
}
|
||||||
|
}, [dispatch]);
|
||||||
|
|
||||||
// Register socket event listeners
|
// Register socket event listeners
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!socket) return;
|
if (!socket) return;
|
||||||
@@ -1013,6 +1087,7 @@ export const useTaskSocketHandlers = () => {
|
|||||||
{ event: SocketEvents.TASK_CUSTOM_COLUMN_UPDATE.toString(), handler: handleCustomColumnUpdate },
|
{ event: SocketEvents.TASK_CUSTOM_COLUMN_UPDATE.toString(), handler: handleCustomColumnUpdate },
|
||||||
{ event: SocketEvents.TASK_TIMER_START.toString(), handler: handleTimerStart },
|
{ event: SocketEvents.TASK_TIMER_START.toString(), handler: handleTimerStart },
|
||||||
{ event: SocketEvents.TASK_TIMER_STOP.toString(), handler: handleTimerStop },
|
{ event: SocketEvents.TASK_TIMER_STOP.toString(), handler: handleTimerStop },
|
||||||
|
{ event: SocketEvents.TASK_SORT_ORDER_CHANGE.toString(), handler: handleTaskSortOrderChange },
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -1047,6 +1122,7 @@ export const useTaskSocketHandlers = () => {
|
|||||||
handleCustomColumnUpdate,
|
handleCustomColumnUpdate,
|
||||||
handleTimerStart,
|
handleTimerStart,
|
||||||
handleTimerStop,
|
handleTimerStop,
|
||||||
|
handleTaskSortOrderChange,
|
||||||
|
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -50,7 +50,11 @@ export const useTaskTimer = (taskId: string, initialStartTime: number | null) =>
|
|||||||
|
|
||||||
// Timer management effect
|
// Timer management effect
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (started && localStarted && reduxStartTime) {
|
if (started && reduxStartTime) {
|
||||||
|
// Sync local state with Redux state
|
||||||
|
if (!localStarted) {
|
||||||
|
setLocalStarted(true);
|
||||||
|
}
|
||||||
clearTimerInterval();
|
clearTimerInterval();
|
||||||
timerTick();
|
timerTick();
|
||||||
intervalRef.current = setInterval(timerTick, 1000);
|
intervalRef.current = setInterval(timerTick, 1000);
|
||||||
|
|||||||
79
worklenz-frontend/src/hooks/useTimerInitialization.ts
Normal file
79
worklenz-frontend/src/hooks/useTimerInitialization.ts
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import { useEffect, useRef } from 'react';
|
||||||
|
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||||
|
import { updateTaskTimeTracking } from '@/features/tasks/tasks.slice';
|
||||||
|
import { updateTask } from '@/features/task-management/task-management.slice';
|
||||||
|
import { taskTimeLogsApiService } from '@/api/tasks/task-time-logs.api.service';
|
||||||
|
import { store } from '@/app/store';
|
||||||
|
import { Task } from '@/types/task-management.types';
|
||||||
|
import logger from '@/utils/errorLogger';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
export const useTimerInitialization = () => {
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
const hasInitialized = useRef(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const initializeTimers = async () => {
|
||||||
|
// Prevent duplicate initialization
|
||||||
|
if (hasInitialized.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
hasInitialized.current = true;
|
||||||
|
|
||||||
|
// Fetch running timers from backend
|
||||||
|
const response = await taskTimeLogsApiService.getRunningTimers();
|
||||||
|
|
||||||
|
if (response && response.done && Array.isArray(response.body)) {
|
||||||
|
const runningTimers = response.body;
|
||||||
|
|
||||||
|
// Update Redux state for each running timer
|
||||||
|
runningTimers.forEach(timer => {
|
||||||
|
if (timer.task_id && timer.start_time) {
|
||||||
|
try {
|
||||||
|
// Convert start_time to timestamp
|
||||||
|
const startTime = moment(timer.start_time);
|
||||||
|
if (startTime.isValid()) {
|
||||||
|
const timestamp = startTime.valueOf();
|
||||||
|
|
||||||
|
// Update the tasks slice activeTimers
|
||||||
|
dispatch(updateTaskTimeTracking({
|
||||||
|
taskId: timer.task_id,
|
||||||
|
timeTracking: timestamp
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Update the task-management slice if the task exists
|
||||||
|
const currentTask = store.getState().taskManagement.entities[timer.task_id];
|
||||||
|
if (currentTask) {
|
||||||
|
const updatedTask: Task = {
|
||||||
|
...currentTask,
|
||||||
|
timeTracking: {
|
||||||
|
...currentTask.timeTracking,
|
||||||
|
activeTimer: timestamp,
|
||||||
|
},
|
||||||
|
updatedAt: new Date().toISOString(),
|
||||||
|
updated_at: new Date().toISOString(),
|
||||||
|
};
|
||||||
|
dispatch(updateTask(updatedTask));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`Error initializing timer for task ${timer.task_id}:`, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (runningTimers.length > 0) {
|
||||||
|
logger.info(`Initialized ${runningTimers.length} running timers from backend`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Error initializing timers from backend:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize timers when the hook mounts
|
||||||
|
initializeTimers();
|
||||||
|
}, [dispatch]);
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useSelector, useDispatch } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { Space, Steps, Button, Typography } from 'antd/es';
|
import { Space, Steps, Button, Typography } from 'antd/es';
|
||||||
@@ -26,6 +26,7 @@ import { validateEmail } from '@/utils/validateEmail';
|
|||||||
import { sanitizeInput } from '@/utils/sanitizeInput';
|
import { sanitizeInput } from '@/utils/sanitizeInput';
|
||||||
import logo from '@/assets/images/worklenz-light-mode.png';
|
import logo from '@/assets/images/worklenz-light-mode.png';
|
||||||
import logoDark from '@/assets/images/worklenz-dark-mode.png';
|
import logoDark from '@/assets/images/worklenz-dark-mode.png';
|
||||||
|
import { useAppDispatch } from '@/hooks/useAppDispatch';
|
||||||
|
|
||||||
import './account-setup.css';
|
import './account-setup.css';
|
||||||
import { IAccountSetupRequest } from '@/types/project-templates/project-templates.types';
|
import { IAccountSetupRequest } from '@/types/project-templates/project-templates.types';
|
||||||
@@ -34,7 +35,7 @@ import { profileSettingsApiService } from '@/api/settings/profile/profile-settin
|
|||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
const AccountSetup: React.FC = () => {
|
const AccountSetup: React.FC = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { t } = useTranslation('account-setup');
|
const { t } = useTranslation('account-setup');
|
||||||
useDocumentTitle(t('setupYourAccount', 'Account Setup'));
|
useDocumentTitle(t('setupYourAccount', 'Account Setup'));
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -52,8 +53,7 @@ const AccountSetup: React.FC = () => {
|
|||||||
trackMixpanelEvent(evt_account_setup_visit);
|
trackMixpanelEvent(evt_account_setup_visit);
|
||||||
const verifyAuthStatus = async () => {
|
const verifyAuthStatus = async () => {
|
||||||
try {
|
try {
|
||||||
const response = (await dispatch(verifyAuthentication()).unwrap())
|
const response = await dispatch(verifyAuthentication()).unwrap() as IAuthorizeResponse;
|
||||||
.payload as IAuthorizeResponse;
|
|
||||||
if (response?.authenticated) {
|
if (response?.authenticated) {
|
||||||
setSession(response.user);
|
setSession(response.user);
|
||||||
dispatch(setUser(response.user));
|
dispatch(setUser(response.user));
|
||||||
@@ -163,6 +163,18 @@ const AccountSetup: React.FC = () => {
|
|||||||
const res = await profileSettingsApiService.setupAccount(model);
|
const res = await profileSettingsApiService.setupAccount(model);
|
||||||
if (res.done && res.body.id) {
|
if (res.done && res.body.id) {
|
||||||
trackMixpanelEvent(skip ? evt_account_setup_skip_invite : evt_account_setup_complete);
|
trackMixpanelEvent(skip ? evt_account_setup_skip_invite : evt_account_setup_complete);
|
||||||
|
|
||||||
|
// Refresh user session to update setup_completed status
|
||||||
|
try {
|
||||||
|
const authResponse = await dispatch(verifyAuthentication()).unwrap() as IAuthorizeResponse;
|
||||||
|
if (authResponse?.authenticated && authResponse?.user) {
|
||||||
|
setSession(authResponse.user);
|
||||||
|
dispatch(setUser(authResponse.user));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Failed to refresh user session after setup completion', error);
|
||||||
|
}
|
||||||
|
|
||||||
navigate(`/worklenz/projects/${res.body.id}?tab=tasks-list&pinned_tab=tasks-list`);
|
navigate(`/worklenz/projects/${res.body.id}?tab=tasks-list&pinned_tab=tasks-list`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { useAuthService } from '@/hooks/useAuth';
|
import { useAuthService } from '@/hooks/useAuth';
|
||||||
import { useMediaQuery } from 'react-responsive';
|
import { useMediaQuery } from 'react-responsive';
|
||||||
import { authApiService } from '@/api/auth/auth.api.service';
|
import { authApiService } from '@/api/auth/auth.api.service';
|
||||||
|
import CacheCleanup from '@/utils/cache-cleanup';
|
||||||
|
|
||||||
const LoggingOutPage = () => {
|
const LoggingOutPage = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -14,14 +15,30 @@ const LoggingOutPage = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const logout = async () => {
|
const logout = async () => {
|
||||||
|
try {
|
||||||
|
// Clear local session
|
||||||
await auth.signOut();
|
await auth.signOut();
|
||||||
|
|
||||||
|
// Call backend logout
|
||||||
await authApiService.logout();
|
await authApiService.logout();
|
||||||
|
|
||||||
|
// Clear all caches using the utility
|
||||||
|
await CacheCleanup.clearAllCaches();
|
||||||
|
|
||||||
|
// Force a hard reload to ensure fresh state
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.location.href = '/';
|
CacheCleanup.forceReload('/auth/login');
|
||||||
}, 1500);
|
}, 1000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Logout error:', error);
|
||||||
|
// Fallback: force reload to login page
|
||||||
|
CacheCleanup.forceReload('/auth/login');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void logout();
|
void logout();
|
||||||
}, [auth, navigate]);
|
}, [auth]);
|
||||||
|
|
||||||
const cardStyles = {
|
const cardStyles = {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import { resetState as resetEnhancedKanbanState } from '@/features/enhanced-kanb
|
|||||||
import { setProjectId as setInsightsProjectId } from '@/features/projects/insights/project-insights.slice';
|
import { setProjectId as setInsightsProjectId } from '@/features/projects/insights/project-insights.slice';
|
||||||
import { SuspenseFallback } from '@/components/suspense-fallback/suspense-fallback';
|
import { SuspenseFallback } from '@/components/suspense-fallback/suspense-fallback';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useTimerInitialization } from '@/hooks/useTimerInitialization';
|
||||||
|
|
||||||
|
|
||||||
// Import critical components synchronously to avoid suspense interruptions
|
// Import critical components synchronously to avoid suspense interruptions
|
||||||
@@ -89,6 +90,9 @@ const ProjectView = React.memo(() => {
|
|||||||
const [taskid, setTaskId] = useState<string>(urlParams.taskId);
|
const [taskid, setTaskId] = useState<string>(urlParams.taskId);
|
||||||
const [isInitialized, setIsInitialized] = useState(false);
|
const [isInitialized, setIsInitialized] = useState(false);
|
||||||
|
|
||||||
|
// Initialize timer state from backend when project view loads
|
||||||
|
useTimerInitialization();
|
||||||
|
|
||||||
// Update local state when URL params change
|
// Update local state when URL params change
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setActiveTab(urlParams.tab);
|
setActiveTab(urlParams.tab);
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ export interface Task {
|
|||||||
has_subscribers?: boolean;
|
has_subscribers?: boolean;
|
||||||
schedule_id?: string | null;
|
schedule_id?: string | null;
|
||||||
order?: number;
|
order?: number;
|
||||||
|
status_sort_order?: number; // Sort order when grouped by status
|
||||||
|
priority_sort_order?: number; // Sort order when grouped by priority
|
||||||
|
phase_sort_order?: number; // Sort order when grouped by phase
|
||||||
|
member_sort_order?: number; // Sort order when grouped by members
|
||||||
reporter?: string; // Reporter field
|
reporter?: string; // Reporter field
|
||||||
timeTracking?: { // Time tracking information
|
timeTracking?: { // Time tracking information
|
||||||
logged?: number;
|
logged?: number;
|
||||||
@@ -173,3 +177,21 @@ export interface BulkAction {
|
|||||||
value?: any;
|
value?: any;
|
||||||
taskIds: string[];
|
taskIds: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper function to get the appropriate sort order field based on grouping
|
||||||
|
export function getSortOrderField(grouping: string | undefined): keyof Task {
|
||||||
|
switch (grouping) {
|
||||||
|
case 'status':
|
||||||
|
return 'status_sort_order';
|
||||||
|
case 'priority':
|
||||||
|
return 'priority_sort_order';
|
||||||
|
case 'phase':
|
||||||
|
return 'phase_sort_order';
|
||||||
|
case 'members':
|
||||||
|
return 'member_sort_order';
|
||||||
|
case 'general':
|
||||||
|
return 'order'; // explicit general sorting
|
||||||
|
default:
|
||||||
|
return 'status_sort_order'; // Default to status sorting to match backend
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ export interface ITaskRecurringSchedule {
|
|||||||
interval_weeks?: number | null;
|
interval_weeks?: number | null;
|
||||||
schedule_type?: ITaskRecurring;
|
schedule_type?: ITaskRecurring;
|
||||||
week_of_month?: number | null;
|
week_of_month?: number | null;
|
||||||
|
timezone?: string;
|
||||||
|
end_date?: string | null;
|
||||||
|
excluded_dates?: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRepeatOption {
|
export interface IRepeatOption {
|
||||||
|
|||||||
163
worklenz-frontend/src/utils/cache-cleanup.ts
Normal file
163
worklenz-frontend/src/utils/cache-cleanup.ts
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
* Cache cleanup utilities for logout operations
|
||||||
|
* Handles clearing of various caches to prevent stale data issues
|
||||||
|
*/
|
||||||
|
|
||||||
|
export class CacheCleanup {
|
||||||
|
/**
|
||||||
|
* Clear all caches including service worker, browser cache, and storage
|
||||||
|
*/
|
||||||
|
static async clearAllCaches(): Promise<void> {
|
||||||
|
try {
|
||||||
|
console.log('CacheCleanup: Starting cache clearing process...');
|
||||||
|
|
||||||
|
// Clear browser caches
|
||||||
|
if ('caches' in window) {
|
||||||
|
const cacheNames = await caches.keys();
|
||||||
|
console.log('CacheCleanup: Found caches:', cacheNames);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
cacheNames.map(async cacheName => {
|
||||||
|
const deleted = await caches.delete(cacheName);
|
||||||
|
console.log(`CacheCleanup: Deleted cache "${cacheName}":`, deleted);
|
||||||
|
return deleted;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
console.log('CacheCleanup: Browser caches cleared');
|
||||||
|
} else {
|
||||||
|
console.log('CacheCleanup: Cache API not supported');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear service worker cache
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
const registration = await navigator.serviceWorker.getRegistration();
|
||||||
|
if (registration) {
|
||||||
|
console.log('CacheCleanup: Found service worker registration');
|
||||||
|
|
||||||
|
// Send logout message to service worker to clear its caches and unregister
|
||||||
|
if (registration.active) {
|
||||||
|
try {
|
||||||
|
console.log('CacheCleanup: Sending LOGOUT message to service worker...');
|
||||||
|
await this.sendMessageToServiceWorker('LOGOUT');
|
||||||
|
console.log('CacheCleanup: LOGOUT message sent successfully');
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('CacheCleanup: Failed to send logout message to service worker:', error);
|
||||||
|
// Fallback: try to clear cache manually
|
||||||
|
try {
|
||||||
|
console.log('CacheCleanup: Trying fallback CLEAR_CACHE message...');
|
||||||
|
await this.sendMessageToServiceWorker('CLEAR_CACHE');
|
||||||
|
console.log('CacheCleanup: CLEAR_CACHE message sent successfully');
|
||||||
|
} catch (fallbackError) {
|
||||||
|
console.warn('CacheCleanup: Failed to clear service worker cache:', fallbackError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If service worker is still registered, unregister it
|
||||||
|
if (registration.active) {
|
||||||
|
console.log('CacheCleanup: Unregistering service worker...');
|
||||||
|
await registration.unregister();
|
||||||
|
console.log('CacheCleanup: Service worker unregistered');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('CacheCleanup: No service worker registration found');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('CacheCleanup: Service Worker not supported');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear localStorage and sessionStorage
|
||||||
|
const localStorageKeys = Object.keys(localStorage);
|
||||||
|
const sessionStorageKeys = Object.keys(sessionStorage);
|
||||||
|
|
||||||
|
console.log('CacheCleanup: Clearing localStorage keys:', localStorageKeys);
|
||||||
|
console.log('CacheCleanup: Clearing sessionStorage keys:', sessionStorageKeys);
|
||||||
|
|
||||||
|
localStorage.clear();
|
||||||
|
sessionStorage.clear();
|
||||||
|
console.log('CacheCleanup: Local storage cleared');
|
||||||
|
|
||||||
|
console.log('CacheCleanup: Cache clearing process completed successfully');
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('CacheCleanup: Error clearing caches:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send message to service worker
|
||||||
|
*/
|
||||||
|
private static async sendMessageToServiceWorker(type: string, payload?: any): Promise<any> {
|
||||||
|
if (!('serviceWorker' in navigator)) {
|
||||||
|
throw new Error('Service Worker not supported');
|
||||||
|
}
|
||||||
|
|
||||||
|
const registration = await navigator.serviceWorker.getRegistration();
|
||||||
|
if (!registration || !registration.active) {
|
||||||
|
throw new Error('Service Worker not active');
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const messageChannel = new MessageChannel();
|
||||||
|
|
||||||
|
messageChannel.port1.onmessage = (event) => {
|
||||||
|
if (event.data.error) {
|
||||||
|
reject(event.data.error);
|
||||||
|
} else {
|
||||||
|
resolve(event.data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
registration.active!.postMessage(
|
||||||
|
{ type, payload },
|
||||||
|
[messageChannel.port2]
|
||||||
|
);
|
||||||
|
|
||||||
|
// Timeout after 5 seconds
|
||||||
|
setTimeout(() => {
|
||||||
|
reject(new Error('Service Worker message timeout'));
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force reload the page to ensure fresh state
|
||||||
|
*/
|
||||||
|
static forceReload(url: string = '/auth/login'): void {
|
||||||
|
// Use replace to prevent back button issues
|
||||||
|
window.location.replace(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear specific cache types
|
||||||
|
*/
|
||||||
|
static async clearSpecificCaches(cacheTypes: string[]): Promise<void> {
|
||||||
|
if (!('caches' in window)) return;
|
||||||
|
|
||||||
|
const cacheNames = await caches.keys();
|
||||||
|
const cachesToDelete = cacheNames.filter(name =>
|
||||||
|
cacheTypes.some(type => name.includes(type))
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
cachesToDelete.map(cacheName => caches.delete(cacheName))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear API cache specifically
|
||||||
|
*/
|
||||||
|
static async clearAPICache(): Promise<void> {
|
||||||
|
await this.clearSpecificCaches(['api', 'dynamic']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear static asset cache
|
||||||
|
*/
|
||||||
|
static async clearStaticCache(): Promise<void> {
|
||||||
|
await this.clearSpecificCaches(['static', 'images']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CacheCleanup;
|
||||||
Reference in New Issue
Block a user