improvment: progression bar added to cases attachment card. upload size restrictions removed.
This commit is contained in:
@@ -16,7 +16,8 @@ alwaysApply: false
|
||||
- **Share link:** QR + URL when the case is sent **or** a lab-origin case is started; token API + focus page — see `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
- **One plan:** a live case has one prosthesis plan. Clinic send still uses `treatmentDetailId` as `sourceKey`. Lab-origin cases use the case id. Outsource children use the child case id, or `childId:parentSourceKey` when two selected steps would collide (see Outsource). `LabCaseLine` is gone. Detail and New case use `UnderlineTabs`: Details, Files, Messages. Origin is one combobox of linked clinics and labs, or a typed name. Dentist/Technician stays optional. Arch jobs (`UA`/`LA`) highlight the read-only FDI chart.
|
||||
- **Case Sheet PDF:** same layout for portrait and landscape (Download PDF menu). One A4 page, scaled to fit — the chart is never split. Header is a flex row: current organization name (one line, 48px line box so html2canvas does not clip the glyphs), Nudentic lockup aligned with that text, share QR at 88px inside a 96px frame with `fill` off (a stretched SVG is dropped by html2canvas; not a table cell). The page stays LTR in every locale. On `fa`, the org name is a shrink-wrapped `inline-block` (`direction: ltr` unless the name itself contains Arabic script) with `letter-spacing` and `word-spacing` `0px` — a full-width RTL box gaps Latin words. Party and meta values use `printRtlValueStyle` (Arabic script stays RTL; Latin stays LTR and right-aligned). `FA_RULE_DROP` (6px) clears Persian descenders. `onclone` must not overwrite the name span’s direction. Print ink is `prosthesisTypePrintColorFromCatalog` (heaviest family swatch). Prosthesis rows are SVG boxes. Chart is 85% of the page width with capped glyph height, shared upper column widths, outline-only unselected teeth, root vs crown fills, a larger gap under the upper caption, and matching tooth/number/midline gaps on both arches. Bridge marks match the FDI chart: 10px `#009cae` dots on the column boundary in the tooth-to-number gap. `onclone` sizes the lockup SVGs and the organization-name line box. Hex inline styles only. Optional `externalCode` replaces the order number.
|
||||
- **Detail chrome:** **Mark as important** is centered in the header. Edit and Outsource are at the top of the end column. External code sits under the progress bar in the start column, same width as the bar; billed price is under that. Get PDF, Add case, and Add files are primary `CaseLifecycleButton`s with no icon, the same width as Outsource. There is no Comments button, and opening Messages does not scroll the page. File cards: name at the start and checkbox at the end, then a clipped preview, then size over date at the start with the View/Download menu centered at the end. The sent-date line reads “Outsource {date}”.
|
||||
- **Detail chrome:** **Mark as important** is centered in the header on `lg`. Below that, the header is one compact stack: name and a 56px QR on the first row, mobile/from/date on one wrapping line, the progress bar without a separate “tasks completed” sentence, important and billed on one row, and Edit / Outsource / Get PDF sharing one row (`responsiveFill`). External code sits under the progress bar in the start column, same width as the bar; billed price is under important on `lg`. Get PDF, Add case, and Add files are primary `CaseLifecycleButton`s with no icon, the same width as Outsource from `lg` up. There is no Comments button, and opening Messages does not scroll the page. File cards: name at the start and checkbox at the end, then a clipped preview, then size over date at the start with the View/Download menu centered at the end. An in-progress upload is its own card with a progress bar. The sent-date line reads “Outsource {date}”.
|
||||
- **Attachments:** no size cap. One file per request, streamed with `orgDiskStorage` (not memory). The client has no axios timeout. Nginx `/api` uses `client_max_body_size 0`. Do not set `Content-Type: multipart/form-data` by hand.
|
||||
- **Drafts rail:** unstarted lab-origin cases sit in a collapsed `TreatmentRailSection`; expands on click or **Add case**. Main list is received + started cases (`drafts=exclude` / `drafts=only`), newest first by `listedAt` (`LAB_CASE_LIST_ORDER_BY`; trigger `lab_cases_listed_at_sync` = `COALESCE(startedAt, sentAt)`). Never `orderBy startedAt, sentAt` and never a `GENERATED ALWAYS` `listedAt`.
|
||||
- **Add case / Start / Delete draft:** `TAB_CASES_EDIT`. Delete only unstarted lab-origin drafts (`origin === LAB_INTERNAL && !startedAt`). Comments on Cases accept `TAB_CASES_*` (owners are not blocked by Tasks opt-in).
|
||||
|
||||
|
||||
@@ -47,7 +47,8 @@ List item shape: `prosthesisGroups: { prosthesisTypeCode, teeth[], ponticTeeth?
|
||||
- Comments: shared `LabCaseCommentsPanel` + `tasksApi` comment routes (`viewerSide="LAB"`). Newest-first; sent/received use logical start/end alignment (RTL-safe). Compact `h-9` composer with primary send + visibility controls. Lab-origin cases (`LAB_INTERNAL`, including after Start) are visible to lab comments/mark-read — do not require `sentAt` / `LabCaseSend`. Generated cases hide the eye until a linked clinic is selected; that eye publishes the comment to the clinic. A linked lab reads the thread on the share page and does not use the eye. Received cases use it for the clinic. Lab-to-lab cases use the same eye button for the sending lab: off keeps the comment on this lab, on shows it in that lab's handoff and notifies them. Comments that already existed on a lab-to-lab case stay shared.
|
||||
- Mark read: `POST /notifications/mark-case-read` on select (Cases tab badge)
|
||||
- FDI chart (`CaseToothChartPanel`): prosthesis colors + **connected bridge dots** from `selectionGroupId` (`buildCaseConnectedTeeth` / `buildCaseProsthesisRows` in `caseDetailUtils.ts`).
|
||||
- **Important + external code** (`TAB_CASES_EDIT`): **Mark as important** is centered in the header. External code is under the progress bar in the start column, same width as the bar (no title; placeholder only); billed price is under that. Save code on blur → `PATCH /cases/:id/external-code`. Edit, Outsource, Get PDF, Add case, and Add files use `CaseLifecycleButton` (primary, no icon; Treatment Lab dispatch / Chart / Add detail width). There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use that same width. The sent-date line is `cases.sentAt` (“Outsource {date}”). File cards (`CaseFilesPanel`): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end.
|
||||
- **Important + external code** (`TAB_CASES_EDIT`): **Mark as important** is centered in the header on `lg`. Below `lg` the header is one compact stack: name and a 56px QR on the first row, mobile / from / date on one wrapping line, the progress bar (no separate “tasks completed” sentence), important and billed on one row, and Edit / Outsource / Get PDF sharing one row (`CaseLifecycleButton` `responsiveFill`). External code is under the progress bar in the start column, same width as the bar (no title; placeholder only); billed price is under important on `lg`. Save code on blur → `PATCH /cases/:id/external-code`. Edit, Outsource, Get PDF, Add case, and Add files use `CaseLifecycleButton` (primary, no icon; Treatment Lab dispatch / Chart / Add detail width from `lg` up). There is no Comments button. Opening Messages does not scroll the page. Start and Delete on a draft use that same width. The sent-date line is `cases.sentAt` (“Outsource {date}”). File cards (`CaseFilesPanel`): name at the start and checkbox at the end, a clipped preview between them and the footer, then size over date at the start with the View/Download menu centered at the end. Each file being uploaded is its own card with a progress bar (one request per file).
|
||||
- **Attachment uploads:** no size limit in multer, axios, or nginx `/api` (`client_max_body_size 0`, `client_body_timeout 3600s`, `proxy_request_buffering off`). Files stream to disk via `orgDiskStorage` under `uploads/lab-cases/{orgId}` (treatment uploads use `uploads/treatments`). Do not buffer the file in memory and do not set `Content-Type: multipart/form-data` yourself — that drops the boundary. A previous 50MB nginx cap, a 120s axios timeout, and `memoryStorage` are why scans around 80MB failed.
|
||||
- **Case Sheet PDF** — see below.
|
||||
- **Share link (sent cases):** `shareUrl` on detail; attachment preview left + QR thumb right; `LabCaseShareQrDialog` (`react-qr-code`). Full flow: `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
|
||||
|
||||
30
backend/src/common/org-disk-storage.ts
Normal file
30
backend/src/common/org-disk-storage.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { randomUUID } from 'crypto';
|
||||
import { mkdirSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import type { Request } from 'express';
|
||||
import { diskStorage } from 'multer';
|
||||
|
||||
/**
|
||||
* Stream an upload onto disk under uploads/{folder}/{organizationId}.
|
||||
* There is no file-size cap. Memory storage was holding the whole file in RAM,
|
||||
* which dropped large scans once the process ran out of memory.
|
||||
*/
|
||||
export function orgDiskStorage(folder: 'lab-cases' | 'treatments') {
|
||||
return diskStorage({
|
||||
destination(req, _file, cb) {
|
||||
const orgId = (req as Request & { user?: { organizationId?: string } }).user
|
||||
?.organizationId;
|
||||
if (!orgId) {
|
||||
cb(new Error('missing organization'), '');
|
||||
return;
|
||||
}
|
||||
const dir = join(process.cwd(), 'uploads', folder, orgId);
|
||||
mkdirSync(dir, { recursive: true });
|
||||
cb(null, dir);
|
||||
},
|
||||
filename(_req, file, cb) {
|
||||
const safe = file.originalname.replace(/[^\w.\-()+]/g, '_');
|
||||
cb(null, `${randomUUID()}-${safe}`);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { FilesInterceptor } from '@nestjs/platform-express';
|
||||
import { memoryStorage } from 'multer';
|
||||
import { orgDiskStorage } from '../../common/org-disk-storage';
|
||||
import type { Response } from 'express';
|
||||
import { ApiBearerAuth, ApiConsumes, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { LabOrgGuard } from '../../common/guards/lab-org.guard';
|
||||
@@ -157,7 +157,7 @@ export class CasesController {
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(
|
||||
FilesInterceptor('files', 20, {
|
||||
storage: memoryStorage(),
|
||||
storage: orgDiskStorage('lab-cases'),
|
||||
}),
|
||||
)
|
||||
uploadAttachments(
|
||||
|
||||
@@ -3,8 +3,7 @@ import {
|
||||
Injectable,
|
||||
} from '@nestjs/common';
|
||||
import { AppException, ErrorCode } from '../../common/errors';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { createReadStream, existsSync, mkdirSync, unlinkSync } from 'fs';
|
||||
import { createReadStream, existsSync, unlinkSync } from 'fs';
|
||||
import { join, resolve, sep } from 'path';
|
||||
import { CatalogEntityKind, LabCaseActivityType, LabCaseOrigin, LabTaskStatus, LinkStatus, Prisma, UserNotificationType } from '@prisma/client';
|
||||
import { PrismaService } from '../../../prisma/prisma.service';
|
||||
@@ -1046,9 +1045,6 @@ export class CasesService {
|
||||
throw new AppException(ErrorCode.TREATMENT_FILE_REQUIRED, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
const orgDir = join(this.uploadRoot, labOrganizationId);
|
||||
mkdirSync(orgDir, { recursive: true });
|
||||
|
||||
const created: {
|
||||
id: string;
|
||||
fileName: string;
|
||||
@@ -1057,29 +1053,34 @@ export class CasesService {
|
||||
}[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
const storageName = `${randomUUID()}-${file.originalname.replace(/[^\w.\-()+]/g, '_')}`;
|
||||
const storagePath = join(orgDir, storageName);
|
||||
const { writeFileSync } = await import('fs');
|
||||
writeFileSync(storagePath, file.buffer);
|
||||
const storagePath = file.path;
|
||||
if (!storagePath) {
|
||||
throw new AppException(ErrorCode.TREATMENT_FILE_REQUIRED, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
const attachment = await this.prisma.treatmentDetailAttachment.create({
|
||||
data: {
|
||||
detailClientKey: null,
|
||||
fileName: file.originalname,
|
||||
mimeType: file.mimetype || 'application/octet-stream',
|
||||
sizeBytes: file.size,
|
||||
storagePath,
|
||||
},
|
||||
});
|
||||
await this.prisma.labCaseAttachment.create({
|
||||
data: { labCaseId, attachmentId: attachment.id },
|
||||
});
|
||||
created.push({
|
||||
id: attachment.id,
|
||||
fileName: attachment.fileName,
|
||||
mimeType: attachment.mimeType,
|
||||
sizeBytes: attachment.sizeBytes,
|
||||
});
|
||||
try {
|
||||
const attachment = await this.prisma.treatmentDetailAttachment.create({
|
||||
data: {
|
||||
detailClientKey: null,
|
||||
fileName: file.originalname,
|
||||
mimeType: file.mimetype || 'application/octet-stream',
|
||||
sizeBytes: file.size,
|
||||
storagePath,
|
||||
},
|
||||
});
|
||||
await this.prisma.labCaseAttachment.create({
|
||||
data: { labCaseId, attachmentId: attachment.id },
|
||||
});
|
||||
created.push({
|
||||
id: attachment.id,
|
||||
fileName: attachment.fileName,
|
||||
mimeType: attachment.mimeType,
|
||||
sizeBytes: attachment.sizeBytes,
|
||||
});
|
||||
} catch (error) {
|
||||
this.removeStoredFiles([storagePath]);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true, data: created };
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { FilesInterceptor } from '@nestjs/platform-express';
|
||||
import { ApiBearerAuth, ApiBody, ApiConsumes, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { memoryStorage } from 'multer';
|
||||
import { orgDiskStorage } from '../../common/org-disk-storage';
|
||||
import type { Response } from 'express';
|
||||
import { ClinicOrgGuard } from '../../common/guards/clinic-org.guard';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
@@ -177,7 +177,7 @@ export class TreatmentsController {
|
||||
})
|
||||
@UseInterceptors(
|
||||
FilesInterceptor('files', 20, {
|
||||
storage: memoryStorage(),
|
||||
storage: orgDiskStorage('treatments'),
|
||||
}),
|
||||
)
|
||||
uploadDetailAttachments(
|
||||
@@ -202,7 +202,7 @@ export class TreatmentsController {
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(
|
||||
FilesInterceptor('files', 20, {
|
||||
storage: memoryStorage(),
|
||||
storage: orgDiskStorage('treatments'),
|
||||
}),
|
||||
)
|
||||
uploadDetailAttachmentsLegacy(
|
||||
@@ -372,7 +372,7 @@ export class TreatmentsController {
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(
|
||||
FilesInterceptor('files', 20, {
|
||||
storage: memoryStorage(),
|
||||
storage: orgDiskStorage('treatments'),
|
||||
}),
|
||||
)
|
||||
uploadDetailAttachmentsByTreatment(
|
||||
|
||||
@@ -4,9 +4,8 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { AppException, ErrorCode } from '../../common/errors';
|
||||
import { LabCaseActivityType, LabTaskStatus, LinkStatus, Prisma, UserNotificationType } from '@prisma/client';
|
||||
import { createReadStream, existsSync, mkdirSync } from 'fs';
|
||||
import { createReadStream, existsSync, unlinkSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { randomUUID } from 'crypto';
|
||||
import {
|
||||
buildLabCaseShareUrl,
|
||||
generateLabCaseAccessToken,
|
||||
@@ -1349,9 +1348,6 @@ export class TreatmentsService {
|
||||
throw new AppException(ErrorCode.TREATMENT_DETAIL_SENT, HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
const orgDir = join(this.uploadRoot, organizationId);
|
||||
mkdirSync(orgDir, { recursive: true });
|
||||
|
||||
const created: {
|
||||
id: string;
|
||||
fileName: string;
|
||||
@@ -1360,23 +1356,27 @@ export class TreatmentsService {
|
||||
}[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
const storageName = `${randomUUID()}-${file.originalname.replace(/[^\w.\-()+]/g, '_')}`;
|
||||
const storagePath = join(orgDir, storageName);
|
||||
const { writeFileSync } = await import('fs');
|
||||
writeFileSync(storagePath, file.buffer);
|
||||
const storagePath = file.path;
|
||||
if (!storagePath) {
|
||||
throw new AppException(ErrorCode.TREATMENT_FILE_REQUIRED, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
const attachment = await this.prisma.treatmentDetailAttachment.create({
|
||||
data: {
|
||||
appointmentId,
|
||||
detailClientKey,
|
||||
fileName: file.originalname,
|
||||
mimeType: file.mimetype || 'application/octet-stream',
|
||||
sizeBytes: file.size,
|
||||
storagePath,
|
||||
},
|
||||
});
|
||||
|
||||
created.push(this.mapAttachment(attachment));
|
||||
try {
|
||||
const attachment = await this.prisma.treatmentDetailAttachment.create({
|
||||
data: {
|
||||
appointmentId,
|
||||
detailClientKey,
|
||||
fileName: file.originalname,
|
||||
mimeType: file.mimetype || 'application/octet-stream',
|
||||
sizeBytes: file.size,
|
||||
storagePath,
|
||||
},
|
||||
});
|
||||
created.push(this.mapAttachment(attachment));
|
||||
} catch (error) {
|
||||
if (existsSync(storagePath)) unlinkSync(storagePath);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true, data: created };
|
||||
@@ -1419,9 +1419,6 @@ export class TreatmentsService {
|
||||
throw new AppException(ErrorCode.TREATMENT_DETAIL_SENT, HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
const orgDir = join(this.uploadRoot, organizationId);
|
||||
mkdirSync(orgDir, { recursive: true });
|
||||
|
||||
const created: {
|
||||
id: string;
|
||||
fileName: string;
|
||||
@@ -1430,23 +1427,27 @@ export class TreatmentsService {
|
||||
}[] = [];
|
||||
|
||||
for (const file of files) {
|
||||
const storageName = `${randomUUID()}-${file.originalname.replace(/[^\w.\-()+]/g, '_')}`;
|
||||
const storagePath = join(orgDir, storageName);
|
||||
const { writeFileSync } = await import('fs');
|
||||
writeFileSync(storagePath, file.buffer);
|
||||
const storagePath = file.path;
|
||||
if (!storagePath) {
|
||||
throw new AppException(ErrorCode.TREATMENT_FILE_REQUIRED, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
const attachment = await this.prisma.treatmentDetailAttachment.create({
|
||||
data: {
|
||||
treatmentId,
|
||||
detailClientKey,
|
||||
fileName: file.originalname,
|
||||
mimeType: file.mimetype || 'application/octet-stream',
|
||||
sizeBytes: file.size,
|
||||
storagePath,
|
||||
},
|
||||
});
|
||||
|
||||
created.push(this.mapAttachment(attachment));
|
||||
try {
|
||||
const attachment = await this.prisma.treatmentDetailAttachment.create({
|
||||
data: {
|
||||
treatmentId,
|
||||
detailClientKey,
|
||||
fileName: file.originalname,
|
||||
mimeType: file.mimetype || 'application/octet-stream',
|
||||
sizeBytes: file.size,
|
||||
storagePath,
|
||||
},
|
||||
});
|
||||
created.push(this.mapAttachment(attachment));
|
||||
} catch (error) {
|
||||
if (existsSync(storagePath)) unlinkSync(storagePath);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
return { success: true, data: created };
|
||||
|
||||
@@ -577,6 +577,8 @@
|
||||
"filesView": "View",
|
||||
"filesMenu": "File actions",
|
||||
"filesPreviewUnavailable": "This file cannot be previewed.",
|
||||
"filesUploadProgress": "Uploading",
|
||||
"filesUploadFailed": "Upload failed",
|
||||
"partnerClinicNone": "None",
|
||||
"dueDateField": "Due date",
|
||||
"caseLinesTitle": "Work lines",
|
||||
|
||||
@@ -578,6 +578,8 @@
|
||||
"filesView": "مشاهده",
|
||||
"filesMenu": "عملیات فایل",
|
||||
"filesPreviewUnavailable": "پیشنمایش این فایل ممکن نیست.",
|
||||
"filesUploadProgress": "در حال بارگذاری",
|
||||
"filesUploadFailed": "بارگذاری انجام نشد",
|
||||
"partnerClinicNone": "هیچکدام",
|
||||
"dueDateField": "موعد",
|
||||
"caseLinesTitle": "خطوط کار",
|
||||
|
||||
@@ -578,6 +578,8 @@
|
||||
"filesView": "Bekijken",
|
||||
"filesMenu": "Bestandsacties",
|
||||
"filesPreviewUnavailable": "Dit bestand kan niet worden bekeken.",
|
||||
"filesUploadProgress": "Uploaden",
|
||||
"filesUploadFailed": "Uploaden mislukt",
|
||||
"partnerClinicNone": "Geen",
|
||||
"dueDateField": "Vervaldatum",
|
||||
"caseLinesTitle": "Werklijnen",
|
||||
|
||||
@@ -435,17 +435,17 @@ export function CaseCreatePanel({
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUpload(files: File[]) {
|
||||
if (!files.length || !canEdit) return;
|
||||
async function handleUploadFile(file: File, onProgress: (percent: number) => void) {
|
||||
if (!canEdit) return;
|
||||
uploadLockRef.current = true;
|
||||
cancelScheduledPersistRef.current();
|
||||
setUploadBusy(true);
|
||||
try {
|
||||
await persist();
|
||||
const response = await casesApi.uploadAttachments(labCase.id, files);
|
||||
const response = await casesApi.uploadAttachments(labCase.id, [file], onProgress);
|
||||
attachmentIdsRef.current = [
|
||||
...attachmentIdsRef.current,
|
||||
...response.data.map((file) => file.id),
|
||||
...response.data.map((item) => item.id),
|
||||
];
|
||||
persistAfterUploadRef.current = true;
|
||||
updatePlan((line) => ({
|
||||
@@ -454,6 +454,7 @@ export function CaseCreatePanel({
|
||||
}));
|
||||
} catch (error: unknown) {
|
||||
onError(getUserFacingError(error, tErrors, t('errorSaveCase')));
|
||||
throw error;
|
||||
} finally {
|
||||
uploadLockRef.current = false;
|
||||
setUploadBusy(false);
|
||||
@@ -633,7 +634,7 @@ export function CaseCreatePanel({
|
||||
attachments={plan.attachments}
|
||||
canAdd={canEdit}
|
||||
adding={uploadBusy}
|
||||
onAdd={(files) => void handleUpload(files)}
|
||||
onUploadFile={(file, onProgress) => handleUploadFile(file, onProgress)}
|
||||
onDownload={(file) => casesApi.getAttachmentFileBlob(labCase.id, file.id)}
|
||||
onDownloadError={(error) =>
|
||||
onError(getUserFacingError(error, tErrors, t('errorDownloadFile')))
|
||||
|
||||
@@ -260,7 +260,6 @@ export function CaseDetailPanel({
|
||||
const messages = useMessages();
|
||||
const toast = useToast();
|
||||
const [section, setSection] = useState<'details' | 'files' | 'messages'>('details');
|
||||
const [uploadingFiles, setUploadingFiles] = useState(false);
|
||||
const [prosthesisCatalog, setProsthesisCatalog] = useState<ProsthesisCatalogEntry[]>(
|
||||
prosthesisCatalogProp ?? [],
|
||||
);
|
||||
@@ -316,17 +315,15 @@ export function CaseDetailPanel({
|
||||
},
|
||||
);
|
||||
|
||||
async function handleAddFiles(files: File[]) {
|
||||
if (!files.length || !canAddFiles) return;
|
||||
setUploadingFiles(true);
|
||||
async function handleUploadFile(file: File, onProgress: (percent: number) => void) {
|
||||
if (!canAddFiles) return;
|
||||
try {
|
||||
await casesApi.uploadAttachments(labCase.id, files);
|
||||
await casesApi.uploadAttachments(labCase.id, [file], onProgress);
|
||||
const refreshed = await casesApi.getOne(labCase.id);
|
||||
onCaseUpdated?.(refreshed.data);
|
||||
} catch {
|
||||
} catch (error: unknown) {
|
||||
toast.showError(t('errorSaveCase'));
|
||||
} finally {
|
||||
setUploadingFiles(false);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,39 +409,50 @@ export function CaseDetailPanel({
|
||||
|
||||
return (
|
||||
<div className="space-y-4 min-w-0">
|
||||
<header className="grid grid-cols-1 items-start gap-4 border-b border-border pb-3 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-stretch">
|
||||
<div className="min-w-0 space-y-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<h2 className="text-lg font-semibold text-text-primary">
|
||||
{formatPatientName(labCase.patient, t('walkIn'))}
|
||||
</h2>
|
||||
<LabCaseDueDateBadge dueDate={labCase.dueDate} locale={locale} />
|
||||
<LabCaseOriginBadge origin={labCase.origin} />
|
||||
</div>
|
||||
<p className="text-sm text-text-muted">
|
||||
{t('patientMobile')}: {formatPatientMobile(labCase.patient)}
|
||||
</p>
|
||||
{headerMetaLines}
|
||||
{(labCase.sentAt || labCase.startedAt) ? (
|
||||
<p className="text-sm text-text-muted">
|
||||
{labCase.sentAt
|
||||
? t('sentAt', { date: formatCaseDateTime(labCase.sentAt, locale) })
|
||||
: t('startedAt', { date: formatCaseDateTime(labCase.startedAt ?? null, locale) })}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="max-w-xs space-y-2 pt-1">
|
||||
<div>
|
||||
<p className="text-sm text-text-muted mb-1">
|
||||
{t('taskProgressLabel', {
|
||||
completed: labCase.taskProgress.completed,
|
||||
total: labCase.taskProgress.total,
|
||||
})}
|
||||
</p>
|
||||
<CaseTaskProgressBar
|
||||
completed={labCase.taskProgress.completed}
|
||||
total={labCase.taskProgress.total}
|
||||
/>
|
||||
<header className="grid grid-cols-1 items-start gap-2 border-b border-border pb-3 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-stretch lg:gap-4">
|
||||
<div className="min-w-0 space-y-1.5">
|
||||
<div className="flex items-start gap-2">
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<h2 className="text-base font-semibold text-text-primary sm:text-lg">
|
||||
{formatPatientName(labCase.patient, t('walkIn'))}
|
||||
</h2>
|
||||
<LabCaseDueDateBadge dueDate={labCase.dueDate} locale={locale} />
|
||||
<LabCaseOriginBadge origin={labCase.origin} />
|
||||
</div>
|
||||
<div className="mt-0.5 flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-xs text-text-muted sm:text-sm">
|
||||
<span>
|
||||
{t('patientMobile')}: {formatPatientMobile(labCase.patient)}
|
||||
</span>
|
||||
{headerMetaLines ? (
|
||||
<>
|
||||
<span aria-hidden="true">·</span>
|
||||
{headerMetaLines}
|
||||
</>
|
||||
) : null}
|
||||
{labCase.sentAt || labCase.startedAt ? (
|
||||
<>
|
||||
<span aria-hidden="true">·</span>
|
||||
<span>
|
||||
{labCase.sentAt
|
||||
? t('sentAt', { date: formatCaseDateTime(labCase.sentAt, locale) })
|
||||
: t('startedAt', { date: formatCaseDateTime(labCase.startedAt ?? null, locale) })}
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
{labCase.shareUrl ? (
|
||||
<div className="shrink-0 lg:hidden">
|
||||
<LabCaseShareQr key={labCase.shareUrl} shareUrl={labCase.shareUrl} compact />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="max-w-xs space-y-1.5">
|
||||
<CaseTaskProgressBar
|
||||
completed={labCase.taskProgress.completed}
|
||||
total={labCase.taskProgress.total}
|
||||
/>
|
||||
{canEditImportant ? (
|
||||
<Input
|
||||
value={externalCodeDraft}
|
||||
@@ -466,7 +474,7 @@ export function CaseDetailPanel({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col items-center gap-2 lg:h-full">
|
||||
<div className="flex flex-row flex-wrap items-center justify-between gap-x-3 gap-y-1 lg:h-full lg:flex-col lg:items-center lg:justify-start">
|
||||
{canEditImportant ? (
|
||||
<Checkbox
|
||||
checked={labCase.isImportant ?? false}
|
||||
@@ -480,7 +488,7 @@ export function CaseDetailPanel({
|
||||
</Badge>
|
||||
) : null}
|
||||
{labCase.billedAmount != null || labCase.calculatedAmount != null ? (
|
||||
<p className="text-center text-sm text-text-secondary lg:mt-auto">
|
||||
<p className="text-xs text-text-secondary sm:text-sm lg:mt-auto lg:text-center">
|
||||
<span className="font-bold text-text-primary">{t('billedLead')}</span>
|
||||
{' '}
|
||||
{t('billedCurrencyNote')}
|
||||
@@ -493,31 +501,34 @@ export function CaseDetailPanel({
|
||||
</div>
|
||||
|
||||
<div className="flex w-full shrink-0 flex-col items-stretch gap-2 lg:items-end">
|
||||
{canStop || canSend ? (
|
||||
<div className="flex w-full flex-wrap items-center justify-end gap-2 sm:w-auto">
|
||||
{canStop && onStop ? (
|
||||
<div className="flex w-full flex-wrap items-center gap-2 lg:w-auto lg:justify-end">
|
||||
{canStop && onStop ? (
|
||||
<div className="min-w-0 flex-1 lg:flex-none">
|
||||
<CaseLifecycleButton
|
||||
variant="danger"
|
||||
label={t('stopCase')}
|
||||
isLoading={stopping}
|
||||
responsiveFill
|
||||
onClick={onStop}
|
||||
/>
|
||||
) : null}
|
||||
{canSend && onSend ? (
|
||||
</div>
|
||||
) : null}
|
||||
{canSend && onSend ? (
|
||||
<div className="min-w-0 flex-1 lg:flex-none">
|
||||
<CaseLifecycleButton
|
||||
variant="primary"
|
||||
label={t('sendCase')}
|
||||
responsiveFill
|
||||
onClick={onSend}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex w-full flex-wrap items-center justify-end gap-2 sm:w-auto">
|
||||
<div ref={sheetMenuRef} className="relative">
|
||||
</div>
|
||||
) : null}
|
||||
<div ref={sheetMenuRef} className="relative min-w-0 flex-1 lg:flex-none">
|
||||
<CaseLifecycleButton
|
||||
variant="primary"
|
||||
label={pdfLabel}
|
||||
isLoading={downloadingPdf}
|
||||
responsiveFill
|
||||
ariaExpanded={sheetMenuOpen}
|
||||
ariaHaspopup="menu"
|
||||
onClick={() => setSheetMenuOpen((open) => !open)}
|
||||
@@ -543,7 +554,7 @@ export function CaseDetailPanel({
|
||||
</div>
|
||||
</div>
|
||||
{labCase.shareUrl ? (
|
||||
<div className="flex flex-wrap items-center gap-2 shrink-0">
|
||||
<div className="hidden shrink-0 lg:block">
|
||||
<LabCaseShareQr key={labCase.shareUrl} shareUrl={labCase.shareUrl} />
|
||||
</div>
|
||||
) : null}
|
||||
@@ -565,8 +576,7 @@ export function CaseDetailPanel({
|
||||
<CaseFilesPanel
|
||||
attachments={labCase.attachments}
|
||||
canAdd={canAddFiles}
|
||||
adding={uploadingFiles}
|
||||
onAdd={(files) => void handleAddFiles(files)}
|
||||
onUploadFile={(file, onProgress) => handleUploadFile(file, onProgress)}
|
||||
onDownload={(file) => loadAttachmentBlob(labCase.id, file.id)}
|
||||
onDownloadError={() => toast.showError(t('errorDownloadFile'))}
|
||||
/>
|
||||
|
||||
@@ -25,6 +25,14 @@ type CardPreview = {
|
||||
text?: string;
|
||||
};
|
||||
|
||||
type PendingUpload = {
|
||||
id: string;
|
||||
fileName: string;
|
||||
sizeBytes: number;
|
||||
percent: number;
|
||||
failed: boolean;
|
||||
};
|
||||
|
||||
type ViewerState = {
|
||||
fileName: string;
|
||||
kind: CaseFilePreviewKind | null;
|
||||
@@ -74,7 +82,7 @@ export function CaseFilesPanel({
|
||||
canAdd,
|
||||
adding = false,
|
||||
downloading = false,
|
||||
onAdd,
|
||||
onUploadFile,
|
||||
onDownload,
|
||||
onDownloadError,
|
||||
onRemove,
|
||||
@@ -83,7 +91,7 @@ export function CaseFilesPanel({
|
||||
canAdd: boolean;
|
||||
adding?: boolean;
|
||||
downloading?: boolean;
|
||||
onAdd: (files: File[]) => void;
|
||||
onUploadFile?: (file: File, onProgress: (percent: number) => void) => Promise<void>;
|
||||
onDownload: (attachment: LabCaseAttachmentMeta) => Promise<Blob>;
|
||||
onDownloadError?: (error: unknown) => void;
|
||||
onRemove?: (attachmentId: string) => void;
|
||||
@@ -101,6 +109,7 @@ export function CaseFilesPanel({
|
||||
const [menuId, setMenuId] = useState<string | null>(null);
|
||||
const [previews, setPreviews] = useState<Record<string, CardPreview>>({});
|
||||
const [viewer, setViewer] = useState<ViewerState | null>(null);
|
||||
const [uploads, setUploads] = useState<PendingUpload[]>([]);
|
||||
const attachmentKey = attachments.map((file) => file.id).join('\n');
|
||||
|
||||
useEffect(() => {
|
||||
@@ -288,7 +297,34 @@ export function CaseFilesPanel({
|
||||
}
|
||||
}
|
||||
|
||||
const working = busy || downloading || adding;
|
||||
const uploading = uploads.some((item) => !item.failed);
|
||||
const working = busy || downloading || adding || uploading;
|
||||
|
||||
function patchUpload(id: string, patch: Partial<PendingUpload>) {
|
||||
setUploads((prev) => prev.map((item) => (item.id === id ? { ...item, ...patch } : item)));
|
||||
}
|
||||
|
||||
async function enqueueUploads(files: File[]) {
|
||||
if (!onUploadFile || files.length === 0) return;
|
||||
const pending: PendingUpload[] = files.map((file) => ({
|
||||
id: `${file.name}-${file.size}-${file.lastModified}-${Math.random().toString(36).slice(2)}`,
|
||||
fileName: file.name,
|
||||
sizeBytes: file.size,
|
||||
percent: 0,
|
||||
failed: false,
|
||||
}));
|
||||
setUploads((prev) => [...pending, ...prev]);
|
||||
for (let index = 0; index < files.length; index += 1) {
|
||||
const item = pending[index];
|
||||
const file = files[index];
|
||||
try {
|
||||
await onUploadFile(file, (percent) => patchUpload(item.id, { percent }));
|
||||
setUploads((prev) => prev.filter((row) => row.id !== item.id));
|
||||
} catch {
|
||||
patchUpload(item.id, { failed: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
@@ -313,7 +349,7 @@ export function CaseFilesPanel({
|
||||
<CaseLifecycleButton
|
||||
variant="primary"
|
||||
label={t('filesAdd')}
|
||||
isLoading={adding}
|
||||
isLoading={adding || uploading}
|
||||
disabled={working}
|
||||
onClick={() => inputRef.current?.click()}
|
||||
/>
|
||||
@@ -324,7 +360,7 @@ export function CaseFilesPanel({
|
||||
className="hidden"
|
||||
onChange={(event) => {
|
||||
const files = event.target.files ? Array.from(event.target.files) : [];
|
||||
if (files.length) onAdd(files);
|
||||
if (files.length) void enqueueUploads(files);
|
||||
event.target.value = '';
|
||||
}}
|
||||
/>
|
||||
@@ -332,10 +368,63 @@ export function CaseFilesPanel({
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{attachments.length === 0 ? (
|
||||
{attachments.length === 0 && uploads.length === 0 ? (
|
||||
<p className="text-sm text-text-muted">{t('filesEmpty')}</p>
|
||||
) : (
|
||||
<ul className="grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(220px,1fr))]">
|
||||
{uploads.map((item) => (
|
||||
<li
|
||||
key={item.id}
|
||||
className="flex min-w-0 flex-col overflow-hidden rounded-xl border border-border bg-background-card"
|
||||
>
|
||||
<div className="flex items-center gap-2 px-3 py-2">
|
||||
<p
|
||||
className="min-w-0 flex-1 truncate text-start text-sm font-medium text-text-primary"
|
||||
title={item.fileName}
|
||||
>
|
||||
{shortFileName(item.fileName)}
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
className="flex h-40 shrink-0 flex-col items-center justify-center gap-3 bg-background-secondary px-4"
|
||||
role="progressbar"
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={item.failed ? 0 : item.percent}
|
||||
aria-label={item.failed ? t('filesUploadFailed') : t('filesUploadProgress')}
|
||||
>
|
||||
{item.failed ? (
|
||||
<p className="text-center text-sm text-red-600">{t('filesUploadFailed')}</p>
|
||||
) : (
|
||||
<>
|
||||
<div className="h-1.5 w-full overflow-hidden rounded-full bg-border">
|
||||
<div
|
||||
className={`h-full rounded-full bg-primary ${item.percent ? 'transition-[width]' : 'animate-pulse'}`}
|
||||
style={{ width: `${Math.max(item.percent, 8)}%` }}
|
||||
/>
|
||||
</div>
|
||||
<p className="text-xs text-text-secondary">
|
||||
{formatAppNumber(item.percent, locale)}%
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-2 px-3 py-2">
|
||||
<p className="min-w-0 flex-1 truncate text-start text-xs text-text-secondary">
|
||||
{formatFileSize(item.sizeBytes)}
|
||||
</p>
|
||||
{item.failed ? (
|
||||
<button
|
||||
type="button"
|
||||
className="shrink-0 text-xs text-text-secondary hover:text-text-primary"
|
||||
onClick={() => setUploads((prev) => prev.filter((row) => row.id !== item.id))}
|
||||
>
|
||||
{t('filesRemove')}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
{attachments.map((file) => {
|
||||
const checked = selected.includes(file.id);
|
||||
const preview = previews[file.id];
|
||||
|
||||
@@ -15,6 +15,8 @@ type CaseLifecycleButtonProps = {
|
||||
isLoading?: boolean;
|
||||
ariaExpanded?: boolean;
|
||||
ariaHaspopup?: 'menu';
|
||||
/** Fill the row below the lg breakpoint. Desktop keeps the shared label width. */
|
||||
responsiveFill?: boolean;
|
||||
onClick: () => void;
|
||||
};
|
||||
|
||||
@@ -27,6 +29,7 @@ export function CaseLifecycleButton({
|
||||
isLoading,
|
||||
ariaExpanded,
|
||||
ariaHaspopup,
|
||||
responsiveFill = false,
|
||||
onClick,
|
||||
}: CaseLifecycleButtonProps) {
|
||||
const t = useTranslations('cases');
|
||||
@@ -48,7 +51,7 @@ export function CaseLifecycleButton({
|
||||
type="button"
|
||||
variant={variant}
|
||||
size="sm"
|
||||
className={WORKSPACE_ACTION_BTN_CLASS}
|
||||
className={`${WORKSPACE_ACTION_BTN_CLASS}${responsiveFill ? ' w-full min-w-0 lg:w-auto' : ''}`}
|
||||
disabled={disabled}
|
||||
isLoading={isLoading}
|
||||
aria-expanded={ariaExpanded}
|
||||
@@ -61,13 +64,17 @@ export function CaseLifecycleButton({
|
||||
{widthLabels.map((text, index) => (
|
||||
<span
|
||||
key={`${index}-${text}`}
|
||||
className="invisible col-start-1 row-start-1 whitespace-nowrap"
|
||||
className={`invisible col-start-1 row-start-1 whitespace-nowrap${responsiveFill ? ' hidden lg:block' : ''}`}
|
||||
aria-hidden
|
||||
>
|
||||
{text}
|
||||
</span>
|
||||
))}
|
||||
<span className="col-start-1 row-start-1 whitespace-nowrap">{label}</span>
|
||||
<span
|
||||
className={`col-start-1 row-start-1 whitespace-nowrap${responsiveFill ? ' max-lg:truncate' : ''}`}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</Button>
|
||||
|
||||
@@ -961,9 +961,7 @@ export function CasesPage() {
|
||||
canAddFiles={canEdit}
|
||||
onCaseUpdated={setSelectedCase}
|
||||
headerMetaLines={
|
||||
<p className="text-sm text-text-muted">
|
||||
{t('fromClinic', { name: selectedCase.clinic.name })}
|
||||
</p>
|
||||
<span>{t('fromClinic', { name: selectedCase.clinic.name })}</span>
|
||||
}
|
||||
commentsSection={
|
||||
selectedCaseId ? (
|
||||
|
||||
@@ -84,18 +84,28 @@ interface LabCaseShareQrThumbProps {
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export function LabCaseShareQrThumb({ shareUrl, onClick }: LabCaseShareQrThumbProps) {
|
||||
export function LabCaseShareQrThumb({
|
||||
shareUrl,
|
||||
onClick,
|
||||
compact = false,
|
||||
}: LabCaseShareQrThumbProps & { compact?: boolean }) {
|
||||
const t = useTranslations('cases');
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className="aspect-square w-24 sm:w-32 cursor-pointer rounded-[var(--radius-md)] border border-border/60 overflow-hidden bg-white p-2 transition-colors hover:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary flex items-center justify-center"
|
||||
className={`aspect-square cursor-pointer overflow-hidden rounded-[var(--radius-md)] border border-border/60 bg-white transition-colors hover:border-primary/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary flex items-center justify-center ${
|
||||
compact ? 'w-14 p-1' : 'w-24 p-2 sm:w-32'
|
||||
}`}
|
||||
title={t('viewShareQr')}
|
||||
aria-label={t('viewShareQr')}
|
||||
>
|
||||
<LabCaseShareQrCode value={shareUrl} size={96} className="h-full w-full max-h-full max-w-full" />
|
||||
<LabCaseShareQrCode
|
||||
value={shareUrl}
|
||||
size={compact ? 48 : 96}
|
||||
className="h-full w-full max-h-full max-w-full"
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -104,9 +114,11 @@ export function LabCaseShareQrThumb({ shareUrl, onClick }: LabCaseShareQrThumbPr
|
||||
export function LabCaseShareQr({
|
||||
shareUrl,
|
||||
className,
|
||||
compact = false,
|
||||
}: {
|
||||
shareUrl: string;
|
||||
className?: string;
|
||||
compact?: boolean;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const url = shareUrl.trim();
|
||||
@@ -115,7 +127,7 @@ export function LabCaseShareQr({
|
||||
return (
|
||||
<>
|
||||
<div className={className}>
|
||||
<LabCaseShareQrThumb shareUrl={url} onClick={() => setOpen(true)} />
|
||||
<LabCaseShareQrThumb shareUrl={url} compact={compact} onClick={() => setOpen(true)} />
|
||||
</div>
|
||||
<LabCaseShareQrDialog open={open} onClose={() => setOpen(false)} shareUrl={url} />
|
||||
</>
|
||||
|
||||
@@ -683,7 +683,6 @@ export function TasksPage() {
|
||||
<CaseFilesPanel
|
||||
attachments={caseFiles}
|
||||
canAdd={false}
|
||||
onAdd={() => undefined}
|
||||
onDownload={(file) =>
|
||||
casesApi.getAttachmentFileBlob(caseGroup.labCaseId, file.id)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export function MobileDetailBackButton({
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className={`${HIDE_FROM_CLASS[hideFrom]} inline-flex items-center gap-1 text-sm text-primary hover:opacity-90 mb-3`}
|
||||
className={`${HIDE_FROM_CLASS[hideFrom]} mb-1.5 inline-flex items-center gap-1 text-sm text-primary hover:opacity-90`}
|
||||
>
|
||||
<ChevronLeft className="h-4 w-4 icon-flat" />
|
||||
{t('back')}
|
||||
|
||||
@@ -22,7 +22,7 @@ export function UnderlineTabs<T extends string>({
|
||||
role="tab"
|
||||
aria-selected={active}
|
||||
onClick={() => onChange(tab.id)}
|
||||
className={`-mb-px border-b-2 px-3 py-2 text-sm font-medium transition-colors ${
|
||||
className={`-mb-px border-b-2 px-3 py-2 text-base font-bold transition-colors ${
|
||||
active
|
||||
? 'border-primary text-primary'
|
||||
: 'border-transparent text-text-secondary hover:text-text-primary'
|
||||
|
||||
@@ -97,14 +97,30 @@ export const casesApi = {
|
||||
uploadAttachments: async (
|
||||
caseId: string,
|
||||
files: File[],
|
||||
onUploadProgress?: (percent: number) => void,
|
||||
): Promise<{ success: boolean; data: LabCaseAttachmentMeta[] }> => {
|
||||
const form = new FormData();
|
||||
for (const file of files) {
|
||||
form.append('files', file);
|
||||
}
|
||||
const response = await apiClient.post(`/cases/${caseId}/attachments`, form, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: 120_000,
|
||||
// No deadline and no body cap. A scan larger than ~40MB exceeds 120s on a
|
||||
// slow link, and a manual multipart header drops the boundary.
|
||||
timeout: 0,
|
||||
maxBodyLength: Infinity,
|
||||
maxContentLength: Infinity,
|
||||
transformRequest: (data, headers) => {
|
||||
if (typeof FormData !== 'undefined' && data instanceof FormData) {
|
||||
headers.delete('Content-Type');
|
||||
}
|
||||
return data;
|
||||
},
|
||||
onUploadProgress: onUploadProgress
|
||||
? (event) => {
|
||||
if (!event.total) return;
|
||||
onUploadProgress(Math.round((event.loaded / event.total) * 100));
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
@@ -166,7 +182,7 @@ export const casesApi = {
|
||||
getAttachmentFileBlob: async (caseId: string, attachmentId: string): Promise<Blob> => {
|
||||
const response = await apiClient.get(`/cases/${caseId}/attachments/${attachmentId}/file`, {
|
||||
responseType: 'blob',
|
||||
timeout: 120_000,
|
||||
timeout: 0,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -115,8 +115,15 @@ export const treatmentsApi = {
|
||||
`/treatments/${treatmentId}/details/${encodeURIComponent(detailClientId)}/attachments`,
|
||||
form,
|
||||
{
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: 120_000,
|
||||
timeout: 0,
|
||||
maxBodyLength: Infinity,
|
||||
maxContentLength: Infinity,
|
||||
transformRequest: (data, headers) => {
|
||||
if (typeof FormData !== 'undefined' && data instanceof FormData) {
|
||||
headers.delete('Content-Type');
|
||||
}
|
||||
return data;
|
||||
},
|
||||
onUploadProgress: onUploadProgress
|
||||
? (event) => {
|
||||
if (!event.total) return;
|
||||
@@ -161,8 +168,15 @@ export const treatmentsApi = {
|
||||
`/treatments/appointments/${appointmentId}/details/${encodeURIComponent(detailClientId)}/attachments`,
|
||||
form,
|
||||
{
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
timeout: 120_000,
|
||||
timeout: 0,
|
||||
maxBodyLength: Infinity,
|
||||
maxContentLength: Infinity,
|
||||
transformRequest: (data, headers) => {
|
||||
if (typeof FormData !== 'undefined' && data instanceof FormData) {
|
||||
headers.delete('Content-Type');
|
||||
}
|
||||
return data;
|
||||
},
|
||||
onUploadProgress: onUploadProgress
|
||||
? (event) => {
|
||||
if (!event.total) return;
|
||||
@@ -218,7 +232,7 @@ export const treatmentsApi = {
|
||||
getAttachmentFileBlob: async (attachmentId: string): Promise<Blob> => {
|
||||
const response = await apiClient.get(`/treatments/attachments/${attachmentId}/file`, {
|
||||
responseType: 'blob',
|
||||
timeout: 120_000,
|
||||
timeout: 0,
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
@@ -39,7 +39,13 @@ server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
# Attachments have no size cap. Stream the body so a large scan is not
|
||||
# rejected or dropped when the client pauses.
|
||||
client_max_body_size 0;
|
||||
client_body_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,13 @@ server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
# Attachments have no size cap. Stream the body so a large scan is not
|
||||
# rejected or dropped when the client pauses.
|
||||
client_max_body_size 0;
|
||||
client_body_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,13 @@ server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
# Attachments have no size cap. Stream the body so a large scan is not
|
||||
# rejected or dropped when the client pauses.
|
||||
client_max_body_size 0;
|
||||
client_body_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,13 @@ server {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
# Attachments have no size cap. Stream the body so a large scan is not
|
||||
# rejected or dropped when the client pauses.
|
||||
client_max_body_size 0;
|
||||
client_body_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ http {
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
# Unlimited at http{} so a gitea.wixur.ir vhost can inherit it (Docker layers
|
||||
# 413 with 50M). App server blocks below cap uploads at 50M.
|
||||
# 413 with 50M). The app HTML stays at 50M. /api is unlimited for attachments.
|
||||
client_max_body_size 0;
|
||||
|
||||
# Shared proxy to Docker staging
|
||||
@@ -43,6 +43,23 @@ http {
|
||||
|
||||
client_max_body_size 50M;
|
||||
|
||||
location /api {
|
||||
client_max_body_size 0;
|
||||
client_body_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
proxy_pass http://127.0.0.1:18088;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:18088;
|
||||
proxy_http_version 1.1;
|
||||
@@ -68,6 +85,23 @@ http {
|
||||
|
||||
client_max_body_size 50M;
|
||||
|
||||
location /api {
|
||||
client_max_body_size 0;
|
||||
client_body_timeout 3600s;
|
||||
proxy_request_buffering off;
|
||||
proxy_pass http://127.0.0.1:18088;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:18088;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
Reference in New Issue
Block a user