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.

1170 lines
31 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var resourceInfoWindow = null;
  3. var settingsAreChanged = false;
  4. var settingsChanged = [];
  5. function settingsChangeNotifier( A ){
  6. settingsAreChanged = true;
  7. if( !settingsChanged.includes( A ) ){
  8. settingsChanged[settingsChanged.length] = A;
  9. };
  10. };
  11. function cleanupChangeNotifier(){
  12. settingsAreChanged = false;
  13. settingsChanged = [];
  14. };
  15. function removeAllFromSite(){
  16. Ext.Msg.show({
  17. title:'<?=$Labels->GetLabel('_CLEAR_SITE_');?>',
  18. msg: '<?=$Labels->GetLabel('_SITE_DEL_ALL_ABO_');?>',
  19. buttons: Ext.Msg.YESNO,
  20. icon: Ext.MessageBox.WARNING,
  21. fn: function(btn, text){
  22. if (btn == 'yes'){
  23. Ext.Ajax.request({
  24. url: '/lib/controller/resetAllSettings.php',
  25. params: {
  26. SAID: SelectedSite,
  27. UID: <?=$UserID;?>,
  28. SID: '<?=$Session;?>'
  29. },
  30. success: function( response, opts ){
  31. doRefresh();
  32. },
  33. failure: failureAJAXFunction
  34. });
  35. };
  36. }
  37. });
  38. };
  39. function showResourceInfo( rid ){
  40. Ext.Ajax.request({
  41. url: '/lib/controller/getResourceInfo.php',
  42. params: {
  43. RID: rid,
  44. UID: <?=$UserID;?>,
  45. SID: '<?=$Session;?>',
  46. },
  47. success: function( response, opts ){
  48. var data = Ext.decode(response.responseText);
  49. if( resourceInfoWindow == null ){
  50. resourceInfoWindow = new Ext.Window({
  51. title: '<?=$Labels->GetLabel('_RES_INFO_');?>',
  52. modal: true,
  53. width: 800,
  54. height: 400,
  55. resizable: false,
  56. layout: 'fit',
  57. closeAction: 'hide',
  58. items: [],
  59. buttons:[{
  60. text: `close`,
  61. handler: function(){
  62. resourceInfoWindow.hide();
  63. }
  64. }]
  65. });
  66. };
  67. resourceInfoWindow.removeAll( true );
  68. resourceInfoWindow.add( data );
  69. resourceInfoWindow.show();
  70. },
  71. failure: failureAJAXFunction
  72. });
  73. };
  74. var settingsWindow = null;
  75. function showSettings( nid, tab = 0 ){
  76. Ext.Ajax.request({
  77. url: '/lib/controller/getNodeSettings.php',
  78. params: {
  79. NID: nid,
  80. TAB: tab,
  81. UID: <?=$UserID;?>,
  82. SID: '<?=$Session;?>',
  83. },
  84. success: function( response, opts ){
  85. var data = Ext.decode( response.responseText );
  86. if( settingsWindow == null ){
  87. settingsWindow = new Ext.Window({
  88. title: '<?=$Labels->GetLabel('_SETTINGS_');?>',
  89. modal: true,
  90. resizable: false,
  91. width: 800,
  92. height: 400,
  93. layout: 'fit',
  94. closeAction: 'hide',
  95. items: [],
  96. buttons:[{
  97. text: `<?=$Labels->GetLabel('_CLOSE_');?>`,
  98. handler: function(){
  99. if( settingsAreChanged ){
  100. Ext.Msg.show({
  101. title:'<?=$Labels->GetLabel('_SETTINGS_CHANGED_');?>',
  102. msg: '<?=$Labels->GetLabel('_SET_CHANGED_WOULD_SAVE_');?>',
  103. buttons: Ext.Msg.YESNO,
  104. icon: Ext.MessageBox.WARNING,
  105. fn: function(btn, text){
  106. if( btn == 'yes' ){
  107. cleanupChangeNotifier();
  108. settingsWindow.hide();
  109. } else {
  110. var TT = Ext.getCmp('node_settings_content');
  111. TT.updateSettings();
  112. };
  113. }
  114. });
  115. } else {
  116. settingsWindow.hide();
  117. };
  118. }
  119. }]
  120. });
  121. };
  122. settingsWindow.show();
  123. settingsWindow.removeAll( true );
  124. settingsWindow.add( data );
  125. settingsWindow.doLayout();
  126. },
  127. failure: failureAJAXFunction
  128. });
  129. };
  130. function editResource( rid ){
  131. var loadEditor = true;
  132. if( settingsAreChanged ){
  133. Ext.Msg.show({
  134. title:'<?=$Labels->GetLabel('_SETTINGS_CHANGED_');?>',
  135. msg: '<?=$Labels->GetLabel('_SET_CHANGED_WOULD_SAVE_');?>',
  136. buttons: Ext.Msg.YESNO,
  137. icon: Ext.MessageBox.WARNING,
  138. fn: function(btn, text){
  139. if( btn == 'yes' ){
  140. cleanupChangeNotifier();
  141. } else {
  142. loadEditor = false;
  143. };
  144. }
  145. });
  146. };
  147. if( loadEditor ){
  148. Ext.Ajax.request({
  149. url: '/lib/controller/getResourceEditor.php',
  150. params: {
  151. RID: rid,
  152. UID: <?=$UserID;?>,
  153. SID: '<?=$Session;?>',
  154. },
  155. success: function( response, opts ){
  156. var data = Ext.decode(response.responseText);
  157. var resourceEdPanel = Ext.getCmp('res_ed_small');
  158. if( resourceEdPanel ){
  159. resourceEdPanel.removeAll( true );
  160. resourceEdPanel.add( data );
  161. resourceEdPanel.doLayout();
  162. };
  163. },
  164. failure: failureAJAXFunction
  165. });
  166. };
  167. };
  168. function editModule( mid ){
  169. var loadEditor = true;
  170. if( settingsAreChanged ){
  171. Ext.Msg.show({
  172. title:'<?=$Labels->GetLabel('_SETTINGS_CHANGED_');?>',
  173. msg: '<?=$Labels->GetLabel('_SET_CHANGED_WOULD_SAVE_');?>',
  174. buttons: Ext.Msg.YESNO,
  175. icon: Ext.MessageBox.WARNING,
  176. fn: function(btn, text){
  177. if( btn == 'yes' ){
  178. cleanupChangeNotifier();
  179. } else {
  180. loadEditor = false;
  181. };
  182. }
  183. });
  184. };
  185. if( loadEditor ){
  186. Ext.Ajax.request({
  187. url: '/lib/controller/getModuleEditor.php',
  188. params: {
  189. MID: mid,
  190. UID: <?=$UserID;?>,
  191. SID: '<?=$Session;?>',
  192. },
  193. success: function( response, opts ){
  194. var data = Ext.decode(response.responseText);
  195. var moduleEdPanel = Ext.getCmp('mod_ed_small');
  196. if( moduleEdPanel ){
  197. moduleEdPanel.removeAll( true );
  198. moduleEdPanel.add( data );
  199. moduleEdPanel.doLayout();
  200. };
  201. },
  202. failure: failureAJAXFunction
  203. });
  204. };
  205. };
  206. function editWidthTable( did ){
  207. var loadEditor = true;
  208. if( settingsAreChanged ){
  209. Ext.Msg.show({
  210. title:'<?=$Labels->GetLabel('_SETTINGS_CHANGED_');?>',
  211. msg: '<?=$Labels->GetLabel('_SET_CHANGED_WOULD_SAVE_');?>',
  212. buttons: Ext.Msg.YESNO,
  213. icon: Ext.MessageBox.WARNING,
  214. fn: function(btn, text){
  215. if( btn == 'yes' ){
  216. cleanupChangeNotifier();
  217. } else {
  218. loadEditor = false;
  219. };
  220. }
  221. });
  222. };
  223. if( loadEditor ){
  224. Ext.Ajax.request({
  225. url: '/lib/controller/getWidthTableEditor.php',
  226. params: {
  227. DID: did,
  228. UID: <?=$UserID;?>,
  229. SID: '<?=$Session;?>',
  230. },
  231. success: function( response, opts ){
  232. var data = Ext.decode(response.responseText);
  233. var resourceEdPanel = Ext.getCmp('dep_ed_small');
  234. if( resourceEdPanel ){
  235. resourceEdPanel.removeAll( true );
  236. resourceEdPanel.add( data );
  237. resourceEdPanel.doLayout();
  238. };
  239. },
  240. failure: failureAJAXFunction
  241. });
  242. };
  243. };
  244. function renderer_mask_0( a ){ return ( a & 1 )?'<img src="/style/icons/fam/accept.png">':'<img src="/style/icons/icons/cancel.png">';};
  245. function renderer_mask_1( a ){ return ( a & ( 1 << 1 ) )?'<img src="/style/icons/fam/accept.png">':'<img src="/style/icons/icons/cancel.png">';};
  246. function renderer_mask_2( a ){ return ( a & ( 1 << 2 ) )?'<img src="/style/icons/fam/accept.png">':'<img src="/style/icons/icons/cancel.png">';};
  247. function renderer_mask_3( a ){ return ( a & ( 1 << 3 ) )?'<img src="/style/icons/fam/accept.png">':'<img src="/style/icons/icons/cancel.png">';};
  248. function renderer_mask_4( a ){ return ( a & ( 1 << 4 ) )?'<img src="/style/icons/fam/accept.png">':'<img src="/style/icons/icons/cancel.png">';};
  249. function renderer_day_0( a ){ return ( a & 1 )?'<img src="/style/icons/icons/clock.png">':'';};
  250. function renderer_day_1( a ){ return ( a & ( 1 << 1 ) )?'<img src="/style/icons/icons/clock.png">':'';};
  251. function renderer_day_2( a ){ return ( a & ( 1 << 2 ) )?'<img src="/style/icons/icons/clock.png">':'';};
  252. function renderer_day_3( a ){ return ( a & ( 1 << 3 ) )?'<img src="/style/icons/icons/clock.png">':'';};
  253. function renderer_day_4( a ){ return ( a & ( 1 << 4 ) )?'<img src="/style/icons/icons/clock.png">':'';};
  254. function renderer_day_5( a ){ return ( a & ( 1 << 5 ) )?'<img src="/style/icons/icons/clock.png">':'';};
  255. function renderer_day_6( a ){ return ( a & ( 1 << 6 ) )?'<img src="/style/icons/icons/clock.png">':'';};
  256. function renderer_day_s( a ){ return ( a & ( 1 << 7 ) )?'<img src="/style/icons/icons/clock.png">':'';};
  257. function editMaskSchedule( did ){
  258. var loadEditor = true;
  259. if( settingsAreChanged ){
  260. Ext.Msg.show({
  261. title:'<?=$Labels->GetLabel('_SETTINGS_CHANGED_');?>',
  262. msg: '<?=$Labels->GetLabel('_SET_CHANGED_WOULD_SAVE_');?>',
  263. buttons: Ext.Msg.YESNO,
  264. icon: Ext.MessageBox.WARNING,
  265. fn: function(btn, text){
  266. if( btn == 'yes' ){
  267. cleanupChangeNotifier();
  268. } else {
  269. loadEditor = false;
  270. };
  271. }
  272. });
  273. };
  274. if( loadEditor ){
  275. Ext.Ajax.request({
  276. url: '/lib/controller/getMaskScheduleEditor.php',
  277. params: {
  278. DID: did,
  279. UID: <?=$UserID;?>,
  280. SID: '<?=$Session;?>',
  281. },
  282. success: function( response, opts ){
  283. var data = Ext.decode(response.responseText);
  284. var resourceEdPanel = Ext.getCmp('dep_ed_small');
  285. if( resourceEdPanel ){
  286. resourceEdPanel.removeAll( true );
  287. resourceEdPanel.add( data );
  288. resourceEdPanel.doLayout();
  289. };
  290. },
  291. failure: failureAJAXFunction
  292. });
  293. };
  294. };
  295. function reloadNetworkData(){
  296. Ext.Ajax.request({
  297. url: '/lib/controller/getNetwork.php',
  298. params: {
  299. NID: SelectedSite,
  300. UID: <?=$UserID;?>,
  301. SID: '<?=$Session;?>',
  302. },
  303. success: function( response, opts ){
  304. var data = Ext.decode(response.responseText);
  305. netwodkData.nodes = new vis.DataSet( data.nodes );
  306. netwodkData.edges = new vis.DataSet( data.edges );
  307. networkObj.setData( netwodkData );
  308. networkObj.redraw();
  309. },
  310. failure: failureAJAXFunction
  311. });
  312. };
  313. function createNode( STYPE ){
  314. Ext.Ajax.request({
  315. url: '/lib/controller/addNetworkNode.php',
  316. params: {
  317. NID: <?=$SiteID;?>,
  318. UID: <?=$UserID;?>,
  319. SID: '<?=$Session;?>',
  320. TYPE: STYPE
  321. },
  322. success: function( response, opts ){
  323. reloadNetworkData( <?=$SiteID;?> );
  324. },
  325. failure: failureAJAXFunction
  326. });
  327. };
  328. function removeModule( ID ){
  329. Ext.Msg.show({
  330. title:'Q!',
  331. msg: 'Are you sure delete this Module?',
  332. buttons: Ext.Msg.YESNOCANCEL,
  333. fn: function( btn, text ){
  334. if( btn == 'yes' ){
  335. Ext.Ajax.request({
  336. url: '/lib/controller/doModuleOperation.php',
  337. params: {
  338. OPID: 1,
  339. MID: ID,
  340. UID: <?=$UserID;?>,
  341. SID: '<?=$Session;?>'
  342. },
  343. success: function(){
  344. showSettings( SelectedNodeID, 2 );
  345. }
  346. });
  347. };
  348. },
  349. icon: Ext.MessageBox.QUESTION
  350. });
  351. };
  352. function enableModule( ID ){
  353. Ext.Ajax.request({
  354. url: '/lib/controller/doModuleOperation.php',
  355. params: {
  356. OPID: 2,
  357. OPCODE: 1,
  358. MID: ID,
  359. UID: <?=$UserID;?>,
  360. SID: '<?=$Session;?>'
  361. },
  362. success: function(){
  363. showSettings( SelectedNodeID, 2 );
  364. }
  365. });
  366. };
  367. function disableModule( ID ){
  368. Ext.Ajax.request({
  369. url: '/lib/controller/doModuleOperation.php',
  370. params: {
  371. OPID: 2,
  372. OPCODE: 0,
  373. MID: ID,
  374. UID: <?=$UserID;?>,
  375. SID: '<?=$Session;?>'
  376. },
  377. success: function(){
  378. showSettings( SelectedNodeID, 2 );
  379. }
  380. });
  381. };
  382. var addSensor_window = null;
  383. function addSerialSensor( sensorType ){
  384. if( addSensor_window!= null ){
  385. addSensor_window.hide();
  386. addSensor_window.destroy();
  387. addSensor_window = null;
  388. };
  389. var TTL = '';
  390. var IMG = '';
  391. switch( sensorType ){
  392. case 1: TTL = '<?=$Labels->GetLabel("_DLG_ADD_ALS_");?>'; IMG = '/style/assets/!cid_ii_jvmzuzrm9.png'; break;
  393. case 2: TTL = '<?=$Labels->GetLabel("_DLG_ADD_LFS_");?>'; IMG = '/style/assets/!cid_ii_jvmzuzqb2.png'; break;
  394. case 3: TTL = '<?=$Labels->GetLabel("_DLG_ADD_PLS200_");?>'; IMG = '/style/assets/!cid_ii_jvmzuzqh3.png'; break;
  395. case 4: TTL = '<?=$Labels->GetLabel("_DLG_ADD_PLS360_");?>'; IMG = '/style/assets/!cid_ii_jvmzuzqx6.png'; break;
  396. };
  397. addSensor_window = new Ext.Window({
  398. modal: true,
  399. title: TTL,
  400. width: 400,
  401. height: 400,
  402. layout: 'fit',
  403. closeAction: 'hide',
  404. items:[{
  405. xtype: 'form',
  406. frame: false,
  407. border: false,
  408. hideLabels: false,
  409. labelAlign: 'right', // or 'right' or 'top'
  410. //labelSeparator: '>>', // takes precedence over layoutConfig value
  411. labelWidth: 160, // defaults to 100
  412. labelPad: 8, // defaults to 5, must specify labelWidth to be honored
  413. items:[{
  414. xtype:'panel',
  415. frame: false,
  416. border: false,
  417. html: '<center><img height="180px" src="'+IMG+'"></center>',
  418. height: '200px'
  419. },{
  420. html: '&nbsp;',
  421. frame: false,
  422. border: false,
  423. },{
  424. fieldLabel: '<?=$Labels->GetLabel('_DEVICE_NAME_');?>',
  425. xtype: 'textfield',
  426. width: 200,
  427. id: 'p200_dev_name',
  428. allowBlank: false
  429. },{
  430. xtype: 'combo',
  431. fieldLabel: '<?=$Labels->GetLabel('_SENSOR_MAX_RANGE_');?>',
  432. lazyRender: true,
  433. id: 'p200_range',
  434. width: 200,
  435. mode: 'local',
  436. disabled: false,
  437. forceSelection: true, triggerAction: 'all', editable: false, disableKeyFilter: true,
  438. store: new Ext.data.ArrayStore({
  439. fields: ['range','range_txt'],
  440. data: [[35,'35'],[60,'60'],[120,'120'],[150,'150'],[160,'160'],[200,'200'],[300,'300']]
  441. }),
  442. valueField: 'range',
  443. displayField: 'range_txt'
  444. },{
  445. xtype: 'combo',
  446. fieldLabel: '<?=$Labels->GetLabel('_UART_PORT_');?>',
  447. lazyRender: true,
  448. id: 'p200_uart_id',
  449. width: 200,
  450. disabled: false,
  451. forceSelection: true,
  452. triggerAction: 'all',
  453. editable: false,
  454. disableKeyFilter: true,
  455. store: UartListStore,
  456. valueField: 'uart_id',
  457. displayField: 'uart_name'
  458. },{
  459. fieldLabel: '<?=$Labels->GetLabel('_PROTO_DEVICE_ID_');?>',
  460. xtype: 'numberfield',
  461. id: 'p200_dev_id',
  462. width: 200,
  463. allowBlank: false,
  464. allowNegative: false,
  465. minValue: 0,
  466. maxValue: 255
  467. }],
  468. bbar:[ '->',{
  469. text: '<?=$Labels->GetLabel('_CANCEL_');?>',
  470. handler: function(){
  471. addSensor_window.hide();
  472. }
  473. },{
  474. text: '<?=$Labels->GetLabel('_ADD_');?>',
  475. handler: function(){
  476. var uart_id_val = Ext.getCmp('p200_uart_id').getValue();
  477. var dev_id_val = Ext.getCmp('p200_dev_id').getValue();
  478. var sname = Ext.getCmp('p200_dev_name').getValue();
  479. var range = parseInt( Ext.getCmp('p200_range').getValue());
  480. if( sname != '' && uart_id_val != '' && range > 0 ){
  481. var uart_id = parseInt( uart_id_val );
  482. var dev_id = parseInt( dev_id_val );
  483. Ext.Ajax.request({
  484. url: '/lib/controller/addNetworkNode.php',
  485. params: {
  486. SITEID: <?=$SiteID;?>,
  487. UID: <?=$UserID;?>,
  488. SID: '<?=$Session;?>',
  489. TYPE: sensorType,
  490. SNAME: sname,
  491. RANGE: range,
  492. UART: uart_id,
  493. DEVID: dev_id
  494. },
  495. success: function( response, opts ){
  496. addSensor_window.hide();
  497. reloadNetworkData( <?=$SiteID;?> );
  498. },
  499. failure: failureAJAXFunction
  500. });
  501. } else {
  502. playSound();
  503. Ext.Msg.show({
  504. title:'<?=$Labels->GetLabel('_WRO_VALUES_');?>',
  505. msg: '<?=$Labels->GetLabel('_WRO_VAL_MSG_');?>',
  506. buttons: Ext.Msg.OK,
  507. icon: Ext.MessageBox.INFO
  508. });
  509. };
  510. }
  511. }]
  512. }]
  513. });
  514. if( addSensor_window != null ){
  515. addSensor_window.show();
  516. };
  517. };
  518. var add3D_window = null;
  519. function addSensor_3D(){
  520. if( add3D_window == null ){
  521. add3D_window = new Ext.Window({
  522. modal: true,
  523. title: '<?=$Labels->GetLabel("_DLG_ADD_3DSENS_");?>',
  524. width: 400,
  525. height: 400,
  526. layout: 'fit',
  527. closeAction: 'hide',
  528. items:[{
  529. xtype: 'form',
  530. frame: false,
  531. border: false,
  532. hideLabels: false,
  533. labelAlign: 'right', // or 'right' or 'top'
  534. //labelSeparator: '>>', // takes precedence over layoutConfig value
  535. labelWidth: 160, // defaults to 100
  536. labelPad: 8, // defaults to 5, must specify labelWidth to be honored
  537. items:[{
  538. xtype:'panel',
  539. frame: false,
  540. border: false,
  541. html: '<center><img height="180px" src="/style/assets/SDR28_Safeshore1.png"></center>',
  542. height: '200px'
  543. },{
  544. html: '&nbsp;',
  545. frame: false,
  546. border: false,
  547. },{
  548. fieldLabel: '<?=$Labels->GetLabel('_DEVICE_NAME_');?>',
  549. xtype: 'textfield',
  550. width: 200,
  551. id: 's3d_dev_name',
  552. allowBlank: false
  553. },{
  554. xtype: 'combo',
  555. fieldLabel: '<?=$Labels->GetLabel('_DLG_CON_SEVER_NODE_');?>',
  556. lazyRender: true,
  557. id: 's3d_server',
  558. width: 200,
  559. disabled: false,
  560. forceSelection: true,
  561. triggerAction: 'all',
  562. editable: false,
  563. disableKeyFilter: true,
  564. store: ServerListStore,
  565. valueField: 'server_id',
  566. displayField: 'server_name'
  567. },{
  568. fieldLabel: '<?=$Labels->GetLabel('_DEVICE_IP_');?>',
  569. xtype: 'textfield',
  570. id: 's3d_dev_addr',
  571. width: 200,
  572. allowBlank: false
  573. },{
  574. fieldLabel: '<?=$Labels->GetLabel('_DEVICE_PORT_');?>',
  575. xtype: 'numberfield',
  576. id: 's3d_dev_port',
  577. width: 200,
  578. allowBlank: false,
  579. allowNegative: false,
  580. value: 2222,
  581. minValue: 1000,
  582. maxValue: 65535
  583. }],
  584. bbar:[ '->',{
  585. text: '<?=$Labels->GetLabel('_CANCEL_');?>',
  586. handler: function(){
  587. add3D_window.hide();
  588. }
  589. },{
  590. text: '<?=$Labels->GetLabel('_ADD_');?>',
  591. handler: function(){
  592. var dev_addr = Ext.getCmp('s3d_dev_addr').getValue();
  593. var dev_port = parseInt( Ext.getCmp('s3d_dev_port').getValue() );
  594. var dev_server = parseInt( Ext.getCmp('s3d_server').getValue() );
  595. var dev_name = Ext.getCmp('s3d_dev_name').getValue();
  596. if( dev_name != '' && dev_addr != '' && dev_port > 0 && dev_server > 0 ){
  597. Ext.Ajax.request({
  598. url: '/lib/controller/addNetworkNode.php',
  599. params: {
  600. SITEID: <?=$SiteID;?>,
  601. UID: <?=$UserID;?>,
  602. SID: '<?=$Session;?>',
  603. TYPE: 5,
  604. SNAME: dev_name,
  605. PORT: dev_port,
  606. ADDR: dev_addr,
  607. SERVER: dev_server
  608. },
  609. success: function( response, opts ){
  610. add3D_window.hide();
  611. // If the response is JSON, you have to decode it
  612. reloadNetworkData( <?=$SiteID;?> );
  613. },
  614. failure: failureAJAXFunction
  615. });
  616. } else {
  617. playSound();
  618. Ext.Msg.show({
  619. title:'<?=$Labels->GetLabel('_WRO_VALUES_');?>',
  620. msg: '<?=$Labels->GetLabel('_WRO_VAL_MSG_');?>',
  621. buttons: Ext.Msg.OK,
  622. icon: Ext.MessageBox.INFO
  623. });
  624. };
  625. }
  626. }]
  627. }]
  628. });
  629. };
  630. add3D_window.show();
  631. };
  632. function loadNodeSockets( NID, store ){
  633. Ext.Ajax.request({
  634. url: '/lib/controller/listNodeSockets.php',
  635. params: {
  636. NID: <?=$SiteID;?>,
  637. UID: <?=$UserID;?>,
  638. SID: '<?=$Session;?>',
  639. DID: NID
  640. },
  641. success: function( response, opts ){
  642. var data = Ext.decode( response.responseText );
  643. if( data['success'] == true ){
  644. store.loadData( data, false );
  645. } else {
  646. Ext.Msg.show({
  647. title: '<?=$Labels->GetLabel('_ERROR_MSG_TITLE_');?>',
  648. msg: data['error'],
  649. buttons: Ext.Msg.OK,//YESNOCANCEL,
  650. //fn: processResult,
  651. //animEl: 'elId',
  652. icon: Ext.MessageBox.ERROR //QUESTION
  653. });
  654. };
  655. //Ext.getCmp('zigzag').getEl().unmask();
  656. },
  657. failure: failureAJAXFunction
  658. });
  659. };
  660. function createConnection( SID, EID, CTY ){
  661. if( addConnectionDialog == null ){
  662. addConnectionDialog = new Ext.Window({
  663. modal: true,
  664. title: '<?=$Labels->GetLabel('_ADD_CONNECTION_');?>',
  665. width: 773,
  666. height: 600,
  667. layout: 'hbox',
  668. closeAction: 'hide',
  669. listeners:{
  670. beforehide : function(){
  671. Ext.getCmp('connectstarterbutton').toggle( false, false );
  672. }
  673. },
  674. items:[{
  675. xtype: 'grid',
  676. width: 380,
  677. height: 400,
  678. ds: A_socketsListStore,
  679. cm: socketListColModel,
  680. sm: A_socketSelModel
  681. },{
  682. xtype: 'grid',
  683. width: 380,
  684. height: 400,
  685. ds: B_socketsListStore,
  686. cm: socketListColModel,
  687. sm: B_socketSelModel
  688. }],
  689. bbar: [{
  690. text: '<?=$Labels->GetLabel("_CANCEL_");?>',
  691. handler: function(){
  692. addConnectionDialog.hide();
  693. }
  694. },{
  695. id: 'con_to_src',
  696. text: '<?=$Labels->GetLabel("_ADD_");?>',
  697. disabled: true,
  698. handler: function(){
  699. if( selected_A_socket != null && selected_B_socket != null ){
  700. Ext.Ajax.request({
  701. url: '/lib/controller/addConnection.php',
  702. params: {
  703. NID: <?=$SiteID;?>,
  704. SNID: SID,
  705. SOSID: selected_A_socket.id,
  706. ENID: EID,
  707. SOEID: selected_B_socket.id,
  708. UID: <?=$UserID;?>,
  709. SID: '<?=$Session;?>'
  710. },
  711. success: function( response, opts ){
  712. var data = Ext.decode(response.responseText);
  713. if( data.status ){
  714. //reloadNetworkData( NID );
  715. netwodkData.edges.add( data.edge );
  716. } else {
  717. startCreateConnection();
  718. //alert( data.message );
  719. };
  720. Ext.getCmp('connectstarterbutton').toggle( false, false );
  721. },
  722. failure: failureAJAXFunction
  723. });
  724. };
  725. }
  726. }]
  727. });
  728. };
  729. loadNodeSockets( SID, A_socketsListStore );
  730. loadNodeSockets( EID, B_socketsListStore );
  731. addConnectionDialog.show();
  732. };
  733. function loadNodeProperties( NodeID ){
  734. SelectedNodeID = NodeID;
  735. Ext.Ajax.request({
  736. url: '/lib/controller/getNetworkNodeProps.php',
  737. params: {
  738. NID: <?=$SiteID;?>,
  739. UID: <?=$UserID;?>,
  740. SID: '<?=$Session;?>',
  741. NODE: NodeID
  742. },
  743. success: function( response, opts ){
  744. var data = Ext.decode(response.responseText);
  745. var tPanel = Ext.getCmp('prop_content');
  746. tPanel.remove(0);
  747. tPanel.add( data );
  748. tPanel.doLayout();
  749. },
  750. failure: failureAJAXFunction
  751. });
  752. };
  753. var mp_FlyHunterWindow = null;
  754. function module_prop_FlyHunter( module_id ){
  755. if( mp_FlyHunterWindow == null ){
  756. mp_FlyHunterWindow = new Ext.Window({
  757. modal: true,
  758. title: '<?=$Labels->GetLabel('_FHM_PROPS_');?>',
  759. width: 773,
  760. height: 600,
  761. layout: 'table',
  762. closeAction: 'hide',
  763. flex: 1,
  764. defaults: {
  765. bodyStyle:'padding:20px'
  766. },
  767. layoutConfig: {
  768. // The total column count must be specified here
  769. columns: 2
  770. },
  771. items:[{
  772. html: 'Radio LINK UART Port'
  773. },{
  774. xtype: 'combo',
  775. editable: false,
  776. typeAhead: true,
  777. triggerAction: 'all',
  778. lazyRender:true,
  779. mode: 'local',
  780. store: new Ext.data.ArrayStore({
  781. id: 0,
  782. fields: ['myId', 'displayText' ],
  783. data: [ <?php
  784. $QS="SELECT re.aux_id, re.device FROM resources re LEFT JOIN nodes no ON( re.node_id = no.id ) WHERE ( re.type=1 OR re.type=129 )";
  785. $RR=$DATABASE->Query( $QS );
  786. if( count( $RR ) ){
  787. $RE=array();
  788. foreach( $RR as $R ){
  789. $RE[] = "[ {$R['aux_id']}, '{$R['device']}']";
  790. };
  791. echo implode( ',', $RE );
  792. } else {
  793. echo "[0, '".$Labels->GetLabel('_NO_UARTS_DEF_')."']";
  794. };
  795. ?>]
  796. }),
  797. valueField: 'myId',
  798. displayField: 'displayText'
  799. },{
  800. html: 'ChakaLaka DC Channel'
  801. },{
  802. xtype: 'combo',
  803. editable: false,
  804. typeAhead: true,
  805. triggerAction: 'all',
  806. lazyRender:true,
  807. mode: 'local',
  808. store: new Ext.data.ArrayStore({
  809. id: 1,
  810. fields: ['myId', 'displayText' ],
  811. data: [ <?php
  812. //$QS="SELECT ca.id, ca.channel_id, dcb.serial_id FROM module_dcr_chanels ca LEFT JOIN modules_dcr dcb ON( ca.dcr_id = dcb.id ) WHERE dcb.site_id={$SiteID}";
  813. //$RR=$DATABASE->Query( $QS );
  814. $RR=array();
  815. if( count( $RR ) ){
  816. $RE=array();
  817. foreach( $RR as $R ){
  818. $RE[] = "[ {$R['id']}, '{$R['serial_id']}_{$R['channel_id']}']";
  819. };
  820. echo implode( ',', $RE );
  821. } else {
  822. echo "[0, '".$Labels->GetLabel('_NO_DCB_DEF_')."']";
  823. };
  824. ?>]
  825. }),
  826. valueField: 'myId',
  827. displayField: 'displayText'
  828. }],
  829. bbar:[{
  830. text:'cancel'
  831. },{
  832. text:'submit'
  833. }]
  834. });
  835. };
  836. mp_FlyHunterWindow.show();
  837. Ext.Ajax.request({
  838. url: '/lib/controller/getModuleProps.php',
  839. params: {
  840. NID: <?=$SiteID;?>,
  841. UID: <?=$UserID;?>,
  842. SID: '<?=$Session;?>',
  843. MODULE: module_id
  844. },
  845. success: function( response, opts ){
  846. var data = Ext.decode(response.responseText);
  847. var tPanel = Ext.getCmp('prop_content');
  848. tPanel.remove(0);
  849. tPanel.add( data );
  850. tPanel.doLayout();
  851. },
  852. failure: failureAJAXFunction
  853. });
  854. };
  855. function loadSystemEditor(){
  856. if( tlInterval!= null ){
  857. window.clearInterval( tlInterval );
  858. tlInterval = null;
  859. timelineObj = null;
  860. };
  861. setUserContent( 3 );
  862. var tPanel = Ext.getCmp('main_portal');
  863. tPanel.removeAll( true );
  864. Ext.getCmp('main_content').setTitle( '<?=$Labels->GetLabel('_SYS_MAP_');?>' );
  865. tPanel.add({
  866. columnWidth: 0.83,
  867. frame: false,
  868. border: false,
  869. items: [{
  870. xtype: 'panel',
  871. layout: 'fit',
  872. layoutConfig: {
  873. align : 'stretch',
  874. pack : 'start'
  875. //padding:'5',
  876. //align:'middle'
  877. },
  878. height: PanelH-5,
  879. flex: 1,
  880. frame: false,
  881. border: false,
  882. items:{
  883. id: 'sys_map'
  884. },
  885. tbar: [{
  886. xtype: 'splitbutton',
  887. text: '<?=$Labels->GetLabel('_SMM_ADD_LSEN_');?>',
  888. split: true,
  889. enableToggle : undefined,
  890. menu : {
  891. items: [{
  892. text:'ALS',
  893. icon: '/style/assets/!cid_ii_jvmzuzrq10.png',
  894. handler: function(){
  895. addSerialSensor( 1 );
  896. }
  897. },{
  898. text:'LFS',
  899. icon: '/style/assets/!cid_ii_jvmzuzpt0.png',
  900. handler: function(){
  901. addSerialSensor( 2 );
  902. }
  903. },{
  904. text:'PLS-200',
  905. icon: '/style/assets/!cid_ii_jvmzuzql4.png',
  906. handler: function(){
  907. addSerialSensor( 3 );
  908. }
  909. },{
  910. text:'PLS-360',
  911. icon: '/style/assets/!cid_ii_jvmzuzr87.png',
  912. handler: function(){
  913. addSerialSensor( 4 );
  914. }
  915. },{
  916. text:'3DLIDAR',
  917. icon: '/style/assets/unnamed34.png',
  918. handler: function(){
  919. addSensor_3D();
  920. }
  921. }]
  922. }
  923. },{
  924. xtype: 'splitbutton',
  925. text: '<?=$Labels->GetLabel('_SMM_ADD_ADDIT_');?>',
  926. split: true,
  927. enableToggle : true,
  928. menu : {
  929. items: [{
  930. text:'Argus Event Server',
  931. icon: '/style/assets/0_node.png',
  932. handler: function(){
  933. addServer();
  934. }
  935. },{
  936. text:'Static Analog Camera',
  937. icon: '/style/assets/11_node.png',
  938. handler: function(){
  939. SelectedCamTYPE = 10;
  940. addAnalogCam();
  941. }
  942. },{
  943. text:'PTZ Analog Camera',
  944. icon: '/style/assets/12_node.png',
  945. handler: function(){
  946. SelectedCamTYPE = 11;
  947. addAnalogCam();
  948. }
  949. },{
  950. text:'Static IP Camera',
  951. icon: '/style/assets/11_node.png',
  952. handler: function(){
  953. SelectedCamTYPE = 12;
  954. addIpCam();
  955. }
  956. },{
  957. text:'PTZ IP Camera',
  958. icon: '/style/assets/12_node.png',
  959. handler: function(){
  960. SelectedCamTYPE = 13;
  961. addIpCam();
  962. }
  963. },{
  964. text:'DVR/Video Server/Streamer',
  965. icon: '/style/assets/videoServer.png',
  966. handler: function(){
  967. addMediaServer();
  968. }
  969. },{
  970. text:'Network Video Recorder',
  971. icon: '/style/assets/15_node.png'
  972. },{
  973. text:'Ethernet to UART transeiver',
  974. icon: '/style/assets/eth2uart.png',
  975. handler: function(){
  976. addEthernet2Uart();
  977. }
  978. },{
  979. text:'DC to Ethernet (ADAM)',
  980. icon: '/style/assets/adam-1.png',
  981. }]
  982. }
  983. },{
  984. xtype: 'button',
  985. id: 'deletecomponentbutton',
  986. text: 'Remove Component',
  987. enableToggle: true,
  988. handler: function(){
  989. if( InComponentRemoveMode ){
  990. Ext.getCmp('deletecomponentbutton').toggle( false, false );
  991. InComponentRemoveMode = false;
  992. } else {
  993. Ext.getCmp('deletecomponentbutton').toggle( true, true );
  994. InComponentRemoveMode = true;
  995. };
  996. }
  997. },{
  998. xtype: 'button',
  999. id:'deleteallcomponents',
  1000. text: '<?=$Labels->GetLabel('_CLEAR_SITE_');?>',
  1001. handler: removeAllFromSite
  1002. }]
  1003. }]
  1004. });
  1005. tPanel.add({
  1006. title: '<?=$Labels->GetLabel('_PROPERTIES_');?>',
  1007. xtype: 'panel',
  1008. flex: 1,
  1009. height: PanelH-5,
  1010. //width: 210,
  1011. columnWidth: 0.17,
  1012. layout: 'fit',
  1013. frame: false,
  1014. id: 'prop_content',
  1015. border: false,
  1016. items:[{
  1017. html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
  1018. }]
  1019. });
  1020. tPanel.doLayout();
  1021. Ext.Ajax.request({
  1022. url: '/lib/controller/getNetwork.php',
  1023. params: {
  1024. NID: SelectedSite,
  1025. UID: <?=$UserID;?>,
  1026. SID: '<?=$Session;?>'
  1027. },
  1028. success: function( response, opts ){
  1029. // If the response is JSON, you have to decode it
  1030. var data = Ext.decode(response.responseText);
  1031. netwodkData.nodes = new vis.DataSet( data.nodes );
  1032. netwodkData.edges = new vis.DataSet( data.edges );
  1033. var container = document.getElementById(Ext.getCmp('sys_map').body.id);
  1034. networkObj = new vis.Network(container, netwodkData, networkOpts );
  1035. networkObj.on("click", function (params) {
  1036. //if(!connectionAddMode){
  1037. if( !InComponentRemoveMode ){
  1038. if( params.nodes.length > 0 ){
  1039. loadNodeProperties( params.nodes[0] );
  1040. } else if( params.edges.length > 0 ){
  1041. selectedConnection = netwodkData.edges.get(params.edges[0]);
  1042. loadLinkProperties( params.edges[0], selectedConnection.from, selectedConnection.to );
  1043. };
  1044. } else {
  1045. if( params.nodes.length > 0 ){
  1046. if( netwodkData.nodes.get(params.nodes[0]).role == 'server' ){
  1047. Ext.Msg.show({
  1048. title:'Remove Server Component!',
  1049. msg: 'You can not remove Server component!',
  1050. buttons: Ext.Msg.OK,
  1051. icon: Ext.MessageBox.INFO
  1052. });
  1053. } else {
  1054. Ext.Msg.show({
  1055. title:'Remove Component?',
  1056. msg: 'You are about to remove.<br/>Are you sure to do so?',
  1057. buttons: Ext.Msg.YESNOCANCEL,
  1058. fn: function( result ){
  1059. if( result=='yes' ){
  1060. Ext.Ajax.request({
  1061. url: '/lib/controller/removeNode.php',
  1062. params: {
  1063. SAID: <?=$SiteID;?>,
  1064. NID: params.nodes[0],
  1065. UID: <?=$UserID;?>,
  1066. SID: '<?=$Session;?>'
  1067. },
  1068. success: function( response, opts ){
  1069. var data = Ext.decode(response.responseText);
  1070. if( data.sucess == false ){
  1071. Ext.Msg.show({
  1072. title:'Request Failure!',
  1073. msg: data.error,
  1074. buttons: Ext.Msg.OK,
  1075. icon: Ext.MessageBox.INFO
  1076. });
  1077. } else {
  1078. stopCreateConnection();
  1079. InComponentRemoveMode = false;
  1080. loadSystemEditor();
  1081. };
  1082. },
  1083. failure: failureAJAXFunction
  1084. });
  1085. };
  1086. },
  1087. //animEl: 'elId',
  1088. icon: Ext.MessageBox.QUESTION
  1089. });
  1090. };
  1091. };
  1092. };
  1093. //};
  1094. });
  1095. /*
  1096. networkObj.on("doubleClick", function (params) {
  1097. //if(!connectionAddMode){
  1098. if( !InComponentRemoveMode ){
  1099. if( params.nodes.length > 0 ){
  1100. loadNodeProperties( params.nodes[0] );
  1101. } else if( params.edges.length > 0 ){
  1102. selectedConnection = netwodkData.edges.get(params.edges[0]);
  1103. loadLinkProperties( params.edges[0], selectedConnection.from, selectedConnection.to );
  1104. };
  1105. } else {
  1106. alert( 'Remove' );
  1107. };
  1108. //};
  1109. });
  1110. */
  1111. /*
  1112. networkObj.on("dragStart", function (params) {
  1113. if( connectionAddMode ){
  1114. var tID = this.getNodeAt(params.pointer.DOM);
  1115. if( tID != undefined ){
  1116. newConnectionStart = tID;
  1117. };
  1118. };
  1119. });
  1120. networkObj.on("dragEnd", function (params) {
  1121. if( connectionAddMode ){
  1122. var tID = this.getNodeAt(params.pointer.DOM);
  1123. if( tID != undefined ){
  1124. newConnectionEnd = tID;
  1125. //selectedConnection = netwodkData.edges[netwodkData.edges.length];
  1126. //selectedConnection.color = {
  1127. // color: '#ff0000',
  1128. // opacity: 0.3,
  1129. // highlight: 'blue'
  1130. //};
  1131. //networkObj.addEdgeMode(0);
  1132. createConnection( newConnectionStart, newConnectionEnd );
  1133. connectionAddMode = false;
  1134. };
  1135. };
  1136. });
  1137. */
  1138. },
  1139. failure: failureAJAXFunction
  1140. });
  1141. };