Selaa lähdekoodia

Show dashboards at top of home page

Andrew 9 vuotta sitten
vanhempi
commit
56b9657e73

+ 4 - 0
app/assets/stylesheets/blazer/application.css

@@ -83,3 +83,7 @@ input.search:focus {
   overflow: scroll;
   text-align: left;
 }
+
+.dashboard a {
+  font-weight: bold;
+}

+ 1 - 0
app/controllers/blazer/queries_controller.rb

@@ -169,6 +169,7 @@ module Blazer
       @queries = @queries.includes(:creator) if Blazer.user_class
       @trending_queries = Blazer::Audit.group(:query_id).where("created_at > ?", 2.days.ago).having("COUNT(DISTINCT user_id) >= 3").uniq.count(:user_id)
       @checks = Blazer::Check.group(:query_id).count
+      @dashboards = Blazer::Dashboard.order(:name)
     end
 
     def set_query

+ 15 - 12
app/views/blazer/queries/_index.html.erb

@@ -1,18 +1,21 @@
-<% @queries.each do |query| %>
+<% (@dashboards + @queries).each do |query| %>
+  <% is_query = query.is_a?(Blazer::Query) %>
   <tr>
-    <td class="query">
+    <td class="query <%= "dashboard" unless is_query %>">
       <%= link_to query.name, query %>
-      <span style="color: #ccc;"><%= extract_vars(query.statement).join(", ") %></span>
-      <% if @queries.size < 1000 && query.created_at > 2.days.ago %>
-        <small style="font-weight: bold; color: #5cb85c;">NEW</small>
-      <% end %>
-      <% if @trending_queries[query.id] %>
-        <small style="font-weight: bold; color: #f60;">TRENDING</small>
-      <% end %>
-      <% if @checks[query.id] %>
-        <small style="font-weight: bold; color: #f60;">CHECK</small>
+      <% if is_query %>
+        <span style="color: #ccc;"><%= extract_vars(query.statement).join(", ") %></span>
+        <% if @queries.size < 1000 && query.created_at > 2.days.ago %>
+          <small style="font-weight: bold; color: #5cb85c;">NEW</small>
+        <% end %>
+        <% if @trending_queries[query.id] %>
+          <small style="font-weight: bold; color: #f60;">TRENDING</small>
+        <% end %>
+        <% if @checks[query.id] %>
+          <small style="font-weight: bold; color: #f60;">CHECK</small>
+        <% end %>
+        <div class="hide"><%= query.name.gsub(/\s+/, "") %></div>
       <% end %>
-      <div class="hide"><%= query.name.gsub(/\s+/, "") %></div>
     </td>
     <td class="creator text-right text-muted">
       <% if query.respond_to?(:creator) && (creator = query.creator) && creator.respond_to?(Blazer.user_name) %>

+ 1 - 1
app/views/blazer/queries/home.html.erb

@@ -20,7 +20,7 @@
   <table class="table">
     <thead>
       <tr>
-        <th>Query</th>
+        <th>Name</th>
         <th style="width: 20%; text-align: right;">Mastermind</th>
       </tr>
     </thead>