From b02aa51bede795f123efc4ed77983ffd4ae0e602 Mon Sep 17 00:00:00 2001 From: Alix JEUDI--LEMOINE Date: Thu, 29 May 2025 15:25:36 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Config=20page,=20using=20Config=20s?= =?UTF-8?q?ervice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/config/config.component.css | 0 .../components/config/config.component.html | 122 ++++++++++++++++++ src/app/components/config/config.component.ts | 57 ++++++++ 3 files changed, 179 insertions(+) create mode 100644 src/app/components/config/config.component.css create mode 100644 src/app/components/config/config.component.html create mode 100644 src/app/components/config/config.component.ts diff --git a/src/app/components/config/config.component.css b/src/app/components/config/config.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/config/config.component.html b/src/app/components/config/config.component.html new file mode 100644 index 0000000..e345b8e --- /dev/null +++ b/src/app/components/config/config.component.html @@ -0,0 +1,122 @@ +
+

Configuration du système

+ +
+
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+
+
+
\ No newline at end of file diff --git a/src/app/components/config/config.component.ts b/src/app/components/config/config.component.ts new file mode 100644 index 0000000..6fb7468 --- /dev/null +++ b/src/app/components/config/config.component.ts @@ -0,0 +1,57 @@ +import { Component, OnInit } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { ConfigService } from '../../services/config.service'; +import { SystemConfig } from '../../model/SystemConfig'; + + +@Component({ + selector: 'app-config', + templateUrl: './config.component.html', + styleUrls: ['./config.component.css'], + imports: [CommonModule, FormsModule] +}) +export class ConfigComponent implements OnInit { + config: SystemConfig = { + max_image_size: 8 * 1024 * 1024, + max_images_per_pin: 10, + max_images_per_user: 100, + allowed_image_types: ['image/jpeg', 'image/png', 'image/gif', 'image/webp'], + max_pins_per_user: 50, + max_friends_per_user: 100 + }; + + constructor(private configService: ConfigService) {} + + ngOnInit(): void { + this.loadConfig(); + } + + loadConfig(): void { + this.configService.loadConfig().subscribe(config => { + this.config = config; + }); + } + + saveConfig(): void { + this.configService.saveConfig(this.config).subscribe(config => { + this.config = config; + alert('Configuration enregistrée avec succès'); + }); + } + + resetConfig(): void { + this.loadConfig(); + } + + addImageType(): void { + this.config.allowed_image_types.push(''); + } + + removeImageType(type: string): void { + const index = this.config.allowed_image_types.indexOf(type); + if (index > -1) { + this.config.allowed_image_types.splice(index, 1); + } + } +} \ No newline at end of file