Browse Source

Changes MER-1

master
Evgeny Gagua 3 years ago
parent
commit
0238b2d716
  1. 2
      lib/1.json
  2. 2
      lib/controller/doApplicationOperation.php
  3. 38
      lib/controller/doDatabaseOperation.php
  4. 20
      lib/controller/downloadSettings.php
  5. 35
      lib/controller/downloadVideo.php
  6. 5
      lib/javascript/clipchamp/player.js
  7. 6
      lib/javascript/jsapi_dynamic/mojo_map.js
  8. 91
      lib/javascript/jsapi_dynamic/mojo_reports.js
  9. 158
      lib/javascript/jsapi_dynamic/mojo_settings.js
  10. BIN
      style/assets/nosignal.mp4
  11. 7
      style/style.css

2
lib/1.json
File diff suppressed because it is too large
View File

2
lib/controller/doApplicationOperation.php

@ -26,7 +26,7 @@
$Data['success'] = true;
break;
};
case 3:{
case 3:{//Ident Update
$RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db');
$PARAM = md5( time() );
$QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES(1,249,0,'{$PARAM}')";

38
lib/controller/doDatabaseOperation.php

@ -0,0 +1,38 @@
<?php
require_once('../ajax_asm.php');
function verbose( $ok=1,$info=""){
// failure to upload throws 400 error
if( $ok==0 ){
http_response_code(400);
};
die(json_encode(["ok"=>$ok, "info"=>$info]));
};
if( $CUser->Data['id'] > 1 ){
if( empty( $_FILES ) || $_FILES['db_file']['error'] ){
verbose( 0, "Failed to move uploaded file.[" . $_FILES['db_file']['error'] . "]" );
};
$filePath = $SYSPath . 'lib/controller/data';
if( !file_exists( $filePath ) ){
if( !mkdir($filePath, 0777, true ) ){
verbose( 0, "Failed to create $filePath" );
};
};
if( file_exists( $_FILES['db_file']['tmp_name'] ) ){
$MD5 = md5_file( $_FILES['db_file']['tmp_name'] );
$TArr = explode( '.', $_FILES['db_file']['name'] );
$EXT = 'db';
$FNAME = $MD5 . '.' . $EXT;
copy( $_FILES['db_file']['tmp_name'], $filePath . '/' . $FNAME );
@unlink( $_FILES['db_file']['tmp_name'] );
$RBASE = new SQLite_DB( '/dev/shm/argus/mem_db.db');
$PARAM = $MD5;
$QS = "INSERT INTO `nodes_qcq`(`node_id`,`cmd`,`status`,`parameter`) VALUES(1,129,0,'{$PARAM}')";
$RBASE->Query( $QS, false );
verbose( 1, "ALL IS OK" );
};
} else {
verbose( 0, 'Access Denied!' );
};
?>

20
lib/controller/downloadSettings.php

@ -0,0 +1,20 @@
<?php
$NN = './data/'.md5(time()).'.db';
$COM = "sqlite3 ./data/mysqlitedb.db '.clone {$NN}'";
$JUJA = `$COM`;
if( file_exists( $NN ) ){
$FD = fopen( $NN , "r" );
if( $FD ){
header( 'Content-Type: application/vnd.sqlite3;' );
while(!feof( $FD ) ){
echo fread( $FD, 2048 );
};
fclose( $FD );
};
unlink( $NN );
} else {
echo "Error!";
};
?>

35
lib/controller/downloadVideo.php

@ -0,0 +1,35 @@
<?php
function output_dummy( $DST ){
$FD = fopen( $DST, "r" );
if( $FD ){
header( 'Content-Type: video/mp4;' );
while(!feof( $FD ) ){
echo fread( $FD, 2048 );
};
fclose( $FD );
};
};
if( isset( $_POST['FLOC'] ) ){
//'/lib/controller/' = 16 chars
$SRC = substr( $_POST['FLOC'], 16 );
$FPS = intval( $_POST['FFPS'] );
if( file_exists( $SRC ) ){
$DST = '../tmp/' . md5_file( $SRC ) . '.mp4';
//echo $SRC . "->" . $DST . "\n\n"; exit();
$COM = "ffmpeg -hide_banner -loglevel error -y -r {$FPS} -i {$SRC} -pix_fmt yuvj420p -b:v 4000k -c:v libx264 {$DST} 2>&1";
$JUJA = `$COM`;
if( file_exists( $DST ) ){
output_dummy( $DST );
unlink( $DST );
} else output_dummy( '../../style/assets/nosignal.mp4' );
} else output_dummy( '../../style/assets/nosignal.mp4' );
} else output_dummy( '../../style/assets/nosignal.mp4' );
//-crf 20 -r 9 -b:v 3500 -filter:v "setpts=2.0 * PTS" ^M
?>

5
lib/javascript/clipchamp/player.js

@ -132,9 +132,10 @@
btn = document.createElement('div');
btn.setAttribute( 'id', 'btn_loop'+wrapperElement.id );
btn.setAttribute( 'onclick', "stop_loop_mjpeg('btn_loop"+wrapperElement.id+"');" );
//btn.setAttribute( 'onclick', "stop_loop_mjpeg('btn_loop"+wrapperElement.id+"');" );
btn.setAttribute( 'onclick', "downloadVideoFile( videoFileURI, videoFileFPS, videoFileDownloadTarget );" );
btn.classList.add('pl_ctl_btn');
btn.classList.add('loop');
btn.classList.add('download_button');
ctlDIV.appendChild(btn);
dWE.appendChild(ctlDIV);
if (jpegFiles.length > 0) {

6
lib/javascript/jsapi_dynamic/mojo_map.js

@ -989,7 +989,7 @@ function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
attributionControl: aK,
//preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
center: [SiteLat,SiteLon],
/*zoomControl: false,
zoom: 17,
minZoom: 17,
@ -1013,7 +1013,7 @@ function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
attributionControl: false,
preferCanvas: true,
zoomControl: true,
center: [SiteLat, SiteLon],
center: [SiteLat,SiteLon],
/*zoomControl: false,*/
zoom: 0,
minZoom: 0,
@ -1023,7 +1023,7 @@ function loadLocationEditor( el_id , node_type, node_id, lat, lon ){
var bounds = [[MAP_SET.bounds_lx,MAP_SET.bounds_ly], [MAP_SET.bounds_rx,MAP_SET.bounds_ry]];
var image = L.imageOverlay( '/lib/controller/data/assets/images/'+MAP_SET.layer_url, bounds ).addTo( map_ed );
}
map_ed.setView([SiteLat, SiteLon], MAP_SET.maxZoom);
map_ed.setView([SiteLat,SiteLon], MAP_SET.maxZoom);
if( node_type ){
ed_anchor = L.marker([SiteLat, SiteLon], { draggable: false, icon: SITEZ_Icon, zIndexOffset: 1000 } ).addTo(map_ed).bindPopup("<b><?=$Labels->GetLabel('_SYS_ANCHORT_LBL_');?></b>");//.openPopup();
} else {

91
lib/javascript/jsapi_dynamic/mojo_reports.js

@ -749,7 +749,7 @@ function loadEventData( record ){
//var mjpegUrl = "http://127.0.0.1/web/Images/Stream/somevideo.mjpeg";
var fps = data.fps;
var autoloop = true;
setVideoDownloadButton( tVL, data.fps, ( data.uts+data.uts_ms/1000 ) );
$( video_t ).clipchamp_mjpeg_player( VideoLinks[data.node_id] , fps, autoloop,
function( wrapperElement, playerInterface ) {
//playerInterface.finish();
@ -1482,11 +1482,7 @@ function loadReportDayTree( ts ){
xtype: 'treepanel',
autoScroll: true,
width: '100%',
<?php if( $CUser->Data['access'] > 3 ){ ?>
height: PanelH-260,
<?php } else { ?>
height: PanelH-209,
<?php }; ?>
height: PanelH-206,
border: true,
frame: true,
loader: new Ext.tree.TreeLoader(),
@ -1517,19 +1513,6 @@ function loadReportDayTree( ts ){
Ext.getCmp('chu_adate').hide();
initReportsView();
}
<?php if( $CUser->Data['access'] > 3 ){ ?>
},{
xtype: 'spacer',
height: 10
},{
xtype: 'button',
width: '100%',
scale: 'large',
iconCls: 'reports_delete_btn',
text: '<?=$Labels->GetLabel('_BTN_CLR_SELECTED_');?>',
handler: function(){
}
<?php }; ?>
}]
});
sPanel.doLayout();
@ -1576,7 +1559,7 @@ function initReportsView(){
html: '<div id="activity_ph"></div>',
listeners:{
afterrender: function(){
ReportMask = new Ext.LoadMask(Ext.getCmp('main_content').getEl(), {msg:"Please wait..."});
ReportMask = new Ext.LoadMask(Ext.getCmp('main_content').getEl(), {msg:"<?=$Labels->GetLabel('_Please_Wait_');?>..."});
ReportMask.show();
var jj = (PanelW - 230)/55;
changeStyleSheet('amap-empty-day','{width: '+jj+'px; height: '+jj+'px;}');
@ -1616,18 +1599,66 @@ function initReportsView(){
border: false,
items: [{
html: '<div class="setEd_infoPanel" id="NANA"><?=$Labels->GetLabel('_PLS_SEL_CAL_DATE_');?></div>',
<?php if( $CUser->Data['access'] > 3 ){ ?>
height: PanelH - 70
},{
xtype: 'button',
width: '100%',
scale: 'large',
iconCls: 'reports_delete_btn',
text: '<?=$Labels->GetLabel('_BTN_CLR_AHIST_');?>'
<?php } else { ?>
height: PanelH - 30
<?php }; ?>
}]
});
sPanel.doLayout();
};
var videoFileDownloadTarget = '';
var videoFileURI = '';
var videoFileFPS = 15;
function setVideoDownloadButton( URI, fps, ts ){
var d = new Date( ts );
videoFileDownloadTarget = d.getFullYear()+'_'+(d.getMonth()+1)+'_'+d.getDate()+'_'+d.getHours()+'-'+d.getMinutes()+'-'+d.getSeconds()+'.mp4';
videoFileURI = URI;
videoFileFPS = fps;
};
//downloadVideoFile( videoFileURI, videoFileFPS, videoFileDownloadTarget );
function downloadVideoFile( z, b, c ){
//Ext.getCmp('main_content').getEl()
ReportMask = new Ext.LoadMask(Ext.getBody(), {msg:"<?=$Labels->GetLabel('_Please_Wait_');?>..."});
ReportMask.show();
const formData = new FormData();
formData.append("UID",<?=$UserID;?>);
formData.append("SID",'<?=$Session;?>');
formData.append("FLOC", z );
formData.append("FFPS", b );
fetch('/lib/controller/downloadVideo.php',{
//headers: {
// 'Accept': 'video/mp4',
// 'Content-Type': 'multipart/form-data',
// 'KAKA': 'JUJA'
//},
method: "POST",
body: formData
})
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
// the filename you want
a.download = c;//'video.mp4';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
ReportMask.hide();
Ext.Msg.show({
title:'<?=$Labels->GetLabel('_SUCCESS_');?>',
msg: '<?=$Labels->GetLabel('_VIDEO_FILE_HAS_DOWNLOADED_');?>',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.INFO
});
})
.catch(() => {
ReportMask.hide();
Ext.Msg.show({
title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
});
};

158
lib/javascript/jsapi_dynamic/mojo_settings.js

@ -1411,6 +1411,54 @@ function fetchDeviceUploadStatus(){
});
};
function downloadSettings(){
ReportMask = new Ext.LoadMask(Ext.getBody(), {msg:"<?=$Labels->GetLabel('_Please_Wait_');?>..."});
ReportMask.show();
const formData = new FormData();
formData.append("UID",<?=$UserID;?>);
formData.append("SID",'<?=$Session;?>');
fetch('/lib/controller/downloadSettings.php',{
method: "POST",
body: formData
})
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
var today=new Date();
var SY=1900+today.getYear();
var SMO=today.getMonth()+1;
var SD=today.getDate();
var SH = today.getHours();
var SM = today.getMinutes();
var SS = today.getSeconds();
a.download = 'backup_'+SY+'.'+SMO+'.'+SD+'_'+SH+'-'+SM+'-'+SS+'.db';
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
ReportMask.hide();
Ext.Msg.show({
title:'<?=$Labels->GetLabel('_SUCCESS_');?>',
msg: '<?=$Labels->GetLabel('_DB_FILE_HAS_DOWNLOADED_');?>',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.INFO
});
})
.catch(() => {
ReportMask.hide();
Ext.Msg.show({
title:'<?=$Labels->GetLabel('_REQ_FAILURE_');?>',
msg: '<?=$Labels->GetLabel('_AJX_REQFAILURE_');?>',
buttons: Ext.Msg.OK,
icon: Ext.MessageBox.ERROR
});
});
};
function showSettingsGeneral(){
stopStatusUpdater();
@ -2190,7 +2238,6 @@ function showSettingsVideo(){
updateUserContent();
updateServerStatus();
};
function showSettingsApplication(){
stopStatusUpdater();
content_lvl1 = 1;
@ -2212,6 +2259,7 @@ function showSettingsApplication(){
xtype: 'form',
labelAlign: 'right',
labelWidth: 180,
height: PanelH - 30,
items:[{
xtype: 'spacer',
height: 10
@ -2275,7 +2323,7 @@ function showSettingsApplication(){
}
}
}]
},{
}/*,{
title: '<?=$Labels->GetLabel('_MONIT_LAYOUT_');?>',
layout:'table',
defaults: {
@ -2288,7 +2336,7 @@ function showSettingsApplication(){
},
frame: false,
border: false,
height: 800,
height: PanelH - 30,
items:[{
xtype: 'spacer',
width: 100
@ -2397,7 +2445,7 @@ function showSettingsApplication(){
border: false,
html: '<img width="43px" src="/style/assets/ed-5.png" />'
}]
},{
}*/,{
title: '<?=$Labels->GetLabel('_GEO_LOCATION_');?>',
layout: 'column',
items:[{
@ -2548,6 +2596,108 @@ function showSettingsApplication(){
html:'<div class="setEd_infoPanel" id="NUNU"><?=$Labels->GetLabel('_PLS_SEL_LEFT_ITEM_');?></div>'
}]
}]
},{
title: '<?=$Labels->GetLabel('_BACKUP_SETTINGS_');?>',
xtype: 'form',
id: 'as_dbbackup',
fileUpload: true,
labelAlign: 'right',
labelWidth: 180,
height: PanelH - 30,
items:[{
xtype: 'spacer',
height: 10
},{
xtype: 'button',
text: '<?=$Labels->GetLabel( '_DOWNLOAD_SETTINGS_' );?>',
width: 500,
handler: downloadSettings
},{
xtype: 'spacer',
height: 10
},{
xtype: 'fileuploadfield',
id: 'db_file',
emptyText: '<?=$Labels->GetLabel('_DB_BACKUP_');?>',
fieldLabel: '<?=$Labels->GetLabel('_SELE_DBBACKUP_');?>',
width: 300,
name: 'db_file',
buttonText: '<?=$Labels->GetLabel('_BROWSE_');?>'
},{
xtype: 'spacer',
height: 10
},{
xtype: 'button',
text: '<?=$Labels->GetLabel( '_APLY_DBBACKUP_' );?>',
width: 500,
handler: function(){
if( Ext.getCmp('as_dbbackup').getForm().isValid()){
Ext.getCmp('as_dbbackup').getForm().submit({
url: '/lib/controller/doDatabaseOperation.php',
waitMsg: '<?=$Labels->GetLabel('_DB_UPLOAD_BACKUP_');?>...',
encoding: 'multipart/form-data',
success: function(fp, o){
}
});
};
}
},{
xtype: 'spacer',
height: 10
}<?php
if( file_exists( '../../controller/data/factory.db' ) ){
?>,{
xtype: 'button',
text: '<?=$Labels->GetLabel( '_FACTORY_RESET_' );?>',
width: 500,
handler: function(){
doDeviceOperation( 1, 254, '', true );
}
}<?php
};
?>]
},{
title: '<?=$Labels->GetLabel('_REPORT_STORAGE_');?>',
xtype: 'form',
id: 'as_reposit',
labelAlign: 'right',
labelWidth: 180,
height: PanelH - 30,
items:[{
xtype: 'spacer',
height: 10
},{
xtype: 'numberfield',
id: 'stor_days',
emptyText: '<?=$Labels->GetLabel('_SELE_DBBACKUP_');?>',
fieldLabel: '<?=$Labels->GetLabel('_STORE_DAYS_');?>',
width: 300,
value: <?=intval($AP_DATA['report_cleanup']);?>,
name: 'db_time',
},{
xtype: 'spacer',
height: 10
},{
xtype: 'slider',
id: 'stor_space',
fieldLabel: '<?=$Labels->GetLabel('_SELE_DBBACKUP_');?>',
value: <?=intval($AP_DATA['preserve_empty']);?>,
width: 300,
name: 'db_space',
},{
xtype: 'spacer',
height: 10
},{
xtype: 'button',
text: '<?=$Labels->GetLabel( '_APPLY_SETTINGS_' );?>',
width: 500,
handler: function(){
doDeviceOperation( 1, 250, '', true );
}
},{
xtype: 'spacer',
height: 10
}]
}]
});
tPanel.doLayout();

BIN
style/assets/nosignal.mp4

Binary file not shown.

7
style/style.css

@ -1452,7 +1452,7 @@ input[type="range"]:focus::-moz-range-thumb {
background-image: url( 'assets/picons2.png' );
}
.pl_ctl_btn.loop{
float: right;
float: right;
background-position: -2px -34px;
background-image: url( 'assets/picons2.png' );
}
@ -1470,11 +1470,12 @@ input[type="range"]:focus::-moz-range-thumb {
}
.pl_ctl_btn.download_button{
background-position: 0px -80px;
float: right;
background-position: -2px -80px;
background-image: url( 'assets/picons2.png' );
}
.pl_ctl_btn.download_button:hover{
background-position: 0px -65px;
background-position: -2px -65px;
background-image: url( 'assets/picons2.png' );
}
.pl_ctl_btn.fullscreen_button{

Loading…
Cancel
Save