diff --git a/app/assets/javascripts/services/topology_service.js b/app/assets/javascripts/services/topology_service.js index 4909c4cfaf8..1e00be2514b 100644 --- a/app/assets/javascripts/services/topology_service.js +++ b/app/assets/javascripts/services/topology_service.js @@ -6,6 +6,13 @@ ManageIQ.angular.app.service('topologyService', function() { __('Status: ') + d.item.status, ]; + if (d.item.kind === 'Tag') { + status = [ + d.item.name, + __('Type: ') + d.item.display_kind, + ]; + } + if (d.item.kind === 'Host' || d.item.kind === 'Vm') { status.push(__('Provider: ') + d.item.provider); } @@ -13,7 +20,6 @@ ManageIQ.angular.app.service('topologyService', function() { return status; }; - this.showHideNames = function($scope) { return function() { $scope.checkboxModel.value = $('input#box_display_names')[0].checked; diff --git a/app/services/topology_service.rb b/app/services/topology_service.rb index dc11fb80b6a..02537d586aa 100644 --- a/app/services/topology_service.rb +++ b/app/services/topology_service.rb @@ -24,9 +24,18 @@ def entity_id(entity) entity_type(entity) + entity.compressed_id.to_s end + def entity_name(entity) + if entity.kind_of?(Tag) + cls = entity.classification + [cls.parent, cls].map(&:description).join(': ') + else + entity.name + end + end + def build_base_entity_data(entity) { - :name => entity.name, + :name => entity_name(entity), :kind => entity_type(entity), :model => entity.class.to_s, :miq_id => entity.id, diff --git a/spec/services/topology_service_spec.rb b/spec/services/topology_service_spec.rb index ab3beb1f539..930b840bcc3 100644 --- a/spec/services/topology_service_spec.rb +++ b/spec/services/topology_service_spec.rb @@ -128,4 +128,26 @@ end end end + + describe '#entity_name' do + let(:name) { subject.send(:entity_name, entity) } + + context 'entity is not a tag' do + let(:entity) { FactoryGirl.create(:vm_vmware) } + + it 'returns with the name of the entity' do + expect(name).to eq(entity.name) + end + end + + context 'entity is a tag' do + let(:parent_cls) { FactoryGirl.create(:classification, :description => 'foo') } + let(:cls) { FactoryGirl.create(:classification, :parent => parent_cls, :description => 'bar') } + let(:entity) { FactoryGirl.create(:tag, :classification => cls) } + + it 'returns with the parent and the child classification description' do + expect(name).to eq('foo: bar') + end + end + end end