18562: Add upgrade note about new config key.
[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').with_count("none").
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 Rails.configuration.Services.WebShell.ExternalURL == URI("")
29     webshell_url = URI(Rails.configuration.Services.WebShell.ExternalURL)
30     if webshell_url.host.index("*") != nil
31       webshell_url.host = webshell_url.host.sub("*", @object.hostname)
32     else
33       webshell_url.path = "/#{@object.hostname}"
34     end
35     @webshell_url = webshell_url.to_s
36     render layout: false
37   end
38
39 end