update frontend DNS to use dns.web
This commit is contained in:
@@ -74,7 +74,7 @@ end
|
||||
|
||||
local function loadDomains()
|
||||
print('Loading domains...')
|
||||
local response = fetch('gurt://localhost:8877/auth/domains?page=1&limit=100', {
|
||||
local response = fetch('gurt://dns.web/auth/domains?page=1&limit=100', {
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
}
|
||||
@@ -95,7 +95,7 @@ local function checkAuth()
|
||||
|
||||
if authToken then
|
||||
print('Found auth token, checking validity...')
|
||||
local response = fetch('gurt://localhost:8877/auth/me', {
|
||||
local response = fetch('gurt://dns.web/auth/me', {
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ local renderRecords
|
||||
local function deleteRecord(recordId)
|
||||
print('Deleting DNS record: ' .. recordId)
|
||||
|
||||
local response = fetch('gurt://localhost:8877/domain/' .. domainName .. '/records/' .. recordId, {
|
||||
local response = fetch('gurt://dns.web/domain/' .. domainName .. '/records/' .. recordId, {
|
||||
method = 'DELETE',
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
@@ -57,7 +57,7 @@ end
|
||||
-- Actual implementation
|
||||
loadRecords = function()
|
||||
print('Loading DNS records for: ' .. domainName)
|
||||
local response = fetch('gurt://localhost:8877/domain/' .. domainName .. '/records', {
|
||||
local response = fetch('gurt://dns.web/domain/' .. domainName .. '/records', {
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
}
|
||||
@@ -175,7 +175,7 @@ end
|
||||
|
||||
local function loadDomain()
|
||||
print('Loading domain details for: ' .. domainName)
|
||||
local response = fetch('gurt://localhost:8877/domain/' .. domainName, {
|
||||
local response = fetch('gurt://dns.web/domain/' .. domainName, {
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
}
|
||||
@@ -197,7 +197,7 @@ local function checkAuth()
|
||||
|
||||
if authToken then
|
||||
print('Found auth token, checking validity...')
|
||||
local response = fetch('gurt://localhost:8877/auth/me', {
|
||||
local response = fetch('gurt://dns.web/auth/me', {
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
}
|
||||
@@ -228,7 +228,7 @@ end
|
||||
local function addRecord(type, name, value, ttl)
|
||||
hideError('record-error')
|
||||
|
||||
local response = fetch('gurt://localhost:8877/domain/' .. domainName .. '/records', {
|
||||
local response = fetch('gurt://dns.web/domain/' .. domainName .. '/records', {
|
||||
method = 'POST',
|
||||
headers = {
|
||||
['Content-Type'] = 'application/json',
|
||||
|
||||
@@ -75,7 +75,7 @@ end
|
||||
|
||||
local function loadTLDs()
|
||||
print('Loading available TLDs...')
|
||||
local response = fetch('gurt://localhost:8877/tlds')
|
||||
local response = fetch('gurt://dns.web/tlds')
|
||||
|
||||
if response:ok() then
|
||||
tlds = response:json()
|
||||
@@ -91,7 +91,7 @@ local function checkAuth()
|
||||
|
||||
if authToken then
|
||||
print('Found auth token, checking validity...')
|
||||
local response = fetch('gurt://localhost:8877/auth/me', {
|
||||
local response = fetch('gurt://dns.web/auth/me', {
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
}
|
||||
@@ -127,7 +127,7 @@ local function submitDomain(name, tld)
|
||||
hideError('domain-error')
|
||||
print('Submitting domain: ' .. name .. '.' .. tld)
|
||||
|
||||
local response = fetch('gurt://localhost:8877/domain', {
|
||||
local response = fetch('gurt://dns.web/domain', {
|
||||
method = 'POST',
|
||||
headers = {
|
||||
['Content-Type'] = 'application/json',
|
||||
@@ -157,7 +157,7 @@ end
|
||||
|
||||
local function createInvite()
|
||||
print('Creating invite code...')
|
||||
local response = fetch('gurt://localhost:8877/auth/invite', {
|
||||
local response = fetch('gurt://dns.web/auth/invite', {
|
||||
method = 'POST',
|
||||
headers = {
|
||||
Authorization = 'Bearer ' .. authToken
|
||||
@@ -184,7 +184,7 @@ local function redeemInvite(code)
|
||||
hideError('redeem-error')
|
||||
print('Redeeming invite code: ' .. code)
|
||||
|
||||
local response = fetch('gurt://localhost:8877/auth/redeem-invite', {
|
||||
local response = fetch('gurt://dns.web/auth/redeem-invite', {
|
||||
method = 'POST',
|
||||
headers = {
|
||||
['Content-Type'] = 'application/json',
|
||||
|
||||
@@ -21,7 +21,7 @@ submitBtn:on('submit', function(event)
|
||||
password = password
|
||||
})
|
||||
print(request_body)
|
||||
local url = 'gurt://localhost:8877/auth/login'
|
||||
local url = 'gurt://dns.web/auth/login'
|
||||
local headers = {
|
||||
['Content-Type'] = 'application/json'
|
||||
}
|
||||
|
||||
66
flumi/Scenes/NetworkRequestItem.tscn
Normal file
66
flumi/Scenes/NetworkRequestItem.tscn
Normal file
@@ -0,0 +1,66 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dqvgywj71hfry"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/NetworkRequestItem.gd" id="1_8v2qr"]
|
||||
|
||||
[node name="NetworkRequestItem" type="PanelContainer"]
|
||||
custom_minimum_size = Vector2(0, 28)
|
||||
script = ExtResource("1_8v2qr")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="IconContainer" type="Control" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(20, 20)
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="HBoxContainer/IconContainer"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -8.0
|
||||
offset_top = -8.0
|
||||
offset_right = 8.0
|
||||
offset_bottom = 8.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
custom_minimum_size = Vector2(16, 16)
|
||||
|
||||
[node name="NameLabel" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
custom_minimum_size = Vector2(140, 0)
|
||||
text = "Request Name"
|
||||
clip_contents = true
|
||||
text_overrun_behavior = 3
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="StatusLabel" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(60, 0)
|
||||
text = "200"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TypeLabel" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(60, 0)
|
||||
text = "Fetch"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="SizeLabel" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
text = "1.2 KB"
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="TimeLabel" type="Label" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
custom_minimum_size = Vector2(80, 0)
|
||||
text = "125ms"
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 1
|
||||
98
flumi/Scripts/NetworkRequestItem.gd
Normal file
98
flumi/Scripts/NetworkRequestItem.gd
Normal file
@@ -0,0 +1,98 @@
|
||||
class_name NetworkRequestItem
|
||||
extends PanelContainer
|
||||
|
||||
@onready var icon: TextureRect = $HBoxContainer/IconContainer/Icon
|
||||
@onready var name_label: Label = $HBoxContainer/NameLabel
|
||||
@onready var status_label: Label = $HBoxContainer/StatusLabel
|
||||
@onready var type_label: Label = $HBoxContainer/TypeLabel
|
||||
@onready var size_label: Label = $HBoxContainer/SizeLabel
|
||||
@onready var time_label: Label = $HBoxContainer/TimeLabel
|
||||
|
||||
var request: NetworkRequest
|
||||
var network_tab: NetworkTab
|
||||
|
||||
signal item_clicked(request: NetworkRequest)
|
||||
|
||||
func _ready():
|
||||
# Set up styles for different states
|
||||
var style_normal = StyleBoxFlat.new()
|
||||
style_normal.bg_color = Color.TRANSPARENT
|
||||
style_normal.content_margin_left = 5
|
||||
style_normal.content_margin_bottom = 5
|
||||
style_normal.content_margin_right = 5
|
||||
style_normal.content_margin_top = 5
|
||||
style_normal.corner_radius_bottom_left = 8
|
||||
style_normal.corner_radius_bottom_right = 8
|
||||
style_normal.corner_radius_top_left = 8
|
||||
style_normal.corner_radius_top_right = 8
|
||||
|
||||
add_theme_stylebox_override("panel", style_normal)
|
||||
|
||||
# Set up mouse handling
|
||||
mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
gui_input.connect(_on_gui_input)
|
||||
|
||||
func init(network_request: NetworkRequest, parent_tab: NetworkTab):
|
||||
request = network_request
|
||||
network_tab = parent_tab
|
||||
update_display()
|
||||
|
||||
func update_display():
|
||||
if not request:
|
||||
return
|
||||
|
||||
# Update icon
|
||||
icon.texture = request.get_icon_texture()
|
||||
|
||||
# Update labels
|
||||
name_label.text = request.name
|
||||
status_label.text = request.get_status_display()
|
||||
type_label.text = request.get_type_display()
|
||||
size_label.text = request.get_size_display()
|
||||
time_label.text = request.get_time_display()
|
||||
|
||||
# Color code status
|
||||
match request.status:
|
||||
NetworkRequest.RequestStatus.SUCCESS:
|
||||
status_label.add_theme_color_override("font_color", Color.GREEN)
|
||||
NetworkRequest.RequestStatus.ERROR:
|
||||
status_label.add_theme_color_override("font_color", Color.RED)
|
||||
NetworkRequest.RequestStatus.PENDING:
|
||||
status_label.add_theme_color_override("font_color", Color.YELLOW)
|
||||
|
||||
func _on_gui_input(event: InputEvent):
|
||||
if event is InputEventMouseButton:
|
||||
if event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
item_clicked.emit(request)
|
||||
|
||||
func set_selected(selected: bool):
|
||||
if selected:
|
||||
var style_selected = StyleBoxFlat.new()
|
||||
style_selected.bg_color = Color(0.2, 0.4, 0.8, 0.3)
|
||||
style_selected.content_margin_left = 5
|
||||
style_selected.content_margin_bottom = 5
|
||||
style_selected.content_margin_right = 5
|
||||
style_selected.content_margin_top = 5
|
||||
style_selected.corner_radius_bottom_left = 8
|
||||
style_selected.corner_radius_bottom_right = 8
|
||||
style_selected.corner_radius_top_left = 8
|
||||
style_selected.corner_radius_top_right = 8
|
||||
add_theme_stylebox_override("panel", style_selected)
|
||||
else:
|
||||
var style_normal = StyleBoxFlat.new()
|
||||
style_normal.bg_color = Color.TRANSPARENT
|
||||
style_normal.content_margin_left = 5
|
||||
style_normal.content_margin_bottom = 5
|
||||
style_normal.content_margin_right = 5
|
||||
style_normal.content_margin_top = 5
|
||||
style_normal.corner_radius_bottom_left = 8
|
||||
style_normal.corner_radius_bottom_right = 8
|
||||
style_normal.corner_radius_top_left = 8
|
||||
style_normal.corner_radius_top_right = 8
|
||||
add_theme_stylebox_override("panel", style_normal)
|
||||
|
||||
func hide_columns(should_hide: bool):
|
||||
status_label.visible = !should_hide
|
||||
type_label.visible = !should_hide
|
||||
size_label.visible = !should_hide
|
||||
time_label.visible = !should_hide
|
||||
Reference in New Issue
Block a user