diff --git a/applications/admin/controllers/appadmin.py b/applications/admin/controllers/appadmin.py index e72b3dab..2935959d 100644 --- a/applications/admin/controllers/appadmin.py +++ b/applications/admin/controllers/appadmin.py @@ -12,12 +12,6 @@ import gluon.contenttype import gluon.fileutils from gluon._compat import iteritems -# d3_graph_model added but leaving pygraphviz code as is for initial tests. -try: - import pygraphviz as pgv -except ImportError: - pgv = None - is_gae = request.env.web2py_runtime_gae or False # ## critical --- make a copy of the environment @@ -566,60 +560,6 @@ def table_template(table): _cellborder=0, _cellspacing=0) ).xml() - -# d3_graph_model added but leaving pygraphviz code as is for initial tests. -# The Graph Model button in admin app views/default/design.html has been redirected -# to the d3_graph_model function. -def bg_graph_model(): - graph = pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR') - - subgraphs = dict() - for tablename in db.tables: - if hasattr(db[tablename],'_meta_graphmodel'): - meta_graphmodel = db[tablename]._meta_graphmodel - else: - meta_graphmodel = dict(group=request.application, color='#ECECEC') - - group = meta_graphmodel['group'].replace(' ', '') - if group not in subgraphs: - subgraphs[group] = dict(meta=meta_graphmodel, tables=[]) - subgraphs[group]['tables'].append(tablename) - - graph.add_node(tablename, name=tablename, shape='plaintext', - label=table_template(tablename)) - - for n, key in enumerate(subgraphs.iterkeys()): - graph.subgraph(nbunch=subgraphs[key]['tables'], - name='cluster%d' % n, - style='filled', - color=subgraphs[key]['meta']['color'], - label=subgraphs[key]['meta']['group']) - - for tablename in db.tables: - for field in db[tablename]: - f_type = field.type - if isinstance(f_type,str) and ( - f_type.startswith('reference') or - f_type.startswith('list:reference')): - referenced_table = f_type.split()[1].split('.')[0] - n1 = graph.get_node(tablename) - n2 = graph.get_node(referenced_table) - graph.add_edge(n1, n2, color="#4C4C4C", label='') - - graph.layout() - if not request.args: - response.headers['Content-Type'] = 'image/png' - return graph.draw(format='png', prog='dot') - else: - response.headers['Content-Disposition']='attachment;filename=graph.%s'%request.args(0) - if request.args(0) == 'dot': - return graph.string() - else: - return graph.draw(format=request.args(0), prog='dot') - -def graph_model(): - return dict(databases=databases, pgv=pgv) - def manage(): tables = manager_action['tables'] if isinstance(tables[0], str): @@ -752,4 +692,4 @@ def d3_graph_model(): # d3 v4 allows individual modules to be specified. The complete d3 library is included below. response.files.append(URL('static','js/d3.min.js')) response.files.append(URL('static','js/d3_graph.js')) - return dict(nodes=nodes, links=links) \ No newline at end of file + return dict(databases=databases, nodes=nodes, links=links) \ No newline at end of file diff --git a/applications/welcome/static/css/d3_graph.css b/applications/admin/static/css/d3_graph.css similarity index 100% rename from applications/welcome/static/css/d3_graph.css rename to applications/admin/static/css/d3_graph.css diff --git a/applications/welcome/static/js/d3.min.js b/applications/admin/static/js/d3.min.js similarity index 100% rename from applications/welcome/static/js/d3.min.js rename to applications/admin/static/js/d3.min.js diff --git a/applications/welcome/static/js/d3_graph.js b/applications/admin/static/js/d3_graph.js similarity index 100% rename from applications/welcome/static/js/d3_graph.js rename to applications/admin/static/js/d3_graph.js diff --git a/applications/admin/views/appadmin.html b/applications/admin/views/appadmin.html index c92e4058..5330b163 100644 --- a/applications/admin/views/appadmin.html +++ b/applications/admin/views/appadmin.html @@ -233,43 +233,22 @@
{{pass}} -{{if request.function=='graph_model':}} -

{{=T("Graph Model")}}

- {{if not pgv:}} - {{=T('pygraphviz library not found')}} - {{elif not databases:}} - {{=T("No databases in this application")}} - {{else:}} -
- - {{=T('Save model as...')}} - - - -
-
- {{=IMG(_src=URL('appadmin', 'bg_graph_model'))}} - {{pass}} -{{pass}} - {{if request.function=='d3_graph_model':}}

{{=T("Graph Model")}}

-
- - -{{pass}} + {{if not databases:}} + {{=T("No databases in this application")}} + {{else:}} +
+ + + {{pass}} +{{pass}} {{if request.function == 'manage':}}

{{=heading}}

diff --git a/applications/admin/views/default/design.html b/applications/admin/views/default/design.html index ec3ca099..3166dc10 100644 --- a/applications/admin/views/default/design.html +++ b/applications/admin/views/default/design.html @@ -105,10 +105,8 @@ def deletefile(arglist, vars={}): {{if os.access(os.path.join(request.folder,'..',app,'databases','sql.log'),os.R_OK):}} {{=button(URL('peek/%s/databases/sql.log'%app), 'sql.log')}} {{pass}} - {{if os.access(os.path.join(request.folder,'..',app,'static','js','d3_graph.js'),os.R_OK):}} + {{if os.access(os.path.join(request.folder,'..','admin','static','js','d3_graph.js'),os.R_OK):}} {{=button(URL(a=app, c='appadmin',f='d3_graph_model'), T('graph model'))}} - {{else:}} - {{=button(URL(a=app, c='appadmin',f='graph_model'), T('graph model'))}} {{pass}}