fix(admin): expose gateway test actions
This commit is contained in:
@@ -51,36 +51,6 @@ module Admin
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_qr_code_data(api_key)
|
||||
require "rqrcode"
|
||||
|
||||
# Determine the base URL and WebSocket URL
|
||||
base_url = request.base_url
|
||||
ws_url = request.base_url.sub(/^http/, "ws") + "/cable"
|
||||
|
||||
# Create JSON configuration for the Android app
|
||||
config_data = {
|
||||
api_key: api_key,
|
||||
api_base_url: base_url,
|
||||
websocket_url: ws_url,
|
||||
version: "1.0"
|
||||
}.to_json
|
||||
|
||||
# Generate QR code
|
||||
qr = RQRCode::QRCode.new(config_data, level: :h)
|
||||
|
||||
# Return as SVG string
|
||||
qr.as_svg(
|
||||
offset: 0,
|
||||
color: "000",
|
||||
shape_rendering: "crispEdges",
|
||||
module_size: 4,
|
||||
standalone: true,
|
||||
use_path: true
|
||||
)
|
||||
end
|
||||
|
||||
def toggle
|
||||
@gateway = Gateway.find(params[:id])
|
||||
@@ -148,5 +118,36 @@ module Admin
|
||||
Rails.logger.error "Test SMS failed: #{e.message}\n#{e.backtrace.join("\n")}"
|
||||
render json: { status: "error", message: e.message }, status: :internal_server_error
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_qr_code_data(api_key)
|
||||
require "rqrcode"
|
||||
|
||||
# Determine the base URL and WebSocket URL
|
||||
base_url = request.base_url
|
||||
ws_url = request.base_url.sub(/^http/, "ws") + "/cable"
|
||||
|
||||
# Create JSON configuration for the Android app
|
||||
config_data = {
|
||||
api_key: api_key,
|
||||
api_base_url: base_url,
|
||||
websocket_url: ws_url,
|
||||
version: "1.0"
|
||||
}.to_json
|
||||
|
||||
# Generate QR code
|
||||
qr = RQRCode::QRCode.new(config_data, level: :h)
|
||||
|
||||
# Return as SVG string
|
||||
qr.as_svg(
|
||||
offset: 0,
|
||||
color: "000",
|
||||
shape_rendering: "crispEdges",
|
||||
module_size: 4,
|
||||
standalone: true,
|
||||
use_path: true
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user