QutBioacoustics/baw-server

View on GitHub
app/views/sites/show.html.haml

Summary

Maintainability
Test Coverage
- content_for :meta_title, "Project #{@project.name} | Site #{@site.name}"
- content_for :page_title do @site.name
  %small
    Project:
    = @project.name
  %br
  = @site.name
- @info_bar = {model: @site,  icon: 'map-marker'}

- content_for :page_actions do
  = nav_item(href: make_visualise_path(@site),
    title: t('baw.shared.links.visualize.title'),
    tooltip: t('baw.shared.links.visualize.description'),
    icon: 'map' )
  = listen_link(@site)
  = nav_item(href: make_site_annotations_path(@project, @site),
    title: t('baw.shared.links.annotations_download.title'),
    tooltip: t('baw.shared.links.annotations_download.description'),
    icon: 'table' )
  - if can? :edit, @site
    = edit_link(edit_project_site_path(@project, @site), 'site')
  - if can? :upload_instructions, @site
    = nav_item(href:  upload_instructions_project_site_path(@project, @site),
      title: t('baw.shared.links.harvest.title'),
      tooltip: t('baw.shared.links.harvest.description') )
  - if defined?(@project) && defined?(@site) && Access::Core.is_admin?(current_user)
    = destroy_button([@project, @site], 'site')

- content_for :right_sidebar do
  - level = Access::Core.user_levels(current_user, @project)
  - unless level.blank?
    - level_name = Access::Core.get_level_name(level)
    = render partial: 'shared/sidebar_metadata', locals: {title: 'Your access level', text: level_name}

.col-sm-12
  .row
    .col-sm-4
      .thumbnail
        = image_tag @site.image.url(:span3), alt: @site.name
    .col-sm-8
      = raw @site.description_html
  .row
    .col-sm-12
      %h2
        Audio Recordings

  - play_details = @site.get_bookmark_or_recording
  - play_link = play_details.blank? ? nil : make_listen_path(play_details[:audio_recording], play_details[:start_offset_seconds])

  .row
    .col-sm-6
      - if !@site.audio_recordings.any?
        %p
          This site does not contain any audio recordings.
      - else
        - duration_sum = @site.audio_recordings.sum(:duration_seconds)

        - record_min = @site.audio_recordings.order(recorded_date: :asc).first
        - recorded_min = record_min.recorded_date
        - recorded_min = recorded_min.in_time_zone(@site.rails_tz) unless @site.rails_tz.blank?

        -# record_max = @site.audio_recordings.order('recorded_date + CAST(duration_seconds || \' seconds\' as interval) DESC').first
        -# recorded_max = record_max.recorded_date.advance(seconds: record_max.duration_seconds)
        -# recorded_max = recorded_max.in_time_zone(@site.rails_tz) unless @site.rails_tz.blank?

        -# recorded_diff = recorded_max - recorded_min
        %p
          This site contains recordings from #{recorded_min.to_formatted_s(:readable_full_without_seconds)}.
          -# to #{recorded_max.to_formatted_s(:readable_full_without_seconds)}.
        %p
          This site covers
          -# = distance_of_time recorded_diff
          and there are recordings for
          = distance_of_time duration_sum
          of that time.

        %ul.nav.nav-pills{style: 'margin-bottom:0'}
          - if play_link.blank?
            %li
              %a{href: '#', title: 'No audio recordings in this site', data: {toggle: 'tooltip',  placement: 'top'}}
                No audio
          - else
            %li
              %a{href: play_link}
                %span.fa.fa-play-circle{aria: {hidden: 'true' }}
                Play

          %li
            %a{href: make_visualise_path(@site)}
              %span.fa.fa-eye{aria: {hidden: 'true' }}
              Visualise

        %h4 Recent Annotations
        - site_audio_events = AudioEvent.in_site(@site)
        - if site_audio_events.blank?
          %p There are no annotations in this site.
        - else
          %ul.nav.nav-pills.nav-stacked{style: 'margin-bottom:0'}
            - site_audio_events.each do |ae|
              %li
                - tag = ae.tags.first
                - tag_text = tag.blank? ? '(not tagged)' : tag.text
                - user = ae.updater.blank? ? ae.updater : ae.creator
                = link_to "\"#{tag_text}\" by #{user.blank? ? '(unknown)' : user.user_name}", make_listen_path(ae)

    - if @site.latitude.blank? || @site.longitude.blank?
      .col-sm-6.map-placeholder
        %span.map-placeholder-text
          This site does not have a location set.
    - else
      .col-sm-6
        = render partial: 'shared/google_maps', locals: {markers: [{title: @site.name, lat: @site.latitude, lng: @site.longitude}]}