Skip to content

Commit 9a9de78

Browse files
committed
2 parents a82a791 + 9e42af8 commit 9a9de78

File tree

5 files changed

+324
-10
lines changed

5 files changed

+324
-10
lines changed

frontend/src/app/components/login/signUp.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import { SignUpService } from '../../services/signUp.service';
2+
import { SignUpService } from '../../services/usero.service';
33

44
@Component({
55
selector: 'signup',
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
export interface Usero {
22
id?: number;
3-
nick:string;
3+
nick: string;
44

5-
name:string;
5+
name: string;
66

7-
lastName:string;
7+
lastName: string;
88

9-
email:string;
9+
email: string;
1010

11-
creditCard:string;
11+
creditCard: string;
1212

13-
image:boolean;
13+
image: boolean;
1414

15-
roles:string[];
15+
roles: string[];
1616
}

frontend/src/app/services/login.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ const BASE_URL = '/api/auth';
77
@Injectable({ providedIn: 'root' })
88
export class LoginService {
99

10-
logged: boolean | undefined;
11-
user: Usero | undefined;
10+
//Check these 2 lines, i've added '?' to both of them
11+
logged?: boolean;
12+
user?: Usero;
1213

1314
constructor(private http: HttpClient) {
1415
this.reqIsLogged();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Injectable } from '@angular/core';
2+
import { HttpClient } from '@angular/common/http';
3+
import { Usero } from '../models/usero.model';
4+
import { Observable, throwError } from 'rxjs';
5+
import { catchError } from 'rxjs/operators';
6+
7+
const BASE_URL = '/api/users';
8+
9+
@Injectable({ providedIn: 'root' })
10+
export class SignupService {
11+
12+
user?: Usero;
13+
14+
constructor(private http: HttpClient) {}
15+
16+
getUsers(): Observable<Usero[]> {
17+
return this.http.get(BASE_URL).pipe(
18+
//catchError(error => this.handleError(error)) da un error raro
19+
) as Observable<Usero[]>;
20+
}
21+
22+
getUser(id: number | string): Observable<Usero> {
23+
return this.http.get(BASE_URL + id).pipe(
24+
//catchError(error => this.handleError(error))
25+
) as Observable<Usero>;
26+
}
27+
28+
createUser(user: Usero, password: String) {
29+
this.http.post(BASE_URL + '/signup', {username: user, password: password});
30+
}
31+
32+
updateUser(user: Usero) {
33+
this.http.post(BASE_URL + '/updateUser', {});
34+
}
35+
36+
private handleError(error: any) {
37+
console.log("ERROR:");
38+
console.error(error);
39+
return throwError("Server error (" + error.status + "): " + error.text())
40+
}
41+
42+
}

frontend/src/script.ts

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
pageValueNews: 0;
2+
pageValueVideogames: 0;
3+
pageValueRecommendedGames: 0;
4+
5+
6+
7+
/*document.addEventListener("DOMContentLoaded", () => {
8+
const $boton = document.querySelector("#generatePDF");
9+
$boton.addEventListener("click", () => {
10+
const $elementoParaConvertir = document.body; // <-- Here you can choose any element of the DOM
11+
html2pdf()
12+
.set({
13+
margin: 1,
14+
filename: 'documento.pdf',
15+
image: {
16+
type: 'jpeg',
17+
quality: 0.98
18+
},
19+
html2canvas: {
20+
scale: 3, // Larger scale, better graphics, but more weight
21+
letterRendering: true,
22+
},
23+
jsPDF: {
24+
unit: "in",
25+
format: "a3",
26+
orientation: 'portrait' // landscape o portrait
27+
}
28+
})
29+
.from($elementoParaConvertir)
30+
.save()
31+
.catch(err => console.log(err));
32+
33+
});
34+
});*/
35+
/*
36+
$(document).ready(function() {
37+
$('#moreImagesButton').on('click', function(){
38+
39+
$('#loader').html('<div class="loading"><img src="Photos/loader.gif" alt="loading" /><br/>Un momento, por favor...</div>');
40+
increaseNews();
41+
$.ajax({
42+
type: "GET",
43+
url: '/news/' + pageValueNews,
44+
beforeSend: function () { // Before we send the request, remove the .hidden class from the spinner and default to inline-block.
45+
$('#loader').removeClass('hidden');
46+
},
47+
success: function (data) {
48+
//We finally load the desired content
49+
//$('#moreImgages').fadeIn(1000).html(data);
50+
$("#moreImages").fadeIn(1000).append(data);
51+
},
52+
complete: function () { // Set our complete callback, adding the .hidden class and hiding the spinner.
53+
$('#loader').addClass('hidden');
54+
},
55+
});
56+
});
57+
});
58+
59+
$(document).ready(function() {
60+
$('#moreRecomendedVideogame').on('click', function(){
61+
62+
$('#loader').html('<div class="loading"><img src="Photos/loader.gif" alt="loading" /><br/>Un momento, por favor...</div>');
63+
increaseRecommendedVideogames();
64+
$.ajax({
65+
type: "GET",
66+
url: '/videogameStatistics/' + pageValueRecommendedGames,
67+
beforeSend: function () { // Before we send the request, remove the .hidden class from the spinner and default to inline-block.
68+
$('#loader').removeClass('hidden');
69+
},
70+
success: function (data) {
71+
$("#moreImages").fadeIn(1000).append(data);
72+
},
73+
complete: function () { // Set our complete callback, adding the .hidden class and hiding the spinner.
74+
$('#loader').addClass('hidden');
75+
},
76+
});
77+
});
78+
});
79+
80+
$(document).ready(function () {
81+
$('#moreVideogamesButton').on('click', function () {
82+
//Añadimos la imagen de carga en el contenedor
83+
$('#loader').html('<div class="loading"><img src="Photos/loader.gif" alt="loading" /><br/>Un momento, por favor...</div>');
84+
increaseVideogames();
85+
$.ajax({
86+
type: "GET", //era un get
87+
url: '/videogames/' + pageValueVideogames,
88+
beforeSend: function () { // Before we send the request, remove the .hidden class from the spinner and default to inline-block.
89+
$('#loader').removeClass('hidden');
90+
},
91+
success: function (data) {
92+
//Cargamos finalmente el contenido deseado
93+
//$('#masImagenes').fadeIn(1000).html(data);
94+
$("#moreImages").fadeIn(1000).append(data);
95+
},
96+
complete: function () { // Set our complete callback, adding the .hidden class and hiding the spinner.
97+
$('#loader').addClass('hidden');
98+
},
99+
});
100+
});
101+
});
102+
103+
104+
function increaseNews() {
105+
pageValueNews += 1;
106+
return pageValueNews;
107+
}
108+
109+
function increaseVideogames() {
110+
pageValueVideogames += 1;
111+
return pageValueVideogames;
112+
}
113+
114+
function increaseRecommendedVideogames() {
115+
pageValueRecommendedGames += 1;
116+
return pageValueRecommendedGames;
117+
}
118+
119+
function verifySignin() {
120+
principal = request.getUserPrincipal();
121+
122+
if (getUserPrincipal() === true) {
123+
location.href = '/paymentConfirmation';
124+
} else {
125+
location.href = '/errorMessage';
126+
}
127+
}
128+
129+
130+
function alertDataChange() {
131+
alert("Los datos de usuario se han guardado")
132+
}
133+
134+
var check = function () {
135+
if (document.getElementById('inputPassword1').value ==
136+
document.getElementById('inputPassword2').value) {
137+
document.getElementById('passwordMessage').style.color = 'green';
138+
document.getElementById('passwordMessage').innerHTML = 'contraseñas coinciden';
139+
document.getElementById('createUserBtn').disabled = false;
140+
} else {
141+
document.getElementById('passwordMessage').style.color = 'red';
142+
document.getElementById('passwordMessage').innerHTML = 'contraseñas no coinciden';
143+
document.getElementById('createUserBtn').disabled = true;
144+
}
145+
}
146+
147+
$(document).ready(function () {
148+
$('#myChart').ready(function () {
149+
150+
var games = [];
151+
var solds = [];
152+
153+
$.ajax({
154+
type: "GET",
155+
url: '/api/videogames/stats/sales',
156+
success: function (data) {
157+
158+
for (let item of data) {
159+
games.push(item[0])
160+
solds.push(item[1])
161+
}
162+
163+
var ctx = document.getElementById("myChart");
164+
var myChart = new Chart(ctx, {
165+
type: 'bar',
166+
data: {
167+
labels: games,
168+
datasets: [{
169+
label: 'nº de ventas',
170+
data: solds,
171+
backgroundColor: [
172+
'rgba(255, 99, 132, 0.2)',
173+
'rgba(54, 162, 235, 0.2)',
174+
'rgba(255, 206, 86, 0.2)',
175+
'rgba(75, 192, 192, 0.2)',
176+
'rgba(153, 102, 255, 0.2)',
177+
'rgba(255, 159, 64, 0.2)'
178+
],
179+
borderColor: [
180+
'rgba(255,99,132,1)',
181+
'rgba(54, 162, 235, 1)',
182+
'rgba(255, 206, 86, 1)',
183+
'rgba(75, 192, 192, 1)',
184+
'rgba(153, 102, 255, 1)',
185+
'rgba(255, 159, 64, 1)'
186+
],
187+
borderWidth: 1
188+
}]
189+
},
190+
options: {
191+
scales: {
192+
yAxes: [{
193+
ticks: {
194+
beginAtZero: true
195+
}
196+
}]
197+
}
198+
}
199+
});
200+
},
201+
});
202+
})
203+
})
204+
205+
$(document).ready(function () {
206+
$('#myChartSoldGenre').ready(function () {
207+
208+
var games1 = [];
209+
var solds1 = [];
210+
211+
$.ajax({
212+
type: "GET",
213+
url: '/api/videogames/stats/genres',
214+
success: function (data) {
215+
216+
for (let item of data) {
217+
games1.push(item[0])
218+
solds1.push(item[1])
219+
}
220+
221+
var ctx = document.getElementById("myChartSoldGenre");
222+
var myChartSoldGenre = new Chart(ctx, {
223+
type: 'pie',
224+
data: {
225+
labels: games1,
226+
datasets: [{
227+
label: 'nº de ventas',
228+
data: solds1,
229+
backgroundColor: [
230+
'rgba(255, 99, 132, 0.2)',
231+
'rgba(54, 162, 235, 0.2)',
232+
'rgba(255, 206, 86, 0.2)',
233+
'rgba(75, 192, 192, 0.2)',
234+
'rgba(153, 102, 255, 0.2)',
235+
'rgba(255, 159, 64, 0.2)',
236+
'rgba(0, 0, 0, 0.2)',
237+
'rgba(255, 0, 0, 0.2)',
238+
'rgba(255, 255, 0, 0.2)',
239+
'rgba(0, 255, 0, 0.2)',
240+
'rgba(128, 0, 128, 0.2)'
241+
],
242+
borderColor: [
243+
'rgba(255,99,132,1)',
244+
'rgba(54, 162, 235, 1)',
245+
'rgba(255, 206, 86, 1)',
246+
'rgba(75, 192, 192, 1)',
247+
'rgba(153, 102, 255, 1)',
248+
'rgba(0, 0, 0, 1)',
249+
'rgba(255, 0, 0, 1)',
250+
'rgba(255, 0, 04, 1)',
251+
'rgba(255, 255, 0, 1)',
252+
'rgba(0, 255, 0, 1)',
253+
'rgba(128, 0, 128, 1)'
254+
],
255+
borderWidth: 1
256+
}]
257+
},
258+
options: {
259+
scales: {
260+
yAxes: [{
261+
ticks: {
262+
beginAtZero: true
263+
}
264+
}]
265+
}
266+
}
267+
});
268+
},
269+
});
270+
})
271+
})*/

0 commit comments

Comments
 (0)