Class: Crm::ImagePresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- BasePresenter
- Crm::ImagePresenter
- Includes:
- Presenters::ImageTag
- Defined in:
- app/presenters/crm/image_presenter.rb
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
8 9 10 11 12 |
# File 'app/presenters/crm/image_presenter.rb', line 8 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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/presenters/crm/image_presenter.rb', line 48 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 '<i class="fa-solid fa-circle-check text-success ms-1" title="All AI analysis complete"></i>' when 0 '<i class="fa-solid fa-circle-xmark text-danger ms-1" title="No AI analysis"></i>' else '<i class="fa-solid fa-circle-half-stroke text-warning ms-1" title="AI analysis incomplete"></i>' end end |
#image_asset_tag(options = {}) ⇒ Object
image_asset_tag('mudroom-with-slab-heating-cable-01ea58', width: 600, class: 'img-fluid img-room')
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/presenters/crm/image_presenter.rb', line 15 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
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/presenters/crm/image_presenter.rb', line 31 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 |