Top Donators / Total
This commit is contained in:
@@ -53,7 +53,13 @@
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.development.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterOutlet } from '@angular/router';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterOutlet],
|
||||
imports: [CommonModule, RouterOutlet,HttpClientModule],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import {provideHttpClient} from '@angular/common/http';
|
||||
import { ApplicationConfig } from '@angular/core';
|
||||
import { provideRouter } from '@angular/router';
|
||||
|
||||
import { routes } from './app.routes';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [provideRouter(routes)]
|
||||
providers: [provideRouter(routes),provideHttpClient()]
|
||||
};
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import {DonationComponent} from "./donation/donation.component";
|
||||
import {TopdonorsComponent} from "./topdonors/topdonors.component";
|
||||
import { Routes } from '@angular/router';
|
||||
import {TotalComponent} from "./total/total.component";
|
||||
|
||||
export const routes: Routes = [
|
||||
{ path: 'topdonors' , component: TopdonorsComponent },
|
||||
{ path: 'donation' , component: DonationComponent }
|
||||
|
||||
{ path: 'donations' , component: DonationComponent },
|
||||
{ path: 'total' , component: TotalComponent },
|
||||
];
|
||||
|
||||
@@ -8,3 +8,8 @@ export class WSMessage {
|
||||
Name : String;
|
||||
Euro : number;
|
||||
}
|
||||
|
||||
export class Donator {
|
||||
name : String;
|
||||
amount : number;
|
||||
}
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
<p>topdonors works!</p>
|
||||
<table>
|
||||
<thead>
|
||||
<th>Nom</th>
|
||||
<th>Montant</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let d of donators" >
|
||||
<td>{{d.name}}</td>
|
||||
<td>{{d.amount}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {WebsocketService} from '../../services/websocket';
|
||||
import {ApiService} from '../../services/api';
|
||||
import {Donator} from '../models/WSMessage';
|
||||
|
||||
@Component({
|
||||
selector: 'app-topdonors',
|
||||
@@ -8,6 +11,20 @@ import { CommonModule } from '@angular/common';
|
||||
templateUrl: './topdonors.component.html',
|
||||
styleUrl: './topdonors.component.scss'
|
||||
})
|
||||
export class TopdonorsComponent {
|
||||
export class TopdonorsComponent implements OnInit{
|
||||
|
||||
donators: Donator[] = []
|
||||
|
||||
constructor( private socket : WebsocketService,private ApiService: ApiService) {};
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getDonators();
|
||||
this.socket.Messages.subscribe(s => {
|
||||
this.getDonators();
|
||||
});
|
||||
}
|
||||
|
||||
getDonators(){
|
||||
this.ApiService.TopDonators().subscribe(donators => this.donators = donators);
|
||||
}
|
||||
}
|
||||
|
||||
1
frontend/src/app/total/total.component.html
Normal file
1
frontend/src/app/total/total.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<p>{{Total}}</p>
|
||||
0
frontend/src/app/total/total.component.scss
Normal file
0
frontend/src/app/total/total.component.scss
Normal file
23
frontend/src/app/total/total.component.spec.ts
Normal file
23
frontend/src/app/total/total.component.spec.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TotalComponent } from './total.component';
|
||||
|
||||
describe('TotalComponent', () => {
|
||||
let component: TotalComponent;
|
||||
let fixture: ComponentFixture<TotalComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [TotalComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(TotalComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
29
frontend/src/app/total/total.component.ts
Normal file
29
frontend/src/app/total/total.component.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {WebsocketService} from '../../services/websocket';
|
||||
import {ApiService} from '../../services/api';
|
||||
|
||||
@Component({
|
||||
selector: 'app-total',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
templateUrl: './total.component.html',
|
||||
styleUrl: './total.component.scss'
|
||||
})
|
||||
export class TotalComponent implements OnInit{
|
||||
|
||||
Total : string;
|
||||
|
||||
constructor( private socket : WebsocketService,private ApiService: ApiService) {};
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getTotal();
|
||||
this.socket.Messages.subscribe(s => {
|
||||
this.getTotal();
|
||||
});
|
||||
}
|
||||
|
||||
getTotal(){
|
||||
this.ApiService.Total().subscribe(t => this.Total = t as string);
|
||||
}
|
||||
}
|
||||
4
frontend/src/environments/environment.development.ts
Normal file
4
frontend/src/environments/environment.development.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production : false,
|
||||
apiUrl : 'http://localhost:5000/'
|
||||
};
|
||||
4
frontend/src/environments/environment.ts
Normal file
4
frontend/src/environments/environment.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const environment = {
|
||||
production : false,
|
||||
apiUrl : 'http://localhost:5000/'
|
||||
};
|
||||
22
frontend/src/services/api.ts
Normal file
22
frontend/src/services/api.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import {Observable, Observer, Subject} from 'rxjs';
|
||||
import { Donator, WSMessage } from '../app/models/WSMessage';
|
||||
import {environment} from '../environments/environment';
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ApiService {
|
||||
|
||||
constructor(private httpClient : HttpClient) {
|
||||
}
|
||||
|
||||
Total() {
|
||||
return this.httpClient.get(`${environment.apiUrl}/total`);
|
||||
}
|
||||
|
||||
TopDonators() : Observable<Donator[]> {
|
||||
return this.httpClient.get<Donator[]>(`${environment.apiUrl}/topdonators`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user