This commit is contained in:
2026-06-12 15:40:12 -04:00
commit 521653e5de
53 changed files with 8635 additions and 0 deletions
+152
View File
@@ -0,0 +1,152 @@
class ApplicationController < Sinatra::Base
register Sinatra::ActiveRecordExtension
register Sinatra::Contrib
configure do
set :views, File.expand_path('../../views', __FILE__)
set :public_folder, File.expand_path('../../../public', __FILE__)
set :root, File.expand_path('../../..', __FILE__)
set :trust_proxy, true
set :bind, '0.0.0.0'
set :port, 4567
end
get '/' do
client_ip = request.ip.to_s
puts client_ip
if client_ip.start_with?('100.')
@url_type = 'tailscale'
elsif params[:local_ip].present? && params[:local_ip] == 'true'
@url_type = 'local_ip'
else
@url_type = 'local_domain'
end
@media = ServiceType.media
@media.services.map { |serv| serv.set_current_url(@url_type) }
@support = ServiceType.support
@support.services.map { |serv| serv.set_current_url(@url_type) }
@admin = ServiceType.admin
@admin.services.map { |serv| serv.set_current_url(@url_type) }
erb :'index'
end
get '/admin' do
erb :'admin/index'
end
get '/admin/local_network' do
@local_network = LocalNetwork.first || LocalNetwork.new
@is_readonly = true
erb :'admin/local_network/index'
end
get '/admin/local_network/edit' do
@local_network = LocalNetwork.first || LocalNetwork.create
@is_readonly = false
erb :'admin/local_network/index'
end
post '/admin/local_network' do
@local_network = LocalNetwork.find(params[:local_network][:id])
if @local_network.update(params[:local_network])
redirect 'admin/local_network'
else
erb :'admin/local_network/index'
end
end
get '/admin/machines' do
@machines = Machine.all
@is_readonly = true
erb :'admin/machines/index'
end
get '/admin/machines/edit' do
@machines = Machine.all
@is_readonly = false
erb :'admin/machines/index'
end
post '/admin/machines' do
params[:machines].each do |machine_data|
machine_data["local_network_id"] = 1
if machine_data[:id].empty? && machine_data[:name].present?
Machine.create(machine_data)
elsif machine_data[:id].present?
@machine = Machine.find(machine_data[:id])
@machine.update(machine_data)
end
end
redirect 'admin/machines'
end
get '/admin/service_types' do
@service_types = ServiceType.all
@is_readonly = true
erb :'admin/service_types/index'
end
get '/admin/service_types/edit' do
@service_types = ServiceType.all
@is_readonly = false
erb :'admin/service_types/index'
end
get '/admin/service_types/media' do
@service_type = ServiceType.media
erb :'admin/service_types/position'
end
get '/admin/service_types/admin' do
@service_type = ServiceType.admin
erb :'admin/service_types/position'
end
get '/admin/service_types/support' do
@service_type = ServiceType.support
erb :'admin/service_types/position'
end
post '/admin/service_types' do
puts params
params[:service_types].each do |service_type_data|
if service_type_data[:id].empty? && service_type_data[:name].present?
ServiceType.create(service_type_data)
elsif service_type_data[:id].present?
@service_type = ServiceType.find(service_type_data[:id])
@service_type.update(service_type_data)
end
end
redirect 'admin/service_types'
end
get '/admin/services' do
@services = Service.all
@service_types = ServiceType.all
@machines = Machine.all
@is_readonly = true
erb :'admin/services/index'
end
get '/admin/services/edit' do
@services = Service.all
@service_types = ServiceType.all
@machines = Machine.all
@is_readonly = false
erb :'admin/services/index'
end
post '/admin/services' do
params[:services].each do |service_data|
if service_data[:id].empty? && service_data[:name].present?
Service.create(service_data)
elsif service_data[:id].present?
@service = Service.find(service_data[:id])
@service.update(service_data)
end
end
redirect 'admin/services'
end
end
+14
View File
@@ -0,0 +1,14 @@
# encoding: utf-8
class LocalNetwork < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
has_many :machines
# # belongs_to :someotherthing
# scope :published, -> { order("created_at DESC") }
end
+26
View File
@@ -0,0 +1,26 @@
# encoding: utf-8
class Machine < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
has_many :services
belongs_to :local_network
# scope :published, -> { order("created_at DESC") }
# def tailscale_ip
# tailscale_ip
# end
def local_domain
"#{domain}.#{local_network.tld}"
end
def local_ip
"#{local_network.subnet}.#{local_ip_octet}"
end
end
+14
View File
@@ -0,0 +1,14 @@
# encoding: utf-8
class Post < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
# # has_many :somethings
# # belongs_to :someotherthing
# scope :published, -> { order("created_at DESC") }
end
+15
View File
@@ -0,0 +1,15 @@
# encoding: utf-8
class ServiceType < ActiveRecord::Base
# attr_accessible :title, :body
# validates :title, :presence => true
# validates :body, :presence => true
has_many :services, -> { order(position: :asc) }
scope :media, -> { includes(:services).find_by(name: "Media") }
scope :support, -> { includes(:services).find_by(name: "Support") }
scope :admin, -> { includes(:services).find_by(name: "Admin") }
end
+57
View File
@@ -0,0 +1,57 @@
# encoding: utf-8
class Service < ActiveRecord::Base
attr_accessor :current_url
# validates :title, :presence => true
# validates :body, :presence => true
belongs_to :machine
belongs_to :service_type
acts_as_list scope: :service_type
# scope :published, -> { order("created_at DESC") }
def tailscale_ip_url
if machine.tailscale_ip.present?
url = "http://#{machine.tailscale_ip}:#{port}"
if url_path.present?
url.concat(url_path)
end
url
end
end
def local_domain_url
url = "http://"
if subdomain.present?
url.concat("#{subdomain}.")
end
url.concat(machine.local_domain)
if url_path.present?
url.concat(url_path)
end
url
end
def local_ip_url
url = "http://#{machine.local_ip}:#{port}"
if url_path.present?
url.concat(url_path)
end
url
end
def set_current_url(url_type)
if url_type == 'tailscale'
self.current_url = self.tailscale_ip_url
elsif url_type == 'local_ip'
self.current_url = self.local_ip_url
else
self.current_url = self.local_domain_url
end
end
end
+23
View File
@@ -0,0 +1,23 @@
<div class="text-4xl mb-10">
Network Directory Admin
</div>
<div class="w-1/2 flex flex-col space-y-10 ml-20 mt-10">
<a href="/admin/local_network" class="inline-block w-50 px-3 py-1 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Local Network
</a>
<a href="/admin/machines" class="inline-block w-50 px-3 py-1 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Machines
</a>
<a href="/admin/service_types" class="inline-block w-50 px-3 py-1 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Service Types
</a>
<a href="/admin/services" class="inline-block w-50 px-3 py-1 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Services
</a>
</div>
+52
View File
@@ -0,0 +1,52 @@
<form action="/admin/local_network" method="POST">
<div class="text-4xl mb-10">
Local Network Settings
</div>
<% unless @is_readonly %>
<div class="w-1/2 flex flex-none items-center justify-between ml-5 mb-2">
<div class="flex-none text-xl text-[#2FD400]">Edit</div>
<div class="grow h-[1px] mt-1 bg-[#2FD400]"></div>
</div>
<% end %>
<div class="flex ml-10 space-x-2">
<input type="hidden" name="local_network[id]" value="<%= @local_network.id %>">
<div class="flex flex-col items-center">
<input class="h-8 border-2 border-[#8000FF] rounded-lg text-center" type="text" id="local_network_name" name="local_network[name]" value="<%= @local_network.name %>" <%= 'readonly' if @is_readonly %> >
<div class="text-[#2FD400]">Name</div>
</div>
<div class="flex flex-col items-center">
<input class="h-8 border-2 border-[#8000FF] rounded-lg text-center" type="text" id="local_network_subnet" name="local_network[subnet]" value="<%= @local_network.subnet %>" <%= 'readonly' if @is_readonly %> >
<div class="text-[#2FD400]">Subnet</div>
</div>
<div class="flex flex-col items-center">
<input class="h-8 border-2 border-[#8000FF] rounded-lg text-center" type="text" id="local_network_tld" name="local_network[tld]" value="<%= @local_network.tld %>" <%= 'readonly' if @is_readonly %> >
<div class="text-[#2FD400]">Top Level Domain</div>
</div>
</div>
<div class="flex flex-col space-y-2 mt-10">
<% if @is_readonly %>
<div class="w-1/2 flex justify-end space-x-5">
<a href="/admin/local_network/edit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Edit Local Network
</a>
</div>
<% else %>
<div class="w-1/2 flex justify-end space-x-5">
<button type="submit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Save Local Network
</button>
<a href="/admin/local_network" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#F80800] border-2 border-[#F80800] rounded-lg hover:text-[#F80800] hover:bg-[#140029] hover:border-[#F80800] transition-colors duration-200">
Cancel
</a>
</div>
<% end %>
</div>
</form>
+135
View File
@@ -0,0 +1,135 @@
<form action="/admin/machines" method="POST">
<div class="text-4xl mb-10">
Network Machines
</div>
<% unless @is_readonly %>
<div class="w-2/3 flex flex-none items-center justify-between ml-5 mb-2">
<div class="flex-none text-xl text-[#2FD400]">Edit</div>
<div class="grow h-[1px] mt-1 bg-[#2FD400]"></div>
</div>
<% end %>
<div class="flex flex-col ml-10 space-y-2">
<% @machines.each_with_index do |mach, index| %>
<div class="flex space-x-2">
<input type="hidden" name="machines[][id]" value="<%= mach.id %>">
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_<%= index %>_name"
name="machines[][name]"
value="<%= mach.name %>"
<%= 'readonly' if @is_readonly %> >
<% if index == @machines.length - 1 %>
<div class="text-[#2FD400]">Name</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_<%= index %>_domain"
name="machines[][domain]"
value="<%= mach.domain %>"
<%= 'readonly' if @is_readonly %> >
<% if index == @machines.length - 1 %>
<div class="text-[#2FD400]">Domain</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_<%= index %>_local_ip_octet"
name="machines[][local_ip_octet]"
value="<%= mach.local_ip_octet %>"
<%= 'readonly' if @is_readonly %> >
<% if index == @machines.length - 1 %>
<div class="text-[#2FD400]">Local IP Octet</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_<%= index %>_tailscale_ip"
name="machines[][tailscale_ip]"
value="<%= mach.tailscale_ip %>"
<%= 'readonly' if @is_readonly %> >
<% if index == @machines.length - 1 %>
<div class="text-[#2FD400]">Tailscale IP</div>
<% end %>
</div>
</div>
<% end %>
</div>
<div class="flex flex-col space-y-2 mt-10">
<% if @is_readonly %>
<div class="w-2/3 flex justify-end space-x-5">
<a href="/admin/machines/edit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Edit/Add Machines
</a>
</div>
<% else %>
<div class="w-2/3 flex flex-none items-center justify-between ml-5 mb-2">
<div class="flex-none text-xl text-[#2FD400]">New</div>
<div class="grow h-[1px] mt-1 bg-[#2FD400]"></div>
</div>
<div class="flex space-x-2 mb-10 ml-10">
<input type="hidden" name="machines[][id]" value="">
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_new_name"
name="machines[][name]"
value=""
<%= 'readonly' if @is_readonly %> >
<label for="mach_new_name" class="text-[#2FD400]">Name</label>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_new_domain"
name="machines[][domain]"
value=""
<%= 'readonly' if @is_readonly %> >
<label for="mach_new_domain" class="text-[#2FD400]">Domain</label>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_new_local_ip_octet"
name="machines[][local_ip_octet]"
value=""
<%= 'readonly' if @is_readonly %> >
<label for="mach_new_local_ip_octet" class="text-[#2FD400]">Local IP Octet</label>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="mach_new_tailscale_ip"
name="machines[][tailscale_ip]"
value=""
<%= 'readonly' if @is_readonly %> >
<label for="mach_new_tailscale_ip" class="text-[#2FD400]">Tailscale IP</label>
</div>
</div>
<div class="w-2/3 flex justify-end space-x-5">
<button type="submit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Save Machines
</button>
<a href="/admin/machines" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#F80800] border-2 border-[#F80800] rounded-lg hover:text-[#F80800] hover:bg-[#140029] hover:border-[#F80800] transition-colors duration-200">
Cancel
</a>
</div>
<% end %>
</div>
</form>
+91
View File
@@ -0,0 +1,91 @@
<form action="/admin/service_types" method="POST">
<div class="text-4xl mb-10">
Service Types
</div>
<% unless @is_readonly %>
<div class="w-1/2 flex flex-none items-center justify-between ml-5 mb-2">
<div class="flex-none text-xl text-[#2FD400]">Edit</div>
<div class="grow h-[1px] mt-1 bg-[#2FD400]"></div>
</div>
<% end %>
<div class="flex flex-col ml-10 space-y-2">
<% @service_types.each_with_index do |servt, index| %>
<div class="flex space-x-2">
<input type="hidden" name="service_types[][id]" value="<%= servt.id %>">
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="servt_<%= index %>_name"
name="service_types[][name]"
value="<%= servt.name %>"
<%= 'readonly' if @is_readonly %> >
<% if index == @service_types.length - 1 %>
<div class="text-[#2FD400]">Name</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="servt_<%= index %>_hex_color"
name="service_types[][hex_color]"
value="<%= servt.hex_color %>"
<%= 'readonly' if @is_readonly %> >
<% if index == @service_types.length - 1 %>
<div class="text-[#2FD400]">Hex Color</div>
<% end %>
</div>
</div>
<% end %>
</div>
<div class="flex flex-col space-y-2 mt-10">
<% if @is_readonly %>
<div class="w-1/2 flex justify-end space-x-5">
<a href="/admin/service_types/edit" class="inline-block w-60 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Edit/Add Service Types
</a>
</div>
<% else %>
<div class="w-1/2 flex flex-none items-center justify-between ml-5 mb-2">
<div class="flex-none text-xl text-[#2FD400]">New</div>
<div class="grow h-[1px] mt-1 bg-[#2FD400]"></div>
</div>
<div class="flex space-x-2 mb-10 ml-10">
<input type="hidden" name="service_types[][id]" value="">
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="servt_new_name"
name="service_types[][name]"
value=""
<%= 'readonly' if @is_readonly %> >
<label for="servt_new_name" class="text-[#2FD400]">Name</label>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="servt_new_hex_color"
name="service_types[][hex_color]"
value=""
<%= 'readonly' if @is_readonly %> >
<label for="servt_new_hex_color" class="text-[#2FD400]">Hex Color</label>
</div>
</div>
<div class="w-1/2 flex justify-end space-x-5">
<button type="submit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Save Service Types
</button>
<a href="/admin/service_types" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#F80800] border-2 border-[#F80800] rounded-lg hover:text-[#F80800] hover:bg-[#140029] hover:border-[#F80800] transition-colors duration-200">
Cancel
</a>
</div>
<% end %>
</div>
</form>
@@ -0,0 +1,45 @@
<form action="/admin/services" method="POST">
<div class="text-4xl mb-10">
Service Positions
</div>
<div class="flex flex-col ml-10 space-y-2">
<% @service_type.services.each_with_index do |service, index| %>
<div class="flex space-x-2">
<input type="hidden" name="services[][id]" value="<%= service.id %>">
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="service_<%= index %>_name"
name="services[][name]"
value="<%= service.name %>"
readonly >
<% if index == @service_type.services.length - 1 %>
<div class="text-[#2FD400]">Name</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="service_<%= index %>_position"
name="services[][position]"
value="<%= service.position %>" >
<% if index == @service_type.services.length - 1 %>
<div class="text-[#2FD400]">Position</div>
<% end %>
</div>
</div>
<% end %>
<div class="w-1/2 flex justify-end space-x-5">
<button type="submit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Save Service Positions
</button>
<a href="/admin/service_types" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#F80800] border-2 border-[#F80800] rounded-lg hover:text-[#F80800] hover:bg-[#140029] hover:border-[#F80800] transition-colors duration-200">
Cancel
</a>
</div>
</div>
</form>
+177
View File
@@ -0,0 +1,177 @@
<form action="/admin/services" method="POST">
<div class="text-4xl mb-10">
Services
</div>
<% unless @is_readonly %>
<div class="w-19/20 flex flex-none items-center justify-between ml-5 mb-2">
<div class="flex-none text-xl text-[#2FD400]">Edit</div>
<div class="grow h-[1px] mt-1 bg-[#2FD400]"></div>
</div>
<% end %>
<div class="flex flex-col ml-10 space-y-2">
<% @services.each_with_index do |serv, index| %>
<div class="flex space-x-2">
<input type="hidden" name="services[][id]" value="<%= serv.id %>">
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_<%= index %>_name"
name="services[][name]"
value="<%= serv.name %>"
<%= 'readonly' if @is_readonly %> >
<% if index == @services.length - 1 %>
<div class="text-[#2FD400]">Name</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<select class="h-8 border-2 border-[#8000FF] rounded-lg text-center" name="services[][service_type_id]" id="service_type_select" <%= 'disabled' if @is_readonly %> >
<option value="">Select a Service Type</option>
<% @service_types.each do |service_type| %>
<option value="<%= service_type.id %>" <%= "selected" if serv.service_type_id == service_type.id %>><%= service_type.name %></option>
<% end %>
</select>
<% if index == @services.length - 1 %>
<div class="text-[#2FD400]">Service Type</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<select class="h-8 border-2 border-[#8000FF] rounded-lg text-center" name="services[][machine_id]" id="machine_select" <%= 'disabled' if @is_readonly %> >
<option value="">Select a Service Type</option>
<% @machines.each do |machine| %>
<option value="<%= machine.id %>" <%= "selected" if serv.machine_id == machine.id %>><%= machine.name %></option>
<% end %>
</select>
<% if index == @services.length - 1 %>
<div class="text-[#2FD400]">Machine</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_<%= index %>_subdomain"
name="services[][subdomain]"
value="<%= serv.subdomain%>"
<%= 'readonly' if @is_readonly %> >
<% if index == @services.length - 1 %>
<div class="text-[#2FD400]">Subdomain</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_<%= index %>_port"
name="services[][port]"
value="<%= serv.port%>"
<%= 'readonly' if @is_readonly %> >
<% if index == @services.length - 1 %>
<div class="text-[#2FD400]">Port</div>
<% end %>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_<%= index %>_url_path"
name="services[][url_path]"
value="<%= serv.url_path%>"
<%= 'readonly' if @is_readonly %> >
<% if index == @services.length - 1 %>
<div class="text-[#2FD400]">URL Path (optional)</div>
<% end %>
</div>
</div>
<% end %>
</div>
<div class="flex flex-col space-y-2 mt-10">
<% if @is_readonly %>
<div class="w-19/20 flex justify-end space-x-5">
<a href="/admin/services/edit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Edit/Add Services
</a>
</div>
<% else %>
<div class="w-19/20 flex flex-none items-center justify-between ml-5 mb-2">
<div class="flex-none text-xl text-[#2FD400]">New</div>
<div class="grow h-[1px] mt-1 bg-[#2FD400]"></div>
</div>
<div class="flex space-x-2 mb-10 ml-10"">
<input type="hidden" name="services[][id]" value="">
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_new_name"
name="services[][name]"
value="">
<div class="text-[#2FD400]">Name</div>
</div>
<div class="flex flex-col items-center">
<select class="h-8 border-2 border-[#8000FF] rounded-lg text-center" name="services[][service_type_id]" id="service_type_select" <%= 'disabled' if @is_readonly %> >
<option value="">Select a Service Type</option>
<% @service_types.each do |service_type| %>
<option value="<%= service_type.id %>"><%= service_type.name %></option>
<% end %>
</select>
<div class="text-[#2FD400]">Service Type</div>
</div>
<div class="flex flex-col items-center">
<select class="h-8 border-2 border-[#8000FF] rounded-lg text-center" name="services[][machine_id]" id="machine_select" <%= 'disabled' if @is_readonly %> >
<option value="">Select a Service Type</option>
<% @machines.each do |machine| %>
<option value="<%= machine.id %>"><%= machine.name %></option>
<% end %>
</select>
<div class="text-[#2FD400]">Machine</div>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_new_subdomain"
name="services[][subdomain]"
value="">
<div class="text-[#2FD400]">Subdomain</div>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_new_port"
name="services[][port]"
value="">
<div class="text-[#2FD400]">Port</div>
</div>
<div class="flex flex-col items-center">
<input type="text"
class="h-8 border-2 border-[#8000FF] rounded-lg text-center"
id="serv_new_url_path"
name="services[][url_path]"
value="">
<div class="text-[#2FD400]">URL Path (optional)</div>
</div>
</div>
<div class="w-19/20 flex justify-end space-x-5">
<button type="submit" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#8000FF] border-2 border-[#8000FF] rounded-lg hover:text-[#2FD400] hover:bg-[#140029] hover:border-[#2FD400] transition-colors duration-200">
Save Services
</button>
<a href="/admin/services" class="inline-block w-50 px-3 py-1 mt-20 text-center font-semibold text-[#140029] bg-[#F80800] border-2 border-[#F80800] rounded-lg hover:text-[#F80800] hover:bg-[#140029] hover:border-[#F80800] transition-colors duration-200">
Cancel
</a>
</div>
<% end %>
</div>
</form>
+66
View File
@@ -0,0 +1,66 @@
<div class="flex flex-col gap-y-2 bg-[url('/images/purpleandblackfire.svg')] bg-size-[auto_113%] bg-center bg-no-repeat">
<div class="flex flex-none items-center py-2 mb-13">
<div class="flex-none text-5xl text-[#8000FF]">Local Network Directory</div>
<div class="grow-5 h-[3px] mt-3 bg-[#8000FF]"></div>
<div class="flex-none mx-1 mt-2 text-2xl text-[#2FD400]">
<% if @url_type == 'tailscale' %>
<%= @url_type.gsub('_', ' ') %>
<% elsif @url_type == 'local_ip' %>
<a href="/" class="flex h-full text-center hover:text-[#009fff]">
<%= @url_type.gsub('_', ' ') %>
</a>
<% else %>
<a href="?local_ip=true" class="flex h-full text-center hover:text-[#009fff]">
<%= @url_type.gsub('_', ' ') %>
</a>
<% end %>
</div>
<div class="grow-1 h-[3px] mt-3 bg-[#8000FF]"></div>
</div>
<div class="flex gap-x-7">
<div class="flex flex-col w-3/5 items-start">
<div class="flex bg-[#140029] text-center text-3xl text-[#<%= @media.hex_color %>] ml-15 -mb-4 px-2 z-1">
<%= @media.name %>
</div>
<div class="flex flex-wrap text-2xl gap-1 py-4 justify-evenly items-center border-4 border-[#<%= @media.hex_color %>] rounded-lg">
<% @media.services.each do |service| %>
<a href=<%= service.current_url %> class="flex justify-center items-center h-15 w-55 px-2 py-10 my-4 text-center font-bold text-[#<%= @media.hex_color %>] bg-transparent border-2 border-[#<%= @media.hex_color %>] rounded-lg hover:text-[#140029] hover:bg-[#<%= @media.hex_color %>] transition-colors duration-200">
<%= service.name %>
</a>
<% end %>
</div>
</div>
<div class="flex flex-col w-2/5 items-start">
<div class="bg-[#140029] text-center text-3xl text-[#<%= @support.hex_color %>] ml-15 -mb-4 px-2 z-1">
<%= @support.name %>
</div>
<div class="flex flex-wrap text-2xl gap-1 py-4 justify-evenly items-center border-4 border-[#<%= @support.hex_color %>] rounded-lg">
<% @support.services.each do |service| %>
<a href=<%= service.current_url %> class="flex justify-center items-center h-15 w-55 px-2 py-10 my-4 text-center font-bold text-[#<%= @support.hex_color %>] bg-transparent border-2 border-[#<%= @support.hex_color %>] rounded-lg hover:text-[#140029] hover:bg-[#<%= @support.hex_color %>] transition-colors duration-200">
<%= service.name %>
</a>
<% end %>
</div>
</div>
</div>
<div class="flex flex-col w-full items-start">
<div class="bg-[#140029] text-center text-3xl text-[#<%= @admin.hex_color %>] ml-15 -mb-4 px-2 z-1">
<%= @admin.name %>
</div>
<div class="flex flex-wrap w-full text-2xl gap-1 py-4 justify-evenly items-center border-4 border-[#<%= @admin.hex_color %>] rounded-lg">
<% @admin.services.each do |service| %>
<div class="flex w-[21%] justify-center items-center">
<a href=<%= service.current_url %> class="flex justify-center items-center h-15 w-55 px-2 py-10 my-4 text-center font-bold text-[#<%= @admin.hex_color %>] bg-transparent border-2 border-[#<%= @admin.hex_color %>] rounded-lg hover:text-[#140029] hover:bg-[#<%= @admin.hex_color %>] transition-colors duration-200">
<%= service.name %>
</a>
</div>
<% end %>
</div>
</div>
</div>
+13
View File
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Network Directory</title>
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
</head>
<body class="bg-[#140029] text-[#8000FF] font-semibold antialiased">
<div class="container mx-auto px-4 py-8">
<%= yield %>
</div>
</body>
</html>
+3
View File
@@ -0,0 +1,3 @@
<div class="small-12 columns">
<h2>404 Not Found</h2>
</div>