Add a Works page
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
a86a40e845
commit
3bd2c44bad
@ -0,0 +1,5 @@
|
||||
<div>
|
||||
<h4>{{ work.id_work }} - {{ work.title }}</h4>
|
||||
<span> WORK CONTENT : {{ work.content }}</span>
|
||||
<a [routerLink]="['/work/', work.id_work]">Edit Code</a>
|
||||
</div>
|
@ -0,0 +1,22 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { WorkListDetailComponent } from './work-list-detail.component';
|
||||
|
||||
describe('WorkListDetailComponent', () => {
|
||||
let component: WorkListDetailComponent;
|
||||
let fixture: ComponentFixture<WorkListDetailComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [WorkListDetailComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(WorkListDetailComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,14 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Work } from '../../models/work.model';
|
||||
import { RouterLink } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-work-list-detail',
|
||||
standalone: true,
|
||||
imports: [RouterLink],
|
||||
templateUrl: './work-list-detail.component.html',
|
||||
styleUrl: './work-list-detail.component.css',
|
||||
})
|
||||
export class WorkListDetailComponent {
|
||||
@Input() work!: Work;
|
||||
}
|
@ -1,37 +1,6 @@
|
||||
<div>
|
||||
<div *ngIf="work">
|
||||
<h2>Works</h2>
|
||||
<h3>CURRENT WORK ID - {{ work.id_work }}</h3>
|
||||
|
||||
<ul>
|
||||
<li *ngFor="let work of works">
|
||||
{{ work.id_work }} - {{ work.link }} - {{ work.content }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<form #addBookForm="ngForm" (ngSubmit)="onSubmit(addBookForm)">
|
||||
<div class="form-group">
|
||||
<label for="link">Link</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="link"
|
||||
name="link"
|
||||
ngModel
|
||||
required />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="content">Content</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
id="content"
|
||||
name="content"
|
||||
ngModel
|
||||
required />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
|
||||
<!--<app-editor></app-editor>-->
|
||||
<!-- <app-editor></app-editor>-->
|
||||
</div>
|
||||
|
@ -1,51 +1,60 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { RouterLink, ActivatedRoute } from '@angular/router';
|
||||
import { ThemeService } from '../../services/theme.service';
|
||||
import { NgClass } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { Work } from '../../models/work.model';
|
||||
import { WorkService } from '../../services/work.service';
|
||||
import { NgForOf } from '@angular/common';
|
||||
import { FormsModule, NgForm } from '@angular/forms';
|
||||
import { Observable } from 'rxjs';
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {RouterLink, ActivatedRoute} from '@angular/router';
|
||||
import {ThemeService} from '../../services/theme.service';
|
||||
import {NgClass, NgIf} from '@angular/common';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {Work} from '../../models/work.model';
|
||||
import {WorkService} from '../../services/work.service';
|
||||
import {NgForOf} from '@angular/common';
|
||||
import {FormsModule, NgForm} from '@angular/forms';
|
||||
import {EditorComponent} from '../editor/editor.component';
|
||||
import {WorkListDetailComponent} from '../work-list-detail/work-list-detail.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-work',
|
||||
templateUrl: './work.component.html',
|
||||
styleUrl: './work.component.scss',
|
||||
standalone: true,
|
||||
imports: [NgClass, TranslateModule, RouterLink, NgForOf, FormsModule],
|
||||
selector: 'app-work',
|
||||
templateUrl: './work.component.html',
|
||||
styleUrl: './work.component.scss',
|
||||
standalone: true,
|
||||
imports: [
|
||||
NgClass,
|
||||
TranslateModule,
|
||||
RouterLink,
|
||||
NgForOf,
|
||||
FormsModule,
|
||||
EditorComponent,
|
||||
WorkListDetailComponent,
|
||||
NgIf,
|
||||
],
|
||||
})
|
||||
export class WorkComponent implements OnInit {
|
||||
// à retirer quand les boutons seront dans editor.component
|
||||
isLoaded: boolean = false; // Pour vérifier si le chargement est terminé
|
||||
// à retirer quand les boutons seront dans editor.component
|
||||
isLoaded: boolean = false; // Pour vérifier si le chargement est terminé
|
||||
|
||||
themeClass!: string;
|
||||
works: Work[] = [];
|
||||
workEnCours: Observable<Work> = new Observable();
|
||||
themeClass!: string;
|
||||
work!: Work;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private themeService: ThemeService,
|
||||
protected workService: WorkService
|
||||
) {}
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private themeService: ThemeService,
|
||||
protected workService: WorkService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.themeService.isDarkTheme.subscribe((value) => {
|
||||
value
|
||||
? (this.themeClass = 'dark-theme')
|
||||
: (this.themeClass = 'light-theme');
|
||||
});
|
||||
|
||||
ngOnInit() {
|
||||
this.themeService.isDarkTheme.subscribe((value) => {
|
||||
value
|
||||
? (this.themeClass = 'dark-theme')
|
||||
: (this.themeClass = 'light-theme');
|
||||
});
|
||||
this.workService
|
||||
.getWorks()
|
||||
.subscribe((response: Work[]) => (this.works = response));
|
||||
const link = String(this.route.snapshot.paramMap.get('link'));
|
||||
if (link) {
|
||||
// this.workEnCours = this.workService.getWorkByLink(link);
|
||||
const work_id = String(this.route.snapshot.paramMap.get('id'));
|
||||
|
||||
this.workService.getWorkById(work_id).subscribe((response: Work) => {
|
||||
this.work = response as Work;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onSubmit(form: NgForm) {
|
||||
this.workService.postWork(form);
|
||||
}
|
||||
onSubmit(form: NgForm) {
|
||||
this.workService.postWork(form);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue