Fixes with scroll in agents and modules

This commit is contained in:
José González 2022-02-23 18:04:23 +01:00
parent e2d6b30d51
commit f6a8fdf085
3 changed files with 124 additions and 76 deletions

View File

@ -1,15 +1,33 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Agent view for mobile
*
* @category Mobile
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
require_once '../include/functions_users.php';
class Agent
@ -41,7 +59,7 @@ class Agent
var isgentoo = /Gentoo/i.test(navigator.userAgent);
var iscentos = /CentOS/i.test(navigator.userAgent);
var issuse = /SUSE/i.test(navigator.userAgent);
if(!(ismobile) && !(iswindows) && !(ismac) && !(isubuntu) && !(isfedora) && !(isredhat) && !(isdebian) && !(isgentoo) && !(iscentos)
&& !(issuse)){
window.location.href = '".$config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$this->id."';
@ -256,10 +274,9 @@ class Agent
SECONDS_1DAY,
'',
true,
false,
true,
1,
''
500,
1
);
$html .= '</div>';
$html .= '</div>';

View File

@ -1,15 +1,33 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Agents list view for mobile
*
* @category Mobile
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
class Agents
{
@ -67,7 +85,7 @@ class Agents
$listAgents = $this->getListAgents($page, true);
if (!empty($listAgents['agents'])) {
if (empty($listAgents['agents']) === false) {
$end = 0;
$agents = [];
@ -96,7 +114,7 @@ class Agents
$system = System::getInstance();
$user = User::getInstance();
// Default
// Default.
$filters = [
'free_search' => '',
'status' => -1,
@ -104,7 +122,7 @@ class Agents
];
$serialized_filters = (string) $system->getRequest('agents_filter');
if (!empty($serialized_filters)) {
if (empty($serialized_filters) === true) {
$filters_unsafe = json_decode(base64_decode($serialized_filters, true), true);
if ($filters_unsafe) {
$filters = $system->safeInput($filters_unsafe);
@ -144,8 +162,8 @@ class Agents
$filters['group'] = $this->group;
}
if (!empty($filters)) {
// Store the filter
if (empty($filters) === false) {
// Store the filter.
$this->serializedFilters = base64_encode(json_encode($system->safeOutput($filters)));
}
}
@ -260,7 +278,7 @@ class Agents
$search_sql = '';
if (!empty($this->free_search)) {
if (empty($this->free_search) === false) {
$search_sql = " AND (
alias LIKE '%".$this->free_search."%'
OR nombre LIKE '%".$this->free_search."%'
@ -461,15 +479,13 @@ class Agents
"<script type=\"text/javascript\">
var load_more_rows = 1;
var page = 1;
function custom_scroll() {
if (load_more_rows) {
if ($(this).scrollTop() + $(this).height()
>= ($(document).height() - 100)) {
load_more_rows = 0;
postvars = {};
postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"agents\";
@ -479,7 +495,7 @@ class Agents
postvars[\"free_search\"] = $(\"input[name='free_search']\").val();
postvars[\"page\"] = page;
page++;
$.post(\"index.php\",
postvars,
function (data) {
@ -499,23 +515,26 @@ class Agents
\"<td class='cell_6'>\" + agent[8] + \"</td>\" +
\"</tr>\");
});
load_more_rows = 1;
refresh_link_listener_list_agents();
}
},
\"json\");
// Clean
$('#loading_rows').remove();
}
}
}
$(document).ready(function() {
// Be sure of fill all of screen first.
custom_scroll();
$(window).bind(\"scroll\", function () {
custom_scroll();
});
$(window).on(\"touchmove\", function(event) {
custom_scroll();
});

View File

@ -1,15 +1,33 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// phpcs:disable Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
/**
* Modules list view for mobile
*
* @category Mobile
* @package Pandora FMS
* @subpackage Community
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2022 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* ============================================================================
*/
// Begin.
class Modules
{
@ -106,7 +124,7 @@ class Modules
}
if (isset($filters['status'])) {
$this->status = $filters['status'];
$this->status = (int) $filters['status'];
}
if (isset($filters['name'])) {
@ -143,7 +161,7 @@ class Modules
}
$this->status = $system->getRequest('status', __('Status'));
if (($this->status === __('Status')) || ($this->status == AGENT_MODULE_STATUS_ALL)) {
if (($this->status === __('Status')) || ((int) $this->status === AGENT_MODULE_STATUS_ALL)) {
$this->status = AGENT_MODULE_STATUS_ALL;
} else {
$this->default = false;
@ -390,35 +408,28 @@ class Modules
}
// Part SQL fro Status
if ($this->status == AGENT_MODULE_STATUS_NORMAL) {
// Normal
$sql_conditions .= ' AND tagente_estado.estado = 0
if ((int) $this->status == AGENT_MODULE_STATUS_NORMAL) {
// Normal.
$sql_conditions .= ' AND tagente_estado.estado = 0
AND (utimestamp > 0 OR (tagente_modulo.id_tipo_modulo IN(21,22,23,100))) ';
} else if ($this->status == AGENT_MODULE_STATUS_CRITICAL_BAD) {
// Critical
} else if ((int) $this->status === AGENT_MODULE_STATUS_CRITICAL_BAD) {
// Critical.
$sql_conditions .= ' AND tagente_estado.estado = 1 AND utimestamp > 0';
} else if ($this->status == AGENT_MODULE_STATUS_WARNING) {
// Warning
} else if ((int) $this->status === AGENT_MODULE_STATUS_WARNING) {
// Warning.
$sql_conditions .= ' AND tagente_estado.estado = 2 AND utimestamp > 0';
} else if ($this->status == AGENT_MODULE_STATUS_NOT_NORMAL) {
// Not normal
} else if ((int) $this->status === AGENT_MODULE_STATUS_NOT_NORMAL) {
// Not normal.
$sql_conditions .= ' AND tagente_estado.estado <> 0';
} else if ($this->status == AGENT_MODULE_STATUS_UNKNOWN) {
// Unknown
} else if ((int) $this->status === AGENT_MODULE_STATUS_UNKNOWN) {
// Unknown.
$sql_conditions .= ' AND tagente_estado.estado = 3 AND tagente_estado.utimestamp <> 0';
} else if ($this->status == AGENT_MODULE_STATUS_NOT_INIT) {
// Not init
} else if ((int) $this->status === AGENT_MODULE_STATUS_NOT_INIT) {
// Not init.
$sql_conditions .= ' AND tagente_estado.utimestamp = 0
AND tagente_modulo.id_tipo_modulo NOT IN (21,22,23,100)';
}
if ($this->status != AGENT_MODULE_STATUS_NOT_INIT) {
// When filter is not "not init"
// Not show not init modules. It's only operation view
$sql_conditions .= ' AND (tagente_estado.utimestamp != 0
OR tagente_modulo.id_tipo_modulo IN (21,22,23,100))';
}
if ($this->tag > 0) {
$sql_conditions .= ' AND tagente_modulo.id_agente_modulo IN (
SELECT ttag_module.id_agente_modulo
@ -435,7 +446,7 @@ class Modules
SELECT ttag_module.id_tag
FROM ttag_module
WHERE ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo))
AS tags,
AS tags,
tagente_modulo.id_agente_modulo,
tagente.intervalo AS agent_interval,
tagente.nombre AS agent_name,
@ -476,6 +487,7 @@ class Modules
ON ttag_module.id_agente_modulo = tagente_modulo.id_agente_modulo'.$sql_conditions_all;
$sql_limit = 'ORDER BY tagente.nombre ASC ';
if (!$this->all_modules) {
$sql_limit = ' LIMIT '.(int) ($page * $system->getPageSize()).','.(int) $system->getPageSize();
}