add button for the refresh db function

dev
floxx2112 2 years ago
parent 3a8c52ae76
commit b78d4dc5a4
  1. 4
      src/app/navbar/navbar.component.html
  2. 8
      src/app/navbar/navbar.component.ts
  3. 18
      src/app/service/reset_data.service.ts

@ -23,11 +23,15 @@
<a routerLink="joins" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Jointures</a> <a routerLink="joins" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Jointures</a>
<a routerLink="createjoins" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Création</a> <a routerLink="createjoins" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Création</a>
<button (click)="applyResetDatabase()" class="text-white bg-orange-400 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">MAJ BDD</button>
</div> </div>
</div> </div>
</div> </div>
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0"> <div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
<!-- Profile dropdown --> <!-- Profile dropdown -->
<div class="relative ml-3"> <div class="relative ml-3">
<div> <div>
<button type="button" class="flex rounded-full bg-gray-800 text-sm focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800" id="user-menu-button" aria-expanded="false" aria-haspopup="true"> <button type="button" class="flex rounded-full bg-gray-800 text-sm focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800" id="user-menu-button" aria-expanded="false" aria-haspopup="true">

@ -1,4 +1,6 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { ResetDataService } from '../service/reset_data.service';
@Component({ @Component({
selector: 'app-navbar', selector: 'app-navbar',
@ -8,7 +10,13 @@ import { Component } from '@angular/core';
export class NavbarComponent { export class NavbarComponent {
public mobileOpen: boolean = false; public mobileOpen: boolean = false;
constructor(private resetDataService: ResetDataService){}
public openMobileMenu(){ public openMobileMenu(){
this.mobileOpen = !this.mobileOpen; this.mobileOpen = !this.mobileOpen;
} }
public applyResetDatabase():void {
this.resetDataService.resetDatabase().subscribe();
}
} }

@ -0,0 +1,18 @@
import { Injectable } from '@angular/core';
import { environment } from '../../environments/environment.development';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ResetDataService {
private apiServerUrl = environment.apiBaseUrl;
constructor(private http: HttpClient) { }
public resetDatabase(){
return this.http.post<void>(`${this.apiServerUrl}/api/reset`, null);
}
}
Loading…
Cancel
Save