feat: Refine notice filtering and Docker setup

Implement granular notice filtering logic based on user roles and notice targeting.
Update Dockerfiles and .dockerignore for a cleaner build process.
This commit is contained in:
2025-12-09 14:15:43 +01:00
parent 891ea7a12c
commit 25eafb1c6e
5 changed files with 20 additions and 69 deletions

Binary file not shown.

View File

@@ -1,15 +0,0 @@
# Stage 1: Build Frontend
FROM node:18-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# Stage 2: Serve with Nginx
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
# Copy the nginx configuration file (using the .txt extension as provided in source)
COPY nginx.txt /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -1,38 +0,0 @@
worker_processes 1;
events { worker_connections 1024; }
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
# Limite upload per allegati (es. foto/video ticket) - Allineato con il backend
client_max_body_size 50M;
# Compressione Gzip
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Gestione SPA (React Router)
location / {
try_files $uri $uri/ /index.html;
}
# Proxy API verso il backend
location /api/ {
proxy_pass http://backend:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}

View File

@@ -30,12 +30,29 @@ export const FamilyList: React.FC = () => {
setSettings(appSettings); setSettings(appSettings);
if (condo && currentUser && appSettings.features.notices) { if (condo && currentUser && appSettings.features.notices) {
const condoNotices = allNotices.filter(n => n.condoId === condo.id && n.active); // Filter notices logic:
// 1. Must belong to current condo and be active
// 2. If Admin/PowerUser -> See everything
// 3. If standard User -> See Public notices (no target) OR Targeted notices containing their familyId
const isPrivileged = currentUser.role === 'admin' || currentUser.role === 'poweruser';
const condoNotices = allNotices.filter(n => {
if (n.condoId !== condo.id || !n.active) return false;
if (isPrivileged) return true;
// Check targeting
const hasTargets = n.targetFamilyIds && n.targetFamilyIds.length > 0;
if (!hasTargets) return true; // Public to all
return currentUser.familyId && n.targetFamilyIds?.includes(currentUser.familyId);
});
setNotices(condoNotices); setNotices(condoNotices);
// Check which ones are read // Check which ones are read
const readStatuses = await Promise.all(condoNotices.map(n => CondoService.getNoticeReadStatus(n.id))); const readStatuses = await Promise.all(condoNotices.map(n => CondoService.getNoticeReadStatus(n.id)));
const readIds = []; const readIds: string[] = [];
readStatuses.forEach((reads, idx) => { readStatuses.forEach((reads, idx) => {
if (reads.find(r => r.userId === currentUser.id)) { if (reads.find(r => r.userId === currentUser.id)) {
readIds.push(condoNotices[idx].id); readIds.push(condoNotices[idx].id);
@@ -182,4 +199,4 @@ export const FamilyList: React.FC = () => {
</div> </div>
</div> </div>
); );
}; };

View File

@@ -1,13 +0,0 @@
FROM node:18-alpine
WORKDIR /app
# Set production environment
ENV NODE_ENV=production
COPY package*.json ./
RUN npm install --production
COPY . .
EXPOSE 3001
CMD ["node", "server.js"]