pruebas fetch a la api
This commit is contained in:
parent
227c254ebc
commit
00aa79bd3c
File diff suppressed because it is too large
Load Diff
|
@ -29,7 +29,7 @@
|
|||
"zone.js": "~0.10.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "~0.1000.0",
|
||||
"@angular-devkit/build-angular": "^0.1102.1",
|
||||
"@angular/cli": "10.0.8",
|
||||
"@angular/compiler": "~10.0.0",
|
||||
"@angular/compiler-cli": "~10.0.0",
|
||||
|
@ -39,6 +39,7 @@
|
|||
"@types/jasmine": "~3.5.0",
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"@types/node": "^12.11.1",
|
||||
"angular-in-memory-web-api": "^0.11.0",
|
||||
"codelyzer": "^6.0.0",
|
||||
"cordova-android": "^9.0.0",
|
||||
"cordova-plugin-device": "^2.0.2",
|
||||
|
@ -75,4 +76,4 @@
|
|||
"android"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,16 +10,20 @@ import { Discoteca } from './discoteca';
|
|||
})
|
||||
export class ApiService {
|
||||
|
||||
apiUrl = 'api/users';
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
validateUser(loginUser: string, loginPassword: string): boolean{
|
||||
/*validateUser(loginUser: string, loginPassword: string): boolean{
|
||||
return (loginUser=='');
|
||||
}
|
||||
}*/
|
||||
|
||||
getUser (loginUser: string): void{
|
||||
getUser (loginUser: string): Observable<User>{
|
||||
const url = `${this.apiUrl}/${loginUser}`;
|
||||
return this.http.get<User>(url);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ const routes: Routes = [
|
|||
},
|
||||
{
|
||||
path:'',
|
||||
redirectTo: 'tabs',
|
||||
redirectTo: 'login',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@ import { PerfilDiscotecaPage } from './perfil-discoteca/perfil-discoteca.page';
|
|||
import { PromptEventoPage} from './prompt-evento/prompt-evento.page'
|
||||
import { GaleriamodalPageModule } from './galeriamodal/galeriamodal.module';
|
||||
import { LoginPage } from './login/login.page';
|
||||
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
|
||||
|
||||
@NgModule({
|
||||
declarations: [AppComponent, PerfilDiscotecaPage, PromptEventoPage, LoginPage],
|
||||
entryComponents: [],
|
||||
imports: [BrowserModule, HttpClientModule, IonicModule.forRoot(), AppRoutingModule, ReactiveFormsModule, GaleriamodalPageModule],
|
||||
imports: [BrowserModule, HttpClientModule, InMemoryWebApiModule, IonicModule.forRoot(), AppRoutingModule, ReactiveFormsModule, GaleriamodalPageModule],
|
||||
providers: [
|
||||
StatusBar,
|
||||
SplashScreen,
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { InMemoryDataService } from './in-memory-data.service';
|
||||
|
||||
describe('InMemoryDataService', () => {
|
||||
let service: InMemoryDataService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(InMemoryDataService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { InMemoryDbService } from 'angular-in-memory-web-api';
|
||||
import { getMaxListeners } from 'process';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class InMemoryDataService implements InMemoryDbService{
|
||||
|
||||
createDb(){
|
||||
let users = [
|
||||
{id: 1, userType: 0, loginUser: 'berywell@gmail.com', loginPassword: '1234'},
|
||||
{id: 2, userType: 1, loginUser: 'lostmysocks@gmail.com', loginPassword: 'abcd'},
|
||||
{id: 3, userType: 0, loginUser: 'ducktype@gmail.com', loginPassword: 'wasd'}
|
||||
]
|
||||
return {users};
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ApiService } from './api.service';
|
||||
import { User } from './user';
|
||||
|
||||
|
@ -7,24 +8,33 @@ import { User } from './user';
|
|||
})
|
||||
export class LoginService {
|
||||
|
||||
private userId: number;
|
||||
private sessionType: number;
|
||||
private loginUser: string;
|
||||
private loginPassword: string;
|
||||
|
||||
user: User;
|
||||
userId: number;
|
||||
sessionType: number;
|
||||
loginUser: string;
|
||||
loginPassword: string;
|
||||
|
||||
constructor(private apiService: ApiService) {
|
||||
|
||||
}
|
||||
|
||||
validateUser(loginUser: string, loginPassword: string): boolean{
|
||||
/* validateUser(loginUser: string, loginPassword: string): boolean{
|
||||
return (loginUser=='');
|
||||
}
|
||||
} */
|
||||
|
||||
getUser (loginUser: string): void{
|
||||
/* getUser (loginUser: string): void{
|
||||
this.apiService.getUser(loginUser).subscribe(
|
||||
user => {
|
||||
this.user = user;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
postNewUser(user: User): void{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,4 +8,8 @@
|
|||
<ion-button (click)="login()">
|
||||
Login
|
||||
</ion-button>
|
||||
|
||||
<label>
|
||||
|
||||
</label>
|
||||
</ion-content>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { LoginService } from '../login.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
|
@ -8,13 +9,20 @@ import { Router } from '@angular/router';
|
|||
})
|
||||
export class LoginPage implements OnInit {
|
||||
|
||||
constructor(private router: Router) { }
|
||||
userId: number;
|
||||
sessionType: number;
|
||||
loginUser: string;
|
||||
loginPassword: string;
|
||||
|
||||
constructor(private router: Router, private loginService: LoginService) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
}
|
||||
|
||||
login(){
|
||||
this.router.navigate(['/tabs']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue