Skip to content

Commit

Permalink
added more zmi4 aspects
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho committed Jul 13, 2020
1 parent 83692d7 commit c8a2f1b
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/Shared/DC/ZRDB/Connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ def title_and_id(self):
if hasattr(self, '_v_connected') and self._v_connected:
s = '%s, which is connected' % s
else:
s = '%s, which is <font color=red>not connected</font>' % s
s = '%s, which is not connected' % s
return s

def title_or_id(self):
s = Connection.inheritedAttribute('title_or_id')(self)
if hasattr(self, '_v_connected') and self._v_connected:
s = '%s (connected)' % s
else:
s = '%s (<font color=red>not connected</font>)' % s
s = '%s (not connected)' % s
return s

def connected(self):
Expand Down
42 changes: 21 additions & 21 deletions src/Shared/DC/ZRDB/dtml/advanced.dtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<main class="container-fluid">

<h2 class="zmi-form-title">Advanced settings</h2>
<p class="zmi-form-title font-weight-bold">Advanced settings for <a href="manage_main" title="Edit Z SQLMethod">&dtml-title_or_id;</a></p>

<form action="manage_advanced" method="post">

<div class="form-group row">
<label for="connection_hook"
class="form-label col-sm-3 col-md-2">Connection Hook</label>
<div class="col-sm-9 col-md-10">
class="form-label col-sm-3 col-xl-2">Connection Hook</label>
<div class=" col-sm-9 col-xl-10">
<input type="text" class="form-control" name="connection_hook"
id="connection_hook" size="40"
value="<dtml-var connection_hook null="" missing="" html_quote>"/>
Expand All @@ -22,37 +22,37 @@

<div class="form-group row">
<label for="max_rows"
class="form-label col-sm-3 col-md-2">Maximum rows to retrieve</label>
<div class="col-sm-9 col-md-10">
class="form-label col-sm-3 col-xl-2">Maximum rows to retrieve</label>
<div class=" col-sm-9 col-xl-10">
<input type="text" class="form-control" name="max_rows:int"
id="max_rows" size="40" value="&dtml-max_rows_;"/>
id="max_rows" value="&dtml-max_rows_;"/>
</div>
</div>

<div class="form-group row">
<label for="max_cache"
class="form-label col-sm-3 col-md-2">Maximum results to cache</label>
<div class="col-sm-9 col-md-10">
class="form-label col-sm-3 col-xl-2">Maximum results to cache</label>
<div class=" col-sm-9 col-xl-10">
<input type="text" class="form-control" name="max_cache:int"
id="max_cache" size="40" value="&dtml-max_cache_;"/>
id="max_cache" value="&dtml-max_cache_;"/>
</div>
</div>

<div class="form-group row">
<label for="cache_time"
class="form-label col-sm-3 col-md-2">Maximum time (sec) to cache</label>
<div class="col-sm-9 col-md-10">
class="form-label col-sm-3 col-xl-2">Maximum time (sec) to cache</label>
<div class=" col-sm-9 col-xl-10 col-xl-10">
<input type="text" class="form-control" name="cache_time:int"
id="cache_time" size="40" value="&dtml-cache_time_;"/>
id="cache_time" value="&dtml-cache_time_;"/>
</div>
</div>

<dtml-if da_has_single_argument>
<div class="form-group row">
<label for="direct"
class="form-label col-sm-3 col-md-2">Allow "simple" direct traversal</label>
<div class="col-sm-9 col-md-10">
<input type="checkbox" class="form-control" name="direct" id="direct"
class="form-label col-sm-3 col-xl-2">Allow "simple" direct traversal</label>
<div class=" col-sm-9 col-xl-10">
<input type="checkbox" name="direct" id="direct"
<dtml-if allow_simple_one_argument_traversal>checked</dtml-if>/>
</div>
</div>
Expand All @@ -66,19 +66,19 @@

<div class="form-group row">
<label for="class_name"
class="form-label col-sm-3 col-md-2">Class Name</label>
<div class="col-sm-9 col-md-10">
class="form-label col-sm-3 col-xl-2">Class Name</label>
<div class=" col-sm-9 col-xl-10">
<input type="text" class="form-control" name="class_name"
id="class_name" size="40" value="&dtml-class_name_;"/>
id="class_name" value="&dtml-class_name_;"/>
</div>
</div>

<div class="form-group row">
<label for="class_file"
class="form-label col-sm-3 col-md-2">Class File</label>
<div class="col-sm-9 col-md-10">
class="form-label col-sm-3 col-xl-2">Class File</label>
<div class=" col-sm-9 col-xl-10">
<input type="text" class="form-control" name="class_file"
id="class_file" size="40" value="&dtml-class_file_;"/>
id="class_file" value="&dtml-class_file_;"/>
</div>
</div>

Expand Down
57 changes: 35 additions & 22 deletions src/Shared/DC/ZRDB/dtml/test.dtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

<dtml-let num_rows="REQUEST.get('num_rows') or 20">

<h2 class="zmi-form-title">Test query &dtml-title_or_id;</h2>
<p class="zmi-form-title m-0 font-weight-bold">
Test query <a href="manage_main" title="Edit Z SQLMethod">&dtml-title_or_id;</a>
</p>

