Arie/serveme

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

Summary

Maintainability
Test Coverage
= turbo_stream_from @reservation

- title = "Reservation: #{reservation.to_s}"
- content_for :title do
  = title
- content_for :meta_description do
  = title

- content_for :head do
  = render "shared/meta_tags", title: title, description: title, url: reservation_url(reservation)

%h3
  Reservation:
  = reservation.to_s
  - clone_identifier = "#{[reservation&.server_config&.file, reservation&.first_map, (reservation&.whitelist&.file || reservation&.custom_whitelist_id)].reject(&:blank?).join(' | ')}"
  = link_to new_reservation_path(reservation.template_attributes), class: 'btn btn-lg btn-primary', title: "Clone this reservation: #{clone_identifier}", alt: clone_identifier do
    %i.fa.fa-clone
    Clone

- if reservation&.server&.sdr?
  .row
    .col-md-12
      %p.alert.alert-warning
        This is a server hosted on Valve's SDR network. A special kind of VPN to improve pings and defend against DDoS attacks.
        %br
        SDR servers can't be used for TF2Center/TF2Stadium and you can only use RCON with the !rcon chat command
        %br
        Use the connect command in TF2 console to connect to the server.

.row
  .col-md-12

    %table.table.table-hover.table-bordered.table-striped
      - if current_user.admin? || current_user.league_admin? || current_user.streamer?
        %tr
          %td Reserved by
          %td
            = link_to(reservation.user.nickname, reservation.user.steam_profile_url, target: "_blank")
      %tr
        %td Status
        %td
          = render "status"

      %tr
        %td Actions
        %td.actions= render 'actions'

      - if reservation.now?
        %tr
          %td Server control
          %td= link_to "Web RCON", rcon_reservation_path(reservation), class: "btn btn-sm btn-warning"

      %tr
        %td Connect info
        %td
          = render "connect_info"

      %tr
        %td
          SDR connect info
        %td
          = render "sdr_connect_info"

      - if !reservation&.server&.sdr?
        %tr
          %td TF2Center info
          %td
            Server Address:
            - ip_and_port = "#{reservation.server&.hostname_to_ip}:#{reservation.public_port}"
            = ip_and_port
            = render 'shared/copy_button', :copy_button_id => "server_address", :copy_text => ip_and_port
            %br
            Rcon Password:
            = reservation.rcon
            = render 'shared/copy_button', :copy_button_id => "rcon_password", :copy_text => reservation.rcon

      %tr
        %td Password
        %td= reservation.password

      %tr
        %td RCON
        %td
          -if !au_system? && reservation&.server&.sdr? && !(current_user.admin? || current_user.league_admin? || current_user.streamer?)
            %p RCON is not available for SDR servers, use !rcon in chat
          - else
            = reservation.rcon_string
            = render 'shared/copy_button', :copy_button_id => "rcon_string", :copy_text => reservation.rcon_string

      %tr
        %td TV password
        %td= reservation.tv_password

      %tr
        %td STV connect info
        %td
          = render "stv_connect_info"
          - if current_admin || current_league_admin || current_streamer
            - ip_and_port = "#{reservation&.server&.public_ip}:#{reservation&.server&.public_tv_port}"
            - password_for_relay = reservation.tv_relaypassword.presence || reservation.tv_password
            = link_to "http://relay.fakkelbrigade.eu/new?ip_port=#{ip_and_port}&password=#{password_for_relay}", :title => "create relay", :class => "btn btn-sm btn-warning", :target => "_blank" do
              Create relay
              %i.fa.fa-share-alt

      - if reservation.server_config
        %tr
          %td Server config
          %td= reservation.server_config

      - if reservation.custom_whitelist_id.present?
        %tr
          %td Whitelist
          %td= link_to("Custom whitelist", "http://whitelist.tf/#{reservation.custom_whitelist_id}")
      - elsif reservation.whitelist
        %tr
          %td Whitelist
          %td= reservation.whitelist

      - if current_admin || current_league_admin || current_streamer
        %tr
          %td Logsecret
          %td
            = reservation.logsecret
            = render 'shared/copy_button', :copy_button_id => "logsecret_string", :copy_text => reservation.logsecret
            - ip_and_port = "#{reservation&.server&.ip}:#{reservation&.server&.port}"
            = link_to "http://live.fakkelbrigade.eu/matches/new?host=#{ip_and_port}&rcon=#{reservation.rcon}&logsecret=#{reservation.logsecret}", :title => "create livestats", :class => "btn btn-sm btn-warning", :target => "_blank" do
              Livestats
              %i.fa.fa-bar-chart
        %tr
          %td Stats
          %td
            = link_to show_reservation_statistic_path(reservation),         :title => "Player stats", :class => "btn btn-sm btn-info" do
              Player stats
              %i.fa.fa-bar-chart
            = link_to show_reservation_server_statistic_path(reservation),  :title => "Server stats", :class => "btn btn-sm btn-primary" do
              Server stats
              %i.fa.fa-bar-chart

    %table#reservation_statuses.table.table-hover.table-bordered
      = render reservation.reservation_statuses.ordered