Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
Callmycab-Driverapp
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kevin
Callmycab-Driverapp
Commits
082174de
Commit
082174de
authored
Jul 19, 2018
by
Alen Jose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
live location
parent
18e6946a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
14 deletions
+39
-14
app.component.ts
src/app/app.component.ts
+30
-10
home.ts
src/pages/home/home.ts
+5
-2
userlocation.ts
src/pages/userlocation/userlocation.ts
+4
-2
No files found.
src/app/app.component.ts
View file @
082174de
...
@@ -11,6 +11,7 @@ import { driver } from "../models/mymodel";
...
@@ -11,6 +11,7 @@ import { driver } from "../models/mymodel";
import
*
as
firebase
from
'firebase'
;
import
*
as
firebase
from
'firebase'
;
import
{
LocalNotifications
}
from
'@ionic-native/local-notifications'
;
import
{
LocalNotifications
}
from
'@ionic-native/local-notifications'
;
import
{
dataService
}
from
"../providers/common.service"
;
import
{
dataService
}
from
"../providers/common.service"
;
import
{
Geolocation
}
from
'@ionic-native/geolocation'
;
@
Component
({
@
Component
({
templateUrl
:
'app.html'
templateUrl
:
'app.html'
...
@@ -25,8 +26,9 @@ export class MyApp {
...
@@ -25,8 +26,9 @@ export class MyApp {
local
:
driver
local
:
driver
status
:
boolean
status
:
boolean
pushId
:
string
pushId
:
string
locSubs
:
any
;
constructor
(
public
platform
:
Platform
,
public
statusBar
:
StatusBar
,
public
splashScreen
:
SplashScreen
,
private
network
:
Network
,
private
alertCtrl
:
AlertController
,
private
oneSignal
:
OneSignal
,
private
locationAccuracy
:
LocationAccuracy
,
private
storage
:
Storage
,
private
myservice
:
Myservice
,
public
events
:
Events
,
private
localNotifications
:
LocalNotifications
,
private
data
:
dataService
)
{
constructor
(
public
platform
:
Platform
,
public
statusBar
:
StatusBar
,
public
splashScreen
:
SplashScreen
,
private
network
:
Network
,
private
alertCtrl
:
AlertController
,
private
oneSignal
:
OneSignal
,
private
locationAccuracy
:
LocationAccuracy
,
private
storage
:
Storage
,
private
myservice
:
Myservice
,
public
events
:
Events
,
private
localNotifications
:
LocalNotifications
,
private
data
:
dataService
,
private
geolocation
:
Geolocation
)
{
this
.
initializeApp
();
this
.
initializeApp
();
}
}
...
@@ -35,8 +37,8 @@ export class MyApp {
...
@@ -35,8 +37,8 @@ export class MyApp {
this
.
platform
.
ready
().
then
(()
=>
{
this
.
platform
.
ready
().
then
(()
=>
{
this
.
statusBar
.
styleLightContent
();
this
.
statusBar
.
styleLightContent
();
this
.
initOnesignal
();
//
this.initOnesignal();
this
.
enableLoc
()
//
this.enableLoc()
this
.
network
.
onDisconnect
().
subscribe
(()
=>
{
this
.
network
.
onDisconnect
().
subscribe
(()
=>
{
const
alert
=
this
.
alertCtrl
.
create
({
const
alert
=
this
.
alertCtrl
.
create
({
...
@@ -66,6 +68,14 @@ export class MyApp {
...
@@ -66,6 +68,14 @@ export class MyApp {
}
}
})
})
this
.
events
.
subscribe
(
'driver:locOff'
,
_
=>
{
this
.
locSubs
.
unsubscribe
();
})
this
.
events
.
subscribe
(
'driver:locOn'
,
_
=>
{
this
.
liveLoc
();
})
this
.
storage
.
get
(
'driver_data'
).
then
(
data
=>
{
this
.
storage
.
get
(
'driver_data'
).
then
(
data
=>
{
if
(
data
!=
null
)
{
if
(
data
!=
null
)
{
this
.
local
=
data
this
.
local
=
data
...
@@ -90,12 +100,13 @@ export class MyApp {
...
@@ -90,12 +100,13 @@ export class MyApp {
}
}
checkStatus
()
{
checkStatus
()
{
this
.
oneSignal
.
getIds
().
then
((
id
)
=>
{
// this.oneSignal.getIds().then((id) => {
console
.
log
(
id
.
userId
)
// console.log(id.userId)
this
.
myservice
.
load_post
({
deviceid
:
id
.
userId
,
driverid
:
this
.
local
.
id
},
'updateDeviceid'
).
subscribe
(
resp
=>
{
// this.myservice.load_post({deviceid:id.userId,driverid:this.local.id},'updateDeviceid').subscribe(resp=>{
console
.
log
(
resp
)
// console.log(resp)
})
// })
})
// })
console
.
log
(
this
.
local
)
var
This
=
this
var
This
=
this
var
query
=
firebase
.
database
().
ref
(
"drivers/"
).
orderByChild
(
"id"
).
equalTo
((
this
.
local
.
id
))
var
query
=
firebase
.
database
().
ref
(
"drivers/"
).
orderByChild
(
"id"
).
equalTo
((
this
.
local
.
id
))
query
.
once
(
"child_added"
,
function
(
snapshot
)
{
query
.
once
(
"child_added"
,
function
(
snapshot
)
{
...
@@ -122,7 +133,7 @@ export class MyApp {
...
@@ -122,7 +133,7 @@ export class MyApp {
}
}
})
})
},
20000
)
},
20000
)
This
.
setlocalNotification
();
//
This.setlocalNotification();
}
}
openPage
(
page
)
{
openPage
(
page
)
{
...
@@ -202,4 +213,13 @@ export class MyApp {
...
@@ -202,4 +213,13 @@ export class MyApp {
})
})
}
}
liveLoc
(){
this
.
locSubs
=
this
.
geolocation
.
watchPosition
().
filter
((
p
)
=>
p
.
coords
!==
undefined
)
//Filter Out Errors
.
subscribe
(
position
=>
{
firebase
.
database
().
ref
(
"drivers/"
+
this
.
pushId
+
"/"
).
update
({
lat
:
Number
(
position
.
coords
.
latitude
),
lng
:
Number
(
position
.
coords
.
longitude
)
})
// firebase.database().ref("drivers/" + this.pushId + "/").update({
// lat: 10.014907, lng: 76.363020})
})
}
}
}
src/pages/home/home.ts
View file @
082174de
import
{
Component
}
from
'@angular/core'
;
import
{
Component
}
from
'@angular/core'
;
import
{
IonicPage
,
NavController
,
NavParams
}
from
'ionic-angular'
;
import
{
IonicPage
,
NavController
,
NavParams
,
Events
}
from
'ionic-angular'
;
import
{
Storage
}
from
"@ionic/storage"
;
import
{
Storage
}
from
"@ionic/storage"
;
import
{
Myservice
}
from
"../../providers/myservice"
;
import
{
Myservice
}
from
"../../providers/myservice"
;
import
{
dataService
}
from
"../../providers/common.service"
;
import
{
dataService
}
from
"../../providers/common.service"
;
...
@@ -15,10 +15,13 @@ upcoming:any;
...
@@ -15,10 +15,13 @@ upcoming:any;
completed
:
any
;
completed
:
any
;
baseurl
=
this
.
myservice
.
base_url
baseurl
=
this
.
myservice
.
base_url
constructor
(
public
navCtrl
:
NavController
,
public
navParams
:
NavParams
,
private
storage
:
Storage
,
private
myservice
:
Myservice
,
private
data
:
dataService
)
{
constructor
(
public
navCtrl
:
NavController
,
public
navParams
:
NavParams
,
private
storage
:
Storage
,
private
myservice
:
Myservice
,
private
data
:
dataService
,
public
events
:
Events
)
{
}
}
ionViewDidEnter
(){
ionViewDidEnter
(){
this
.
events
.
publish
(
'driver:locOn'
,
''
);
if
(
this
.
navParams
.
get
(
'id'
))
if
(
this
.
navParams
.
get
(
'id'
))
this
.
navCtrl
.
push
(
'QuickridePage'
,
{
id
:
this
.
navParams
.
get
(
'id'
),
from
:
this
.
navParams
.
get
(
'from'
)
})
this
.
navCtrl
.
push
(
'QuickridePage'
,
{
id
:
this
.
navParams
.
get
(
'id'
),
from
:
this
.
navParams
.
get
(
'from'
)
})
...
...
src/pages/userlocation/userlocation.ts
View file @
082174de
import
{
Component
,
ViewChild
,
ElementRef
}
from
'@angular/core'
;
import
{
Component
,
ViewChild
,
ElementRef
}
from
'@angular/core'
;
import
{
IonicPage
,
NavController
,
NavParams
,
MenuController
}
from
'ionic-angular'
;
import
{
IonicPage
,
NavController
,
NavParams
,
MenuController
,
Events
}
from
'ionic-angular'
;
import
{
Geolocation
}
from
'@ionic-native/geolocation'
;
import
{
Geolocation
}
from
'@ionic-native/geolocation'
;
import
*
as
firebase
from
'firebase'
;
import
*
as
firebase
from
'firebase'
;
import
{
AngularFireDatabase
}
from
'angularfire2/database'
;
import
{
AngularFireDatabase
}
from
'angularfire2/database'
;
...
@@ -31,12 +31,14 @@ export class UserlocationPage {
...
@@ -31,12 +31,14 @@ export class UserlocationPage {
waypoints
=
[]
waypoints
=
[]
ride
:
any
;
ride
:
any
;
constructor
(
public
navCtrl
:
NavController
,
public
navParams
:
NavParams
,
private
geolocation
:
Geolocation
,
private
db
:
AngularFireDatabase
,
private
storage
:
Storage
,
private
myservice
:
Myservice
,
private
menu
:
MenuController
,
private
data
:
dataService
)
{
constructor
(
public
navCtrl
:
NavController
,
public
navParams
:
NavParams
,
private
geolocation
:
Geolocation
,
private
db
:
AngularFireDatabase
,
private
storage
:
Storage
,
private
myservice
:
Myservice
,
private
menu
:
MenuController
,
private
data
:
dataService
,
public
events
:
Events
)
{
this
.
loadMap
()
this
.
loadMap
()
}
}
ionViewDidEnter
()
{
ionViewDidEnter
()
{
this
.
events
.
publish
(
'driver:locOff'
,
''
);
this
.
menu
.
swipeEnable
(
false
);
this
.
menu
.
swipeEnable
(
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment