mirror of
https://github.com/Relintai/pandemonium_demo_projects.git
synced 2025-01-02 14:39:37 +01:00
Also converted the settings page to the new templates.
This commit is contained in:
parent
15e23dbedf
commit
4975c59422
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=14 format=2]
|
||||
[gd_scene load_steps=15 format=2]
|
||||
|
||||
[ext_resource path="res://WebServerSimple.gd" type="Script" id=1]
|
||||
[ext_resource path="res://WebRoot.gd" type="Script" id=2]
|
||||
@ -10,6 +10,7 @@
|
||||
[ext_resource path="res://templates/LoginPage.tres" type="HTMLTemplate" id=8]
|
||||
[ext_resource path="res://templates/RegisterDefaultPage.tres" type="HTMLTemplate" id=9]
|
||||
[ext_resource path="res://templates/RegisterSuccessPage.tres" type="HTMLTemplate" id=10]
|
||||
[ext_resource path="res://templates/SettingsPage.tres" type="HTMLTemplate" id=11]
|
||||
|
||||
[sub_resource type="SessionSetupWebServerMiddleware" id=3]
|
||||
|
||||
@ -77,6 +78,7 @@ uri_segment = "settings"
|
||||
logged_out_render_type = 1
|
||||
logged_out_redirect_url = "/user/login"
|
||||
script = ExtResource( 7 )
|
||||
template = ExtResource( 11 )
|
||||
|
||||
[node name="HTTPSessionManagerDB" type="HTTPSessionManagerDB" parent="WebServerSimple"]
|
||||
script = ExtResource( 3 )
|
||||
|
@ -1,5 +1,7 @@
|
||||
extends UserSettingsWebPage
|
||||
|
||||
export(HTMLTemplate) var template : HTMLTemplate
|
||||
|
||||
class SettingsRequestData:
|
||||
var error_str : String = ""
|
||||
var pass_val : String = ""
|
||||
@ -52,94 +54,7 @@ func _render_index(request : WebServerRequest) -> void:
|
||||
func _render_user_page(request: WebServerRequest, data: Dictionary) -> void:
|
||||
#print(data)
|
||||
|
||||
var user : User = data["user"]
|
||||
|
||||
var b : HTMLBuilder = HTMLBuilder.new()
|
||||
|
||||
# Title
|
||||
b.div("row mb-4")
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-8")
|
||||
|
||||
b.h2()
|
||||
b.w("User Settings")
|
||||
b.ch2()
|
||||
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
b.cdiv()
|
||||
|
||||
# Errors
|
||||
var error_str : String = data["error_str"]
|
||||
|
||||
if !error_str.empty():
|
||||
b.div("row mb-4")
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-8")
|
||||
b.div("alert alert-danger").attrib("role", "alert")
|
||||
b.w(error_str)
|
||||
b.cdiv()
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
b.cdiv()
|
||||
|
||||
if error_str.empty() && request.get_method() == HTTPServerEnums.HTTP_METHOD_POST:
|
||||
b.div("row mb-4")
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-8")
|
||||
b.div("alert alert-success").attrib("role", "alert")
|
||||
b.w("Save successful!")
|
||||
b.cdiv()
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
b.cdiv()
|
||||
|
||||
# Form
|
||||
b.div("row")
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-8")
|
||||
|
||||
if true:
|
||||
b.form().method_post()
|
||||
b.csrf_tokenr(request)
|
||||
|
||||
b.div("form-group")
|
||||
b.label().fora("password_input").cls("form_label").f().w("New Password").clabel()
|
||||
b.input_password("password", "", "*******", "form-control", "password_input")
|
||||
b.cdiv()
|
||||
|
||||
b.div("form-group")
|
||||
b.label().fora("password_check_input").cls("form_label").f().w("New Password again").clabel()
|
||||
b.input_password("password_check", "", "*******", "form-control", "password_check_input")
|
||||
b.cdiv()
|
||||
|
||||
b.button().type("submit").cls("btn btn-outline-primary mt-3").f().w("Save").cbutton()
|
||||
|
||||
b.cform()
|
||||
|
||||
b.cdiv()
|
||||
|
||||
b.div("col-2")
|
||||
b.cdiv()
|
||||
b.cdiv()
|
||||
|
||||
|
||||
b.write_tag()
|
||||
request.body += b.result
|
||||
request.body += template.render(request, data)
|
||||
request.compile_and_send_body()
|
||||
|
||||
func _ready() -> void:
|
||||
|
@ -0,0 +1,26 @@
|
||||
[gd_resource type="HTMLTemplate" load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://templates/SettingsPageTP.phtpl" type="HTMLTemplateData" id=1]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
script/source = "extends HTMLTemplate
|
||||
|
||||
func _render(request: WebServerRequest, data: Dictionary) -> String:
|
||||
data[\"csrf_token\"] = request.get_csrf_token()
|
||||
|
||||
var error_str : String = data[\"error_str\"]
|
||||
|
||||
if !error_str.empty():
|
||||
data[\"error_str\"] = get_and_render_template(@\"Error\", data)
|
||||
|
||||
if error_str.empty() && request.get_method() == HTTPServerEnums.HTTP_METHOD_POST:
|
||||
data[\"error_str\"] = get_and_render_template(@\"Success\", data)
|
||||
|
||||
return get_and_render_template(@\"Settings\", data)
|
||||
"
|
||||
|
||||
[resource]
|
||||
templates = [ ExtResource( 1 ) ]
|
||||
template_override/add_key_button = null
|
||||
template_defaults/add_key_button = null
|
||||
script = SubResource( 1 )
|
@ -0,0 +1,49 @@
|
||||
|
||||
[ Error ]
|
||||
<div class="row mb-4">
|
||||
<div class="col-2"></div>
|
||||
<div class="col-8">
|
||||
<div class="alert alert-danger" role="alert">{{ pr(error_str) }}</div>
|
||||
</div>
|
||||
<div class="col-2"></div>
|
||||
</div>
|
||||
|
||||
[ Success ]
|
||||
<div class="row mb-4">
|
||||
<div class="col-2"></div>
|
||||
<div class="col-8">
|
||||
<div class="alert alert-success" role="alert">Save successful!</div>
|
||||
</div>
|
||||
<div class="col-2"></div>
|
||||
</div>
|
||||
|
||||
[ Settings ]
|
||||
<div class="row mb-4">
|
||||
<div class="col-2"></div>
|
||||
<div class="col-8"> <h2>User Settings</h2></div>
|
||||
<div class="col-2"></div>
|
||||
</div>
|
||||
{{ pr(error_str) }}
|
||||
<div class="row mb-4">
|
||||
<div class="col-2"></div>
|
||||
|
||||
<div class="col-8">
|
||||
<form method="POST">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password_input" class="form_label">New Password</label>
|
||||
<input type="password" name="password" placeholder="*******" class="form-control" id="password_input">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="password_check_input" class="form_label">New Password again</label>
|
||||
<input type="password" name="password_check" placeholder="*******" class="form-control" id="password_check_input">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-outline-primary mt-3">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-2"></div>
|
||||
</div>
|
@ -0,0 +1,13 @@
|
||||
[remap]
|
||||
|
||||
importer="html_template_data"
|
||||
type="HTMLTemplateData"
|
||||
path="res://.import/SettingsPageTP.phtpl-edc6f5910c86fd5d50b7b412fc14029e.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://templates/SettingsPageTP.phtpl"
|
||||
dest_files=[ "res://.import/SettingsPageTP.phtpl-edc6f5910c86fd5d50b7b412fc14029e.res" ]
|
||||
|
||||
[params]
|
||||
|
Loading…
Reference in New Issue
Block a user