2411: Eliminate whitespace to placate test.
[arvados.git] / apps / workbench / app / controllers / virtual_machines_controller.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 class VirtualMachinesController < ApplicationController
6   def index
7     @objects ||= model_class.all
8     @vm_logins = {}
9     if @objects.andand.first
10       Link.where(tail_uuid: current_user.uuid,
11                  head_uuid: @objects.collect(&:uuid),
12                  link_class: 'permission',
13                  name: 'can_login').
14         each do |perm_link|
15         if perm_link.properties.andand[:username]
16           @vm_logins[perm_link.head_uuid] ||= []
17           @vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
18         end
19       end
20       @objects.each do |vm|
21         vm.current_user_logins = @vm_logins[vm.uuid].andand.compact || []
22       end
23     end
24     super
25   end
26
27   def webshell
28     return render_not_found if not Rails.configuration.shell_in_a_box_url
29     @webshell_url = Rails.configuration.shell_in_a_box_url % {
30       uuid: @object.uuid,
31       hostname: @object.hostname,
32     }
33     render layout: false
34   end
35
36 end