Commit 8b17f980 by Alen Jose

initial

parent 45361de6
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.ionic.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>MyApp</name>
<widget id="com.techware.cmc" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>CMC</name>
<description>An awesome Ionic/Cordova app.</description>
<author email="hi@ionicframework" href="http://ionicframework.com/">Ionic Framework Team</author>
<content src="index.html" />
......@@ -15,15 +15,10 @@
<preference name="webviewbounce" value="false" />
<preference name="UIWebViewBounce" value="false" />
<preference name="DisallowOverscroll" value="true" />
<preference name="android-minSdkVersion" value="16" />
<preference name="android-minSdkVersion" value="19" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<!--
Change these to configure how the splashscreen displays and fades in/out.
More info here: https://github.com/apache/cordova-plugin-splashscreen
-->
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
......@@ -47,6 +42,10 @@
<splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
<splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
<config-file parent="/resources" target="./res/values/strings.xml">
<string name="fb_app_id">223991774869277</string>
<string name="fb_app_name">CMC</string>
</config-file>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
......@@ -83,9 +82,21 @@
<splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
</platform>
<plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
<plugin name="cordova-plugin-whitelist" spec="1.3.1" />
<plugin name="cordova-plugin-statusbar" spec="2.2.2" />
<plugin name="cordova-plugin-device" spec="1.1.4" />
<plugin name="cordova-plugin-splashscreen" spec="~4.0.1" />
<engine name="android" spec="^7.1.0" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-facebook4" spec="^1.9.1">
<variable name="APP_ID" value="223991774869277" />
<variable name="APP_NAME" value="CMC" />
</plugin>
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-statusbar" spec="^2.2.2" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.1" />
<plugin name="cordova-plugin-x-toast" spec="^2.6.2" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
<plugin name="cordova-plugin-googleplus" spec="^5.3.0">
<variable name="REVERSED_CLIENT_ID" value="151146703576-dr7il48km7elnm2f8cfj6ru8g0adpgi6.apps.googleusercontent.com" />
</plugin>
<plugin name="cordova-plugin-geolocation" spec="^4.0.1">
<variable name="GEOLOCATION_USAGE_DESCRIPTION" value="To locate you" />
</plugin>
</widget>
......@@ -2,5 +2,7 @@
"name": "cmc_v2",
"app_id": "b8b89996",
"type": "ionic-angular",
"integrations": {}
"integrations": {
"cordova": {}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "cmc_v2",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.4.3",
"@angular/compiler": "4.4.3",
"@angular/compiler-cli": "4.4.3",
"@angular/core": "4.4.3",
"@angular/forms": "4.4.3",
"@angular/http": "4.4.3",
"@angular/platform-browser": "4.4.3",
"@angular/platform-browser-dynamic": "4.4.3",
"@ionic-native/core": "3.12.1",
"@ionic-native/splash-screen": "3.12.1",
"@ionic-native/status-bar": "3.12.1",
"@ionic/storage": "2.0.1",
"ionic-angular": "3.7.0",
"ionicons": "3.0.0",
"rxjs": "5.4.3",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.17"
},
"devDependencies": {
"@ionic/app-scripts": "3.0.0",
"typescript": "2.3.4"
},
"description": "An Ionic project"
}
"name": "cmc_v2",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.4.3",
"@angular/compiler": "4.4.3",
"@angular/compiler-cli": "4.4.3",
"@angular/core": "4.4.3",
"@angular/forms": "4.4.3",
"@angular/http": "4.4.3",
"@angular/platform-browser": "4.4.3",
"@angular/platform-browser-dynamic": "4.4.3",
"@ionic-native/core": "3.12.1",
"@ionic-native/facebook": "^4.6.0",
"@ionic-native/geolocation": "^4.7.0",
"@ionic-native/google-plus": "^4.7.0",
"@ionic-native/splash-screen": "3.12.1",
"@ionic-native/status-bar": "3.12.1",
"@ionic-native/toast": "^4.7.0",
"@ionic/storage": "2.0.1",
"angularfire2": "^5.0.0-rc.10",
"cordova-android": "^7.1.0",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-facebook4": "^1.9.1",
"cordova-plugin-geolocation": "^4.0.1",
"cordova-plugin-googleplus": "^5.3.0",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"cordova-plugin-x-toast": "^2.6.2",
"firebase": "^5.0.4",
"ionic-angular": "3.7.0",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"promise-polyfill": "^8.0.0",
"rxjs": "^5.5.11",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.17"
},
"devDependencies": {
"@ionic/app-scripts": "3.0.0",
"typescript": "2.3.4"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-whitelist": {},
"ionic-plugin-keyboard": {},
"cordova-plugin-x-toast": {},
"cordova-plugin-facebook4": {
"APP_ID": "223991774869277",
"APP_NAME": "CMC"
},
"cordova-plugin-googleplus": {
"REVERSED_CLIENT_ID": "151146703576-dr7il48km7elnm2f8cfj6ru8g0adpgi6.apps.googleusercontent.com"
},
"cordova-plugin-geolocation": {
"GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
}
},
"platforms": [
"android"
]
}
}
\ No newline at end of file
File deleted
import { Component, ViewChild } from '@angular/core';
import { Nav, Platform } from 'ionic-angular';
import { Nav, Platform, Events } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Storage } from '@ionic/storage';
import { user } from '../models/mymodel'
import { Myservice } from "../providers/myservice";
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = 'LandingPage';
rootPage: string ;
local:user;
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen) {
constructor(public platform: Platform, public statusBar: StatusBar, public splashScreen: SplashScreen, public storage: Storage, public events: Events, private myservice: Myservice) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.storage.get('user_data').then(data=>{
console.log(data)
if(data){
this.rootPage = 'HomePage'
this.local = data
console.log(this.local)
}
else
this.rootPage = 'LandingPage'
})
this.events.subscribe('user:profile', data => {
this.local = data
if (this.local) {
this.local.image = this.local.image.startsWith("http") ? this.local.image : this.myservice.base_url + this.local.image;
console.log(this.local)
}
})
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
open_page(page){
if (page =='LandingPage'){
this.storage.remove('user_data');
this.nav.setRoot(page);
this.events.publish('user:profile', '');
}
else
this.nav.setRoot(page);
}
}
}
\ No newline at end of file
<ion-menu [content]="content">
<ion-content class="cab_sidemenu_bg">
<div class="cab_sidemenu_wrapper">
<div menuClose class="cab_profile_banner" (click)="open_page('ProfilePage')">
<div menuClose class="cab_profile_banner" (click)="open_page('ProfilePage')" *ngIf="local">
<div class="cab_profile_picture">
<img [src]=local.image>
</div>
<h6>Catharine Morgan</h6>
<p>+0966-26539</p>
<h6>{{local.name}}</h6>
<p>{{local.dial_code}}{{local.mobile}}</p>
</div>
<div class="cab_sidemenu_list">
<ul>
<li menuClose class="book" (click)="open_page('HomePage')">Book Ride</li>
<li menuClose class="trip" (click)="open_page('MytripsPage')">My Trips</li>
<li menuClose class="settings" (click)="open_page('SettingsPage')">Settings</li>
<li menuClose class="logout" (click)="open_page('LoginPage')">Logout</li>
<li menuClose class="logout" (click)="open_page('LandingPage')">Logout</li>
</ul>
</div>
</div>
......
......@@ -5,6 +5,26 @@ import { MyApp } from './app.component';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Myservice } from "../providers/myservice";
import { HttpModule } from "@angular/http";
import { IonicStorageModule } from '@ionic/storage';
import { OrderbyPipe } from '../providers/sort-pipe';
import { Toast } from '@ionic-native/toast';
import { Facebook } from '@ionic-native/facebook';
import { GooglePlus } from '@ionic-native/google-plus';
import { AngularFireModule } from 'angularfire2';
import { fireService } from '../providers/firebase.service'
import { AngularFireDatabase } from 'angularfire2/database';
import { Geolocation } from '@ionic-native/geolocation';
export const firebaseConfig = {
apiKey: "AIzaSyDLrbLd4RCCh86xuTVu7-cfJ28We_cG1sU",
authDomain: "callmycab-205809.firebaseapp.com",
databaseURL: "https://callmycab-205809.firebaseio.com",
projectId: "callmycab-205809",
storageBucket: "callmycab-205809.appspot.com",
messagingSenderId: "151146703576"
};
@NgModule({
declarations: [
MyApp
......@@ -12,6 +32,9 @@ import { SplashScreen } from '@ionic-native/splash-screen';
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpModule,
IonicStorageModule.forRoot(),
AngularFireModule.initializeApp(firebaseConfig),
],
bootstrap: [IonicApp],
entryComponents: [
......@@ -20,7 +43,15 @@ import { SplashScreen } from '@ionic-native/splash-screen';
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler}
{provide: ErrorHandler, useClass: IonicErrorHandler},
Myservice,
OrderbyPipe,
Toast,
Facebook,
GooglePlus,
fireService,
AngularFireDatabase,
Geolocation,
]
})
export class AppModule {}
......@@ -10,6 +10,7 @@
.cab_sign_btn{height:45px;width:100%;background:#ff9c00;color: #fff;text-transform: capitalize !important;font-size: 16px;font-weight: 400;}
.cab_sign_btn1{height:45px;width:100%;border:1px solid #ff9c00;color: #ff9c00;background:transparent;text-transform: capitalize !important;font-size: 16px;font-weight: 400;}
.cab_form p{color: #3d3a3b;font-weight: 500;font-size: 18px;}
.cab_req{color: #e42727;padding-top: 7px;font-weight: 500;text-align: center;font-size: 15px;}
/* LOGIN */
......@@ -174,8 +175,12 @@
/*EDIT-PROFILE*/
.cab_edit_profile_wrapper{width:100%;padding-top: 40px;}
.cab_edit_profilepic_edit{width:100px;height:100px;margin:0 auto;border-radius:50%;border: 2px solid #f7941e;background-color:#f7941e !important;background-size: 25px !important;background: url(../assets/img/avatar.png);background-position: center;background-repeat: no-repeat;}
.cab_edit_profilepic_edit{width:100px;height:100px;margin:0 auto;position:relative;border-radius:50%;border: 2px solid #f7941e;background-color:#f7941e !important;background-size: 25px !important;background: url(../assets/img/avatar.png);background-position: center;background-repeat: no-repeat;}
.cab_edit_profilepic_edit img{width:100%;height:100%;border-radius:50%;object-fit:cover;object-position:center;}
.cab_edit_profile_edit_form{width:100%;padding-top: 20px;}
.cab_edit_profile_edit_row{width:100%;}
.cab_edit_profile_input{width:100%;}
\ No newline at end of file
.cab_edit_profile_input{width:100%;}
.edit_circle{width:30px;height:30px;position:absolute;top:0px;right:0px;background-color:#f7941e;color:#fff;text-align:center;border-radius: 50%;padding:7px;}
.edit_circle input{width: 100%;opacity: 0;z-index: 99;position: absolute;right: 0px;}
.edit_circle ion-icon{position: absolute;top: 6px;right: 8px;}
\ No newline at end of file
......@@ -16,26 +16,27 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!-- cordova.js required for cordova apps -->
<script src="http://maps.google.com/maps/api/js?key=AIzaSyCIs0lfeIa7zWX0SU4oE6irYsXkUEWe1aU"></script>
<script src="cordova.js"></script>
<link href="build/main.css" rel="stylesheet">
</head>
<body>
<!-- Ionic's root component and where the app will load -->
<ion-app></ion-app>
<!-- The polyfills js is generated during the build process -->
<script src="build/polyfills.js"></script>
<!-- The vendor js is generated during the build process
It contains all of the dependencies in node_modules -->
<script src="build/vendor.js"></script>
<!-- The main bundle js is generated during the build process -->
<script src="build/main.js"></script>
</body>
</html>
It contains all of the dependencies in node_modules -->
<script src="build/vendor.js"></script>
<!-- The main bundle js is generated during the build process -->
<script src="build/main.js"></script>
<script src="http://maps.google.com/maps/api/js?libraries=places&key=AIzaSyCk1_NXO6fDntAzKEl7sO-z6Ut5evHLsKQ"></script>
</body>
</html>
\ No newline at end of file
export class dialcode{
country:string;
dialCode:number;
}
export class user{
email:string
id: string
mobile: string
name: string
image: string
dial_code: string
}
\ No newline at end of file
......@@ -13,8 +13,8 @@
</ion-content>
<ion-footer>
<div class="cab_footer_location theme_bgcolor">
<input class="cab_location_input cab_current" placeholder="Pickup Location">
<input class="cab_location_input cab_destination" placeholder="Drop Location">
<input class="cab_location_input cab_current" placeholder="Pickup Location" id="pickUp" [(ngModel)]="pickLoc">
<input class="cab_location_input cab_destination" placeholder="Drop Location" id="drop">
</div>
<div class="cab_footer_btn_bay">
<button ion-button class="cab_footer_btn floatRight" (click)="ridenow()">RIDE NOW</button>
......
import { Component,ViewChild, ElementRef} from '@angular/core';
import { IonicPage, NavController, NavParams,ModalController } from 'ionic-angular';
import { Component, ViewChild, ElementRef } from '@angular/core';
import { IonicPage, NavController, NavParams, ModalController } from 'ionic-angular';
import { Storage } from "@ionic/storage";
import { Geolocation } from '@ionic-native/geolocation';
import { fireService } from "../../providers/firebase.service";
import { AngularFireDatabase } from 'angularfire2/database';
import { Myservice } from "../../providers/myservice";
import * as firebase from 'firebase';
declare var google;
@IonicPage()
@Component({
......@@ -10,41 +17,78 @@ export class HomePage {
@ViewChild('map') mapElement: ElementRef;
map: any;
p_lat: any;
p_lng: any;
pickLoc:string
constructor(public navCtrl: NavController, public navParams: NavParams,public modalCtrl: ModalController) {
constructor(public navCtrl: NavController, public navParams: NavParams, public modalCtrl: ModalController, public storage: Storage, private geolocation: Geolocation, private firebase: fireService, private db: AngularFireDatabase,private myservice:Myservice) {
}
ionViewDidLoad() {
this.loadMap();
ionViewDidEnter() {
this.geolocation.getCurrentPosition().then((resp) => {
this.loadMap(resp.coords.latitude, resp.coords.longitude);
}).catch((error) => {
console.log('Error getting location', error);
});
var This = this
firebase.database().ref().child('/drivers/').orderByChild("status").equalTo('online').on("value", function (snapshot) {
var res_arr = (<any>Object).entries(snapshot.val()).map(e => Object.assign(e[1], { key: e[0] }));
for (let i = 0; i < res_arr.length; i++) {
let marker = new google.maps.Marker({
map: This.map,
icon:'assets/img/star-on-big.png',
position: { lat: res_arr[i].lat, lng: res_arr[i].lng }
});
}
});
}
loadMap(){
ionViewDidLoad(){
let latLng = new google.maps.LatLng(-34.9290, 138.6010);
var autocomplete = new google.maps.places.Autocomplete(document.getElementById("pickUp"));
var This = this;
console.log(autocomplete)
autocomplete.addListener('place_changed', function() {
var place = autocomplete.getPlace();
This.p_lat = place.geometry.location.lat();
This.p_lng = place.geometry.location.lng();
console.log(This.p_lat, This.p_lng)
This.loadMap(This.p_lat, This.p_lng)
});
}
loadMap(lat, lng) {
let latLng = new google.maps.LatLng(lat, lng);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var marker = new google.maps.Marker({
position: latLng
});
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
marker.setMap(this.map);
}
ridemore() {
let modal = this.modalCtrl.create('RidepopPage');
modal.present();
}
let modal = this.modalCtrl.create('RidepopPage');
modal.present();
}
ridenow() {
let modal = this.modalCtrl.create('RidenowPage');
modal.present();
}
searchride(){
let modal = this.modalCtrl.create('SearchridePage');
modal.present();
}
ridenow() {
let modal = this.modalCtrl.create('RidenowPage');
modal.present();
}
searchride() {
let modal = this.modalCtrl.create('SearchridePage');
modal.present();
}
}
......@@ -19,8 +19,8 @@
<ion-footer>
<div class="cab_footer">
<p>Or Sign in with</p>
<li><img src="assets/img/fb.png"></li>
<li><img src="assets/img/linked.png"></li>
<li><img src="assets/img/fb.png" (click)="signInWithFB()"></li>
<li><img src="assets/img/linked.png" (click)="signInWithGoogle()"></li>
<div class="clear"></div>
</div>
</ion-footer>
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { IonicPage, NavController, NavParams,Events } from 'ionic-angular';
import { Facebook, FacebookLoginResponse } from '@ionic-native/facebook';
import { GooglePlus } from '@ionic-native/google-plus';
import { Myservice } from '../../providers/myservice'
import { Storage } from '@ionic/storage';
import { fireService } from "../../providers/firebase.service";
import { Geolocation } from '@ionic-native/geolocation';
@IonicPage()
@Component({
......@@ -7,8 +13,10 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
templateUrl: 'landing.html',
})
export class LandingPage {
fb_data = { email: '', firstname: '', lastname: '', gender: '', image: '', fb_id: '', id: '', name: '' };
gp_data = { email: '', firstname: '', lastname: '', image: '', google_id: '', id: '', name: '' };
constructor(public navCtrl: NavController, public navParams: NavParams) {
constructor(public navCtrl: NavController, public navParams: NavParams, private fb: Facebook, private googlePlus: GooglePlus, private myservice: Myservice, public storage: Storage, private events: Events, private firebase: fireService, private geolocation: Geolocation) {
}
ionViewDidLoad() {
......@@ -19,5 +27,82 @@ export class LandingPage {
this.navCtrl.push(page);
}
signInWithFB() {
this.myservice.show_loader()
this.fb.login(['public_profile', 'user_friends', 'email'])
.then((res: FacebookLoginResponse) => {
// console.log('Logged into Facebook!', res)
this.fb.api('me?fields=id,name,email,gender,last_name,first_name,picture.width(720).height(720).as(picture_large)', []).then(profile => {
console.log('profile', profile)
this.fb_data.email = profile.email;
this.fb_data.name = profile.first_name + ' ' + profile.last_name;
this.fb_data.image = profile.picture_large.url;
// this.fb_data.fb_id = profile.id;
this.myservice.load_post(this.fb_data, 'social_login').subscribe(response => {
if (response.status == true) {
this.getLoc().then((obj: any) => {
var data = response.data
data.lat = obj.loc.latitude
data.lng = obj.loc.longitude
this.firebase.pushItem('users/', response.data)
response.data.image = response.data.image.startsWith("http") ? response.data.image : this.myservice.base_url + response.data.image;
this.myservice.hide_loader()
this.storage.set('user_data', response.data);
this.logged_event(this.fb_data)
this.navCtrl.setRoot('HomePage')
})
}
else {
}
})
});
})
.catch(e => console.log('Error logging into Facebook', e));
}
signInWithGoogle() {
this.myservice.show_loader()
this.googlePlus.login({})
.then(res => {
this.gp_data.email = res.email;
this.gp_data.name = res.givenName + ' ' + res.familyName;
if (res.imageUrl) {
this.gp_data.image = res.imageUrl;
}
this.myservice.load_post(this.gp_data, 'social_login').subscribe(response => {
if (response.status == 'success') {
this.getLoc().then((obj:any)=>{
var data = response.data
data.lat = obj.loc.latitude
data.lng = obj.loc.longitude
this.firebase.pushItem('users/', response.data)
response.data.image = response.data.image.startsWith("http") ? response.data.image : this.myservice.base_url + response.data.image;
this.myservice.hide_loader()
this.storage.set('user_data', response.data);
this.logged_event(response.data)
this.navCtrl.setRoot('HomePage')
})
}
else {
}
})
})
.catch(err => console.error(err));
}
logged_event(data) {
this.events.publish('user:profile', data);
}
getLoc(){
var promise = new Promise((resolve, reject) => {
this.geolocation.getCurrentPosition().then((resp) => {
resolve({ 'loc': resp.coords });
})
});
return promise;
}
}
......@@ -8,32 +8,40 @@
<hr>
<br>
<div class="cab_form">
<form [formGroup]="loginForm">
<div class="cab_form_row">
<div class="cab_phone_number">
<select class="cab_phone_code floatLeft">
<option>+91</option>
<select class="cab_phone_code floatLeft" formControlName="dial_code">
<option *ngFor="let code of codes" value=+{{code.dialCode}}>+{{code.dialCode}}</option>
</select>
<input class="cab_phone_input floatRight cab_call" placeholder="Mobile Number">
<input class="cab_phone_input floatRight cab_call" placeholder="Mobile Number" formControlName="mobile" type="number">
<div class="clear"></div>
<div class="cab_req" *ngIf="loginForm.controls.mobile.invalid && (loginForm.get('mobile').dirty || loginForm.get('mobile').touched)">
Enter a valid Mobile
</div>
</div>
</div>
<br>
<div class="cab_form_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_pass width100" placeholder="Password">
<input class="cab_phone_input cab_pass width100" placeholder="Password" formControlName="password" type="password">
<div class="cab_req" *ngIf="loginForm.controls.password.invalid && (loginForm.get('password').dirty || loginForm.get('password').touched)">
Minimum 6 characters
</div>
<div class="clear"></div>
</div>
</div>
</form>
<br>
<div class="cab_form_row textCenter">
<!-- <div class="cab_form_row textCenter">
<ion-item>
<ion-label><p>Remember me</p></ion-label>
<ion-checkbox></ion-checkbox>
</ion-item>
</div>
</div> -->
<br>
<div class="cab_form_row">
<button ion-button class="cab_sign_btn" (click)="open_page('HomePage')">Sign In</button>
<button ion-button class="cab_sign_btn" (click)="login()">Sign In</button>
</div>
<br>
<div class="cab_form_row textCenter">
......
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { IonicPage, NavController, NavParams, Events } from 'ionic-angular';
import { Validators, FormGroup, FormBuilder } from '@angular/forms'
import { Myservice } from '../../providers/myservice'
import { Storage } from '@ionic/storage';
import { Http } from '@angular/http'
import { OrderbyPipe } from '../../providers/sort-pipe';
import { user } from "../../models/mymodel";
@IonicPage()
@Component({
......@@ -7,12 +13,23 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
templateUrl: 'login.html',
})
export class LoginPage {
loginForm: FormGroup
codes:any;
local:user
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
constructor(public navCtrl: NavController, public navParams: NavParams, public events: Events, private formBuilder: FormBuilder, private myservice: Myservice, public storage: Storage, private http: Http, private orderbyPipe: OrderbyPipe) {
this.loginForm = this.formBuilder.group({
mobile: ['', Validators.compose([Validators.required, this.myservice.checkLimit(10000000, 999999999999999)])],
dial_code: ['+91', Validators.required],
password: ['', Validators.compose([Validators.required, Validators.minLength(6)])]
})
ionViewDidLoad() {
console.log('ionViewDidLoad LoginPage');
this.http.get('dial-codes.json')
.subscribe(response => {
this.codes = response.json().dialCodes
this.codes = this.orderbyPipe.transform(this.codes, 'dialCode');
})
}
open_page(page){
......@@ -23,4 +40,25 @@ export class LoginPage {
this.navCtrl.pop();
}
login(){
this.myservice.show_loader()
this.myservice.load_post(this.loginForm.value,'login').subscribe(response=>{
if (response[0].status == 'success'){
this.local = response[0].data
response[0].data.image = response[0].data.image.startsWith("http") ? response[0].data.image : this.myservice.base_url + response[0].data.image;
this.storage.set('user_data', response[0].data)
var This = this;
setTimeout(() => {
This.myservice.hide_loader();
This.events.publish('user:profile', response[0].data);
This.navCtrl.setRoot('HomePage')
}, 500);
}
else{
this.myservice.hide_loader();
this.myservice.show_alert('Failed', response[0].message)
}
})
}
}
......@@ -8,40 +8,77 @@
<ion-content padding class="themelogin_background">
<div class="cab_edit_profile_wrapper">
<div class="cab_edit_profilepic_edit">
<div class="edit_circle">
<input id="imgSelector" type="file" accept="image/*" (change)="fileChange($event)" />
<ion-icon name="create"></ion-icon>
</div>
<img [src]=profileForm.value.image>
</div>
<div class="cab_edit_profile_edit_form">
<div class="cab_form">
<form [formGroup]="profileForm">
<div class="cab_form_row cab_edit_profile_edit_row">
<div class="cab_phone_number">
<select class="cab_phone_code floatLeft">
<option>+91</option>
</select>
<input class="cab_phone_input floatRight cab_call" placeholder="Mobile Number">
<div class="clear"></div>
<input class="cab_phone_input floatRight cab_call" placeholder="Mobile Number" formControlName="mobile">
<div class="clear"></div>
</div>
</div>
</div>
<div class="cab_req" *ngIf="profileForm.controls.mobile.invalid && (profileForm.get('mobile').dirty || profileForm.get('mobile').touched)">
Enter a valid Mobile
</div>
<div class="cab_form_row cab_edit_profile_edit_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_user width100" placeholder="Username">
<div class="clear"></div>
<input class="cab_phone_input cab_user width100" placeholder="Name" formControlName="name">
<div class="clear"></div>
</div>
</div>
<div class="cab_req" *ngIf="profileForm.controls.name.invalid && (profileForm.get('name').dirty || profileForm.get('name').touched)">
Enter a valid Name
</div>
<div class="cab_form_row cab_edit_profile_edit_row">
<div class="cab_phone_number">
<input class="cab_phone_input width100" placeholder="Email" type="email" formControlName="email">
<div class="clear"></div>
</div>
</div>
</div>
<div class="cab_req" *ngIf="profileForm.controls.email.invalid && (profileForm.get('email').dirty || profileForm.get('email').touched)">
Enter a valid Email
</div>
<div class="cab_form_row cab_edit_profile_edit_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_pass width100" placeholder="Password" type="password">
<div class="clear"></div>
<input class="cab_phone_input cab_pass width100" placeholder="Current Password" type="password" formControlName="password">
<div class="clear"></div>
</div>
</div>
</div>
<div class="cab_req" *ngIf="profileForm.controls.password.invalid && (profileForm.get('password').dirty || profileForm.get('password').touched)">
Minimum 6 characters
</div>
<div class="cab_form_row cab_edit_profile_edit_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_pass width100" placeholder="New Password" type="password" formControlName="new">
<div class="clear"></div>
</div>
</div>
<div class="cab_req" *ngIf="profileForm.controls.new.invalid && (profileForm.get('new').dirty || profileForm.get('new').touched)">
Minimum 6 characters
</div>
<div class="cab_form_row cab_edit_profile_edit_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_pass width100" placeholder="Confirm Password" type="password">
<div class="clear"></div>
<input class="cab_phone_input cab_pass width100" placeholder="Confirm Password" type="password" formControlName="confirm">
<div class="clear"></div>
</div>
</div>
</div>
<div class="cab_req" *ngIf="profileForm.controls.confirm.invalid && (profileForm.get('confirm').dirty || profileForm.get('confirm').touched)">
Password Mismatches
</div>
</form>
</div>
</div>
</div>
</ion-content>
<ion-footer>
<button ion-button class="cab_footer_btn width100 text_white">UPDATE</button>
<button ion-button class="cab_footer_btn width100 text_white" (click)="update()" [disabled]="profileForm.invalid">UPDATE</button>
</ion-footer>
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
/**
* Generated class for the ProfilePage page.
*
* See https://ionicframework.com/docs/components/#navigation for more info on
* Ionic pages and navigation.
*/
import { IonicPage, NavController, NavParams,Events } from 'ionic-angular';
import { Validators, FormGroup, FormBuilder } from '@angular/forms'
import { Myservice } from '../../providers/myservice'
import { Storage } from '@ionic/storage';
import { Http } from '@angular/http'
import { OrderbyPipe } from '../../providers/sort-pipe';
import { user } from "../../models/mymodel";
@IonicPage()
@Component({
selector: 'page-profile',
templateUrl: 'profile.html',
})
export class ProfilePage {
profileForm:FormGroup
codes: any;
local:user
image:boolean = false;
formdata = new FormData();
constructor(public navCtrl: NavController, public navParams: NavParams, private formBuilder: FormBuilder, private myservice: Myservice, private http: Http, private orderbyPipe: OrderbyPipe, public storage: Storage,private events:Events) {
this.profileForm = this.formBuilder.group({
name: ['', Validators.compose([Validators.required, Validators.minLength(3)])],
mobile: ['', Validators.compose([Validators.required, this.myservice.checkLimit(10000000, 999999999999999)])],
dial_code: ['+91', Validators.required],
email: ['', Validators.compose([Validators.required, Validators.pattern("[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}")])],
password: ['', Validators.compose([Validators.minLength(6)])],//,
new: [''],//Validators.compose([ Validators.minLength(6)])
confirm: [''],// Validators.compose([]), this.MatchPassword.bind(this)
image:[''],
secret_key: ['My_key']
})
this.http.get('dial-codes.json')
.subscribe(response => {
this.codes = response.json().dialCodes
this.codes = this.orderbyPipe.transform(this.codes, 'dialCode');
})
}
ionViewDidEnter(){
this.storage.get('user_data').then(data=>{
if(data){
this.local = data
this.profileForm.controls['name'].setValue(this.local.name)
this.profileForm.controls['email'].setValue(this.local.email)
this.profileForm.controls['dial_code'].setValue(this.local.dial_code)
this.profileForm.controls['mobile'].setValue(this.local.mobile)
this.profileForm.controls['image'].setValue(this.local.image)
// this.myservice.load_post(this.local.id,'get_userProfile').subscribe(response=>{
// if(response.status == 'success'){
// }
// })
}
})
}
update(){
if(this.profileForm.value.password.length>0){
this.profileForm.controls["new"].setValidators([Validators.minLength(6), Validators.required]);
this.profileForm.controls["confirm"].setValidators([Validators.required]), this.MatchPassword.bind(this);
this.profileForm.controls["confirm"].setAsyncValidators(this.MatchPassword.bind(this))
}
if(this.profileForm.valid){
this.myservice.show_loader()
this.formdata.append('data', JSON.stringify(this.profileForm.value));
this.formdata.append('id', JSON.stringify(this.local.id));
this.myservice.fileUpload(this.formdata,'update_user').subscribe(response=>{
if(response.status=='success'){
this.local = response.data
var This = this
setTimeout(() => {
This.myservice.hide_loader()
This.events.publish('user:profile', This.local);
}, 500);
}
else{
this.myservice.hide_loader()
this.myservice.show_alert('',response.message)
}
})
}
}
fileChange(event) {
let fileList: FileList = event.target.files;
if (fileList.length > 0) {
var reader = new FileReader();
reader.onload = (event: any) => {
this.profileForm.controls['image'].setValue(event.target.result)
}
reader.readAsDataURL(event.target.files[0]);
constructor(public navCtrl: NavController, public navParams: NavParams) {
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.image = true;
}
else {
this.myservice.show_alert("Error","Please choose an image file")
}
}
}
ionViewDidLoad() {
console.log('ionViewDidLoad ProfilePage');
MatchPassword(val) {
return new Promise(resolve => {
if (val.value == this.profileForm.value.new) {
resolve(null);
}
else {
resolve({ 'match': false });
}
})
}
}
......@@ -8,53 +8,73 @@
<hr>
<br>
<div class="cab_form">
<form [formGroup]="signupForm">
<div class="cab_form_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_user width100" placeholder="Username">
<input class="cab_phone_input cab_user width100" placeholder="Name" formControlName="User_name">
<div class="cab_req" *ngIf="signupForm.controls.User_name.invalid && (signupForm.get('User_name').dirty || signupForm.get('User_name').touched)">
Enter a valid Name
</div>
<div class="clear"></div>
</div>
</div>
<br>
<div class="cab_form_row">
<div class="cab_phone_number">
<select class="cab_phone_code floatLeft">
<option>+91</option>
<select class="cab_phone_code floatLeft" formControlName="dial_code" >
<option *ngFor="let code of codes" value=+{{code.dialCode}}>+{{code.dialCode}}</option>
</select>
<input class="cab_phone_input floatRight cab_call" placeholder="Mobile Number">
<input class="cab_phone_input floatRight cab_call" placeholder="Mobile Number" formControlName="Mobile" type="number">
<div class="cab_req" *ngIf="signupForm.controls.Mobile.invalid && (signupForm.get('Mobile').dirty || signupForm.get('Mobile').touched)">
Enter a valid Mobile
</div>
<div class="clear"></div>
</div>
</div>
<br>
<div class="cab_form_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_mail width100" placeholder="Email">
<input class="cab_phone_input cab_mail width100" placeholder="Email" formControlName="Email" type="email">
<div class="cab_req" *ngIf="signupForm.controls.Email.invalid && (signupForm.get('Email').dirty || signupForm.get('Email').touched)">
Enter a valid Email
</div>
<div class="clear"></div>
</div>
</div>
<br>
<div class="cab_form_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_pass width100" placeholder="Password">
<input class="cab_phone_input cab_pass width100" placeholder="Password" formControlName="Password" type="password">
<div class="cab_req" *ngIf="signupForm.controls.Password.invalid && (signupForm.get('Password').dirty || signupForm.get('Password').touched)">
Minimum 6 characters
</div>
<div class="clear"></div>
</div>
</div>
<br>
<div class="cab_form_row">
<div class="cab_phone_number">
<input class="cab_phone_input cab_confirmpass width100" placeholder="Confirm Password">
<input class="cab_phone_input cab_confirmpass width100" placeholder="Confirm Password" formControlName="confirm" type="password">
<div class="cab_req" *ngIf="signupForm.controls.confirm.invalid && (signupForm.get('confirm').dirty || signupForm.get('confirm').touched)">
Password mismatches
</div>
<div class="clear"></div>
</div>
</div>
<br>
<div class="cab_form_row textCenter">
<ion-item style="width:100%;">
<ion-item style="width:100% !important;">
<ion-label><p>I accept terms & condition</p></ion-label>
<ion-checkbox></ion-checkbox>
<ion-checkbox formControlName="terms"></ion-checkbox>
</ion-item>
<div class="cab_req" *ngIf="signupForm.controls.terms.invalid && (signupForm.get('terms').dirty || signupForm.get('terms').touched)">
Please accept terms & conditions
</div>
</div>
</form>
<br>
<div class="cab_form_row">
<button ion-button class="cab_sign_btn" (click)="open_page('HomePage')">Sign Up</button>
<button ion-button class="cab_sign_btn" (click)="register()" [disabled]="signupForm.invalid">Sign Up</button>
</div>
</div>
</div>
......
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { IonicPage, NavController, NavParams, Events } from 'ionic-angular';
import { Validators, FormBuilder, FormGroup } from "@angular/forms";
import { Myservice } from "../../providers/myservice";
import { Http } from '@angular/http'
import { OrderbyPipe } from '../../providers/sort-pipe';
import { dialcode } from "../../models/mymodel";
import { Toast } from '@ionic-native/toast';
import { Storage } from '@ionic/storage';
import { fireService } from "../../providers/firebase.service";
import { Geolocation } from '@ionic-native/geolocation';
@IonicPage()
@Component({
......@@ -7,18 +16,79 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
templateUrl: 'signup.html',
})
export class SignupPage {
signupForm: FormGroup
codes: Array<dialcode>;
errors: string = '';
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
constructor(public navCtrl: NavController, public navParams: NavParams, public formBuilder: FormBuilder, private myservice: Myservice, private http: Http, private orderbyPipe: OrderbyPipe, private toast: Toast, private events: Events, public storage: Storage, private firebase: fireService, private geolocation: Geolocation) {
this.signupForm = this.formBuilder.group({
User_name: ['', Validators.compose([Validators.required, Validators.minLength(3)])],
Mobile: ['', Validators.compose([Validators.required, this.myservice.checkLimit(10000000, 999999999999999)])],
dial_code: ['+91', Validators.required],
Email: ['', Validators.compose([Validators.required, Validators.pattern("[a-zA-Z0-9.-_]{1,}@[a-zA-Z.-]{2,}[.]{1}[a-zA-Z]{2,}")])],
Password: ['', Validators.compose([Validators.required, Validators.minLength(6)])],
confirm: ['', Validators.compose([Validators.required]), this.MatchPassword.bind(this)],
terms: [null, Validators.compose([Validators.required, Validators.pattern('true')])],
})
ionViewDidLoad() {
console.log('ionViewDidLoad SignupPage');
this.http.get('dial-codes.json')
.subscribe(response => {
this.codes = response.json().dialCodes
this.codes = this.orderbyPipe.transform(this.codes, 'dialCode');
})
}
open_page(page){
open_page(page) {
this.navCtrl.push(page);
}
goBack(){
goBack() {
this.navCtrl.pop();
}
register() {
this.myservice.show_loader()
this.geolocation.getCurrentPosition().then((resp) => {
this.myservice.load_post(this.signupForm.value, 'sign_up').subscribe(response => {
if (response.status == 'success') {
response.data.lat = resp.coords.latitude
response.data.lng = resp.coords.longitude
this.firebase.pushItem('users/', response.data)
response.data.image = response.data.image.startsWith("http") ? response.data.image : this.myservice.base_url + response.data.image;
this.myservice.hide_loader()
this.storage.set('user_data', response.data);
this.events.publish('user:profile', response.data);
this.navCtrl.setRoot('HomePage')
this.toast.show(response.message, '2000', 'center').subscribe(
toast => {
console.log(toast);
});
}
else {
this.myservice.hide_loader()
for (let index = 0; index < response.error_list.length; index++) {
this.errors = this.errors + response.error_list[index].message + '.<br/>'
}
this.myservice.show_alert('Failed', this.errors)
}
})
}).catch((error) => {
console.log('Error getting location', error);
});
}
MatchPassword(val) {
return new Promise(resolve => {
if (val.value == this.signupForm.value.Password) {
resolve(null);
}
else {
resolve({ 'match': false });
}
})
}
}
import { Injectable } from '@angular/core';
import { AngularFireDatabase } from 'angularfire2/database';
import { FirebaseListObservable } from 'angularfire2/database-deprecated';
import * as firebase from 'firebase';
import 'rxjs/add/operator/toPromise';
// import { Router } from '@angular/router';
@Injectable()
export class fireService {
items: FirebaseListObservable<any[]>;
//data: FirebaseObjectObservable<any[]>;
data:any;
currentUser: any;
userData: any;
// private basePath: string = 'users';
constructor(
private db: AngularFireDatabase,) {
// console.log(this.currentUser);
// console.log('hhhh');
}
pushItem(url,data){
var key = firebase.database().ref(url).push().key;
var new_node = url + "/" + key;
data.push_id = key;
this.updateItem(new_node, data)
return 'success';
}
updateItem(url,data){
// return this.db.object(url).update(data);
var promise = new Promise((resolve, reject) => {
if (this.db.object(url).update(data)) {
// console.log("Updated");
resolve({ 'status': 'success' });
} else {
reject();
}
});
return promise;
}
removeItem(url){
return this.db.object(url).remove();
}
listItem(url){
return this.db.list(url);
}
listItemQuery(url,query){
return this.db.list(url,query);
}
checkItem(url){
return this.db.list(url);
}
}
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { LoadingController, AlertController, Events } from 'ionic-angular';
import { AbstractControl, ValidatorFn } from '@angular/forms'
@Injectable()
export class Myservice {
// base_url = 'http://techlabz.in/bmd_new/'
base_url = 'http://192.168.140.20/CMC/'
webservice_url = this.base_url + 'web_service/'
loader: any;
alert: any;
post_url: any;
data: any;
result: any;
msg_push: any;
constructor(public http: Http, public loadingCtrl: LoadingController, public alertCtrl: AlertController, public events: Events) { }
show_loader() {
this.loader = this.loadingCtrl.create({
content: ""
});
this.loader.present();
}
show_alert(title, message) {
this.alert = this.alertCtrl.create({
title: title,
subTitle: message,
// message: message,
buttons: ['OK']
});
this.alert.present();
}
hide_loader() {
this.loader.dismissAll();
}
load_post(post_data, fn_name) {
post_data.secret_key = 'My_key';
post_data = JSON.stringify(post_data);
this.post_url = this.webservice_url + fn_name;
// let headers = new Headers();
// headers.append('X-API-KEY', 'key_test');
// let options = new RequestOptions({ headers });
return this.http.post(`${this.post_url}`, `${post_data}`).map(res => res.json());
}
get_data(fn_name) {
return this.http.get(this.webservice_url + fn_name)
.map(res => res.json());
}
get_dataById(fn_name, id) {
return this.http.get(this.webservice_url + fn_name + id)
.map(res => res.json());
}
fileUpload(data, fn_name) {
var post_url = this.webservice_url + fn_name;
return this.http.post(post_url, data)
.map(res => res.json());
}
get_baseurl() {
return this.base_url;
}
checkLimit(min: number, max: number): ValidatorFn {
return (c: AbstractControl): { [key: string]: boolean } | null => {
if (c.value && (isNaN(c.value) || c.value < min || c.value > max)) {
return { 'range': true };
}
return null;
};
}
}
\ No newline at end of file
import { Pipe, PipeTransform } from '@angular/core';
/**
* Generated class for the OrderbyPipe pipe.
*
* See https://angular.io/api/core/Pipe for more info on Angular Pipes.
*/
@Pipe({
name: 'orderby',
pure: false
})
export class OrderbyPipe implements PipeTransform {
/**
* Takes a value and makes it lowercase.
*/
transform(array, orderBy, asc = true){
if (!orderBy || orderBy.trim() == ""){
return array;
}
//ascending
if (asc){
return Array.from(array).sort((item1: any, item2: any) => {
return this.orderByComparator(item1[orderBy], item2[orderBy]);
});
}
else{
//not asc
return Array.from(array).sort((item1: any, item2: any) => {
return this.orderByComparator(item2[orderBy], item1[orderBy]);
});
}
}
orderByComparator(a:any, b:any):number{
if((isNaN(parseFloat(a)) || !isFinite(a)) || (isNaN(parseFloat(b)) || !isFinite(b))){
//Isn't a number so lowercase the string to properly compare
if(a.toLowerCase() < b.toLowerCase()) return -1;
if(a.toLowerCase() > b.toLowerCase()) return 1;
}
else{
//Parse strings as numbers to compare properly
if(parseFloat(a) < parseFloat(b)) return -1;
if(parseFloat(a) > parseFloat(b)) return 1;
}
return 0; //equal each other
}
}
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class SubjectService {
private searchSubject = new BehaviorSubject<any>(null);
private docSubjects = new BehaviorSubject<any>(null);
private querySubjects = new BehaviorSubject<any>(null);
sendSearchData(searchData: any) {
this.searchSubject.next(searchData);
}
getSearchData(): Observable<any> {
return this.searchSubject.asObservable();
}
sendDocData(docData: any) {
this.docSubjects.next(docData);
}
getDocData(): Observable<any> {
return this.docSubjects.asObservable();
}
sendQueryData(queryData: any) {
this.querySubjects.next(queryData);
}
getQueryData(): Observable<any> {
return this.querySubjects.asObservable();
}
}
\ No newline at end of file
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