|
|
|
|
@ -95,11 +95,12 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
private checkUserResult: CheckUserAuthenticationResponse;
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
console.log("ENAD TEST!!!")
|
|
|
|
|
this.cs.stopLoading();
|
|
|
|
|
// tslint:disable-next-line: triple-equals
|
|
|
|
|
if (TranslatorService.CURRENT_LANGUAGE == TranslatorService.EN) {
|
|
|
|
|
this.language = "US";
|
|
|
|
|
this.language = 'US';
|
|
|
|
|
} else {
|
|
|
|
|
this.language = "AR";
|
|
|
|
|
this.language = 'AR';
|
|
|
|
|
}
|
|
|
|
|
this.ts.switchLanguage();
|
|
|
|
|
this.currentLang = TranslatorService.getCurrentLanguageCode();
|
|
|
|
|
@ -118,72 +119,26 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
this.events.subscribe('user', user => {
|
|
|
|
|
console.log('login compont: ' + user);
|
|
|
|
|
this.events.subscribe('user', user => {
|
|
|
|
|
this.user = user;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.deviceToken = localStorage.getItem('devicyeToken');
|
|
|
|
|
console.log('let deviceToken' + this.deviceToken);
|
|
|
|
|
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
this.deviceToken = localStorage.getItem('devicyeToken');
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
} else {
|
|
|
|
|
console.log('no deviceToken' );
|
|
|
|
|
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
// alert('login enabled second time: ' + this.deviceToken);
|
|
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
// alert("this.logoutFlage in setTime" +localStorage.getItem('logoutFlage'));
|
|
|
|
|
// alert("this.this.user in setTime" + this.user);
|
|
|
|
|
|
|
|
|
|
// if(localStorage.getItem('logoutFlage')== "true"){
|
|
|
|
|
// this.getLastLoginInfo();
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// },1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// here will delete below part and depdding on user (response from getMobileInfo)
|
|
|
|
|
this.username = localStorage.getItem('user');
|
|
|
|
|
this.password = localStorage.getItem('password'); // ****//
|
|
|
|
|
const remember = localStorage.getItem('remember'); // ****//
|
|
|
|
|
this.empname = localStorage.getItem('emp-name');
|
|
|
|
|
this.logintype = localStorage.getItem('login-type');
|
|
|
|
|
this.username = localStorage.getItem('user');
|
|
|
|
|
this.password = localStorage.getItem('password'); // ****//
|
|
|
|
|
const remember = localStorage.getItem('remember'); // ****//
|
|
|
|
|
this.empname = localStorage.getItem('emp-name');
|
|
|
|
|
this.logintype = localStorage.getItem('login-type');
|
|
|
|
|
// tslint:disable-next-line: triple-equals
|
|
|
|
|
if (remember == 'true') { this.remeberMe = true; } else { this.remeberMe = false; }
|
|
|
|
|
|
|
|
|
|
// here will be check on user if exite then s part and depdding on user (response from getMobileInfo)
|
|
|
|
|
|
|
|
|
|
if (this.user) {
|
|
|
|
|
|
|
|
|
|
// this.loginDiv=false;
|
|
|
|
|
// this.welcomeBack=true;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// this.user=true;
|
|
|
|
|
// this.welcomeBack=false;
|
|
|
|
|
}
|
|
|
|
|
// alert("user>>" + this.username);
|
|
|
|
|
// alert("pass>>>" + this.password);
|
|
|
|
|
// alert("remember>>>" + this.remeberMe);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// call getLoginInfo
|
|
|
|
|
|
|
|
|
|
if (remember == 'true') { this.remeberMe = true; } else { this.remeberMe = false; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnDestroy(): void {
|
|
|
|
|
@ -191,14 +146,16 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public changeLanguage(langNumber) {
|
|
|
|
|
if(this.currentLang == langNumber){
|
|
|
|
|
// tslint:disable-next-line: triple-equals
|
|
|
|
|
if (this.currentLang == langNumber) {
|
|
|
|
|
return;
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
this.ts.switchLanguage();
|
|
|
|
|
// tslint:disable-next-line: triple-equals
|
|
|
|
|
if (TranslatorService.CURRENT_LANGUAGE == TranslatorService.EN) {
|
|
|
|
|
this.language = "US";
|
|
|
|
|
this.language = 'US';
|
|
|
|
|
} else {
|
|
|
|
|
this.language = "AR";
|
|
|
|
|
this.language = 'AR';
|
|
|
|
|
}
|
|
|
|
|
this.currentLang = TranslatorService.getCurrentLanguageCode();
|
|
|
|
|
}
|
|
|
|
|
@ -215,36 +172,20 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public addValue(e): void {
|
|
|
|
|
// console.log(e.currentTarget.checked);
|
|
|
|
|
this.remeberMe = true; // e.currentTarget.checked;
|
|
|
|
|
this.remeberMe = true;
|
|
|
|
|
this.remeberMyInfo();
|
|
|
|
|
}
|
|
|
|
|
public remeberMyInfo() {
|
|
|
|
|
// if (this.remeberMe) {
|
|
|
|
|
if (this.username) {localStorage.setItem('user', this.username); }
|
|
|
|
|
if (this.password) {localStorage.setItem('password', this.password); }
|
|
|
|
|
localStorage.setItem('remember', 'true');
|
|
|
|
|
// } else {
|
|
|
|
|
// localStorage.setItem("user", "");
|
|
|
|
|
// localStorage.setItem("password", "");
|
|
|
|
|
// localStorage.setItem("remember", "false");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public onLogin() {
|
|
|
|
|
console.log('onLogin');
|
|
|
|
|
// this.checkAppUpdated();
|
|
|
|
|
// this.checkUserAuthentication();
|
|
|
|
|
|
|
|
|
|
this.deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
console.log('let deviceToken' + this.deviceToken);
|
|
|
|
|
|
|
|
|
|
if (this.deviceToken) {
|
|
|
|
|
console.log('login enabled first time: ' + this.deviceToken);
|
|
|
|
|
this.checkAppUpdated();
|
|
|
|
|
} else {
|
|
|
|
|
console.log('no deviceToken' );
|
|
|
|
|
|
|
|
|
|
this.pushService.startReceiving();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.deviceToken = localStorage.getItem('deviceToken');
|
|
|
|
|
|