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) {}