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.

781 lines
20 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
6 years ago
​
​
5 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
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 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
5 years ago
​
6 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 selectedSite = <?=$SiteID;?>;
  3. var SettingsLidar3D = null;
  4. var SelectedNodeID = 0;
  5. function loadSettingsLidar3D( NodeID, Master ){
  6. SelectedNodeID = NodeID;
  7. Ext.Ajax.request({
  8. url: '/lib/controller/getSettingsLidsr3D.php',
  9. params: {
  10. NID: NodeID,
  11. MST: ((Master)?1:0),
  12. UID: <?=$UserID;?>,
  13. SID: '<?=$Session;?>',
  14. },
  15. success: function( response, opts ){
  16. // If the response is JSON, you have to decode it
  17. var data = Ext.decode(response.responseText);
  18. Ext.getCmp('setting_master_ip').setValue( data.ip_address );
  19. Ext.getCmp('setting_master_port').setValue( data.port );
  20. Ext.getCmp('setting_slave_ip').setValue( data.aux_ip_address );
  21. Ext.getCmp('setting_slave_port').setValue( data.aux_port );
  22. Ext.getCmp('setting_lat').setValue( data.lat );
  23. Ext.getCmp('setting_lon').setValue( data.lon );
  24. Ext.getCmp('setting_alt').setValue( data.alt );
  25. Ext.getCmp('setting_roll').setValue( data.roll );
  26. Ext.getCmp('setting_pitch').setValue( data.pitch );
  27. Ext.getCmp('setting_yaw').setValue( data.yaw );
  28. },
  29. failure: failureAJAXFunction
  30. });
  31. };
  32. function SaveSettingsLidar3D( ){
  33. if( SelectedNodeID == 0 ) return;
  34. t1 = Ext.getCmp('setting_master_ip').getValue();
  35. t2 = Ext.getCmp('setting_master_port').getValue();
  36. t3 = Ext.getCmp('setting_slave_ip').getValue();
  37. t4 = Ext.getCmp('setting_slave_port').getValue();
  38. t5 = Ext.getCmp('setting_lat').getValue();
  39. t6 = Ext.getCmp('setting_lon').getValue();
  40. t7 = Ext.getCmp('setting_alt').getValue();
  41. t8 = Ext.getCmp('setting_roll').getValue();
  42. t9 = Ext.getCmp('setting_pitch').getValue();
  43. t10 = Ext.getCmp('setting_yaw').getValue();
  44. Ext.Ajax.request({
  45. url: '/lib/controller/setSettingsLidsr3D.php',
  46. params: {
  47. NID: SelectedNodeID,
  48. UID: <?=$UserID;?>,
  49. SID: '<?=$Session;?>',
  50. MIP: t1,
  51. MPP: t2,
  52. SIP: t3,
  53. SPP: t4,
  54. LAT: t5,
  55. LON: t6,
  56. ALT: t7,
  57. ROL: t8,
  58. PCH: t9,
  59. YAW: t10
  60. },
  61. success: function( response, opts ){
  62. // If the response is JSON, you have to decode it
  63. var data = Ext.decode(response.responseText);
  64. if( data.success == true ) {
  65. Ext.Msg.show({
  66. title:'Info Message',
  67. msg: 'Settings are sucessfully saved.',
  68. buttons: Ext.Msg.OK,//YESNOCANCEL,
  69. fn: function(){
  70. SettingsLidar3D.hide();
  71. },
  72. //animEl: 'elId',
  73. icon: Ext.MessageBox.INFO //QUESTION
  74. });
  75. } else {
  76. Ext.Msg.show({
  77. title:'Error Message',
  78. msg: data['error'],
  79. buttons: Ext.Msg.OK,//YESNOCANCEL,
  80. fn: function(){
  81. SettingsLidar3D.hide();
  82. },
  83. //animEl: 'elId',
  84. icon: Ext.MessageBox.ERROR //QUESTION
  85. });
  86. };
  87. },
  88. failure: failureAJAXFunction
  89. });
  90. };
  91. function editSettingsLidar3D( NodeID, Master ){
  92. if( SettingsLidar3D == null ){
  93. SettingsLidar3D = new Ext.Window({
  94. modal: true,
  95. title: '<?=$Labels->GetLabel("_EDIT_LRF3D_SETTINGS_");?>',
  96. width: 773,
  97. height: 600,
  98. layout: 'fit',
  99. closeAction: 'hide',
  100. listeners:{
  101. beforehide : function(){
  102. Ext.getCmp('connectstarterbutton').toggle( false, false );
  103. }
  104. },
  105. items:[{
  106. layout: 'table',
  107. border: false,
  108. defaults: {
  109. // applied to each contained panel
  110. bodyStyle:'padding-top:10px;padding-left:20px;padding-right:20px;padding-bottom:10px;'
  111. },
  112. layoutConfig: {
  113. // The total column count must be specified here
  114. columns: 4
  115. },
  116. items: [{
  117. border: false,
  118. html: 'Master IP Address:'
  119. },{
  120. xtype: 'textfield',
  121. id: 'setting_master_ip',
  122. width: '70%'
  123. },{
  124. border: false,
  125. html: 'Port:'
  126. },{
  127. xtype: 'textfield',
  128. id: 'setting_master_port',
  129. width: '30%'
  130. },{
  131. border: false,
  132. html: 'Slave IP Address:'
  133. },{
  134. xtype: 'textfield',
  135. id: 'setting_slave_ip',
  136. width: '70%'
  137. },{
  138. border: false,
  139. html: 'Port:'
  140. },{
  141. xtype: 'textfield',
  142. id: 'setting_slave_port',
  143. width: '30%'
  144. },{
  145. border: false,
  146. html: 'Position Lat/Lon/Alt:'
  147. },{
  148. xtype: 'textfield',
  149. id: 'setting_lat',
  150. width: '30%'
  151. },{
  152. xtype: 'textfield',
  153. id: 'setting_lon',
  154. width: '30%'
  155. },{
  156. xtype: 'textfield',
  157. id: 'setting_alt',
  158. width: '30%'
  159. },{
  160. border: false,
  161. html: 'Orientation Roll/Pitch/Yaw:'
  162. },{
  163. xtype: 'textfield',
  164. id: 'setting_roll',
  165. width: '30%'
  166. },{
  167. xtype: 'textfield',
  168. id: 'setting_pitch',
  169. width: '30%'
  170. },{
  171. xtype: 'textfield',
  172. id: 'setting_yaw',
  173. width: '30%'
  174. }]
  175. }],
  176. bbar: [{
  177. text: '<?=$Labels->GetLabel("_CANCEL_");?>',
  178. handler: function(){
  179. SettingsLidar3D.hide();
  180. }
  181. },{
  182. text: '<?=$Labels->GetLabel("_SAVE_");?>',
  183. handler: SaveSettingsLidar3D
  184. }]
  185. });
  186. };
  187. SettingsLidar3D.show();
  188. loadSettingsLidar3D( NodeID, Master );
  189. };
  190. function reloadNetworkData(){
  191. Ext.Ajax.request({
  192. url: '/lib/controller/getNetwork.php',
  193. params: {
  194. NID: <?=$SiteID;?>,
  195. UID: <?=$UserID;?>,
  196. SID: '<?=$Session;?>',
  197. },
  198. success: function( response, opts ){
  199. // If the response is JSON, you have to decode it
  200. var data = Ext.decode(response.responseText);
  201. netwodkData.nodes = new vis.DataSet( data.nodes );
  202. netwodkData.edges = new vis.DataSet( data.edges );
  203. networkObj.setData( netwodkData );
  204. networkObj.redraw();
  205. },
  206. failure: failureAJAXFunction
  207. });
  208. };
  209. function createNode( STYPE ){
  210. Ext.Ajax.request({
  211. url: '/lib/controller/addNetworkNode.php',
  212. params: {
  213. NID: <?=$SiteID;?>,
  214. UID: <?=$UserID;?>,
  215. SID: '<?=$Session;?>',
  216. TYPE: STYPE
  217. },
  218. success: function( response, opts ){
  219. // If the response is JSON, you have to decode it
  220. reloadNetworkData( <?=$SiteID;?> );
  221. },
  222. failure: failureAJAXFunction
  223. });
  224. };
  225. function loadNodeSockets( NID, store ){
  226. Ext.Ajax.request({
  227. url: '/lib/controller/listNodeSockets.php',
  228. params: {
  229. NID: <?=$SiteID;?>,
  230. UID: <?=$UserID;?>,
  231. SID: '<?=$Session;?>',
  232. DID: NID
  233. },
  234. success: function( response, opts ){
  235. var data = Ext.decode( response.responseText );
  236. if( data['success'] == true ){
  237. store.loadData( data, false );
  238. } else {
  239. Ext.Msg.show({
  240. title:'Error Message',
  241. msg: data['error'],
  242. buttons: Ext.Msg.OK,//YESNOCANCEL,
  243. //fn: processResult,
  244. //animEl: 'elId',
  245. icon: Ext.MessageBox.ERROR //QUESTION
  246. });
  247. };
  248. //Ext.getCmp('zigzag').getEl().unmask();
  249. },
  250. failure: failureAJAXFunction
  251. });
  252. };
  253. function createConnection( SID, EID, CTY ){
  254. if( addConnectionDialog == null ){
  255. addConnectionDialog = new Ext.Window({
  256. modal: true,
  257. title: '<?=$Labels->GetLabel("_ADD_CONNECTION_");?>',
  258. width: 773,
  259. height: 600,
  260. layout: 'hbox',
  261. closeAction: 'hide',
  262. listeners:{
  263. beforehide : function(){
  264. Ext.getCmp('connectstarterbutton').toggle( false, false );
  265. }
  266. },
  267. items:[{
  268. xtype: 'grid',
  269. width: 380,
  270. height: 400,
  271. ds: A_socketsListStore,
  272. cm: socketListColModel,
  273. sm: A_socketSelModel
  274. },{
  275. xtype: 'grid',
  276. width: 380,
  277. height: 400,
  278. ds: B_socketsListStore,
  279. cm: socketListColModel,
  280. sm: B_socketSelModel
  281. }],
  282. bbar: [{
  283. text: '<?=$Labels->GetLabel("_CANCEL_");?>',
  284. handler: function(){
  285. addConnectionDialog.hide();
  286. }
  287. },{
  288. id: 'con_to_src',
  289. text: '<?=$Labels->GetLabel("_ADD_");?>',
  290. disabled: true,
  291. handler: function(){
  292. if( selected_A_socket != null && selected_B_socket != null ){
  293. Ext.Ajax.request({
  294. url: '/lib/controller/addConnection.php',
  295. params: {
  296. NID: <?=$SiteID;?>,
  297. SNID: SID,
  298. SOSID: selected_A_socket.id,
  299. ENID: EID,
  300. SOEID: selected_B_socket.id,
  301. UID: <?=$UserID;?>,
  302. SID: '<?=$Session;?>'
  303. },
  304. success: function( response, opts ){
  305. var data = Ext.decode(response.responseText);
  306. if( data.status ){
  307. //reloadNetworkData( NID );
  308. netwodkData.edges.add( data.edge );
  309. } else {
  310. startCreateConnection();
  311. //alert( data.message );
  312. };
  313. Ext.getCmp('connectstarterbutton').toggle( false, false );
  314. },
  315. failure: function( response, opts ) {
  316. //Ext.fly('some_div').update('Fail!');
  317. }/*,
  318. callback: function(options,success,response){
  319. // use this if you need to perform your own success/failure checking
  320. }*/
  321. });
  322. };
  323. }
  324. }]
  325. });
  326. };
  327. loadNodeSockets( SID, A_socketsListStore );
  328. loadNodeSockets( EID, B_socketsListStore );
  329. addConnectionDialog.show();
  330. };
  331. function loadNodeProperties( NodeID ){
  332. //alert( 'Node: ' + NodeID );
  333. SelectedNodeID = NodeID;
  334. Ext.Ajax.request({
  335. url: '/lib/controller/getNetworkNodeProps.php',
  336. params: {
  337. NID: <?=$SiteID;?>,
  338. UID: <?=$UserID;?>,
  339. SID: '<?=$Session;?>',
  340. NODE: NodeID
  341. },
  342. success: function( response, opts ){
  343. // If the response is JSON, you have to decode it
  344. var data = Ext.decode(response.responseText);
  345. var tPanel = Ext.getCmp('prop_content');
  346. tPanel.remove(0);
  347. tPanel.add( data );
  348. tPanel.doLayout();
  349. },
  350. failure: failureAJAXFunction
  351. });
  352. };
  353. function loadServerProperties( NodeID ){
  354. Ext.Ajax.request({
  355. url: '/lib/controller/getNetworkServerProps.php',
  356. params: {
  357. NID: <?=$SiteID;?>,
  358. UID: <?=$UserID;?>,
  359. SID: '<?=$Session;?>',
  360. NODE: NodeID
  361. },
  362. success: function( response, opts ){
  363. var data = Ext.decode(response.responseText);
  364. var tPanel = Ext.getCmp('prop_content');
  365. tPanel.remove(0);
  366. tPanel.add( data );
  367. tPanel.doLayout();
  368. },
  369. failure: failureAJAXFunction
  370. });
  371. };
  372. var mp_FlyHunterWindow = null;
  373. function module_prop_FlyHunter( module_id ){
  374. if( mp_FlyHunterWindow == null ){
  375. mp_FlyHunterWindow = new Ext.Window({
  376. modal: true,
  377. title: '<?=$Labels->GetLabel("_FHM_PROPS_");?>',
  378. width: 773,
  379. height: 600,
  380. layout: 'table',
  381. closeAction: 'hide',
  382. flex: 1,
  383. defaults: {
  384. bodyStyle:'padding:20px'
  385. },
  386. layoutConfig: {
  387. // The total column count must be specified here
  388. columns: 2
  389. },
  390. items:[{
  391. html: 'Radio LINK UART Port'
  392. },{
  393. xtype: 'combo',
  394. editable: false,
  395. typeAhead: true,
  396. triggerAction: 'all',
  397. lazyRender:true,
  398. mode: 'local',
  399. store: new Ext.data.ArrayStore({
  400. id: 0,
  401. fields: ['myId', 'displayText' ],
  402. data: [ <?php
  403. $QS="SELECT so.id, so.name FROM nodes no LEFT JOIN sockets so ON( so.node_id = no.id ) WHERE ( no.type=0 OR no.type=20 ) AND no.site_id={$SiteID} AND so.type=1";
  404. $RR=$DATABASE->Query( $QS );
  405. if( count( $RR ) ){
  406. $RE=array();
  407. foreach( $RR as $R ){
  408. $RE[] = "[ {$R['id']}, '{$R['name']}']";
  409. };
  410. echo implode( ',', $RE );
  411. } else {
  412. echo "[0, 'No UARTS DEFINED']";
  413. };
  414. ?>]
  415. }),
  416. valueField: 'myId',
  417. displayField: 'displayText'
  418. },{
  419. html: 'ChakaLaka DC Channel'
  420. },{
  421. xtype: 'combo',
  422. editable: false,
  423. typeAhead: true,
  424. triggerAction: 'all',
  425. lazyRender:true,
  426. mode: 'local',
  427. store: new Ext.data.ArrayStore({
  428. id: 1,
  429. fields: ['myId', 'displayText' ],
  430. data: [ <?php
  431. $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}";
  432. $RR=$DATABASE->Query( $QS );
  433. if( count( $RR ) ){
  434. $RE=array();
  435. foreach( $RR as $R ){
  436. $RE[] = "[ {$R['id']}, '{$R['serial_id']}_{$R['channel_id']}']";
  437. };
  438. echo implode( ',', $RE );
  439. } else {
  440. echo "[0, 'No DCB Connected']";
  441. };
  442. ?>]
  443. }),
  444. valueField: 'myId',
  445. displayField: 'displayText'
  446. }],
  447. bbar:[{
  448. text:'cancel'
  449. },{
  450. text:'submit'
  451. }]
  452. });
  453. };
  454. mp_FlyHunterWindow.show();
  455. Ext.Ajax.request({
  456. url: '/lib/controller/getModuleProps.php',
  457. params: {
  458. NID: <?=$SiteID;?>,
  459. UID: <?=$UserID;?>,
  460. SID: '<?=$Session;?>',
  461. MODULE: module_id
  462. },
  463. success: function( response, opts ){
  464. var data = Ext.decode(response.responseText);
  465. var tPanel = Ext.getCmp('prop_content');
  466. tPanel.remove(0);
  467. tPanel.add( data );
  468. tPanel.doLayout();
  469. },
  470. failure: function( response, opts ) {
  471. }
  472. });
  473. };
  474. function loadSystemEditor(){
  475. if( tlInterval!= null ){
  476. window.clearInterval( tlInterval );
  477. tlInterval = null;
  478. timelineObj = null;
  479. };
  480. var tPanel = Ext.getCmp('main_portal');
  481. tPanel.removeAll( true );
  482. Ext.getCmp('main_content').setTitle( 'System Map' );
  483. tPanel.add({
  484. columnWidth: 0.83,
  485. frame: false,
  486. border: false,
  487. items: [{
  488. xtype: 'panel',
  489. layout: 'fit',
  490. layoutConfig: {
  491. align : 'stretch',
  492. pack : 'start'
  493. //padding:'5',
  494. //align:'middle'
  495. },
  496. height: PanelH-5,
  497. flex: 1,
  498. frame: false,
  499. border: false,
  500. items:{
  501. id: 'sys_map'
  502. },
  503. tbar: [{
  504. xtype: 'splitbutton',
  505. text: 'Add Laser Sensor',
  506. split: true,
  507. enableToggle : undefined,
  508. menu : {
  509. items: [{
  510. text:'ALS',
  511. icon: '/style/assets/!cid_ii_jvmzuzrq10.png',
  512. handler: function(){
  513. createNode( 1 );
  514. }
  515. },{
  516. text:'LFS',
  517. icon: '/style/assets/!cid_ii_jvmzuzpt0.png',
  518. handler: function(){
  519. createNode( 2 );
  520. }
  521. },{
  522. text:'PLS-200',
  523. icon: '/style/assets/!cid_ii_jvmzuzql4.png',
  524. handler: function(){
  525. createNode( 3 );
  526. }
  527. },{
  528. text:'PLS-360',
  529. icon: '/style/assets/!cid_ii_jvmzuzr87.png',
  530. handler: function(){
  531. createNode( 4 );
  532. }
  533. },{
  534. text:'3DLIDAR',
  535. icon: '/style/assets/unnamed34.png',
  536. handler: function(){
  537. createNode( 5 );
  538. }
  539. }]
  540. }
  541. },{
  542. xtype: 'splitbutton',
  543. text: 'Add Additional Equipment',
  544. split: true,
  545. enableToggle : true,
  546. menu : {
  547. items: [{
  548. text:'Static Analog Camera',
  549. icon: '/style/assets/11_node.png'
  550. },{
  551. text:'PTZ Analog Camera',
  552. icon: '/style/assets/12_node.png'
  553. },{
  554. text:'Static IP Camera',
  555. icon: '/style/assets/11_node.png',
  556. handler: function(){
  557. SelectedCamPTZ = false;
  558. addIpCam();
  559. }
  560. },{
  561. text:'PTZ IP Camera',
  562. icon: '/style/assets/12_node.png',
  563. handler: function(){
  564. SelectedCamPTZ = true;
  565. addIpCam();
  566. }
  567. },{
  568. text:'DVR/Video Server/Streamer',
  569. icon: '/style/assets/videoServer.png',
  570. handler: function(){
  571. addMediaServer();
  572. }
  573. },{
  574. text:'Network Video Recorder',
  575. icon: '/style/assets/15_node.png'
  576. },{
  577. text:'Ethernet to UART transeiver',
  578. icon: '/style/assets/eth2uart.png',
  579. handler: function(){
  580. addEthernet2Uart();
  581. }
  582. },{
  583. text:'DC to Ethernet (ADAM)',
  584. icon: '/style/assets/adam-1.png',
  585. }]
  586. }
  587. },{
  588. xtype: 'button',
  589. id: 'connectstarterbutton',
  590. text: 'Add Connection',
  591. enableToggle : undefined,
  592. handler: function(){
  593. if( InConnectEditMode ){
  594. Ext.getCmp('connectstarterbutton').toggle( false, false );
  595. InConnectEditMode = false;
  596. stopCreateConnection();
  597. } else {
  598. Ext.getCmp('connectstarterbutton').toggle( true, true );
  599. InConnectEditMode = true;
  600. startCreateConnection();
  601. };
  602. }
  603. },{
  604. xtype: 'button',
  605. id: 'deletecomponentbutton',
  606. text: 'Remove Component',
  607. enableToggle: true,
  608. handler: function(){
  609. if( InComponentRemoveMode ){
  610. Ext.getCmp('deletecomponentbutton').toggle( false, false );
  611. InComponentRemoveMode = false;
  612. } else {
  613. Ext.getCmp('deletecomponentbutton').toggle( true, true );
  614. InComponentRemoveMode = true;
  615. };
  616. }
  617. }]
  618. }]
  619. });
  620. tPanel.add({
  621. title: 'Properties',
  622. xtype: 'panel',
  623. flex: 1,
  624. height: 700,
  625. //width: 210,
  626. columnWidth: 0.17,
  627. layout: 'fit',
  628. //frame: true,
  629. id: 'prop_content',
  630. // border: true
  631. items:{
  632. html: 'Select Item From Map'
  633. }
  634. });
  635. tPanel.doLayout();
  636. Ext.Ajax.request({
  637. url: '/lib/controller/getNetwork.php',
  638. params: {
  639. NID: selectedSite,
  640. UID: <?=$UserID;?>,
  641. SID: '<?=$Session;?>'
  642. },
  643. success: function( response, opts ){
  644. // If the response is JSON, you have to decode it
  645. var data = Ext.decode(response.responseText);
  646. netwodkData.nodes = new vis.DataSet( data.nodes );
  647. netwodkData.edges = new vis.DataSet( data.edges );
  648. var container = document.getElementById(Ext.getCmp('sys_map').body.id);
  649. networkObj = new vis.Network(container, netwodkData, networkOpts );
  650. networkObj.on("click", function (params) {
  651. //if(!connectionAddMode){
  652. if( !InComponentRemoveMode ){
  653. if( params.nodes.length > 0 ){
  654. if( netwodkData.nodes.get(params.nodes[0]).role == 'server' ){
  655. loadServerProperties( params.nodes[0] );
  656. } else {
  657. loadNodeProperties( params.nodes[0] );
  658. };
  659. } else if( params.edges.length > 0 ){
  660. selectedConnection = netwodkData.edges.get(params.edges[0]);
  661. loadLinkProperties( params.edges[0], selectedConnection.from, selectedConnection.to );
  662. };
  663. } else {
  664. if( params.nodes.length > 0 ){
  665. if( netwodkData.nodes.get(params.nodes[0]).role == 'server' ){
  666. Ext.Msg.show({
  667. title:'Remove Server Component!',
  668. msg: 'You can not remove Server component!',
  669. buttons: Ext.Msg.OK,
  670. icon: Ext.MessageBox.INFO
  671. });
  672. } else {
  673. Ext.Msg.show({
  674. title:'Remove Component?',
  675. msg: 'You are about to remove.<br/>Are you sure to do so?',
  676. buttons: Ext.Msg.YESNOCANCEL,
  677. fn: function( result ){
  678. if( result=='yes' ){
  679. Ext.Ajax.request({
  680. url: '/lib/controller/removeNode.php',
  681. params: {
  682. SAID: <?=$SiteID;?>,
  683. NID: params.nodes[0],
  684. UID: <?=$UserID;?>,
  685. SID: '<?=$Session;?>'
  686. },
  687. success: function( response, opts ){
  688. var data = Ext.decode(response.responseText);
  689. if( data.sucess == false ){
  690. Ext.Msg.show({
  691. title:'Request Failure!',
  692. msg: data.error,
  693. buttons: Ext.Msg.OK,
  694. icon: Ext.MessageBox.INFO
  695. });
  696. } else {
  697. stopCreateConnection();
  698. InComponentRemoveMode = false;
  699. loadSystemEditor();
  700. };
  701. },
  702. failure: function( response, opts ) {
  703. Ext.Msg.show({
  704. title:'Request Failure!',
  705. msg: 'Ajax Request failed!',
  706. buttons: Ext.Msg.OK,
  707. icon: Ext.MessageBox.INFO
  708. });
  709. }
  710. });
  711. };
  712. },
  713. //animEl: 'elId',
  714. icon: Ext.MessageBox.QUESTION
  715. });
  716. };
  717. };
  718. };
  719. //};
  720. });
  721. /*
  722. networkObj.on("doubleClick", function (params) {
  723. //if(!connectionAddMode){
  724. if( !InComponentRemoveMode ){
  725. if( params.nodes.length > 0 ){
  726. loadNodeProperties( params.nodes[0] );
  727. } else if( params.edges.length > 0 ){
  728. selectedConnection = netwodkData.edges.get(params.edges[0]);
  729. loadLinkProperties( params.edges[0], selectedConnection.from, selectedConnection.to );
  730. };
  731. } else {
  732. alert( 'Remove' );
  733. };
  734. //};
  735. });
  736. */
  737. /*
  738. networkObj.on("dragStart", function (params) {
  739. if( connectionAddMode ){
  740. var tID = this.getNodeAt(params.pointer.DOM);
  741. if( tID != undefined ){
  742. newConnectionStart = tID;
  743. };
  744. };
  745. });
  746. networkObj.on("dragEnd", function (params) {
  747. if( connectionAddMode ){
  748. var tID = this.getNodeAt(params.pointer.DOM);
  749. if( tID != undefined ){
  750. newConnectionEnd = tID;
  751. //selectedConnection = netwodkData.edges[netwodkData.edges.length];
  752. //selectedConnection.color = {
  753. // color: '#ff0000',
  754. // opacity: 0.3,
  755. // highlight: 'blue'
  756. //};
  757. //networkObj.addEdgeMode(0);
  758. createConnection( newConnectionStart, newConnectionEnd );
  759. connectionAddMode = false;
  760. };
  761. };
  762. });
  763. */
  764. },
  765. failure: failureAJAXFunction
  766. });
  767. };