Files
ubicloud/views/admin/object.erb
2025-07-18 16:49:27 -07:00

64 lines
1.8 KiB
Plaintext

<% @page_title = "#{@klass.name} #{@obj.ubid}" %>
<% if @klass.associations.include?(:sshable) && (sshable = @obj.sshable) %>
<p>SSH Command: <code>ssh -i &lt;PRIVATE_KEY_PATH&gt; <%= sshable.unix_user %>@<%= sshable.host %></code></p>
<% end %>
<% if @klass.associations.include?(:strand) && (strand = @obj.strand) %>
<p>
<a href="/model/Strand/<%= strand.ubid %>">Strand</a>: <%= strand.prog %>#<%= strand.label %>
| schedule: <%= strand.schedule.strftime("%F %T") %>
<% if strand.try > 0 %>
| try: <%= strand.try %>
<% end %>
</p>
<% end %>
<% if @klass.associations.include?(:semaphores) && !(semaphores = @obj.semaphores_dataset.select_order_map(:name)).empty? %>
<p>Semaphores Set: <%= semaphores.join(", ") %></p>
<% end %>
<table class="object-table">
<caption>Data</caption>
<thead>
<tr>
<th>Column</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<% @obj.inspect_values_hash.each do |k, v| %>
<tr>
<td><%= k %></td>
<td>
<% if v.is_a?(String) && v.bytesize == 26 && (column_class = UBID.class_for_ubid(v)) %>
<a href="/model/<%= column_class %>/<%= v %>"><%= v %></a>
<% else %>
<%= v %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<h2 id="associations-header">Associations</h2>
<div class="associations">
<% @klass.associations.sort.each do |assoc| %>
<%
assoc_objs = Array(@obj.send(assoc)).select { defined?(it.ubid) && it.ubid }
next if assoc_objs.empty?
associated_class = @klass.association_reflection(assoc).associated_class
%>
<div class="association">
<h3><%= assoc %></h3>
<ul>
<% assoc_objs.each do %>
<li><a href="/model/<%= associated_class %>/<%= it.ubid %>"><%= it.ubid %></a></li>
<% end %>
</ul>
</div>
<% end %>
</div>