Web Interface For Lite Argus Control modules
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.
 
 
 
 

569 lines
15 KiB

//<?php require_once('../../js_asm.php'); ?>
var muploader = null;
var uploads_store_id = 0;
var uploads_store = new Ext.data.ArrayStore({
autoDestroy: false,
storeId: 'up_store',
idIndex: 0,
fields: [
{name: 'id', type: 'int' },
{name: 'file_name', type: 'string'},
{name: 'file_id', type: 'string'},
{name: 'size', type: 'string'},
{name: 'progress', type: 'int'},
{name: 'status', type: 'string' }
]
});
var uploaded_store_id = 0;
var uploaded_store = new Ext.data.ArrayStore({
autoDestroy: false,
storeId: 'mod_store',
idIndex: 0,
fields: [
{name: 'id', type: 'int' },
{name: 'file_name', type: 'string'},
{name: 'size', type: 'int'},
{name: 'status', type: 'int'},
{name: 'ts', type: 'string' },
{name: 'memo', type: 'string' }
]
});
function progressRenderer( value, meta, record ){
Ext.defer( function( id ){
var p = new Ext.ProgressBar({
id: 'progress_'+id,
renderTo: 'div_'+id,
animate: false,
width: '100%',
value: 0,
text: 'Upload Pending',
});
}, 50, undefined, [ record.data.file_id ] );
return '<div id="div_' + record.data.file_id + '"></div>';
};
var fileUploadsColModel_ops = {
columns: [
{header: "ID", width: 50, align: 'center', css: 'vertical-align: middle;', dataIndex: 'id' },
{header: "File Name", width: 280, fixed: false, align: 'left', css: 'vertical-align: middle;', dataIndex: 'file_name' },
{header: "Size", width: 80, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' },
{header: "Progress", width: 150, renderer: progressRenderer, dataIndex: 'progress' },
{header: " ", width: 50, dataIndex: 'status3' }
],
defaults: {
sortable: false,
fixed: true,
menuDisabled: true,
width: 100
}
};
function loadModuleFiles( sensorID ){
Ext.Ajax.request({
url: '/lib/controller/getDeviceFiles.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
DID: sensorID
},
success: function( response, opts ){
var data = Ext.decode( response.responseText );
uploaded_store.removeAll();
uploaded_store.loadData( data.files );
},
failure: failureAJAXFunction
});
};
function onModuleFileRenderer( value, meta, record ){
if( value == 0 ){
rv = '<img title="Ready to Upload" alt="Ready to Upload" src="/style/assets/bul_green.png">';
} else {
if( value < 101 ){
rv = '<img title="Uploading" alt="Uploading" src="/style/assets/bul_gray.png">';
} else {
rv = '<img title="Already Uploaded" alt="Already Uploaded" src="/style/assets/bul_blue.png">';
};
};
return rv;
};
var fileModuleColModel_ops = {
columns: [
{header: "ID", width: 50, align: 'center', css: 'vertical-align: middle;', dataIndex: 'id' },
{header: "File Name", width: 60, fixed: false, align: 'left', css: 'vertical-align: middle;', dataIndex: 'file_name' },
{header: "Size", width: 80, renderer: plupload.formatSize, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' },
{header: "Time", width: 150, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ts' },
{header: "Status", width: 50, renderer: onModuleFileRenderer, dataIndex: 'status' },
{header: "Memo", dataIndex: 'memo' }
],
defaults: {
sortable: false,
fixed: true,
menuDisabled: true,
width: 100
}
};
var fileUploadsSelModel_ops = {
singleSelect: true
};
function archiveTypeRenderer( value, meta, record ){
var alt_txt = '';
var img_src = '';
if( record.data.bk_type == 3 ){
alt_txt = 'Full System Snapeshot';
img_src = '/style/icons/icons/rosette.png';
} else {
alt_txt = 'Database Backup';
img_src = '/style/icons/icons/database.png';
};
return '<div><img alt="'+alt_txt+'" src="'+img_src+'"></div>';
};
var taskIsArmed = false;
var archives_store = new Ext.data.JsonStore({
root: 'backups',
totalProperty: 'totalCount',
idProperty: 'id',
//remoteSort: true,
autoLoad: true,
//url: '/lib/php/setup_toolkit/list_vault.php',
storeId: 'a_store',
fields: [{
name: 'id',
type: 'int'
},{
name: 'bk_type',
type: 'int'
},{
name: 'file_name',
type: 'string'
},{
name: 'base_version',
type: 'string'
},{
name: 'ts',
type: 'string'
},{
name: 'size',
type: 'string'
}],
proxy : new Ext.data.HttpProxy({
method: 'POST',
prettyUrls: false,
url: '/lib/php/setup_toolkit/list_vault.php',
headers: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
}
})
});
var archivesColModel_ops = {
columns: [
{header: "Type", width: 50, align: 'center', css: 'vertical-align: middle;', renderer: archiveTypeRenderer, dataIndex: 'bk_type' },
{header: "Version", width: 150, align: 'center', css: 'vertical-align: middle;', dataIndex: 'base_version' },
{header: "Name", width: 280, align: 'left', css: 'vertical-align: middle;', dataIndex: 'file_name' },
{header: "Date", width: 120, align: 'left', css: 'vertical-align: middle;', dataIndex: 'ts' },
{header: "Size", width: 80, align: 'left', css: 'vertical-align: middle;', dataIndex: 'size' }
],
defaults: {
sortable: false,
fixed: true,
menuDisabled: true,
width: 100
}
};
var selectedArchiveRecord = null;
var archivesSelModel_ops = {
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec ) {
//loadEventProperties( rec.data );
//SelectedEvent = rec.data.id;
//alert( SelectedEvent );
//var CB = Ext.getCmp('con_to_src');
//CB.enable();
selectedArchiveRecord = rec;
if( rec.data.bk_type!=3 ){
} else {
};
}
}
};
var initial_md5 = '';
function updateTaskStatus(){
Ext.Ajax.request({
url: '/lib/php/setup_toolkit/getTaskStatus.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
IMD: initial_md5
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
switch( data.status ){
case 0:{
Ext.getCmp('ch_ta_btn').disable();
if( taskIsArmed ){
taskIsArmed = false;
archives_store.reload();
};
break;
};
case 1:{
Ext.getCmp('ch_ta_btn').enable();
taskIsArmed = true;
break;
};
case 2:{
Ext.getCmp('ch_ta_btn').disable();
break;
};
};
Ext.getCmp('ctask_status').update( '<p>'+data.msg +': ' + data.status_desc+'</p>' );
if( initial_md5 != data.log_md5 ){
initial_md5 = data.log_md5;
Ext.getCmp('task_log').setRawValue( data.status_log );
};
},
failure: failureAJAXFunction
});
};
function createNewTask( task_id, param = '' ){
Ext.Ajax.request({
url: '/lib/php/setup_toolkit/createNewTask.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>',
TID: task_id,
PRM: param
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
if( data.status == 0 ){
Ext.Msg.show({
title:'Error',
msg: data.error,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
};
},
failure: failureAJAXFunction
});
};
function deleteNewTask(){
Ext.Ajax.request({
url: '/lib/php/setup_toolkit/cleanNewTask.php',
params: {
UID: <?=$UserID;?>,
SID: '<?=$Session;?>'
},
success: function( response, opts ){
var data = Ext.decode(response.responseText);
if( data.status == 0 ){
Ext.Msg.show({
title:'Error',
msg: data.error,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
};
},
failure: failureAJAXFunction
});
};
function loadUpgradeManagmenet(){
if( tlInterval!= null ){
window.clearInterval( tlInterval );
tlInterval = null;
timelineObj = null;
};
setUserContent( 5 );
initial_md5 = '';
Ext.getCmp('main_content').setTitle( '<?=$Labels->GetLabel('_SWU_DASHBOARD_');?>' );
var tPanel = Ext.getCmp('main_portal');
tPanel.removeAll(true);
tPanel.add({
columnWidth: 1.0,
frame: false,
border: false,
items: [{
frame: false,
border: false,
collapsible: false,
draggable: false,
layout: 'vbox',
//layoutConfig: {
// align : 'stretch',
// pack : 'start',
//},
height: PanelH,
items:[{
title: '<?=$Labels->getLabel('_MAP_MONITORING_');?>',
xtype: 'panel',
height: PanelH-300,
//flex: 1,
frame: true,
width: '100%',
border: false,
layout: {
type: 'table',
columns: 2,
tableAttrs: {
valign: 'top',
style: 'valign:top;width:100%;'
}
},
defaults: {
frame: true,
border: false,
height: ( PanelH-400 ) / 2,
style: 'margin: 5px;width:400px;display:block;'
},
items:[{
title: 'Current System Info',
width: '100%',
//flex: 1,
html: '<p>Current Web Version:&nbsp;<b><?=$ARGUS_WEB_VERSION;?></b></p>'
},{
title: 'Tasks',
//width: 400,
layout: 'vbox',
items:[{
xtype: 'button',
width: '100%',
text: 'Create Database Backup',
handler: function(){
createNewTask( 2 );
}
},{
xtype: 'button',
width: '100%',
text: 'Create Full Snapeshot',
handler: function(){
createNewTask( 255 );
}
}]
},{
title: 'Archives',
height: 250,
width: '100%',
tbar:[{
text: 'Restore',
id: 'ar_restore_btn',
handler: function(){
createNewTask(1, selectedArchiveRecord.data.file_name );
}
},{
text: 'Download',
id: 'ar_download_btn',
handler: function(){
if( selectedArchiveRecord!= null ){
window.open( '/lib/php/setup_toolkit/vault/'+selectedArchiveRecord.data.base_version + '/'+ selectedArchiveRecord.data.file_name );
};
}
},{
text: 'Delete',
id: 'ar_delete_btn',
handler: function(){
createNewTask(100, selectedArchiveRecord.data.file_name );
}
}],
items:[{
xtype: 'grid',
id: 'archives_grid',
border: false,
frame: false,
autoScroll: true,
//width: '100%',
lazyRender: true,
height: 210,
ds: archives_store,
cm: new Ext.grid.ColumnModel( archivesColModel_ops ),
sm: new Ext.grid.RowSelectionModel( archivesSelModel_ops ),
viewConfig: {
// forceFit: true
}
}]
},{
title: 'Task Status',
height: 250,
//flex: 1,
items:[{
xtype: 'spacer',
height: 4
},{
id: 'ctask_status',
border: true,
html: ''
},{
xtype: 'spacer',
height: 4
},{
xtype: 'textarea',
id: 'task_log',
height: ( PanelH-320 ) / 2 - 120,
style: 'font-size:9px;width:100%;margin-bottom:4px;',
readOnly: true,
autoScroll: true,
value: ''
},{
xtype: 'progress',
id: 'task_progress',
value: 1.0,
text: 'idle',
disabled: true
}],
tbar:[{
text: 'Cancel Task',
id: 'ch_ta_btn',
disabled: true,
handler: deleteNewTask
}]
}]
},{
title: '<?=$Labels->getLabel('_UPLOAD_PACKAGE_');?>',
xtype: 'panel',
height: 300,
//flex: 1,
frame: true,
border: false,
//layout: 'vbox',
items:[{
xtype:'button',
id: 'pickfiles',
width: '100%',
text: 'Choose File'
},{
height: 200,
xtype: 'grid',
id: 'upload_grid',
border: false,
frame: false,
mode: 'local',
lazyRender: true,
width: '100%',
autoScroll: true,
ds: uploads_store,
cm: new Ext.grid.ColumnModel( fileUploadsColModel_ops ),
sm: new Ext.grid.RowSelectionModel( fileUploadsSelModel_ops ),
viewConfig: {
forceFit: true
},
bbar: [{
text: 'Clear',
width: '100%',
handler: function(){
muploader.splice();
uploads_store.removeAll();
}
}]
},{
xtype:'button',
id: 'umpalumpa',
width: '100%',
disabled: true,
text: 'Upload',
handler: function(){
if( muploader!= null ){
muploader.start();
};
}
}],
listeners:{
afterrender: function(){
muploader = new plupload.Uploader({
runtimes : 'html5,html4',
browse_button : Ext.getDom('pickfiles'), // you can pass in id...
//container: document.getElementById('upupu'), // ... or DOM Element itself
max_file_size : '1000mb',
chunk_size: '200kb',
max_retries: 3,
multi_selection: false,
max_file_count: 1,
// Fake server response here
url: '/lib/php/setup_toolkit/upload.php',
//url: "/echo/json",
//flash_swf_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf',
//silverlight_xap_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap',
filters : [
//{title : "Image files", extensions : "jpg,gif,png"},
{title : "Archive files", extensions : "rar,zip,gz,bz2"}
],
init: {
PostInit: function() {
//$('filelist').innerHTML = '';
//$('uploadfiles').onclick = function() {
// uploader.start();
// return false;
//};
},
FilesAdded: function( up, files ) {
Ext.getCmp('umpalumpa').enable();
plupload.each( files, function(file) {
uploads_store.loadData( [[ uploads_store_id, file.name, file.id, plupload.formatSize( file.size ), 0, 'N' ]], true );
uploads_store_id++;
Ext.getCmp('upload_grid').doLayout();
});
},
UploadProgress: function(up, file) {
var pb = Ext.getCmp( 'progress_'+file.id );
if( file.percent < 100 ){
pb.updateProgress( file.percent / 100, file.percent + '%', false );
} else {
pb.updateProgress( 1.0, 'Uploaded', false );
};
},
Error: function(up, err) {
Ext.Msg.show({
title:'Upload Status',
msg: "Error #" + err.code + ": " + err.message,
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
}
}
});
muploader.init();
}
}
}]
}]
});
muploader = null;
uploads_store.removeAll();
tPanel.doLayout();
archives_store.load();//{params:{start:0, limit:50, src: 'arch', fil: selecredActiveSourceFilter }});
updateTaskStatus();
tlInterval = window.setInterval( updateTaskStatus, 333 );
};