feat(back-end):improvement
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
<h1>{{ 'CALC.TITLE' | translate }}</h1>
|
||||
<p class="subtitle">{{ 'CALC.SUBTITLE' | translate }}</p>
|
||||
|
||||
@if (error()) {
|
||||
@if (error() === 'VIRUS_DETECTED') {
|
||||
<app-alert type="error">{{ 'CALC.ERROR_VIRUS' | translate }}</app-alert>
|
||||
} @else if (error()) {
|
||||
<app-alert type="error">{{ 'CALC.ERROR_GENERIC' | translate }}</app-alert>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -26,7 +26,7 @@ export class CalculatorPageComponent implements OnInit {
|
||||
loading = signal(false);
|
||||
uploadProgress = signal(0);
|
||||
result = signal<QuoteResult | null>(null);
|
||||
error = signal<boolean>(false);
|
||||
error = signal<string | null>(null);
|
||||
|
||||
orderSuccess = signal(false);
|
||||
|
||||
@@ -141,7 +141,7 @@ export class CalculatorPageComponent implements OnInit {
|
||||
this.currentRequest = req;
|
||||
this.loading.set(true);
|
||||
this.uploadProgress.set(0);
|
||||
this.error.set(false);
|
||||
this.error.set(null);
|
||||
this.result.set(null);
|
||||
this.orderSuccess.set(false);
|
||||
|
||||
@@ -175,8 +175,12 @@ export class CalculatorPageComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
this.error.set(true);
|
||||
error: (err) => {
|
||||
if (typeof err === 'string') {
|
||||
this.error.set(err);
|
||||
} else {
|
||||
this.error.set('GENERIC');
|
||||
}
|
||||
this.loading.set(false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -215,7 +215,8 @@ export class QuoteEstimatorService {
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Item upload failed', err);
|
||||
finalResponses[index] = { success: false, fileName: item.file.name };
|
||||
const errorMsg = err.error?.code === 'VIRUS_DETECTED' ? 'VIRUS_DETECTED' : 'UPLOAD_FAILED';
|
||||
finalResponses[index] = { success: false, fileName: item.file.name, error: errorMsg };
|
||||
completedRequests++;
|
||||
checkCompletion();
|
||||
}
|
||||
@@ -262,7 +263,13 @@ export class QuoteEstimatorService {
|
||||
});
|
||||
|
||||
if (validCount === 0) {
|
||||
observer.error('All calculations failed.');
|
||||
// Check if any failed due to virus
|
||||
const virusError = responses.find(r => r.error === 'VIRUS_DETECTED');
|
||||
if (virusError) {
|
||||
observer.error('VIRUS_DETECTED');
|
||||
} else {
|
||||
observer.error('All calculations failed.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
"CTA_START": "Start Now",
|
||||
"BUSINESS": "Business",
|
||||
"PRIVATE": "Private",
|
||||
"MODE_EASY": "Quick",
|
||||
"MODE_EASY": "Easy Print",
|
||||
"MODE_ADVANCED": "Advanced",
|
||||
"UPLOAD_LABEL": "Drag your 3D file here",
|
||||
"UPLOAD_SUB": "Supports STL, 3MF, STEP, OBJ up to 50MB",
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"CTA_START": "Inizia Ora",
|
||||
"BUSINESS": "Aziende",
|
||||
"PRIVATE": "Privati",
|
||||
"MODE_EASY": "Base",
|
||||
"MODE_EASY": "Stampa Facile",
|
||||
"MODE_ADVANCED": "Avanzata",
|
||||
"UPLOAD_LABEL": "Trascina il tuo file 3D qui",
|
||||
"UPLOAD_SUB": "Supportiamo STL, 3MF, STEP, OBJ fino a 50MB",
|
||||
|
||||
Reference in New Issue
Block a user