Update visual console view
Former-commit-id: f9d78c01055c88b2e2de62e5b14f3c17e116b155
This commit is contained in:
parent
4a3eaca1cd
commit
633ccc5f10
|
@ -201,7 +201,7 @@ final class Container extends Model
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function getItemsFromDB(int $id_layout): array
|
public static function getItemsFromDB(int $id_layout): string
|
||||||
{
|
{
|
||||||
$layout_items = db_get_all_rows_filter('tlayout_data', ['id_layout' => $id_layout]);
|
$layout_items = db_get_all_rows_filter('tlayout_data', ['id_layout' => $id_layout]);
|
||||||
if (!empty($layout_items) === true) {
|
if (!empty($layout_items) === true) {
|
||||||
|
@ -220,12 +220,6 @@ final class Container extends Model
|
||||||
case SIMPLE_VALUE_MAX:
|
case SIMPLE_VALUE_MAX:
|
||||||
case SIMPLE_VALUE_MIN:
|
case SIMPLE_VALUE_MIN:
|
||||||
case SIMPLE_VALUE_AVG:
|
case SIMPLE_VALUE_AVG:
|
||||||
$value['value'] = visual_map_get_simple_value(
|
|
||||||
$value['type'],
|
|
||||||
$value['id_agente_modulo'],
|
|
||||||
$value['period']
|
|
||||||
);
|
|
||||||
|
|
||||||
array_push(
|
array_push(
|
||||||
$array_items,
|
$array_items,
|
||||||
(string) Items\SimpleValue::fromArray($value)
|
(string) Items\SimpleValue::fromArray($value)
|
||||||
|
@ -319,7 +313,7 @@ final class Container extends Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $array_items;
|
return json_encode($array_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,45 @@ if (!is_metaconsole()) {
|
||||||
use Models\VisualConsole\Container;
|
use Models\VisualConsole\Container;
|
||||||
|
|
||||||
$container = (string) Container::fromArray($layout);
|
$container = (string) Container::fromArray($layout);
|
||||||
$items = Container::getItemsFromDB($id_layout, $config['homedir']);
|
$items = Container::getItemsFromDB($id_layout);
|
||||||
|
|
||||||
hd($config['homedir']);
|
echo '<div id="visual-console-container"></div>';
|
||||||
|
|
||||||
|
$dir = $config['homedir'].'/include/visual-console/';
|
||||||
|
if (is_dir($dir)) {
|
||||||
|
$dh = opendir($dir);
|
||||||
|
if ($dh) {
|
||||||
|
while (($file = readdir($dh)) !== false) {
|
||||||
|
if ($file !== '.' && $file !== '..') {
|
||||||
|
preg_match('/.*.js$/', $file, $match_js, PREG_OFFSET_CAPTURE);
|
||||||
|
if (!empty($match_js)) {
|
||||||
|
echo '<script type="text/javascript"
|
||||||
|
src="'.ui_get_full_url(false, false, false, false).'include/visual-console/'.$match_js[0][0].'"></script>';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
preg_match('/.*.css$/', $file, $match_css, PREG_OFFSET_CAPTURE);
|
||||||
|
if (!empty($match_css)) {
|
||||||
|
echo '<link rel="stylesheet" type="text/css" media="screen"
|
||||||
|
href="'.ui_get_full_url(false, false, false, false).'include/visual-console/'.$match_css[0][0].'" />';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir($dh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<script type="text/javascript">';
|
||||||
|
echo 'var container = document.getElementById("visual-console-container");';
|
||||||
|
echo 'var props = '.$container.';';
|
||||||
|
echo 'var items = '.$items.';';
|
||||||
|
echo '</script>';
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function () {
|
||||||
|
var visualConsole = new VisualConsole(container, props, items);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
hd($items);
|
|
||||||
|
|
|
@ -76,6 +76,9 @@ export function visualConsolePropsDecoder(
|
||||||
// TODO: Document.
|
// TODO: Document.
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||||
function itemInstanceFrom(data: UnknownObject) {
|
function itemInstanceFrom(data: UnknownObject) {
|
||||||
|
if (typeof data === "string") {
|
||||||
|
data = JSON.parse(data);
|
||||||
|
}
|
||||||
const type = parseIntOr(data.type, null);
|
const type = parseIntOr(data.type, null);
|
||||||
if (type == null) throw new TypeError("missing item type.");
|
if (type == null) throw new TypeError("missing item type.");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue