Works nicely! +1 to adding this into appadmin and moving the static/view files into admin. It wouldn't need to replace the existing "graph model", there is plenty of space for another button next to it ;)
Regards, Ales On Thursday, January 31, 2013 3:31:53 PM UTC+1, Paolo Caruccio wrote: > > first post updated: replaced following files > > db_diagram.html > corrected CDN links. Now the diagram works on https too > > db_diagram.py [please note that you must copy the code within this file > and paste at the bottom of web2py_app/controllers/appadmin.py] > deleted a print statement > > > > Il giorno mercoledì 30 gennaio 2013 17:23:21 UTC+1, Paolo Caruccio ha > scritto: >> >> I was not able to succesfully install pygraphviz on my windows7 64bit >> enviroment but I liked Jose's idea >> https://groups.google.com/d/topic/web2py/cFqD1M6rkc8/discussion, so I >> wrote a simple addendum to appadmin in order to show a graph representation >> of a database. >> It's not alternative to or a replacement of Jose's graph layout because >> there are substantial differences. >> "db diagram" is interactive (nodes are draggable and clickable) but you >> cannot save it as an image (anyway it's possible to use a third party >> application for screenshoots). >> Moreover it is customizable via css (you will find here attached a css >> theme for reference) and it's based on jqueryUI framewok. >> The nodes contain only the table name, so we can draw the layout of a >> database with (moderately) numerous tables. >> In order to see table data you have to click on the node. I added some >> infos like indexed columns (currently available only for sqlite but I think >> it's not hard to implement for other database engines), the list of other >> affected tables when we delete a row in cascade mode. >> The layout (the position of nodes on the screen) is generated trough a >> force-directed spring algorythm. Therefore the layout is generated >> dinamically and it will be different each time you refresh the page. >> For this scope, I adapted and translated to jQuery the original prototype >> source code freely distributed under the terms of a MIT-style license from >> http://snipplr.com/view/1950/graph-javascript-framework-version-001/ >> For a jquery version of this original source code you could visit >> http://www.graphdracula.net/ >> The edges are drawn by jsPlumb library ( >> http://www.jsplumb.org/jquery/demo.html ). All 1.x.x versions of jsPlumb >> are dual-licensed under both MIT and GPL version 2. >> Current main limitation: the database must have 'db' key in application >> databases dictionary. In other words in our model we must have >> db = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) >> and not, for example, >> mydb = DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all']) >> The screen dimensions are important too: the layout will be messed on >> small screens. >> The code has been tested on latest versions of Firefox, Chrome, Opera, >> IE(7,8,9) and on a very limited number of databases. So please check for >> errors and bugs. >> >> Installation: >> 1) append the code within in the attached db_diagram.py in >> your_application/controllers/appadmin.py file >> 2) put attached db_diagram.html in to your_application/views folder >> 3) create a new folder in your_application/static folder and name it >> "db_diagram" >> 4) in to latter put db_diagram.css, db_diagram_print.css, >> jquery.dbdiagram.js, pencildiagonals.png (an image create by me only for >> the css theme in bundle) (all these files are here attached) >> 5) download jsPlumb (jQuery release) from >> http://code.google.com/p/jsplumb/downloads/list and put >> jquery.jsPlumb-1.3.16-all-min.js file in your_application/static/db_diagram >> folder >> >> Usage: >> In your appadmin page you should see a new menu item "diagram" (see image >> 1), click on it and you should see the layout of your "db". >> >> That's all Folks! >> > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.