do you set also different links for each host right ? @cps86
if you can post the content too
Yes, you can set anything that you want, custom/fixed urls as well as different links for different hosts.
My plugin config file:
:column_view:
:name1:
:title: AppVer
:after: last_report
:content: facts_hash['application_version']
:name2:
:title: Remote
:after: name1
:content: 'link_to(_("VNC View"), "https://www.google.com", { :class => "btn btn-info", :target => "_blank", :rel => "noopener noreferrer" } )'
:name3:
:title: Remote
:after: name2
:content: 'link_to(_("VNC Control"), "https://www.google.com", { :class => "btn btn-danger", :target => "_blank", :rel => "noopener noreferrer" } )'
:name4:
:title: Printer
:after: name3
:content: 'link_to(_("WEB UI"), "https://#{host.interfaces.first.name}/API/CALL/OF/YOUR/CHOICE", { :class => "btn btn-info text-center", :target => "_blank", :rel => "noopener noreferrer" } )'
name2 & name3 point to www.google.com (created that just for the testing purposes).
name4 shows how to get hostname.
Enjoy.
thank you so much Iāll test that now
Now the thing which does not work for me are the conditions.
I would like to display text or a link only if parituclar parameter or fact exists for a host. Canāt figure it out.
Same here, some hosts donest have e.g. factX so it doesnt work!
If I found a solution for it, Iāll let you knowā¦
Hey Neeloj
Thanks for the reply. I figured it out as well by modyfing foreman column view plugin and it works. Hereās the code:
module ForemanColumnView
module HostsHelper
include ActionView::Helpers::UrlHelper
def fcv_title(column)
title = SETTINGS[:column_view][column.to_sym][:title]
return title
end
def fcv_content(host, column)
content = SETTINGS[:column_view][column.to_sym][:content]
if content =~ /(.*)\[(.*)\]/
content_name = $2
intermediate_result = host.send($1)[$2.gsub(/['"]/,'')]
something = intermediate_result.nil? ? "null" : "#{intermediate_result}"
if something.start_with?("http")
if content_name =~ /"url_vnc_view"/
return link_to("VNC View", something, { :class => "btn btn-info text-center", :target => "_blank", :rel => "noopener noreferrer" })
elsif content_name =~ /"url_vnc_control"/
return link_to("VNC Control", something, { :class => "btn btn-danger text-center", :target => "_blank", :rel => "noopener noreferrer" })
elsif content_name =~ /url_printer/
return link_to("Web UI", something, { :class => "btn btn-success text-center", :target => "_blank", :rel => "noopener noreferrer" })
else
return link_to("Link", something, { :class => "btn btn-info text-center", :target => "_blank", :rel => "noopener noreferrer" })
end
else
return intermediate_result
end
elsif content =~ /^link_to/
something = host.send(content)
return eval(content)
else
something = host.send(content)
return something
end
end
end
end
plugin config:
:column_view:
:name1:
:title: PlatformVer
:after: last_report
:content: facts_hash['application_version']
:name2:
:title: Remote
:after: name1
:content: params["url_vnc_view"]
:name3:
:title: Remote
:after: name2
:content: params["url_vnc_control"]
:name4:
:title: Printer
:after: name3
:content: params["url_printer"]
Please not that I donāt know ruby programming language, actually I never used it before. So most probably thatās an invalid approach. But it works and thatās all I need.
If you came up with an easier idea, perhaps without modifying the plugin then please let me know.
thank you so much, it looks very good, Iāll check it out. @cps86
Same here
Which file is the first change, path of the file please?
Which file is the first change, path of the file please?
In my case it is here:
/usr/share/foreman/vendor/ruby/2.7.0/gems/foreman_column_view-0.4.0/app/helpers/foreman_column_view/hosts_helper.rb
By the way, too bad that we canāt sort using these extra columns.
I wonder if it can be added