From f2fc528f7ca9a2d2f2f53cac7baeb0a48ce00287 Mon Sep 17 00:00:00 2001 From: Face <69168154+face-hh@users.noreply.github.com> Date: Fri, 5 Sep 2025 16:22:56 +0300 Subject: [PATCH] update frontend DNS to use dns.web --- dns/frontend/dashboard.lua | 4 +- dns/frontend/domain.lua | 10 +-- dns/frontend/register.lua | 10 +-- dns/frontend/script.lua | 2 +- flumi/Scenes/NetworkRequestItem.tscn | 66 +++++++++++++++++++ flumi/Scripts/NetworkRequestItem.gd | 98 ++++++++++++++++++++++++++++ 6 files changed, 177 insertions(+), 13 deletions(-) create mode 100644 flumi/Scenes/NetworkRequestItem.tscn create mode 100644 flumi/Scripts/NetworkRequestItem.gd diff --git a/dns/frontend/dashboard.lua b/dns/frontend/dashboard.lua index c6feba5..920e42a 100644 --- a/dns/frontend/dashboard.lua +++ b/dns/frontend/dashboard.lua @@ -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 } diff --git a/dns/frontend/domain.lua b/dns/frontend/domain.lua index ab73ced..0f70f66 100644 --- a/dns/frontend/domain.lua +++ b/dns/frontend/domain.lua @@ -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', diff --git a/dns/frontend/register.lua b/dns/frontend/register.lua index 7206d1d..859662c 100644 --- a/dns/frontend/register.lua +++ b/dns/frontend/register.lua @@ -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', diff --git a/dns/frontend/script.lua b/dns/frontend/script.lua index f0fe8e3..12bcc87 100644 --- a/dns/frontend/script.lua +++ b/dns/frontend/script.lua @@ -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' } diff --git a/flumi/Scenes/NetworkRequestItem.tscn b/flumi/Scenes/NetworkRequestItem.tscn new file mode 100644 index 0000000..f3f3e46 --- /dev/null +++ b/flumi/Scenes/NetworkRequestItem.tscn @@ -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 \ No newline at end of file diff --git a/flumi/Scripts/NetworkRequestItem.gd b/flumi/Scripts/NetworkRequestItem.gd new file mode 100644 index 0000000..7f442e8 --- /dev/null +++ b/flumi/Scripts/NetworkRequestItem.gd @@ -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 \ No newline at end of file