|
|
@@ -14,6 +14,7 @@
|
|
|
## See the License for the specific language governing permissions and
|
|
|
## limitations under the License.
|
|
|
<%!
|
|
|
+import time
|
|
|
from django.template.defaultfilters import timesince
|
|
|
from desktop.views import commonheader, commonfooter
|
|
|
%>
|
|
|
@@ -23,185 +24,234 @@ from desktop.views import commonheader, commonfooter
|
|
|
${commonheader("Beeswax: My Queries", "beeswax", "100px")}
|
|
|
${layout.menubar(section='my queries')}
|
|
|
<style>
|
|
|
- .tab-content {
|
|
|
- overflow:visible!important;
|
|
|
- }
|
|
|
+ .tab-content {
|
|
|
+ overflow:visible!important;
|
|
|
+ }
|
|
|
</style>
|
|
|
<div class="container-fluid">
|
|
|
- <h1>Beeswax: My Queries</h1>
|
|
|
+ <h1>Beeswax: My Queries</h1>
|
|
|
|
|
|
- <ul class="nav nav-tabs">
|
|
|
- <li class="active"><a href="#recentSavedQueries" data-toggle="tab">Recent Saved Queries</a></li>
|
|
|
- <li><a href="#recentRunQueries" data-toggle="tab">Recent Run Queries</a></li>
|
|
|
- </ul>
|
|
|
+ <div class="well hueWell">
|
|
|
+ <div class="btn-group pull-right">
|
|
|
+ <a class="btn" href="/beeswax/">Create New Query</a>
|
|
|
+ </div>
|
|
|
|
|
|
+ <form class="form-search">
|
|
|
+ Filter: <input placeholder="Search for name, description, etc..." class="input-xlarge search-query" id="filterInput">
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="tab-content">
|
|
|
- <div class="active tab-pane" id="recentSavedQueries">
|
|
|
+ <ul class="nav nav-tabs">
|
|
|
+ <li class="active"><a href="#recentSavedQueries" data-toggle="tab">Recent Saved Queries <span id="recentSavedQueriesFilterCnt" class="badge badge-info hide"></span></a></li>
|
|
|
+ <li><a href="#recentRunQueries" data-toggle="tab">Recent Run Queries <span id="recentRunQueriesFilterCnt" class="badge badge-info hide"></span></a></li>
|
|
|
+ </ul>
|
|
|
|
|
|
- <table class="table table-striped table-condensed datatables">
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th>Name</th>
|
|
|
- <th>Desc</th>
|
|
|
- <th>Type</th>
|
|
|
- <th>Last Modified</th>
|
|
|
- <th></th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <%!
|
|
|
- from beeswax import models
|
|
|
- %>
|
|
|
- % for design in q_page.object_list:
|
|
|
- <tr>
|
|
|
- <td>
|
|
|
- % if design.type == models.SavedQuery.REPORT:
|
|
|
- <a href="${ url('beeswax.views.edit_report', design_id=design.id) }" data-row-selector="true">${design.name}</a>
|
|
|
- % else:
|
|
|
- <a href="${ url('beeswax.views.execute_query', design_id=design.id) }" data-row-selector="true">${design.name}</a>
|
|
|
- % endif
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- % if design.desc:
|
|
|
- <p>${design.desc}</p>
|
|
|
- % endif
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- % if design.type == models.SavedQuery.REPORT:
|
|
|
- Report
|
|
|
- % else:
|
|
|
- Query
|
|
|
- % endif
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- ${ timesince(design.mtime) } ago
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <div class="btn-group">
|
|
|
- <a href="#" data-toggle="dropdown" class="btn dropdown-toggle">
|
|
|
- Options
|
|
|
- <span class="caret"></span>
|
|
|
- </a>
|
|
|
- <ul class="dropdown-menu">
|
|
|
- % if design.type == models.SavedQuery.REPORT:
|
|
|
- <li><a href="${ url('beeswax.views.edit_report', design_id=design.id) }" title="Edit this report." class="contextItem">Edit</a></li>
|
|
|
- % else:
|
|
|
- <li><a href="${ url('beeswax.views.execute_query', design_id=design.id) }" title="Edit this query." class="contextItem">Edit</a></li>
|
|
|
- % endif
|
|
|
- <li><a href="javascript:void(0)" data-confirmation-url="${ url('beeswax.views.delete_design', design_id=design.id) }" title="Delete this query." class="contextItem confirmationModal">Delete</a></li>
|
|
|
- <li><a href="${ url('beeswax.views.list_query_history') }?design_id=${design.id}" title="View the usage history of this query." class="contextItem">Usage History</a></li>
|
|
|
- <li><a href="${ url('beeswax.views.clone_design', design_id=design.id) }" title="Copy this query." class="contextItem">Clone</a></li>
|
|
|
- </ul>
|
|
|
- </div>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- % endfor
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- % if q_page.number != q_page.num_pages():
|
|
|
- <a href="${ url('beeswax.views.list_designs') }?user=${request.user.username|u}" >View all my queries »</a>
|
|
|
- % endif
|
|
|
- </div>
|
|
|
+ <div class="tab-content">
|
|
|
+ <div class="active tab-pane" id="recentSavedQueries">
|
|
|
|
|
|
- <div class="tab-pane" id="recentRunQueries">
|
|
|
- <table class="table table-striped table-condensed datatables">
|
|
|
- <thead>
|
|
|
- <tr>
|
|
|
- <th>Time</th>
|
|
|
- <th>Name</th>
|
|
|
- <th>Query</th>
|
|
|
- <th>State</th>
|
|
|
- <th>Result</th>
|
|
|
- </tr>
|
|
|
- </thead>
|
|
|
- <tbody>
|
|
|
- <%!
|
|
|
- from beeswax import models, views
|
|
|
- %>
|
|
|
- % for query in h_page.object_list:
|
|
|
- <%
|
|
|
- qcontext = ""
|
|
|
- try:
|
|
|
- design = query.design
|
|
|
- qcontext = views.make_query_context('design', design.id)
|
|
|
- except:
|
|
|
- pass
|
|
|
- %>
|
|
|
- <tr >
|
|
|
- <td>${query.submission_date.strftime("%x %X")}</td>
|
|
|
- ## TODO (bc): Only showing HQL (not REPORT)
|
|
|
- <td><a href="${ url('beeswax.views.execute_query', design_id=design.id) }" data-row-selector="true">${design.name}</a></td>
|
|
|
- <td>
|
|
|
- <p>
|
|
|
- % if len(query.query) > 100:
|
|
|
- <code>${collapse_whitespace(query.query[:100])}...</code>
|
|
|
- % else:
|
|
|
- <code>${collapse_whitespace(query.query)}</code>
|
|
|
- % endif
|
|
|
- </p>
|
|
|
- </td>
|
|
|
- <td>${models.QueryHistory.STATE[query.last_state]}</td>
|
|
|
- <td>
|
|
|
- % if qcontext and query.last_state != models.QueryHistory.STATE.expired.index:
|
|
|
- <a href="${ url('beeswax.views.watch_query', id=query.id) }?context=${qcontext|u}">View</a>
|
|
|
- % else:
|
|
|
- ~
|
|
|
- % endif
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
- % endfor
|
|
|
- </tbody>
|
|
|
- </table>
|
|
|
- % if h_page.number != h_page.num_pages():
|
|
|
- <a href="${ url('beeswax.views.list_query_history') }">View my entire query history »</a>
|
|
|
- % endif
|
|
|
- </div>
|
|
|
+ <table id="recentSavedQueriesTable" class="table table-striped table-condensed datatables">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>Name</th>
|
|
|
+ <th>Desc</th>
|
|
|
+ <th>Type</th>
|
|
|
+ <th>Last Modified</th>
|
|
|
+ <th></th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <%!
|
|
|
+ from beeswax import models
|
|
|
+ %>
|
|
|
+ % for design in q_page.object_list:
|
|
|
+ <tr>
|
|
|
+ <td>
|
|
|
+ % if design.type == models.SavedQuery.REPORT:
|
|
|
+ <a href="${ url('beeswax.views.edit_report', design_id=design.id) }" data-row-selector="true">${design.name}</a>
|
|
|
+ % else:
|
|
|
+ <a href="${ url('beeswax.views.execute_query', design_id=design.id) }" data-row-selector="true">${design.name}</a>
|
|
|
+ % endif
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ % if design.desc:
|
|
|
+ <p>${design.desc}</p>
|
|
|
+ % endif
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ % if design.type == models.SavedQuery.REPORT:
|
|
|
+ Report
|
|
|
+ % else:
|
|
|
+ Query
|
|
|
+ % endif
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <span alt="${time.mktime(design.mtime.timetuple())}">${ timesince(design.mtime) } ago</span>
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="btn-group">
|
|
|
+ <a href="#" data-toggle="dropdown" class="btn dropdown-toggle">
|
|
|
+ Options
|
|
|
+ <span class="caret"></span>
|
|
|
+ </a>
|
|
|
+ <ul class="dropdown-menu">
|
|
|
+ % if design.type == models.SavedQuery.REPORT:
|
|
|
+ <li><a href="${ url('beeswax.views.edit_report', design_id=design.id) }" title="Edit this report." class="contextItem">Edit</a></li>
|
|
|
+ % else:
|
|
|
+ <li><a href="${ url('beeswax.views.execute_query', design_id=design.id) }" title="Edit this query." class="contextItem">Edit</a></li>
|
|
|
+ % endif
|
|
|
+ <li><a href="javascript:void(0)" data-confirmation-url="${ url('beeswax.views.delete_design', design_id=design.id) }" title="Delete this query." class="contextItem confirmationModal">Delete</a></li>
|
|
|
+ <li><a href="${ url('beeswax.views.list_query_history') }?design_id=${design.id}" title="View the usage history of this query." class="contextItem">Usage History</a></li>
|
|
|
+ <li><a href="${ url('beeswax.views.clone_design', design_id=design.id) }" title="Copy this query." class="contextItem">Clone</a></li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ % endfor
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ % if q_page.number != q_page.num_pages():
|
|
|
+ <a href="${ url('beeswax.views.list_designs') }?user=${request.user.username|u}" >View all my queries »</a>
|
|
|
+ % endif
|
|
|
+ </div>
|
|
|
|
|
|
+ <div class="tab-pane" id="recentRunQueries">
|
|
|
+ <table id="recentRunQueriesTable" class="table table-striped table-condensed datatables">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th>Time</th>
|
|
|
+ <th>Name</th>
|
|
|
+ <th>Query</th>
|
|
|
+ <th>State</th>
|
|
|
+ <th>Result</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <%!
|
|
|
+ from beeswax import models, views
|
|
|
+ %>
|
|
|
+ % for query in h_page.object_list:
|
|
|
+ <%
|
|
|
+ qcontext = ""
|
|
|
+ try:
|
|
|
+ design = query.design
|
|
|
+ qcontext = views.make_query_context('design', design.id)
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ %>
|
|
|
+ <tr>
|
|
|
+ <td><span alt="${time.mktime(query.submission_date.timetuple())}">${query.submission_date.strftime("%x %X")}</span></td>
|
|
|
+ ## TODO (bc): Only showing HQL (not REPORT)
|
|
|
+ <td><a href="${ url('beeswax.views.execute_query', design_id=design.id) }" data-row-selector="true">${design.name}</a></td>
|
|
|
+ <td>
|
|
|
+ <p>
|
|
|
+ % if len(query.query) > 100:
|
|
|
+ <code>${collapse_whitespace(query.query[:100])}...</code>
|
|
|
+ % else:
|
|
|
+ <code>${collapse_whitespace(query.query)}</code>
|
|
|
+ % endif
|
|
|
+ </p>
|
|
|
+ </td>
|
|
|
+ <td>${models.QueryHistory.STATE[query.last_state]}</td>
|
|
|
+ <td>
|
|
|
+ % if qcontext and query.last_state != models.QueryHistory.STATE.expired.index:
|
|
|
+ <a href="${ url('beeswax.views.watch_query', id=query.id) }?context=${qcontext|u}">View</a>
|
|
|
+ % else:
|
|
|
+ ~
|
|
|
+ % endif
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ % endfor
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ % if h_page.number != h_page.num_pages():
|
|
|
+ <a href="${ url('beeswax.views.list_query_history') }">View my entire query history »</a>
|
|
|
+ % endif
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<div id="deleteQuery" class="modal hide fade">
|
|
|
- <form id="deleteQueryForm" action="" method="POST">
|
|
|
- <div class="modal-header">
|
|
|
- <a href="#" class="close" data-dismiss="modal">×</a>
|
|
|
- <h3 id="deleteQueryMessage">Confirm action</h3>
|
|
|
- </div>
|
|
|
- <div class="modal-footer">
|
|
|
- <input type="submit" class="btn primary" value="Yes"/>
|
|
|
- <a href="#" class="btn secondary" data-dismiss="modal">No</a>
|
|
|
- </div>
|
|
|
- </form>
|
|
|
-</div>
|
|
|
+ <form id="deleteQueryForm" action="" method="POST">
|
|
|
+ <div class="modal-header">
|
|
|
+ <a href="#" class="close" data-dismiss="modal">×</a>
|
|
|
+ <h3 id="deleteQueryMessage">Confirm action</h3>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer">
|
|
|
+ <input type="submit" class="btn primary" value="Yes"/>
|
|
|
+ <a href="#" class="btn secondary" data-dismiss="modal">No</a>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
|
- $(document).ready(function(){
|
|
|
- $(".datatables").dataTable({
|
|
|
- "bPaginate": false,
|
|
|
- "bLengthChange": false,
|
|
|
- "bInfo": false,
|
|
|
- "bFilter": false,
|
|
|
- "aoColumns": [
|
|
|
- null,
|
|
|
- null,
|
|
|
- null,
|
|
|
- null,
|
|
|
- { "bSortable": false }
|
|
|
- ]
|
|
|
- });
|
|
|
+ $(document).ready(function(){
|
|
|
+ var recentSavedQueries = $("#recentSavedQueriesTable").dataTable({
|
|
|
+ "sDom": "<'row'r>t<'row'<'span8'i><''p>>",
|
|
|
+ "bPaginate": false,
|
|
|
+ "bLengthChange": false,
|
|
|
+ "bInfo": false,
|
|
|
+ "aoColumns": [
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ { "sType": "alt-numeric"},
|
|
|
+ { "bSortable": false }
|
|
|
+ ]
|
|
|
+ });
|
|
|
|
|
|
- $(".confirmationModal").live("click", function(){
|
|
|
- $.getJSON($(this).attr("data-confirmation-url"), function(data){
|
|
|
- $("#deleteQueryForm").attr("action", data.url);
|
|
|
- $("#deleteQueryMessage").text(data.title);
|
|
|
- });
|
|
|
- $("#deleteQuery").modal("show");
|
|
|
- });
|
|
|
+ var recentRunQueries = $("#recentRunQueriesTable").dataTable({
|
|
|
+ "sDom": "<'row'r>t<'row'<'span8'i><''p>>",
|
|
|
+ "bPaginate": false,
|
|
|
+ "bLengthChange": false,
|
|
|
+ "bInfo": false,
|
|
|
+ "aoColumns": [
|
|
|
+ { "sType": "alt-numeric"},
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ { "bSortable": false }
|
|
|
+ ]
|
|
|
+ });
|
|
|
|
|
|
- $("a[data-row-selector='true']").jHueRowSelector();
|
|
|
|
|
|
- });
|
|
|
-</script>
|
|
|
+ $("#filterInput").keyup(function() {
|
|
|
+ recentSavedQueries.fnFilter($(this).val());
|
|
|
+ recentRunQueries.fnFilter($(this).val());
|
|
|
+ if ($.trim($(this).val()) != ""){
|
|
|
+ var recentSavedQueriesCnt = $("#recentSavedQueriesTable tbody tr").length;
|
|
|
+ var isRecentSavedQueriesEmpty = ($("#recentSavedQueries tbody tr td.dataTables_empty").length == 1)
|
|
|
+ if (recentSavedQueriesCnt > 0 && !isRecentSavedQueriesEmpty){
|
|
|
+ $("#recentSavedQueriesFilterCnt").text(recentSavedQueriesCnt).show();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $("#recentSavedQueriesFilterCnt").hide().text("");
|
|
|
+ }
|
|
|
+
|
|
|
+ var recentRunQueriesCnt = $("#recentRunQueriesTable tbody tr").length;
|
|
|
+ var isRecentRunQueriesEmpty = ($("#recentRunQueriesTable tbody tr td.dataTables_empty").length == 1)
|
|
|
+ if (recentRunQueriesCnt > 0 && !isRecentRunQueriesEmpty){
|
|
|
+ $("#recentRunQueriesFilterCnt").text(recentRunQueriesCnt).show();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $("#recentRunQueriesFilterCnt").hide().text("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $("#recentSavedQueriesFilterCnt").hide().text("");
|
|
|
+ $("#recentRunQueriesFilterCnt").hide().text("");
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
+ $(".confirmationModal").live("click", function(){
|
|
|
+ $.getJSON($(this).attr("data-confirmation-url"), function(data){
|
|
|
+ $("#deleteQueryForm").attr("action", data.url);
|
|
|
+ $("#deleteQueryMessage").text(data.title);
|
|
|
+ });
|
|
|
+ $("#deleteQuery").modal("show");
|
|
|
+ });
|
|
|
+
|
|
|
+ $("a[data-row-selector='true']").jHueRowSelector();
|
|
|
+ });
|
|
|
+</script>
|
|
|
|
|
|
${commonfooter()}
|