ubicloud/views/admin/index.erb
Jeremy Evans a318ec6efb Paginate by filter instead of offset in the autoforme tables on the admin site
Offset pagination results in suboptimal performance.

This requires an unreleased version of autoforme. That version also
supports the autoforme_framework Roda class method, so use that and
simplify the related code.
2025-09-23 02:53:47 +09:00

61 lines
1.7 KiB
Text

<% @content_class = "" %>
<% unless @grouped_pages.empty? %>
<table class="page-table">
<caption>Active Pages</caption>
<thead>
<tr>
<th>VmHost</th>
<th>UBID</th>
<th>Created At</th>
<th>Summary</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<% @grouped_pages.sort_by { |k,| k || "z" }.each do |vmh_ubid, pages| %>
<% pages.each_with_index do |page, index| %>
<tr>
<% if index == 0 %>
<td rowspan="<%= pages.size %>">
<% if vmh_ubid %>
<a href="/model/VmHost/<%= vmh_ubid %>"><%= vmh_ubid %></a>
<% end%>
</td>
<% end %>
<td><a href="/model/Page/<%= page.ubid %>"><%= page.ubid %></a></td>
<td><%= page.created_at.strftime("%F %T") %></td>
<td><%= page.summary %></td>
<td><%== h(page.details).gsub(/\b[a-tv-z0-9]{26}\b/) do
if (klass = UBID.class_for_ubid(it))
"<a href=\"/model/#{klass}/#{it}\">#{it}</a>"
else
it
end
end %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% end %>
<div class="container">
<h2>Browse by Model Class</h2>
<ul id="model-class-list">
<% autoforme_models = self.class.autoforme_framework.models %>
<% @classes.each do |klass| %>
<li><a href="<%= autoforme_models[klass.to_s] ? "/autoforme/#{klass}/browse" : "/model/#{klass}" %>"><%= klass %></a></li>
<% end %>
</ul>
<h2 class="container">Manage</h2>
<ul>
<li><a href="/change-password">Change Password</a></li>
<li><a href="/multifactor-manage">Manage Multifactor Authentication</a></li>
</ul>
</div>