pandorafms/pandora_console/views/dashboard/list.php

198 lines
5.3 KiB
PHP
Raw Normal View History

2020-03-26 12:29:38 +01:00
<?php
/**
* Dashboards View List Table Pandora FMS Console
*
* @category Console Class
* @package Pandora FMS
* @subpackage Dashboards
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
2023-06-08 12:42:10 +02:00
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
2020-03-26 12:29:38 +01:00
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
2023-06-08 11:53:13 +02:00
* Copyright (c) 2005-2023 Pandora FMS
2023-06-08 13:19:01 +02:00
* Please see https://pandorafms.com/community/ for full contribution list
2020-03-26 12:29:38 +01:00
* 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.
* ============================================================================
*/
// Includes.
require_once $config['homedir'].'/include/class/HTML.class.php';
global $config;
ui_require_css_file('dashboards');
2021-02-17 12:19:22 +01:00
if ((bool) \is_metaconsole() === true) {
\ui_require_css_file('meta_dashboards');
}
2020-03-26 12:29:38 +01:00
2023-03-02 19:25:31 +01:00
ui_print_standard_header(
2023-03-01 13:44:01 +01:00
__('Dashboards'),
'',
false,
'',
2023-03-02 19:25:31 +01:00
true,
[],
[
[
'link' => '',
'label' => __('Dashboards'),
],
]
2023-03-01 13:44:01 +01:00
);
2020-03-26 12:29:38 +01:00
if (isset($resultDelete) === true) {
\ui_print_result_message(
$resultDelete,
__('Successfully deleted'),
__('Could not be deleted')
);
}
if (isset($resultCopy) === true) {
\ui_print_result_message(
$resultCopy,
__('Successfully duplicate'),
__('Could not be duplicate')
);
}
if (empty($dashboards) === true) {
ui_print_info_message(
[
'no_close' => true,
'message' => __('There are no dashboards defined.'),
]
);
} else {
$id_table = 'dashboards_list';
$columns = [
'name',
'cells',
'groups',
'favorite',
'full_screen',
];
$column_names = [
__('Name'),
__('Cells'),
__('Group'),
__('Favorite'),
__('Full screen'),
];
2023-09-04 11:09:58 +02:00
if ($manageDashboards === 1) {
$columns[] = 'copy';
$columns[] = 'delete';
$column_names[] = __('Copy');
$column_names[] = __('Delete');
}
ui_print_datatable(
[
'id' => $id_table,
'class' => 'info_table',
'style' => 'width: 100%',
'columns' => $columns,
'column_names' => $column_names,
'ajax_url' => 'include/ajax/dashboard.ajax',
2023-09-04 10:58:15 +02:00
'ajax_data' => [
2023-09-04 11:09:58 +02:00
'method' => 'draw',
'urlDashboard' => $urlDashboard,
'manageDashboards' => $manageDashboards,
2023-09-04 10:58:15 +02:00
],
'default_pagination' => $config['block_size'],
'no_sortable_columns' => [
4,
5,
6,
],
'order' => [
'field' => 'name',
'direction' => 'desc',
],
'search_button_class' => 'sub filter float-right',
'form' => [
'inputs' => [
[
2023-11-22 10:10:35 +01:00
'label' => __('Name'),
'type' => 'text',
2023-11-22 10:10:35 +01:00
'class' => 'w80p',
'id' => 'free_search',
'name' => 'free_search',
],
2023-11-22 10:10:35 +01:00
[
'label' => __('Group'),
'type' => 'select_groups',
'id' => 'group',
'name' => 'group',
],
],
],
2023-11-22 10:10:35 +01:00
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar',
'csv' => false,
]
2020-03-26 12:29:38 +01:00
);
}
2023-03-02 19:25:31 +01:00
$input_button = '';
2020-03-26 12:29:38 +01:00
if ($writeDashboards === 1) {
$text = __('Create a new dashboard');
2020-03-26 12:29:38 +01:00
// Button for display modal options dashboard.
2023-03-02 19:25:31 +01:00
$onclick = 'show_option_dialog('.json_encode(
2020-03-26 12:29:38 +01:00
[
'title' => $text,
'btn_text' => __('Ok'),
'btn_cancel' => __('Cancel'),
'url' => $ajaxController,
'url_ajax' => ui_get_full_url('ajax.php'),
2020-03-26 12:29:38 +01:00
]
);
2023-03-02 19:25:31 +01:00
$onclick .= ')';
$input_button = html_print_button(
2020-03-26 12:29:38 +01:00
__('New dashboard'),
'',
false,
2023-03-02 19:25:31 +01:00
$onclick,
['icon' => 'add'],
2020-03-26 12:29:38 +01:00
true
);
2023-03-02 19:25:31 +01:00
2024-02-12 17:59:27 +01:00
if (isset($output) === false) {
$output = '<div>';
}
2023-02-21 17:07:03 +01:00
$output .= '</div>';
2020-03-26 12:29:38 +01:00
echo $output;
// Div for modal update dashboard.
echo '<div id="modal-update-dashboard" class="invisible"></div>';
2020-03-26 12:29:38 +01:00
}
2023-03-02 19:25:31 +01:00
2024-02-12 17:59:27 +01:00
if (isset($tablePagination) === false) {
$tablePagination = '';
}
2023-03-02 19:25:31 +01:00
html_print_action_buttons(
$input_button,
[
'type' => 'form_action',
'right_content' => $tablePagination,
]
);
ui_require_javascript_file('pandora_dashboards');