<dtml-if connectionIsValid>
<form action="manage_testForm" method="get">
Expand All @@ -28,7 +30,7 @@

<dtml-let typ="type or REQUEST.get('%s_type' % name, 'string')">
<div class="col-sm-3 col-md-2">
<select name="&dtml-name;_type">
<select name="&dtml-name;_type" class="form-control">
<option <dtml-if "typ == 'float'">selected</dtml-if>>
float
</option>
Expand All @@ -45,7 +47,7 @@
</div>
</dtml-let>

<div class="col-sm-7 col-md-7">
<div class="col-sm-6 col-md-7">
<input type="text" class="form-control" size="40"
name="&dtml-name;"
id="&dtml-name;"
Expand All @@ -62,8 +64,8 @@
<div class="form-group row">
<label for="num_rows"
class="form-label col-sm-3 col-md-2">Rows per page</label>
<div class="col-sm-9 col-md-10">
<select name="num_rows">
<div class="col-sm-3 col-md-2">
<select name="num_rows" class="form-control">
<dtml-in "[10, 20, 50, 100, 500, 1000]">
<option <dtml-if "_.int(num_rows)==_['sequence-item']">selected</dtml-if>>
<dtml-var sequence-item>
Expand All @@ -83,18 +85,17 @@
<dtml-if QUERY_SUBMIT>
<hr/>

<h2 class="zmi-form-title">Rendered SQL query template</h2>

<dtml-try>
<p class="zmi-form-title m-0 font-weight-bold">Rendered SQL query template</p>
<p class="form-help">
This code represents the rendered ZSQL template only.
The final query sent to the database may contain additional
elements inserted automatically, such as a <em>LIMIT</em> clause.
</p>
<textarea id="content" data-contenttype="sql"
class="form-control zmi-code col-sm-12"
name="template:text" wrap="off"
rows="20"><dtml-var "this().manage_zmi_test(REQUEST, src__=1)"></textarea>
<textarea data-contenttype="sql"
class="form-control code zmi-code col-sm-12"
name="template:text" wrap="off" disabled="disabled"
rows="4"><dtml-var "this().manage_zmi_test(REQUEST, src__=1)"></textarea>

<br clear="all"/><hr/>

Expand All @@ -103,9 +104,14 @@
<dtml-let res="this().manage_zmi_test(REQUEST)"
res_size="_.len(res)">

<h2 class="zmi-form-title">
&dtml-res_size; results matched this query
</h2>
<p class="zmi-form-title font-weight-bold">
<dtml-if "res_size == 0">
<span class="badge badge-danger">0</span>
<dtml-else>
<span class="badge badge-success">&dtml-res_size;</span>
</dtml-if>
Results matched this query
</p>
<dtml-if "max_rows_ and res_size >= max_rows_">
<div class="alert alert-warning mt-4">
The query returned the maximum number of rows configured for
Expand All @@ -115,24 +121,31 @@

<dtml-in "res" size=num_rows start=query_start orphan=3>
<dtml-if sequence-start>
<ul class="pagination">
<dtml-if previous-sequence-size>
<a href="&dtml-URL;&dtml-sequence-query;query_start=&dtml-previous-sequence-start-number;">
&lt;&lt; Previous <dtml-var previous-sequence-size> results
</a>
<dtml-if next-sequence-size>&nbsp;|&nbsp;</dtml-if>
<li class="page-item">
<a class="page-link" href="&dtml-URL;&dtml-sequence-query;query_start=&dtml-previous-sequence-start-number;">
<i class="fas fa-angle-double-left mr-2"></i> Previous <dtml-var previous-sequence-size> results
</a>
</li>
</dtml-if previous-sequence-size>
<dtml-if next-sequence-size>
<a href="&dtml-URL;&dtml-sequence-query;query_start=&dtml-next-sequence-start-number;">
Next <dtml-var next-sequence-size> results &gt;&gt;
</a>
<li class="page-item">
<a class="page-link" href="&dtml-URL;&dtml-sequence-query;query_start=&dtml-next-sequence-start-number;">
Next <dtml-var next-sequence-size> results <i class="fas fa-angle-double-right ml-2"></i>
</a>
</li>
</ul>
</dtml-if next-sequence-size>

<table border="1">
<table class="table table-sm table-responsive table-striped table-hover table-bordered mb-5">
<thead>
<tr>
<dtml-in "res.names()">
<th>&dtml-sequence-item;</th>
</dtml-in>
</tr>
</thead>
</dtml-if sequence-start>

<tr>
Expand Down

3 comments on commit c8a2f1b

@drfho
Copy link
Contributor Author

@drfho drfho commented on c8a2f1b Jul 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @dataflake,
I am sorry for pushing my last change unintentionally to the master instead of a new branch "more_zmi4" for a pull-request.
Tomorow morning I will correct that.

ZSQLMethod_ZMI

Thank you for your patience
f

@dataflake
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I'll look at it this morning. The diff is readable, so that's good.

@dataflake
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice, and thanks a lot for finally getting rid of that horrible hardcoded HTML in the title_and_id/title_or_id methods.

I completed your changes for the ZSQL Method "Test" tab (the pagination links at the bottom of the results table were not styled) and applied similar changes to the database connector "Test" ZMI tab. Version 3.10 with all of that is now released.

Please sign in to comment.