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.

2230 lines
72 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 months ago
5 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 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 drawSessionDataOnSlider( a, b , z, v ){
  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, 12 );//25
  1162. };
  1163. ctx.fillStyle='#0000FF';
  1164. for( var i=0; i< v.length; i++ ){
  1165. var cX = 7 + Math.round( tK * ( v[i].sts /1000 - a ) );
  1166. var cD = 7 + Math.round( tK * ( v[i].ets /1000 - a ) );
  1167. var cW = cD - cX;
  1168. ctx.fillRect( cX, 13, cW, 25 );
  1169. };
  1170. cel.setStyle('background','url(' + c.toDataURL() + ')');
  1171. };
  1172. var max_grad_levels = 16;
  1173. function getTransperecy( i ){
  1174. if( i == 0 ) return 'FF';
  1175. var k = 128.0 / max_grad_levels;
  1176. var l = parseInt( k*(max_grad_levels-i) ).toString(16);
  1177. if( l.length < 2 ) l = '0'+l;
  1178. return l;
  1179. };
  1180. function getSize( i ){
  1181. var k = 75.0 / max_grad_levels;
  1182. return 25+parseInt( k * i );
  1183. };
  1184. class argusSessionPlayer{
  1185. sessionId;
  1186. mMapID;
  1187. startTime;
  1188. endTime;
  1189. currentTime;
  1190. rVideoJS = null;
  1191. lVideoJS = null;
  1192. rVideoJS_id = null;
  1193. lVideoJS_id = null;
  1194. rVideoJS_playing = false;
  1195. lVideoJS_playing = false;
  1196. rVideoJS_cid = -1;
  1197. lVideoJS_cid = -1;
  1198. mapLayout;
  1199. lVideos;
  1200. rVideos;
  1201. Events;
  1202. basePath;
  1203. mTimer = null;
  1204. mPaused = true;
  1205. mLooping = true;
  1206. mAutoPlay = false;
  1207. nextRTimestamp = 0.0;
  1208. nextLTimestamp = 0.0;
  1209. mSvgElements;//076.png
  1210. checkLVideoTime(){
  1211. const t = mSesPlay.lVideoJS.currentTime(); // seconds
  1212. while( t >= mSesPlay.nextLTimestamp ){
  1213. mSesPlay.lVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextLTimestamp });
  1214. mSesPlay.nextLTimestamp += 0.1; // next 100 ms of video time
  1215. };
  1216. }
  1217. checkRVideoTime(){
  1218. const t = mSesPlay.rVideoJS.currentTime(); // seconds
  1219. while( t >= mSesPlay.nextRTimestamp ){
  1220. mSesPlay.rVideoJS.trigger({ type: 'videotick', timestamp: mSesPlay.nextRTimestamp });
  1221. mSesPlay.nextRTimestamp += 0.1; // next 100 ms of video time
  1222. };
  1223. }
  1224. constructor( session_id, autoplay ) {
  1225. this.sessionId = session_id;
  1226. this.currentTime = 0;
  1227. this.startTime = 0;
  1228. this.endTime = 0;
  1229. this.lVideos = [];
  1230. this.rVideos = [];
  1231. this.Events = [];
  1232. this.mSvgElements = [];
  1233. if( autoplay != undefined ) this.mAutoPlay = autoplay;
  1234. Ext.Ajax.request({
  1235. url: '/lib/controller/getSessionData.php',
  1236. params: {
  1237. SESSION: this.sessionId,
  1238. UID: <?=$UserID;?>,
  1239. SID: '<?=$Session;?>'
  1240. },
  1241. success: function( response, opts ){
  1242. var data = Ext.decode( response.responseText );
  1243. //debugger;
  1244. if( data.status == 'ok' ){
  1245. mSesPlay.mapLayout = data.layout;
  1246. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  1247. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  1248. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  1249. //debugger;
  1250. if( data.data_ok ){
  1251. mSesPlay.startTime = data.start_ts;
  1252. mSesPlay.endTime = data.start_ts + data.length;
  1253. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  1254. mSesPlay.rVideos = [];
  1255. mSesPlay.lVideos = [];
  1256. mSesPlay.nextRTimestamp = 0.0;
  1257. mSesPlay.nextLTimestamp = 0.0;
  1258. var tt = Ext.getCmp('hpl_slider');
  1259. tt.setMinValue( 0 );
  1260. tt.setMaxValue( data.length / 1000 );
  1261. if( data.events.length ) mSesPlay.Events = data.events;
  1262. if( data.videos.length ){
  1263. for( var i=0; i < data.videos.length; i++ )
  1264. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] );
  1265. };
  1266. if( mSesPlay.rVideos.length ) { //data.r_module_id ){
  1267. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  1268. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  1269. //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  1270. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  1271. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  1272. // New imp
  1273. mSesPlay.rVideoJS.on('play', () => {
  1274. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1275. });
  1276. mSesPlay.rVideoJS.on( 'timeupdate', mSesPlay.checkRVideoTime );
  1277. mSesPlay.rVideoJS.on('seeking', () => {
  1278. mSesPlay.nextRTimestamp = Math.floor( mSesPlay.rVideoJS.currentTime() * 10) / 10 + 0.1;
  1279. });
  1280. mSesPlay.rVideoJS.on('videotick', (e) => {
  1281. console.log("Video timestamp:", e.timestamp.toFixed(1));
  1282. });
  1283. } else {
  1284. //correct empty Video Placeholder
  1285. };
  1286. if( mSesPlay.lVideos.length ){ //data.l_module_id ){
  1287. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  1288. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  1289. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  1290. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  1291. // New imp
  1292. mSesPlay.lVideoJS.on('play', () => {
  1293. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1294. });
  1295. mSesPlay.lVideoJS.on( 'timeupdate', mSesPlay.checkLVideoTime );
  1296. mSesPlay.lVideoJS.on('seeking', () => {
  1297. mSesPlay.nextLTimestamp = Math.floor( mSesPlay.lVideoJS.currentTime() * 10) / 10 + 0.1;
  1298. });
  1299. mSesPlay.lVideoJS.on('videotick', (e) => {
  1300. console.log("Video timestamp:", e.timestamp.toFixed(1));
  1301. });
  1302. } else {
  1303. //correct empty Video Placeholder
  1304. };
  1305. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  1306. mSesPlay.setPosition( 0 );
  1307. if( mSesPlay.mAutoPlay ) mSesPlay.play();
  1308. } else {
  1309. Ext.Msg.show({
  1310. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  1311. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  1312. buttons: Ext.Msg.OK,
  1313. icon: Ext.MessageBox.ERROR
  1314. });
  1315. }
  1316. };
  1317. },
  1318. failure: failureAJAXFunction
  1319. });
  1320. }
  1321. action(){
  1322. if( !this.mPaused ){
  1323. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1324. //debugger;
  1325. var zz = document.getElementById('hpl_time_mon');
  1326. if( zz != undefined ){
  1327. zz.innerHTML = ts2dts( this.currentTime );
  1328. };
  1329. //Check videos
  1330. if( this.rVideos.length ){
  1331. var fid = -1;
  1332. for(var i=0; i<this.rVideos.length; i++ ){
  1333. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  1334. fid = i;
  1335. break;
  1336. };
  1337. };
  1338. if( fid < 0 ){
  1339. //No Segments for Now;
  1340. this.rVideoJS_playing = false;
  1341. } else {
  1342. if( this.rVideoJS_cid != fid ){
  1343. this.rVideoJS_cid = fid;
  1344. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1345. this.rVideoJS.src( ns );
  1346. };
  1347. this.rVideoJS_playing = true;
  1348. };
  1349. if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  1350. };
  1351. if( this.lVideos.length ){
  1352. var fid = -1;
  1353. for(var i=0; i<this.lVideos.length; i++ ){
  1354. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  1355. fid = i;
  1356. break;
  1357. };
  1358. };
  1359. if( fid < 0 ){
  1360. //No Segments for Now;
  1361. this.lVideoJS_playing = false;
  1362. } else {
  1363. if( this.lVideoJS_cid != fid ){
  1364. this.lVideoJS_cid = fid;
  1365. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1366. this.lVideoJS.src( ns );
  1367. };
  1368. this.lVideoJS_playing = true;
  1369. };
  1370. if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1371. };
  1372. if( this.Events.length ){
  1373. var sid = -1;
  1374. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  1375. sid = i;
  1376. break;
  1377. };
  1378. if( sid > -1 ){
  1379. for( var i=0; i< max_grad_levels; i++ ){
  1380. var cid = sid-i;
  1381. var csize = getSize( i );
  1382. //debugger;
  1383. if( typeof this.mSvgElements[i] === 'undefined') {
  1384. if( cid > -1 ){
  1385. var svgns = "http://www.w3.org/2000/svg";
  1386. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1387. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1388. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1389. this.mSvgElements[i].setAttribute('height', ''+csize);
  1390. this.mSvgElements[i].setAttribute('width', ''+csize);
  1391. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1392. var tt = document.getElementById('svgTrackMap');
  1393. var zz = document.getElementById('scheme_anch');
  1394. tt.insertBefore( this.mSvgElements[i], zz );
  1395. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1396. };
  1397. } else {
  1398. if( cid > -1 ){
  1399. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1400. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1401. this.mSvgElements[i].setAttribute('height', ''+csize);
  1402. this.mSvgElements[i].setAttribute('width', ''+csize);
  1403. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1404. } else {
  1405. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1406. };
  1407. };
  1408. };
  1409. } else
  1410. for( var i=0; i< max_grad_levels; i++ )
  1411. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1412. };
  1413. var tt = Ext.getCmp('hpl_slider');
  1414. if( tt!= undefined ){
  1415. tt.suspendEvents();
  1416. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  1417. tt.resumeEvents();
  1418. };
  1419. this.currentTime += 250;
  1420. if( this.currentTime > this.endTime ) if( this.mLooping ){
  1421. this.currentTime = 0;
  1422. } else {
  1423. //Stop
  1424. this.play();
  1425. };
  1426. };
  1427. }
  1428. play(){
  1429. var zz = Ext.getCmp( 'hpl_pl_btn' );
  1430. if( this.mPaused ){
  1431. this.mPaused = false;
  1432. if( this.rVideoJS_playing ) this.rVideoJS.play();
  1433. if( this.lVideoJS_playing ) this.lVideoJS.play();
  1434. zz.setIconClass( 'plr_op_pause' );
  1435. zz.setText('Pause');
  1436. } else {
  1437. this.mPaused = true;
  1438. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  1439. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  1440. zz.setIconClass( 'plr_op_play' );
  1441. zz.setText('Play');
  1442. };
  1443. this.action();
  1444. //if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  1445. }
  1446. pause(){
  1447. this.mPaused = true;
  1448. }
  1449. toggleLoop(){
  1450. this.mLooping = !this.mLooping;
  1451. if( this.mLooping ) if( this.currentTime > this.endTime ){
  1452. this.currentTime = 0;
  1453. // Start
  1454. this.play();
  1455. };
  1456. }
  1457. setPosition( pos_time ){
  1458. this.currentTime = this.startTime + pos_time*1000;
  1459. var zz = document.getElementById('hpl_time_mon');
  1460. zz.innerHTML = ts2dts( this.currentTime );
  1461. }
  1462. onLVideoEnd(){
  1463. }
  1464. onRVideoEnd(){
  1465. }
  1466. dispose(){
  1467. if( this.mTimer != null ) clearInterval( this.mTimer );
  1468. this.mTimer = null;
  1469. if( this.rVideoJS!= null ){
  1470. this.rVideoJS.dispose();
  1471. this.rVideoJS = null;
  1472. };
  1473. if( this.lVideoJS!= null ){
  1474. this.lVideoJS.dispose();
  1475. this.lVideoJS = null;
  1476. };
  1477. }
  1478. }
  1479. // canvas aproach ///////////////////////////////////////////
  1480. /*
  1481. const player = videojs('my-video');
  1482. let nextTimestamp = 0;
  1483. let rafId = null;
  1484. function tick() {
  1485. if (player.paused() || player.ended())
  1486. return;
  1487. const t = player.currentTime();
  1488. while (t >= nextTimestamp) {
  1489. player.trigger({
  1490. type: 'videotick',
  1491. timestamp: nextTimestamp
  1492. });
  1493. nextTimestamp += 0.1;
  1494. }
  1495. rafId = requestAnimationFrame(tick);
  1496. }
  1497. player.on('play', () => {
  1498. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  1499. cancelAnimationFrame(rafId);
  1500. rafId = requestAnimationFrame(tick);
  1501. });
  1502. player.on('pause', () => cancelAnimationFrame(rafId));
  1503. player.on('ended', () => cancelAnimationFrame(rafId));
  1504. player.on('seeking', () => {
  1505. nextTimestamp = Math.floor(player.currentTime() * 10) / 10 + 0.1;
  1506. });
  1507. player.on('videotick', (e) => {
  1508. console.log(e.timestamp);
  1509. });
  1510. */
  1511. class _argusSessionPlayer{
  1512. sessionId;
  1513. mMapID;
  1514. startTime;
  1515. endTime;
  1516. currentTime;
  1517. rVideoJS = null;
  1518. lVideoJS = null;
  1519. rVideoJS_id = null;
  1520. lVideoJS_id = null;
  1521. rVideoJS_playing = false;
  1522. lVideoJS_playing = false;
  1523. rVideoJS_cid = -1;
  1524. lVideoJS_cid = -1;
  1525. mapLayout;
  1526. lVideos;
  1527. rVideos;
  1528. Events;
  1529. basePath;
  1530. mTimer = null;
  1531. mPaused = true;
  1532. mLooping = true;
  1533. mSvgElements;//076.png
  1534. constructor( session_id ) {
  1535. this.sessionId = session_id;
  1536. this.currentTime = 0;
  1537. this.startTime = 0;
  1538. this.endTime = 0;
  1539. this.lVideos = [];
  1540. this.rVideos = [];
  1541. this.Events = [];
  1542. this.mSvgElements = [];
  1543. Ext.Ajax.request({
  1544. url: '/lib/controller/getSessionData.php',
  1545. params: {
  1546. SESSION: this.sessionId,
  1547. UID: <?=$UserID;?>,
  1548. SID: '<?=$Session;?>'
  1549. },
  1550. success: function( response, opts ){
  1551. var data = Ext.decode( response.responseText );
  1552. //debugger;
  1553. if( data.status == 'ok' ){
  1554. mSesPlay.mapLayout = data.layout;
  1555. //mSesPlay.rVideoJS = document.getElementById( 'video_obj_'+data.r_module_id );
  1556. //mSesPlay.lVideoJS = document.getElementById( 'video_obj_'+data.l_module_id );
  1557. mSesPlay.mMapID = document.getElementById( 'plat_map_'+data.track_id );
  1558. //debugger;
  1559. if( data.data_ok ){
  1560. if( data.r_module_id ){
  1561. mSesPlay.rVideoJS_id = 'video_player_'+data.r_module_id;
  1562. mSesPlay.rVideoJS = videojs( mSesPlay.rVideoJS_id );
  1563. //mSesPlay.rVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  1564. mSesPlay.rVideoJS.on("click", function(){ mSesPlay.play(); });
  1565. mSesPlay.rVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.rVideoJS_id );});
  1566. };
  1567. mSesPlay.startTime = data.start_ts;
  1568. mSesPlay.endTime = data.start_ts + data.length;
  1569. mSesPlay.basePath = window.location.origin + data.basepath +'/';
  1570. mSesPlay.rVideos = [];
  1571. mSesPlay.lVideos = [];
  1572. if( data.videos.length ){
  1573. for( var i=0; i < data.videos.length; i++ )
  1574. if( data.videos[i].side == 'R' ) mSesPlay.rVideos.push( data.videos[i] ); else mSesPlay.lVideos.push( data.videos[i] );
  1575. };
  1576. if( data.events.length ) mSesPlay.Events = data.events;
  1577. var tt = Ext.getCmp('hpl_slider');
  1578. tt.setMinValue( 0 );
  1579. tt.setMaxValue( data.length / 1000 );
  1580. drawSessionDataOnSlider( mSesPlay.startTime/1000, mSesPlay.endTime/1000, data.events, data.videos );
  1581. //player.on('ended', function() {
  1582. // this.dispose();
  1583. //});
  1584. //alert( data.basepath +'/'+data.videos[0].name );
  1585. //mSesPlay.rVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  1586. //mSesPlay.rVideoJS.ready(function() {
  1587. //mSesPlay.rVideoJS.play();
  1588. //var howLoudIsIt = player.volume();
  1589. //mSesPlay.rVideoJS.volume( 0.0 ); // Set volume to half
  1590. //});
  1591. //mSesPlay.rVideoJS.on("timeupdate", function(){
  1592. // method will be calledd each 250 msecs
  1593. //});
  1594. if( data.l_module_id ){
  1595. mSesPlay.lVideoJS_id = 'video_player_'+data.l_module_id;
  1596. mSesPlay.lVideoJS = videojs( mSesPlay.lVideoJS_id );
  1597. //mSesPlay.lVideoJS.poster( window.location.origin + '/style/assets/no-signal_h.png' );
  1598. //mSesPlay.lVideoJS.src({type: 'video/mp4', src: window.location.origin + data.basepath +'/'+data.videos[0].name });
  1599. //mSesPlay.lVideoJS.ready(function() {
  1600. //mSesPlay.rVideoJS.play();
  1601. //var howLoudIsIt = player.volume();
  1602. // mSesPlay.lVideoJS.volume( 0.0 ); // Set volume to half
  1603. //});
  1604. mSesPlay.lVideoJS.on("click", function(){ mSesPlay.play(); });
  1605. mSesPlay.lVideoJS.on("dblclick", function(){ fullScreen( mSesPlay.lVideoJS_id );});
  1606. };
  1607. //mSesPlay.lVideoJS.on("timeupdate", function(){
  1608. // // method will be calledd each 250 msecs
  1609. //});
  1610. mSesPlay.setPosition( 0 );
  1611. } else {
  1612. Ext.Msg.show({
  1613. title:'<?=$Labels->GetLabel('_SESSION_DATA_');?>',
  1614. msg: '<?=$Labels->GetLabel('_SESS_DATA_NOTF_');?>',
  1615. buttons: Ext.Msg.OK,
  1616. icon: Ext.MessageBox.ERROR
  1617. });
  1618. }
  1619. };
  1620. },
  1621. failure: failureAJAXFunction
  1622. });
  1623. }
  1624. action(){
  1625. if( !this.mPaused ){
  1626. if( this.currentTime == 0 ) this.currentTime = this.startTime;
  1627. var zz = document.getElementById('hpl_time_mon');
  1628. //debugger;
  1629. if( zz != undefined ){
  1630. zz.innerHTML = ts2dts( this.currentTime );
  1631. };
  1632. //Check videos
  1633. if( this.rVideos.length ){
  1634. var fid = -1;
  1635. for(var i=0; i<this.rVideos.length; i++ ){
  1636. if( this.currentTime >= this.rVideos[i].sts && this.currentTime <= (this.rVideos[i].sts+60000) ){
  1637. fid = i;
  1638. break;
  1639. };
  1640. };
  1641. if( fid < 0 ){
  1642. //No Segments for Now;
  1643. this.rVideoJS_playing = false;
  1644. } else {
  1645. if( this.rVideoJS_cid != fid ){
  1646. this.rVideoJS_cid = fid;
  1647. var ns = {type: 'video/mp4', src: this.basePath + this.rVideos[this.rVideoJS_cid].name };
  1648. this.rVideoJS.src( ns );
  1649. };
  1650. this.rVideoJS_playing = true;
  1651. };
  1652. if( this.rVideoJS_playing ) this.rVideoJS.currentTime( ( this.currentTime - this.rVideos[this.rVideoJS_cid].sts ) / 1000 );
  1653. };
  1654. if( this.lVideos.length ){
  1655. var fid = -1;
  1656. for(var i=0; i<this.lVideos.length; i++ ){
  1657. if( this.currentTime >= this.lVideos[i].sts && this.currentTime <= (this.lVideos[i].sts+60000) ){
  1658. fid = i;
  1659. break;
  1660. };
  1661. };
  1662. if( fid < 0 ){
  1663. //No Segments for Now;
  1664. this.lVideoJS_playing = false;
  1665. } else {
  1666. if( this.lVideoJS_cid != fid ){
  1667. this.lVideoJS_cid = fid;
  1668. var ns = {type: 'video/mp4', src: this.basePath + this.lVideos[this.lVideoJS_cid].name };
  1669. this.lVideoJS.src( ns );
  1670. };
  1671. this.lVideoJS_playing = true;
  1672. };
  1673. if( this.lVideoJS_playing ) this.lVideoJS.currentTime( ( this.currentTime - this.lVideos[this.lVideoJS_cid].sts ) / 1000 );
  1674. };
  1675. if( this.Events.length ){
  1676. var sid = -1;
  1677. for( var i= this.Events.length-1; i > -1; i--) if( this.Events[i].ts < this.currentTime ) {
  1678. sid = i;
  1679. break;
  1680. };
  1681. if( sid > -1 ){
  1682. for( var i=0; i< max_grad_levels; i++ ){
  1683. var cid = sid-i;
  1684. var csize = getSize( i );
  1685. //debugger;
  1686. if( typeof this.mSvgElements[i] === 'undefined') {
  1687. if( cid > -1 ){
  1688. var svgns = "http://www.w3.org/2000/svg";
  1689. this.mSvgElements[i] = document.createElementNS(svgns, 'rect');
  1690. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1691. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1692. this.mSvgElements[i].setAttribute('height', ''+csize);
  1693. this.mSvgElements[i].setAttribute('width', ''+csize);
  1694. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i));
  1695. var tt = document.getElementById('svgTrackMap');
  1696. var zz = document.getElementById('scheme_anch');
  1697. tt.insertBefore( this.mSvgElements[i], zz );
  1698. //document.getElementById('svgTrackMap').appendChild(this.mSvgElements[i]);
  1699. };
  1700. } else {
  1701. if( cid > -1 ){
  1702. this.mSvgElements[i].setAttribute('x', this.Events[cid].x+'%');
  1703. this.mSvgElements[i].setAttribute('y', ''+(50+(100-csize)/2) );
  1704. this.mSvgElements[i].setAttribute('height', ''+csize);
  1705. this.mSvgElements[i].setAttribute('width', ''+csize);
  1706. this.mSvgElements[i].setAttribute('fill', '#FF0000'+getTransperecy(i) );
  1707. } else {
  1708. this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1709. };
  1710. };
  1711. };
  1712. } else
  1713. for( var i=0; i< max_grad_levels; i++ )
  1714. if( typeof this.mSvgElements[i] !== 'undefined') this.mSvgElements[i].setAttribute('fill', '#FF000000');
  1715. };
  1716. var tt = Ext.getCmp('hpl_slider');
  1717. if( tt!= undefined ){
  1718. tt.suspendEvents();
  1719. tt.setValue( ( this.currentTime - this.startTime ) / 1000, true );
  1720. tt.resumeEvents();
  1721. };
  1722. this.currentTime += 250;
  1723. if( this.currentTime > this.endTime ) if( this.mLooping ){
  1724. this.currentTime = 0;
  1725. } else {
  1726. //Stop
  1727. this.play();
  1728. };
  1729. };
  1730. }
  1731. play(){
  1732. var zz = Ext.getCmp( 'hpl_pl_btn' );
  1733. if( this.mPaused ){
  1734. this.mPaused = false;
  1735. if( this.rVideoJS_playing ) this.rVideoJS.play();
  1736. if( this.lVideoJS_playing ) this.lVideoJS.play();
  1737. zz.setIconClass( 'plr_op_pause' );
  1738. zz.setText('Pause');
  1739. } else {
  1740. this.mPaused = true;
  1741. if( this.rVideoJS_playing ) this.rVideoJS.pause();
  1742. if( this.lVideoJS_playing ) this.lVideoJS.pause();
  1743. zz.setIconClass( 'plr_op_play' );
  1744. zz.setText('Play');
  1745. };
  1746. if( this.mTimer == null ) this.mTimer = window.setInterval( this.action.bind(this), 250 );
  1747. }
  1748. pause(){
  1749. this.mPaused = true;
  1750. }
  1751. toggleLoop(){
  1752. this.mLooping = !this.mLooping;
  1753. if( this.mLooping ) if( this.currentTime > this.endTime ){
  1754. this.currentTime = 0;
  1755. // Start
  1756. this.play();
  1757. };
  1758. }
  1759. setPosition( pos_time ){
  1760. this.currentTime = this.startTime + pos_time*1000;
  1761. var zz = document.getElementById('hpl_time_mon');
  1762. zz.innerHTML = ts2dts( this.currentTime );
  1763. }
  1764. onLVideoEnd(){
  1765. }
  1766. onRVideoEnd(){
  1767. }
  1768. dispose(){
  1769. if( this.mTimer != null ) clearInterval( this.mTimer );
  1770. this.mTimer = null;
  1771. if( this.rVideoJS!= null ){
  1772. this.rVideoJS.dispose();
  1773. this.rVideoJS = null;
  1774. };
  1775. if( this.lVideoJS!= null ){
  1776. this.lVideoJS.dispose();
  1777. this.lVideoJS = null;
  1778. };
  1779. }
  1780. }
  1781. function loadHistorySessionView( session_id ){
  1782. autoRiseEvent = false;
  1783. rep_selectedEventId = session_id;
  1784. Ext.Ajax.request({
  1785. url: '/lib/controller/getHistorySessionView.php',
  1786. params: {
  1787. SESSION: rep_selectedEventId,
  1788. UID: <?=$UserID;?>,
  1789. SID: '<?=$Session;?>'
  1790. },
  1791. success: function( response, opts ){
  1792. var data = Ext.decode(response.responseText);
  1793. if( data.status == 'ok' ){
  1794. monitoringViewLevel = 5;
  1795. if( mSesPlay!= null ) {
  1796. mSesPlay.dispose();
  1797. mSesPlay = null;
  1798. };
  1799. Ext.getCmp('main_content').removeAll(true);
  1800. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  1801. Ext.getCmp('main_content').doLayout();
  1802. changeContent( 2, 5, rep_selectedStation+'-'+rep_selectedDateTS+'-'+rep_selectedEventId );
  1803. updateUserContent();
  1804. mSesPlay = new argusSessionPlayer( rep_selectedEventId , true );
  1805. fetchStatus();
  1806. };
  1807. },
  1808. failure: failureAJAXFunction
  1809. });
  1810. };
  1811. function deleteSession( session_id ){
  1812. if( session_id == 0 ) return;
  1813. Ext.Msg.show({
  1814. title:'<?=$Labels->GetLabel('_RYS_DEL_SES_');?>',
  1815. msg: '<?=$Labels->GetLabel('_RYS_DEL_SESSION_');?>',
  1816. buttons: Ext.Msg.YESNOCANCEL,
  1817. icon: Ext.MessageBox.QUESTION,
  1818. fn: function(btn, text){
  1819. if( btn == 'yes' ){
  1820. Ext.Ajax.request({
  1821. url: '/lib/controller/doSessionOperations.php',
  1822. params: {
  1823. SESSION: session_id,
  1824. OPID: 1,
  1825. UID: <?=$UserID;?>,
  1826. SID: '<?=$Session;?>'
  1827. },
  1828. success: function( response, opts ){
  1829. Ext.Msg.hide();
  1830. var data = Ext.decode(response.responseText);
  1831. if( data.status == 'ok' ){
  1832. getBackToMap();
  1833. } else {
  1834. Ext.Msg.show({
  1835. title:'<?=$Labels->GetLabel('_ERROR_MSG_');?>',
  1836. msg: data.msg,
  1837. buttons: Ext.Msg.OK,
  1838. icon: Ext.MessageBox.ERROR
  1839. });
  1840. };
  1841. },
  1842. failure: failureAJAXFunction
  1843. });
  1844. };
  1845. }
  1846. });
  1847. };
  1848. function loadHistoryStationEvt( e ){
  1849. loadHistoryStation( e.target.options.mycustomid );
  1850. };
  1851. function loadHistoryStation( STT, buba ){
  1852. if( buba == undefined ){
  1853. autoRiseEvent = false;
  1854. } else {
  1855. autoRiseEvent = buba;
  1856. };
  1857. rep_selectedStation = STT;
  1858. changeContent( 2, 1, rep_selectedStation );
  1859. updateUserContent();
  1860. Ext.Ajax.request({
  1861. url: '/lib/controller/getHistoryStationView.php',
  1862. params: {
  1863. STT: rep_selectedStation,
  1864. UID: <?=$UserID;?>,
  1865. SID: '<?=$Session;?>'
  1866. },
  1867. success: function( response, opts ){
  1868. var data = Ext.decode(response.responseText);
  1869. if( data.status == 'ok' ){
  1870. Ext.getCmp('main_content').removeAll(true);
  1871. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  1872. Ext.getCmp('main_content').doLayout();
  1873. Ext.getCmp('left_side_menu').removeAll(true);
  1874. Ext.getCmp('left_side_menu').add({
  1875. xtype: 'panel',
  1876. frame: true,
  1877. border: false,
  1878. items: [{
  1879. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
  1880. height: PanelH - 30
  1881. }]
  1882. });
  1883. Ext.getCmp('left_side_menu').doLayout();
  1884. } else {
  1885. };
  1886. },
  1887. failure: failureAJAXFunction
  1888. });
  1889. };
  1890. function loadReportDayTree( ts ){
  1891. ReportSelectionMode = 1;//Day Selected
  1892. rep_selectedDateTS = ts;
  1893. //ReportMask = new Ext.LoadMask(Ext.getCmp('left_side_menu').getEl(), {msg:"Please wait..."});
  1894. //ReportMask.show();
  1895. Ext.Ajax.request({
  1896. url: '/lib/controller/getHistoryDay.php',
  1897. params: {
  1898. UID: <?=$UserID;?>,
  1899. SID: '<?=$Session;?>',
  1900. STT: rep_selectedStation,
  1901. DTS: rep_selectedDateTS
  1902. },
  1903. success: function(response, opts ){
  1904. var data = Ext.decode( response.responseText );
  1905. var sPanel = Ext.getCmp('left_side_menu');
  1906. sPanel.removeAll( true );
  1907. sPanel.add({
  1908. xtype: 'panel',
  1909. layout: 'vbox',
  1910. frame: true,
  1911. border: false,
  1912. items:[{
  1913. xtype: 'spacer',
  1914. height: 3
  1915. },{
  1916. 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>',
  1917. frame: false,
  1918. width: '100%',
  1919. border: false
  1920. },{
  1921. xtype: 'spacer',
  1922. height: 5
  1923. },{
  1924. xtype: 'treepanel',
  1925. autoScroll: true,
  1926. width: '100%',
  1927. height: PanelH-206,
  1928. border: true,
  1929. frame: true,
  1930. loader: new Ext.tree.TreeLoader(),
  1931. rootVisible: false,
  1932. root: new Ext.tree.AsyncTreeNode( data ),
  1933. listeners: {
  1934. click: function(n) {
  1935. if( n.attributes.leaf ){
  1936. Ext.getCmp('chu_adate').show();
  1937. sPanel.doLayout();
  1938. loadHistorySessionView( n.attributes.sid );
  1939. };
  1940. }
  1941. }
  1942. },{
  1943. xtype: 'spacer',
  1944. height: 10
  1945. },{
  1946. xtype: 'button',
  1947. id: 'chu_adate',
  1948. text: 'Show Dates',
  1949. hidden: true,
  1950. width: '100%',
  1951. iconCls: 'reports_dates_btn',
  1952. scale: 'large',
  1953. handler: function(){
  1954. Ext.getCmp('chu_adate').hide();
  1955. loadHistoryStation( rep_selectedStation );
  1956. }
  1957. }]
  1958. });
  1959. sPanel.doLayout();
  1960. changeContent( 2, 2, rep_selectedStation+'-'+rep_selectedDateTS );
  1961. updateUserContent();
  1962. //ReportMask.hide();
  1963. }
  1964. });
  1965. };
  1966. function noHistDialog(){
  1967. Ext.Msg.show({
  1968. title:'<?=$Labels->GetLabel('_GEN_MSG_');?>',
  1969. msg: '<?=$Labels->GetLabel('_NO_REPORTS_4_STATION_');?>',
  1970. buttons: Ext.Msg.OK,
  1971. icon: Ext.MessageBox.INFO
  1972. });
  1973. };
  1974. var history_map = null;
  1975. function initHistoryMap( map_id, x, y ){
  1976. if( tlInterval!= null ){
  1977. window.clearTimeout( tlInterval );
  1978. tlInterval = null;
  1979. };
  1980. var mapLayers = [];
  1981. if( history_map != null ){
  1982. history_map.off();
  1983. history_map.remove();
  1984. history_map = null;
  1985. };
  1986. history_map = L.map( map_id,{
  1987. crs: L.CRS.Simple,
  1988. attributionControl: false,
  1989. preferCanvas: true,
  1990. zoomControl: true,
  1991. center: [x,y],
  1992. zoom: 0,
  1993. minZoom: -3,
  1994. maxZoom: 0,
  1995. keyboard: false
  1996. });
  1997. var bounds = [[SCHEMATIC_SET.bounds_lx,SCHEMATIC_SET.bounds_ly], [SCHEMATIC_SET.bounds_rx,SCHEMATIC_SET.bounds_ry]];
  1998. var image = L.imageOverlay( SCHEMATIC_SET.layer_url, bounds ).addTo( history_map );
  1999. Ext.Ajax.request({
  2000. url: '/lib/controller/listHistoryStations.php',
  2001. params: {
  2002. UID: <?=$UserID;?>,
  2003. SID: '<?=$Session;?>'
  2004. },
  2005. success: function( response, opts ){
  2006. var data = Ext.decode(response.responseText);
  2007. if( data.status == 'ok' ){
  2008. for( i=0; i < data.stations.length; i++ ){
  2009. if( data.stations[i].status ){
  2010. 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 );
  2011. } else {
  2012. 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 );
  2013. };
  2014. };
  2015. };
  2016. },
  2017. failure: failureAJAXFunction
  2018. });
  2019. };
  2020. function getBackToHistoryMap(){
  2021. autoRiseEvent = false;
  2022. changeContent( 2, 0 );
  2023. updateUserContent();
  2024. var tP = Ext.getCmp('left_side_menu');
  2025. tP.removeAll( true );
  2026. tP.add({
  2027. layout:'vbox',
  2028. frame: false,
  2029. border: false,
  2030. items:[{
  2031. xtype: 'panel',
  2032. frame: true,
  2033. border: false,
  2034. items: [{
  2035. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_STA_ONMAP_');?></div>',
  2036. height: PanelH - 30
  2037. }]
  2038. }]
  2039. });
  2040. tP.doLayout();
  2041. loadHistoryMapView();
  2042. };
  2043. function loadHistoryMapView(){
  2044. autoRiseEvent = false;
  2045. Ext.Ajax.request({
  2046. url: '/lib/controller/getHistoryMapView.php',
  2047. params: {
  2048. UID: <?=$UserID;?>,
  2049. SID: '<?=$Session;?>'
  2050. },
  2051. success: function( response, opts ){
  2052. var data = Ext.decode(response.responseText);
  2053. if( data.status == 'ok' ){
  2054. monitoringViewLevel = 0;
  2055. Ext.getCmp('main_content').removeAll(true);
  2056. Ext.getCmp('main_content').add( Ext.decode( data.content ) );
  2057. Ext.getCmp('main_content').doLayout();
  2058. };
  2059. },
  2060. failure: failureAJAXFunction
  2061. });
  2062. return;
  2063. };
  2064. function initReportsView(){
  2065. if( tlInterval!= null ){
  2066. window.clearInterval( tlInterval );
  2067. tlInterval = null;
  2068. timelineObj = null;
  2069. };
  2070. var tP = Ext.getCmp('left_side_menu');
  2071. tP.removeAll( true );
  2072. tP.add({
  2073. layout:'vbox',
  2074. frame: false,
  2075. border: false,
  2076. items:[{
  2077. xtype: 'panel',
  2078. frame: true,
  2079. border: false,
  2080. items: [{
  2081. html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel("_PLS_SEL_STA_ONMAP_");?></div>',
  2082. height: PanelH - 30
  2083. }]
  2084. }]
  2085. });
  2086. tP.doLayout();
  2087. monitoringViewLevel = contentView.l[2].v;
  2088. switch( monitoringViewLevel ){
  2089. case 0:{
  2090. loadHistoryMapView();
  2091. break;
  2092. };
  2093. case 1:{
  2094. loadHistoryStation( parseInt( contentView.l[2].p ), autoRiseEvent );
  2095. break;
  2096. };
  2097. case 2:{
  2098. var tA = contentView.l[2].p.split('-');
  2099. rep_selectedStation = parseInt( tA[0] );
  2100. rep_selectedDateTS = parseInt( tA[1] );
  2101. loadHistoryStation( rep_selectedStation, autoRiseEvent );
  2102. loadReportDayTree( rep_selectedDateTS );
  2103. break;
  2104. };
  2105. case 5:{
  2106. var tA = contentView.l[2].p.split('-');
  2107. rep_selectedStation = parseInt( tA[0] );
  2108. rep_selectedDateTS = parseInt( tA[1] );
  2109. rep_selectedEventId = parseInt( tA[2] );
  2110. loadReportDayTree( rep_selectedDateTS );
  2111. loadHistorySessionView( rep_selectedEventId );
  2112. break;
  2113. };
  2114. };
  2115. //Ext.getCmp('main_content').doLayout();
  2116. };