Skip to content

Commit

Permalink
Merge pull request #200 from himdel/topology-item-image-full-path
Browse files Browse the repository at this point in the history
Use full paths to images in decorators, remove item_image in favor of listicon_image
  • Loading branch information
martinpovolny authored Jan 23, 2017
2 parents 002c23c + 85797b9 commit 55e40f8
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ function MiddlewareTopologyCtrl($scope, $http, $interval, $location, topologySer
if (d.item.icon) {
return {
'type': 'image',
'icon': '/assets/svg/' + d.item.icon + '.svg'
}
'icon': d.item.icon,
};
}
return icons[d.item.display_kind]

return icons[d.item.display_kind];
};

this.dblclick = function dblclick(d) {
Expand Down Expand Up @@ -190,4 +191,4 @@ function MiddlewareTopologyCtrl($scope, $http, $interval, $location, topologySer
// Reset the search term in search input
$scope.search.query = '';
};
}
}
8 changes: 1 addition & 7 deletions app/decorators/auth_private_key_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ def fonticon
end

def listicon_image
"100/#{item_image}.png"
end

private

def item_image
'auth_key_pair'
"100/auth_key_pair.png"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ def fonticon
end

def listicon_image
"svg/#{item_image}.svg"
end

def item_image
'vendor-hawkular'
"svg/vendor-hawkular.svg"
end
end
end
6 changes: 2 additions & 4 deletions app/decorators/middleware_datasource_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
class MiddlewareDatasourceDecorator < Draper::Decorator
delegate_all
include MiddlewareDecoratorMixin

def fonticon
'fa fa-database'.freeze
end

# Determine the icon
def item_image
'middleware_datasource'
def listicon_image
'100/middleware_datasource.png'
end
end
5 changes: 0 additions & 5 deletions app/decorators/middleware_decorator_mixin.rb

This file was deleted.

12 changes: 4 additions & 8 deletions app/decorators/middleware_deployment_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class MiddlewareDeploymentDecorator < Draper::Decorator
delegate_all
include MiddlewareDecoratorMixin

def fonticon
if name.end_with? '.ear'
Expand All @@ -12,16 +11,13 @@ def fonticon
end
end

# Determine the icon
# we want to display a different icon depending of the type
# of server we have.
def item_image
def listicon_image
if name.end_with? '.ear'
'middleware_deployment_ear'
'100/middleware_deployment_ear.png'
elsif name.end_with? '.war'
'middleware_deployment_war'
'100/middleware_deployment_war.png'
else
'middleware_deployment'
'100/middleware_deployment.png'
end
end
end
6 changes: 2 additions & 4 deletions app/decorators/middleware_domain_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
class MiddlewareDomainDecorator < Draper::Decorator
delegate_all
include MiddlewareDecoratorMixin

def fonticon
'pficon-domain'.freeze
end

# Determine the icon
def item_image
'middleware_domain'
def listicon_image
'100/middleware_domain.png'
end
end
6 changes: 2 additions & 4 deletions app/decorators/middleware_messaging_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
class MiddlewareMessagingDecorator < Draper::Decorator
delegate_all
include MiddlewareDecoratorMixin

def fonticon
'fa fa-exchange'.freeze
end

# Determine the icon
def item_image
'middleware_messaging'
def listicon_image
'100/middleware_messaging.png'
end
end
15 changes: 5 additions & 10 deletions app/decorators/middleware_server_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
class MiddlewareServerDecorator < Draper::Decorator
delegate_all
include MiddlewareDecoratorMixin

def fonticon
nil
end

# Determine the icon
# we want to display a different icon depending of the type
# of server we have.
def item_image
def listicon_image
case product
when 'Hawkular'
'vendor-hawkular'
'svg/vendor-hawkular.svg'
when 'JBoss EAP'
'vendor-jboss-eap'
'svg/vendor-jboss-eap.svg'
else
'vendor-wildfly'
'svg/vendor-wildfly.svg'
end
end

end
end
6 changes: 2 additions & 4 deletions app/decorators/middleware_server_group_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
class MiddlewareServerGroupDecorator < Draper::Decorator
delegate_all
include MiddlewareDecoratorMixin

def fonticon
'pficon-server-group'.freeze
end

# Determine the icon
def item_image
'middleware_server_group'
def listicon_image
'100/middleware_server_group.png'
end
end
7 changes: 6 additions & 1 deletion app/services/middleware_topology_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ def build_entity_data(entity)
data = build_base_entity_data(entity)
data[:status] = 'Unknown'
data[:display_kind] = entity_display_type(entity)
data[:icon] = entity.decorate.try(:item_image) unless glyph? entity

unless glyph? entity
data[:icon] = ActionController::Base.helpers.image_path(entity.decorate.try(:listicon_image))
end

if entity.kind_of?(Vm)
data[:status] = entity.power_state.capitalize
data[:provider] = entity.ext_management_system.name
end

data
end

Expand Down

0 comments on commit 55e40f8

Please sign in to comment.