-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
131 lines (113 loc) · 4.4 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
* File: app.js
*
* This file was generated by Sencha Architect version 3.2.0.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Ext JS 4.2.x library, under independent license.
* License of Sencha Architect does not include license for Ext JS 4.2.x. For more
* details see http://www.sencha.com/license or contact [email protected].
*
* This file will be auto-generated each and everytime you save your project.
*
* Do NOT hand edit this file.
*/
// @require @packageOverrides
Ext.Loader.setConfig({
enabled: true,
paths: {
Ext: 'http://static.pinpointers.com/Lib/Sencha/ExtJS/4.2.1/src'
}
});
Ext.application({
requires: [
'Ext.Loader',
'Ext.window.MessageBox',
'Ext.layout.container.Border'
],
models: [
'LastReportedEvent'
],
stores: [
'LastReportedEvent',
'MapMarker'
],
views: [
'MainViewport',
'CurrentLocationsGrid',
'MapPanel'
],
controllers: [
'MapController'
],
name: 'LiveUpdates',
launch: function() {
Ext.create('LiveUpdates.view.MainViewport');
this.waitMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
this.waitMask.show();
this.initialSetup = true;
//First check for presence of a security token in the URL
//var securityToken = this.getSecurityToken();
//if(!Ext.isEmpty(securityToken)){
//Here we set an extra param to be passed in every request made on the LastReportedEventStore
var store = this.getLastReportedEventStore(), proxy;
proxy = store.getProxy();
proxy.setExtraParam('token', '44FF5FA1F9E644E7B82100000A0A00000004000000019ADF5DB313BE');
proxy.sortParam =null;
//store.on('load', this.storeloadhandler, this);
this.getSessionData(store);
//store.load();
//} else {
//this.waitMask.hide();
//Ext.Msg.show({
//title:'Missing Token?',
//msg: 'Your access token is missing, please ensure this is present in the address bar and try again.',
//closable: false,
//icon: Ext.Msg.ERROR
//});
//}
},
getSecurityToken: function() {
var queryStringObj = {};
if(window.location.href.indexOf('?')!==-1) {
queryStringObj = Ext.Object.fromQueryString(window.location.href.split("?")[1]);
}
return !Ext.isEmpty(queryStringObj.token) ? queryStringObj.token : null;
},
storeloadhandler: function(store, records, success) {
},
getSessionData: function(store) {
store.load({
scope: this,
addRecords: true,
callback: function(records, operation, success) {
if(success){
if(this.initialSetup) {
this.waitMask.hide();
this.initialSetup=false;
//Would not normally do carry out the line below.
//Normally the token is passed as an query string param in the Url.
delete store.getProxy().extraParams['token'];
this.fireEvent('initapp');
}
//Decode any nextUrl property in the response and use for the url on the next store.load() call
var response = Ext.decode(operation.response.responseText);
if(Ext.isDefined(response.nextURL)) {
store.getProxy().url = 'location' + response.nextURL;
}
//Buffer the next fetch of data after 10 seconds
Ext.Function.defer(function(){
this.getSessionData(store);
}, 10000, this);
} else {
//Error handling logic goes here...
}
}
});
},
getLastReportedEventHtml: function(record) {
var journeyStatusCls=(record.data.InJourney ? 'inJourney': 'outJourney'),
rowBody = '<div class="lastreportedeventrow"><b>'+record.get("EventDTDisplay")+'</b> - '+record.get("Location")+'</div>';
return '<div class = "unitname-header"><span class="journeystatusicon '+journeyStatusCls+'"></span></div><span class="unitname">' + record.get('UnitName') + '</span>' + rowBody;
}
});