home.html.erb 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <div id="queries">
  2. <div id="header" style="margin-bottom: 20px;">
  3. <div class="pull-right">
  4. <% if blazer_user %>
  5. <%= link_to "All", root_path, class: !params[:filter] ? "active" : nil, style: "margin-right: 40px;" %>
  6. <% if Blazer.audit %>
  7. <%= link_to "Viewed", root_path(filter: "viewed"), class: params[:filter] == "viewed" ? "active" : nil, style: "margin-right: 40px;" %>
  8. <% end %>
  9. <%= link_to "Mine", root_path(filter: "mine"), class: params[:filter] == "mine" ? "active" : nil, style: "margin-right: 40px;" %>
  10. <% end %>
  11. <div class="btn-group">
  12. <%= link_to "New Query", new_query_path, class: "btn btn-info" %>
  13. <button type="button" class="btn btn-info dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  14. <span class="caret"></span>
  15. <span class="sr-only">Toggle Dropdown</span>
  16. </button>
  17. <ul class="dropdown-menu">
  18. <li><%= link_to "Dashboards", dashboards_path %></li>
  19. <li><%= link_to "Checks", checks_path %></li>
  20. <li role="separator" class="divider"></li>
  21. <li><%= link_to "New Dashboard", new_dashboard_path %></li>
  22. <li><%= link_to "New Check", new_check_path %></li>
  23. </ul>
  24. </div>
  25. </div>
  26. <input type="text" placeholder="Start typing a query or person" style="width: 300px; display: inline-block;" autofocus=true class="search form-control" />
  27. </div>
  28. <table class="table">
  29. <thead>
  30. <tr>
  31. <th>Name</th>
  32. <th style="width: 20%; text-align: right;">Mastermind</th>
  33. </tr>
  34. </thead>
  35. <tbody class="list">
  36. <tr id="search-item">
  37. <td>
  38. <span class="name"></span>
  39. <span class="vars"></span>
  40. <span class="hide"></span>
  41. </td>
  42. <td class="creator"></td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. </div>
  47. <script>
  48. var options = {
  49. valueNames: ["name", "vars", "hide", "creator"],
  50. item: "search-item",
  51. page: 200,
  52. indexAsync: true
  53. };
  54. var dashboardValues = <%= blazer_json_escape(@dashboards.to_json).html_safe %>;
  55. var queryValues = <%= blazer_json_escape(@queries.to_json).html_safe %>;
  56. var queryList = new List("queries", options, dashboardValues);
  57. queryList.add(queryValues);
  58. var queryIds = {};
  59. for (var i = 0; i < queryValues.length; i++) {
  60. queryIds[queryValues[i].id] = true;
  61. }
  62. </script>
  63. <% if @more %>
  64. <p id="loading" class="text-muted">Loading...</p>
  65. <script>
  66. $.getJSON("<%= queries_path %>", function (data) {
  67. var i, j, newValues, val, size = 500;
  68. $("#loading").remove();
  69. for (i = 0; i < data.length / size; i++) {
  70. newValues = [];
  71. for (j = 0; j < size; j++) {
  72. val = data[i * size + j];
  73. if (!val) {
  74. break;
  75. }
  76. if (!queryIds[val.id]) {
  77. newValues.push(val);
  78. }
  79. }
  80. queryList.add(newValues);
  81. }
  82. });
  83. </script>
  84. <% end %>