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