Visual Console Refactor: minor fixes

Former-commit-id: 9959423e5556abe8f3fa2cbcd289a7ca1b5367bd
This commit is contained in:
Alejandro Gallardo Escobar 2019-04-12 10:06:53 +02:00
parent 08ffb3cd2f
commit 5d154eee04
3 changed files with 21 additions and 13 deletions

View File

@ -210,6 +210,10 @@ final class Container extends Model
throw new \Exception('error fetching the data from the DB');
}
// Load side libraries.
global $config;
include_once $config['homedir'].'/include/functions_ui.php';
$backgroundUrl = static::extractBackgroundUrl($row);
$backgroundImage = static::extractBackgroundImage($row);

View File

@ -47,8 +47,7 @@ require_once 'include/functions_visual_map.php';
$hash = (string) get_parameter('hash');
$visualConsoleId = (int) get_parameter('id_layout');
$config['id_user'] = (string) get_parameter('id_user');
$refr = (int) get_parameter('refr', 0);
$layout = db_get_row('tlayout', 'id', $visualConsoleId);
$refr = (int) get_parameter('refr', $config['refr']);
if (!isset($config['pure'])) {
$config['pure'] = 0;
@ -61,22 +60,22 @@ if ($myhash != $hash) {
exit;
}
if (!$layout) {
// Load Visual Console.
use Models\VisualConsole\Container as VisualConsole;
$visualConsole = null;
try {
$visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]);
} catch (Throwable $e) {
db_pandora_audit(
'ACL Violation',
'Trying to access visual console without id layout'
'Trying to access visual console without Id'
);
include $config['homedir'].'/general/noaccess.php';
exit;
}
use Models\VisualConsole\Container as VisualConsole;
$visualConsoleName = $layout['name'];
// TODO: Show an error message when the models can't be loaded.
$visualConsole = VisualConsole::fromArray($layout);
$visualConsoleItems = VisualConsole::getItemsFromDB($visualConsoleId);
$visualConsoleData = $visualConsole->toArray();
$visualConsoleName = $visualConsoleData['name'];
// TODO: Extract to a function.
$baseUrl = ui_get_full_url(false, false, false, false);
@ -138,8 +137,12 @@ echo '<div style="display: none;" id="qrcode_container" title="'.__('QR code of
echo '<div id="qrcode_container_image"></div>';
echo '</div>';
// Load Visual Console Items.
$visualConsoleItems = VisualConsole::getItemsFromDB($visualConsoleId);
ui_require_javascript_file('pandora_visual_console');
?>
<script type="text/javascript">
var container = document.getElementById("visual-console-container");
var props = <?php echo (string) $visualConsole; ?>;
@ -153,7 +156,7 @@ ui_require_javascript_file('pandora_visual_console');
props,
items,
baseUrl,
10000,
<?php echo ($refr * 1000); ?>,
handleUpdate
);

View File

@ -22,6 +22,7 @@ require_once $config['homedir'].'/include/functions_visual_map.php';
// Query parameters.
$visualConsoleId = (int) get_parameter(!is_metaconsole() ? 'id' : 'id_visualmap');
$pure = (bool) get_parameter('pure', $config['pure']);
$refr = (int) get_parameter('refr', $config['refr']);
// Load Visual Console.
use Models\VisualConsole\Container as VisualConsole;
@ -226,7 +227,7 @@ ui_require_javascript_file('pandora_visual_console');
props,
items,
baseUrl,
100000,
<?php echo ($refr * 1000); ?>,
handleUpdate
);