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.

568 lines
15 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //<?php require_once('../../js_asm.php'); ?>
  2. var muploader = null;
  3. var uploads_store_id = 0;
  4. var uploads_store = new Ext.data.ArrayStore({
  5. autoDestroy: false,
  6. storeId: 'up_store',
  7. idIndex: 0,
  8. fields: [
  9. {name: 'id', type: 'int' },
  10. {name: 'file_name', type: 'string'},
  11. {name: 'file_id', type: 'string'},
  12. {name: 'size', type: 'string'},
  13. {name: 'progress', type: 'int'},
  14. {name: 'status', type: 'string' }
  15. ]
  16. });
  17. var uploaded_store_id = 0;
  18. var uploaded_store = new Ext.data.ArrayStore({
  19. autoDestroy: false,
  20. storeId: 'mod_store',
  21. idIndex: 0,
  22. fields: [
  23. {name: 'id', type: 'int' },
  24. {name: 'file_name', type: 'string'},
  25. {name: 'size', type: 'int'},
  26. {name: 'status', type: 'int'},
  27. {name: 'ts', type: 'string' },
  28. {name: 'memo', type: 'string' }
  29. ]
  30. });
  31. function progressRenderer( value, meta, record ){
  32. Ext.defer( function( id ){
  33. var p = new Ext.ProgressBar({
  34. id: 'progress_'+id,
  35. renderTo: 'div_'+id,
  36. animate: false,
  37. width: '100%',
  38. value: 0,
  39. text: 'Upload Pending',
  40. });
  41. }, 50, undefined, [ record.data.file_id ] );
  42. return '<div id="div_' + record.data.file_id + '"></div>';
  43. };
  44. var fileUploadsColModel_ops = {
  45. columns: [
  46. {header: "ID", width: 50, align: 'center', css: 'vertical-align: middle;', dataIndex: 'id' },
  47. {header: "File Name", width: 280, fixed: false, align: 'left', css: 'vertical-align: middle;', dataIndex: 'file_name' },
  48. {header: "Size", width: 80, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' },
  49. {header: "Progress", width: 150, renderer: progressRenderer, dataIndex: 'progress' },
  50. {header: " ", width: 50, dataIndex: 'status3' }
  51. ],
  52. defaults: {
  53. sortable: false,
  54. fixed: true,
  55. menuDisabled: true,
  56. width: 100
  57. }
  58. };
  59. function loadModuleFiles( sensorID ){
  60. Ext.Ajax.request({
  61. url: '/lib/controller/getDeviceFiles.php',
  62. params: {
  63. UID: <?=$UserID;?>,
  64. SID: '<?=$Session;?>',
  65. DID: sensorID
  66. },
  67. success: function( response, opts ){
  68. var data = Ext.decode( response.responseText );
  69. uploaded_store.removeAll();
  70. uploaded_store.loadData( data.files );
  71. },
  72. failure: failureAJAXFunction
  73. });
  74. };
  75. function onModuleFileRenderer( value, meta, record ){
  76. if( value == 0 ){
  77. rv = '<img title="Ready to Upload" alt="Ready to Upload" src="/style/assets/bul_green.png">';
  78. } else {
  79. if( value < 101 ){
  80. rv = '<img title="Uploading" alt="Uploading" src="/style/assets/bul_gray.png">';
  81. } else {
  82. rv = '<img title="Already Uploaded" alt="Already Uploaded" src="/style/assets/bul_blue.png">';
  83. };
  84. };
  85. return rv;
  86. };
  87. var fileModuleColModel_ops = {
  88. columns: [
  89. {header: "ID", width: 50, align: 'center', css: 'vertical-align: middle;', dataIndex: 'id' },
  90. {header: "File Name", width: 60, fixed: false, align: 'left', css: 'vertical-align: middle;', dataIndex: 'file_name' },
  91. {header: "Size", width: 80, renderer: plupload.formatSize, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' },
  92. {header: "Time", width: 150, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ts' },
  93. {header: "Status", width: 50, renderer: onModuleFileRenderer, dataIndex: 'status' },
  94. {header: "Memo", dataIndex: 'memo' }
  95. ],
  96. defaults: {
  97. sortable: false,
  98. fixed: true,
  99. menuDisabled: true,
  100. width: 100
  101. }
  102. };
  103. var fileUploadsSelModel_ops = {
  104. singleSelect: true
  105. };
  106. function archiveTypeRenderer( value, meta, record ){
  107. var alt_txt = '';
  108. var img_src = '';
  109. if( record.data.bk_type == 3 ){
  110. alt_txt = 'Full System Snapeshot';
  111. img_src = '/style/icons/icons/rosette.png';
  112. } else {
  113. alt_txt = 'Database Backup';
  114. img_src = '/style/icons/icons/database.png';
  115. };
  116. return '<div><img alt="'+alt_txt+'" src="'+img_src+'"></div>';
  117. };
  118. var taskIsArmed = false;
  119. var archives_store = new Ext.data.JsonStore({
  120. root: 'backups',
  121. totalProperty: 'totalCount',
  122. idProperty: 'id',
  123. //remoteSort: true,
  124. autoLoad: true,
  125. //url: '/lib/php/setup_toolkit/list_vault.php',
  126. storeId: 'a_store',
  127. fields: [{
  128. name: 'id',
  129. type: 'int'
  130. },{
  131. name: 'bk_type',
  132. type: 'int'
  133. },{
  134. name: 'file_name',
  135. type: 'string'
  136. },{
  137. name: 'base_version',
  138. type: 'string'
  139. },{
  140. name: 'ts',
  141. type: 'string'
  142. },{
  143. name: 'size',
  144. type: 'string'
  145. }],
  146. proxy : new Ext.data.HttpProxy({
  147. method: 'POST',
  148. prettyUrls: false,
  149. url: '/lib/php/setup_toolkit/list_vault.php',
  150. headers: {
  151. UID: <?=$UserID;?>,
  152. SID: '<?=$Session;?>'
  153. }
  154. })
  155. });
  156. var archivesColModel_ops = {
  157. columns: [
  158. {header: "Type", width: 50, align: 'center', css: 'vertical-align: middle;', renderer: archiveTypeRenderer, dataIndex: 'bk_type' },
  159. {header: "Version", width: 150, align: 'center', css: 'vertical-align: middle;', dataIndex: 'base_version' },
  160. {header: "Name", width: 280, align: 'left', css: 'vertical-align: middle;', dataIndex: 'file_name' },
  161. {header: "Date", width: 120, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ts' },
  162. {header: "Size", width: 80, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' }
  163. ],
  164. defaults: {
  165. sortable: false,
  166. fixed: true,
  167. menuDisabled: true,
  168. width: 100
  169. }
  170. };
  171. var selectedArchiveRecord = null;
  172. var archivesSelModel_ops = {
  173. singleSelect: true,
  174. listeners: {
  175. rowselect: function(sm, row, rec ) {
  176. //loadEventProperties( rec.data );
  177. //SelectedEvent = rec.data.id;
  178. //alert( SelectedEvent );
  179. //var CB = Ext.getCmp('con_to_src');
  180. //CB.enable();
  181. selectedArchiveRecord = rec;
  182. if( rec.data.bk_type!=3 ){
  183. } else {
  184. };
  185. }
  186. }
  187. };
  188. var initial_md5 = '';
  189. function updateTaskStatus(){
  190. Ext.Ajax.request({
  191. url: '/lib/php/setup_toolkit/getTaskStatus.php',
  192. params: {
  193. UID: <?=$UserID;?>,
  194. SID: '<?=$Session;?>',
  195. IMD: initial_md5
  196. },
  197. success: function( response, opts ){
  198. var data = Ext.decode(response.responseText);
  199. switch( data.status ){
  200. case 0:{
  201. Ext.getCmp('ch_ta_btn').disable();
  202. if( taskIsArmed ){
  203. taskIsArmed = false;
  204. archives_store.reload();
  205. };
  206. break;
  207. };
  208. case 1:{
  209. Ext.getCmp('ch_ta_btn').enable();
  210. taskIsArmed = true;
  211. break;
  212. };
  213. case 2:{
  214. Ext.getCmp('ch_ta_btn').disable();
  215. break;
  216. };
  217. };
  218. Ext.getCmp('ctask_status').update( '<p>'+data.msg +': ' + data.status_desc+'</p>' );
  219. if( initial_md5 != data.log_md5 ){
  220. initial_md5 = data.log_md5;
  221. Ext.getCmp('task_log').setRawValue( data.status_log );
  222. };
  223. },
  224. failure: failureAJAXFunction
  225. });
  226. };
  227. function createNewTask( task_id, param = '' ){
  228. Ext.Ajax.request({
  229. url: '/lib/php/setup_toolkit/createNewTask.php',
  230. params: {
  231. UID: <?=$UserID;?>,
  232. SID: '<?=$Session;?>',
  233. TID: task_id,
  234. PRM: param
  235. },
  236. success: function( response, opts ){
  237. var data = Ext.decode(response.responseText);
  238. if( data.status == 0 ){
  239. Ext.Msg.show({
  240. title:'Error',
  241. msg: data.error,
  242. buttons: Ext.Msg.OK,
  243. icon: Ext.MessageBox.ERROR
  244. });
  245. };
  246. },
  247. failure: failureAJAXFunction
  248. });
  249. };
  250. function deleteNewTask(){
  251. Ext.Ajax.request({
  252. url: '/lib/php/setup_toolkit/cleanNewTask.php',
  253. params: {
  254. UID: <?=$UserID;?>,
  255. SID: '<?=$Session;?>'
  256. },
  257. success: function( response, opts ){
  258. var data = Ext.decode(response.responseText);
  259. if( data.status == 0 ){
  260. Ext.Msg.show({
  261. title:'Error',
  262. msg: data.error,
  263. buttons: Ext.Msg.OK,
  264. icon: Ext.MessageBox.ERROR
  265. });
  266. };
  267. },
  268. failure: failureAJAXFunction
  269. });
  270. };
  271. function loadUpgradeManagmenet(){
  272. if( tlInterval!= null ){
  273. window.clearInterval( tlInterval );
  274. tlInterval = null;
  275. timelineObj = null;
  276. };
  277. setUserContent( 5 );
  278. initial_md5 = '';
  279. Ext.getCmp('main_content').setTitle( '<?=$Labels->GetLabel('_SWU_DASHBOARD_');?>' );
  280. var tPanel = Ext.getCmp('main_portal');
  281. tPanel.removeAll(true);
  282. tPanel.add({
  283. columnWidth: 1.0,
  284. frame: false,
  285. border: false,
  286. items: [{
  287. frame: false,
  288. border: false,
  289. collapsible: false,
  290. draggable: false,
  291. layout: 'vbox',
  292. //layoutConfig: {
  293. // align : 'stretch',
  294. // pack : 'start',
  295. //},
  296. height: PanelH,
  297. items:[{
  298. title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
  299. xtype: 'panel',
  300. height: PanelH-300,
  301. //flex: 1,
  302. frame: true,
  303. width: '100%',
  304. border: false,
  305. layout: {
  306. type: 'table',
  307. columns: 2,
  308. tableAttrs: {
  309. valign: 'top',
  310. style: 'valign:top;width:100%;'
  311. }
  312. },
  313. defaults: {
  314. frame: true,
  315. border: false,
  316. height: ( PanelH-400 ) / 2,
  317. style: 'margin: 5px;width:400px;display:block;'
  318. },
  319. items:[{
  320. title: 'Current System Info',
  321. width: '100%',
  322. //flex: 1,
  323. html: '<p>Current Web Version:&nbsp;<b><?=$ARGUS_WEB_VERSION;?></b></p>'
  324. },{
  325. title: 'Tasks',
  326. //width: 400,
  327. layout: 'vbox',
  328. items:[{
  329. xtype: 'button',
  330. width: '100%',
  331. text: 'Create Database Backup',
  332. handler: function(){
  333. createNewTask( 2 );
  334. }
  335. },{
  336. xtype: 'button',
  337. width: '100%',
  338. text: 'Create Full Snapeshot',
  339. handler: function(){
  340. createNewTask( 255 );
  341. }
  342. }]
  343. },{
  344. title: 'Archives',
  345. height: 250,
  346. width: '100%',
  347. tbar:[{
  348. text: 'Restore',
  349. id: 'ar_restore_btn',
  350. handler: function(){
  351. createNewTask(1, selectedArchiveRecord.data.file_name );
  352. }
  353. },{
  354. text: 'Download',
  355. id: 'ar_download_btn',
  356. handler: function(){
  357. if( selectedArchiveRecord!= null ){
  358. window.open( '/lib/php/setup_toolkit/vault/'+selectedArchiveRecord.data.base_version + '/'+ selectedArchiveRecord.data.file_name );
  359. };
  360. }
  361. },{
  362. text: 'Delete',
  363. id: 'ar_delete_btn',
  364. handler: function(){
  365. createNewTask(100, selectedArchiveRecord.data.file_name );
  366. }
  367. }],
  368. items:[{
  369. xtype: 'grid',
  370. id: 'archives_grid',
  371. border: false,
  372. frame: false,
  373. autoScroll: true,
  374. //width: '100%',
  375. lazyRender: true,
  376. height: 210,
  377. ds: archives_store,
  378. cm: new Ext.grid.ColumnModel( archivesColModel_ops ),
  379. sm: new Ext.grid.RowSelectionModel( archivesSelModel_ops ),
  380. viewConfig: {
  381. // forceFit: true
  382. }
  383. }]
  384. },{
  385. title: 'Task Status',
  386. height: 250,
  387. //flex: 1,
  388. items:[{
  389. xtype: 'spacer',
  390. height: 4
  391. },{
  392. id: 'ctask_status',
  393. border: true,
  394. html: ''
  395. },{
  396. xtype: 'spacer',
  397. height: 4
  398. },{
  399. xtype: 'textarea',
  400. id: 'task_log',
  401. height: ( PanelH-320 ) / 2 - 120,
  402. style: 'font-size:9px;width:100%;margin-bottom:4px;',
  403. readOnly: true,
  404. autoScroll: true,
  405. value: ''
  406. },{
  407. xtype: 'progress',
  408. id: 'task_progress',
  409. value: 1.0,
  410. text: 'idle',
  411. disabled: true
  412. }],
  413. tbar:[{
  414. text: 'Cancel Task',
  415. id: 'ch_ta_btn',
  416. disabled: true,
  417. handler: deleteNewTask
  418. }]
  419. }]
  420. },{
  421. title: '<?=$Labels->getLabel('_UPLOAD_PACKAGE_');?>',
  422. xtype: 'panel',
  423. height: 300,
  424. //flex: 1,
  425. frame: true,
  426. border: false,
  427. //layout: 'vbox',
  428. items:[{
  429. xtype:'button',
  430. id: 'pickfiles',
  431. width: '100%',
  432. text: 'Choose File'
  433. },{
  434. height: 200,
  435. xtype: 'grid',
  436. id: 'upload_grid',
  437. border: false,
  438. frame: false,
  439. mode: 'local',
  440. lazyRender: true,
  441. width: '100%',
  442. autoScroll: true,
  443. ds: uploads_store,
  444. cm: new Ext.grid.ColumnModel( fileUploadsColModel_ops ),
  445. sm: new Ext.grid.RowSelectionModel( fileUploadsSelModel_ops ),
  446. viewConfig: {
  447. forceFit: true
  448. },
  449. bbar: [{
  450. text: 'Clear',
  451. width: '100%',
  452. handler: function(){
  453. muploader.splice();
  454. uploads_store.removeAll();
  455. }
  456. }]
  457. },{
  458. xtype:'button',
  459. id: 'umpalumpa',
  460. width: '100%',
  461. disabled: true,
  462. text: 'Upload',
  463. handler: function(){
  464. if( muploader!= null ){
  465. muploader.start();
  466. };
  467. }
  468. }],
  469. listeners:{
  470. afterrender: function(){
  471. muploader = new plupload.Uploader({
  472. runtimes : 'html5,html4',
  473. browse_button : Ext.getDom('pickfiles'), // you can pass in id...
  474. //container: document.getElementById('upupu'), // ... or DOM Element itself
  475. max_file_size : '1000mb',
  476. chunk_size: '200kb',
  477. max_retries: 3,
  478. multi_selection: false,
  479. max_file_count: 1,
  480. // Fake server response here
  481. url: '/lib/php/setup_toolkit/upload.php',
  482. //url: "/echo/json",
  483. //flash_swf_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf',
  484. //silverlight_xap_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap',
  485. filters : [
  486. //{title : "Image files", extensions : "jpg,gif,png"},
  487. {title : "Archive files", extensions : "rar,zip,gz,bz2"}
  488. ],
  489. init: {
  490. PostInit: function() {
  491. //$('filelist').innerHTML = '';
  492. //$('uploadfiles').onclick = function() {
  493. // uploader.start();
  494. // return false;
  495. //};
  496. },
  497. FilesAdded: function( up, files ) {
  498. Ext.getCmp('umpalumpa').enable();
  499. plupload.each( files, function(file) {
  500. uploads_store.loadData( [[ uploads_store_id, file.name, file.id, plupload.formatSize( file.size ), 0, 'N' ]], true );
  501. uploads_store_id++;
  502. Ext.getCmp('upload_grid').doLayout();
  503. });
  504. },
  505. UploadProgress: function(up, file) {
  506. var pb = Ext.getCmp( 'progress_'+file.id );
  507. if( file.percent < 100 ){
  508. pb.updateProgress( file.percent / 100, file.percent + '%', false );
  509. } else {
  510. pb.updateProgress( 1.0, 'Uploaded', false );
  511. };
  512. },
  513. Error: function(up, err) {
  514. Ext.Msg.show({
  515. title:'Upload Status',
  516. msg: "Error #" + err.code + ": " + err.message,
  517. buttons: Ext.Msg.OK,
  518. icon: Ext.MessageBox.ERROR
  519. });
  520. }
  521. }
  522. });
  523. muploader.init();
  524. }
  525. }
  526. }]
  527. }]
  528. });
  529. muploader = null;
  530. uploads_store.removeAll();
  531. tPanel.doLayout();
  532. archives_store.load();//{params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
  533. updateTaskStatus();
  534. tlInterval = window.setInterval( updateTaskStatus, 333 );
  535. };