diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-07-22 18:45:59 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-07-22 19:35:33 +0200 |
commit | 3b9d27649a31e5af3fb137ff5b3378e7b8f7b9ae (patch) | |
tree | 0f43f30d824b8b805e4a72b66a0ee1bee7397803 /templates | |
parent | 1e4613aa1113b373a8d841c28e222599237a33c5 (diff) | |
download | lens-3b9d27649a31e5af3fb137ff5b3378e7b8f7b9ae.tar.gz lens-3b9d27649a31e5af3fb137ff5b3378e7b8f7b9ae.tar.bz2 lens-3b9d27649a31e5af3fb137ff5b3378e7b8f7b9ae.zip |
feat: Add user management
As many things it is on crude state. The settings.go has become a big
mess, but I have achieve MVP, so from now one things shall improve as
I'll spent more time on refactoring.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/base.qtpl | 12 | ||||
-rw-r--r-- | templates/settings.qtpl | 5 | ||||
-rw-r--r-- | templates/user.qtpl | 54 |
3 files changed, 70 insertions, 1 deletions
diff --git a/templates/base.qtpl b/templates/base.qtpl index 0c05782..5a7c3b7 100644 --- a/templates/base.qtpl +++ b/templates/base.qtpl @@ -1,11 +1,23 @@ This is a base page template. All the other template pages implement this interface. +{% import "strconv" %} + {% interface Page { Title() Content() Script() } + +%} + +{% code + func FromUInttoString(u *uint) string { + if u != nil { + return strconv.FormatUint(uint64(*u), 10) + } + return "" + } %} diff --git a/templates/settings.qtpl b/templates/settings.qtpl index 6eee1ab..4207439 100644 --- a/templates/settings.qtpl +++ b/templates/settings.qtpl @@ -52,10 +52,13 @@ type SettingsPage struct { <div class="column"> {%s user.Path %} </div> - <div class="column has-text-right"><a href="#">Edit</a> / <a href="#" class="is-danger">Delete</a></div> + <div class="column has-text-right"><a href="/users?userId={%s FromUInttoString(&user.ID) %}">Edit</a> <a href="/users/delete?userId={%s FromUInttoString(&user.ID) %}" class="is-danger">Delete</a></div> </div> </div> {% endfor %} + <div class="field"> + <a href="/users/" class="button">Create</a> + </div> </div> </div> {% endfunc %} diff --git a/templates/user.qtpl b/templates/user.qtpl new file mode 100644 index 0000000..ba2f071 --- /dev/null +++ b/templates/user.qtpl @@ -0,0 +1,54 @@ + +{% code +type UserPage struct { + ID *uint + Username string + Path string + IsAdmin bool +} + +%} + +{% func (p *UserPage) Title() %}Login{% endfunc %} + +{% func (p *UserPage) Content() %} +<h1>Initial Setup</h1> +<form action="/users/" method="post"> + {% if p.ID != nil %} + <input type="hidden" name="userId" value="{%s FromUInttoString(p.ID) %}" /> + {% endif %} + <div class="field"> + <label class="label">Username</label> + <div class="control"> + <input class="input" name="username" type="text" value="{%s p.Username %}"> + </div> + </div> + + {% if p.ID == nil %} + <div class="field"> + <label class="label">Password</label> + <div class="control"> + <input class="input" name="password" type="password"> + </div> + </div> + {% endif %} + <div class="field"> + <label class="label">Root folder</label> + <div class="control"> + <input class="input" name="path" type="text" value="{%s p.Path %}"> + </div> + </div> + <div class="field"> + <label class="label">Is Admin?</label> + <div class="control"> + <input type="checkbox" name="isAdmin" type="password" {% if p.IsAdmin %}checked{% endif %}> + </div> + </div> + <div class="field"> + <input class="button is-pulled-right" value="Save" type="submit"> + </div> +</form> +{% endfunc %} + +{% func (p *UserPage) Script() %} +{% endfunc %} |