Skip to content

Commit

Permalink
Drop append domain names setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Dyrkon committed Feb 2, 2023
1 parent 9519609 commit 4c4c44f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions app/models/host/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def dup
:domain=, :domain_id=, :domain_name=, :to => :primary_interface

attr_writer :updated_virtuals

def updated_virtuals
@updated_virtuals ||= []
end
Expand Down Expand Up @@ -351,6 +352,14 @@ def render_template(template:, **params)
template.render(host: self, **params)
end

def to_label
if Setting[:append_domain_name_for_hosts]
name.to_s
else
name.to_s.split('.')[0]
end
end

private

def parse_ip_address(address, ignore_link_local: true)
Expand Down
10 changes: 9 additions & 1 deletion app/views/api/v2/hosts/base.json.rabl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
object @host

attributes :name, :id
attributes :id

node :name do |name|
if Setting[:append_domain_name_for_hosts]
name.split('.')[0]
else
name
end
end

0 comments on commit 4c4c44f

Please sign in to comment.