Skip to content

Commit

Permalink
Fixed response menu dashboard, many getUserDetails requests, charts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhossymarbalderrama committed May 14, 2024
1 parent bef7a95 commit 13d0ba2
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 67 deletions.
6 changes: 5 additions & 1 deletion firebase.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"hosting": {
"public": "./dist/e-commerce",
"public": "dist/e-commerce",
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ],
"ignore": [
"firebase.json",
"**/.*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class DashboardAnalyticsComponent implements OnInit, OnDestroy, AfterView

// * CONSTRUCTOR
constructor(
private LoginService: LoginService,
private ChartService: ChartService
) {
this.ChartService.getDataCharts().subscribe(
Expand Down Expand Up @@ -116,10 +115,8 @@ export class DashboardAnalyticsComponent implements OnInit, OnDestroy, AfterView
this.ChartService.chartArea = this.constructorChart('chartArea', optionsChartArea);

// ! Creo el siguiente chart
setTimeout(() => {
this.generatePieChart(data);
}, 500);


this.generatePieChart(data);
}

/**
Expand Down Expand Up @@ -150,10 +147,8 @@ export class DashboardAnalyticsComponent implements OnInit, OnDestroy, AfterView
this.ChartService.chartPie = new ApexCharts(document.getElementById('pieChart'), options);
this.ChartService.chartPie.render();

setTimeout(() => {
this.createChartDonut(data);
}, 700);

this.createChartDonut(data);
}

/**
Expand Down Expand Up @@ -182,10 +177,7 @@ export class DashboardAnalyticsComponent implements OnInit, OnDestroy, AfterView

this.ChartService.chartDonut = this.constructorChart('chartDonut', options);

setTimeout(() => {
this.createChartRadar(data);
}, 800);

}

createChartRadar(data: any) {
Expand Down Expand Up @@ -213,10 +205,8 @@ export class DashboardAnalyticsComponent implements OnInit, OnDestroy, AfterView

this.ChartService.chartRadar = this.constructorChart('chartRadar', options);

setTimeout(() => {
this.createChartLine(data);
}, 900);

this.createChartLine(data);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export class DashboardListUsersComponent implements OnInit {

// * CONSTRUCTOR
constructor(
private AuthService: AuthService,
private LoginService: LoginService
private AuthService: AuthService
) {
// this.LoginService.checkTokenExpiration();
this.AuthService.svListUsers().subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@ export class DashboardOrdersComponent {

// * CONSTRUCTOR
constructor(
private LoginService: LoginService,
private FacturacionService: FacturacionService,
private ToastService: ToastService
private FacturacionService: FacturacionService
) {
// this.LoginService.checkTokenExpiration(); // ? Check Token Login
// this.FacturacionService.svListFacturas().subscribe( data => {
// this.listFacturas = data;
// })

this.action = Crud;
this.loadListFacturas();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export class DashboardProductsComponent implements OnInit {

// * CONSTRUCTOR
constructor(
private ProductService: ProductService,
private LoginService: LoginService
private ProductService: ProductService
) {
this.action = Crud;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ export class FormProductComponent implements OnInit {
private FormBuilder: FormBuilder,
private ProductService: ProductService,
private storage: Storage,
private ToastService: ToastService,
private datePipe: DatePipe
private ToastService: ToastService
) { }

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export class DashboardProfileComponent implements OnInit, AfterViewInit {
public UrlService: UrlService
) {
// this.LoginService.checkTokenExpiration();
if (!this.AuthService.userData) {
this.refreshData(true);
}
// if (!this.AuthService.userData) {
// this.refreshData(true);
// }
}

ngAfterViewInit(): void {}
Expand All @@ -47,6 +47,7 @@ export class DashboardProfileComponent implements OnInit, AfterViewInit {
* @param $event
*/
refreshData($event: any){
this.AuthService.svDetailsUser(localStorage.getItem('userLogin') as string).subscribe();
// this.AuthService.svDetailsUser(localStorage.getItem('userLogin') as string).subscribe();
// this.AuthService.svDetailsUserID(localStorage.getItem('idUser') as any);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class DashboardShoppingCartComponent {

// * CONSTRUCTOR
constructor(
private LoginService: LoginService,
private CartService: CartService
) {
// this.LoginService.checkTokenExpiration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export class PaymentFormComponent implements OnInit {
private Router: Router,
public UrlService: UrlService
) {
if (this.AuthService.userData == null || this.AuthService.userData == undefined) {
this.AuthService.svGetUserData();
}
// if (this.AuthService.userData == null || this.AuthService.userData == undefined) {
// this.AuthService.svGetUserData();
// }

this.DeliveryService.svGetListDelivery().subscribe(
rp => {
Expand Down Expand Up @@ -153,6 +153,8 @@ export class PaymentFormComponent implements OnInit {
date: ""
} as any;



this.ToastService.showOverlay = true;

this.FacturacionService.svAltaFacturacion(facturacionRequest, products).subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ export class DashboardShoppingHistoryComponent {

// * CONSTRUCTOR
constructor(
private LoginService: LoginService,
private FacturacionService: FacturacionService,
private AuthService: AuthService
) {
this.loadListFacturas();
console.log("Llamo a cargar Lista");

this.action = Crud;
}

Expand All @@ -72,25 +69,14 @@ export class DashboardShoppingHistoryComponent {
}

loadListFacturas() {
console.log("Entro a cargar lista");
console.log(this.AuthService.userData);

// this.AuthService.svDetailsUser(localStorage.getItem('userLogin') as string).subscribe(
// (user) => {
// console.log(user);

this.FacturacionService.svListFacturasUser(this.AuthService.svIdUserLogin).subscribe(data => {
this.listFacturas = data;
console.log(data);

if (data.length != 0) {
this.tieneFacturas = true;
}else{
this.tieneFacturas = false;
}
});
// }
// );
this.FacturacionService.svListFacturasUser(this.AuthService.svIdUserLogin).subscribe(data => {
this.listFacturas = data;
if (data.length != 0) {
this.tieneFacturas = true;
} else {
this.tieneFacturas = false;
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ export class DashboardStoreComponent {

// * CONSTRUCTOR
constructor(
private LoginService: LoginService
) {
// this.LoginService.checkTokenExpiration();
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="block lg:block bg-menu text-white flex flex-col pt-5 w-full h-full pl-10 lg:pl-5 flex-grow overflow-y-auto">
<div class="block lg:block bg-menu text-white flex flex-col pt-2 w-full h-full pl-10 lg:pl-5 flex-grow overflow-y-auto">

<div class="w-full flex justify-center">
<div class="mb-4 flex flex-col justify-center items-center w-56 h-52 lg:w-36 lg:h-36 xl:w-52 xl:h-52" (click)="navClose()" [routerLink]="'/dashboard/profile'">
<div class="mb-2 flex flex-col justify-center items-center w-56 h-52 lg:w-36 lg:h-36 xl:w-52 xl:h-52" (click)="navClose()" [routerLink]="'/dashboard/profile'">
<img [src]="this.AuthService.userData?.img ? this.AuthService.userData?.img : UrlService.url?.profileDefault "
alt="Imagen de perfil"
class="w-40 h-40 lg:pr-0 lg:w-36 lg:h-36 xl:w-44 xl:h-44 object-cover rounded-full transition-transform transform-gpu hover:scale-105 cursor-pointer"
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ export class LoginComponent implements OnInit {
this.LoginService.svLogin(this.formLogin.value as LoginRequest).subscribe({
next: (userData) => {
//Trae el Token
// console.log("Logeado: ",userData);
this.AuthService.svDetailsUser(this.formLogin.get('username')?.value).subscribe();
// console.log("Logeado: ",userData);
},
error: (errorData) => {
// console.error(errorData);
this.loginError = errorData;
this.ToastService.showOverlay = false;
},
complete: () => {
this.AuthService.svDetailsUser(this.formLogin.get('username')?.value).subscribe();
setTimeout(() => {
this.formLogin.reset();
this.Router.navigateByUrl('/dashboard/profile');
Expand Down
1 change: 0 additions & 1 deletion src/app/components/store/item/item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class ItemComponent implements OnInit, OnDestroy {
constructor(
private route: ActivatedRoute,
private productServ: ProductService,
private authServ: AuthService,
private cartServ: CartService,
private Location: Location,
private Router: Router
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AuthService {
) {

let id = localStorage.getItem('idUser');
id ? this.svIdUserLogin = Number.parseInt(id) : 0;
id ? this.svIdUserLogin = Number.parseInt(id) : 0;
}

// * GETTERs
Expand Down

0 comments on commit 13d0ba2

Please sign in to comment.