From cfea56891da9f1eea77f6dd1c3aaf64cbea2087b Mon Sep 17 00:00:00 2001 From: "hugo.pradier2" Date: Thu, 11 Jan 2024 16:24:53 +0100 Subject: [PATCH] =?UTF-8?q?Correctif=20:=20le=20code=20envoy=C3=A9=20n=20e?= =?UTF-8?q?st=20plus=20celui=20par=20d=C3=A9faut=20mais=20le=20contenu=20d?= =?UTF-8?q?e=20l=20editeur=20directement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/editor/editor.component.html | 6 +++--- src/app/components/editor/editor.component.ts | 13 +++++++++---- src/app/services/codeExecution.service.ts | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/components/editor/editor.component.html b/src/app/components/editor/editor.component.html index 5c06bd3..4c9981c 100644 --- a/src/app/components/editor/editor.component.html +++ b/src/app/components/editor/editor.component.html @@ -8,10 +8,10 @@ mode: mode, autofocus: true }" - [ngModel]="defaults[mode]" + [(ngModel)]="editorContent" [autoFocus]="true" - (ngModelChange)="handleChange($event)" - > + > +
diff --git a/src/app/components/editor/editor.component.ts b/src/app/components/editor/editor.component.ts index c2f565c..3f5f0a6 100644 --- a/src/app/components/editor/editor.component.ts +++ b/src/app/components/editor/editor.component.ts @@ -20,6 +20,7 @@ const defaults = { styleUrls: ['./editor.component.scss'] }) export class EditorComponent implements OnInit{ + loadingProgress: number = 0; // Pour suivre la progression du chargement isLoaded: boolean = false; // Pour vérifier si le chargement est terminé @@ -31,6 +32,9 @@ export class EditorComponent implements OnInit{ }; defaults = defaults; + // Contenu de l'éditeur que l'on passera au serveur + editorContent: string = defaults[this.mode]; + constructor(private router: Router, private codeExecutionService: CodeExecutionService) {} ngOnInit(): void { @@ -56,11 +60,14 @@ export class EditorComponent implements OnInit{ } onRunButtonClicked() { - const codeToExecute = this.defaults[this.mode]; - + // Le code à exécuter est le contenu de l'éditeur + const codeToExecute = this.editorContent; + this.codeExecutionService.executeCode(codeToExecute).subscribe( (response) => { console.log('Réponse du serveur:', response); + console.log('Code qui va être exécuté:', codeToExecute); + // Redirigez vers une autre page (par exemple, 'output') this.router.navigate(['/output']); }, @@ -69,6 +76,4 @@ export class EditorComponent implements OnInit{ } ); } - - } diff --git a/src/app/services/codeExecution.service.ts b/src/app/services/codeExecution.service.ts index e9bd80a..a487009 100644 --- a/src/app/services/codeExecution.service.ts +++ b/src/app/services/codeExecution.service.ts @@ -6,7 +6,7 @@ import { Observable } from 'rxjs'; providedIn: 'root', }) export class CodeExecutionService { - private apiUrl = 'http://localhost:3000'; // Url du serveur Node.js en local + private apiUrl = 'http://localhost:3000/run'; // Url du serveur Node.js en local constructor(private http: HttpClient) {}