+++ /dev/null
-class ManageAccountController < ApplicationController
-
- def model_class
- AuthorizedKey
- end
-
- def index_pane_list
- %w(Manage_account)
- end
-
- def index
- # repositories current user can read / write
- @repo_links = []
- Link.where(tail_uuid: current_user.uuid,
- link_class: 'permission',
- name: ['can_write', 'can_read']).
- each do |perm_link|
- @repo_links << perm_link[:head_uuid]
- end
- @repositories = Repository.where(uuid: @repo_links)
-
- # virtual machines the current user can login into
- @vm_logins = {}
- Link.where(tail_uuid: current_user.uuid,
- link_class: 'permission',
- name: 'can_login').
- each do |perm_link|
- if perm_link.properties.andand[:username]
- @vm_logins[perm_link.head_uuid] ||= []
- @vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
- end
- end
- @virtual_machines = VirtualMachine.where(uuid: @vm_logins.keys)
-
- # current user's ssh keys
- filters=[["owner_uuid", "=", current_user.uuid]]
- @ssh_keys = AuthorizedKey.where(key_type: 'SSH', filters: filters)
- @objects = @ssh_keys
-
- render_index
- end
-
-end
end
end
+ def manage_account
+ # repositories current user can read / write
+ repo_links = []
+ Link.where(tail_uuid: current_user.uuid,
+ link_class: 'permission',
+ name: ['can_write', 'can_read']).
+ each do |perm_link|
+ repo_links << perm_link[:head_uuid]
+ end
+ @my_repositories = Repository.where(uuid: repo_links)
+
+ # virtual machines the current user can login into
+ @my_vm_logins = {}
+ Link.where(tail_uuid: current_user.uuid,
+ link_class: 'permission',
+ name: 'can_login').
+ each do |perm_link|
+ if perm_link.properties.andand[:username]
+ @my_vm_logins[perm_link.head_uuid] ||= []
+ @my_vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
+ end
+ end
+ @my_virtual_machines = VirtualMachine.where(uuid: @my_vm_logins.keys)
+
+ # current user's ssh keys
+ @my_ssh_keys = AuthorizedKey.where(key_type: 'SSH', owner_uuid: current_user.uuid)
+
+ respond_to do |f|
+# f.js { render template: 'users/manage_account.js' }
+ f.html { render template: 'users/manage_account' }
+ end
+ end
+
protected
def find_current_links user
</div>
<div id="manage_<%=section_id%>">
<div class="panel-body">
- <%= render partial: "show_manage_#{section_id}", locals: {repositories: @repositories, virtual_machines: @virtual_machines, vm_logins: @vm_logins, ssh_keys: @ssh_keys} %>
+ <%= render partial: "manage_#{section_id}" %>
</div>
</div>
</div>
</div>
<div id="manage_<%=section_id%>">
<div class="panel-body">
- <%= render partial: "show_manage_#{section_id}", locals: {repositories: @repositories, virtual_machines: @virtual_machines, ssh_keys: @ssh_keys} %>
+ <%= render partial: "manage_#{section_id}" %>
</div>
</div>
</div>
</tr>
</thead>
<tbody>
- <% @repositories.andand.each do |repo| %>
+ <% @my_repositories.andand.each do |repo| %>
<tr>
<td>
<%= repo[:name] %>
<col style="width: 5%" />
</colgroup>
<tbody>
- <% @ssh_keys.andand.each do |key| %>
+ <% @my_ssh_keys.andand.each do |key| %>
<tr>
<td>
<%= key[:uuid] %>
<pre>
Host *.arvados
ProxyCommand ssh -p2222 turnout@switchyard.<%= current_api_host || 'xyzzy.arvadosapi.com' %> -x -a $SSH_PROXY_FLAGS %h
-<% if @vm_logins.andand.first %>
- User <%= @vm_logins[@vm_logins.andand.keys.first].andand.first %>
+<% if @my_vm_logins.andand.first %>
+ User <%= @my_vm_logins[@my_vm_logins.andand.keys.first].andand.first %>
<% end %>
</pre>
</p>
<pre>
-ssh <%= @virtual_machines.first.andand.hostname.andand.sub('.'+current_api_host,'') or 'vm-hostname' %>.arvados
+ssh <%= @my_virtual_machines.first.andand.hostname.andand.sub('.'+current_api_host,'') or 'vm-hostname' %>.arvados
</pre>
<p>
</tr>
</thead>
<tbody>
- <% @virtual_machines.andand.each do |vm| %>
+ <% @my_virtual_machines.andand.each do |vm| %>
<tr>
<td>
<%= vm[:hostname] %>
</td>
<td>
- <%= @vm_logins[vm[:uuid]].andand.compact || [] %>
+ <%= @my_vm_logins[vm[:uuid]].andand.compact || [] %>
</td>
<td>
</td>
--- /dev/null
+<%= render :partial => 'manage_account' %>
get 'choose', on: :collection
post 'share_with', on: :member
end
- get '/manage_account' => 'manage_account#index'
+ get '/manage_account' => 'users#manage_account'
post 'actions' => 'actions#post'
get 'websockets' => 'websocket#index'