add loader + dialog box + maj port

dev
floxx2112 2 years ago
parent be40370cb2
commit 9571e2f4ff
  1. 7
      angular.json
  2. 6
      src/app/app.module.ts
  3. 5
      src/app/navbar/navbar.component.html
  4. 17
      src/app/navbar/navbar.component.ts

@ -100,7 +100,12 @@
"browserTarget": "angularTest:build:development" "browserTarget": "angularTest:build:development"
} }
}, },
"defaultConfiguration": "development" "defaultConfiguration": "development",
"options": {
"port": 9002
}
}, },
"extract-i18n": { "extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n", "builder": "@angular-devkit/build-angular:extract-i18n",

@ -13,6 +13,7 @@ import { EmployeeService } from './service/employee.service';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatStepperModule } from '@angular/material/stepper'; import { MatStepperModule } from '@angular/material/stepper';
import { MatToolbarModule } from '@angular/material/toolbar'; import { MatToolbarModule } from '@angular/material/toolbar';
import {MatDialogModule} from '@angular/material/dialog';
import { MatIconModule } from "@angular/material/icon"; import { MatIconModule } from "@angular/material/icon";
import { Custom_Ng2SearchPipe } from './../Custom_Ng2SearchPipe'; import { Custom_Ng2SearchPipe } from './../Custom_Ng2SearchPipe';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
@ -21,6 +22,7 @@ import { CreateJoinsPageComponent } from './create-joins-page/create-joins-page.
import { JoinsTableComponent } from './joins-table/joins-table.component'; import { JoinsTableComponent } from './joins-table/joins-table.component';
import { WhereCardComponent } from './where-card/where-card.component'; import { WhereCardComponent } from './where-card/where-card.component';
import { ColumnsCardComponent } from './columns-card/columns-card.component'; import { ColumnsCardComponent } from './columns-card/columns-card.component';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -44,7 +46,9 @@ import { ColumnsCardComponent } from './columns-card/columns-card.component';
MatStepperModule, MatStepperModule,
MatToolbarModule, MatToolbarModule,
MatIconModule, MatIconModule,
FormsModule FormsModule,
MatDialogModule,
MatProgressSpinnerModule
], ],
providers: [EmployeeService], providers: [EmployeeService],

@ -26,6 +26,7 @@
<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 hover:animate-pulse">MAJ BDD</button> <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 hover:animate-pulse">MAJ BDD</button>
<mat-spinner *ngIf="isLoading" diameter="30"></mat-spinner>
</div> </div>
</div> </div>
</div> </div>
@ -52,6 +53,10 @@
<a routerLink="joins" class="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium">Jointures</a> <a routerLink="joins" class="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium">Jointures</a>
<a href="#" class="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium">Calendar</a> <a href="#" class="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium">Calendar</a>
<button (click)="applyResetDatabase()" class="ml-2 text-white bg-orange-400 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium hover:animate-pulse">MAJ BDD</button>
<mat-spinner *ngIf="isLoading" diameter="30" class="ml-2 mt-2"></mat-spinner>
</div> </div>
</div> </div>
</nav> </nav>

@ -3,6 +3,7 @@ import { Component } from '@angular/core';
import { ResetDataService } from '../service/reset_data.service'; import { ResetDataService } from '../service/reset_data.service';
import { Router, RouterModule } from '@angular/router'; import { Router, RouterModule } from '@angular/router';
import { AppRoutingModule } from '../app-routing.module'; import { AppRoutingModule } from '../app-routing.module';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
@Component({ @Component({
selector: 'app-navbar', selector: 'app-navbar',
@ -11,6 +12,7 @@ import { AppRoutingModule } from '../app-routing.module';
}) })
export class NavbarComponent { export class NavbarComponent {
public mobileOpen: boolean = false; public mobileOpen: boolean = false;
public isLoading: boolean = false;
constructor(private resetDataService: ResetDataService, private router: Router){} constructor(private resetDataService: ResetDataService, private router: Router){}
@ -19,7 +21,18 @@ export class NavbarComponent {
} }
public applyResetDatabase():void { public applyResetDatabase():void {
this.resetDataService.resetDatabase().subscribe(); if(window.confirm('Êtes-vous sûr de vouloir recharger le BDD ? Cela peut prendre du temps !')){
this.router.navigateByUrl(''); this.isLoading = true;
this.resetDataService.resetDatabase().subscribe(
() => {
//this.router.navigateByUrl('');
this.isLoading = false;
},
(error: HttpErrorResponse) => {
alert(error.message)
} }
);
}
}
} }

Loading…
Cancel
Save