From b7e64f14776a62616617ea290033e652dfae7217 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 18 Dec 2020 13:23:35 +0100 Subject: [PATCH] Visual console list mobile view --- .../images/visual_console.menu.png | Bin 0 -> 8400 bytes pandora_console/mobile/include/style/main.css | 6 + .../mobile/include/system.class.php | 2 +- pandora_console/mobile/index.php | 12 ++ pandora_console/mobile/operation/home.php | 16 +- .../mobile/operation/visualmaps.php | 187 +++++++++++------- 6 files changed, 150 insertions(+), 73 deletions(-) create mode 100644 pandora_console/images/visual_console.menu.png diff --git a/pandora_console/images/visual_console.menu.png b/pandora_console/images/visual_console.menu.png new file mode 100644 index 0000000000000000000000000000000000000000..818beae6f2355799893dd2be8baaca5fa5239824 GIT binary patch literal 8400 zcmeHLc{r49+o#RGM5t_IB*YkFEHjLK-?A?u8M82$#mrzRWJ#8?q=b~RXARj#Ng+$N zvSo=DlBJYXBJ~dS^z?l1^F8nP9LM+m_sntJGxv2}zw>vV*Y7&d>%Omvvp#Ih#lD}N ziHV8J)WpD+@hh--vF>7gUl+w;jm0hw6U^` zBWW+xxedNG#JfkrQXf2{9bUS6aY`s}@g@R|X>yt|dmt#wtpnh_I^$?>RXX)`{bM)vf6ty^EyYHr%2_4#y! zt%mS?jYK2m%ZhUHsF0l8xxNh%ne6RHs)bkJI-}$2dWYZna|A3deEy=kJ=|>4jjpgh zbG$X=2{cIs>x}1_Jgah?IdDVP)mw2v^P$cAL&Kx>ZzdcgbtgyXXwDZxK6Y)SekFbD zlvQ0^j~8}A#jJmL9eV4;?Qrg*v^a5W?Q5;~Ghq*1w28AH)x4~HdMksR+?w;AO$_4Y z7WhTw4%RJHHp?x~eij*#dvC_RqUtu86lm{m>4hgf7(5(wbY&2A^b$e-VFnWDgvzX3 zaIboZ9%%JlHF6Kh^saub`m819I4Gzm6co~PX@qJieeg}@6(eXm?TJkAx^P9(_8!^f z_U1W)+%RTGw7fn-dTHgJM93s*`eFpJVmAD_Qv%C|62&uWrs#O={D(N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P*{<1j7mWI{TkIK6`DbXhIy)~crsWpiYN?7Sq+K>!Qm)HkTO&mgHl03kuVf$i)wQn z)OD>*HGxVBiof?*`yr`VA{nmPKcs{lG4@)8l`T;U_>&K4Tnd1VZbDU*Ve%1vZymA!w?p^SsM)It$xN_ z)b+_2B$Y_ECldWMft#@cHYvAC3V`@gEb10S)Ry5E7=zxdw;vU!hx7t(H4)&y0{6!oup{tWz+$(FI#QK;l#)BiB3|A9k%PgfI$ zEs-4ji+?+e|M%AS4apC;B^3a$wF#&rQQzgKAOkVzttDXS_vtSIBo+etGUNV*cL8c%CsHkKmur#~*32Svmj3&yRHbFM425|KsFu>HCjd|H$>X z6!=@{e+&FicKyG}#s2#V8$)2c=mjy(&)rx1VEn^EGd0k)hdr1X1jp{t z+0*{6Ps0fwRGH2h5A%T4=cw9n%g1{tdRGc_9^6^7>uxyf!Gtz#%NuN`v*sfATEv)B zykRr2FHt$M_o~m3<=<2_Mz%#D)779;pL=eJCw-&u9CT58A%XoG`C)&%x$Ke#=!USd zzgYG`CPJ&_Vw+we@f|@H6A%i3=HB+$`6SkPPI}m-(0^m(gwNv-8KZ5lhqIq{$W&?Q zpA<#h7jg98_sJ-N+b*Ptnct~WKuC#VjP1p|TzqWy?%LTt$>&CP+NWCTqY`NF@<&3n z_|fiLX&LLTX=+H};rn4>24B4U#d@D{(qRv?6tz3E@9CNIEw;#tw06d>B0965zNfPH;+&4%zxs3gVG#f z4(pev1~y+&%Rir=A~onDKIBq8Oox%@gqi4(C_G)%_3h3I7r)B$
'.__('Please remember that any attempts to access this page will be recorded on the %s System Database.', get_product_name()); } diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 71b6db82ac..6cb2b4a56c 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -349,6 +349,18 @@ switch ($action) { $agent = new Agent(); $agent->show(); break; + + case 'visualmap': + $id = $system->getRequest('id', null); + if ($id !== null) { + $vc = new Visualmap(); + $vc->show(); + } else { + // Show a list ov VC. + $vc_list = new Visualmaps(); + $vc_list->show(); + } + break; } break; } diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php index d49f42eb0b..1fd8a79a47 100644 --- a/pandora_console/mobile/operation/home.php +++ b/pandora_console/mobile/operation/home.php @@ -59,12 +59,16 @@ class Home 'menu_item' => true, 'icon' => 'groups', ]; - $items['console'] = [ - 'name' => __('Visual consoles'), - 'filename' => 'vconsole.php', - 'menu_item' => true, - 'icon' => 'consoles', - ]; + + if ((bool) $system->getConfig('legacy_vc', false) === false) { + // Show Visual consoles only if new system is enabled. + $items['visualmap'] = [ + 'name' => __('Visual consoles'), + 'filename' => 'visualmaps.php', + 'menu_item' => true, + 'icon' => 'visual_console', + ]; + } if (!$system->getConfig('metaconsole')) { $items['alerts'] = [ diff --git a/pandora_console/mobile/operation/visualmaps.php b/pandora_console/mobile/operation/visualmaps.php index 632f0ff1a9..1159e14409 100644 --- a/pandora_console/mobile/operation/visualmaps.php +++ b/pandora_console/mobile/operation/visualmaps.php @@ -1,56 +1,107 @@ checkACL($this->acl)) { - $this->correct_acl = true; + $this->allowed = true; } else { - $this->correct_acl = false; + $this->allowed = false; } } + /** + * Prepare filters for current view. + * + * @return void + */ private function getFilters() { $system = System::getInstance(); $user = User::getInstance(); - $this->default_filters['group'] = true; - $this->default_filters['type'] = true; + $this->defaultFilters['group'] = true; + $this->defaultFilters['type'] = true; $this->group = (int) $system->getRequest('group', __('Group')); if (!$user->isInGroup($this->acl, $this->group)) { @@ -61,7 +112,7 @@ class Visualmaps $this->group = 0; } else { $this->default = false; - $this->default_filters['group'] = false; + $this->defaultFilters['group'] = false; } $this->type = $system->getRequest('type', __('Type')); @@ -69,14 +120,19 @@ class Visualmaps $this->type = '0'; } else { $this->default = false; - $this->default_filters['type'] = false; + $this->defaultFilters['type'] = false; } } + /** + * Run view. + * + * @return void + */ public function show() { - if (!$this->correct_acl) { + if (!$this->allowed) { $this->show_fail_acl(); } else { $this->getFilters(); @@ -85,12 +141,19 @@ class Visualmaps } + /** + * Show a message about failed ACL access. + * + * @return void + */ private function show_fail_acl() { $error['type'] = 'onStart'; $error['title_text'] = __('You don\'t have access to this page'); $error['content_text'] = System::getDefaultACLFailText(); - if (class_exists('HomeEnterprise')) { + + // Redirect to main page. + if (class_exists('HomeEnterprise') === true) { $home = new HomeEnterprise(); } else { $home = new Home(); @@ -100,6 +163,11 @@ class Visualmaps } + /** + * Show visual console list header. + * + * @return void + */ private function show_visualmaps() { $ui = Ui::getInstance(); @@ -124,57 +192,44 @@ class Visualmaps } + /** + * Show list of visual consoles. + * + * @return void + */ private function listVisualmapsHtml() { $system = System::getInstance(); $ui = Ui::getInstance(); - // Create filter - $where = []; - // Order by type field - $where['order'] = 'type'; + $visualmaps = visual_map_get_user_layouts(); - if ($this->group != '0') { - $where['id_group'] = $this->group; - } - - if ($this->type != '0') { - $where['type'] = $this->type; - } - - // Only display maps of "All" group if user is administrator - // or has "RR" privileges, otherwise show only maps of user group - $id_user = $system->getConfig('id_user'); - $own_info = get_user_info($id_user); - if ($own_info['is_admin'] || $system->checkACL($this->acl)) { - $maps = visual_map_get_user_layouts(); - } else { - $maps = visual_map_get_user_layouts($id_user, false, false, false); - } - - if (empty($maps)) { - $maps = []; - } - - $list = []; - foreach ($maps as $map) { - $row = []; - $row[__('Name')] = ''.io_safe_output($map['name']).''; - // $row[__('Type')] = $map['type']; - $row[__('Group')] = ui_print_group_icon($map['id_group'], true, 'groups_small', '', false); - $list[] = $row; - } - - if (count($maps) == 0) { + if (empty($visualmaps) === true) { $ui->contentAddHtml('

'.__('No maps defined').'

'); } else { $table = new Table(); + // Without header jquery.mobile crashes. + $table->addHeader(['']); $table->id = 'list_visualmaps'; - $table->importFromHash($list); - $ui->contentAddHtml($table->getHTML()); - } + foreach ($visualmaps as $map) { + $link = ''.io_safe_output($map['name']).''; - $ui->contentAddLinkListener('list_visualmaps'); + $row = $link; + $row .= ui_print_group_icon( + $map['id_group'], + true, + 'groups_small', + '', + false + ); + $table->addRow([ $map['id'].' flex-center' => $row]); + } + + $ui->contentAddHtml($table->getHTML()); + $ui->contentAddLinkListener('list_visualmaps'); + } }