Skip to content

Commit 4cfcb2d

Browse files
committed
Issue: Intropage was not saving the users desired priority
* Really it was saving it in the wrong table. As we discuss the ordering more, there will likely be additional changes though.
1 parent 4781a40 commit 4cfcb2d

File tree

6 files changed

+27
-9
lines changed

6 files changed

+27
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* issue#316: Fix php error when db check skip huge db
77
* issue#327: Move Timespan from action menu
88
* issue: Fix support for Cacti 1.3+
9+
* issue: Intropage was not remembering the users desired panel order
910
* feature: Add 24h averages for CPU and poller stats panel
1011
* feature: Add Boost graphs panels - memory usage, pending records
1112
* feature: Add Syslog graphs panels - levels, number of messages

INFO

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
[info]
2323
name = intropage
24-
version = 4.0.4
24+
version = 4.0.5
2525
longname = Intropage/Dashboard
2626
author = The Cacti Group, Petr Macek
2727

display.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ function display_information() {
9797
array($_SESSION['sess_user_id'], $dashboard_id));
9898

9999
if (cacti_sizeof($panels)) {
100-
101100
$removed = 0;
102101

103102
foreach ($panels as $one) {
@@ -126,23 +125,23 @@ function display_information() {
126125
}
127126

128127
// User allowed panels
129-
$panels = db_fetch_assoc_prepared("SELECT pd.*
128+
$panels = db_fetch_assoc_prepared("SELECT pd.*, pda.priority AS user_priority
130129
FROM plugin_intropage_panel_data AS pd
131130
INNER JOIN plugin_intropage_panel_dashboard AS pda
132131
ON pd.id = pda.panel_id
133132
WHERE pd.user_id in (0, ?)
134133
AND pda.dashboard_id = ?
135134
AND pd.panel_id != 'favourite_graph'
136135
UNION
137-
SELECT t3.*
136+
SELECT t3.*, t4.priority AS user_priority
138137
FROM plugin_intropage_panel_data as t3
139138
INNER JOIN plugin_intropage_panel_dashboard AS t4
140139
ON t3.id = t4.panel_id
141140
WHERE t3.user_id = ?
142141
AND t4.dashboard_id = ?
143142
AND t3.panel_id = 'favourite_graph'
144143
AND t3.fav_graph_id IS NOT NULL
145-
ORDER BY priority DESC",
144+
ORDER BY user_priority DESC",
146145
array(
147146
$_SESSION['sess_user_id'],
148147
$dashboard_id,
@@ -577,7 +576,8 @@ function display_information() {
577576
var intropage_autorefresh = <?php print $autorefresh;?>;
578577
var intropage_drag = true;
579578
var intropage_square = true;
580-
var intropage_page = '';
579+
var callbackPage = '';
580+
var redirectPage = '';
581581
var dashboard_id = <?php print $dashboard_id;?>;
582582
var intropage_text_panel_details = '<?php print __('Panel Details', 'intropage');?>';
583583
var intropage_text_panel_disable = '<?php print __esc('Disable panel move/Enable copy text from panel', 'intropage');?>';

include/database.php

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ function intropage_initialize_database() {
8787
$data['columns'][] = array('name' => 'panel_id', 'type' => 'int(11)', 'NULL' => false);
8888
$data['columns'][] = array('name' => 'user_id', 'type' => 'int(11)', 'NULL' => false);
8989
$data['columns'][] = array('name' => 'dashboard_id', 'type' => 'int(11)', 'NULL' => false);
90+
$data['columns'][] = array('name' => 'priority', 'type' => 'int(11)', 'NULL' => false, 'default' => 0);
9091
$data['type'] = 'InnoDB';
9192
$data['primary'] = 'panel_id`, `user_id`, `dashboard_id';
9293
$data['comment'] = 'panel x dashboard dependency';

include/functions.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ function intropage_actions() {
199199
} else {
200200
$value = '';
201201
}
202+
202203
if (isset($values[2])) {
203204
$value_ext = trim($values[2]);
204205
}
@@ -334,11 +335,20 @@ function intropage_actions() {
334335
AND id = ?',
335336
array ($priority, $_SESSION['sess_user_id'], $b));
336337

338+
db_execute_prepared('UPDATE plugin_intropage_panel_dashboard
339+
SET priority = ?
340+
WHERE user_id = ?
341+
AND panel_id = ?
342+
AND dashboard_id = ?',
343+
array ($priority, $_SESSION['sess_user_id'], $b, get_request_var('dashboard_id')));
344+
337345
$priority--;
338346
}
339347
}
340348
}
341349

350+
exit;
351+
342352
break;
343353
case 'refresh':
344354
if (filter_var($value, FILTER_VALIDATE_INT)) {
@@ -464,7 +474,6 @@ function intropage_actions() {
464474
array($value, $value_ext));
465475

466476
foreach ($ids_panels as $id_panel) {
467-
468477
$result = db_execute_prepared('INSERT INTO plugin_intropage_panel_data
469478
(panel_id,user_id,data,priority,refresh_interval,trend_interval,fav_graph_id,fav_graph_timespan)
470479
SELECT panel_id, ? ,data,priority,refresh_interval,trend_interval,fav_graph_id,fav_graph_timespan
@@ -487,11 +496,11 @@ function intropage_actions() {
487496
header('Location: ' . html_escape("$redirectPage?header=false&dashboard_id=$new_dashboard_id"));
488497

489498
exit;
490-
491499
} else {
492500
raise_message('share_panel_error', __('Error - trying share non-shared dashboard', 'intropage'), MESSAGE_LEVEL_INFO);
493501
}
494502
}
503+
495504
break;
496505
}
497506
}

include/intropage.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,14 @@ function initPage() {
276276
xdata.push($(this).attr('id'));
277277
});
278278

279-
$.get(callbackPage, { xdata:xdata, intropage_action:'order' });
279+
var post = {
280+
'intropage_action': 'order',
281+
'dashboard_id': dashboard_id,
282+
'xdata': xdata,
283+
__csrf_magic: csrfMagicToken
284+
}
285+
286+
$.post(callbackPage, post);
280287
}
281288
});
282289

0 commit comments

Comments
 (0)