You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1872 lines
60 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
12 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var map = null;
  3. var selectedMarker = null;
  4. var timelineObj = null;
  5. var rep_selectedEventId = 0;
  6. var rep_selectedDateTS = 0;
  7. var rep_selectedStation = 0;
  8. var rep_selectedEvtTS = 0;
  9. // Calendar
  10. var CurrentDate=(new Date())/1000;
  11. var today=new Date();
  12. var SY=1900+today.getYear();
  13. var SMO=today.getMonth()+1;
  14. var SD=today.getDate();
  15. var SelectedDay = SD;
  16. var Dates = new Array();
  17. function CheckDate(D){
  18. for(j_index=0;j_index<Dates.length;j_index++){
  19. if (Dates[j_index]==D)return true;
  20. };
  21. return false;
  22. };
  23. function ShiftBAK(){
  24. CurrentDate=CurrentDate-24*3600*GetMonthLength(CurrentDate);
  25. BuildCalendar();
  26. SMO = GetMonthNum(CurrentDate);
  27. SY = GetYear(CurrentDate);
  28. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  29. loadCalendarDates();
  30. };
  31. function ShiftFWD(){
  32. CurrentDate=CurrentDate+24*3600*GetMonthLength(CurrentDate);
  33. BuildCalendar();
  34. SMO = GetMonthNum(CurrentDate);
  35. SY = GetYear(CurrentDate);
  36. if( SD > GetMonthLength(CurrentDate) ) SD = GetMonthLength(CurrentDate);
  37. loadCalendarDates();
  38. };
  39. function GetMonthName(UTS){ // Unix Time Stamp
  40. var MoNames= new Array();
  41. MoNames[0]='January';
  42. MoNames[1]='February';
  43. MoNames[2]='March';
  44. MoNames[3]='April';
  45. MoNames[4]='May';
  46. MoNames[5]='June';
  47. MoNames[6]='July';
  48. MoNames[7]='August';
  49. MoNames[8]='September';
  50. MoNames[9]='October';
  51. MoNames[10]='November';
  52. MoNames[11]='December';
  53. CDate=new Date();
  54. CDate.setTime(UTS*1000);
  55. CMo=CDate.getMonth();
  56. return MoNames[CMo];
  57. };
  58. function GetMonthShift(UTS){ // Unix Time Stamp
  59. CDate=new Date();
  60. CDate.setTime(UTS*1000);
  61. CDate.setTime((UTS-(CDate.getDate()-1)*86400)*1000);
  62. return CDate.getDay();
  63. };
  64. function GetMonthLength(UTS){ // Unix Time Stamp
  65. CDate=new Date();
  66. CDate.setTime(UTS*1000);
  67. CD=CDate.getDate();
  68. RetVal=31;
  69. CDate.setTime((UTS+(31-CD)*86400)*1000);
  70. if ( CDate.getDate()==31) return RetVal;
  71. RetVal=30;
  72. CDate.setTime((UTS+(30-CD)*86400)*1000);
  73. if ( CDate.getDate()==30) return RetVal;
  74. RetVal=29;
  75. CDate.setTime((UTS+(29-CD)*86400)*1000);
  76. if ( CDate.getDate()==29) return RetVal;
  77. RetVal=28;
  78. CDate.setTime((UTS+(28-CD)*86400)*1000);
  79. if ( CDate.getDate()==28) return RetVal;
  80. return -1;
  81. };
  82. function GetMonthNum(UTS){ // Unix Time Stamp
  83. CDate=new Date();
  84. CDate.setTime(UTS*1000);
  85. return CDate.getMonth()+1;
  86. };
  87. function GetYear(UTS){ // Unix Time Stamp
  88. CDate=new Date();
  89. CDate.setTime(UTS*1000);
  90. y=CDate.getYear();
  91. if (y<100)y+=2000;
  92. if (y<200)y+=1900;
  93. return y;
  94. };
  95. function GetDay(UTS){ // Unix Time Stamp
  96. CDate=new Date();
  97. CDate.setTime(UTS*1000);
  98. y=CDate.getDate();
  99. return y;
  100. };
  101. function selectDate( m, d ){
  102. SY = GetYear(CurrentDate);
  103. SMO = m;
  104. SD = d;
  105. SelectedDay = SD;
  106. getData( 'arch' );
  107. };
  108. function BuildCalendar( ){
  109. Msh=GetMonthShift(CurrentDate);
  110. Mnm=GetMonthName(CurrentDate);
  111. Mln=GetMonthLength(CurrentDate);
  112. Mid=GetMonthNum(CurrentDate);
  113. Mye=GetYear(CurrentDate);
  114. InDTA='<table cellpadding="2" cellspacing="0"><tr height="19px"><td valign="middle"><a href="#" onclick="ShiftBAK();"><img src="/style/img/calendar/l_cal_b.gif"></a></td><td colspan="5" class="CalendarMN" align="center">'+Mnm+' '+Mye+'</td><td><a href="#" onclick="ShiftFWD();"><img border=0 src="/style/img/calendar/r_cal_b.gif"></a></td></tr>';
  115. InDTA+='<tr><td class="CalendarWT" align="center">Su</td><td class="CalendarWT" align="center">Mo</td><td class="CalendarWT" align="center">Tu</td><td class="CalendarWT" align="center">We</td><td class="CalendarWT" align="center">Th</td><td class="CalendarWT" align="center">Fr</td><td class="CalendarWT" align="center">Sa</td></tr>';
  116. InDTA+='<tr>';
  117. for(index=0;index<Msh;index++){
  118. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  119. };
  120. for(;index<(Mln+Msh);index++){
  121. if( CheckDate(index-Msh+1) ){
  122. //InDTA+='<td style="padding: 1px"><div id="ds'+Mid.toString()+(index-Msh+1).toString()+'" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" href="#" title="'+(index-Msh+1).toString()+'" class="CalendarDE">'+(index-Msh+1).toString()+'</a></td>';
  123. if( SD == index ){
  124. InDTA+='<td style="padding: 1px"><div id="selected_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Selected" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
  125. } else {
  126. InDTA+='<td style="padding: 1px"><div id="have_data_day" onclick="selectDate('+Mid.toString()+','+(index-Msh+1).toString()+');" title="Have Events" class="calendar_t">'+(index-Msh+1).toString()+'</div></td>';
  127. };
  128. } else {
  129. if( SD == index ){
  130. InDTA+='<td style="padding: 1px"><div id="selected_day" class="calendar_t" title="Selected">'+(index-Msh+1).toString()+'</a></td>';
  131. } else {
  132. InDTA+='<td style="padding: 1px"><div id="no_data_day" class="calendar_t" title="No Events">'+(index-Msh+1).toString()+'</a></td>';
  133. };
  134. };
  135. if ((index+1)%7==0){
  136. InDTA+='</tr><tr>';
  137. };
  138. };
  139. for(;(index)%7!=0;index++){
  140. InDTA+='<td style="padding: 1px"><div id="disabled" class="calendar_t">&nbsp;</div></td>';
  141. };
  142. InDTA+='</tr></table>';
  143. tab=document.getElementById('calendar_TD');
  144. tab.innerHTML=InDTA;
  145. };
  146. function loadCalendarDates(){
  147. Ext.MessageBox.wait("<?=$Labels->GetLabel('_Loading_Calo_');?>","<?=$Labels->GetLabel('_Please_Wait_');?>",{
  148. width: '100%',
  149. hidden: true,
  150. progress: true,
  151. closable: false
  152. });
  153. Ext.Ajax.request({
  154. url: '/lib/controller/getEventDates.php',
  155. params: {
  156. NID: selecredActiveSourceFilter,
  157. UID: <?=$UserID;?>,
  158. SID: '<?=$Session;?>',
  159. SYE: SY,
  160. SMO: SMO
  161. },
  162. success: function( response, opts ){
  163. Ext.MessageBox.hide();
  164. var data = Ext.decode( response.responseText );
  165. if( data.status == 'ok' ){
  166. Dates = data.days;
  167. BuildCalendar();
  168. //for( var i = 0; i < data.days.length; i++ ){
  169. //
  170. //};
  171. };
  172. },
  173. failure: function( response, opts ) {
  174. Ext.MessageBox.hide();
  175. }
  176. });
  177. };
  178. var eventsListStore = new Ext.data.JsonStore({
  179. root: 'log',
  180. totalProperty: 'totalCount',
  181. idProperty: 'id',
  182. remoteSort: true,
  183. fields: [{
  184. name: 'id',
  185. type: 'int'
  186. },{
  187. name: 'date',
  188. type: 'string'
  189. },{
  190. name: 'time',
  191. type: 'string'
  192. },{
  193. name: 'device',
  194. type: 'string'
  195. },{
  196. name: 'event',
  197. type: 'int'
  198. },{
  199. name: 'data',
  200. type: 'string',
  201. },{
  202. name: 'has_target',
  203. type: 'boolean'
  204. },{
  205. name: 'has_geo',
  206. type: 'boolean'
  207. },{
  208. name: 'has_images',
  209. type: 'boolean'
  210. },{
  211. name: 'images',
  212. type: 'Array'
  213. },{
  214. name: 'dev_type',
  215. type: 'int'
  216. },{
  217. name: 'geo',
  218. type: 'object'
  219. }] /*,
  220. proxy : new Ext.data.HttpProxy({
  221. method: 'POST',
  222. prettyUrls: false,
  223. url: '/lib/controller/getEventRecords.php',
  224. headers: {
  225. UID: <?=$UserID;?>,
  226. SID: '<?=$Session;?>',
  227. NID: 1
  228. }
  229. })*/
  230. });
  231. var EventPanelWindow = null;
  232. function showEventPanel(){
  233. if( EventPanelWindow == null ){
  234. EventPanelWindow = new Ext.Window({
  235. modal: true,
  236. title: '<?=$Labels->GetLabel("_EVENT_VIEWER_");?>',
  237. width: winW*0.66,
  238. height: winH*0.66,
  239. layout: 'fit',
  240. closeAction: 'hide',
  241. items:[{
  242. title: 'Cameras',
  243. html:'koko',
  244. autoScroll: true,
  245. height: 320
  246. },{
  247. html: 'koko22',
  248. height: 320
  249. }]
  250. });
  251. };
  252. EventPanelWindow .show();
  253. };
  254. function ModeRenderer(val){
  255. var p1, p2, p3;
  256. if( ( val & 1 ) == 1 ){
  257. p1 = '<img src="/style/img/cam_cap3.png" alt="Video Source">';
  258. } else {
  259. p1 = '<img src="/style/img/cam_cap0.png" alt="NO Video Source">';
  260. };
  261. if( ( val & 2 ) == 2 ){
  262. p2 = '<img src="/style/img/cam_cap2.png" alt="Audio Source">';
  263. } else {
  264. p2 = '<img src="/style/img/cam_cap0.png" alt="NO Audio Source">';
  265. };
  266. if( ( val & 4 ) == 4 ){
  267. p3 = '<img src="/style/img/cam_cap1.png" alt="PTZ Control">';
  268. } else {
  269. p3 = '<img src="/style/img/cam_cap0.png" alt="NO PTZ Control">';
  270. };
  271. return p1+p2+p3;
  272. };
  273. function LocRenderer( val ){
  274. if( val ){
  275. return '<img src="/style/icons/icons/accept.png" alt="Location" />';
  276. };
  277. return '<img src="/style/icons/icons/bullet_white.png" alt="NO Location" />';
  278. };
  279. function PicRenderer( val ){
  280. if( val ){
  281. return '<img src="/style/icons/icons/camera_link.png"/>';
  282. };
  283. return '<img src="/style/icons/icons/bullet_white.png"/>';
  284. };
  285. function EvtTypeRenderer( val ){
  286. switch( val ){
  287. case 6: return 'Device Enters Into Study Mode';
  288. case 7: return 'Device Is BUSY';
  289. case 8: return 'Flip Complete';
  290. case 9: return 'Scan Complete';
  291. case 10:
  292. case 11:
  293. case 12:
  294. case 13:
  295. case 14: return 'Target';
  296. case 36: return 'Region Of Interest';
  297. default: return 'Event ['+val+']';
  298. };
  299. };
  300. var eventsListColModel_ops = {
  301. columns: [
  302. {header: "ID", width: 100, sortable: false, menuDisabled: true, align: 'center', fixed: true, css: 'vertical-align: middle;', dataIndex: 'id' },
  303. {header: "Date",width: 100, sortable: false, fixed: true, menuDisabled: true, /*renderer: camCapRenderer,*/ dataIndex: 'date' },
  304. {header: "Time", width: 80, sortable: false, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'time' },
  305. {header: "Device", width: 80, sortable: false, fixed: true, menuDisabled: true, align: 'left', css: 'vertical-align: middle;', dataIndex: 'device' },
  306. {header: "Event", width: 120, sortable: false, dataIndex: 'event', renderer: EvtTypeRenderer },
  307. {header: "Info", width: 200, sortable: false, dataindex: 'data' },
  308. {header: "", width: 25, sortable: false, dataIndex: 'has_geo', renderer: LocRenderer },
  309. {header: "", width: 25, sortable: false, dataIndex: 'has_images', renderer: PicRenderer }
  310. ],
  311. defaults: {
  312. sortable: true,
  313. menuDisabled: true,
  314. width: 100
  315. },
  316. listeners: {
  317. hiddenchange: function(cm, colIndex, hidden) {
  318. //saveConfig(colIndex, hidden);
  319. }
  320. }
  321. };
  322. var SelectedRow = -1;
  323. var eventsListSelModel_ops = {
  324. singleSelect: true,
  325. listeners: {
  326. rowselect: function(sm, row, rec ) {
  327. loadEventProperties( rec.data );
  328. SelectedEvent = rec.data.id;
  329. SelectedRow = row;
  330. //alert( SelectedEvent );
  331. //var CB = Ext.getCmp('con_to_src');
  332. //CB.enable();
  333. }
  334. }
  335. };
  336. function loadTimeLineGroups( NID ){
  337. Ext.Ajax.request({
  338. url: '/lib/controller/getTimeLineGroups.php',
  339. params: {
  340. NID: NID,
  341. UID: <?=$UserID;?>,
  342. SID: '<?=$Session;?>'
  343. },
  344. success: function( response, opts ){
  345. // If the response is JSON, you have to decode it
  346. var data = Ext.decode(response.responseText);
  347. //for(var i = 0; i < data.length; i++) {
  348. //tlGroups.add(data[i]);
  349. //};
  350. tlGroups.update( data );
  351. loadTimeLineItems( SelectedSite );
  352. tlInterval = window.setInterval( loadTimeLineItems, 333, SelectedSite );
  353. },
  354. failure: function( response, opts ) {
  355. //Ext.fly('some_div').update('Fail!');
  356. }/*,
  357. callback: function(options,success,response){
  358. // use this if you need to perform your own success/failure checking
  359. }*/
  360. });
  361. };
  362. function clickDeviceSelector( id ){
  363. var rr = document.getElementById(id+'_div');
  364. if( selecredActiveSourceFilter != id ){
  365. if( selecredActiveSourceFilter > 0 ){
  366. var oo = document.getElementById( selecredActiveSourceFilter + '_div');
  367. oo.classList.remove( "cardDeviceSourceSelected" );
  368. oo.classList.add( "cardDeviceSource" );
  369. };
  370. rr.classList.remove( "cardDeviceSource" );
  371. rr.classList.add( "cardDeviceSourceSelected" );
  372. selecredActiveSourceFilter = id;
  373. turnOffAllGzButThis( selecredActiveSourceFilter );
  374. } else {
  375. selecredActiveSourceFilter = 0;
  376. rr.classList.remove( "cardDeviceSourceSelected" );
  377. rr.classList.add( "cardDeviceSource" );
  378. turnAllGzOn();
  379. var tPanel = Ext.getCmp('prop_content');
  380. tPanel.remove(0);
  381. tPanel.add( {
  382. title: 'Event Information',
  383. border: false,
  384. frame: false,
  385. collapsible: false,
  386. draggable: false,
  387. html: '<p align="center">Select an Event from TimeLine to See Information</p>'
  388. } );
  389. tPanel.doLayout();
  390. };
  391. };
  392. function getZoneByNode( nid ){
  393. var rVal = -1;
  394. for( var i=0; i < ActiveZones.totalCount; i++ ){
  395. if( ActiveZones.zones[i].dev_id == nid ){
  396. rVal = i;
  397. break;
  398. };
  399. };
  400. return rVal;
  401. };
  402. function turnOffAllGzButThis( nid ){
  403. var chocho = -1;
  404. for( var i=0; i < ActiveZones.totalCount; i++ ){
  405. if( ActiveZones.zones[i].dev_id == nid ) chocho = i;
  406. map.removeLayer( ActiveZones.fig[i] );
  407. map.removeLayer( ActiveZones.zang[i] );
  408. map.removeLayer( ActiveZones.center[i] );
  409. };
  410. if( chocho > -1 ){
  411. map.addLayer( ActiveZones.fig[chocho] );
  412. map.addLayer( ActiveZones.zang[chocho] );
  413. map.addLayer( ActiveZones.center[chocho] );
  414. var cVisible = L.featureGroup( Array( ActiveZones.fig[chocho], ActiveZones.zang[chocho], ActiveZones.center[chocho] ) );
  415. map.flyToBounds( cVisible.getBounds() );
  416. };
  417. };
  418. function turnAllGzOn(){
  419. var tall = Array();
  420. for( var i=0; i < ActiveZones.totalCount; i++ ){
  421. tall[i*3] = ActiveZones.fig[i];
  422. tall[i*3+1] = ActiveZones.zang[i];
  423. tall[i*3+2] = ActiveZones.center[i];
  424. if(!map.hasLayer(ActiveZones.fig[i])) map.addLayer( ActiveZones.fig[i] );
  425. if(!map.hasLayer(ActiveZones.zang[i])) map.addLayer( ActiveZones.zang[i] );
  426. if(!map.hasLayer(ActiveZones.center[i])) map.addLayer( ActiveZones.center[i] );
  427. };
  428. var cVisible = L.featureGroup( tall );
  429. map.flyToBounds( cVisible.getBounds() );
  430. };
  431. function loadMapZones( SID ){
  432. Ext.Ajax.request({
  433. url: '/lib/controller/getGeoZones.php',
  434. params: {
  435. SITE: SID,
  436. UID: <?=$UserID;?>,
  437. SID: '<?=$Session;?>'
  438. },
  439. success: function( response, opts ){
  440. // If the response is JSON, you have to decode it
  441. var data = Ext.decode(response.responseText);
  442. var pp = Ext.getCmp('sources_panel');
  443. if( typeof pp !== 'undefined' ) pp.removeAll();
  444. ActiveZones = data;
  445. ActiveZones.fig = new Array();
  446. ActiveZones.zang = new Array();
  447. ActiveZones.center = new Array();
  448. for(var i = 0; i < data.totalCount; i++ ) {
  449. switch( data.zones[i].type ){
  450. case 'circle':{
  451. //L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } ).addTo( map );
  452. ActiveZones.fig[i] = new L.circle( data.zones[i].center, {radius: data.zones[i].radius, color: data.zones[i].color, weight: 1, opacity: 0.8 } );
  453. //map.addLayer( ActiveZones.fig[i] );
  454. break;
  455. };
  456. case 'poly':{
  457. ActiveZones.fig[i] = new L.polygon( data.zones[i].points, {color: data.zones[i].color, dashArray: "4 1 2 3", weight: 1, opacity: 0.8, clickable: false, interactive: false, bubblingMouseEvents: false });//.addTo(map);
  458. //map.addLayer( ActiveZones.fig[i] );
  459. break;
  460. };
  461. case 'image':{
  462. ActiveZones.fig[i] = L.imageOverlay( data.zones[i].url, data.zones[i].bounds, { opacity: 1.0 });//.addTo( map );
  463. //map.addLayer( ActiveZones.fig[i] );
  464. break;
  465. };
  466. case 'image_rot':{
  467. ActiveZones.fig[i] = L.imageOverlay.rotated( data.zones[i].url, data.zones[i].topleft, data.zones[i].topright, data.zones[i].bottomleft, {
  468. opacity: 0.8 //,
  469. //interactive: true,
  470. //attribution: "Historical building plan &copy; <a href='http://www.ign.es'>Instituto Geográfico Nacional de España</a>"
  471. });//.addTo( map );
  472. //map.addLayer( ActiveZones.fig[i] );
  473. break;
  474. };
  475. };
  476. if( data.zones[i].dev_is_source ){
  477. if( typeof pp !== 'undefined' ) {
  478. var sty = '';
  479. if( selecredActiveSourceFilter == data.zones[i].dev_id ){
  480. sty = 'cardDeviceSourceSelected';
  481. } else {
  482. sty = 'cardDeviceSource';
  483. };
  484. pp.add( {
  485. id: data.zones[i].dev_id+'_container',
  486. frame: false,
  487. border: false,
  488. width: 130,
  489. height: 130,
  490. html: '<div id="'+data.zones[i].dev_id+'_div" class="'+sty+'" onclick="clickDeviceSelector('+data.zones[i].dev_id+');"><img id="'+data.zones[i].dev_id+'_ind" width="16px" src="/style/assets/led_green_blink_300ms.gif"><center><img src="/style/assets/'+data.zones[i].dev_type+'_node.png"><br/><p class="dev_name">'+data.zones[i].dev_name+'</p></center></div>'
  491. });
  492. };
  493. };
  494. if( data.zones[i].zang != undefined ){
  495. //L.polygon( data.zones[i].zang, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  496. ActiveZones.zang[i] = L.circle( data.zones[i].zang, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } );//.addTo( map );
  497. };
  498. if( data.zones[i].center != undefined ){
  499. //L.polygon( data.zones[i].zmark, {color: '#ffff00', weight: 1, opacity: 1.0, clickable: false, interactive: false, bubblingMouseEvents: false }).addTo(map);
  500. ActiveZones.center[i] = L.circle( data.zones[i].center, {radius: 0.3, color: '#ffff00', weight: 1, opacity: 1.0, fillOpacity: 1.0 } ).addTo( map );
  501. };
  502. };
  503. if( selecredActiveSourceFilter == 0 ){
  504. turnAllGzOn();
  505. } else {
  506. turnOffAllGzButThis( selecredActiveSourceFilter );
  507. };
  508. if( typeof pp !== 'undefined' ) pp.doLayout();
  509. //LoadMapEvents( SelectedSite );
  510. //tlInterval = window.setInterval( LoadMapEvents, 333, SelectedSite );
  511. },
  512. failure: function( response, opts ) {
  513. //Ext.fly('some_div').update('Fail!');
  514. }
  515. });
  516. };
  517. var cevt = Array();
  518. var coz = Array();
  519. function showEventsOnMap( data, removeCursor = true ){
  520. if( removeCursor ) map.removeLayer( selectedMarker );
  521. if( cevt.length ){
  522. for( i=0; i< cevt.length; i++ ){
  523. if( cevt[i]!= null ){
  524. cevt[i].remove();
  525. delete( cevt[i] );
  526. cevt[i] = null;
  527. };
  528. };
  529. };
  530. if( coz.length ){
  531. for( i=0; i< coz.length; i++ ){
  532. if( coz[i]!= null ){
  533. coz[i].remove();
  534. delete( coz[i] );
  535. coz[i]=null;
  536. };
  537. };
  538. };
  539. var zz = ( 1.0 / ( data.log.length + 0 ) );
  540. var idx = 0;
  541. for( i=0; i < data.log.length; i++ ){
  542. if( data.log[i].has_geo ){
  543. var cp_color='#FF0000';
  544. switch( data.log[i].event ){
  545. case 36: cp_color='#0000FF'; break;
  546. };
  547. cevt[idx] = L.circleMarker( [data.log[i].geo.lat, data.log[i].geo.lon], {id:data.log[i].id, color: cp_color, radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  548. loadEventPropertiesByID( this.options.id );
  549. } );
  550. cevt[idx].addTo(map);
  551. idx++;
  552. };
  553. };
  554. };
  555. function LoadMapEventsZ( Mode ){
  556. if( tlLoadLocker ) return;
  557. tlLoadLocker = true;
  558. Ext.Ajax.request({
  559. url: '/lib/controller/getGeoAlerts.php',
  560. params: {
  561. SITE: <?=$SiteID;?>,
  562. UID: <?=$UserID;?>,
  563. SID: '<?=$Session;?>',
  564. MODE: Mode
  565. },
  566. success: function( response, opts ){
  567. if( cevt.length ){
  568. for( i=0; i< cevt.length; i++ ){
  569. if( cevt[i]!= null ){
  570. cevt[i].remove();
  571. delete( cevt[i] );
  572. cevt[i] = null;
  573. };
  574. };
  575. };
  576. if( coz.length ){
  577. for( i=0; i< coz.length; i++ ){
  578. if( coz[i]!= null ){
  579. coz[i].remove();
  580. delete( coz[i] );
  581. coz[i]=null;
  582. };
  583. };
  584. };
  585. var data = Ext.decode( response.responseText );
  586. var zz = ( 1.0 / ( data.evt.length + 0 ) );
  587. for( i=0; i < data.evt.length; i++ ){
  588. cevt[i] = L.circleMarker( [data.evt[i].lat,data.evt[i].lon], {id:data.evt[i].id, color: '#FF0000', radius: 5, stroke: false, fillOpacity: ( 1.0 - i * zz ) } ).on('click', function( e, a ){
  589. loadEventProperties( this.options.id );
  590. } );
  591. cevt[i].addTo(map);
  592. };
  593. for( i=0; i < data.other.length; i++ ){
  594. switch( data.other[i].type ){
  595. case 'circle':{
  596. coz[i] = L.circleMarker( data.other[i].loc, {id:data.other[i].id, color: data.other[i].color, radius: 5, stroke: false, fillOpacity: 1.0 } );
  597. coz[i].addTo(map);
  598. break;
  599. };
  600. };
  601. };
  602. //eventsListStore.reload();
  603. tlLoadLocker = false;
  604. },
  605. failure: function( response, opts ) {
  606. //Ext.fly('some_div').update('Fail!');
  607. tlLoadLocker = false;
  608. }
  609. });
  610. };
  611. function loadEventPropertiesByID( id ){
  612. var d = eventsListStore.findExact( 'id', id );
  613. if( d > -1 ) {
  614. var EventRec = eventsListStore.getAt( d );
  615. loadEventProperties( EventRec.data );
  616. };
  617. };
  618. function loadEventProperties( EventRec ){
  619. var tPanel = Ext.getCmp('prop_content');
  620. tPanel.removeAll();// remove( 0 );
  621. var tt = '';
  622. if( selectedMarker!= null ){
  623. selectedMarker.remove();
  624. //map.removeLayer( selectedMarker );
  625. if( EventRec.has_geo ){
  626. tt = ''+EventRec.geo.lat+' '+EventRec.geo.lon;
  627. selectedMarker.setLatLng([EventRec.geo.lat, EventRec.geo.lon]);
  628. selectedMarker.addTo( map );
  629. };
  630. };
  631. tPanel.add( {
  632. title: 'Event Details',
  633. html: '<center><img src="/style/assets/'+EventRec.dev_type+'_node.png" /><p>' + EventRec.device+'</p>'+tt+'</center>'
  634. } );
  635. if( EventRec.has_images ){
  636. for( var i=0; i < EventRec.images.length; i++ ){
  637. tPanel.add( {
  638. frame: false,
  639. html: '<img width="100%" src="/lib/controller/getPicture.php?PID='+EventRec.images[i]+'" data-enlargeable000 ondblclick="fullScreen(\'img-'+EventRec.id+'\');" style="cursor: zoom-in" id="img-'+EventRec.id+'"/>'
  640. });
  641. };
  642. };
  643. tPanel.doLayout();
  644. };
  645. function getData( Mode, ST = 0, ET = 0, SR = 0, DR = 0 ){
  646. if( tlLoadLocker ) return;
  647. tlLoadLocker = true;
  648. if( Mode == 'arch' ){
  649. Ext.MessageBox.wait("Loading Data","Please Wait",{
  650. width: '100%',
  651. hidden: true,
  652. animate: true,
  653. progress: true,
  654. closable: false
  655. });
  656. };
  657. Ext.Ajax.request({
  658. url: '/lib/controller/getEventRecords.php',
  659. params: {
  660. SITE: <?=$SiteID;?>,
  661. UID: <?=$UserID;?>,
  662. SID: '<?=$Session;?>',
  663. MODE: Mode,
  664. FIL: selecredActiveSourceFilter,
  665. SDA: SD,
  666. SMO: SMO,
  667. SYE: SY,
  668. STM: ST,
  669. ETM: ET,
  670. STR: SR,
  671. DIR: DR
  672. },
  673. success: function( response, opts ){
  674. tlLoadLocker = false;
  675. var data = Ext.decode(response.responseText);
  676. if( data.updateFROMTO ){
  677. Ext.getCmp('STimeFROM').setValue( data.STT );
  678. Ext.getCmp('STimeTO').setValue( data.ENT );
  679. if( data.SLD > 0 ){
  680. SMO = GetMonthNum(data.SLD);
  681. SY = GetYear(data.SLD);
  682. SD = GetDay(data.SLD);
  683. BuildCalendar();
  684. };
  685. };
  686. eventsListStore.loadData( data, false );
  687. if( Mode == 'arch' ){
  688. showEventsOnMap( data, true );
  689. Ext.MessageBox.hide();
  690. if( DR > 0 ){
  691. Ext.getCmp('evtArchLog').getView().focusRow( eventsListStore.getCount() - 1 );
  692. Ext.getCmp('evtArchLog').getSelectionModel().selectLastRow();
  693. };
  694. if( DR < 0 ){
  695. Ext.getCmp('evtArchLog').getView().focusRow( 0 );
  696. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  697. };
  698. } else {
  699. showEventsOnMap( data, false );
  700. //LoadMapEventsZ( Mode );
  701. };
  702. },
  703. failure: failureAJAXFunction
  704. });
  705. };
  706. function loadArchive(){
  707. if( tlInterval!= null ){
  708. window.clearInterval( tlInterval );
  709. tlInterval = null;
  710. timelineObj = null;
  711. };
  712. stopStatusUpdater();
  713. setUserContent( 2 );
  714. var tPanel = Ext.getCmp('main_portal');
  715. tPanel.removeAll( true );
  716. Ext.getCmp('main_content').setTitle( 'Events Archive' );
  717. tPanel.add({
  718. columnWidth: 0.83,
  719. frame: false,
  720. border: false,
  721. items: [{
  722. title: 'Site Map',
  723. frame: false,
  724. border: false,
  725. layout: 'vbox',
  726. layoutConfig: {
  727. align : 'stretch',
  728. pack : 'start',
  729. },
  730. height: PanelH-300,
  731. items:[{
  732. height: PanelH-325,
  733. flex: 1,
  734. frame: false,
  735. border: false,
  736. layout: 'fit',
  737. items:{
  738. id: 'event_map',
  739. html: '&nbsp;'
  740. }
  741. }]
  742. },{
  743. frame: false,
  744. border: false,
  745. collapsible: false,
  746. draggable: false,
  747. layout: 'hbox',
  748. items:[{
  749. layout: 'form',
  750. title: 'Date/Time',
  751. width: 200,
  752. frame: true,
  753. border: false,
  754. labelAlign: 'right',
  755. labelWidth: 50,
  756. defaults: { width: 80},
  757. items: [{
  758. xtype: 'combo',
  759. id: 'STimeFROM',
  760. fieldLabel: 'From',
  761. editable: false,
  762. typeAhead: true,
  763. triggerAction: 'all',
  764. width: 120,
  765. lazyRender:true,
  766. mode: 'local',
  767. store: new Ext.data.ArrayStore({
  768. id: 0,
  769. fields: ['ss', 'displayText' ],
  770. data: [<?php
  771. $zuzu = array();
  772. for( $i = 0; $i < 24; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  773. echo implode( ',', $zuzu ); ?>]
  774. }),
  775. valueField: 'ss',
  776. displayField: 'displayText'
  777. },{
  778. xtype: 'combo',
  779. id: 'STimeTO',
  780. fieldLabel: 'Till',
  781. editable: false,
  782. typeAhead: true,
  783. triggerAction: 'all',
  784. width: 120,
  785. lazyRender:true,
  786. mode: 'local',
  787. store: new Ext.data.ArrayStore({
  788. id: 0,
  789. fields: ['ss', 'displayText' ],
  790. data: [<?php
  791. $zuzu = array();
  792. for( $i = 1; $i < 25; $i++) if( $i < 10 ) $zuzu[] = '['.($i*3600).',\'0'.$i.':00\']'; else $zuzu[] = '['.($i*3600).',\''.$i.':00\']';
  793. echo implode( ',', $zuzu ); ?>]
  794. }),
  795. valueField: 'ss',
  796. displayField: 'displayText'
  797. }],
  798. html: '<table width="100%"><tr><td id="calendar_TD" align="center"></td></tr></table>',
  799. buttons: [{
  800. xtype: 'button',
  801. text: 'Display History',
  802. handler: function(){
  803. var STU = Ext.getCmp('STimeFROM').getValue();
  804. var ETU = Ext.getCmp('STimeTO').getValue();
  805. getData( 'arch', STU, ETU );
  806. }
  807. }]
  808. },{
  809. title: 'Event Log',
  810. frame: false,
  811. height: 303,
  812. id: 'evtArchLog',
  813. xtype: 'grid',
  814. ds: eventsListStore,
  815. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  816. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  817. listeners:{
  818. keydown: function( e ) {
  819. if( e.getKey() == e.UP ){
  820. if( SelectedRow == 0 ){
  821. var id = eventsListStore.getAt( 0 ).id;
  822. getData( 'arch', 0, 0, id, 1 );
  823. };
  824. };
  825. if( e.getKey() == e.DOWN ){
  826. if( SelectedRow == ( eventsListStore.getCount() - 1 ) ){
  827. var id = eventsListStore.getAt( SelectedRow ).id;
  828. getData( 'arch', 0, 0, id, -1 );
  829. Ext.getCmp('evtArchLog').getSelectionModel().selectFirstRow();
  830. Ext.getCmp('evtArchLog').focus( false, true );
  831. };
  832. };
  833. }
  834. }
  835. }]
  836. }]
  837. });
  838. tPanel.add({
  839. columnWidth: 0.17,
  840. frame: true,
  841. title: 'Event Information',
  842. id: 'prop_content',
  843. border: false,
  844. items: [{
  845. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  846. }]
  847. });
  848. tPanel.doLayout();
  849. /*
  850. Ext.getCmp('evtLog').getEl().set({tabindex: "0"});
  851. Ext.getCmp('evtLog').getEl().addKeyMap({
  852. eventName: "keyup",
  853. binding: [{
  854. key: Ext.EventObject.SPACE,
  855. fn: function(){ alert("Space key pressed"); }
  856. },{
  857. key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT],
  858. shift: true,
  859. fn: function(){ alert("Left or right pressed while pressing shift"); }
  860. }]
  861. });
  862. */
  863. //BuildCalendar();
  864. loadCalendarDates();
  865. map = L.map('event_map',{
  866. attributionControl: true,
  867. //preferCanvas: true,
  868. zoomControl: true,
  869. center: [SiteLat, SiteLon],
  870. /*zoomControl: false,
  871. zoom: 17,
  872. minZoom: 17,
  873. maxZoom: 17,*/
  874. keyboard: false
  875. }).setView([SiteLat, SiteLon], 17);
  876. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  877. var mapLayers = [];
  878. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  879. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  880. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  881. detectRetina: true
  882. });*/
  883. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  884. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  885. maxNativeZoom: 18,
  886. maxZoom: 24,
  887. })
  888. // https://leaflet-extras.github.io/leaflet-providers/preview/
  889. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  890. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  891. maxZoom: 19
  892. });
  893. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  894. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  895. maxZoom: 19
  896. });
  897. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  898. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  899. maxZoom: 24
  900. });
  901. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  902. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  903. maxZoom: 19
  904. });
  905. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  906. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  907. maxZoom: 19
  908. });
  909. /*
  910. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  911. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  912. maxZoom: 22
  913. });
  914. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  915. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  916. maxZoom: 22
  917. });
  918. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  919. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  920. maxZoom: 22
  921. });
  922. */
  923. var baseMaps = {
  924. "MyMap": mapLayers["MyMap"],
  925. "OpenStreetMap": mapLayers["OpenStreetMap"],
  926. "OpenTopoMap": mapLayers["OpenTopoMap"],
  927. "EsriSat": mapLayers["EsriSat"],
  928. "EsriStreet": mapLayers["EsriStreet"],
  929. "EsriTopo": mapLayers["EsriTopo"],
  930. //"Bing": mapLayers["Bing"],
  931. //"OSM-Cycle": mapLayers["Cycle"],
  932. //"Landscape": mapLayers["Landscape"],
  933. //"Outdoor": mapLayers["Outdoor"],
  934. };
  935. L.control.layers( baseMaps ).addTo(map);
  936. mapLayers["MyMap"].addTo(map);
  937. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  938. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  939. maxNativeZoom: 18,
  940. maxZoom: 24,
  941. }).addTo(map); */
  942. //loadTimeLineGroups( selectedSite );
  943. loadMapZones( SelectedSite );
  944. getData( 'arch' );
  945. //eventsListStore.load({params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
  946. };
  947. function loadMonitoring(){
  948. if( tlInterval!= null ){
  949. window.clearInterval( tlInterval );
  950. tlInterval = null;
  951. timelineObj = null;
  952. };
  953. setUserContent( 1 );
  954. var tPanel = Ext.getCmp('main_portal');
  955. tPanel.removeAll( true );
  956. Ext.getCmp('main_content').setTitle( 'Events Monitoring' );
  957. tPanel.add({
  958. columnWidth: 0.83,
  959. frame: false,
  960. border: false,
  961. items: [{
  962. title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
  963. frame: false,
  964. border: false,
  965. collapsible: false,
  966. draggable: false,
  967. layout: 'vbox',
  968. layoutConfig: {
  969. align : 'stretch',
  970. pack : 'start',
  971. },
  972. height: PanelH-300,
  973. items:[{
  974. height: PanelH-325,
  975. flex: 1,
  976. frame: false,
  977. border: false,
  978. layout: 'fit',
  979. items:{
  980. id: 'event_map',
  981. html: '&nbsp;'
  982. }
  983. }]
  984. },{
  985. frame: false,
  986. border: true,
  987. collapsible: false,
  988. draggable: false,
  989. layout: 'hbox',
  990. items:[{
  991. title: 'Alarm Sources',
  992. xtype: 'panel',
  993. border: false,
  994. frame: false,
  995. collapsible: false,
  996. draggable: false,
  997. id: 'sources_panel',
  998. width: 160,
  999. autoScroll: 'auto',
  1000. height: 303
  1001. },{
  1002. title: 'Event Log',
  1003. height: 303,
  1004. xtype: 'grid',
  1005. border: false,
  1006. frame: false,
  1007. collapsible: false,
  1008. draggable: false,
  1009. ds: eventsListStore,
  1010. cm: new Ext.grid.ColumnModel( eventsListColModel_ops ),
  1011. sm: new Ext.grid.RowSelectionModel( eventsListSelModel_ops ),
  1012. bbar: [{
  1013. text: 'Clear',
  1014. handler: function(){
  1015. Ext.Ajax.request({
  1016. url: '/lib/controller/clearEventCloud.php',
  1017. params: {
  1018. UID: <?=$UserID;?>,
  1019. SID: '<?=$Session;?>'
  1020. },
  1021. success: function( response, opts ){
  1022. },
  1023. failure: function( response, opts ) {
  1024. }
  1025. });
  1026. }
  1027. }]
  1028. }]
  1029. }]
  1030. });
  1031. tPanel.add({
  1032. columnWidth: 0.17,
  1033. title: 'Event Information',
  1034. frame: true,
  1035. id: 'prop_content',
  1036. border: false,
  1037. items: [{
  1038. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1039. }]
  1040. });
  1041. tPanel.doLayout();
  1042. map = L.map('event_map',{
  1043. attributionControl: true,
  1044. //preferCanvas: true,
  1045. zoomControl: true,
  1046. center: [SiteLat, SiteLon],
  1047. /*zoomControl: false,
  1048. zoom: 17,
  1049. minZoom: 17,
  1050. maxZoom: 17,*/
  1051. keyboard: false
  1052. }).setView([SiteLat, SiteLon], 17);
  1053. //L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon } ).addTo(map).on('click', LoadNodesList ).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");
  1054. var mapLayers = [];
  1055. /*mapLayers["Bing"] = new BingLayer('https://t{s}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{q}?it=A,G,L&shading=hill', {
  1056. subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'],
  1057. attribution: '&copy; <a href="https://bing.com/maps" target="_blank">Bing Maps</a>',
  1058. detectRetina: true
  1059. });*/
  1060. mapLayers["MyMap"] = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1061. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1062. maxNativeZoom: 18,
  1063. maxZoom: 24,
  1064. })
  1065. // https://leaflet-extras.github.io/leaflet-providers/preview/
  1066. mapLayers["EsriStreet"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
  1067. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012',
  1068. maxZoom: 19
  1069. });
  1070. mapLayers["EsriSat"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  1071. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community',
  1072. maxZoom: 19
  1073. });
  1074. mapLayers["EsriTopo"] = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}', {
  1075. attribution: 'Tiles &copy; <a href="https://www.esri.com" target="_blank">Esri</a> &mdash; Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community',
  1076. maxZoom: 24
  1077. });
  1078. mapLayers["OpenStreetMap"] = L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { //de/tiles/osmde
  1079. attribution: 'Map data &copy; <a href="https://openstreetmap.org" target="_blank">OpenStreetMap</a> contributors',
  1080. maxZoom: 19
  1081. });
  1082. mapLayers["OpenTopoMap"] = L.tileLayer("https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png", {
  1083. attribution: 'Kartendaten: &copy; <a href="https://openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>-Mitwirkende, SRTM | Kartendarstellung: &copy; <a href="http://opentopomap.org/" target="_blank">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/" target="_blank">CC-BY-SA</a>) ',
  1084. maxZoom: 19
  1085. });
  1086. /*
  1087. mapLayers["Cycle"] = L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1088. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1089. maxZoom: 22
  1090. });
  1091. mapLayers["Landscape"] = L.tileLayer('https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1092. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1093. maxZoom: 22
  1094. });
  1095. mapLayers["Outdoor"] = L.tileLayer('https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=' + _PHP['API_KEY_THUNDERFOREST_1'], {
  1096. attribution: 'Maps &copy; <a href="https://www.thunderforest.com" target="_blank">Thunderforest</a>, Data © <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap contributors</a>',
  1097. maxZoom: 22
  1098. });
  1099. */
  1100. var baseMaps = {
  1101. "MyMap": mapLayers["MyMap"],
  1102. "OpenStreetMap": mapLayers["OpenStreetMap"],
  1103. "OpenTopoMap": mapLayers["OpenTopoMap"],
  1104. "EsriSat": mapLayers["EsriSat"],
  1105. "EsriStreet": mapLayers["EsriStreet"],
  1106. "EsriTopo": mapLayers["EsriTopo"],
  1107. //"Bing": mapLayers["Bing"],
  1108. //"OSM-Cycle": mapLayers["Cycle"],
  1109. //"Landscape": mapLayers["Landscape"],
  1110. //"Outdoor": mapLayers["Outdoor"],
  1111. };
  1112. L.control.layers( baseMaps ).addTo(map);
  1113. mapLayers["MyMap"].addTo(map);
  1114. /*L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  1115. attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
  1116. maxNativeZoom: 18,
  1117. maxZoom: 24,
  1118. }).addTo(map); */
  1119. loadMapZones( SelectedSite );
  1120. tlInterval = window.setInterval( getData, 333, 'live' );
  1121. };
  1122. function loadOnlineMonitoring(devID){
  1123. var tPanel = Ext.getCmp('main_content');
  1124. if( tlInterval!= null ){
  1125. window.clearInterval( tlInterval );
  1126. tlInterval = null;
  1127. timelineObj = null;
  1128. };
  1129. tPanel.remove(0);
  1130. tPanel.add({
  1131. html: 'Device Monitoring '+devID
  1132. });
  1133. tPanel.doLayout();
  1134. };
  1135. var mSesPlay = null;
  1136. function ts2dts( b ){
  1137. var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
  1138. var a = new Date( b );
  1139. var year = a.getFullYear();
  1140. var month = months[a.getMonth()];
  1141. var date = a.getDate();
  1142. var hour = a.getHours();
  1143. var min = "0" + a.getMinutes();
  1144. var sec = "0" + a.getSeconds();
  1145. return date + ' ' + month + ' ' + year + ' ' + hour + ':' + min.substr(-2) + ':' + sec.substr(-2) ;
  1146. };
  1147. function drawEventsOnSlider( a, b , z ){
  1148. var cel = Ext.getCmp("hpl_slider").getEl();
  1149. var c = document.createElement('canvas');
  1150. var ctx = c.getContext('2d');
  1151. c.width = cel.getWidth();
  1152. c.height = cel.getHeight();
  1153. var tK = ( cel.getWidth() - 7 ) / ( b - a );
  1154. var rib = (tK>3)?tK:3;
  1155. ctx.fillStyle='#00000000';
  1156. //ctx.fillStyle='#00FF00';
  1157. ctx.fillRect( 7, 0,cel.getWidth(),cel.getHeight());
  1158. ctx.fillStyle='#FF0000';
  1159. for( var i=0; i< z.length; i++ ){
  1160. var cX = 7 + Math.round( tK * ( z[i].ts /1000 - a ) );
  1161. ctx.fillRect( cX, 0, rib, 25 );
  1162. };
  1163. cel.setStyle('background','url(' + c.toDataURL() + ')');
  1164. };
  1165. var max_grad_levels = 16;
  1166. function getTransperecy( i ){
  1167. if( i == 0 ) return 'FF';
  1168. var k = 128.0 / max_grad_levels;
  1169. var l = parseInt( k*(max_grad_levels-i) ).toString(16);
  1170. if( l.length < 2 ) l = '0'+l;
  1171. return l;
  1172. };
  1173. function getSize( i ){
  1174. var k = 75.0 / max_grad_levels;
  1175. return 25+parseInt( k * i );
  1176. };
  1177. class argusSessionPlayer{
  1178. sessionId;
  1179. mMapID;
  1180. startTime;
  1181. endTime;
  1182. currentTime;
  1183. rVideoJS = null;
  1184. lVideoJS = null;
  1185. rVideoJS_id = null;
  1186. lVideoJS_id = null;
  1187. rVideoJS_playing = false;
  1188. lVideoJS_playing = false;
  1189. rVideoJS_cid = -1;
  1190. lVideoJS_cid = -1;
  1191. mapLayout;
  1192. lVideos;
  1193. rVideos;
  1194. Events;
  1195. basePath;
  1196. mTimer = null;
  1197. mPaused = true;
  1198. mLooping = true;
  1199. mSvgElements;
  1200. constructor( session_id ) {
  1201. this.sessionId = session_id;
  1202. this.currentTime = 0;
  1203. this.startTime = 0;
  1204. this.endTime = 0;
  1205. this.lVideos = [];
  1206. this.rVideos = [];
  1207. this.Events = [];
  1208. this.mSvgElements = [];
  1209. Ext.Ajax.request({
  1210. url: '/lib/controller/getSessionData.php',
  1211. params: {
  1212. SESSION: this.sessionId,
  1213. UID: <?=$UserID;?>,
  1214. SID: '<?=$Session;?>'
  1215. },
  1216. success: function( response, opts ){
  1217. var data = Ext.decode( response.responseText );
  1218. //debugger;
  1219. if( data.status == 'ok' ){
  1220. mSesPlay.mapLayout = data.layout;
  1221. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  1222. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  1223. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  1224. //debugger;
  1225. if( data.data_ok ){
  1226. if( data.r_module_id ){
  1227. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  1228. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  1229. //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  1230. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  1231. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  1232. };
  1233. mSesPlay.startTime = data.start_ts;
  1234. mSesPlay.endTime = data.start_ts + data.length;
  1235. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  1236. mSesPlay.rVideos = [];
  1237. mSesPlay.lVideos = [];
  1238. if( data.videos.length ){
  1239. for( var i=0; i < data.videos.length; i++ )
  1240. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] );
  1241. };
  1242. if( data.events.length ) mSesPlay.Events = data.events;
  1243. var tt = Ext.getCmp('hpl_slider');
  1244. tt.setMinValue( 0 );
  1245. tt.setMaxValue( data.length / 1000 );
  1246. drawEventsOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events );
  1247. //player.on('ended', function() {
  1248. // this.dispose();
  1249. //});
  1250. //alert( data.basepath +'/'+data.videos[0].name );
  1251. //mSesPlay.rVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  1252. //mSesPlay.rVideoJS.ready(function() {
  1253. //mSesPlay.rVideoJS.play();
  1254. //var howLoudIsIt = player.volume();
  1255. //mSesPlay.rVideoJS.volume( 0.0 ); // Set volume to half
  1256. //});
  1257. //mSesPlay.rVideoJS.on("timeupdate", function(){
  1258. // method will be calledd each 250 msecs
  1259. //});
  1260. if( data.l_module_id ){
  1261. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  1262. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  1263. //mSesPlay.lVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  1264. //mSesPlay.lVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  1265. //mSesPlay.lVideoJS.ready(function() {
  1266. //mSesPlay.rVideoJS.play();
  1267. //var howLoudIsIt = player.volume();
  1268. // mSesPlay.lVideoJS.volume( 0.0 ); // Set volume to half
  1269. //});
  1270. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  1271. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  1272. };
  1273. //mSesPlay.lVideoJS.on("timeupdate", function(){
  1274. // // method will be calledd each 250 msecs
  1275. //});
  1276. mSesPlay.setPosition( 0 );
  1277. } else {
  1278. Ext.Msg.show({
  1279. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  1280. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  1281. buttons: Ext.Msg.OK,
  1282. icon: Ext.MessageBox.ERROR
  1283. });
  1284. }
  1285. };
  1286. },
  1287. failure: failureAJAXFunction
  1288. });
  1289. }
  1290. action(){
  1291. if( !this.mPaused ){
  1292. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1293. var zz = document.getElementById('hpl_time_mon');
  1294. //debugger;
  1295. if( zz != undefined ){
  1296. zz.innerHTML = ts2dts( this.currentTime );
  1297. };
  1298. //Check videos
  1299. if( this.rVideos.length ){
  1300. var fid = -1;
  1301. for(var i=0; i<this.rVideos.length; i++ ){
  1302. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  1303. fid = i;
  1304. break;
  1305. };
  1306. };
  1307. if( fid < 0 ){
  1308. //No Segments for Now;
  1309. this.rVideoJS_playing = false;
  1310. } else {
  1311. if( this.rVideoJS_cid != fid ){
  1312. this.rVideoJS_cid = fid;
  1313. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1314. this.rVideoJS.src( ns );
  1315. };
  1316. this.rVideoJS_playing = true;
  1317. };
  1318. if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  1319. };
  1320. if( this.lVideos.length ){
  1321. var fid = -1;
  1322. for(var i=0; i<this.lVideos.length; i++ ){
  1323. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  1324. fid = i;
  1325. break;
  1326. };
  1327. };
  1328. if( fid < 0 ){
  1329. //No Segments for Now;
  1330. this.lVideoJS_playing = false;
  1331. } else {
  1332. if( this.lVideoJS_cid != fid ){
  1333. this.lVideoJS_cid = fid;
  1334. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1335. this.lVideoJS.src( ns );
  1336. };
  1337. this.lVideoJS_playing = true;
  1338. };
  1339. if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1340. };
  1341. if( this.Events.length ){
  1342. var sid = -1;
  1343. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  1344. sid = i;
  1345. break;
  1346. };
  1347. if( sid > -1 ){
  1348. for( var i=0; i< max_grad_levels; i++ ){
  1349. var cid = sid-i;
  1350. var csize = getSize( i );
  1351. //debugger;
  1352. if( typeof this.mSvgElements[i] === 'undefined') {
  1353. if( cid > -1 ){
  1354. var svgns = "http://www.w3.org/2000/svg";
  1355. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1356. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1357. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1358. this.mSvgElements[i].setAttribute('height', ''+csize);
  1359. this.mSvgElements[i].setAttribute('width', ''+csize);
  1360. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1361. var tt = document.getElementById('svgTrackMap');
  1362. var zz = document.getElementById('scheme_anch');
  1363. tt.insertBefore( this.mSvgElements[i], zz );
  1364. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1365. };
  1366. } else {
  1367. if( cid > -1 ){
  1368. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1369. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1370. this.mSvgElements[i].setAttribute('height', ''+csize);
  1371. this.mSvgElements[i].setAttribute('width', ''+csize);
  1372. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1373. } else {
  1374. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1375. };
  1376. };
  1377. };
  1378. } else
  1379. for( var i=0; i< max_grad_levels; i++ )
  1380. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1381. };
  1382. var tt = Ext.getCmp('hpl_slider');
  1383. if( tt!= undefined ){
  1384. tt.suspendEvents();
  1385. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  1386. tt.resumeEvents();
  1387. };
  1388. this.currentTime += 250;
  1389. if( this.currentTime > this.endTime ) if( this.mLooping ){
  1390. this.currentTime = 0;
  1391. } else {
  1392. //Stop
  1393. this.play();
  1394. };
  1395. };
  1396. }
  1397. play(){
  1398. var zz = Ext.getCmp( 'hpl_pl_btn' );
  1399. if( this.mPaused ){
  1400. this.mPaused = false;
  1401. if( this.rVideoJS_playing ) this.rVideoJS.play();
  1402. if( this.lVideoJS_playing ) this.lVideoJS.play();
  1403. zz.setIconClass( 'plr_op_pause' );
  1404. zz.setText('Pause');
  1405. } else {
  1406. this.mPaused = true;
  1407. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  1408. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  1409. zz.setIconClass( 'plr_op_play' );
  1410. zz.setText('Play');
  1411. };
  1412. if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  1413. }
  1414. pause(){
  1415. this.mPaused = true;
  1416. }
  1417. toggleLoop(){
  1418. this.mLooping = !this.mLooping;
  1419. if( this.mLooping ) if( this.currentTime > this.endTime ){
  1420. this.currentTime = 0;
  1421. // Start
  1422. this.play();
  1423. };
  1424. }
  1425. setPosition( pos_time ){
  1426. this.currentTime = this.startTime + pos_time*1000;
  1427. var zz = document.getElementById('hpl_time_mon');
  1428. zz.innerHTML = ts2dts( this.currentTime );
  1429. }
  1430. onLVideoEnd(){
  1431. }
  1432. onRVideoEnd(){
  1433. }
  1434. dispose(){
  1435. if( this.mTimer != null ) clearInterval( this.mTimer );
  1436. this.mTimer = null;
  1437. if( this.rVideoJS!= null ){
  1438. this.rVideoJS.dispose();
  1439. this.rVideoJS = null;
  1440. };
  1441. if( this.lVideoJS!= null ){
  1442. this.lVideoJS.dispose();
  1443. this.lVideoJS = null;
  1444. };
  1445. }
  1446. }
  1447. function loadHistorySessionView( session_id ){
  1448. autoRiseEvent = false;
  1449. rep_selectedEventId = session_id;
  1450. Ext.Ajax.request({
  1451. url: '/lib/controller/getHistorySessionView.php',
  1452. params: {
  1453. SESSION: rep_selectedEventId,
  1454. UID: <?=$UserID;?>,
  1455. SID: '<?=$Session;?>'
  1456. },
  1457. success: function( response, opts ){
  1458. var data = Ext.decode(response.responseText);
  1459. if( data.status == 'ok' ){
  1460. monitoringViewLevel = 5;
  1461. if( mSesPlay!= null ) {
  1462. mSesPlay.dispose();
  1463. mSesPlay = null;
  1464. };
  1465. Ext.getCmp('main_content').removeAll(true);
  1466. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  1467. Ext.getCmp('main_content').doLayout();
  1468. changeContent( 2, 5, rep_selectedStation+'-'+rep_selectedDateTS+'-'+rep_selectedEventId );
  1469. updateUserContent();
  1470. mSesPlay = new argusSessionPlayer( rep_selectedEventId );
  1471. mSesPlay.play();
  1472. fetchStatus();
  1473. };
  1474. },
  1475. failure: failureAJAXFunction
  1476. });
  1477. };
  1478. function deleteSession( session_id ){
  1479. if( session_id == 0 ) return;
  1480. Ext.Msg.show({
  1481. title:'<?=$Labels->GetLabel('_RYS_DEL_SES_');?>',
  1482. msg: '<?=$Labels->GetLabel('_RYS_DEL_SESSION_');?>',
  1483. buttons: Ext.Msg.YESNOCANCEL,
  1484. icon: Ext.MessageBox.QUESTION,
  1485. fn: function(btn, text){
  1486. if( btn == 'yes' ){
  1487. Ext.Ajax.request({
  1488. url: '/lib/controller/doSessionOperations.php',
  1489. params: {
  1490. SESSION: session_id,
  1491. OPID: 1,
  1492. UID: <?=$UserID;?>,
  1493. SID: '<?=$Session;?>'
  1494. },
  1495. success: function( response, opts ){
  1496. Ext.Msg.hide();
  1497. var data = Ext.decode(response.responseText);
  1498. if( data.status == 'ok' ){
  1499. getBackToMap();
  1500. } else {
  1501. Ext.Msg.show({
  1502. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  1503. msg: data.msg,
  1504. buttons: Ext.Msg.OK,
  1505. icon: Ext.MessageBox.ERROR
  1506. });
  1507. };
  1508. },
  1509. failure: failureAJAXFunction
  1510. });
  1511. };
  1512. }
  1513. });
  1514. };
  1515. function loadHistoryStationEvt( e ){
  1516. loadHistoryStation( e.target.options.mycustomid );
  1517. };
  1518. function loadHistoryStation( STT, buba ){
  1519. if( buba == undefined ){
  1520. autoRiseEvent = false;
  1521. } else {
  1522. autoRiseEvent = buba;
  1523. };
  1524. rep_selectedStation = STT;
  1525. changeContent( 2, 1, rep_selectedStation );
  1526. updateUserContent();
  1527. Ext.Ajax.request({
  1528. url: '/lib/controller/getHistoryStationView.php',
  1529. params: {
  1530. STT: rep_selectedStation,
  1531. UID: <?=$UserID;?>,
  1532. SID: '<?=$Session;?>'
  1533. },
  1534. success: function( response, opts ){
  1535. var data = Ext.decode(response.responseText);
  1536. if( data.status == 'ok' ){
  1537. Ext.getCmp('main_content').removeAll(true);
  1538. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  1539. Ext.getCmp('main_content').doLayout();
  1540. Ext.getCmp('left_side_menu').removeAll(true);
  1541. Ext.getCmp('left_side_menu').add({
  1542. xtype: 'panel',
  1543. frame: true,
  1544. border: false,
  1545. items: [{
  1546. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
  1547. height: PanelH - 30
  1548. }]
  1549. });
  1550. Ext.getCmp('left_side_menu').doLayout();
  1551. } else {
  1552. };
  1553. },
  1554. failure: failureAJAXFunction
  1555. });
  1556. };
  1557. function loadReportDayTree( ts ){
  1558. ReportSelectionMode = 1;//Day Selected
  1559. rep_selectedDateTS = ts;
  1560. //ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
  1561. //ReportMask.show();
  1562. Ext.Ajax.request({
  1563. url: '/lib/controller/getHistoryDay.php',
  1564. params: {
  1565. UID: <?=$UserID;?>,
  1566. SID: '<?=$Session;?>',
  1567. STT: rep_selectedStation,
  1568. DTS: rep_selectedDateTS
  1569. },
  1570. success: function(response, opts ){
  1571. var data = Ext.decode( response.responseText );
  1572. var sPanel = Ext.getCmp('left_side_menu');
  1573. sPanel.removeAll( true );
  1574. sPanel.add({
  1575. xtype: 'panel',
  1576. layout: 'vbox',
  1577. frame: true,
  1578. border: false,
  1579. items:[{
  1580. xtype: 'spacer',
  1581. height: 3
  1582. },{
  1583. html: '<p class="cur_date">'+( new Date( ts * 1000)).toLocaleDateString()+'</p><p class="cur_sessions">'+data.sessions+'</p><p class="cur_events">'+data.events+'</p><p class="cur_videos">'+data.videos+'</p>',
  1584. frame: false,
  1585. width: '100%',
  1586. border: false
  1587. },{
  1588. xtype: 'spacer',
  1589. height: 5
  1590. },{
  1591. xtype: 'treepanel',
  1592. autoScroll: true,
  1593. width: '100%',
  1594. height: PanelH-206,
  1595. border: true,
  1596. frame: true,
  1597. loader: new Ext.tree.TreeLoader(),
  1598. rootVisible: false,
  1599. root: new Ext.tree.AsyncTreeNode( data ),
  1600. listeners: {
  1601. click: function(n) {
  1602. if( n.attributes.leaf ){
  1603. Ext.getCmp('chu_adate').show();
  1604. sPanel.doLayout();
  1605. loadHistorySessionView( n.attributes.sid );
  1606. };
  1607. }
  1608. }
  1609. },{
  1610. xtype: 'spacer',
  1611. height: 10
  1612. },{
  1613. xtype: 'button',
  1614. id: 'chu_adate',
  1615. text: 'Show Dates',
  1616. hidden: true,
  1617. width: '100%',
  1618. iconCls: 'reports_dates_btn',
  1619. scale: 'large',
  1620. handler: function(){
  1621. Ext.getCmp('chu_adate').hide();
  1622. loadHistoryStation( rep_selectedStation );
  1623. }
  1624. }]
  1625. });
  1626. sPanel.doLayout();
  1627. changeContent( 2, 2, rep_selectedStation+'-'+rep_selectedDateTS );
  1628. updateUserContent();
  1629. //ReportMask.hide();
  1630. }
  1631. });
  1632. };
  1633. function noHistDialog(){
  1634. Ext.Msg.show({
  1635. title:'<?=$Labels->GetLabel('_GEN_MSG_');?>',
  1636. msg: '<?=$Labels->GetLabel('_NO_REPORTS_4_STATION_');?>',
  1637. buttons: Ext.Msg.OK,
  1638. icon: Ext.MessageBox.INFO
  1639. });
  1640. };
  1641. var history_map = null;
  1642. function initHistoryMap( map_id, x, y ){
  1643. if( tlInterval!= null ){
  1644. window.clearTimeout( tlInterval );
  1645. tlInterval = null;
  1646. };
  1647. var mapLayers = [];
  1648. if( history_map != null ){
  1649. history_map.off();
  1650. history_map.remove();
  1651. history_map = null;
  1652. };
  1653. history_map = L.map( map_id,{
  1654. crs: L.CRS.Simple,
  1655. attributionControl: false,
  1656. preferCanvas: true,
  1657. zoomControl: true,
  1658. center: [x,y],
  1659. zoom: 0,
  1660. minZoom: -3,
  1661. maxZoom: 0,
  1662. keyboard: false
  1663. });
  1664. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  1665. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( history_map );
  1666. Ext.Ajax.request({
  1667. url: '/lib/controller/listHistoryStations.php',
  1668. params: {
  1669. UID: <?=$UserID;?>,
  1670. SID: '<?=$Session;?>'
  1671. },
  1672. success: function( response, opts ){
  1673. var data = Ext.decode(response.responseText);
  1674. if( data.status == 'ok' ){
  1675. for( i=0; i < data.stations.length; i++ ){
  1676. if( data.stations[i].status ){
  1677. stationMarkers[ data.stations[i].id ] = L.marker([data.stations[i].y, data.stations[i].x], { draggable: false, icon: GREEN_Icon, zIndexOffset: 1000, mycustomid: data.stations[i].id } ).addTo( history_map ).on('click', loadHistoryStationEvt );
  1678. } else {
  1679. stationMarkers[ data.stations[i].id ] = L.marker([data.stations[i].y, data.stations[i].x], { draggable: false, icon: GREY_Icon, zIndexOffset: 1000, mycustomid: data.stations[i].id } ).addTo( history_map ).on('click', noHistDialog );
  1680. };
  1681. };
  1682. };
  1683. },
  1684. failure: failureAJAXFunction
  1685. });
  1686. };
  1687. function getBackToHistoryMap(){
  1688. autoRiseEvent = false;
  1689. changeContent( 2, 0 );
  1690. updateUserContent();
  1691. var tP = Ext.getCmp('left_side_menu');
  1692. tP.removeAll( true );
  1693. tP.add({
  1694. layout:'vbox',
  1695. frame: false,
  1696. border: false,
  1697. items:[{
  1698. xtype: 'panel',
  1699. frame: true,
  1700. border: false,
  1701. items: [{
  1702. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_STA_ONMAP_');?></div>',
  1703. height: PanelH - 30
  1704. }]
  1705. }]
  1706. });
  1707. tP.doLayout();
  1708. loadHistoryMapView();
  1709. };
  1710. function loadHistoryMapView(){
  1711. autoRiseEvent = false;
  1712. Ext.Ajax.request({
  1713. url: '/lib/controller/getHistoryMapView.php',
  1714. params: {
  1715. UID: <?=$UserID;?>,
  1716. SID: '<?=$Session;?>'
  1717. },
  1718. success: function( response, opts ){
  1719. var data = Ext.decode(response.responseText);
  1720. if( data.status == 'ok' ){
  1721. monitoringViewLevel = 0;
  1722. Ext.getCmp('main_content').removeAll(true);
  1723. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  1724. Ext.getCmp('main_content').doLayout();
  1725. };
  1726. },
  1727. failure: failureAJAXFunction
  1728. });
  1729. return;
  1730. };
  1731. function initReportsView(){
  1732. if( tlInterval!= null ){
  1733. window.clearInterval( tlInterval );
  1734. tlInterval = null;
  1735. timelineObj = null;
  1736. };
  1737. var tP = Ext.getCmp('left_side_menu');
  1738. tP.removeAll( true );
  1739. tP.add({
  1740. layout:'vbox',
  1741. frame: false,
  1742. border: false,
  1743. items:[{
  1744. xtype: 'panel',
  1745. frame: true,
  1746. border: false,
  1747. items: [{
  1748. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_STA_ONMAP_');?></div>',
  1749. height: PanelH - 30
  1750. }]
  1751. }]
  1752. });
  1753. tP.doLayout();
  1754. monitoringViewLevel = contentView.l[2].v;
  1755. switch( monitoringViewLevel ){
  1756. case 0:{
  1757. loadHistoryMapView();
  1758. break;
  1759. };
  1760. case 1:{
  1761. loadHistoryStation( parseInt( contentView.l[2].p ), autoRiseEvent );
  1762. break;
  1763. };
  1764. case 2:{
  1765. var tA = contentView.l[2].p.split('-');
  1766. rep_selectedStation = parseInt( tA[0] );
  1767. rep_selectedDateTS = parseInt( tA[1] );
  1768. loadHistoryStation( rep_selectedStation, autoRiseEvent );
  1769. loadReportDayTree( rep_selectedDateTS );
  1770. break;
  1771. };
  1772. case 5:{
  1773. var tA = contentView.l[2].p.split('-');
  1774. rep_selectedStation = parseInt( tA[0] );
  1775. rep_selectedDateTS = parseInt( tA[1] );
  1776. rep_selectedEventId = parseInt( tA[2] );
  1777. loadReportDayTree( rep_selectedDateTS );
  1778. loadHistorySessionView( rep_selectedEventId );
  1779. break;
  1780. };
  1781. };
  1782. //Ext.getCmp('main_content').doLayout();
  1783. };