add multiroom
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details

pull/11/head
Bastien OLLIER 11 months ago
parent 7d0fc24b8c
commit 89e1fff2c1

@ -62,7 +62,7 @@
<button
class="button-join"
type="button"
(click)="onRunButtonClicked()"
(click)="onCreateRoomButtonClicked()"
[disabled]="isLoaded">
Créer une salle
</button>

@ -46,7 +46,6 @@ svg {
color: white;
padding: 12px 16px;
font-size: 16px;
width: 100px;
cursor: pointer;
border-radius: 10px;
}

@ -1,11 +1,12 @@
import { Component, Input, ViewChild } from '@angular/core';
import { CodeExecutionService } from 'src/app/services/codeExecution.service';
import { BackendService } from 'src/app/services/backendService.service';
import { Compartment, StateEffect } from '@codemirror/state';
import { CodeMirrorComponent } from '@sandkasten/codemirror6-editor';
import { LanguageDescription } from '@codemirror/language';
import { CODE_DEFAULTS, LANGUAGES } from '../languages';
import { SafeHTMLPipe } from '../../safe-html.pipe';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import {
keymap,
highlightSpecialChars,
@ -157,13 +158,22 @@ export class EditorComponent {
});
}
constructor(private codeExecutionService: CodeExecutionService) {}
constructor(
private router: Router,
private codeExecutionService: BackendService
) {}
// Efface le contenu de l'éditeur
clear(): void {
this.editorContent = '';
}
async onCreateRoomButtonClicked() {
const idRoom = await this.codeExecutionService.createRoom();
console.log(idRoom);
this.router.navigate([`./editor-live/${idRoom}`]);
}
onRunButtonClicked() {
// Le code à exécuter est le contenu de l'éditeur
const codeToExecute = this.editorContent;

@ -10,14 +10,19 @@ export type ExecutionMessage = {
@Injectable({
providedIn: 'root',
})
export class CodeExecutionService {
private apiUrl = 'http://localhost:3000/run';
export class BackendService {
private apiUrl = 'http://localhost:3000';
private resultSubject = new Subject<ExecutionMessage>();
constructor() {}
async createRoom() {
const reponse = await fetch(this.apiUrl + '/live');
return reponse.text();
}
executeCode(code: string, language: string) {
const sse = new SSE(this.apiUrl, {
const sse = new SSE(this.apiUrl + '/run', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Loading…
Cancel
Save