From cbdbeada4b4b655fc02374240d7d919ac6299e5c Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Wed, 20 Aug 2025 15:26:48 -0400 Subject: [PATCH] fix styles --- src/app/pages/activetask/activetask.page.ts | 848 +++++++-------- src/app/pages/forgot/forgot.page.html | 174 +-- src/app/pages/jobactive/jobactive.page.ts | 405 +++---- src/app/pages/login/login.page.html | 29 +- src/app/pages/login/login.page.scss | 19 +- src/app/pages/login/login.page.ts | 1059 ++++++++++--------- src/app/pages/register/register.page.html | 393 +++---- src/global.scss | 7 + 8 files changed, 1507 insertions(+), 1427 deletions(-) diff --git a/src/app/pages/activetask/activetask.page.ts b/src/app/pages/activetask/activetask.page.ts index d6084be..3befa12 100644 --- a/src/app/pages/activetask/activetask.page.ts +++ b/src/app/pages/activetask/activetask.page.ts @@ -1,9 +1,9 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {AlertController, LoadingController, NavController, ToastController} from "@ionic/angular"; import {Router} from "@angular/router"; -import { SessionDataProviderService } from 'src/app/store/session-data-provider.service'; -import { BlogDataService } from 'src/app/store/blog-data.service'; -import { WrenchService } from 'src/app/services/wrench.service'; +import {SessionDataProviderService} from 'src/app/store/session-data-provider.service'; +import {BlogDataService} from 'src/app/store/blog-data.service'; +import {WrenchService} from 'src/app/services/wrench.service'; import {Camera, CameraResultType, CameraSource} from "@capacitor/camera"; import {TasksDataService} from "../../store/tasks-data.service"; import {FilePicker} from "@capawesome/capacitor-file-picker"; @@ -11,442 +11,462 @@ import {MediaConnectService} from "../../services/media-connect.service"; import {SocketToolsService} from "../../services/socket-tools.service"; @Component({ - selector: 'app-activetask', - templateUrl: './activetask.page.html', - styleUrls: ['./activetask.page.scss'], + selector: 'app-activetask', + templateUrl: './activetask.page.html', + styleUrls: ['./activetask.page.scss'], }) export class ActivetaskPage implements OnInit { - @ViewChild('yourmessage') yourmessage; - tabs = 'activities'; - status_description:string=''; - session_image_server:string=''; - curr_session:string=''; - socket_room:string=''; + @ViewChild('yourmessage') yourmessage; + tabs = 'activities'; + status_description: string = ''; + session_image_server: string = ''; + curr_session: string = ''; + socket_room: string = ''; - jobData: any; - constructor( - private navctr: NavController, - private router: Router, - public sessionDataProviderService: SessionDataProviderService, - private alertController:AlertController, - private wrenchService: WrenchService, - public tasksDataService:TasksDataService, - private toastController: ToastController, - public blogDataService: BlogDataService, - private loadingCtrl: LoadingController, - private mediaConnectService: MediaConnectService, - private socketToolsService: SocketToolsService - ) { - this.yourmessage=''; - this.jobData = this.router.getCurrentNavigation().extras.state; - // debugger; - console.log("XXXXX 1", this.router.getCurrentNavigation().extras); - console.log("XXXXX 2", this.router.getCurrentNavigation().extras.state); - //console.log("XXXXX 3", this.router.getCurrentNavigation().extras.state.ID); - this.status_description = this.jobData?.status_description; - if ( this.jobData == undefined || this.jobData.status_description==''){ - this.onBack(); - } - this.socket_room = `${this.jobData.contract}-${this.jobData.contract_uid}`; - this.socketToolsService.joinSocketRoom(this.socket_room ); - } - - ngOnInit() { - this.curr_session = this.sessionDataProviderService.session; - this.session_image_server = this.sessionDataProviderService.session_image_server; - //this.activeJobMsgList(); - } - - onBack() { - this.navctr.back(); - } - -/* - sendTaskMessage(messageData){ - return this.getPostData("sendtaskmessage", messageData); - } - - activeJobMsgList(contractData){ - return this.getPostData("activejobmsglist", contractData); - } - - 'member_id' => int 1 - 'sessionid' => string '936571FD2E081B667930E7FFDF4D819938171883CA0CC951DC6C4FB184280EB3' (length=64) - 'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36) - 'message' => string 'Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero' (length=127) - 'msg_type' => string 'TEXT' (length=4) - 'contract' => string '49BWBRW738' (length=10) - 'action' => int 14010 - */ - - - // contrData: { - // action:number, - // member_id: number, - // uid: string, - // sessionid: string, - // limit:20, - // contract:string, - // offset: 0 - // }; - // msgListTotalData:any; - // msgListData: []; - // activeJobMsgList(){ - // this.contrData = { - // action:14011, - // member_id: this.sessionDataProviderService.member_id, - // uid: this.sessionDataProviderService.member_uid, - // sessionid: this.sessionDataProviderService.session , - // limit:20, - // contract: this.jobData.contract, - // offset: 0} - // - // this.wrenchService.activeJobMsgList(this.contrData).subscribe( - // msgListTotalData => { - // this.msgListTotalData = msgListTotalData; - // // console.log("REFER RETURN->", this.referTotalData); - // this.msgListData = this.msgListTotalData.result_list; - // console.log("REFER RETURN DATA->", this.msgListData); - // } - // ); - // - // } - - /* - 'member_id' => int 1 - 'sessionid' => string '936571FD2E081B667930E7FFDF4D819938171883CA0CC951DC6C4FB184280EB3' (length=64) - 'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36) - 'message' => string 'Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero' (length=127) - 'msg_type' => string 'TEXT' (length=4) - 'contract' => string '49BWBRW738' (length=10) - 'action' => int 14010 - */ - - reqData: { - action:number, member_id: number, uid: string, sessionid: string, msg_type:string, - contract:string, - message:string - }; - - interest_status:string = ""; - interest_msg_status:string = ""; - - msgReqResult:any; - async sendActiveJobMessage(){ - if (this.yourmessage == undefined || this.yourmessage?.length < 5){ - alert("Enter Message to send"); - return; - } - - const loading = await this.loadingCtrl.create({ - message: 'Sending...', - duration: 2500, - }); - this.reqData = {action:14010, - member_id: this.sessionDataProviderService.member_id, - uid: this.sessionDataProviderService.member_uid, - sessionid: this.sessionDataProviderService.session , - msg_type: "TEXT", - contract:this.jobData.contract, - message: this.yourmessage - } - - loading.present(); - this.wrenchService.sendTaskMessage(this.reqData).subscribe( - reqResult => { - loading.dismiss(); - this.msgReqResult = reqResult; - // console.log("msgReqResult RETURN->", this.msgReqResult); - - this.interest_msg_status = this.msgReqResult?.status; - setTimeout(()=>{ - this.interest_msg_status =''; - },5000); - this.yourmessage =''; - const event = new Event("app-taskactivities-refresh"); - this.yourmessage = ''; - this.socketToolsService.emmitSocketEvent("send_message",this.yourmessage, this.socket_room); - // Dispatch the event. - dispatchEvent(event); + jobData: any; + constructor( + private navctr: NavController, + private router: Router, + public sessionDataProviderService: SessionDataProviderService, + private alertController: AlertController, + private wrenchService: WrenchService, + public tasksDataService: TasksDataService, + private toastController: ToastController, + public blogDataService: BlogDataService, + private loadingCtrl: LoadingController, + private mediaConnectService: MediaConnectService, + private socketToolsService: SocketToolsService + ) { + this.yourmessage = ''; + this.jobData = this.router.getCurrentNavigation().extras.state; + // debugger; + console.log("XXXXX 1", this.router.getCurrentNavigation().extras); + console.log("XXXXX 2", this.router.getCurrentNavigation().extras.state); + //console.log("XXXXX 3", this.router.getCurrentNavigation().extras.state.ID); + this.status_description = this.jobData?.status_description; + if (this.jobData == undefined || this.jobData.status_description == '') { + this.onBack(); } - ); - } - - completionRestricted(){ - const strict_timeline = this.jobData.strict_timeline; - const minimum_due = new Date(this.jobData.minimum_due); - - if ( strict_timeline > 0 ){ - const today = new Date(); - const result = ( today > minimum_due); - if ( result == false) { - const tMeassage = "This task can onlt be marked completed after " + minimum_due; - this.presentToast(tMeassage, "middle", 5500); - } - return result; - } - return true; - } - async taskCompleted(){ - // alert(100); - if ( this.completionRestricted()==false ){ - return; - } - let reqData = { - contract: this.jobData.contract, - contract_uid: this.jobData.contract_uid, - job_action: 'NOTIFY_COMPLETE', + this.socket_room = `${this.jobData.contract}-${this.jobData.contract_uid}`; + this.socketToolsService.joinSocketRoom(this.socket_room); } - const alert = await this.alertController.create({ - header: "Confirm the task is completed.", - message: "The task owner will confirm the completion acceptance or rejection soon.", - buttons: [ - { - text: "Cancel", - role: "cancel", - handler: () => { - // this.getMyOffersData(); - }, - }, - { - text: "Confirm Completed ?", - handler: () => { + ngOnInit() { + this.curr_session = this.sessionDataProviderService.session; + this.session_image_server = this.sessionDataProviderService.session_image_server; + //this.activeJobMsgList(); + } + + onBack() { + this.navctr.back(); + } + + /* + sendTaskMessage(messageData){ + return this.getPostData("sendtaskmessage", messageData); + } + + activeJobMsgList(contractData){ + return this.getPostData("activejobmsglist", contractData); + } + + 'member_id' => int 1 + 'sessionid' => string '936571FD2E081B667930E7FFDF4D819938171883CA0CC951DC6C4FB184280EB3' (length=64) + 'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36) + 'message' => string 'Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero' (length=127) + 'msg_type' => string 'TEXT' (length=4) + 'contract' => string '49BWBRW738' (length=10) + 'action' => int 14010 + */ + + + // contrData: { + // action:number, + // member_id: number, + // uid: string, + // sessionid: string, + // limit:20, + // contract:string, + // offset: 0 + // }; + // msgListTotalData:any; + // msgListData: []; + // activeJobMsgList(){ + // this.contrData = { + // action:14011, + // member_id: this.sessionDataProviderService.member_id, + // uid: this.sessionDataProviderService.member_uid, + // sessionid: this.sessionDataProviderService.session , + // limit:20, + // contract: this.jobData.contract, + // offset: 0} + // + // this.wrenchService.activeJobMsgList(this.contrData).subscribe( + // msgListTotalData => { + // this.msgListTotalData = msgListTotalData; + // // console.log("REFER RETURN->", this.referTotalData); + // this.msgListData = this.msgListTotalData.result_list; + // console.log("REFER RETURN DATA->", this.msgListData); + // } + // ); + // + // } + + /* + 'member_id' => int 1 + 'sessionid' => string '936571FD2E081B667930E7FFDF4D819938171883CA0CC951DC6C4FB184280EB3' (length=64) + 'uid' => string '3119b744-42ad-4834-bb83-b737588754ca' (length=36) + 'message' => string 'Lorem Ipsum comes from a latin text written in 45BC by Roman statesman, lawyer, scholar, and philosopher, Marcus Tullius Cicero' (length=127) + 'msg_type' => string 'TEXT' (length=4) + 'contract' => string '49BWBRW738' (length=10) + 'action' => int 14010 + */ + + reqData: { + action: number, member_id: number, uid: string, sessionid: string, msg_type: string, + contract: string, + message: string + }; + + interest_status: string = ""; + interest_msg_status: string = ""; + + msgReqResult: any; + + // async presentToast(amessage, position: "top" | "middle" | "bottom") { + // const toast = await this.toastController.create({ + // message: amessage, + // duration: 3000, + // position: position, + // }); + // + // await toast.present(); + // } + + async sendActiveJobMessage() { + if (this.yourmessage == undefined || this.yourmessage?.length < 5) { + //alert("Enter Message to send"); + await this.presentToast("Please enter the message to send", "middle"); + return; + } + + + const loading = await this.loadingCtrl.create({ + message: 'Sending...', + duration: 2500, + }); + this.reqData = { + action: 14010, + member_id: this.sessionDataProviderService.member_id, + uid: this.sessionDataProviderService.member_uid, + sessionid: this.sessionDataProviderService.session, + msg_type: "TEXT", + contract: this.jobData.contract, + message: this.yourmessage + } + + loading.present(); + this.wrenchService.sendTaskMessage(this.reqData).subscribe( + reqResult => { + loading.dismiss(); + this.msgReqResult = reqResult; + // console.log("msgReqResult RETURN->", this.msgReqResult); + + this.interest_msg_status = this.msgReqResult?.status; + setTimeout(() => { + this.interest_msg_status = ''; + }, 5000); + this.yourmessage = ''; + const event = new Event("app-taskactivities-refresh"); + this.yourmessage = ''; + this.socketToolsService.emmitSocketEvent("send_message", this.yourmessage, this.socket_room); + // Dispatch the event. + dispatchEvent(event); + + } + ); + } + + completionRestricted() { + const strict_timeline = this.jobData.strict_timeline; + const minimum_due = new Date(this.jobData.minimum_due); + + if (strict_timeline > 0) { + const today = new Date(); + const result = (today > minimum_due); + if (result == false) { + const tMeassage = "This task can onlt be marked completed after " + minimum_due; + this.presentToast(tMeassage, "middle", 5500); + } + return result; + } + return true; + } + + async taskCompleted() { + // alert(100); + if (this.completionRestricted() == false) { + return; + } + let reqData = { + contract: this.jobData.contract, + contract_uid: this.jobData.contract_uid, + job_action: 'NOTIFY_COMPLETE', + } + + const alert = await this.alertController.create({ + header: "Confirm the task is completed.", + message: "The task owner will confirm the completion acceptance or rejection soon.", + buttons: [ + { + text: "Cancel", + role: "cancel", + handler: () => { + // this.getMyOffersData(); + }, + }, + { + text: "Confirm Completed ?", + handler: () => { // start - // API CALL TO MARK TASK AS COMPLETED BY WORKER - this.wrenchService.workerJobAction(reqData).subscribe((res)=> { - if (res.status != 200 || res.data.internal_return < 0) { - // setReqStatus({loading:false, status: false, message: 'unable to complete request. Try again'}) - // Alert("Unable to set task as completed, try again soon"); - } else { - this.router.navigate(['mytasks']); - } - } - ); - // this.router.navigate(['mytasks']); - // end - }, - }, - ], - }); - await alert.present(); -} - async taskCancel(){ - let reqData = { - contract: this.jobData.contract, - contract_uid: this.jobData.contract_uid, - job_action: 'NOTIFY_CANCEL', + // API CALL TO MARK TASK AS COMPLETED BY WORKER + this.wrenchService.workerJobAction(reqData).subscribe((res) => { + if (res.status != 200 || res.data.internal_return < 0) { + // setReqStatus({loading:false, status: false, message: 'unable to complete request. Try again'}) + // Alert("Unable to set task as completed, try again soon"); + } else { + this.router.navigate(['mytasks']); + } + } + ); + // this.router.navigate(['mytasks']); + // end + }, + }, + ], + }); + await alert.present(); } - const alert = await this.alertController.create({ - header: "Confirm Cancel Request.", - message: "The task owner will be informed of this cancellation. Once completed, we cannot reverse this action.", - buttons: [ - { - text: "Cancel", - role: "cancel", - handler: () => { - // this.getMyOffersData(); - }, - }, - { - text: "Confirm Cancel ?", - handler: () => { + async taskCancel() { + let reqData = { + contract: this.jobData.contract, + contract_uid: this.jobData.contract_uid, + job_action: 'NOTIFY_CANCEL', + } + + const alert = await this.alertController.create({ + header: "Confirm Cancel Request.", + message: "The task owner will be informed of this cancellation. Once completed, we cannot reverse this action.", + buttons: [ + { + text: "Cancel", + role: "cancel", + handler: () => { + // this.getMyOffersData(); + }, + }, + { + text: "Confirm Cancel ?", + handler: () => { // start - // API CALL TO MARK TASK AS COMPLETED BY WORKER - this.wrenchService.workerJobAction(reqData).subscribe((res)=> { - if (res.status != 200 || res.data.internal_return < 0) { - // setReqStatus({loading:false, status: false, message: 'unable to complete request. Try again'}) - // Alert("Unable to set task as completed, try again soon"); - } else { - this.router.navigate(['mytasks']); - } - } - ); - // this.router.navigate(['mytasks']); - // end - }, - }, - ], - }); - await alert.present(); - } - - - uploadData: { - action:number, - member_id: number, - uid: string, - contract: string, - sessionid: string, - msg_type:'FILE', - file_name: string, - file_size: number, - file_type: string, - file_data: string - }; - - uploadResult:any; - async startCamera(cameraMode){ - const image = await Camera.getPhoto({ - quality: 50, - width : 600, - height : 300, - allowEditing: false, - resultType: CameraResultType.Base64, - source: (cameraMode == 100 ) ? CameraSource.Camera : CameraSource.Prompt // Camera, Photos or Prompt! - }); - - if (image) { - const loading = await this.loadingCtrl.create({ - message: 'Uploading updates', - duration: 5000, - }); - var file_size = parseInt(String(image.base64String.toString().length / 1.3224954) ) ; - // this.saveImage(image) - //debugger; - //image.base64String - this.uploadData={ - action:14010, - member_id: this.sessionDataProviderService.member_id, - uid: this.sessionDataProviderService.member_uid, - contract: this.jobData.contract, - sessionid: this.sessionDataProviderService.session , - msg_type:'FILE', - file_name: `${this.jobData.contract}-job.${image.format}`, - file_size: file_size , - file_type: `image/${image.format}`, - file_data: image.base64String - }; - // console.log(this.uploadData); - loading.present(); - this.wrenchService.uploadFile(this.uploadData).subscribe( - uploadResult => { - this.uploadResult = uploadResult; - console.log("this.wrenchService.uploadFile RETURN DATA->", this.uploadResult); - const event = new Event("app-taskactivities-refresh"); - // Dispatch the event. - dispatchEvent(event); - } - ); - - // console.log( this.uploadData); - } - } - - request_result:string=''; - isDisabled:boolean= false; - async requestExtension(){ - let reqData = { - contract: this.jobData.contract, - contract_uid: this.jobData.contract_uid, - job_action: 'NOTIFY_REQEXTENT', + // API CALL TO MARK TASK AS COMPLETED BY WORKER + this.wrenchService.workerJobAction(reqData).subscribe((res) => { + if (res.status != 200 || res.data.internal_return < 0) { + // setReqStatus({loading:false, status: false, message: 'unable to complete request. Try again'}) + // Alert("Unable to set task as completed, try again soon"); + } else { + this.router.navigate(['mytasks']); + } + } + ); + // this.router.navigate(['mytasks']); + // end + }, + }, + ], + }); + await alert.present(); } - const loading = await this.loadingCtrl.create({ - message: 'Sending...', - duration: 2500, - }); - const alert = await this.alertController.create({ - header: "Request Extensions", - message: "Confirm you are ready to send request?", - buttons: [ - { - text: "Cancel", - role: "cancel", - handler: () => { - // this.getMyOffersData(); - }, - }, - { - text: "Send Request", - handler: () => { - loading.present(); - // API CALL TO MARK TASK AS COMPLETED BY WORKER - this.wrenchService.workerJobAction(reqData).subscribe((res)=> { - // debugger; - loading.dismiss(); - if (res.result != '' || res.internal_return == 0) { - this.request_result = res.result; - this.isDisabled=true; - this.tasksDataService.getJobsData(); - } else { - // this.router.navigate(['mytasks']); - } + uploadData: { + action: number, + member_id: number, + uid: string, + contract: string, + sessionid: string, + msg_type: 'FILE', + file_name: string, + file_size: number, + file_type: string, + file_data: string + }; + + uploadResult: any; + + async startCamera(cameraMode) { + const image = await Camera.getPhoto({ + quality: 50, + width: 600, + height: 300, + allowEditing: false, + resultType: CameraResultType.Base64, + source: (cameraMode == 100) ? CameraSource.Camera : CameraSource.Prompt // Camera, Photos or Prompt! + }); + + if (image) { + const loading = await this.loadingCtrl.create({ + message: 'Uploading updates', + duration: 5000, + }); + var file_size = parseInt(String(image.base64String.toString().length / 1.3224954)); + // this.saveImage(image) + //debugger; + //image.base64String + this.uploadData = { + action: 14010, + member_id: this.sessionDataProviderService.member_id, + uid: this.sessionDataProviderService.member_uid, + contract: this.jobData.contract, + sessionid: this.sessionDataProviderService.session, + msg_type: 'FILE', + file_name: `${this.jobData.contract}-job.${image.format}`, + file_size: file_size, + file_type: `image/${image.format}`, + file_data: image.base64String + }; + // console.log(this.uploadData); + loading.present(); + this.wrenchService.uploadFile(this.uploadData).subscribe( + uploadResult => { + this.uploadResult = uploadResult; + console.log("this.wrenchService.uploadFile RETURN DATA->", this.uploadResult); + const event = new Event("app-taskactivities-refresh"); + // Dispatch the event. + dispatchEvent(event); } ); + // console.log( this.uploadData); + } + } - }, - }, - ], - }); - await alert.present(); - } + request_result: string = ''; + isDisabled: boolean = false; - uploadFormData: { - action:number, - member_id: number, - uid: string, - contract: string, - sessionid: string, - msg_type:'FILE' - }; + async requestExtension() { + let reqData = { + contract: this.jobData.contract, + contract_uid: this.jobData.contract_uid, + job_action: 'NOTIFY_REQEXTENT', + } - async pickFiles (fileMode) { - const result = await FilePicker.pickFiles({ - types: ['image/png','image/jpeg','video/mp4'], - multiple: false, - readData:true - }); + const loading = await this.loadingCtrl.create({ + message: 'Sending...', + duration: 2500, + }); - const loading = await this.loadingCtrl.create({ - message: 'Uploading...', - duration: 5000, - }); + const alert = await this.alertController.create({ + header: "Request Extensions", + message: "Confirm you are ready to send request?", + buttons: [ + { + text: "Cancel", + role: "cancel", + handler: () => { + // this.getMyOffersData(); + }, + }, + { + text: "Send Request", + handler: () => { + loading.present(); + // API CALL TO MARK TASK AS COMPLETED BY WORKER + this.wrenchService.workerJobAction(reqData).subscribe((res) => { + // debugger; + loading.dismiss(); + if (res.result != '' || res.internal_return == 0) { + this.request_result = res.result; + this.isDisabled = true; + this.tasksDataService.getJobsData(); + } else { + // this.router.navigate(['mytasks']); + } + } + ); - if(result){ - console.log(result); - // debugger; - this.uploadFormData={ - action:14010, - member_id: this.sessionDataProviderService.member_id, - uid: this.sessionDataProviderService.member_uid, - contract: this.jobData.contract, - sessionid: this.sessionDataProviderService.session , - msg_type:'FILE' - }; - console.log(this.uploadFormData); - for (const [key, value] of Object.entries( this.uploadFormData )) { - console.log(`${key}: ${value}`); - } + }, + }, + ], + }); + await alert.present(); + } - // var blob = new Blob([ result.files[0].data ], { type: result.files[0].mimeType }); - var file = new File([result.files[0].blob], result.files[0].name, {type: result.files[0].mimeType }); + uploadFormData: { + action: number, + member_id: number, + uid: string, + contract: string, + sessionid: string, + msg_type: 'FILE' + }; + + async pickFiles(fileMode) { + const result = await FilePicker.pickFiles({ + types: ['image/png', 'image/jpeg', 'video/mp4'], + multiple: false, + readData: true + }); + + const loading = await this.loadingCtrl.create({ + message: 'Uploading...', + duration: 5000, + }); + + if (result) { + console.log(result); + // debugger; + this.uploadFormData = { + action: 14010, + member_id: this.sessionDataProviderService.member_id, + uid: this.sessionDataProviderService.member_uid, + contract: this.jobData.contract, + sessionid: this.sessionDataProviderService.session, + msg_type: 'FILE' + }; + + console.log(this.uploadFormData); + for (const [key, value] of Object.entries(this.uploadFormData)) { + console.log(`${key}: ${value}`); + } + + // var blob = new Blob([ result.files[0].data ], { type: result.files[0].mimeType }); + var file = new File([result.files[0].blob], result.files[0].name, {type: result.files[0].mimeType}); //return; - await loading.present(); - this.mediaConnectService.uploadtaskFile(this.uploadFormData, file).subscribe( - uploadResult => { - loading.dismiss(); - this.uploadResult = uploadResult; - console.log("this.mediaConnectService.uploadFile RETURN DATA->", this.uploadFormData); - const event = new Event("app-taskactivities-refresh"); - // Dispatch the event. - dispatchEvent(event); - } - ); + await loading.present(); + this.mediaConnectService.uploadtaskFile(this.uploadFormData, file).subscribe( + uploadResult => { + loading.dismiss(); + this.uploadResult = uploadResult; + console.log("this.mediaConnectService.uploadFile RETURN DATA->", this.uploadFormData); + const event = new Event("app-taskactivities-refresh"); + // Dispatch the event. + dispatchEvent(event); + } + ); + } } - } - async presentToast(amessage, position: 'top' | 'middle' | 'bottom', duration: number= 2500) { - const toast = await this.toastController.create({ - message: amessage, - duration: duration, - position: position, - }); - await toast.present(); - } + async presentToast(amessage, position: 'top' | 'middle' | 'bottom', duration: number = 2500) { + const toast = await this.toastController.create({ + message: amessage, + duration: duration, + position: position, + }); + + await toast.present(); + } } diff --git a/src/app/pages/forgot/forgot.page.html b/src/app/pages/forgot/forgot.page.html index 4123b38..e0e26b3 100644 --- a/src/app/pages/forgot/forgot.page.html +++ b/src/app/pages/forgot/forgot.page.html @@ -1,91 +1,99 @@ -
- - -
-
- Forgot password - - Select which contact details should we use to reset your - password: - - - - Via email - - - - - - Via sms - - -
- -
- -
diff --git a/src/app/pages/jobactive/jobactive.page.ts b/src/app/pages/jobactive/jobactive.page.ts index 69027c1..891f30f 100644 --- a/src/app/pages/jobactive/jobactive.page.ts +++ b/src/app/pages/jobactive/jobactive.page.ts @@ -1,5 +1,5 @@ import {Component, OnInit, ViewChild} from '@angular/core'; -import {LoadingController, NavController} from "@ionic/angular"; +import {LoadingController, NavController, ToastController} from "@ionic/angular"; import {Router} from "@angular/router"; import {SessionDataProviderService} from "../../store/session-data-provider.service"; import {WrenchService} from "../../services/wrench.service"; @@ -9,212 +9,227 @@ import {FilePicker} from "@capawesome/capacitor-file-picker"; import {MediaConnectService} from "../../services/media-connect.service"; @Component({ - selector: 'app-jobactive', - templateUrl: './jobactive.page.html', - styleUrls: ['./jobactive.page.scss'], + selector: 'app-jobactive', + templateUrl: './jobactive.page.html', + styleUrls: ['./jobactive.page.scss'], }) export class JobactivePage implements OnInit { - @ViewChild('yourmessage') yourmessage; + @ViewChild('yourmessage') yourmessage; - jobData: any; - tabs = 'message'; - item_banner:string = 'default.jpg'; - session_image_server:string=''; - curr_session:string=''; - socket_room:string=''; + jobData: any; + tabs = 'message'; + item_banner: string = 'default.jpg'; + session_image_server: string = ''; + curr_session: string = ''; + socket_room: string = ''; - constructor( - private navctr: NavController, - private router: Router, - public sessionDataProviderService: SessionDataProviderService, - private wrenchService: WrenchService, - private socketToolsService: SocketToolsService, - private loadingCtrl: LoadingController, - private mediaConnectService: MediaConnectService - ) { - this.jobData = this.router.getCurrentNavigation().extras.state; - this.item_banner = this.jobData.banner; + constructor( + private navctr: NavController, + private router: Router, + public sessionDataProviderService: SessionDataProviderService, + private wrenchService: WrenchService, + private socketToolsService: SocketToolsService, + private toastController: ToastController, + private loadingCtrl: LoadingController, + private mediaConnectService: MediaConnectService + ) { + this.jobData = this.router.getCurrentNavigation().extras.state; + this.item_banner = this.jobData.banner; - if ( this.jobData == undefined){ - this.onBack(); - } - // debugger; - this.socket_room = `${this.jobData.contract}-${this.jobData.contract_uid}`; - this.socketToolsService.joinSocketRoom(this.socket_room ); - } - - - ngOnInit() { - this.curr_session = this.sessionDataProviderService.session; - this.session_image_server = this.sessionDataProviderService.session_image_server; - //this.activeJobMsgList(); - } - - onBack() { - this.navctr.back(); - } - - - reqData: { - action:number, member_id: number, uid: string, sessionid: string, msg_type:string, - contract:string, - message:string - }; - - interest_status:string = ""; - interest_msg_status:string = ""; - - msgReqResult:any; - async sendActiveJobMessage(){ - if (this.yourmessage == undefined || this.yourmessage?.length < 5){ - alert("Enter Message to send"); - return; - } - - const loading = await this.loadingCtrl.create({ - message: 'Sending...', - duration: 2500, - }); - this.reqData = {action:14010, - member_id: this.sessionDataProviderService.member_id, - uid: this.sessionDataProviderService.member_uid, - sessionid: this.sessionDataProviderService.session , - msg_type: "TEXT", - contract:this.jobData.contract, - message: this.yourmessage - } - - loading.present(); - this.wrenchService.sendTaskMessage(this.reqData).subscribe( - reqResult => { - this.msgReqResult = reqResult; - console.log("msgReqResult RETURN->", this.msgReqResult); - this.interest_msg_status = this.msgReqResult?.status; - this.yourmessage = ''; - //this.activeJobMsgList(); - const event = new Event("app-taskactivities-refresh"); - // Dispatch the event. - dispatchEvent(event); - //alert(this.socket_room); - // debugger; - this.socketToolsService.emmitSocketEvent("send_message",this.yourmessage, this.socket_room); + if (this.jobData == undefined) { + this.onBack(); } - ); - } - - - uploadData: { - action:number, - member_id: number, - uid: string, - contract: string, - sessionid: string, - msg_type:'FILE', - file_name: string, - file_size: number, - file_type: string, - file_data: string - }; - - uploadResult:any; - async startCamera(cameraMode){ - const image = await Camera.getPhoto({ - quality: 50, - width : 600, - height : 300, - allowEditing: false, - resultType: CameraResultType.Base64, - source: (cameraMode == 100 ) ? CameraSource.Camera : CameraSource.Prompt // Camera, Photos or Prompt! - }); - - if (image) { - const loading = await this.loadingCtrl.create({ - message: 'Uploading updates', - duration: 5000, - }); - var file_size = parseInt(String(image.base64String.toString().length / 1.3224954) ) ; - // this.saveImage(image) - //debugger; - //image.base64String - this.uploadData={ - action:14010, - member_id: this.sessionDataProviderService.member_id, - uid: this.sessionDataProviderService.member_uid, - contract: this.jobData.contract, - sessionid: this.sessionDataProviderService.session , - msg_type:'FILE', - file_name: `${this.jobData.contract}-job.${image.format}`, - file_size: file_size , - file_type: `image/${image.format}`, - file_data: image.base64String - }; - // console.log(this.uploadData); - loading.present(); - this.wrenchService.uploadFile(this.uploadData).subscribe( - uploadResult => { - this.uploadResult = uploadResult; - console.log("this.wrenchService.uploadFile RETURN DATA->", this.uploadResult); - const event = new Event("app-taskactivities-refresh"); - // Dispatch the event. - dispatchEvent(event); - } - ); - - // console.log( this.uploadData); + // debugger; + this.socket_room = `${this.jobData.contract}-${this.jobData.contract_uid}`; + this.socketToolsService.joinSocketRoom(this.socket_room); } - } - uploadFormData: { - action:number, - member_id: number, - uid: string, - contract: string, - sessionid: string, - msg_type:'FILE' - }; - async pickFiles (fileMode) { - const result = await FilePicker.pickFiles({ - types: ['image/png','image/jpeg','video/mp4'], - multiple: false, - readData:true - }); - const loading = await this.loadingCtrl.create({ - message: 'Uploading...', - duration: 5000, - }); + ngOnInit() { + this.curr_session = this.sessionDataProviderService.session; + this.session_image_server = this.sessionDataProviderService.session_image_server; + //this.activeJobMsgList(); + } - if(result){ - console.log(result); - // debugger; - this.uploadFormData={ - action:14010, - member_id: this.sessionDataProviderService.member_id, - uid: this.sessionDataProviderService.member_uid, - contract: this.jobData.contract, - sessionid: this.sessionDataProviderService.session , - msg_type:'FILE' - }; + onBack() { + this.navctr.back(); + } - console.log(this.uploadFormData); - for (const [key, value] of Object.entries( this.uploadFormData )) { - console.log(`${key}: ${value}`); - } - var blob = new Blob([ result.files[0].data ], { type: result.files[0].mimeType }); - var file = new File([blob], result.files[0].name, {type: result.files[0].mimeType }); + reqData: { + action: number, member_id: number, uid: string, sessionid: string, msg_type: string, + contract: string, + message: string + }; + + interest_status: string = ""; + interest_msg_status: string = ""; + + msgReqResult: any; + + async presentToast(amessage, position: 'top' | 'middle' | 'bottom', duration: number = 2500) { + const toast = await this.toastController.create({ + message: amessage, + duration: duration, + position: position, + }); + + await toast.present(); + } + + async sendActiveJobMessage() { + if (this.yourmessage == undefined || this.yourmessage?.length < 5) { + await this.presentToast("Please enter the message to send", "middle"); + return; + } + + const loading = await this.loadingCtrl.create({ + message: 'Sending...', + duration: 2500, + }); + this.reqData = { + action: 14010, + member_id: this.sessionDataProviderService.member_id, + uid: this.sessionDataProviderService.member_uid, + sessionid: this.sessionDataProviderService.session, + msg_type: "TEXT", + contract: this.jobData.contract, + message: this.yourmessage + } + + loading.present(); + this.wrenchService.sendTaskMessage(this.reqData).subscribe( + reqResult => { + this.msgReqResult = reqResult; + console.log("msgReqResult RETURN->", this.msgReqResult); + this.interest_msg_status = this.msgReqResult?.status; + this.yourmessage = ''; + //this.activeJobMsgList(); + const event = new Event("app-taskactivities-refresh"); + // Dispatch the event. + dispatchEvent(event); + //alert(this.socket_room); + // debugger; + this.socketToolsService.emmitSocketEvent("send_message", this.yourmessage, this.socket_room); + } + ); + } + + + uploadData: { + action: number, + member_id: number, + uid: string, + contract: string, + sessionid: string, + msg_type: 'FILE', + file_name: string, + file_size: number, + file_type: string, + file_data: string + }; + + uploadResult: any; + + async startCamera(cameraMode) { + const image = await Camera.getPhoto({ + quality: 50, + width: 600, + height: 300, + allowEditing: false, + resultType: CameraResultType.Base64, + source: (cameraMode == 100) ? CameraSource.Camera : CameraSource.Prompt // Camera, Photos or Prompt! + }); + + if (image) { + const loading = await this.loadingCtrl.create({ + message: 'Uploading updates', + duration: 5000, + }); + var file_size = parseInt(String(image.base64String.toString().length / 1.3224954)); + // this.saveImage(image) + //debugger; + //image.base64String + this.uploadData = { + action: 14010, + member_id: this.sessionDataProviderService.member_id, + uid: this.sessionDataProviderService.member_uid, + contract: this.jobData.contract, + sessionid: this.sessionDataProviderService.session, + msg_type: 'FILE', + file_name: `${this.jobData.contract}-job.${image.format}`, + file_size: file_size, + file_type: `image/${image.format}`, + file_data: image.base64String + }; + // console.log(this.uploadData); + loading.present(); + this.wrenchService.uploadFile(this.uploadData).subscribe( + uploadResult => { + this.uploadResult = uploadResult; + console.log("this.wrenchService.uploadFile RETURN DATA->", this.uploadResult); + const event = new Event("app-taskactivities-refresh"); + // Dispatch the event. + dispatchEvent(event); + } + ); + + // console.log( this.uploadData); + } + } + + uploadFormData: { + action: number, + member_id: number, + uid: string, + contract: string, + sessionid: string, + msg_type: 'FILE' + }; + + async pickFiles(fileMode) { + const result = await FilePicker.pickFiles({ + types: ['image/png', 'image/jpeg', 'video/mp4'], + multiple: false, + readData: true + }); + + const loading = await this.loadingCtrl.create({ + message: 'Uploading...', + duration: 5000, + }); + + if (result) { + console.log(result); + // debugger; + this.uploadFormData = { + action: 14010, + member_id: this.sessionDataProviderService.member_id, + uid: this.sessionDataProviderService.member_uid, + contract: this.jobData.contract, + sessionid: this.sessionDataProviderService.session, + msg_type: 'FILE' + }; + + console.log(this.uploadFormData); + for (const [key, value] of Object.entries(this.uploadFormData)) { + console.log(`${key}: ${value}`); + } + + var blob = new Blob([result.files[0].data], {type: result.files[0].mimeType}); + var file = new File([blob], result.files[0].name, {type: result.files[0].mimeType}); //return; - await loading.present(); - this.mediaConnectService.uploadtaskFile(this.uploadFormData, file).subscribe( - uploadResult => { - loading.dismiss(); - this.uploadResult = uploadResult; - console.log("this.mediaConnectService.uploadFile RETURN DATA->", this.uploadFormData); - const event = new Event("app-taskactivities-refresh"); - // Dispatch the event. - dispatchEvent(event); - } - ); + await loading.present(); + this.mediaConnectService.uploadtaskFile(this.uploadFormData, file).subscribe( + uploadResult => { + loading.dismiss(); + this.uploadResult = uploadResult; + console.log("this.mediaConnectService.uploadFile RETURN DATA->", this.uploadFormData); + const event = new Event("app-taskactivities-refresh"); + // Dispatch the event. + dispatchEvent(event); + } + ); + } } - } } diff --git a/src/app/pages/login/login.page.html b/src/app/pages/login/login.page.html index 99dda8b..c9326bb 100644 --- a/src/app/pages/login/login.page.html +++ b/src/app/pages/login/login.page.html @@ -6,18 +6,19 @@
- +
+ Welcome back + +
{{login_response}}
- Forgot your password ? - -
+
+ Forgot your password ? + +
+ +
Or Continue With
diff --git a/src/app/pages/login/login.page.scss b/src/app/pages/login/login.page.scss index bd5ab4c..1e79259 100644 --- a/src/app/pages/login/login.page.scss +++ b/src/app/pages/login/login.page.scss @@ -1,30 +1,33 @@ ion-content { - .family_box{ + .family_box { margin-bottom: 20px; } -.login-type22{ - font-weight: bolder; - color:white; -} - .pending-buttom{ + .login-type22 { + font-weight: bolder; + color: white; + } + + .pending-buttom { padding-top: 25px; } - .simp_lbl_tx{ + .simp_lbl_tx { margin-top: 10px; font-size: 20px; letter-spacing: 1.2px; margin-bottom: 10px; font-family: 'semi-bold'; } - .login-type{ + + .login-type { background-color: #3dc2ff; border-radius: 10px; height: 50px; font-weight: bolder; } + ion-item { --background: #f7f7f7; border-radius: 10px; diff --git a/src/app/pages/login/login.page.ts b/src/app/pages/login/login.page.ts index f8e502a..c818ec0 100644 --- a/src/app/pages/login/login.page.ts +++ b/src/app/pages/login/login.page.ts @@ -1,23 +1,23 @@ -import { Router } from '@angular/router'; -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'; -import { BlogDataService } from 'src/app/store/blog-data.service'; -import { environment} from "../../../environments/environment"; -import {AlertController, LoadingController, Platform} from '@ionic/angular'; -import { Preferences } from '@capacitor/preferences'; -import { Capacitor } from '@capacitor/core'; +import {Router} from '@angular/router'; +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'; +import {BlogDataService} from 'src/app/store/blog-data.service'; +import {environment} from "../../../environments/environment"; +import {AlertController, LoadingController, Platform, ToastController} from '@ionic/angular'; +import {Preferences} from '@capacitor/preferences'; +import {Capacitor} from '@capacitor/core'; import jwt_decode from "jwt-decode"; import { - SignInWithApple, - SignInWithAppleResponse, - SignInWithAppleOptions, + SignInWithApple, + SignInWithAppleResponse, + SignInWithAppleOptions, } from '@capacitor-community/apple-sign-in'; import { - FacebookLogin, - FacebookLoginResponse, + FacebookLogin, + FacebookLoginResponse, } from '@capacitor-community/facebook-login'; -import { GoogleAuth, User } from '@codetrix-studio/capacitor-google-auth'; +import {GoogleAuth, User} from '@codetrix-studio/capacitor-google-auth'; import {UserWalletService} from "../../store/user-wallet.service"; import {IntervalRefreshService} from "../../store/interval-refresh.service"; import {MarketDataService} from "../../store/market-data.service"; @@ -26,206 +26,209 @@ import {BannersDataService} from "../../store/banners-data.service"; import {SocketToolsService} from "../../services/socket-tools.service"; @Component({ - selector: 'app-login', - templateUrl: './login.page.html', - styleUrls: ['./login.page.scss'], + selector: 'app-login', + templateUrl: './login.page.html', + styleUrls: ['./login.page.scss'], }) export class LoginPage implements OnInit { - @ViewChild('username') username; - @ViewChild('password') password; + @ViewChild('username') username; + @ViewChild('password') password; - // @ViewChild('signup_username') signup_username; - @ViewChild('random_text') random_text; - @ViewChild('signup_password') signup_password; + // @ViewChild('signup_username') signup_username; + @ViewChild('random_text') random_text; + @ViewChild('signup_password') signup_password; - loginResult: any; - blogResult:any; - showSocial:boolean = true; - appleSignInAbortController: any; - appleSignInWindow: any; - state: any; - ios: boolean; - android: boolean; - isDisabled:boolean=true; - isPendingDisabled:boolean=true; - loginType:string='normal'; - pending_uid:string=''; - signup_country:string=''; - signup_username:string=''; + loginResult: any; + blogResult: any; + showSocial: boolean = true; + appleSignInAbortController: any; + appleSignInWindow: any; + state: any; + ios: boolean; + android: boolean; + isDisabled: boolean = true; + isPendingDisabled: boolean = true; + loginType: string = 'normal'; + pending_uid: string = ''; + signup_country: string = ''; + signup_username: string = ''; - login_response:string=""; + login_response: string = ""; - constructor( - private router: Router, - private wrenchService: WrenchService, - public sessionDataProviderService:SessionDataProviderService, - public blogDataService:BlogDataService, - private alertController: AlertController, - public userWalletService: UserWalletService, - public intervalRefreshService: IntervalRefreshService, - public platform: Platform, - private socketToolsService: SocketToolsService, - private loadingCtrl: LoadingController, - public marketDataService:MarketDataService, - public tasksDataService:TasksDataService, - public bannersDataService:BannersDataService - ) { - this.sessionDataProviderService.DestroySessionOnLogout(); - // https://ionicframework.com/docs/angular/platform - this.ios = platform.is('ios'); - this.android = platform.is('android'); - } - - ionViewDidEnter() { - // GoogleAuth.init(); - // use hook after platform dom ready - GoogleAuth.initialize({ - clientId: '817021856543-khlurl8ifdr0sd2cvekn167d02mk9dlg.apps.googleusercontent.com', - scopes: ['profile', 'email'], - grantOfflineAccess: true, - }); - } - - ngOnInit() { - this.showSocial = environment.loginSocial; - // this.username='ses66181+6018@gmail.com'; - // this.username='ses66181+1@gmail.com'; - // this.password='may12002'; - - const checkName = async () => { - const { value } = await Preferences.get({ key: 'username' }); - this.username=value; - - //console.log(`Hello ${value}!`); - }; - - checkName(); - // use hook after platform dom ready - FacebookLogin.initialize({ appId: environment.facebookAppId }); - this.refreshBut(); - } - -getBlogData(){ - this.wrenchService.getBlogData([]).subscribe( - blogResult => { - this.blogResult = blogResult; - console.log("BLOG RETURN->", this.blogResult); - this.blogDataService.setBlogData(this.blogResult.blogdata); + constructor( + private router: Router, + private wrenchService: WrenchService, + public sessionDataProviderService: SessionDataProviderService, + public blogDataService: BlogDataService, + private alertController: AlertController, + public userWalletService: UserWalletService, + public intervalRefreshService: IntervalRefreshService, + public platform: Platform, + private socketToolsService: SocketToolsService, + private loadingCtrl: LoadingController, + public marketDataService: MarketDataService, + public tasksDataService: TasksDataService, + public bannersDataService: BannersDataService, + public toastController: ToastController + ) { + this.sessionDataProviderService.DestroySessionOnLogout(); + // https://ionicframework.com/docs/angular/platform + this.ios = platform.is('ios'); + this.android = platform.is('android'); } - ); -} - refreshBut(){ - this.isDisabled = true; - if ( - this.username != undefined - && this.password !=undefined - && String(this.username).length > 5 - && String(this.password).length > 5 - ){ - this.isDisabled = false; - } + ionViewDidEnter() { + // GoogleAuth.init(); + // use hook after platform dom ready + GoogleAuth.initialize({ + clientId: '817021856543-khlurl8ifdr0sd2cvekn167d02mk9dlg.apps.googleusercontent.com', + scopes: ['profile', 'email'], + grantOfflineAccess: true, + }); } - loginData: { - username: string, password: string, sessionid: string - }; - async startLogin() { - this.login_response = ""; - const loading = await this.loadingCtrl.create({ - message: 'Starting ... ', - duration: 3500, - }); - this.isDisabled=true; - if (this.username == null || this.username == '' || this.validateEmail(this.username) == false || this.password == null || this.password == '') { - await this.showAlert('Invalid Login', 'Enter username(email) and password to login'); - return; + ngOnInit() { + this.showSocial = environment.loginSocial; + // this.username='ses66181+6018@gmail.com'; + // this.username='ses66181+1@gmail.com'; + // this.password='may12002'; + + const checkName = async () => { + const {value} = await Preferences.get({key: 'username'}); + this.username = value; + + //console.log(`Hello ${value}!`); + }; + + checkName(); + // use hook after platform dom ready + FacebookLogin.initialize({appId: environment.facebookAppId}); + this.refreshBut(); } - await loading.present(); - 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) { - const setName = async () => { - await Preferences.set({ - key: 'username', - value: this.username, - }); - }; - - setName(); - // this.intervalRefreshService.startIntervalCalls(); // anything with interval call - // this.marketDataService.getJobsData(); - // this.getBlogData(); - // this.userWalletService.getWallet(); - this.startUpCalls(); - - this.router.navigate(['tabs/tab1']); - } - else{ - //debugger; - if (loginResult != null && loginResult.pending_uid != undefined){ - this.loginType='pending'; - this.pending_uid = loginResult.pending_uid; - this.signup_username = loginResult.username; - this.signup_country = loginResult.country; + getBlogData() { + this.wrenchService.getBlogData([]).subscribe( + blogResult => { + this.blogResult = blogResult; + console.log("BLOG RETURN->", this.blogResult); + this.blogDataService.setBlogData(this.blogResult.blogdata); } - else{ - this.login_response = "Invalid username or Password"; - setTimeout(()=>{ - this.login_response = ""; - }, 5000); + ); + } - // this.showAlert("Error","Invalid username/password"); - this.isDisabled=false; - } - // this.showAlert("Error","Invalid username/password"); + refreshBut() { + this.isDisabled = true; + if ( + this.username != undefined + && this.password != undefined + && String(this.username).length > 5 + && String(this.password).length > 5 + ) { + this.isDisabled = false; } - } - ); - } + } - async startUpCalls(){ - await this.bannersDataService.clearCurrentBanners(); - await this.bannersDataService.getBannersData(); - await this.joinLoginSockets(); - await this.intervalRefreshService.startIntervalCalls(); // anything with interval call - this.marketDataService.getJobsData(); - this.getBlogData(); - await this.tasksDataService.getJobsData(); - await this.userWalletService.getWalletData(); - } - onForgot() { - this.router.navigate(['forgot']); - } + loginData: { + username: string, password: string, sessionid: string + }; - onRegister() { - this.router.navigate(['register']); - } + async startLogin() { + this.login_response = ""; + const loading = await this.loadingCtrl.create({ + message: 'Starting ... ', + duration: 3500, + }); + this.isDisabled = true; - moveToStartScan(){ - this.router.navigate(['startscan']); - } + if (this.username == null || this.username == '' || this.validateEmail(this.username) == false || this.password == null || this.password == '') { + await this.showAlert('Invalid Login', 'Enter username(email) and password to login'); + return; + } + await loading.present(); + 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) { + + const setName = async () => { + await Preferences.set({ + key: 'username', + value: this.username, + }); + }; + + setName(); + // this.intervalRefreshService.startIntervalCalls(); // anything with interval call + // this.marketDataService.getJobsData(); + // this.getBlogData(); + // this.userWalletService.getWallet(); + this.startUpCalls(); + + this.router.navigate(['tabs/tab1']); + } else { + //debugger; + if (loginResult != null && loginResult.pending_uid != undefined) { + this.loginType = 'pending'; + this.pending_uid = loginResult.pending_uid; + this.signup_username = loginResult.username; + this.signup_country = loginResult.country; + } else { + this.login_response = "Invalid username or Password"; + setTimeout(() => { + this.login_response = ""; + }, 5000); + + // this.showAlert("Error","Invalid username/password"); + this.isDisabled = false; + } + // this.showAlert("Error","Invalid username/password"); + } + } + ); + } + + async startUpCalls() { + await this.bannersDataService.clearCurrentBanners(); + await this.bannersDataService.getBannersData(); + await this.joinLoginSockets(); + await this.intervalRefreshService.startIntervalCalls(); // anything with interval call + this.marketDataService.getJobsData(); + this.getBlogData(); + await this.tasksDataService.getJobsData(); + await this.userWalletService.getWalletData(); + } + + onForgot() { + this.router.navigate(['forgot']); + } + + onRegister() { + this.router.navigate(['register']); + } + + moveToStartScan() { + this.router.navigate(['startscan']); + } //************************************************* // Start Pending Account set up //************************************************* completeSignupData: { - action:11010, + action: 11010, username: string, random_text: string, password: string, - pending_uid:string, + pending_uid: string, mobile: string, sessionid: string }; - signUpResult:any; - onCompleteProfile(){ + signUpResult: any; + + onCompleteProfile() { this.completeSignupData = { - action:11010, + action: 11010, username: this.signup_username, random_text: this.random_text, password: this.signup_password, @@ -233,396 +236,408 @@ getBlogData(){ mobile: "MOBILE", sessionid: "ABOUT-TO_START" }; - console.log("COMPLETE SIGNUP ",this.completeSignupData); + console.log("COMPLETE SIGNUP ", this.completeSignupData); this.wrenchService.completeMobileSignup(this.completeSignupData).subscribe( signUpResult => { - this.signUpResult = signUpResult; + this.signUpResult = signUpResult; if (signUpResult != null && signUpResult.internal_return == 100 && this.sessionDataProviderService.ConstructGlobalSessionData(this.signUpResult) == true) { // this.getBlogData(); - this. onReturnToLogin(); + this.onReturnToLogin(); this.router.navigate(['tabs/tab1']); - } - else{ - this. onReturnToLogin(); - this.showAlert("Sign up error","Unable to complete the sign up, please try again"); + } else { + this.onReturnToLogin(); + this.showAlert("Sign up error", "Unable to complete the sign up, please try again"); } } - ); } + //************************************************* // End Pending Account set up //************************************************* - onReturnToLogin(){ - this.loginType='normal'; + onReturnToLogin() { + this.loginType = 'normal'; } - signupVerify(){ + signupVerify() { this.isPendingDisabled = true; if ( this.signup_username != undefined - && this.signup_password !=undefined + && this.signup_password != undefined && this.random_text != undefined && String(this.signup_password).length > 7 && String(this.signup_password).length < 15 && String(this.random_text).length > 3 && String(this.random_text).length < 10 - ){ + ) { this.isPendingDisabled = false; } } - onLoginGoogle() { - GoogleAuth.signIn().then((user: User) => { - //const credential = auth.GoogleAuthProvider.credential(user.authentication.idToken); - //return this.afAuth.auth.signInAndRetrieveDataWithCredential(credential); - if (user) { - const oauth2Data = { - "auth_type": "GOOGLE", - "access_token": user.authentication.accessToken, - "refresh_token": user.authentication.refreshToken, - "idToken": user.authentication.idToken, - "auth_code": user.serverAuthCode, - "user": user - }; - console.log(oauth2Data); - // Validate token with server and create new session - this.wrenchService.authStart(oauth2Data).subscribe( - loginResult => { - console.log(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) { - const setName = async () => { - await Preferences.set({ - key: 'username', - value: this.username, - }); - }; + onLoginGoogle() { + GoogleAuth.signIn().then((user: User) => { + //const credential = auth.GoogleAuthProvider.credential(user.authentication.idToken); + //return this.afAuth.auth.signInAndRetrieveDataWithCredential(credential); - // this.intervalRefreshService.startIntervalCalls(); // anything with interval call - // this.marketDataService.getJobsData(); - // this.getBlogData(); - // this.userWalletService.getWallet(); - this.startUpCalls(); - this.router.navigate(['tabs/tab1']); + if (user) { + const oauth2Data = { + "auth_type": "GOOGLE", + "access_token": user.authentication.accessToken, + "refresh_token": user.authentication.refreshToken, + "idToken": user.authentication.idToken, + "auth_code": user.serverAuthCode, + "user": user + }; + console.log(oauth2Data); + // Validate token with server and create new session + this.wrenchService.authStart(oauth2Data).subscribe( + loginResult => { + console.log(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) { + const setName = async () => { + await Preferences.set({ + key: 'username', + value: this.username, + }); + }; + + // this.intervalRefreshService.startIntervalCalls(); // anything with interval call + // this.marketDataService.getJobsData(); + // this.getBlogData(); + // this.userWalletService.getWallet(); + this.startUpCalls(); + this.router.navigate(['tabs/tab1']); + } else { + this.showAlert("Error", "Invalid username/password"); + // debugger; + // if (loginResult != null && loginResult.pending_uid != undefined){ + // this.loginType='pending'; + // } + // else{ + // this.showAlert("Error","Invalid username/password"); + // } + } + } + ); + } else { + console.log(user); + this.showAlert("Error", "Login failed!"); } - else{ - this.showAlert("Error","Invalid username/password"); - // debugger; - // if (loginResult != null && loginResult.pending_uid != undefined){ - // this.loginType='pending'; - // } - // else{ - // this.showAlert("Error","Invalid username/password"); - // } - } - } - ); - } else { - console.log(user); - this.showAlert("Error", "Login failed!"); - } - }).catch((error: any) => { - // this.showAlert("Error", error); - console.log(error); - }); - } - - onLoginFacebook() { - const FACEBOOK_PERMISSIONS = [ - 'email', - 'user_birthday', - 'user_photos', - 'user_gender', - ]; - - FacebookLogin.login({ - permissions: FACEBOOK_PERMISSIONS - }).then((result: FacebookLoginResponse) => { - if (result.accessToken) { - // Login successful. - console.log(result); - console.log(`Facebook access token is ${result.accessToken.token}`); - - /* - var reqData = { - auth_type: "FACEBOOK", - code: codeResponse, - redirect_uri: process.env.REACT_APP_FACEBOOK_REDIRECT_URL, - }; - */ - const oauth2Data = { - "auth_type": "FACEBOOK", - "access_token": result.accessToken.token, - "user":result.accessToken.userId, - "application_id":result.accessToken.applicationId, - }; - console.log(oauth2Data); - // Validate token with server and create new session - this.wrenchService.authStart(oauth2Data).subscribe( - loginResult => { - console.log(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) { - const setName = async () => { - await Preferences.set({ - key: 'username', - value: this.username, - }); - }; - - // this.intervalRefreshService.startIntervalCalls(); // anything with interval call - // this.marketDataService.getJobsData(); - // this.getBlogData(); - // this.userWalletService.getWallet(); - this.startUpCalls(); - this.router.navigate(['tabs/tab1']); - } - else{ - this.showAlert("Error","Invalid username/password"); - } - } - ); - - } else { - console.log(result); - this.showAlert("Error", "Login failed!"); - } - }).catch((error: any) => { - //this.showAlert("Error", error); - // this.showAlert("Error", "Login cancelled"); - console.log(error); - }); - } - - onLoginApple() { - - // -> 'web', 'ios' or 'android' - if (Capacitor.getPlatform() === 'web') { - this.appleSignInAbortController = new AbortController(); - this.appleSignInWindow = window.open( - 'https://appleid.apple.com/auth/authorize?' + - 'client_id=com.wrenchboard.users&'+ - 'redirect_uri='+environment.appleRedirectUri+'&' + - 'response_type=code id_token&' + - 'scope=name email&' + - 'response_mode=web_message', - '_blank' - ); - window.addEventListener( - 'message', - (e) => {this.appleTokenReceived(e);}, - {signal: this.appleSignInAbortController.signal} - ); - return; + }).catch((error: any) => { + // this.showAlert("Error", error); + console.log(error); + }); } - console.log("Capacitor platfor: " + Capacitor.getPlatform()); - const rawNonce = (Math.random() + 1).toString(36); - //const nonce = shajs('sha256').update(rawNonce).digest('hex'); - const nonce = rawNonce; - this.state = (Math.random() + 1).toString(36); - let options: SignInWithAppleOptions = { - clientId: 'com.wrenchboard.users', - redirectURI: environment.appleRedirectUri, - scopes: 'email name', - state: '12345', /* this.state, */ - nonce: nonce, - }; + onLoginFacebook() { + const FACEBOOK_PERMISSIONS = [ + 'email', + 'user_birthday', + 'user_photos', + 'user_gender', + ]; - // https://developer.okta.com/blog/2019/06/04/what-the-heck-is-sign-in-with-apple - - SignInWithApple.authorize(options) - .then((result: SignInWithAppleResponse) => { - // Handle user information - console.log("response", result.response); - /* - { - "identityToken":"eyJraWQiOiJZdXlYb1kiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY29tLndyZW5jaGJvYXJkLnVzZXJzIiwiZXhwIjoxNjk0MzkzMzE3LCJpYXQiOjE2OTQzMDY5MTcsInN1YiI6IjAwMTgxMC4yMGU3NTAyOGQ0OWM0MmQ4YjQzMGI0MmQxZDc0ODdmMy4xMTU3Iiwibm9uY2UiOiIxLnB1ZmJwZGFhMzYiLCJjX2hhc2giOiJQRE1PNXNGa2pjOEtPclNNZDRjUGZnIiwiZW1haWwiOiJhY2lkdW1pcmFlQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjoidHJ1ZSIsImF1dGhfdGltZSI6MTY5NDMwNjkxNywibm9uY2Vfc3VwcG9ydGVkIjp0cnVlLCJyZWFsX3VzZXJfc3RhdHVzIjoyfQ.fEnzaVgB2JaOZbQm2fkpC_J8if5tIIfAphQptZ9Bxp2wrjnDsGvN1b0gvB3KBswv7d6n4A1U46GpaGpShJDhN-e2lKw_lzgFJlRi9-1B-Fudp_gzK61r6W8JzzbPiD0GZgfp_ITPDdxdC7hzixVx4TW8djrV4TIXYjus0b5XnzqRVz2t3ed4Et55s_SZ53SVhM9qnDruVB-KgeGrvDVUks71iM1etuP2vO3xsSFoiKfMEcankX3JUJaCNRSdvVVeUBqH9TfhvmHrCopjnlJ8N2B8o8RDhbnt99OAJtE_dw_Qt5YAAg2ITYQVLBb2dniJ5FBsOBBwbiA0-W1hPJ3RpQ","authorizationCode":"ce0061e5858a34e468a373c3ea7344cdb.0.rryrq.rK6JjdqlVVi6S9coEcTgVQ", - "email":null, - "givenName":null, - "familyName":null, - "user":"001810.20e75028d49c42d8b430b42d1d7487f3.1157" - } - */ - // result.response.user - // result.response.identityToken - // result.response.email: null - // result.response.givenName: null - // result.response.familyName: null + FacebookLogin.login({ + permissions: FACEBOOK_PERMISSIONS + }).then((result: FacebookLoginResponse) => { + if (result.accessToken) { + // Login successful. + console.log(result); + console.log(`Facebook access token is ${result.accessToken.token}`); - var decoded = jwt_decode(result.response.identityToken); + /* + var reqData = { + auth_type: "FACEBOOK", + code: codeResponse, + redirect_uri: process.env.REACT_APP_FACEBOOK_REDIRECT_URL, + }; + */ + const oauth2Data = { + "auth_type": "FACEBOOK", + "access_token": result.accessToken.token, + "user": result.accessToken.userId, + "application_id": result.accessToken.applicationId, + }; + console.log(oauth2Data); + // Validate token with server and create new session + this.wrenchService.authStart(oauth2Data).subscribe( + loginResult => { + console.log(loginResult); + this.loginResult = loginResult; + console.log("INTERNAL RETURN->" + this.loginResult.internal_return); - // https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple - console.log(decoded); - /* - { - "iss": "https://appleid.apple.com", - "aud": "com.wrenchboard.users", - "exp": 1694393317, - "iat": 1694306917, - "sub": "001810.20e75028d49c42d8b430b42d1d7487f3.1157", - "nonce": "1.pufbpdaa36", - "c_hash": "PDMO5sFkjc8KOrSMd4cPfg", - "email": "acidumirae@gmail.com", - "email_verified": "true", - "auth_time": 1694306917, - "nonce_supported": true, - "real_user_status": 2 - } - */ - // real_user_status => The possible values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). + if (loginResult != null && loginResult.internal_return == 100 && this.sessionDataProviderService.ConstructGlobalSessionData(this.loginResult) == true) { + const setName = async () => { + await Preferences.set({ + key: 'username', + value: this.username, + }); + }; - const oauth2Data = { - "auth_type": "APPLE", - "identityToken": result.response.identityToken, - "email":result.response.email, - "givenName":result.response.givenName, - "familyName":result.response.familyName, - "user":result.response.user, - "authorizationCode":result.response.authorizationCode, - "sub": decoded["sub"], - "jwt_email": decoded["email"], - "email_verified": decoded["email_verified"], - "real_user_status": decoded["real_user_status"] - }; - //console.log(oauth2Data); + // this.intervalRefreshService.startIntervalCalls(); // anything with interval call + // this.marketDataService.getJobsData(); + // this.getBlogData(); + // this.userWalletService.getWallet(); + this.startUpCalls(); + this.router.navigate(['tabs/tab1']); + } else { + this.showAlert("Error", "Invalid username/password"); + } + } + ); - this.username = decoded["email"] ?? result.response.email; + } else { + console.log(result); + this.showAlert("Error", "Login failed!"); + } + }).catch((error: any) => { + //this.showAlert("Error", error); + // this.showAlert("Error", "Login cancelled"); + console.log(error); + }); + } - // Validate token with server and create new session - this.wrenchService.authStart(oauth2Data).subscribe( - loginResult => { - console.log(loginResult); - this.loginResult = loginResult; - console.log("INTERNAL RETURN->" + this.loginResult.internal_return); - /* - localStorage.setItem("member_id", `${loginResult.data.member_id}`); - localStorage.setItem("uid", `${loginResult.data.uid}`); - localStorage.setItem("session_token", `${loginResult.data.session}`); - dispatch(updateUserDetails({...loginResult.data})); - */ - if (loginResult != null && loginResult.internal_return == 100 && this.sessionDataProviderService.ConstructGlobalSessionData(this.loginResult) == true) { - const setName = async () => { - await Preferences.set({ - key: 'username', - value: this.username, - }); - }; + onLoginApple() { - // this.intervalRefreshService.startIntervalCalls(); // anything with interval call - // this.marketDataService.getJobsData(); - // this.getBlogData(); - // this.userWalletService.getWallet(); - this.startUpCalls(); - this.router.navigate(['tabs/tab1']); - } - else{ - this.showAlert("Error","Invalid username/password"); - } + // -> 'web', 'ios' or 'android' + if (Capacitor.getPlatform() === 'web') { + this.appleSignInAbortController = new AbortController(); + this.appleSignInWindow = window.open( + 'https://appleid.apple.com/auth/authorize?' + + 'client_id=com.wrenchboard.users&' + + 'redirect_uri=' + environment.appleRedirectUri + '&' + + 'response_type=code id_token&' + + 'scope=name email&' + + 'response_mode=web_message', + '_blank' + ); + window.addEventListener( + 'message', + (e) => { + this.appleTokenReceived(e); + }, + {signal: this.appleSignInAbortController.signal} + ); + return; } - ); - }) - .catch((error) => { - this.showAlert("Error", error); - console.log(error); - }); - console.log("onLoginApple() out"); - } + console.log("Capacitor platfor: " + Capacitor.getPlatform()); + const rawNonce = (Math.random() + 1).toString(36); + //const nonce = shajs('sha256').update(rawNonce).digest('hex'); + const nonce = rawNonce; + this.state = (Math.random() + 1).toString(36); - appleTokenReceived(event: any) { - console.log(event); - this.appleSignInAbortController.abort(); - this.appleSignInWindow.close(); - if (!(event instanceof MessageEvent)) { - return; - } - const data = JSON.parse(event.data); - if (typeof data !== 'object' || data === null) { - return; - } - if (data.data.hasOwnProperty('error')) { - return; - } - let postData: any = { - token: data.data.authorization.id_token, - device_id: 'device UUID', /** NOT IMPLEMENTED! */ - }; - if ( - data.data.hasOwnProperty('user') && - data.data.user.hasOwnProperty('name') && - data.data.user.name.hasOwnProperty('firstName') && - data.data.user.name.hasOwnProperty('lastName') - ) { - //this is only filled after the first login of the user - postData.name = data.data.user.name.lastName + ' ' + data.data.user.name.firstName; - } - //this.http.post(environment.appleRedirectUri + '/api/auth/loginWithApple', postData).subscribe(//Do whatever you need with the data); - this.showAlert("Error", "appleTokenReceived is not implemented!"); - } + let options: SignInWithAppleOptions = { + clientId: 'com.wrenchboard.users', + redirectURI: environment.appleRedirectUri, + scopes: 'email name', + state: '12345', /* this.state, */ + nonce: nonce, + }; - onClick() { - this.router.navigate(['slider']); - } + // https://developer.okta.com/blog/2019/06/04/what-the-heck-is-sign-in-with-apple - validateEmail(email) { - var re = /\S+@\S+\.\S+/; - return re.test(email); - } + SignInWithApple.authorize(options) + .then((result: SignInWithAppleResponse) => { + // Handle user information + console.log("response", result.response); + /* + { + "identityToken":"eyJraWQiOiJZdXlYb1kiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwcGxlaWQuYXBwbGUuY29tIiwiYXVkIjoiY29tLndyZW5jaGJvYXJkLnVzZXJzIiwiZXhwIjoxNjk0MzkzMzE3LCJpYXQiOjE2OTQzMDY5MTcsInN1YiI6IjAwMTgxMC4yMGU3NTAyOGQ0OWM0MmQ4YjQzMGI0MmQxZDc0ODdmMy4xMTU3Iiwibm9uY2UiOiIxLnB1ZmJwZGFhMzYiLCJjX2hhc2giOiJQRE1PNXNGa2pjOEtPclNNZDRjUGZnIiwiZW1haWwiOiJhY2lkdW1pcmFlQGdtYWlsLmNvbSIsImVtYWlsX3ZlcmlmaWVkIjoidHJ1ZSIsImF1dGhfdGltZSI6MTY5NDMwNjkxNywibm9uY2Vfc3VwcG9ydGVkIjp0cnVlLCJyZWFsX3VzZXJfc3RhdHVzIjoyfQ.fEnzaVgB2JaOZbQm2fkpC_J8if5tIIfAphQptZ9Bxp2wrjnDsGvN1b0gvB3KBswv7d6n4A1U46GpaGpShJDhN-e2lKw_lzgFJlRi9-1B-Fudp_gzK61r6W8JzzbPiD0GZgfp_ITPDdxdC7hzixVx4TW8djrV4TIXYjus0b5XnzqRVz2t3ed4Et55s_SZ53SVhM9qnDruVB-KgeGrvDVUks71iM1etuP2vO3xsSFoiKfMEcankX3JUJaCNRSdvVVeUBqH9TfhvmHrCopjnlJ8N2B8o8RDhbnt99OAJtE_dw_Qt5YAAg2ITYQVLBb2dniJ5FBsOBBwbiA0-W1hPJ3RpQ","authorizationCode":"ce0061e5858a34e468a373c3ea7344cdb.0.rryrq.rK6JjdqlVVi6S9coEcTgVQ", + "email":null, + "givenName":null, + "familyName":null, + "user":"001810.20e75028d49c42d8b430b42d1d7487f3.1157" + } + */ + // result.response.user + // result.response.identityToken + // result.response.email: null + // result.response.givenName: null + // result.response.familyName: null + + var decoded = jwt_decode(result.response.identityToken); + + // https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api/authenticating_users_with_sign_in_with_apple + console.log(decoded); + /* + { + "iss": "https://appleid.apple.com", + "aud": "com.wrenchboard.users", + "exp": 1694393317, + "iat": 1694306917, + "sub": "001810.20e75028d49c42d8b430b42d1d7487f3.1157", + "nonce": "1.pufbpdaa36", + "c_hash": "PDMO5sFkjc8KOrSMd4cPfg", + "email": "acidumirae@gmail.com", + "email_verified": "true", + "auth_time": 1694306917, + "nonce_supported": true, + "real_user_status": 2 + } + */ + // real_user_status => The possible values are: 0 (or Unsupported), 1 (or Unknown), 2 (or LikelyReal). + + const oauth2Data = { + "auth_type": "APPLE", + "identityToken": result.response.identityToken, + "email": result.response.email, + "givenName": result.response.givenName, + "familyName": result.response.familyName, + "user": result.response.user, + "authorizationCode": result.response.authorizationCode, + "sub": decoded["sub"], + "jwt_email": decoded["email"], + "email_verified": decoded["email_verified"], + "real_user_status": decoded["real_user_status"] + }; + //console.log(oauth2Data); + + this.username = decoded["email"] ?? result.response.email; + + // Validate token with server and create new session + this.wrenchService.authStart(oauth2Data).subscribe( + loginResult => { + console.log(loginResult); + this.loginResult = loginResult; + console.log("INTERNAL RETURN->" + this.loginResult.internal_return); + /* + localStorage.setItem("member_id", `${loginResult.data.member_id}`); + localStorage.setItem("uid", `${loginResult.data.uid}`); + localStorage.setItem("session_token", `${loginResult.data.session}`); + dispatch(updateUserDetails({...loginResult.data})); + */ + if (loginResult != null && loginResult.internal_return == 100 && this.sessionDataProviderService.ConstructGlobalSessionData(this.loginResult) == true) { + const setName = async () => { + await Preferences.set({ + key: 'username', + value: this.username, + }); + }; + + // this.intervalRefreshService.startIntervalCalls(); // anything with interval call + // this.marketDataService.getJobsData(); + // this.getBlogData(); + // this.userWalletService.getWallet(); + this.startUpCalls(); + this.router.navigate(['tabs/tab1']); + } else { + this.showAlert("Error", "Invalid username/password"); + } + } + ); + }) + .catch((error) => { + this.showAlert("Error", error); + console.log(error); + }); + console.log("onLoginApple() out"); + } + + appleTokenReceived(event: any) { + console.log(event); + this.appleSignInAbortController.abort(); + this.appleSignInWindow.close(); + if (!(event instanceof MessageEvent)) { + return; + } + const data = JSON.parse(event.data); + if (typeof data !== 'object' || data === null) { + return; + } + if (data.data.hasOwnProperty('error')) { + return; + } + let postData: any = { + token: data.data.authorization.id_token, + device_id: 'device UUID', /** NOT IMPLEMENTED! */ + }; + if ( + data.data.hasOwnProperty('user') && + data.data.user.hasOwnProperty('name') && + data.data.user.name.hasOwnProperty('firstName') && + data.data.user.name.hasOwnProperty('lastName') + ) { + //this is only filled after the first login of the user + postData.name = data.data.user.name.lastName + ' ' + data.data.user.name.firstName; + } + //this.http.post(environment.appleRedirectUri + '/api/auth/loginWithApple', postData).subscribe(//Do whatever you need with the data); + this.showAlert("Error", "appleTokenReceived is not implemented!"); + } + + onClick() { + this.router.navigate(['slider']); + } + + validateEmail(email) { + var re = /\S+@\S+\.\S+/; + return re.test(email); + } + + async presentToast(amessage, position: "top" | "middle" | "bottom") { + const toast = await this.toastController.create({ + message: amessage, + duration: 3000, + position: position, + }); + + await toast.present(); + } async showAlert(mtitle: string, amessage: string) { + await this.presentToast(amessage, "middle"); - const alert = await this.alertController.create({ - header: 'WrenchBoard', - subHeader: mtitle, - message: amessage, - buttons: ['OK'], - }); + // const alert = await this.alertController.create({ + // header: 'WrenchBoard', + // subHeader: mtitle, + // message: amessage, + // buttons: ['OK'], + // }); + // + // await alert.present(); + // + // let alert = this.alertCtrl.create({ + // title: mtitle, + // subTitle: amessage, + // buttons: ['OK'] + // }); + // alert.present(); + // // alert(amessage); + } - await alert.present(); - // - // let alert = this.alertCtrl.create({ - // title: mtitle, - // subTitle: amessage, - // buttons: ['OK'] - // }); - // alert.present(); - // // alert(amessage); - } - familyLogin(){ - this.router.navigate(['familylogin']); - } + familyLogin() { + this.router.navigate(['familylogin']); + } - async joinLoginSockets(){ + async joinLoginSockets() { this.socketToolsService.stop(); - setTimeout(()=>{ + setTimeout(() => { this.socketToolsService.setupSocket("NO-NEED-SEND"); - this.socketToolsService.joinSocketRoom("full-markets-jobs" ); + this.socketToolsService.joinSocketRoom("full-markets-jobs"); }, 5000); - } -/* -const setName = async () => { - await Preferences.set({ - key: 'name', - value: 'Max', - }); -}; + } -const checkName = async () => { - const { value } = await Preferences.get({ key: 'name' }); + /* + const setName = async () => { + await Preferences.set({ + key: 'name', + value: 'Max', + }); + }; - console.log(`Hello ${value}!`); -}; + const checkName = async () => { + const { value } = await Preferences.get({ key: 'name' }); -const removeName = async () => { - await Preferences.remove({ key: 'name' }); -}; + console.log(`Hello ${value}!`); + }; -*/ + const removeName = async () => { + await Preferences.remove({ key: 'name' }); + }; + + */ } diff --git a/src/app/pages/register/register.page.html b/src/app/pages/register/register.page.html index 3733c06..71fb2e7 100644 --- a/src/app/pages/register/register.page.html +++ b/src/app/pages/register/register.page.html @@ -1,145 +1,153 @@ -
- -
-
-
-
- -
- -
diff --git a/src/global.scss b/src/global.scss index 928a1c6..f7b925d 100644 --- a/src/global.scss +++ b/src/global.scss @@ -57,6 +57,13 @@ ion-label { display: block; } +.center_contents { + max-width: 550px; + margin-left: auto; + margin-right: auto; +} + + .bg_image { background-position: center; background-size: cover;