Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/api/api/config/ai.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ export const AI_CONFIG = {
branding: {
logo: {
provider: LLMProvider.GEMINI,
modelName: 'gemini-2.5-flash',
modelName: 'gemini-3-flash-preview',
llmOptions: {
maxOutputTokens: 1600,
maxOutputTokens: 4000,
temperature: 0.5,
topP: 0.95,
topK: 40,
Expand Down
2 changes: 2 additions & 0 deletions apps/api/api/config/cors.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ export function buildCorsOptions(): CorsOptions {
],
exposedHeaders: ['Content-Type', 'Cache-Control', 'Connection', 'X-Accel-Buffering'],
maxAge: 600,
optionsSuccessStatus: 200,
};
}

14 changes: 13 additions & 1 deletion apps/api/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,21 @@ app.use((req: Request, res: Response) => {

app.use((err: Error, req: Request, res: Response /*, next: NextFunction */) => {
console.error('Global error handler:', err);
res.status(500).send('Something broke!');

// S'assurer que les en-têtes CORS sont présents même en cas d'erreur
const origin = req.headers.origin;
if (origin) {
res.setHeader('Access-Control-Allow-Origin', origin);
res.setHeader('Access-Control-Allow-Credentials', 'true');
}

res.status(500).json({
error: 'Internal Server Error',
message: err.message || 'Something broke!'
});
});


async function bootstrap() {
await loadSecrets();
initFirebase();
Expand Down
11 changes: 11 additions & 0 deletions apps/api/api/routes/branding.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export const brandingRoutes = Router();

const resourceName = 'brandings';

// Middleware to extend connection timeout for heavy processing tasks (AI generation, PDF, etc.)
const extendedTimeout = (req: any, res: any, next: any) => {
req.setTimeout(180000); // 3 minutes
res.setTimeout(180000); // 3 minutes
next();
};


// All routes are protected and project-specific where applicable

// Generate a new branding for a project
Expand Down Expand Up @@ -207,6 +215,7 @@ brandingRoutes.post(
brandingRoutes.post(
`/${resourceName}/generate/logo-concepts/:projectId`,
authenticate,
extendedTimeout,
checkQuota,
generateLogoConceptsController
);
Expand Down Expand Up @@ -263,6 +272,7 @@ brandingRoutes.post(
brandingRoutes.post(
`/${resourceName}/generate/logo-variations/:projectId`,
authenticate,
extendedTimeout,
checkQuota,
generateLogoVariationsController
);
Expand Down Expand Up @@ -700,6 +710,7 @@ brandingRoutes.get(
brandingRoutes.post(
`/${resourceName}/edit-logo/:projectId`,
authenticate,
extendedTimeout,
checkQuota,
editLogoController
);
13 changes: 13 additions & 0 deletions apps/api/api/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import fsExtra from 'fs-extra';
import path from 'path';
import { storageService } from './storage.service';
import { v4 as uuidv4 } from 'uuid';
import { cacheService } from './cache.service';

class ProjectService {
private projectRepository: IRepository<ProjectModel>;
Expand Down Expand Up @@ -206,6 +207,12 @@ class ProjectService {
const success = await this.projectRepository.delete(projectId, `users/${userId}/projects`);
if (success) {
logger.info(`Project ${projectId} deleted successfully for user ${userId} via repository`);

// Invalider le cache du projet dans Redis
const projectCacheKey = `project_${userId}_${projectId}`;
await cacheService.delete(projectCacheKey, { prefix: 'project' }).catch((err) => {
logger.error(`Error invalidating project cache for key ${projectCacheKey}:`, err);
});
} else {
logger.warn(
`Project ${projectId} not found for deletion or delete failed for user ${userId} via repository`
Expand Down Expand Up @@ -238,6 +245,12 @@ class ProjectService {
);
if (updatedProject) {
logger.info(`Project ${projectId} updated successfully for user ${userId} via repository`);

// Invalider le cache du projet dans Redis
const projectCacheKey = `project_${userId}_${projectId}`;
await cacheService.delete(projectCacheKey, { prefix: 'project' }).catch((err) => {
logger.error(`Error invalidating project cache for key ${projectCacheKey}:`, err);
});
} else {
logger.warn(
`Project ${projectId} not found for update or update failed for user ${userId} via repository`
Expand Down
22 changes: 13 additions & 9 deletions apps/ideploy/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,61 @@ export class CompleteBrandingPage implements OnInit {
next: (project) => {
this.project.set(project);
this.isLoading.set(false);

// Restaurer l'étape et l'état en fonction des données existantes
const branding = project?.analysisResultModel?.branding;
if (branding) {
const hasAiPreferences = !!branding.logoPreferences;
const hasGeneratedLogos = !!(branding.generatedLogos && branding.generatedLogos.length > 0);

if (hasAiPreferences || hasGeneratedLogos) {
this.logoChoice.set('ai');
if (branding.logoPreferences) {
this.aiLogoPreferences.set(branding.logoPreferences);
}
} else if (branding.logo) {
this.logoChoice.set('import');
this.logoImportComplete.set(true);
}

let targetStepIndex = 0;
const choice = this.logoChoice();

if (choice === 'import') {
if (branding.colors) this.colorSelected.set(true);
if (branding.typography) this.typographySelected.set(true);

if (branding.logo && branding.colors && branding.typography) {
targetStepIndex = 3; // overview
} else if (branding.logo && branding.colors) {
targetStepIndex = 2; // typography
} else if (branding.logo) {
targetStepIndex = 1; // colors
}
} else if (choice === 'ai') {
if (branding.colors) this.colorSelected.set(true);
if (branding.typography) this.typographySelected.set(true);

const hasLogo = !!branding.logo;
const hasVariations = !!branding.logo?.variations?.withText;

if (hasLogo && hasVariations) {
targetStepIndex = 6; // overview
} else if (hasLogo) {
targetStepIndex = 5; // logo-variations
} else if (branding.logoPreferences) {
targetStepIndex = 4; // logo-selection
} else if (branding.typography) {
targetStepIndex = 3; // logo-preferences
} else if (branding.colors) {
targetStepIndex = 2; // typography
} else {
targetStepIndex = 1; // colors
}
}

this.currentStepIndex.set(targetStepIndex);
}
},
error: () => {
this.isLoading.set(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ export class LogoSelectionComponent implements OnInit, OnDestroy {
customDescription: firstLogo.customDescription,
});
}

// Sélectionner automatiquement le logo existant s'il y en a un, sinon le premier logo
const currentSelectedLogo = this.project()?.analysisResultModel?.branding?.logo;
if (currentSelectedLogo && currentSelectedLogo.id) {
this.selectedLogoId.set(currentSelectedLogo.id);
} else if (this.logos()!.length > 0) {
// Retarder légèrement pour laisser le temps aux signaux de se stabiliser
setTimeout(() => {
this.selectLogo(this.logos()![0].id!);
}, 100);
}
}
}

Expand Down Expand Up @@ -281,6 +292,11 @@ export class LogoSelectionComponent implements OnInit, OnDestroy {
this.currentStep.set(
this.translate.instant('dashboard.logoSelection.progress.completed'),
);

// Sélectionner automatiquement le premier logo généré
if (logosWithUniqueIds.length > 0) {
this.selectLogo(logosWithUniqueIds[0].id);
}
}, 1000);
},
error: (error) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,50 @@ export class LogoVariationsComponent implements OnInit, OnDestroy {
};

ngOnInit(): void {
// Auto-start generation when component loads
console.log(this.project().analysisResultModel.branding.logo.variations);
if (this.selectedLogo() && !this.project().analysisResultModel.branding.logo.variations) {
const existingVariations = this.project().analysisResultModel?.branding?.logo?.variations;
if (existingVariations) {
console.log('Using existing logo variations:', existingVariations);
const variations: DisplayVariation[] = [];

if (existingVariations.withText) {
const withText = existingVariations.withText;
if (withText.lightBackground) {
variations.push({
id: 'lightBackground',
background: 'lightBackground',
label: this.translate.instant('dashboard.logoVariations.labels.lightBackground'),
svgContent: withText.lightBackground,
description: this.translate.instant('dashboard.logoVariations.descriptions.lightBackground'),
backgroundColor: '#ffffff',
});
}
if (withText.darkBackground) {
variations.push({
id: 'darkBackground',
background: 'darkBackground',
label: this.translate.instant('dashboard.logoVariations.labels.darkBackground'),
svgContent: withText.darkBackground,
description: this.translate.instant('dashboard.logoVariations.descriptions.darkBackground'),
backgroundColor: '#1f2937',
});
}
if (withText.monochrome) {
variations.push({
id: 'monochrome',
background: 'monochrome',
label: this.translate.instant('dashboard.logoVariations.labels.monochrome'),
svgContent: withText.monochrome,
description: this.translate.instant('dashboard.logoVariations.descriptions.monochrome'),
backgroundColor: '#f3f4f6',
});
}
}

this.generatedVariations.set(variations);
this.isCompleted.set(true);
this.variationsGenerated.emit(existingVariations);
} else if (this.selectedLogo()) {
this.startVariationGeneration();
} else {
this.variationsGenerated.emit(this.project().analysisResultModel.branding.logo.variations!);
}
}

Expand Down
Loading