6588: Changed routes to be under /users, used @object and updated
[arvados.git] / apps / workbench / app / views / users / _ssh_keys.html.erb
diff --git a/apps/workbench/app/views/users/_ssh_keys.html.erb b/apps/workbench/app/views/users/_ssh_keys.html.erb
new file mode 100644 (file)
index 0000000..794e89c
--- /dev/null
@@ -0,0 +1,69 @@
+<div class="panel panel-default">
+  <div class="panel-heading">
+    <div class="pull-right">
+      <%= link_to raw('<i class="fa fa-plus"></i>' " Add new SSH key"), add_ssh_key_popup_url,
+                   {class: 'btn btn-xs btn-primary', :remote => true, 'data-toggle' =>  "modal",
+                    'data-target' => '#add-ssh-key-modal-window'}  %>
+    </div>
+    <h4 class="panel-title">
+      <%= link_to ssh_keys_user_path(current_user) do %>
+        SSH Keys
+      <%end%>
+    </h4>
+  </div>
+
+<div id="manage_ssh_keys" class="panel-body">
+  <% if !@my_ssh_keys.any? %>
+     <p> You have not yet set up an SSH public key for use with Arvados. <%= link_to "Learn more.",
+                  "#{Rails.configuration.arvados_docsite}/user/getting_started/ssh-access-unix.html",
+                  style: "font-weight: bold",
+                  target: "_blank" %>
+     </p>
+     <p> When you have an SSH key you would like to use, add it using the <b>Add</b> button. </p>
+  <% else %>
+    <table class="table manage-ssh-keys-table">
+      <colgroup>
+        <col style="width: 35%" />
+        <col style="width: 55%" />
+        <col style="width: 10%" />
+      </colgroup>
+      <thead>
+        <tr>
+          <th> Name </th>
+          <th> Key Fingerprint </th>
+          <th> </th>
+        </tr>
+      </thead>
+      <tbody>
+        <% @my_ssh_keys.andand.each do |key| %>
+          <tr style="word-break:break-all;">
+            <td>
+              <%= key[:name] %>
+            </td>
+            <td style="word-break:break-all;">
+              <% if key[:public_key] && key[:public_key].size > 0 %>
+                <div>
+                  <span title="<%=key[:public_key]%>"> <%=
+                    begin
+                      SSHKey.fingerprint key[:public_key]
+                    rescue
+                      "INVALID KEY: " + key[:public_key]
+                    end
+                   %> </span>
+                </div>
+              <% else %>
+                  <%= key[:public_key] %>
+              <% end %>
+            </td>
+            <td>
+              <%= link_to(authorized_key_path(id: key[:uuid]), method: :delete, class: 'btn btn-sm', data: {confirm: "Really delete key?"}) do %>
+                  <i class="fa fa-fw fa-trash-o"></i>
+              <% end %>
+            </td>
+          </tr>
+        <% end %>
+      </tbody>
+    </table>
+  <% end %>
+</div>
+</div>