Web UI for ARGUS server
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.

1017 lines
26 KiB

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