Skip to content

Editing a Graph Template does not show the Data Template name #3302

Description

@frontierliu

CentOS 7.6 , Chrome browser,
Version: Cacti 1.2.9 pull from github/cacti/cacti/1.2.x

In the previous issue #3233 "When working with non-templated graphs, it can be difficult to determine what items represent", we modify graphs.php to make non-templated graph edit page show full data-sourcename about items . It has been resolved and display well.

when Cacti 1.2.9 anounce, Graph_templates.php also been modified to play the same role in graph_templates edit page. I found there is a little bug in the SQL code led to never display the item's datasource name as below:
QQ图片20200226181651

when fix the bug, the item's datasource-name display correctly as below:
QQ20200227115537

How to resolved:
in cacti/graph_templates.php line 425:
$template_item_list = db_fetch_assoc_prepared("SELECT gti.id, gti.text_format, gti.alpha,
gti.value, gti.hard_return, gti.graph_type_id, gti.consolidation_function_id, gti.textalign,
CONCAT(IFNULL(dtd.name, ''), ' (', dtr.data_source_name, ')') AS data_source_name,
cdef.name AS cdef_name, colors.hex
FROM graph_templates_item AS gti
LEFT JOIN data_template_rrd AS dtr
ON gti.task_item_id=dtr.id
LEFT JOIN data_local AS dl
ON dtr.local_data_id=dl.id
LEFT JOIN data_template_data AS dtd
ON dl.id=dtd.local_data_id
LEFT JOIN cdef
ON cdef_id=cdef.id
LEFT JOIN vdef
ON vdef_id=vdef.id
LEFT JOIN colors
ON color_id=colors.id
WHERE gti.graph_template_id = ?
AND gti.local_graph_id=0
ORDER BY gti.sequence",
array(get_request_var('id')));

Change to:
$template_item_list = db_fetch_assoc_prepared("SELECT gti.id, gti.text_format, gti.alpha,
gti.value, gti.hard_return, gti.graph_type_id, gti.consolidation_function_id, gti.textalign,
CONCAT(IFNULL(dt.name, ''), ' (', dtr.data_source_name, ')') AS data_source_name,
cdef.name AS cdef_name, colors.hex
FROM graph_templates_item AS gti
LEFT JOIN data_template_rrd AS dtr
ON gti.task_item_id=dtr.id
LEFT JOIN data_template AS dt
ON dtr.data_template_id=dt.id
LEFT JOIN cdef
ON cdef_id=cdef.id
LEFT JOIN vdef
ON vdef_id=vdef.id
LEFT JOIN colors
ON color_id=colors.id
WHERE gti.graph_template_id = ?
AND gti.local_graph_id=0
ORDER BY gti.sequence",
array(get_request_var('id')));

This code has been test in my 1.2.9 system and it works well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesired behaviourresolvedA fixed issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions