GetLabel("_ERROR_MSG_")}',
msg: data['msg'],
buttons: Ext.Msg.OK,
- fn: function(){
- SettingsLidar3D.hide();
- },
icon: Ext.MessageBox.ERROR
});
};
@@ -641,21 +643,18 @@ EFUFU;
xtype: 'checkbox',
fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_TS_')}',
id: 'eve_show_ts',
- disabled: true,
checked: {$CI['show_ts']},
handler: updateFramePreview
},{
xtype: 'checkbox',
fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_LBL_')}',
id: 'eve_show_lbl',
- disabled: true,
checked: {$CI['show_label']},
handler: updateFramePreview
},{
xtype: 'checkbox',
fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_LOGO_')}',
id: 'eve_show_logo',
- disabled: true,
checked: {$CI['show_logo']},
handler: updateFramePreview
}]
@@ -795,22 +794,23 @@ EFUFU;
title: 'Time Stamp',
labelWidth: 180,
labelAlign: 'right',
- disabled: true,
items:[{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_POSX_')}',
id: 'TS_POSX',
width: 120,
- minValue: 0,
- maxValue: 100,
+ allowDecimals: false,
+ minValue: -1920,
+ maxValue: 1920,
value: {$CI['ts_x']}
},{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_POSY_')}',
id: 'TS_POSY',
width: 120,
- minValue: 0,
- maxValue: 100,
+ allowDecimals: false,
+ minValue: -1920,
+ maxValue: 1920,
value: {$CI['ts_y']}
},{
xtype: 'checkbox',
@@ -844,20 +844,22 @@ EFUFU;
displayField: 'szText',
value: {$CI['ts_font_face']}
},{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_FSCALE_')}',
id: 'TS_FSCALE',
width: 120,
- minValue: 0.0,
+ decimalPrecision: 1,
+ minValue: 0.1,
maxValue: 4.0,
value: {$CI['ts_font_scale']}
},{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_FTHICK_')}',
id: 'TS_FTHICK',
width: 120,
+ allowDecimals: false,
minValue: 1,
- maxValue: 8.0,
+ maxValue: 8,
value: {$CI['ts_font_thickness']}
},{
xtype: 'combo',
@@ -872,36 +874,42 @@ EFUFU;
xtype: 'arraystore',
fields: [ 'szId', 'szText' ],
data: [
- [0, 'THIN'],
- [1, 'ANTIALIAZED'],
- [2, 'THICK']
+ [8, 'NORMAL'],
+ [4, 'THIN'],
+ [16, 'ANTIALIASED']
]
},
valueField: 'szId',
displayField: 'szText',
- value: {$CI['ts_line_type']}
+ value: {$TS_LT}
+ },{
+ xtype: 'panel',
+ border: false,
+ bodyStyle: 'padding: 10px',
+ html: '{$Labels->GetLabel('_EVE_POS_HINT_')}
{$Labels->GetLabel('_EVE_TS_HINT_')}
'
}]
},{
xtype: 'form',
title: 'Label',
labelWidth: 180,
labelAlign: 'right',
- disabled: true,
items:[{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_POSX_')}',
id: 'LBL_POSX',
width: 120,
- minValue: 0,
- maxValue: 100,
+ allowDecimals: false,
+ minValue: -1920,
+ maxValue: 1920,
value: {$CI['label_x']}
},{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_POSY_')}',
id: 'LBL_POSY',
width: 120,
- minValue: 0,
- maxValue: 100,
+ allowDecimals: false,
+ minValue: -1920,
+ maxValue: 1920,
value: {$CI['label_y']}
},{
xtype: 'checkbox',
@@ -935,20 +943,22 @@ EFUFU;
displayField: 'szText',
value: {$CI['label_font_face']}
},{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_FSCALE_')}',
id: 'LBL_FSCALE',
width: 120,
- minValue: 0.0,
+ decimalPrecision: 1,
+ minValue: 0.1,
maxValue: 4.0,
value: {$CI['label_font_scale']}
},{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_FTHICK_')}',
id: 'LBL_FTHICK',
width: 120,
+ allowDecimals: false,
minValue: 1,
- maxValue: 8.0,
+ maxValue: 8,
value: {$CI['label_font_thickness']}
},{
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_LINE_T_')}',
@@ -963,36 +973,42 @@ EFUFU;
xtype: 'arraystore',
fields: [ 'szId', 'szText' ],
data: [
- [0, 'THIN'],
- [1, 'ANTIALIAZED'],
- [2, 'THICK']
+ [8, 'NORMAL'],
+ [4, 'THIN'],
+ [16, 'ANTIALIASED']
]
},
valueField: 'szId',
displayField: 'szText',
- value: {$CI['label_line_type']}
+ value: {$LBL_LT}
+ },{
+ xtype: 'panel',
+ border: false,
+ bodyStyle: 'padding: 10px',
+ html: '{$Labels->GetLabel('_EVE_POS_HINT_')}
'
}]
},{
xtype: 'form',
title: 'Logo',
labelWidth: 180,
labelAlign: 'right',
- disabled: true,
items:[{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LOGO_POSX_')}',
id: 'LOGO_POSX',
width: 120,
- minValue: 0,
- maxValue: 100,
+ allowDecimals: false,
+ minValue: -1920,
+ maxValue: 1920,
value: {$CI['logo_x']}
},{
- xtype: 'slider',
+ xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LOGO_POSY_')}',
id: 'LOGO_POSY',
width: 120,
- minValue: 0,
- maxValue: 100,
+ allowDecimals: false,
+ minValue: -1920,
+ maxValue: 1920,
value: {$CI['logo_y']}
},{
xtype: 'numberfield',
@@ -1013,7 +1029,7 @@ EFUFU;
},{
xtype: 'panel',
id: 'eve_logo_ph',
- html: '
'
+ html: '
'
},{
xtype: 'panel',
html: ''
diff --git a/lib/controller/updateServerModuleSettings.php b/lib/controller/updateServerModuleSettings.php
new file mode 100644
index 0000000..75e640b
--- /dev/null
+++ b/lib/controller/updateServerModuleSettings.php
@@ -0,0 +1,90 @@
+ saveSettings()).
+ require_once('../ajax_asm.php');
+ if( $CUser->Data['id'] > 1 ){
+ $Data = array();
+ $Data['success'] = false;
+ $Data['msg'] = 'Module Not Selected!';
+ $MID = isset( $_POST['MID'] ) ? intval( $_POST['MID'] ) : 0;
+ if( $MID > 0 ){
+ $Data['msg'] = 'Module Does Not Exists!';
+ $RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID}", false );
+ if( count( $RR ) ){
+ $CMD = $RR[0];
+ $AUX = intval( $CMD['aux_id'] );
+ // clamp a numeric POST field to [min,max], $def when it is missing
+ $pInt = function( $Name, $Min, $Max, $Def ){
+ if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def;
+ return max( $Min, min( $Max, intval( $_POST[$Name] ) ) );
+ };
+ $pFloat = function( $Name, $Min, $Max, $Def ){
+ if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def;
+ return max( $Min, min( $Max, floatval( $_POST[$Name] ) ) );
+ };
+ $pBool = function( $Name ){
+ if( !isset( $_POST[$Name] ) ) return 0;
+ $V = strtolower( strval( $_POST[$Name] ) );
+ return ( $V === 'true' || $V === '1' || $V === 'on' ) ? 1 : 0;
+ };
+ // OpenCV line types la_mojo accepts (0 and 1 are old values: 8 / 4 connected)
+ $pLine = function( $Name ){
+ $V = isset( $_POST[$Name] ) ? intval( $_POST[$Name] ) : 8;
+ return in_array( $V, array( 0, 1, 4, 8, 16 ) ) ? $V : 8;
+ };
+ switch( intval( $CMD['type'] ) ){
+ case 8:{ // Embed Video Encoder (module_eve)
+ $SiW = array( 320, 640, 800, 1280, 1024, 1920 );
+ $SiH = array( 240, 480, 600, 720, 768, 1080 );
+ $SIZE = $pInt( 'SIZE', 0, count( $SiW ) - 1, 3 );
+ $W = $SiW[$SIZE];
+ $H = $SiH[$SIZE];
+ $F = array(
+ 'web_port' => $pInt( 'PORT', 1, 65535, 8972 ),
+ 'width' => $W,
+ 'height' => $H,
+ 'compression_quality' => $pInt( 'COMPRESSION', 0, 100, 70 ),
+ 'show_ts' => $pBool( 'SHOW1' ),
+ 'show_label' => $pBool( 'SHOW2' ),
+ 'show_logo' => $pBool( 'SHOW3' ),
+ // positions in pixels, negative values are measured from the right / bottom edge
+ 'ts_x' => $pInt( 'TS_POSX', -$W, $W, 5 ),
+ 'ts_y' => $pInt( 'TS_POSY', -$H, $H, 5 ),
+ 'ts_transperant' => $pBool( 'TS_TRANS' ),
+ 'ts_font_face' => $pInt( 'TS_FONT', 0, 7, 1 ),
+ 'ts_font_scale' => $pFloat( 'TS_FONT_SCALE', 0.1, 4.0, 1.0 ),
+ 'ts_font_thickness' => $pInt( 'TS_FONT_THICK', 1, 8, 1 ),
+ 'ts_line_type' => $pLine( 'TS_LINE' ),
+ 'label_x' => $pInt( 'LBL_POSX', -$W, $W, 5 ),
+ 'label_y' => $pInt( 'LBL_POSY', -$H, $H, -10 ),
+ 'label_transperant' => $pBool( 'LBL_TRANS' ),
+ 'label_font_face' => $pInt( 'LBL_FONT', 0, 7, 1 ),
+ 'label_font_scale' => $pFloat( 'LBL_FONT_SCALE', 0.1, 4.0, 1.0 ),
+ 'label_font_thickness' => $pInt( 'LBL_FONT_THICK', 1, 8, 1 ),
+ 'label_line_type' => $pLine( 'LBL_LINE' ),
+ 'logo_x' => $pInt( 'LOG_POSX', -$W, $W, 0 ),
+ 'logo_y' => $pInt( 'LOG_POSY', -$H, $H, 0 ),
+ 'logo_w' => $pInt( 'LOG_W', 0, $W, 0 ),
+ 'logo_h' => $pInt( 'LOG_H', 0, $H, 0 )
+ );
+ $SET = array();
+ foreach( $F as $K => $V ) $SET[] = "`{$K}`=".( is_float( $V ) ? sprintf( '%.3F', $V ) : intval( $V ) );
+ // exec() reports a failure instead of die() in Query()
+ if( $DATABASE->DBLink->exec( "UPDATE `module_eve` SET ".implode( ', ', $SET )." WHERE `id`={$AUX}" ) ){
+ $Data['success'] = true;
+ $Data['msg'] = '';
+ } else {
+ $Data['msg'] = 'Unable to save the settings!';
+ };
+ break;
+ };
+ default:
+ $Data['msg'] = 'Saving the settings of this module type is not supported!';
+ break;
+ };
+ };
+ };
+ echo json_encode( $Data );
+ exit();
+ };
+ header( 'location: /');
+?>
diff --git a/lib/controller/uploadAsset.php b/lib/controller/uploadAsset.php
new file mode 100644
index 0000000..0fbd7fc
--- /dev/null
+++ b/lib/controller/uploadAsset.php
@@ -0,0 +1,62 @@
+: logo of the Embed Video Encoder.
+ // The picture is stored as an RGBA PNG in data/assets/images/.png (the path la_mojo
+ // loads, relative to its working folder) and module_eve.logo_md5 is updated.
+ require_once('../ajax_asm.php');
+ if( $CUser->Data['id'] > 1 ){
+ $Data = array();
+ $Data['success'] = false;
+ $Data['msg'] = 'Wrong Parameters';
+ $TYPE = isset( $_POST['type'] ) ? strval( $_POST['type'] ) : '';
+ $MID = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0;
+ if( $TYPE == 'eve_logo' && $MID > 0 ){
+ $RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID} AND `type`=8", false );
+ if( !count( $RR ) ){
+ $Data['msg'] = 'Module Does Not Exists!';
+ } else if( !isset( $_FILES['file'] ) || $_FILES['file']['error'] != UPLOAD_ERR_OK || !is_uploaded_file( $_FILES['file']['tmp_name'] ) ){
+ $Data['msg'] = 'File upload failed!';
+ } else if( $_FILES['file']['size'] > 4 * 1024 * 1024 ){
+ $Data['msg'] = 'The picture is too big (max 4 MB)!';
+ } else if( !function_exists( 'imagecreatefromstring' ) ){
+ $Data['msg'] = 'PHP GD extension is missing!';
+ } else {
+ $IMG = @imagecreatefromstring( file_get_contents( $_FILES['file']['tmp_name'] ) );
+ if( $IMG === false ){
+ $Data['msg'] = 'Unsupported picture format!';
+ } else {
+ // normalise to a true colour picture with alpha channel (la_mojo uses alpha as mask)
+ $W = imagesx( $IMG );
+ $H = imagesy( $IMG );
+ $OUT = imagecreatetruecolor( $W, $H );
+ imagealphablending( $OUT, false );
+ imagesavealpha( $OUT, true );
+ imagefill( $OUT, 0, 0, imagecolorallocatealpha( $OUT, 0, 0, 0, 127 ) );
+ imagecopy( $OUT, $IMG, 0, 0, 0, 0, $W, $H );
+ imagedestroy( $IMG );
+ ob_start();
+ imagepng( $OUT );
+ $PNG = ob_get_clean();
+ imagedestroy( $OUT );
+ $MD5 = md5( $PNG );
+ $DIR = __DIR__.'/data/assets/images';
+ if( !is_dir( $DIR ) ) @mkdir( $DIR, 0775, true );
+ if( @file_put_contents( $DIR.'/'.$MD5.'.png', $PNG ) === false ){
+ $Data['msg'] = 'Unable to store the picture!';
+ } else {
+ $AUX = intval( $RR[0]['aux_id'] );
+ $DATABASE->DBLink->exec( "UPDATE `module_eve` SET `logo_md5`='{$MD5}' WHERE `id`={$AUX}" );
+ $Data['success'] = true;
+ $Data['msg'] = '';
+ $Data['md5'] = $MD5;
+ $Data['url'] = '/lib/controller/data/assets/images/'.$MD5.'.png';
+ $Data['width'] = $W;
+ $Data['height'] = $H;
+ };
+ };
+ };
+ };
+ echo json_encode( $Data );
+ exit();
+ };
+ header( 'location: /');
+?>
diff --git a/lib/javascript/jsapi_dynamic/rgoose_modules.js b/lib/javascript/jsapi_dynamic/rgoose_modules.js
index 17a36a8..bade98f 100644
--- a/lib/javascript/jsapi_dynamic/rgoose_modules.js
+++ b/lib/javascript/jsapi_dynamic/rgoose_modules.js
@@ -71,7 +71,7 @@ function updateFramePreview(){
ctx.closePath();
if( Ext.getCmp('eve_show_logo').getValue() ){
var image = document.getElementById('eve_logo_img');
- if( image.complete && image.naturalHeight !== 0 ){
+ if( image != null && image.complete && image.naturalHeight !== 0 ){
var i_w = Ext.getCmp('LOGO_WIDTH').getValue();
var i_h = Ext.getCmp('LOGO_HEIGHT').getValue();
ctx.drawImage( image, 120, 120, i_w, i_h );
@@ -92,44 +92,41 @@ async function uploadFile() {
}
function uploadEveLogo(){
- if( embedVideoEncoderId > -1 ){
- var llMask = new Ext.LoadMask( Ext.getCmp('eve_logo_ph').getEl(), {msg:"Please wait..."});
- llMask.show();
- var formData = new FormData();
- var img_upload = document.getElementById('eve_logo_upload');
- formData.append("file", img_upload.files[0]);
- formData.append("type", 'eve_logo');
- formData.append("id", embedVideoEncoderId );
- $.ajax({
- type: 'POST',
- url: '/lib/controller/uploadAsset.php',
- data: formData,
- cache: false,
- contentType: false,
- processData: false,
- success: function( data ){
- llMask.hide();
- console.log("success");
- console.log( data );
- },
- error: function( data ){
- llMask.hide();
- console.log("error");
- console.log(data);
- }
- });
- /*
- Ext.Ajax.request({
- url: SITE_URL+'upload/',
- headers: {'Content-type':'multipart/form-data'},
- form: filefield.up('form').getForm(),
- isUpload: true,
- success: function(response, options) { console.log(arguments); },
- failure: function(response, options) { console.log(arguments); }
- });
- */
-
- };
+ var img_upload = document.getElementById('eve_logo_upload');
+ if( embedVideoEncoderId < 1 || img_upload == null || img_upload.files.length == 0 ) return;
+ var llMask = new Ext.LoadMask( Ext.getCmp('eve_logo_ph').getEl(), {msg:"Please wait..."});
+ llMask.show();
+ var formData = new FormData();
+ formData.append("file", img_upload.files[0]);
+ formData.append("type", 'eve_logo');
+ formData.append("id", embedVideoEncoderId );
+ formData.append("UID", =$UserID;?> );
+ formData.append("SID", '=$Session;?>' );
+ fetch( '/lib/controller/uploadAsset.php', { method: 'POST', body: formData, credentials: 'same-origin' } )
+ .then( function( r ){ return r.json(); } )
+ .then( function( data ){
+ llMask.hide();
+ if( data.success ){
+ var image = document.getElementById('eve_logo_img');
+ if( image ){
+ image.onload = updateFramePreview;
+ image.src = data.url;
+ };
+ // first upload: propose the picture size, kept inside 256x256
+ var lw = Ext.getCmp('LOGO_WIDTH'), lh = Ext.getCmp('LOGO_HEIGHT');
+ if( lw && lh && ( !lw.getValue() || !lh.getValue() ) ){
+ var k = Math.min( 1, 256 / Math.max( data.width, data.height ) );
+ lw.setValue( Math.round( data.width * k ) );
+ lh.setValue( Math.round( data.height * k ) );
+ };
+ } else {
+ Ext.Msg.show({ title: "=$Labels->GetLabel('_ERROR_MSG_');?>", msg: data.msg, buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR });
+ };
+ })
+ .catch( function( e ){
+ llMask.hide();
+ Ext.Msg.show({ title: "=$Labels->GetLabel('_ERROR_MSG_');?>", msg: String( e ), buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR });
+ });
};
var moduleSettingsEditorWindow = null;
@@ -147,6 +144,14 @@ function showModuleSettingsEditor( ModuleID ){
resizable: false,
items:[],
buttons: [{
+ id: 'mo_se_ed_save',
+ text: "=$Labels->GetLabel('_SAVE_');?>",
+ hidden: true,
+ handler: function(){
+ var c = Ext.getCmp('mod_set_content');
+ if( c && typeof c.saveSettings == 'function' ) c.saveSettings();
+ }
+ },{
text: "=$Labels->GetLabel('_CLOSE_');?>",
handler: function(){
moduleSettingsEditorWindow.hide();
@@ -154,6 +159,8 @@ function showModuleSettingsEditor( ModuleID ){
}]
});
};
+ embedVideoEncoderId = ModuleID;
+ Ext.getCmp('mo_se_ed_save').hide();
moduleSettingsEditorWindow.show();
Ext.Ajax.request({
url: '/lib/controller/getModuleSettings.php',
@@ -170,6 +177,7 @@ function showModuleSettingsEditor( ModuleID ){
moduleSettingsEditorWindow.removeAll( true );
moduleSettingsEditorWindow.add( data );
moduleSettingsEditorWindow.doLayout();
+ Ext.getCmp('mo_se_ed_save').setVisible( typeof data.saveSettings == 'function' );
} else {
moduleSettingsEditorWindow.close();
moduleSettingsEditorWindow = null;