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.

505 lines
13 KiB

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