Commit 43f6f369 by Alen Jose

Merge branch 'alen' into 'master'

profile See merge request alen/CMC-driver!7
parents b07dac76 b37961d5
import { Component, ViewChild } from '@angular/core'; import { Component, ViewChild } from '@angular/core';
import { Nav, Platform, AlertController, Events } from 'ionic-angular'; import { Nav, Platform, AlertController, Events,Toggle } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar'; import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen'; import { SplashScreen } from '@ionic-native/splash-screen';
import { Network } from '@ionic-native/network'; import { Network } from '@ionic-native/network';
...@@ -16,6 +16,7 @@ import { LocalNotifications } from '@ionic-native/local-notifications'; ...@@ -16,6 +16,7 @@ import { LocalNotifications } from '@ionic-native/local-notifications';
}) })
export class MyApp { export class MyApp {
@ViewChild(Nav) nav: Nav; @ViewChild(Nav) nav: Nav;
@ViewChild('toggle') ionToggle: Toggle;
rootPage: string; rootPage: string;
...@@ -61,6 +62,7 @@ export class MyApp { ...@@ -61,6 +62,7 @@ export class MyApp {
this.local = data this.local = data
if (this.local) { if (this.local) {
this.local.image = this.local.image.startsWith("http") ? this.local.image : this.myservice.base_url + this.local.image; this.local.image = this.local.image.startsWith("http") ? this.local.image : this.myservice.base_url + this.local.image;
this.checkStatus()
} }
}) })
...@@ -68,18 +70,7 @@ export class MyApp { ...@@ -68,18 +70,7 @@ export class MyApp {
if (data != null) { if (data != null) {
this.local = data this.local = data
this.rootPage = 'HomePage' this.rootPage = 'HomePage'
// this.oneSignal.getIds().then((id) => { this.checkStatus()
// this.myservice.load_post({deviceid:id.userId,driverid:this.local.id},'updateDeviceid')
// })
var This = this
var query = firebase.database().ref("drivers/").orderByChild("id").equalTo((data.id))
query.once("child_added", function (snapshot) {
This.pushId = snapshot.val().push_id
if (snapshot.val().status == 'online')
This.status = true
else
This.status = false
});
} }
else { else {
this.rootPage = 'LandingPage' this.rootPage = 'LandingPage'
...@@ -95,12 +86,43 @@ export class MyApp { ...@@ -95,12 +86,43 @@ export class MyApp {
} }
statusChange() { statusChange() {
var This = this if (this.status == true)
if (This.status == true)
var stat = 'online' var stat = 'online'
else else
var stat = 'offline' var stat = 'offline'
firebase.database().ref("drivers/" + This.pushId + "/").update({ status: stat }) firebase.database().ref("drivers/" + this.pushId + "/").update({ status: stat })
}
checkStatus() {
// this.oneSignal.getIds().then((id) => {
// this.myservice.load_post({deviceid:id.userId,driverid:this.local.id},'updateDeviceid')
// })
var This = this
var query = firebase.database().ref("drivers/").orderByChild("id").equalTo((this.local.id))
query.once("child_added", function (snapshot) {
This.pushId = snapshot.val().push_id
console.log(snapshot.val().status)
if (snapshot.val().status == 'online')
This.status = true
else
This.status = false
});
var intr = setInterval(()=>{
This.myservice.load_post({ id: This.local.id }, 'getMyStatus').subscribe(resp => {
if (resp.status == 'success') {
if (resp.data.user_status == "Active"){
console.log('act')
This.ionToggle.disabled = false;
clearInterval(intr);
}
else{
console.log('inact')
This.ionToggle.disabled = true;
}
}
})
},20000)
} }
openPage(page) { openPage(page) {
......
<ion-menu [content]="content"> <ion-menu [content]="content">
<ion-content class="theme_bgcolor"> <ion-content class="theme_bgcolor">
<div class="cab_sidemenu_wrapper"> <div class="cab_sidemenu_wrapper">
<div menuClose class="cab_profile_banner" (click)="openPage('ProfilePage')"> <div menuClose class="cab_profile_banner" (click)="openPage('MyprofilePage')">
<div class="cab_profile_picture"> <div class="cab_profile_picture">
<img [src]="local?.image"> <img [src]="local?.image">
</div> </div>
<p>{{local?.name}}</p> <p>{{local?.name}}</p>
<h6>{{local?.dial_code}} {{local?.phone}}</h6> <h6>{{local?.dial_code}} {{local?.phone}}</h6>
</div>
<ion-list> <ion-list>
<ion-item class="item_cstm"> <ion-item class="item_cstm">
<ion-label>Online</ion-label> <ion-label>Online</ion-label>
<ion-toggle [(ngModel)]="status" (ionChange)=statusChange()></ion-toggle> <ion-toggle #toggle [(ngModel)]="status" (ionChange)=statusChange()></ion-toggle>
</ion-item> </ion-item>
</ion-list> </ion-list>
</div>
<div class="cab_sidemenu_list"> <div class="cab_sidemenu_list">
<ul> <ul>
<li menuClose (click)="openPage('HomePage')">My Rides</li> <li menuClose (click)="openPage('HomePage')">My Rides</li>
......
<ion-header class="nav_header">
<button ion-button class="nav_btn floatLeft" (click)="back()">
<ion-icon name="ios-arrow-back-outline"></ion-icon>
</button>
<div class="nav_header_title floatLeft">
License
</div>
<div class="clear"></div>
</ion-header>
<ion-content padding>
<div class="sign_up_wrapper">
<h4>Licence</h4>
<hr>
<br>
<p>Your documents must be readable<br>
and clear</p>
<button ion-button class="upload_btn">UPDATE</button>
<div class="check_box">
</div>
<h6>mydoc.pdf</h6>
<h5>Upload Complete</h5>
</div>
</ion-content>
<ion-footer padding>
<button ion-button class="primary btn_primary" (click)="login()">DONE</button>
</ion-footer>
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular'; import { IonicPageModule } from 'ionic-angular';
import { ProfilePage } from './profile'; import { DocupdatePage } from './docupdate';
@NgModule({ @NgModule({
declarations: [ declarations: [
ProfilePage, DocupdatePage,
], ],
imports: [ imports: [
IonicPageModule.forChild(ProfilePage), IonicPageModule.forChild(DocupdatePage),
], ],
}) })
export class ProfilePageModule {} export class DocupdatePageModule {}
page-docupdate {
.mobile_background{
background: url("../assets/imgs/forgot_bg.png");
background-position: center top;
background-size: cover;
}
.sign_up_wrapper{
width: 100%;
text-align:center;
span{
img{
width: 80px;
}
}
h4{
text-align:center;
color: #282828;
font-size: 39px;
font-weight:300;
margin-top: 10px;
}
hr{
width: 20px;
border:2px solid #282828;
margin: 0 auto;
height:0px;
border-radius:20px;
margin-top: 15px;
}
.signup_circle_pic{
width: 150px;
height:150px;
border-radius:50%;
background-color: #d9d7d7 !important;
margin: 0 auto;
margin-top:30px;
background: url("../assets/imgs/avatar.png");
background-repeat: no-repeat;
background-position: center;
background-size: 40px;
img{
width: 100%;
height:100%;
object-fit: cover;
object-position: center;
border-radius:50%;
}
}
.upload_btn{
border:2px solid #282828;
height: 45px;
border-radius: 25px;
background: transparent;
color: #282828;
text-transform: uppercase;
font-size: 16px;
padding-left: 40px;
padding-right: 40px;
font-weight:600;
letter-spacing: 2px;
}
p{
color: #737270;
font-size: 16px;
text-align: left;
padding-top: 0px;
text-align: center;
}
.check_box{
width: 50px;
height:50px;
background: url("../assets/imgs/check.png");
background-repeat: no-repeat;
background-position: center;
background-size: 40px;
margin: 0 auto;
margin-top:20px;
}
h6{
text-align: center;
font-weight: 400;
}
h5{
text-align: center;
margin: 0px;
}
}
.btn_primary{
width:100%;
border-radius: 20px;
height: 45px;
font-size: 16px;
letter-spacing: 2px;
}
}
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { IonicPage, NavController, NavParams } from 'ionic-angular';
@IonicPage() @IonicPage()
@Component({ @Component({
selector: 'page-profile', selector: 'page-docupdate',
templateUrl: 'profile.html', templateUrl: 'docupdate.html',
}) })
export class ProfilePage { export class DocupdatePage {
constructor(public navCtrl: NavController, public navParams: NavParams) { constructor(public navCtrl: NavController, public navParams: NavParams) {
} }
ionViewDidLoad() { ionViewDidLoad() {
console.log('ionViewDidLoad ProfilePage'); console.log('ionViewDidLoad DocupdatePage');
}
back(){
this.navCtrl.pop();
}
login(){
this.navCtrl.push("LoginPage");
} }
} }
<ion-header class="nav_header">
<button ion-button class="nav_btn floatLeft" (click)="back()">
<ion-icon name="ios-arrow-back-outline"></ion-icon>
</button>
<div class="nav_header_title floatLeft">
</div>
<div class="clear"></div>
</ion-header>
<ion-content padding>
<div class="myprofile_wrapper">
<h4>My Profile</h4>
<hr>
<br>
<form [formGroup]="editForm">
<div class="profile_circle_pic">
<img [src]=editForm.value.image >
<div class="edit">
<input type="file" (change)="fileChange($event)" accept="image/*">
<ion-icon name="md-create"></ion-icon>
</div>
</div>
<div class="signup_form_content">
<ion-item>
<ion-input type="text" placeholder="Name" formControlName="name"></ion-input>
</ion-item>
<div class="er_req textCenter" *ngIf="editForm.controls.name.invalid && (editForm.get('name').dirty || editForm.get('name').touched)">
Enter a valid Name
</div>
<ion-item>
<ion-input type="text" placeholder="Username" formControlName="username"></ion-input>
</ion-item>
<div class="er_req textCenter" *ngIf="editForm.controls.username.invalid && (editForm.get('username').dirty || editForm.get('username').touched)">
Enter a valid Username
</div>
<ion-item>
<ion-input type="number" placeholder="Mobile Number" formControlName="phone"></ion-input>
</ion-item>
<div class="er_req textCenter" *ngIf="editForm.controls.phone.invalid && (editForm.get('phone').dirty || editForm.get('phone').touched)">
Enter a valid Mobile
</div>
<ion-item>
<ion-input type="email" placeholder="Email" formControlName="email"></ion-input>
</ion-item>
<div class="er_req textCenter" *ngIf="editForm.controls.email.invalid && (editForm.get('email').dirty || editForm.get('email').touched)">
Enter a valid Email
</div>
<!-- <ion-item>
<ion-select>
<ion-option value="1" selected>City</ion-option>
<ion-option value="2">Kochin</ion-option>
</ion-select>
</ion-item> -->
<br>
<button ion-button class="primary" (click)="updateProfile()">SAVE</button>
<button ion-button class="changepass_btn" (click)="changepass()">CHANGE PASSWORD</button>
</div>
</form>
</div>
</ion-content>
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { MyprofilePage } from './myprofile';
@NgModule({
declarations: [
MyprofilePage,
],
imports: [
IonicPageModule.forChild(MyprofilePage),
],
})
export class MyprofilePageModule {}
page-myprofile {
.myprofile_wrapper{
width: 100%;
h4{
text-align:left;
color: #282828;
font-size: 39px;
font-weight:300;
margin-top: 15px;
}
hr{
width: 20px;
border:2px solid #282828;
margin-left: 0 !important;
height:0px;
border-radius:20px;
margin-top: 10px;
}
.profile_circle_pic{
width:130px;
height:130px;
border-radius:50%;
background: #e3e4d9;
position: relative;
img{
width: 100%;
height:100%;
object-fit: cover;
object-position: center;
border-radius:50%;
}
.edit{
width:35px;
height:35px;
border-radius:50%;
background: #282828;
color: #fff;
position: absolute;
right:-45px;
top:50px;
text-align:center;
padding: 9px;
input{
opacity: 0;
width: 100%;
position: absolute;
right: 0px;
}
}
}
.signup_form_content{
width: 100%;
padding-top:30px;
.input {
.text-input{
margin: 0px;
height: 50px;
border-bottom:1px solid #b7b7b7;
font-size: 28px;
font-weight: 300;
margin-bottom: 20px;
&::placeholder{
color: #c9c9c9;
}
}
}
.select {
min-width: 100%;
padding:0px;
border-bottom:1px solid #b7b7b7;
font-size: 28px;
font-weight: 300;
color: #c9c9c9;
background: url("../assets/imgs/arrow.png");
background-position: right 10px top 14px;
background-repeat: no-repeat;
background-size: 15px;
padding-top: 0px;
height: 45px;
.select-icon{
display: none;
}
}
.item{
margin-bottom: 20px;
}
.item-inner{
border:none;
}
p{
color: #606060;
font-size: 20px;
text-align: left;
padding-top: 10px;
}
button{
width:100%;
border-radius: 20px;
height: 45px;
font-size: 16px;
letter-spacing: 2px;
}
.changepass_btn{
border:2px solid #282828;
height: 45px;
border-radius: 25px;
background: transparent;
color: #282828;
text-transform: uppercase;
font-size: 16px;
width: 100%;
font-weight:600;
letter-spacing: 2px;
}
}
}
.er_req{color:#ff6060;padding-top: 10px;font-size: 15px}
}
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Validators, FormBuilder, FormGroup } from "@angular/forms";
import { Http } from '@angular/http'
import { dialcode } from "../../models/mymodel";
import { OrderbyPipe } from '../../providers/sort-pipe';
import { Myservice } from "../../providers/myservice";
import { Storage } from "@ionic/storage";
import { driver } from "../../models/mymodel";
@IonicPage()
@Component({
selector: 'page-myprofile',
templateUrl: 'myprofile.html',
})
export class MyprofilePage {
editForm: FormGroup
imagechange: boolean = false;
fileUri: any;
local:driver;
formdata = new FormData();
constructor(public navCtrl: NavController, public navParams: NavParams, private formBuilder: FormBuilder, private http: Http, private orderbyPipe: OrderbyPipe, private myservice: Myservice,private storage:Storage) {
this.editForm = this.formBuilder.group({
name: ['', Validators.compose([Validators.required, Validators.minLength(3)])],
username: ['', Validators.compose([Validators.required, Validators.minLength(3)])],
email: ['', Validators.compose([Validators.required, Validators.pattern("[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}")])],
dial_code: ['', Validators.required],
phone: ['', Validators.compose([Validators.required, this.myservice.checkLimit(10000000, 999999999999999)])],
image:['']
})
}
ionViewDidEnter() {
this.storage.get('driver_data').then(data=>{
if(data){
console.log(data)
this.editForm.controls['name'].setValue(data.name)
this.editForm.controls['username'].setValue(data.user_name)
this.editForm.controls['email'].setValue(data.email)
this.editForm.controls['dial_code'].setValue(data.dial_code)
this.editForm.controls['phone'].setValue(data.phone)
this.editForm.controls['image'].setValue(data.image)
}
})
// this.myservice.load_post({},'')
}
fileChange(event) {
let fileList: FileList = event.target.files;
if (fileList.length > 0) {
var reader = new FileReader();
reader.onload = (event: any) => {
this.editForm.controls['image'].setValue(event.target.result)
}
reader.readAsDataURL(event.target.files[0]);
let file = fileList[0];
var ext = (file.name).split(".").pop();
if (ext == 'jpg' || ext == 'jpeg' || ext == 'png') {
this.formdata.append('image', file, file.name);
this.imagechange = true;
}
else {
this.myservice.show_alert('','Please choose image with .jpg/.jpeg/.png extension')
}
}
}
updateProfile(){
this.formdata.append('data', JSON.stringify(this.editForm.value));
this.formdata.append('id', JSON.stringify(this.local.id));
this.myservice.fileUpload(this.formdata, 'updatedriverProfile').subscribe(response => {
if (response.status == true) {
// this.local.email = response.data.email
// if (this.imagechange == true)
// this.local.patient_display_image = response.data.patient_display_image
// this.local.name = response.data.firstname + '' + response.data.lastname
// this.events.publish('patient:profile', this.local);
// this.translate.get('editprofile.Profile updated successfully').subscribe(value => {
// var alertTitle = value;
// this.toast.show(alertTitle, '2000', 'center').subscribe(toast => {
// console.log(toast);
// });
// })
}
else {
this.myservice.show_alert('', response.message)
}
})
}
back(){
this.navCtrl.pop();
}
changepass(){
this.navCtrl.push("ChangepassPage");
}
}
<!--
Generated template for the ProfilePage page.
See http://ionicframework.com/docs/components/#navigation for more info on
Ionic pages and navigation.
-->
<ion-header>
<ion-navbar>
<ion-title>profile</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
</ion-content>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment