Class: Crm::ImagePresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- BasePresenter
- Crm::ImagePresenter
- Includes:
- Presenters::ImageTag
- Defined in:
- app/presenters/crm/image_presenter.rb
Overview
Presenter: image presenter.
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
- #advanced_info ⇒ Object
- #embedding_status_badge ⇒ Object
-
#image_asset_tag(options = {}) ⇒ Object
image_asset_tag('mudroom-with-slab-heating-cable-01ea58', width: 600, class: 'img-fluid img-room').
- #image_tab_options ⇒ Object
Methods inherited from BasePresenter
Methods inherited from BasePresenter
#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u
Constructor Details
This class inherits a constructor from Crm::BasePresenter
Instance Method Details
#advanced_info ⇒ Object
9 10 11 12 13 |
# File 'app/presenters/crm/image_presenter.rb', line 9 def advanced_info return unless image.image_info h.simple_format(image.image_info.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')) end |
#embedding_status_badge ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/presenters/crm/image_presenter.rb', line 49 def unified = r.(:unified) has_phash = r.fingerprint.present? has_vision = r.ai_visual_description.present? = unified&..present? && unified&.content_hash.present? count = [has_phash, has_vision, ].count(true) case count when 3 h.fa_icon('circle-check', family: :solid, class: 'text-success ms-1', title: 'All AI analysis complete') when 0 h.fa_icon('circle-xmark', family: :solid, class: 'text-danger ms-1', title: 'No AI analysis') else h.fa_icon('circle-half-stroke', family: :solid, class: 'text-warning ms-1', title: 'AI analysis incomplete') end end |
#image_asset_tag(options = {}) ⇒ Object
image_asset_tag('mudroom-with-slab-heating-cable-01ea58', width: 600, class: 'img-fluid img-room')
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/presenters/crm/image_presenter.rb', line 16 def image_asset_tag( = {}) render_tag = .delete(:render_tag).to_b [:class] ||= 'img-fluid' [:encode_format] ||= @options&.dig(:img_options, :encode_format) || :jpeg = +'' .each_with_index do |(k, v), idx| << ', ' unless idx == 0 << "#{k}: '#{v}'" end if render_tag h.image_asset_tag(r, **) else "<%= image_asset_tag(#{r.id}, #{}) %>" end end |
#image_tab_options ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/presenters/crm/image_presenter.rb', line 32 def tabs = {} tabs[:main_attributes] = { partial: '/crm/images/main_attributes', locals: { ip: self } } tabs[:preview] = { partial: '/crm/images/preview', locals: { ip: self } } tabs[:links] = { partial: '/crm/images/links', locals: { ip: self } } tabs[:file_info] = { remote_href: h.tab_file_info_image_path(r.id) } tabs[:ai_embeddings] = { remote_href: h.(r.id), counter_html: } tabs[:items] = { remote_href: h.tab_items_image_path(r.id), counter: all_my_items.size } tabs[:profiles] = { remote_href: h.tab_profiles_image_path(r.id), counter: image_profiles.size } tabs[:videos] = { remote_href: h.tab_videos_image_path(r.id), counter: video_posters.size } if video_posters.any? tabs[:duplicates] = { remote_href: h.tab_duplicates_image_path(r.id) } tabs end |