This commit is contained in:
CHIEFSOFT\ameye
2023-05-13 09:03:26 -04:00
parent 8431f7c003
commit 6fe3d083f9
9 changed files with 180 additions and 28 deletions
-8
View File
@@ -1,11 +1,3 @@
<!--
Authors : initappz (Rahul Jograna)
Website : https://initappz.com/
App Name : E-Learning App Template
This App Template Source code is licensed as per the
terms found in the Website https://initappz.com/license
Copyright and Good Faith Purchasers © 2021-present initappz.
-->
<ion-header class="ion-no-border">
<ion-toolbar>
<div class="heading">
+1 -8
View File
@@ -1,13 +1,6 @@
/*
Authors : initappz (Rahul Jograna)
Website : https://initappz.com/
App Name : E-Learning App Template
This App Template Source code is licensed as per the
terms found in the Website https://initappz.com/license
Copyright and Good Faith Purchasers © 2021-present initappz.
*/
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { SessionDataProviderService } from 'src/app/store/session-data-provider.service';
@Component({
selector: 'app-home',
+2 -2
View File
@@ -6,12 +6,12 @@
<ion-item lines="none">
<ion-icon slot="start" name="mail-outline"></ion-icon>
<ion-input type="email" placeholder="Email"></ion-input>
<ion-input type="email" placeholder="Email" [(ngModel)]='username'></ion-input>
</ion-item>
<ion-item lines="none">
<ion-icon slot="start" name="lock-closed-outline"></ion-icon>
<ion-input type="password" placeholder="Password"></ion-input>
<ion-input type="password" placeholder="Password" [(ngModel)]='password'></ion-input>
</ion-item>
<div class="check">
+41 -3
View File
@@ -1,5 +1,7 @@
import { Router } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { Component, OnInit, ViewChild } from '@angular/core';
import { WrenchService } from 'src/app/services/wrench.service';
import { SessionDataProviderService } from 'src/app/store/session-data-provider.service';
@Component({
selector: 'app-login',
@@ -7,16 +9,37 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./login.page.scss'],
})
export class LoginPage implements OnInit {
@ViewChild('username') username;
@ViewChild('password') password;
loginResult: any;
constructor(
private router: Router
private router: Router,
private wrenchService: WrenchService,
private sessionDataProviderService:SessionDataProviderService
) { }
ngOnInit() {
}
loginData: {
username: string, password: string, sessionid: string
};
startLogin() {
if (this.username == null || this.username == '' || this.validateEmail(this.username) == false || this.password == null || this.password == '') {
this.showAlert('Invalid Login', 'Enter username(email) and password to login');
return;
}
this.loginData = { username: this.username, password: this.password, sessionid: 'DUMMY-APP-SESSION' }
this.wrenchService.loginUser(this.loginData).subscribe(
loginResult => {
this.loginResult = loginResult;
console.log("INTERNAL RETURN->" + this.loginResult.internal_return);
if (loginResult != null && loginResult.internal_return == 100 && this.sessionDataProviderService.ConstructGlobalSessionData(this.loginResult) == true) {
this.router.navigate(['tabs/tab1']);
}
}
);
//this.router.navigate(['tabs/tab1']);
}
@@ -32,4 +55,19 @@ export class LoginPage implements OnInit {
this.router.navigate(['slider']);
}
validateEmail(email) {
var re = /\S+@\S+\.\S+/;
return re.test(email);
}
showAlert(mtitle: string, amessage: string) {
/* let alert = this.alertCtrl.create({
title: mtitle,
subTitle: amessage,
buttons: ['OK']
});
alert.present();*/
alert(amessage);
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import 'rxjs/add/operator/map';
//import 'rxjs/add/operator/map';
import { environment } from 'src/environments/environment';
@@ -20,14 +20,14 @@ export class WrenchService {
getPostData(reqPath:string, reqData): Observable<any> {
return this.http.post(
`${environment.baseUrl}/movie/}`,reqData
`${environment.baseUrl}/${reqPath}`,reqData
);
}
loginUser(loginData) {
return this.getPostData('getPostData',loginData);
return this.getPostData('userlogin',loginData);
}
/*
registerUser(newUserData) {
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { SessionDataProviderService } from './session-data-provider.service';
describe('SessionDataProviderService', () => {
let service: SessionDataProviderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(SessionDataProviderService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,113 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class SessionDataProviderService {
constructor() {
console.log('Hello SessionDataProvider Store');
}
firstname: string = "";
lastname:string = "";
session: string = "";
balance:number =0;
username:string="";
last_login:string="";
member_id:number = 0;
ccard:number=0;
isPedningJob: number = 0;
isOfferJob: number = 0;
profile_pic:string='';
session_contructed:boolean = false;
ConstructGlobalSessionData(loginResult: any) {
console.log('Hello ConstructGlobalSessionData Provider');
this.session_contructed=false;
try {
console.log(loginResult);
this.firstname = loginResult.firstname;
this.lastname = loginResult.lastname;
this.session = loginResult.session;
this.session_contructed=loginResult.balance;
this.username=loginResult.username;
this.last_login = loginResult.last_login2;
this.member_id = loginResult.member_id;
this.balance = loginResult.balance;
this.ccard=loginResult.ccard;
this.profile_pic=loginResult.profile_pic;
this.isPedningJob = loginResult.pedningjob;
this.isOfferJob = loginResult.offerjob;
//this.pushNotificationProvider.tagUser(this.session);
this.session_contructed = true;
// this.SessionUser.added = loginResult.added;
/* this.SessionUser.added = "";
this.SessionUser.balance = loginResult.balance;
this.SessionUser.city = loginResult.city;
this.SessionUser.country = loginResult.country;
this.SessionUser.email = loginResult.email;
this.SessionUser.fb_id = loginResult.fb_id;
this.SessionUser.firstname = loginResult.firstname;
this.SessionUser.id = loginResult.id;
this.SessionUser.last_login = loginResult.last_login;
this.SessionUser.loc = loginResult.loc;
this.SessionUser.member_id = loginResult.member_id;
this.SessionUser.news = loginResult.news;
this.SessionUser.phone = loginResult.phone;
this.SessionUser.post_jobs = loginResult.post_jobs;
this.SessionUser.profile_pic = loginResult.profile_pic;
this.SessionUser.session = loginResult.session;
this.SessionUser = {
added: loginResult.added,
balance: loginResult.balance,
city: loginResult.city,
country: loginResult.country,
email: loginResult.email,
fb_id: loginResult.fb_id,
firstname: loginResult.firstname,
id: loginResult.id,
last_login: loginResult.last_login,
lastname: loginResult.lastname,
loc: loginResult.loc,
member_id: loginResult.member_id,
news: loginResult.news,
phone: loginResult.phone,
post_jobs: loginResult.post_jobs,
profile_pic: loginResult.profile_pic,
refer: loginResult.refer,
session: loginResult.session,
state: loginResult.state,
status: loginResult.status,
username: loginResult.username
};
this.storage.set('sessionuser', JSON.stringify(this.SessionUser));
*/
} catch (error) {
console.log("LOGIN STORAGE ERROR->" + error);
}
return this.session_contructed;
}
profilePicture(){
var profile_p = '';
if (this.profile_pic !=''){
profile_p="https://www.wrenchboard.com/smedia/LIVE/profile/"+this.profile_pic;
}
return profile_p;
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
export const environment = {
production: true,
apiKey: '', // <-- Enter your own key here!'
baseUrl: 'https://api.themoviedb.org/3',
images: 'http://image.tmdb.org/t/p',
baseUrl: 'https://orion.lotus.g1.wrenchboard.com/svs/user',
images: 'https://orion.lotus.g1.wrenchboard.com/svs/user',
};
+2 -2
View File
@@ -1,7 +1,7 @@
export const environment = {
production: false,
apiKey: '', // <-- Enter your own key here!'
baseUrl: 'https://api.themoviedb.org/3',
images: 'http://image.tmdb.org/t/p',
baseUrl: 'https://apigate.lotus.g1.wrenchboard.com/svs/user',
images: 'https://apigate.lotus.g1.wrenchboard.com/svs/user',
};