Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/main/src/app/body/body.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ <h3 class="dropdown-item-title">
<div class="sidebar">
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
<li class="nav-item">
<!-- <li class="nav-item">
<a href="#" routerLink="home" class="nav-link">
<i class="nav-icon fas fa-home"></i>
<p>
Home
</p>
</a>
</li>
</li> -->
<li class="nav-item" [hidden]="!loginService.admin">
<a href="" routerLink="dashboard" class="nav-link">
<i class="nav-icon fas fa-chart-bar"></i>
Expand Down
2 changes: 1 addition & 1 deletion frontend/main/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class LoginComponent implements OnInit {
}

gotoHome(){
this.router.navigateByUrl('home')
this.router.navigateByUrl('dashboard')
}

register(){
Expand Down
16 changes: 16 additions & 0 deletions frontend/main/src/app/visits.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { VisitsService } from './visits.service';

describe('VisitsService', () => {
let service: VisitsService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(VisitsService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
23 changes: 23 additions & 0 deletions frontend/main/src/app/visits.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';

@Injectable({
providedIn: 'root'
})
export class VisitsService {

readonly APICountVisits:string = "http://localhost:8080/user/countVisitors"

constructor(private router: Router, private http: HttpClient) { }


listVisits():any{

return this.http.get(this.APICountVisits)

}



}
14 changes: 12 additions & 2 deletions frontend/main/src/app/visits/visits.component.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
<table>
<table class="table table-bordered">
<thead>

<th>ID</th>
<th>Data</th>
<th>Time</th>
<th>User</th>
<th>Bounce Rate</th>

</thead>
<tbody>
<tr *ngFor = "let visit of visits; let i = index">

<tr *ngFor="let visit of visits;let i = index;">
<td>{{visit.id}}</td>
<td>{{visit.date}}</td>
<td>{{visit.time}}</td>
<td>{{visit.user}}</td>
<td>{{visit.bounceRate}}</td>
</tr>

</tbody>
</table>






45 changes: 36 additions & 9 deletions frontend/main/src/app/visits/visits.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { VisitsService } from '../visits.service';

@Component({
selector: 'app-visits',
Expand All @@ -9,25 +10,51 @@ import { Router } from '@angular/router';
})
export class VisitsComponent implements OnInit {

readonly APICountVisits:string = "http://localhost:8080/user/countVisitors"
visits!: Array<any>
id!: number
date!: string
time!: number
user!: string
bounceRate!: boolean



visits! : Array<any>

constructor(private router:Router, private http:HttpClient) { }
constructor(public visitsService: VisitsService, private router:Router, private http:HttpClient) { }

ngOnInit(): void {

this.visits = new Array()
this.http.get(this.APICountVisits)
.subscribe((resultado:any)=>{
var count = Object.keys(resultado).length
for(let i = 0; i<count; i++){

this.visits.push({id: resultado[i].id, date: resultado[i].date, time: resultado[i].time, user: resultado[i].user, bounceRate: resultado[i].bounce_rate })
this.visitsService.listVisits().pipe().subscribe((response: any) => {

console.log(response);



var count = Object.keys(response).length;

for (let i = 0; i < count; i++) {

this.id = response[i].id;
this.date = response[i].date;
this.time = response[i].time;
this.user = response[i].user;
this.bounceRate = response[i].bounce_rate;

console.log(this.id);
console.log(this.date);
console.log(this.time);
console.log(this.user);
console.log(this.bounceRate);


this.visits.push({id: this.id, date: this.date, time: this.time, user: this.user, bounceRate: this.bounceRate })

}

})


}

}