repare login

add search in sale detail
add refresh button in sale detail
This commit is contained in:
2024-11-26 15:10:38 +01:00
parent 848fc4909e
commit 23dbfff014
41 changed files with 192 additions and 127 deletions
+6 -6
View File
@@ -7,7 +7,7 @@ import { CoreModule } from './core/core.module';
import { SharedModule } from './shared/shared.module';
import { CustomMaterialModule } from './custom-material/custom-material.module';
import { AppRoutingModule } from './app-routing.module';
import { LoggerModule } from 'ngx-logger';
//import { LoggerModule } from 'ngx-logger';
import { environment } from '../environments/environment';
@NgModule({
@@ -21,11 +21,11 @@ import { environment } from '../environments/environment';
SharedModule,
CustomMaterialModule.forRoot(),
AppRoutingModule,
LoggerModule.forRoot({
serverLoggingUrl: `http://my-api/logs`,
level: environment.logLevel,
serverLogLevel: environment.serverLogLevel
})
// LoggerModule.forRoot({
// serverLoggingUrl: `http://my-api/logs`,
// level: environment.logLevel,
// serverLogLevel: environment.serverLogLevel
// })
],
bootstrap: [AppComponent]
})
+2 -2
View File
@@ -2,7 +2,7 @@ import { NgModule, Optional, SkipSelf, ErrorHandler } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { MediaMatcher } from '@angular/cdk/layout';
import { NGXLogger } from 'ngx-logger';
//import { NGXLogger } from 'ngx-logger';
import { AuthInterceptor } from './interceptors/auth.interceptor';
import { SpinnerInterceptor } from './interceptors/spinner.interceptor';
@@ -36,7 +36,7 @@ import { AdminGuard } from './guards/admin.guard';
provide: ErrorHandler,
useClass: GlobalErrorHandler
},
{ provide: NGXLogger, useClass: NGXLogger },
//{ provide: NGXLogger, useClass: NGXLogger },
{ provide: 'LOCALSTORAGE', useValue: window.localStorage }
],
exports: [
@@ -1,5 +1,5 @@
import { ErrorHandler, Injectable, Injector } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
//import { NGXLogger } from 'ngx-logger';
@Injectable()
export class GlobalErrorHandler implements ErrorHandler {
@@ -11,7 +11,7 @@ export class GlobalErrorHandler implements ErrorHandler {
// Obtain dependencies at the time of the error
// This is because the GlobalErrorHandler is registered first
// which prevents constructor dependency injection
const logger = this.injector.get(NGXLogger);
//const logger = this.injector.get(NGXLogger);
const err = {
message: error.message ? error.message : error.toString(),
@@ -19,7 +19,7 @@ export class GlobalErrorHandler implements ErrorHandler {
};
// Log the error
logger.error(err);
//logger.error(err);
// Re-throw the error
throw error;
@@ -1,6 +1,6 @@
import { UntypedFormGroup, UntypedFormControl, Validators } from '@angular/forms';
import { Component, OnInit } from '@angular/core';
import { NGXLogger } from 'ngx-logger';
//import { NGXLogger } from 'ngx-logger';
import { AuthenticationService } from 'src/app/core/services/auth.service';
import { NotificationService } from 'src/app/core/services/notification.service';
import { SpinnerService } from 'src/app/core/services/spinner.service';
@@ -22,7 +22,7 @@ export class ChangePasswordComponent implements OnInit {
disableSubmit!: boolean;
constructor(private authService: AuthenticationService,
private logger: NGXLogger,
//private logger: NGXLogger,
private spinnerService: SpinnerService,
private notificationService: NotificationService) {
@@ -63,7 +63,7 @@ export class ChangePasswordComponent implements OnInit {
this.authService.changePassword(email, this.currentPassword, this.newPassword)
.subscribe(
data => {
this.logger.info(`User ${email} changed password.`);
//this.logger.info(`User ${email} changed password.`);
this.form.reset();
this.notificationService.openSnackBar('Your password has been changed.');
},
@@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { tap, catchError } from 'rxjs/operators';
import { of } from 'rxjs';
import { Router } from '@angular/router';
import { UntypedFormControl, Validators, UntypedFormGroup } from '@angular/forms';
import { Title } from '@angular/platform-browser';
@@ -15,7 +17,8 @@ export class LoginComponent implements OnInit {
loginForm!: UntypedFormGroup;
loading!: boolean;
constructor(private router: Router,
constructor(
private router: Router,
private titleService: Title,
private notificationService: NotificationService,
private authenticationService: AuthenticationService) {
@@ -45,23 +48,26 @@ export class LoginComponent implements OnInit {
this.loading = true;
this.authenticationService
.login(email.toLowerCase(), password)
.subscribe(
data => {
if (rememberMe) {
localStorage.setItem('savedUserEmail', email);
} else {
localStorage.removeItem('savedUserEmail');
}
this.router.navigate(['dashboard']);
},
error => {
this.notificationService.openSnackBar(error.error.message);
this.loading = false;
}
);
.pipe(
tap(data => {
if (rememberMe) {
localStorage.setItem('savedUserEmail', email);
} else {
localStorage.removeItem('savedUserEmail');
}
setTimeout(() => {
this.router.navigate(['sales'])
},100);
}),
catchError(error => {
this.notificationService.openSnackBar(error.error.message);
this.loading = false;
return of(null); // Return an observable to complete the stream
})
)
.subscribe();
}
resetPassword() {
this.router.navigate(['/auth/password-reset-request']);
}
@@ -1,7 +1,7 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { NGXLogger } from 'ngx-logger';
//import { NGXLogger } from 'ngx-logger';
import { Title } from '@angular/platform-browser';
import { NotificationService } from 'src/app/core/services/notification.service';
@@ -38,14 +38,14 @@ export class CustomerListComponent implements OnInit {
sort: MatSort = new MatSort;
constructor(
private logger: NGXLogger,
//private logger: NGXLogger,
private notificationService: NotificationService,
private titleService: Title
) { }
ngOnInit() {
this.titleService.setTitle('Jucundus - Customers');
this.logger.log('Customers loaded');
//this.logger.log('Customers loaded');
this.notificationService.openSnackBar('Customers loaded');
this.dataSource.sort = this.sort;
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { NotificationService } from 'src/app/core/services/notification.service';
import { Title } from '@angular/platform-browser';
import { NGXLogger } from 'ngx-logger';
//import { NGXLogger } from 'ngx-logger';
import { AuthenticationService } from 'src/app/core/services/auth.service';
@Component({
@@ -15,13 +15,14 @@ export class DashboardHomeComponent implements OnInit {
constructor(private notificationService: NotificationService,
private authService: AuthenticationService,
private titleService: Title,
private logger: NGXLogger) {
//private logger: NGXLogger
) {
}
ngOnInit() {
this.currentUser = this.authService.getCurrentUser();
this.titleService.setTitle('Jucundus - Dashboard');
this.logger.log('Dashboard loaded');
//this.logger.log('Dashboard loaded');
setTimeout(() => {
this.notificationService.openSnackBar('Welcome!');
@@ -32,6 +32,7 @@
</div>
</div>
<div fxLayout="row" fxLayoutGap="2px">
<button mat-raised-button color="primary" (click)="refresh()">Refresh</button>
<button mat-raised-button color="primary" (click)="downloadExcelStatsFile(id)">Excel</button>
</div>
</mat-card-content>
@@ -47,7 +48,14 @@
<ng-template mat-tab-label>
Lots
</ng-template>
<div fxLayout="row" fxLayoutGap="5px">
<mat-form-field>
<mat-label>Search</mat-label>
<input matInput placeholder="Search..." maxlength="255" st [(ngModel)]="searchText" (input)="filterLots()" >
</mat-form-field>
</div>
<div fxLayout="row" fxLayoutGap="5px">
<table mat-table [dataSource]="lotList" matSort class="mat-elevation-z8">
<!--- Note that these columns can be defined in any order.
@@ -27,10 +27,15 @@ import { Lot } from 'src/app/core/services/model/lot.interface';
export class SaleDetailPageComponent implements OnInit, AfterViewInit {
id: any = '';
Sale: Sale;
Sale: Sale;
searchText: string = '';
originalLots: Lot[] = [];
lotList: MatTableDataSource<Lot> = new MatTableDataSource<Lot>();
displayedColumns: string[] = ['lotNum', 'picture', 'title', 'estimateLow', 'estimateHigh', 'price', 'nbrBids', 'duration', 'percentageAboveUnderLow', 'percentageAboveUnderHigh'];
lotList: MatTableDataSource<Lot> = new MatTableDataSource<Lot>();
@ViewChild(MatPaginator) paginator?: MatPaginator;
@ViewChild(MatSort) sort?: MatSort;
@@ -88,6 +93,10 @@ export class SaleDetailPageComponent implements OnInit, AfterViewInit {
});
}
refresh(): void {
this.getLotList();
}
getLotList(){
this.apiLotService.getLotsBySale(this.id).subscribe((lotList: Lot[]) => {
@@ -134,6 +143,7 @@ export class SaleDetailPageComponent implements OnInit, AfterViewInit {
});
console.log(lotList);
this.originalLots = lotList;
this.lotList = new MatTableDataSource(lotList);
this.lotList.paginator = this.paginator ?? null;
this.lotList.sort = this.sort ?? null;
@@ -169,6 +179,14 @@ export class SaleDetailPageComponent implements OnInit, AfterViewInit {
return `${h.toString().padStart(2, '0')}:${m.toString().padStart(2, '0')}`;
}
filterLots(): void {
const filteredData = this.originalLots.filter(lot =>
lot.title?.toLowerCase().includes(this.searchText.toLowerCase()) ||
lot.description?.toLowerCase().includes(this.searchText.toLowerCase())
);
this.lotList.data = filteredData;
}
openDetailLot(idLot: string): void {
this.dialog.open(LotDetailDialogComponent, {
width: '80%',
@@ -1,7 +1,7 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { NGXLogger } from 'ngx-logger';
//import { NGXLogger } from 'ngx-logger';
import { NotificationService } from 'src/app/core/services/notification.service';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
@@ -23,7 +23,7 @@ export class UserListComponent implements OnInit {
@ViewChild(MatSort) sort?: MatSort;
constructor(
private logger: NGXLogger,
//private logger: NGXLogger,
private notificationService: NotificationService,
private titleService: Title,
private router: Router,
@@ -32,7 +32,7 @@ export class UserListComponent implements OnInit {
ngOnInit() {
this.titleService.setTitle('Jucundus - Users');
this.logger.log('Users loaded');
//this.logger.log('Users loaded');
this.refreshUsers()
}
+4 -3
View File
@@ -1,8 +1,9 @@
import { NgxLoggerLevel } from 'ngx-logger';
//import { NgxLoggerLevel } from 'ngx-logger';
export const environment = {
production: true,
logLevel: NgxLoggerLevel.OFF,
serverLogLevel: NgxLoggerLevel.ERROR,
//logLevel: NgxLoggerLevel.OFF,
//serverLogLevel: NgxLoggerLevel.ERROR,
//ServeurURL: "https://jucundus.saucisse.ninja"
ServeurURL: "https://jucundus-api.saucisse.ninja"
};
+3 -3
View File
@@ -1,4 +1,4 @@
import { NgxLoggerLevel } from 'ngx-logger';
//import { NgxLoggerLevel } from 'ngx-logger';
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
@@ -7,7 +7,7 @@ import { NgxLoggerLevel } from 'ngx-logger';
export const environment = {
production: false,
logLevel: NgxLoggerLevel.TRACE,
serverLogLevel: NgxLoggerLevel.OFF,
//logLevel: NgxLoggerLevel.TRACE,
//serverLogLevel: NgxLoggerLevel.OFF,
ServeurURL: "http://localhost:3000"
};