Subversion Repository Public Repository

gpstest

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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%  
    String email=session.getAttribute("email").toString();  
    String password=session.getAttribute("password").toString();  
%>
<title>Nrusingh GPS</title>
<link href="css/main.css" rel="stylesheet" />
<link href="css/topmenu.css" rel="stylesheet" />

<script src="js/jquery.min.js"></script>
<!-- <script src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script> -->
<script src="js/jquery.canvasjs.min.js"></script>
<script>
var jsondata = [{"date":1506796200000,"units":1353},{"date":1506882600000,"units":1123},{"date":1506969000000,"units":1022},{"date":1507055400000,"units":1224},{"date":1507141800000,"units":1068},{"date":1507228200000,"units":1236},{"date":1507314600000,"units":1445},{"date":1507401000000,"units":1343},{"date":1507487400000,"units":1323},{"date":1507573800000,"units":1432},{"date":1507660200000,"units":1556},{"date":1507746600000,"units":1306},{"date":1507833000000,"units":1294},{"date":1507919400000,"units":1385},{"date":1508005800000,"units":1479},{"date":1508092200000,"units":1242},{"date":1508178600000,"units":1105},{"date":1508265000000,"units":1432},{"date":1508351400000,"units":1056},{"date":1508437800000,"units":1014},{"date":1508524200000,"units":932},{"date":1508610600000,"units":1278},{"date":1508697000000,"units":1456},{"date":1508783400000,"units":1524},{"date":1508869800000,"units":1109},{"date":1508956200000,"units":1124},{"date":1509042600000,"units":1085},{"date":1509129000000,"units":1330},{"date":1509215400000,"units":1223},{"date":1509301800000,"units":1323},{"date":1509388200000,"units":1423}]
$(function() {
	var device_url = 'http://23.92.61.79:8082/api/devices';
	var username = "admin";
	var password = "admin";
	$('#loader_map').hide();
	$('#loader_left').show('slow');
	$('#div_left_menu').hide('slow');
	$.ajax({
		type: 'get',
		url: device_url,
		headers: {
			"Accept": "application/json",         
			"Content-Type": "application/json",
			"Authorization": "Basic " + btoa(username + ":" + password)
		},
		'dataType': 'json',
		success: function (response) {
			//console.log('Success: '+JSON.stringify(response));
			$.each(response, function(k,v){
				var id = v.id;
				var name = v.name;
				var uniqueId = v.uniqueId;
				var status = v.status;
				
				var html = '';
				if(status == 'offline')
					html = "<option id='"+id+"^"+uniqueId+"^"+name+"^"+status+"' disabled>"+name+"</option> ";
				else
					html = "<option id='"+id+"^"+uniqueId+"^"+name+"^"+status+"'>"+name+"</option> ";
					
				$("#select_device_list").append(html);
			});
			$('#loader_left').hide();
			$('#div_left_menu').show();
		},
		error: function(response){
			console.log('Error: '+JSON.stringify(response));
			$('#loader_left').hide();
			$('#div_left_menu').show();
		}
	});
	
	$(document).on("click", "#btn_show_history", function(event) {
		$('#loader_map').show('slow');
		////$("#chartContainer").hide();
		//addData();
		//$('#loader_map').hide();
		
		
		var li_id = $("#select_device_list").children(":selected").attr("id");
		//alert($("#select_device_list").children(":selected").attr("id"));
      	var id = li_id.split('^')[0];
      	var uniqueId = li_id.split('^')[1];
      	var name = li_id.split('^')[2];
      	var status = li_id.split('^')[3];
      	
      	//var url = "http://23.92.61.79:8082/api/positions?deviceId="+id+"&from="+to+"&to="+from+"";
      	$.ajax({
			async:false,
			cache:false,
			dataType:"json",
			type: "get",  
			url: "http://23.92.61.79:8082/api/positions?deviceId=1&from=2018-05-23T09:00:00.000Z&to=2018-05-23T09:14:59.000Z",
			//url: url,
			//data:{id:id,uniqueId:uniqueId,name:name,status:status},
			headers: {
				"Accept": "application/json",         
				"Content-Type": "application/json",
				"Authorization": "Basic " + btoa(username + ":" + password)
			},
			'dataType': 'json',
			success: function (response) {
				var location_arr = [];
				var location_obj = {};
				$('#loader_map').hide();
				console.log('Success: '+JSON.stringify(response));
				addData();
				$('#loader_map').hide();
				//$("#chartContainer").show('slow')
				/*
				$.each(response, function(k,v){
					 var id = v.id;
					var deviceId = v.deviceId;
					var distance = v.attributes.distance;
					var motion = v.attributes.motion;
					var serverTime = v.serverTime;
					var latitude = v.latitude;
					var longitude = v.longitude;
					var altitude = v.altitude;
					var speed = v.speed;
					
					serverTime = ISO2Local_Date(serverTime);
					location_obj = {};
					
					location_obj["lat"]= latitude;
					location_obj["lon"]= longitude;
					location_obj["title"]= "Hello";
					location_obj["html"]= "Ji";
					if(k<=5)
						location_arr.push(location_obj); 
				});*/
			},
			error: function (response) {
				$('#loader_map').hide();
				console.log('Error: ');
				$('#div_data').html("");
				$('#div_data').html(JSON.stringify(response));
			}
		});
    });

	//-------------------------------------------------------
	var dataPoints = [];
	var options =  {
		animationEnabled: true,
		theme: "light2",
		title: {
			text: "Speed per Day"
		},
		axisX: {
			valueFormatString: "DD MMM YYYY",
		},
		axisY: {
			title: "speed",
			titleFontSize: 24,
			includeZero: false
		},
		data: [{
			type: "spline", 
			yValueFormatString: "$#,###.##",
			dataPoints: dataPoints
		}]
	};

	function addData() {
		for (var i = 0; i < jsondata.length; i++) {
			dataPoints.push({
				x: new Date(jsondata[i].date),
				y: jsondata[i].units
			});
		}
		$("#chartContainer").CanvasJSChart(options);
	
	}
	
});
</script>
</head>
<body>
	<div class="container">
		<!-- top panel -->
		<header>
		<div><img src="images/logo1.png" style="width: 100px;"></div>
		<div style="margin-top: -95px; margin-left: 180px;"><h1><a href="login" style="text-decoration: none;color: white;">NRUSiNGH GPS TRACKER</a></h1></div>
		
		<div style="float: right; margin-top: -40px;">
			<span style="font-weight: 900; text-transform: uppercase; vertical-align: 7px;"><%=session.getAttribute("email")%></span>
			<a href="logout"><img src="images/logout.png" alt="logout" style="width: 22px; margin-right: 15px;"/></a>
		</div>
		<jsp:include page="menu.jsp" />
		</header>
		<!-- top panel ends -->

		<!-- left panel -->
		<nav> 
			<div id="loader_left">
				<img id="loader_img_left" alt="Loding ..." src="images/loader.gif" />
			</div>
			<div id="div_left_menu">
				<table>
					<tr>
						<td>Devices</td>
						<td><select id="select_device_list" name="select_device_list"></select></td>
					</tr>
				
					<tr>
						<td></td>
						<td><input type="button" id="btn_show_history" value="SHOW" /></td>
					</tr>
				</table>
			</div>
		</nav>
		<!-- left panel ends -->

		<!-- right panel -->
		<article> <!-- <p><a href="map.jsp">Map</a></p> -->
			 <div id="div_map">
				<div id="loader_map" style="disply: none;">
					<img id="loader_img_map" alt="Loding ..." src="images/loader.gif" />
				</div>
				<div id="chartContainer" style="height: 300px; width: 100%;"></div>
			</div>
			
			
		</article>
		<!-- right panel ends -->

		<!-- buttom panel -->
		<footer><div style="text-align: center"> Copyright &copy; Nrusingha nath Nayak</div></footer>
		<!-- buttom panel ends -->
	</div>
</body>
</html>

Commits for gpstest/WebContent/_graph.jsp

Diff revisions: vs.
Revision Author Commited Message
1 lingaraj picture lingaraj Sat 24 Nov, 2018 13:04:59 +0000