<%= link_to admin_gateways_path, class: "inline-flex items-center gap-2 text-sm font-medium text-gray-600 hover:text-gray-900 transition-colors" do %> Back to Gateways <% end %>
<% if @is_new && @raw_key.present? %>

Gateway Created Successfully!

Your new gateway has been registered and is ready to connect.

Important: Save this API key now!

This is the only time you'll be able to see the full API key. You need to configure this key in your Android gateway app to connect it to the system.

Scan QR Code

Scan this QR code with your Android gateway app to auto-configure

<%= @qr_code_data.html_safe %>

QR code contains API key, API base URL, and WebSocket URL

Manual Configuration

Or manually enter these details if QR scanning is unavailable

<%= request.base_url %>
<%= request.base_url.sub(/^http/, 'ws') %>/cable
<%= @raw_key %>

Gateway Details

Device ID
<%= @gateway.device_id %>
Name
<%= @gateway.name %>
Priority
<%= @gateway.priority %>
Status
Offline (Waiting for connection)
Created
<%= @gateway.created_at.strftime("%B %d, %Y at %l:%M %p") %>

Quick Setup Guide

Option 1: QR Code (Recommended)

  1. Install the Android SMS Gateway app on your device
  2. Open the app and look for "Scan QR Code" option
  3. Scan the QR code above - configuration will be applied automatically
  4. Start the gateway service in the app

Option 2: Manual Entry

  1. Install the Android SMS Gateway app on your device
  2. Open the app and navigate to Settings
  3. Copy and paste each field from the "Manual Configuration" section above
  4. Save the configuration and start the gateway service

The gateway will appear as "Online" once it successfully connects to the server.

<% else %>

<%= @gateway.name %>

Gateway device details and statistics

<% if @gateway.status == "online" %> Online <% else %> Offline <% end %>

Connection Status

<%= @gateway.status.titleize %>

Active Status

<%= @gateway.active ? 'Active' : 'Inactive' %>

Priority Level

<%= @gateway.priority %>

Messages Sent Today

<%= @gateway.messages_sent_today %>

Messages Received Today

<%= @gateway.messages_received_today %>

Total Messages

<%= @gateway.total_messages_sent + @gateway.total_messages_received %>

Gateway Details

Device ID
<%= @gateway.device_id %>
Name
<%= @gateway.name %>
Status
<% if @gateway.status == "online" %> Online <% else %> Offline <% end %>
Active
<% if @gateway.active %> Active <% else %> Inactive <% end %>
Priority
<%= @gateway.priority %>
Last Heartbeat
<% if @gateway.last_heartbeat_at %>
<%= @gateway.last_heartbeat_at.strftime("%B %d, %Y at %l:%M:%S %p") %> (<%= time_ago_in_words(@gateway.last_heartbeat_at) %> ago)
<% else %> Never <% end %>
Total Messages Sent
<%= @gateway.total_messages_sent %>
Total Messages Received
<%= @gateway.total_messages_received %>
Created
<%= @gateway.created_at.strftime("%B %d, %Y at %l:%M %p") %>
Last Updated
<%= @gateway.updated_at.strftime("%B %d, %Y at %l:%M %p") %>
<% if @gateway.metadata.present? %>

Device Metadata

<%= JSON.pretty_generate(@gateway.metadata) %>
<% end %>
<%= link_to test_admin_gateway_path(@gateway), class: "inline-flex items-center gap-2 rounded-lg bg-blue-600 px-6 py-3 text-sm font-semibold text-white shadow-sm hover:bg-blue-500 transition-all duration-200" do %> Test Gateway <% end %> <%= button_to toggle_admin_gateway_path(@gateway), method: :post, class: @gateway.active ? "inline-flex items-center gap-2 rounded-lg bg-red-600 px-6 py-3 text-sm font-semibold text-white shadow-sm hover:bg-red-500 transition-all duration-200" : "inline-flex items-center gap-2 rounded-lg bg-green-600 px-6 py-3 text-sm font-semibold text-white shadow-sm hover:bg-green-500 transition-all duration-200" do %> <% if @gateway.active %> Deactivate Gateway <% else %> Activate Gateway <% end %> <% end %>

Recent Messages

Last <%= @recent_messages.size %> messages from this gateway

<% if @recent_messages.any? %>
<% @recent_messages.each do |msg| %> <% end %>
Message ID Phone Number Direction Status Created
<%= msg.message_id[0..15] %>... <%= msg.phone_number %> <% if msg.direction == "outbound" %> Outbound <% else %> Inbound <% end %> <% case msg.status %> <% when "delivered" %> Delivered <% when "sent" %> Sent <% when "failed" %> Failed <% when "pending" %> Pending <% else %> <%= msg.status.titleize %> <% end %> <%= msg.created_at.strftime("%m/%d/%y %H:%M") %>
<% else %>

No messages yet

Messages will appear here once this gateway starts processing SMS.

<% end %>
<% end %>