2013-03-21 Miguel de Dios <miguel.dedios@artica.es>

* mobile/operation/groups.php, mobile/operation/tactical.php,
	mobile/operation/alerts.php, mobile/operation/events.php,
	mobile/include/style/main.css, mobile/include/ui.class.php,
	mobile/include/user.class.php, include/functions_events.php: updated
	the code of events in mobile.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7876 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-03-21 18:47:28 +00:00
parent dba1396900
commit a66683e048
9 changed files with 435 additions and 46 deletions

View File

@ -1,3 +1,11 @@
2013-03-21 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/groups.php, mobile/operation/tactical.php,
mobile/operation/alerts.php, mobile/operation/events.php,
mobile/include/style/main.css, mobile/include/ui.class.php,
mobile/include/user.class.php, include/functions_events.php: updated
the code of events in mobile.
2013-03-20 Miguel de Dios <miguel.dedios@artica.es>
* mobile/index.php, mobile/operation/events.php,

View File

@ -14,6 +14,10 @@ body {
vertical-align: top;
}
/*INIT----------Groups styles-----------------------------------------*/
.group_view tr {
border-bottom: 3px solid white !important;
}
@ -82,8 +86,45 @@ tr.group_view_data, .group_view_data {
.group_view_data_warn {
color: #5C5900 !important;
}
/*END-----------Groups styles-----------------------------------------*/
/*Fix the square border in search input*/
/*INIT----------Events styles-----------------------------------------*/
.datos_green, .datos_greenf9, .datos_green a, .datos_greenf9 a {
background-color: #52A000;
color: #FFFFFF;
}
.datos_red, .datos_redf9, .datos_red a, .datos_redf9 a {
background-color: #FF3E41;
color: #FFFFFF !important;
}
.datos_yellow, .datos_yellowf9 {
background-color: #F5E535;
color: #000000;
}
a.datos_blue, .datos_bluef9, .datos_blue {
background-color: #77E2F2;
color: #000000;
}
.datos_grey, .datos_greyf9 {
background-color: #E4E4E4;
}
.datos_pink, .datos_pinkf9 {
background-color: #FF92E9;
}
.datos_brown, .datos_brownf9 {
background-color: #C97A4A;
}
tr.events {
border-bottom: 3px solid white !important;
}
/*END-----------Events styles-----------------------------------------*/
/*INIT---------Fix the square border in search input------------------*/
.ui-input-search {
border-radius: 0.6em 0.6em 0.6em 0.6em !important;
}
@ -91,3 +132,21 @@ tr.group_view_data, .group_view_data {
.ui-select {
width: 100% !important;
}
/*END----------Fix the square border in search input------------------*/
/*INIT---------Fix to avoid clicks under loading message--------------*/
.ui-loader-background {
width:100% !important;
height:100% !important;
top:0 !important;
margin: 0 !important;
background: rgba(0, 0, 0, 0.3) !important;
display:none !important;
position: fixed !important;
z-index:100 !important;
}
.ui-loading .ui-loader-background {
display:block !important;
}
/*END----------Fix to avoid clicks under loading message--------------*/

View File

@ -30,6 +30,7 @@ class Ui {
private $endForm = true;
private $endGrid = true;
private $endCollapsible = true;
private $dialogs = array();
private $dialog = '';
public function __construct() {
@ -100,6 +101,7 @@ class Ui {
$this->endGrid = true;
$this->endCollapsible = true;
$this->dialog = '';
$this->dialogs = array();
}
public function showFooter($show = true) {
@ -496,23 +498,71 @@ class Ui {
//<input type="range" name="slider-fill" id="slider-fill" value="60" min="0" max="1000" step="50" data-highlight="true">
}
public function addDialog($title = '', $content = '', $button_text = '') {
$this->dialog = "<div data-role='dialog' data-close-btn='none'>\n";
$this->dialog .= "<div data-role='header'>\n";
$this->dialog .= "<h1>" . $title . "</h1>\n";
$this->dialog .= "</div>\n";
$this->dialog .= "<div data-role='content'>\n";
$this->dialog .= $content;
$this->dialog .= "<a data-role='button' href='#main_page'>";
public function addDialog($options) {
$type = 'hidden';
$dialog_id = uniqid('dialog_');
$dialog_class = '';
$title_close_button = false;
$title_text = '';
$content_id = uniqid('content_');
$content_class = '';
$content_text = '';
$button_close = true;
$button_text = __('Close');
if (is_array($options)) {
if (isset($options['type']))
$type = $options['type'];
if (isset($options['dialog_id']))
$dialog_id = $options['dialog_id'];
if (isset($options['dialog_class']))
$dialog_class = $options['dialog_class'];
if (isset($options['title_close_button']))
$title_close_button = $options['title_close_button'];
if (isset($options['title_text']))
$title_text = $options['title_text'];
if (isset($options['content_id']))
$content_id = $options['content_id'];
if (isset($options['content_class']))
$content_class = $options['content_class'];
if (isset($options['content_text']))
$content_text = $options['content_text'];
if (isset($options['button_close']))
$button_close = $options['button_close'];
if (isset($options['button_text']))
$button_text = $options['button_text'];
}
$html_title_close_button = "";
if ($title_close_button) {
$html_title_close_button = "data-close-btn='yes'";
}
$dialogHtml = "<div id='" . $dialog_id . "' class='" . $dialog_class . "' data-role='dialog' " . $html_title_close_button . ">\n";
$dialogHtml .= "<div data-role='header'>\n";
$dialogHtml .= "<h1 class='dialog_title'>" . $title_text . "</h1>\n";
$dialogHtml .= "</div>\n";
$dialogHtml .= "<div id='" . $content_id . "' class='" . $content_class . "' data-role='content'>\n";
$dialogHtml .= $content_text;
if ($button_close) {
$dialogHtml .= "<a data-role='button' href='#main_page'>";
if (empty($button_text)) {
$this->dialog .= __('Close');
$dialogHtml .= __('Close');
}
else {
$this->dialog .= $button_text;
$dialogHtml .= $button_text;
}
$this->dialog .= "</a></p>\n";
$this->dialog .= "</div>\n";
$this->dialog .= "</div>\n";
$dialogHtml .= "</a></p>\n";
}
$dialogHtml .= "</div>\n";
$dialogHtml .= "</div>\n";
$this->dialogs[$type][] = $dialogHtml;
}
public function showError($msg) {
@ -554,8 +604,13 @@ class Ui {
echo " </head>\n";
echo " <body>\n";
if (!empty($this->dialog)) {
echo " " . $this->dialog . "\n";
echo " <div class='ui-loader-background'> </div>";
if (!empty($this->dialogs)) {
if (!empty($this->dialogs['onStart'])) {
foreach ($this->dialogs['onStart'] as $dialog) {
echo " " . $dialog . "\n";
}
}
}
echo " <div data-role='page' id='main_page'>\n";
echo " <div data-role='header' data-position='fixed' >\n";
@ -579,6 +634,13 @@ class Ui {
}
echo " </div>\n";
echo " </div>\n";
if (!empty($this->dialogs)) {
if (!empty($this->dialogs['hidden'])) {
foreach ($this->dialogs['hidden'] as $dialog) {
echo " " . $dialog . "\n";
}
}
}
echo " </body>\n";
echo "</html>";
ob_end_flush();
@ -591,9 +653,11 @@ class Ui {
class Table {
private $head = array();
private $rows = array();
private $id = array();
public $id = '';
private $rowClass = array();
private $class_table = '';
private $row_heads = array();
public $row_keys_as_head_row = false;
public function __construct() {
$this->init();
@ -605,12 +669,27 @@ class Table {
$this->rows = array();
$this->rowClass = array();
$this->class_table = '';
$this->row_heads = array();
$this->row_keys_as_head_row = false;
}
public function addHeader($head) {
$this->head = $head;
}
public function addRowHead($key, $head_text) {
$this->row_heads[$key] = $head_text;
}
public function addRow($row = array(), $key = false) {
if ($key !== false) {
$this->rows[$key] = $row;
}
else {
$this->rows[] = $row;
}
}
public function importFromHash($data) {
foreach ($data as $id => $row) {
$table_row = array();
@ -624,7 +703,7 @@ class Table {
$table_row[$cell_key] = $value;
}
$this->rows[] = $table_row;
$this->rows[$id] = $table_row;
}
}
@ -663,7 +742,6 @@ class Table {
$html .= "</tr>\n";
$html .= "</thead>\n";
$html .= "<tbody>\n";
foreach ($this->rows as $key => $row) {
$class = '';
@ -673,9 +751,17 @@ class Table {
$html .= "<tr class='" . $class . "'>\n";
//Empty head for white space between rows in the responsive vertical layout
if (isset($this->row_heads[$key])) {
$html .= "<th>" . $this->row_heads[$key] . "</th>\n";
}
elseif ($this->row_keys_as_head_row) {
$html .= "<th>" . $key . "</th>\n";
}
else {
$html .= "<th></th>\n";
foreach ($row as $cell) {
$html .= "<td>" . $cell . "</td>\n";
}
foreach ($row as $key_cell => $cell) {
$html .= "<td class='cell_" . $key_cell . "'>" . $cell . "</td>\n";
}
$html .= "</tr>\n";
}

View File

@ -129,12 +129,20 @@ class User {
$ui->createPage();
if ($this->errorLogin) {
$ui->addDialog(__('Login Failed'),
__('User not found in database or incorrect password.'));
$options['type'] = 'onStart';
$options['title_text'] = __('Login Failed');
$options['content_text'] = __('User not found in database or incorrect password.');
$ui->addDialog($options);
}
if ($this->logout_action) {
$ui->addDialog(__('Logged out'),
__('Your session is over. Please close your browser window to close this Pandora session.'));
$options['type'] = 'onStart';
$options['title_text'] = __('Login out');
$options['content_text'] = __('Your session is over. Please close your browser window to close this Pandora session.');
$ui->addDialog($options);
}
$ui->createHeader();
$ui->showFooter(false);

View File

@ -109,8 +109,12 @@ class Alerts {
$ui = Ui::getInstance();
$ui->createPage();
$ui->addDialog(__('You don\'t have access to this page'),
__('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database'));
$options['type'] = 'onStart';
$options['title_text'] = __('You don\'t have access to this page');
$options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
$ui->addDialog($options);
$ui->showPage();
}

View File

@ -88,6 +88,122 @@ class Events {
echo json_encode(array('end' => $end, 'events' => $events));
break;
case 'get_detail_event':
$id_event = $system->getRequest('id_event', 0);
$event = events_get_event($id_event);
if ($event) {
$event['evento'] = io_safe_output($event['evento']);
$event['clean_tags'] = events_clean_tags($event['tags']);
$event["timestamp"] = date($system->getConfig("date_format"), strtotime($event["timestamp"]));
if(empty($event["owner_user"])) {
$event["owner_user"] = '<i>'.__('N/A').'</i>';
}
else {
$user_owner = db_get_value('fullname', 'tusuario', 'id_user', $event["owner_user"]);
if (empty($user_owner)) {
$user_owner = $event['owner_user'];
}
$event["owner_user"] = $user_owner;
}
$event["event_type"] = events_print_type_img ($event["event_type"], true).' '.events_print_type_description($event["event_type"], true);
if (!isset($group_rep))
$group_rep = 0;
if ($group_rep != 0) {
if($event["event_rep"] <= 1) {
$event["event_repeated"] = '<i>'.__('No').'</i>';
}
else {
$event["event_repeated"] = sprintf("%d Times",$event["event_rep"]);
}
}
else {
$event["event_repeated"] = '<i>'.__('No').'</i>';
}
$event_criticity = get_priority_name ($event["criticity"]);
switch ($event["criticity"]) {
default:
case 0:
$img_sev = "images/status_sets/default/severity_maintenance.png";
break;
case 1:
$img_sev = "images/status_sets/default/severity_informational.png";
break;
case 2:
$img_sev = "images/status_sets/default/severity_normal.png";
break;
case 3:
$img_sev = "images/status_sets/default/severity_warning.png";
break;
case 4:
$img_sev = "images/status_sets/default/severity_critical.png";
break;
case 5:
$img_sev = "images/status_sets/default/severity_minor.png";
break;
case 6:
$img_sev = "images/status_sets/default/severity_major.png";
break;
}
$event["criticity"] = html_print_image ($img_sev, true,
array ("class" => "image_status",
"width" => 12,
"height" => 12,
"title" => $event_criticity));
$event["criticity"] .= ' '.$event_criticity;
if ($event['estado'] == 1) {
$user_ack = db_get_value('fullname', 'tusuario', 'id_user', $event['id_usuario']);
if(empty($user_ack)) {
$user_ack = $event['id_usuario'];
}
$date_ack = date ($config["date_format"], $event['ack_utimestamp']);
$event["acknowledged_by"] = $user_ack.' ('.$date_ack.')';
}
else {
$event["acknowledged_by"] = '<i>'.__('N/A').'</i>';
}
// Get Status
switch($event['estado']) {
case 0:
$img_st = "images/star.png";
$title_st = __('New event');
break;
case 1:
$img_st = "images/tick.png";
$title_st = __('Event validated');
break;
case 2:
$img_st = "images/hourglass.png";
$title_st = __('Event in process');
break;
}
$event["status"] = html_print_image($img_st,true).' '.$title_st;
$event["group"] = ui_print_group_icon ($event["id_grupo"], true);
$event["group"] .= groups_get_name ($event["id_grupo"]);
$event["tags"] = tags_get_tags_formatted($event["tags"]);
if (empty($event["tags"])) {
$event["tags"] = '<i>'.__('N/A').'</i>';
}
echo json_encode(array('correct' => 1, 'event' => $event));
}
else {
echo json_encode(array('correct' => 0, 'event' => array()));
}
break;
}
}
@ -106,8 +222,7 @@ class Events {
$this->default = false;
}
$this->status = $system->getRequest('status', __("Status"));
if ($this->status === __("Status")) {
if (($this->status === __("Status")) || ($this->status == 3)) {
$this->status = 3;
}
else {
@ -122,9 +237,9 @@ class Events {
$this->default = false;
}
$this->severity = $system->getRequest('group', __("Group"));
if ($this->severity === __("Group")) {
$this->severity = 0;
$this->group = $system->getRequest('group', __("Group"));
if (($this->group === __("Group")) || ($this->group == 0)) {
$this->group = 0;
}
else {
$this->default = false;
@ -139,7 +254,7 @@ class Events {
}
$this->filter = $system->getRequest('filter', __('Preset Filters'));
if ($this->filter === __("Preset Filters")) {
if (($this->filter === __("Preset Filters")) || ($this->filter == 0)) {
$this->filter = 0;
}
else {
@ -176,8 +291,12 @@ class Events {
$ui = Ui::getInstance();
$ui->createPage();
$ui->addDialog(__('You don\'t have access to this page'),
__('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database'));
$options['type'] = 'onStart';
$options['title_text'] = __('You don\'t have access to this page');
$options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
$ui->addDialog($options);
$ui->showPage();
}
@ -185,9 +304,41 @@ class Events {
$ui = Ui::getInstance();
$ui->createPage();
$options['type'] = 'hidden';
$options['dialog_id'] = 'detail_event_dialog';
$options['title_close_button'] = true;
$options['title_text'] = __('Event detail');
$table = new Table();
$table->row_keys_as_head_row = true;
$table->addRow(array('event_id' => ""), __('Event ID'));
$table->addRow(array('event_name' => ""), __('Event name'));
$table->addRow(array('event_timestamp' => ""), __('Timestamp'));
$table->addRow(array('event_owner' => ""), __('Owner'));
$table->addRow(array('event_type' => ""), __('Type'));
$table->addRow(array('event_repeated' => ""), __('Repeated'));
$table->addRow(array('event_severity' => ""), __('Severity'));
$table->addRow(array('event_status' => ""), __('Status'));
$table->addRow(array('event_acknowledged_by' => ""), __('Acknowledged by'));
$table->addRow(array('event_group' => ""), __('Group'));
$table->addRow(array('event_tags' => ""), __('Tags'));
$options['content_text'] = $table->getHTML();
$options_button = array(
'text' => __('Validate'));
$options['content_text'] .= $ui->createButton($options_button);
$options['button_close'] = false;
$ui->addDialog($options);
$ui->createDefaultHeader(__("PandoraFMS: Events"));
$ui->showFooter(false);
$ui->beginContent();
$ui->contentAddHtml("<a id='detail_event_dialog_hook' href='#detail_event_dialog' style='display:none;'>detail_event_hook</a>");
//$test = "javascript: $(\"#test\").click();";
$filter_title = sprintf(__('Filter Events by %s'), $this->filterEventsGetString());
$ui->contentBeginCollapsible($filter_title);
$ui->beginForm();
@ -372,9 +523,13 @@ class Events {
$field_status = __('Status');
$field_timestamp = __('Timestamp');
$field_agent = __('Agent');
$row_class = array();
foreach ($events_db as $event) {
$row_class[$event['id_evento']] = "events " . get_priority_class($event['criticity']);
$row = array();
$row[$field_event_name] = io_safe_output($event['evento']);
$row[$field_event_name] = '<a href="javascript: openDetails(' . $event['id_evento'] . ')">' .
io_safe_output($event['evento']) . '</a>';
switch ($event['estado']) {
case 0:
$img_st = "images/star.png";
@ -408,7 +563,10 @@ class Events {
}
else {
$table = new Table();
$table->id = 'list_events';
$table->setRowClass($row_class);
$table->importFromHash($events);
$ui->debug($events, true);
$ui->contentAddHtml($table->getHTML());
if ($system->getPageSize() < $total_events) {
@ -419,9 +577,67 @@ class Events {
$this->addJavascriptAddBottom();
}
$this->addJavascriptDialog();
}
}
private function addJavascriptDialog() {
$ui = Ui::getInstance();
$ui->contentAddHtml("
<script type=\"text/javascript\">
function openDetails(id_event) {
$.mobile.showPageLoadingMsg();
postvars = {};
postvars[\"action\"] = \"ajax\";
postvars[\"parameter1\"] = \"events\";
postvars[\"parameter2\"] = \"get_detail_event\";
postvars[\"id_event\"] = id_event
$.post(\"index.php\",
postvars,
function (data) {
if (data.correct) {
event = data.event;
//Fill the dialog
$(\"#detail_event_dialog h1.dialog_title\")
.html(event[\"evento\"]);
$(\"#detail_event_dialog .cell_event_name\")
.html(event[\"evento\"]);
$(\"#detail_event_dialog .cell_event_id\")
.html(id_event);
$(\"#detail_event_dialog .cell_event_timestamp\")
.html(event[\"timestamp\"]);
$(\"#detail_event_dialog .cell_event_owner\")
.html(event[\"owner_user\"]);
$(\"#detail_event_dialog .cell_event_type\")
.html(event[\"event_type\"]);
$(\"#detail_event_dialog .cell_event_repeated\")
.html(event[\"event_repeated\"]);
$(\"#detail_event_dialog .cell_event_severity\")
.html(event[\"criticity\"]);
$(\"#detail_event_dialog .cell_event_status\")
.html(event[\"status\"]);
$(\"#detail_event_dialog .cell_event_acknowledged_by\")
.html(event[\"acknowledged_by\"]);
$(\"#detail_event_dialog .cell_event_group\")
.html(event[\"group\"]);
$(\"#detail_event_dialog .cell_event_tags\")
.html(event[\"tags\"]);
$.mobile.hidePageLoadingMsg();
$(\"#detail_event_dialog_hook\").click();
}
},
\"json\");
}
</script>");
}
private function addJavascriptAddBottom() {
$ui = Ui::getInstance();
@ -459,7 +675,7 @@ class Events {
}
else {
$.each(data.events, function(key, event) {
$(\"table tbody\").append(\"<tr>\" +
$(\"table#list_events tbody\").append(\"<tr>\" +
\"<th></th>\" +
\"<td>\" + event[0] + \"</td>\" +
\"<td>\" + event[1] + \"</td>\" +

View File

@ -51,8 +51,12 @@ class Groups {
$ui = Ui::getInstance();
$ui->createPage();
$ui->addDialog(__('You don\'t have access to this page'),
__('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database'));
$options['type'] = 'onStart';
$options['title_text'] = __('You don\'t have access to this page');
$options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
$ui->addDialog($options);
$ui->showPage();
}

View File

@ -42,8 +42,12 @@ class Tactical {
$ui = Ui::getInstance();
$ui->createPage();
$ui->addDialog(__('You don\'t have access to this page'),
__('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database'));
$options['type'] = 'onStart';
$options['title_text'] = __('You don\'t have access to this page');
$options['content_text'] = __('Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database');
$ui->addDialog($options);
$ui->showPage();
}