Bug fix and format code
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f94e9e7634
commit
a86a40e845
@ -1,195 +1,197 @@
|
|||||||
import {Component, ViewChild} from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import {CodeExecutionService} from 'src/app/services/codeExecution.service';
|
import { CodeExecutionService } from 'src/app/services/codeExecution.service';
|
||||||
import {Compartment} from '@codemirror/state';
|
import { Compartment } from '@codemirror/state';
|
||||||
import {CodeMirrorComponent} from '@sandkasten/codemirror6-editor';
|
import { CodeMirrorComponent } from '@sandkasten/codemirror6-editor';
|
||||||
import {LanguageDescription} from '@codemirror/language';
|
import { LanguageDescription } from '@codemirror/language';
|
||||||
import {CODE_DEFAULTS, LANGUAGES} from '../languages';
|
import { CODE_DEFAULTS, LANGUAGES } from '../languages';
|
||||||
import {SafeHTMLPipe} from '../../safe-html.pipe';
|
import { SafeHTMLPipe } from '../../safe-html.pipe';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import {ReactiveFormsModule, FormsModule} from '@angular/forms';
|
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
||||||
import {
|
import {
|
||||||
keymap,
|
keymap,
|
||||||
highlightSpecialChars,
|
highlightSpecialChars,
|
||||||
drawSelection,
|
drawSelection,
|
||||||
highlightActiveLine,
|
highlightActiveLine,
|
||||||
dropCursor,
|
dropCursor,
|
||||||
rectangularSelection,
|
rectangularSelection,
|
||||||
crosshairCursor,
|
crosshairCursor,
|
||||||
lineNumbers,
|
lineNumbers,
|
||||||
highlightActiveLineGutter,
|
highlightActiveLineGutter,
|
||||||
gutter,
|
gutter,
|
||||||
} from '@codemirror/view';
|
} from '@codemirror/view';
|
||||||
import {Extension, EditorState} from '@codemirror/state';
|
import { Extension, EditorState } from '@codemirror/state';
|
||||||
import {
|
import {
|
||||||
defaultHighlightStyle,
|
defaultHighlightStyle,
|
||||||
syntaxHighlighting,
|
syntaxHighlighting,
|
||||||
indentOnInput,
|
indentOnInput,
|
||||||
bracketMatching,
|
bracketMatching,
|
||||||
foldGutter,
|
foldGutter,
|
||||||
foldKeymap,
|
foldKeymap,
|
||||||
} from '@codemirror/language';
|
} from '@codemirror/language';
|
||||||
import {defaultKeymap, history, historyKeymap} from '@codemirror/commands';
|
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
|
||||||
import {searchKeymap, highlightSelectionMatches} from '@codemirror/search';
|
import { searchKeymap, highlightSelectionMatches } from '@codemirror/search';
|
||||||
import {
|
import {
|
||||||
autocompletion,
|
autocompletion,
|
||||||
completionKeymap,
|
completionKeymap,
|
||||||
closeBrackets,
|
closeBrackets,
|
||||||
closeBracketsKeymap,
|
closeBracketsKeymap,
|
||||||
} from '@codemirror/autocomplete';
|
} from '@codemirror/autocomplete';
|
||||||
import {lintKeymap} from '@codemirror/lint';
|
import { lintKeymap } from '@codemirror/lint';
|
||||||
import {WorkService} from "../../services/work.service";
|
import { WorkService } from '../../services/work.service';
|
||||||
|
|
||||||
const basicSetup: Extension = (() => [
|
const basicSetup: Extension = (() => [
|
||||||
highlightActiveLineGutter(),
|
highlightActiveLineGutter(),
|
||||||
highlightSpecialChars(),
|
highlightSpecialChars(),
|
||||||
history(),
|
history(),
|
||||||
foldGutter(),
|
foldGutter(),
|
||||||
drawSelection(),
|
drawSelection(),
|
||||||
dropCursor(),
|
dropCursor(),
|
||||||
EditorState.allowMultipleSelections.of(true),
|
EditorState.allowMultipleSelections.of(true),
|
||||||
indentOnInput(),
|
indentOnInput(),
|
||||||
syntaxHighlighting(defaultHighlightStyle, {fallback: true}),
|
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
||||||
bracketMatching(),
|
bracketMatching(),
|
||||||
closeBrackets(),
|
closeBrackets(),
|
||||||
autocompletion(),
|
autocompletion(),
|
||||||
rectangularSelection(),
|
rectangularSelection(),
|
||||||
crosshairCursor(),
|
crosshairCursor(),
|
||||||
highlightActiveLine(),
|
highlightActiveLine(),
|
||||||
highlightSelectionMatches(),
|
highlightSelectionMatches(),
|
||||||
keymap.of([
|
keymap.of([
|
||||||
...closeBracketsKeymap,
|
...closeBracketsKeymap,
|
||||||
...defaultKeymap,
|
...defaultKeymap,
|
||||||
...searchKeymap,
|
...searchKeymap,
|
||||||
...historyKeymap,
|
...historyKeymap,
|
||||||
...foldKeymap,
|
...foldKeymap,
|
||||||
...completionKeymap,
|
...completionKeymap,
|
||||||
...lintKeymap,
|
...lintKeymap,
|
||||||
]),
|
]),
|
||||||
])();
|
])();
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-editor',
|
selector: 'app-editor',
|
||||||
templateUrl: './editor.component.html',
|
templateUrl: './editor.component.html',
|
||||||
styleUrls: ['./editor.component.scss'],
|
styleUrls: ['./editor.component.scss'],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [
|
||||||
CodeMirrorComponent,
|
CodeMirrorComponent,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
SafeHTMLPipe,
|
SafeHTMLPipe,
|
||||||
TranslateModule
|
TranslateModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class EditorComponent {
|
export class EditorComponent {
|
||||||
isLoaded: boolean = false; // Pour vérifier si le chargement est terminé
|
isLoaded: boolean = false; // Pour vérifier si le chargement est terminé
|
||||||
|
|
||||||
readonly languages: LanguageDescription[] = LANGUAGES;
|
readonly languages: LanguageDescription[] = LANGUAGES;
|
||||||
// Mode par défaut
|
// Mode par défaut
|
||||||
private _selectedLanguage = this.languages.find(
|
private _selectedLanguage = this.languages.find(
|
||||||
(lang) => lang.name === 'JavaScript'
|
(lang) => lang.name === 'JavaScript'
|
||||||
)!;
|
)!;
|
||||||
get selectedLanguage(): LanguageDescription {
|
get selectedLanguage(): LanguageDescription {
|
||||||
return this._selectedLanguage;
|
return this._selectedLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
|
set selectedLanguage(value: LanguageDescription) {
|
||||||
|
this._selectedLanguage = value;
|
||||||
|
if (value.name in CODE_DEFAULTS) {
|
||||||
|
this.editorContent =
|
||||||
|
CODE_DEFAULTS[value.name as keyof typeof CODE_DEFAULTS];
|
||||||
}
|
}
|
||||||
|
this.selectedLanguage.load().then((language) => {
|
||||||
set selectedLanguage(value: LanguageDescription) {
|
this.codemirror.editor?.dispatch({
|
||||||
this._selectedLanguage = value;
|
effects: this.languageCompartment.reconfigure(language),
|
||||||
if (value.name in CODE_DEFAULTS) {
|
});
|
||||||
this.editorContent =
|
});
|
||||||
CODE_DEFAULTS[value.name as keyof typeof CODE_DEFAULTS];
|
}
|
||||||
}
|
|
||||||
this.selectedLanguage.load().then((language) => {
|
private _linesNumbers: boolean = true;
|
||||||
this.codemirror.editor?.dispatch({
|
get linesNumbers() {
|
||||||
effects: this.languageCompartment.reconfigure(language),
|
return this._linesNumbers;
|
||||||
});
|
}
|
||||||
});
|
|
||||||
}
|
set linesNumbers(lines: boolean) {
|
||||||
|
this._linesNumbers = lines;
|
||||||
private _linesNumbers: boolean = true;
|
this.codemirror.editor?.dispatch({
|
||||||
get linesNumbers() {
|
effects: this.gutterCompartment.reconfigure(
|
||||||
return this._linesNumbers;
|
lines ? lineNumbers() : gutter({})
|
||||||
}
|
),
|
||||||
|
});
|
||||||
set linesNumbers(lines: boolean) {
|
}
|
||||||
this._linesNumbers = lines;
|
|
||||||
this.codemirror.editor?.dispatch({
|
// Contenu de l'éditeur que l'on passera au serveur
|
||||||
effects: this.gutterCompartment.reconfigure(
|
editorContent: string =
|
||||||
lines ? lineNumbers() : gutter({})
|
CODE_DEFAULTS[this.selectedLanguage.name as keyof typeof CODE_DEFAULTS];
|
||||||
),
|
resultContent: string = '';
|
||||||
});
|
|
||||||
}
|
// Message d'erreur
|
||||||
|
errorMessage: string = '';
|
||||||
// Contenu de l'éditeur que l'on passera au serveur
|
|
||||||
editorContent: string =
|
@ViewChild(CodeMirrorComponent) private codemirror!: CodeMirrorComponent;
|
||||||
CODE_DEFAULTS[this.selectedLanguage.name as keyof typeof CODE_DEFAULTS];
|
|
||||||
resultContent: string = '';
|
private readonly languageCompartment = new Compartment();
|
||||||
|
private readonly gutterCompartment = new Compartment();
|
||||||
// Message d'erreur
|
protected readonly extensions: Extension[] = [
|
||||||
errorMessage: string = '';
|
basicSetup,
|
||||||
|
this.gutterCompartment.of(lineNumbers()),
|
||||||
@ViewChild(CodeMirrorComponent) private codemirror!: CodeMirrorComponent;
|
this.languageCompartment.of(this.selectedLanguage.support!),
|
||||||
|
];
|
||||||
private readonly languageCompartment = new Compartment();
|
|
||||||
private readonly gutterCompartment = new Compartment();
|
constructor(
|
||||||
protected readonly extensions: Extension[] = [
|
private codeExecutionService: CodeExecutionService,
|
||||||
basicSetup,
|
protected workService: WorkService
|
||||||
this.gutterCompartment.of(lineNumbers()),
|
) {}
|
||||||
this.languageCompartment.of(this.selectedLanguage.support!),
|
|
||||||
];
|
// Efface le contenu de l'éditeur
|
||||||
|
clear(): void {
|
||||||
constructor(private codeExecutionService: CodeExecutionService, protected workService: WorkService) {
|
this.editorContent = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Efface le contenu de l'éditeur
|
onRunButtonClicked() {
|
||||||
clear(): void {
|
// Le code à exécuter est le contenu de l'éditeur
|
||||||
this.editorContent = '';
|
const codeToExecute = this.editorContent;
|
||||||
|
|
||||||
|
this.codeExecutionService.executeCode(
|
||||||
|
codeToExecute,
|
||||||
|
this.selectedLanguage.name
|
||||||
|
);
|
||||||
|
|
||||||
|
this.resultContent = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
loadFromFile(event: Event) {
|
||||||
|
const file = (event.target as HTMLInputElement).files![0];
|
||||||
|
for (const language of this.languages) {
|
||||||
|
if (language.extensions.some((ext) => file.name.endsWith(`.${ext}`))) {
|
||||||
|
this.selectedLanguage = language;
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = (event) => {
|
||||||
|
this.editorContent = event.target!.result as string;
|
||||||
|
this.errorMessage = '';
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
const extensions = this.languages.flatMap((lang) => lang.extensions);
|
||||||
onRunButtonClicked() {
|
this.errorMessage = `Unsupported language. Please select one of the following languages: ${extensions.join(', ')}.`;
|
||||||
// Le code à exécuter est le contenu de l'éditeur
|
console.error(this.errorMessage);
|
||||||
const codeToExecute = this.editorContent;
|
}
|
||||||
|
|
||||||
this.codeExecutionService.executeCode(
|
saveToFile() {
|
||||||
codeToExecute,
|
const blob = new Blob([this.editorContent], { type: 'text/plain' });
|
||||||
this.selectedLanguage.name
|
const a = document.createElement('a');
|
||||||
);
|
a.download = `code.${this.selectedLanguage.extensions![0]}`;
|
||||||
|
a.href = URL.createObjectURL(blob);
|
||||||
this.resultContent = '';
|
a.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadFromFile(event: Event) {
|
addToDatabase() {
|
||||||
const file = (event.target as HTMLInputElement).files![0];
|
this.workService.postWorkCode(this.editorContent);
|
||||||
for (const language of this.languages) {
|
}
|
||||||
if (language.extensions.some((ext) => file.name.endsWith(`.${ext}`))) {
|
|
||||||
this.selectedLanguage = language;
|
shareButtonClicked() {}
|
||||||
const reader = new FileReader();
|
saveButtonClicked() {}
|
||||||
reader.onload = (event) => {
|
|
||||||
this.editorContent = event.target!.result as string;
|
protected readonly console = console;
|
||||||
this.errorMessage = '';
|
|
||||||
};
|
|
||||||
reader.readAsText(file);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const extensions = this.languages.flatMap((lang) => lang.extensions);
|
|
||||||
this.errorMessage = `Unsupported language. Please select one of the following languages: ${extensions.join(', ')}.`;
|
|
||||||
console.error(this.errorMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
saveToFile() {
|
|
||||||
const blob = new Blob([this.editorContent], {type: 'text/plain'});
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.download = `code.${this.selectedLanguage.extensions![0]}`;
|
|
||||||
a.href = URL.createObjectURL(blob);
|
|
||||||
a.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
addToDatabase() {
|
|
||||||
this.workService.postWorkCode(this.editorContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
shareButtonClicked(){}
|
|
||||||
saveButtonClicked(){}
|
|
||||||
|
|
||||||
protected readonly console = console;
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0 150px 0 150px;
|
margin: 0 150px 0 150px;
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
body {
|
body {
|
||||||
margin: 0 150px 0 150px;
|
margin: 0 150px 0 150px;
|
||||||
}
|
}
|
@ -1,21 +1,33 @@
|
|||||||
<h2>Works</h2>
|
<h2>Works</h2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li *ngFor="let work of works">
|
<li *ngFor="let work of works">
|
||||||
{{ work.id_work }} - {{ work.link }} - {{ work.content }}
|
{{ work.id_work }} - {{ work.link }} - {{ work.content }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<form #addBookForm="ngForm" (ngSubmit)="onSubmit(addBookForm)">
|
<form #addBookForm="ngForm" (ngSubmit)="onSubmit(addBookForm)">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="link">Link</label>
|
<label for="link">Link</label>
|
||||||
<input type="text" class="form-control" id="link" name="link" ngModel required>
|
<input
|
||||||
</div>
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
id="link"
|
||||||
|
name="link"
|
||||||
|
ngModel
|
||||||
|
required />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="content">Content</label>
|
<label for="content">Content</label>
|
||||||
<input type="text" class="form-control" id="content" name="content" ngModel required>
|
<input
|
||||||
</div>
|
type="text"
|
||||||
|
class="form-control"
|
||||||
|
id="content"
|
||||||
|
name="content"
|
||||||
|
ngModel
|
||||||
|
required />
|
||||||
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
<button type="submit" class="btn btn-primary">Submit</button>
|
||||||
</form>
|
</form>
|
@ -1,30 +1,28 @@
|
|||||||
import {Component} from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {Work} from "../../models/work.model";
|
import { Work } from '../../models/work.model';
|
||||||
import {WorkService} from "../../services/work.service";
|
import { WorkService } from '../../services/work.service';
|
||||||
import {NgForOf} from "@angular/common";
|
import { NgForOf } from '@angular/common';
|
||||||
import {FormsModule, NgForm} from "@angular/forms";
|
import { FormsModule, NgForm } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-works-list',
|
selector: 'app-works-list',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [
|
imports: [NgForOf, FormsModule],
|
||||||
NgForOf,
|
templateUrl: './works-list.component.html',
|
||||||
FormsModule
|
styleUrl: './works-list.component.css',
|
||||||
],
|
|
||||||
templateUrl: './works-list.component.html',
|
|
||||||
styleUrl: './works-list.component.css'
|
|
||||||
})
|
})
|
||||||
export class WorksListComponent {
|
export class WorksListComponent {
|
||||||
works: Work[] = [];
|
works: Work[] = [];
|
||||||
|
|
||||||
constructor(protected workService: WorkService) {
|
constructor(protected workService: WorkService) {}
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.workService.getWorks().subscribe((response: Work[]) => this.works = response)
|
this.workService
|
||||||
}
|
.getWorks()
|
||||||
|
.subscribe((response: Work[]) => (this.works = response));
|
||||||
|
}
|
||||||
|
|
||||||
onSubmit(form: NgForm) {
|
onSubmit(form: NgForm) {
|
||||||
this.workService.postWork(form);
|
this.workService.postWork(form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
export interface Work {
|
export interface Work {
|
||||||
id_work: number,
|
id_work: number;
|
||||||
link: string,
|
link: string;
|
||||||
user_id: number,
|
user_id: number;
|
||||||
language_id: number,
|
language_id: number;
|
||||||
content: string
|
content: string;
|
||||||
}
|
}
|
@ -1,43 +1,51 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {Work} from "../models/work.model";
|
import { Work } from '../models/work.model';
|
||||||
import {HttpClient} from "@angular/common/http";
|
import { HttpClient } from '@angular/common/http';
|
||||||
import {Observable} from "rxjs";
|
import { Observable } from 'rxjs';
|
||||||
import {NgForm} from "@angular/forms";
|
import { NgForm } from '@angular/forms';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class WorkService {
|
export class WorkService {
|
||||||
API_URL = 'http://127.0.0.1:3000'
|
API_URL = 'http://127.0.0.1:3000';
|
||||||
|
|
||||||
private works: Work[] = [];
|
private works: Work[] = [];
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {}
|
||||||
}
|
|
||||||
|
getWorks(): Observable<any> {
|
||||||
getWorks(): Observable<any> {
|
return this.http.get(`${this.API_URL}/works`);
|
||||||
return this.http.get(`${this.API_URL}/works`);
|
}
|
||||||
}
|
|
||||||
|
//je veux return les works d'un user id
|
||||||
//je veux return les works d'un user id
|
getWorksByUserId(user_id: string): Observable<any> {
|
||||||
getWorksByUserId(user_id: string): Observable<any> {
|
return this.http.get(`${this.API_URL}/works/${user_id}`);
|
||||||
return this.http.get(`${this.API_URL}/works/${user_id}`);
|
}
|
||||||
}
|
|
||||||
|
//je veux return le link du dernier work d'un user (en l'occurence celui connecté)
|
||||||
//je veux return le link du dernier work d'un user (en l'occurence celui connecté)
|
getLastWorkByUserId(user_id: string): Observable<any> {
|
||||||
getLastWorkByUserId(user_id: string): Observable<any> {
|
return this.http.get(`${this.API_URL}/works/user/${user_id}`);
|
||||||
return this.http.get(`${this.API_URL}/work/${user_id}`);
|
}
|
||||||
}
|
|
||||||
|
postWork(form: NgForm): void {
|
||||||
|
let body = {
|
||||||
postWork(form: NgForm): void {
|
link: crypto.randomUUID(),
|
||||||
let body = {link: crypto.randomUUID(), user_id: 1, id_language: 1, code: form.value.content, saveDate: new Date()}
|
user_id: 1,
|
||||||
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
id_language: 1,
|
||||||
}
|
code: form.value.content,
|
||||||
|
saveDate: new Date(),
|
||||||
postWorkCode(code: string): void {
|
};
|
||||||
let body = {link: crypto.randomUUID(), user_id: 1, id_language: 1, code: code}
|
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
||||||
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
}
|
||||||
}
|
|
||||||
|
postWorkCode(code: string): void {
|
||||||
|
let body = {
|
||||||
|
link: crypto.randomUUID(),
|
||||||
|
user_id: 1,
|
||||||
|
id_language: 1,
|
||||||
|
code: code,
|
||||||
|
};
|
||||||
|
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,32 +1,35 @@
|
|||||||
import {Injectable} from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import {Work} from "../models/work.model";
|
import { Work } from '../models/work.model';
|
||||||
import {HttpClient} from "@angular/common/http";
|
import { HttpClient } from '@angular/common/http';
|
||||||
import {Observable} from "rxjs";
|
import { Observable } from 'rxjs';
|
||||||
import {NgForm} from "@angular/forms";
|
import { NgForm } from '@angular/forms';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class WorksService {
|
export class WorksService {
|
||||||
API_URL = 'http://127.0.0.1:3000'
|
API_URL = 'http://127.0.0.1:3000';
|
||||||
|
|
||||||
private works: Work[] = [];
|
private works: Work[] = [];
|
||||||
|
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {}
|
||||||
}
|
|
||||||
|
|
||||||
getWorks(): Observable<any> {
|
getWorks(): Observable<any> {
|
||||||
return this.http.get(`${this.API_URL}/works`);
|
return this.http.get(`${this.API_URL}/works`);
|
||||||
}
|
}
|
||||||
|
|
||||||
postWork(form: NgForm): void {
|
postWork(form: NgForm): void {
|
||||||
let body = {link: form.value.link, id_user: 1, id_language: 1, code: form.value.content}
|
let body = {
|
||||||
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
link: form.value.link,
|
||||||
}
|
id_user: 1,
|
||||||
|
id_language: 1,
|
||||||
|
code: form.value.content,
|
||||||
|
};
|
||||||
|
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
postWorkCode(code: string): void {
|
postWorkCode(code: string): void {
|
||||||
let body = {link: 'TODO', id_user: 1, id_language: 1, code: code}
|
let body = { link: 'TODO', id_user: 1, id_language: 1, code: code };
|
||||||
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
this.http.post<any>(`${this.API_URL}/works`, body).subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in new issue