|
|
| Author |
Message |
Leddy Cacti User
Joined: 15 May 2005 Posts: 67
|
Posted: Thu Sep 13, 2007 11:11 am Post subject: Adding Tree Item Type |
|
|
Has anyone considered the possibility of adding a 4th TREE_ITEM_TYPE?
It would be nice to be able to add a "Picture" somewhere in the tree i.e. our company logo on the "[root]"
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12295 Location: Muenster, Germany
|
Posted: Thu Sep 13, 2007 1:07 pm Post subject: |
|
|
Move to Feature Request
Reinhard
|
|
| Back to top |
|
 |
Leddy Cacti User
Joined: 15 May 2005 Posts: 67
|
Posted: Thu Sep 13, 2007 1:53 pm Post subject: |
|
|
I've done some digging today and made a few changes.
I've added TREE_ITEM_TYPE_LINK and TREE_ITEM_TYPE_PICTURE
After looking at html_tree.php I see that cacti is determing the type based on the following information:
Graph: local_graph_id > 0
Header: title != ""
Host: host_id > 0
It doesn't seem like this structure is condusive to additional types. How about adding a type_id that mirrors the TREE_ITEM_TYPE constants?
I'd be more than happy to discuss this with someone if they are available.
|
|
| Back to top |
|
 |
Leddy Cacti User
Joined: 15 May 2005 Posts: 67
|
Posted: Thu Sep 13, 2007 7:50 pm Post subject: |
|
|
Bueller, Bueller, anyone alive?
Well I've made a few changes to the graph_tree_items schema to allow new types. I've modified the Graph Tree to reflect the new types.
Next is modifying the display process. Maybe one of the devs will have some interest in this
| Description: |
|
| Filesize: |
28.96 KB |
| Viewed: |
1452 Time(s) |

|
| Description: |
|
| Filesize: |
44.01 KB |
| Viewed: |
1452 Time(s) |

|
|
|
| Back to top |
|
 |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 2167 Location: United Kingdom
|
Posted: Fri Sep 14, 2007 2:17 am Post subject: |
|
|
| Leddy wrote: | Bueller, Bueller, anyone alive?
Well I've made a few changes to the graph_tree_items schema to allow new types. I've modified the Graph Tree to reflect the new types.
Next is modifying the display process. Maybe one of the devs will have some interest in this  |
I had some interest in this too, but I haven't had any time to look at it. I wanted to add a few new 'base types' (file/document, image, link) like you and also some kind of hook so that plugins can supply content (weathermaps, reports, subset of thresholds etc).
My plan was to take another look once 0.8.7 is out, partly because I should have finished messing with weathermap 0.93 by then too.
|
|
| Back to top |
|
 |
gandalf Developer
Joined: 02 Dec 2004 Posts: 12295 Location: Muenster, Germany
|
Posted: Fri Sep 14, 2007 9:08 am Post subject: |
|
|
| Leddy wrote: | Well I've made a few changes to the graph_tree_items schema to allow new types. I've modified the Graph Tree to reflect the new types.
Next is modifying the display process. Maybe one of the devs will have some interest in this  | You may want to share your code following the procedure at http://www.cacti.net/bugs.php
Reinhard
|
|
| Back to top |
|
 |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 2167 Location: United Kingdom
|
Posted: Thu Dec 27, 2007 8:17 am Post subject: |
|
|
Just a quick note to say that I'm working on this again. My version adds four new fields to the graph_tree_items table, but does allow plugins to supply new data types - my test case is to have weathermap supply a new map type, plus a couple of small built-in types for images and text chunks. Link would be another good one didn't think of that.
Since I wrote some notes, here they are...
| Code: | Files touched so far: include/global_arrays.php
lib/html_tree.php
tree.php
graph_view.php
Move away from implicit to explicit type id, and using generic fields for the
new types. Type IDs are already defined for the existing types in
global_constants.php
Assumes item_type=0 will never exist.
All new type IDs will be >= 10
update graph_tree_items set item_type=1 where title <> '';
update graph_tree_items set item_type=2 where local_graph_id > 0;
update graph_tree_items set item_type=3 where host_id > 0;
4 New fields in database:
`item_type` smallint(5) unsigned NOT NULL default '0',
`item_id` int(16) unsigned NOT NULL default '0',
`item_options` int(16) unsigned NOT NULL default '0',
`item_name` varchar(255) NOT NULL,
item_type: from 10 onwards for new items. 1,2,3 for existing ones.
item_id: a type-specific unique ID for that instance (e.g. map id, local_graph_id)
item_options: any display options specific to that type (e.g. rra_id, font-size, thumbnail view)
item_name: a cached name for the item, so that we don't need to do so many database hits to show
a list. The existing code uses left joins, but that can't really scale to many types.
Ultimately the existing local_graph_id, rra_id, title and host_id could go
away, but that would leave another place to 'reapply names', unless there's a
nice way to do that in the background at appropriate times.
Plugin should add a new line to tree_item_types[] with a short description
(this appears in the combo box for adding new items, and also in the tree
editing view). Plugin should then add a row to tree_item_handlers (new array)
with a list of function names to provide the functionality for that type:
render: actually draws the item into a tree
edit: prints the type-specific part of the item editing/adding form
name: returns a string name for use in the tree edit, and the tree itself
Weathermap is the test case. May also 're-implement' the 3 existing ones in the
same style, so tree code is generic.
|
|
|
| Back to top |
|
 |
ghoz
Joined: 29 Aug 2007 Posts: 4
|
Posted: Mon Jan 07, 2008 11:32 am Post subject: |
|
|
Hi.
I almost finished adding a new graph_tree_type (graph_template) to cacti. I think i've covered almost all parts of code requiring change.
My code is far less generic than yours, so rather than continuing an uphill battle with spagetti code, i'd like to know what is the status on that thing...
fyi, I had changes all over the place...
the following files/functions had to be changed (so you don't miss one ;-) :
add tree_item_type constants :
| Code: |
include/global_arrays.php
include/global_constants.php
|
change api_tree_item_save :
| Code: |
cli/add_tree.php
graphs.php
host.php
lib/api_automation_tools.php
lib/api_tree.php
|
tree managment
| Code: |
lib/html_tree.php (grow_graph_tree, grow_edit_graph_tree, create_dhtml_tree, grow_right_pane_tree)
lib/tree.php (get_tree_item_type)
tree.php (form_save, item_edit item_remove)
|
and i have not touched at the tree exports...
Ghoz
|
|
| Back to top |
|
 |
|