Skip to content

Commit cfc6448

Browse files
xmacanTheWitness
andauthored
Add variable panel height (#331)
* first attempt * add height and rename few variables * working on height * fix panels * js change height functionality * number of lines function * it is working! * fix admin alert panel * code cleaning * update --------- Co-authored-by: TheWitness <[email protected]>
1 parent 81b38a3 commit cfc6448

22 files changed

+460
-196
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* feature: Add 24h averages for CPU and poller stats panel
1515
* feature: Add Boost graphs panels - memory usage, pending records
1616
* feature: Add Syslog graphs panels - levels, number of messages
17+
* feature#331: Add variable panel height
1718

1819
--- 4.0.4 ---
1920

display.php

+19-14
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ function display_information() {
6060
$selectedTheme = get_selected_theme();
6161

6262
if (get_filter_request_var('dashboard_id') > 0) {
63-
$_SESSION['dashboard_id'] = get_filter_request_var('dashboard_id');
63+
$_SESSION['dashboard_id'] = get_filter_request_var('dashboard_id');
6464
} elseif (empty($_SESSION['dashboard_id'])) {
65-
$_SESSION['dashboard_id'] = 1;
65+
$_SESSION['dashboard_id'] = 1;
6666
set_request_var('dashboard_id', 1);
6767
} else {
6868
set_request_var('dashboard_id', $_SESSION['dashboard_id']);
@@ -181,8 +181,8 @@ function display_information() {
181181

182182
// Notice about disable cacti dashboard
183183
if (read_config_option('hide_console') != 'on') {
184-
print '<table class="cactiTable"><tr><td class="textAreaNotes">' . __('You can disable rows above in <b>Configure > Settings > General > Hide Cacti Dashboard</b> and use the whole page for Intropage ', 'intropage');
185-
print '<a class="pic" href="' . $config['url_path'] . 'settings.php?tab=general&filter=hide"><i class="intro_glyph fas fa-link"></i></a></td></tr></table></br>';
184+
print '<table class="cactiTable"><tr><td class="textAreaNotes">' . __('You can disable rows above in <b>Configure > Settings > General > Hide Cacti Dashboard</b> and use the whole page for Intropage ', 'intropage');
185+
print '<a class="pic" href="' . $config['url_path'] . 'settings.php?tab=general&filter=hide"><i class="intro_glyph fas fa-link"></i></a></td></tr></table></br>';
186186
}
187187

188188
$dashboards = array_rekey(
@@ -223,7 +223,7 @@ function display_information() {
223223
print '<div id="overlay"><div id="overlay_detail"></div></div>';
224224

225225
// switch dahsboards and form
226-
print '<div>';
226+
print '<div id="intropage_main">';
227227
print '<div class="float_left">';
228228
print "<div class='tabs'><nav><ul>";
229229

@@ -241,7 +241,7 @@ function display_information() {
241241
// settings
242242
print "<form method='post'>";
243243

244-
print "<a href='#' class='pic' id='switch_square' title='" . __esc('Hide red/yellow/green square notifications', 'intropage') . "'><i class='intro_glyph fa fa-minus-square'></i></a>";
244+
print "<a href='#' class='pic' id='switch_square' title='" . __esc('Hide or display red/yellow/green square notifications', 'intropage') . "'><i class='intro_glyph fa fa-minus-square'></i></a>";
245245
print '&nbsp; &nbsp; ';
246246

247247
print "<a href='#' class='pic' id='switch_copytext' title='" . __esc('Disable panel move/enable copy text from panel', 'intropage') . "'><i class='intro_glyph fa fa-clone'></i></a>";
@@ -451,14 +451,18 @@ function display_information() {
451451

452452
print '</select>';
453453
print '</form>';
454-
// end of settings
455454

456455
print '</div>';
457456
print '<br style="clear: both" />';
458457
print '</div>';
459458

460-
print '<div id="megaobal">';
461-
print '<ul id="obal">';
459+
print '<div id="main_container">';
460+
461+
if ($display_wide == 'on') {
462+
print '<ul id="panel_container" class="container_col_4">';
463+
} else {
464+
print '<ul id="panel_container" class="container_col_3">';
465+
}
462466

463467
if (cacti_sizeof($panels) == 0) {
464468
print '<table class="cactiTable">';
@@ -508,14 +512,15 @@ function display_information() {
508512

509513
// extra maint plugin panel - always first
510514
if (api_plugin_is_enabled('maint') && (read_config_option('intropage_maint_plugin_days_before') >= 0)) {
515+
511516
$row = db_fetch_row_prepared("SELECT id, data
512517
FROM plugin_intropage_panel_data
513518
WHERE panel_id = 'maint'
514519
AND user_id = ?",
515520
array($_SESSION['sess_user_id']));
516521

517-
if ($row && strlen($row['data']) > 20 && $dashboard_id == $first_db) {
518-
intropage_display_panel($row['id'], $dashboard_id);
522+
if (isset($row['data']) && $row['data'] != null && $dashboard_id == $first_db) {
523+
intropage_create_panel($row['id'], $dashboard_id);
519524
}
520525
}
521526
// end of extra maint plugin panel
@@ -527,18 +532,18 @@ function display_information() {
527532
WHERE panel_id='admin_alert'");
528533

529534
if ($id && $dashboard_id == $first_db) {
530-
intropage_display_panel($id, $dashboard_id);
535+
intropage_create_panel($id, $dashboard_id);
531536
}
532537
}
533538
// end of admin panel
534539

535540
foreach ($panels as $xkey => $xvalue) {
536-
intropage_display_panel($xvalue['id'], $dashboard_id);
541+
intropage_create_panel($xvalue['id'], $dashboard_id);
537542
}
538543

539544
print '</ul>';
540545
print '<ul class="cloned-slides"></ul>';
541-
print '</div>'; // end of megaobal
546+
print '</div>';
542547

543548
?>
544549
<script type='text/javascript'>

include/database.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function intropage_initialize_database() {
7777
$data['columns'][] = array('name' => 'refresh', 'type' => 'int(10)', 'unsigned' => true, 'default' => '3600');
7878
$data['columns'][] = array('name' => 'trefresh', 'type' => 'int(10)', 'unsigned' => true, 'default' => '3600');
7979
$data['columns'][] = array('name' => 'description', 'type' => 'varchar(200)', 'default' => '', 'NULL' => true);
80+
$data['columns'][] = array('name' => 'height', 'type' => "enum('normal','double','triple')", 'default' => 'normal', 'NULL' => false);
8081

8182
$data['type'] = 'InnoDB';
8283
$data['primary'] = 'panel_id';
@@ -106,6 +107,7 @@ function intropage_initialize_database() {
106107
$data['columns'][] = array('name' => 'trend_interval', 'type' => 'int(9)', 'default' => '300', 'NULL' => false);
107108
$data['columns'][] = array('name' => 'fav_graph_id', 'type' => 'int(11)', 'NULL' => true);
108109
$data['columns'][] = array('name' => 'fav_graph_timespan', 'type' => 'int(2)', 'default' => '1', 'NULL' => false);
110+
$data['columns'][] = array('name' => 'height', 'type' => "enum('normal','double','triple')", 'default' => 'normal', 'NULL' => false);
109111

110112
$data['type'] = 'InnoDB';
111113
$data['primary'] = 'id';
@@ -299,7 +301,6 @@ function intropage_upgrade_database() {
299301
db_execute("DELETE FROM plugin_intropage_panel_data WHERE panel_id = 'trend'");
300302
}
301303

302-
303304
if (cacti_version_compare($oldv, '4.0.4', '<=')) {
304305

305306
$data = array();
@@ -317,6 +318,13 @@ function intropage_upgrade_database() {
317318
api_plugin_register_hook('intropage', 'user_group_remove', 'intropage_user_group_remove', 'setup.php', '1');
318319
}
319320

321+
if (cacti_version_compare($oldv, '4.0.5', '<=')) {
322+
db_execute('ALTER TABLE plugin_intropage_panel_definition
323+
ADD COLUMN `height` enum("normal","double","triple") NOT NULL DEFAULT "normal"');
324+
db_execute('ALTER TABLE plugin_intropage_panel_data
325+
ADD COLUMN `height` enum("normal","double","triple") NOT NULL DEFAULT "normal"');
326+
}
327+
320328
// Set the new version
321329
db_execute_prepared("UPDATE plugin_config
322330
SET version = ?, author = ?, webpage = ?

0 commit comments

Comments
 (0)