1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-08-08 14:55:17 +00:00

working on user profile edit

This commit is contained in:
webplusai 2024-10-08 07:55:23 +00:00
parent b61789b3f4
commit f02c8562f0
2 changed files with 118 additions and 66 deletions

View File

@ -8,16 +8,15 @@ GET /admin/users/:user_id
\*/ \*/
(function() { (function() {
/*jslint node: true, browser: true */ /*jslint node: true, browser: true */
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
exports.method = "GET"; exports.method = "GET";
exports.path = /^\/admin\/users\/([^\/]+)\/?$/; exports.path = /^\/admin\/users\/([^\/]+)\/?$/;
exports.handler = function(request,response,state) {
exports.handler = function(request,response,state) {
var user_id = $tw.utils.decodeURIComponentSafe(state.params[0]); var user_id = $tw.utils.decodeURIComponentSafe(state.params[0]);
var userData = state.server.sqlTiddlerDatabase.getUser(user_id); var userData = state.server.sqlTiddlerDatabase.getUser(user_id);
@ -57,12 +56,13 @@ exports.handler = function(request,response,state) {
"user": JSON.stringify(user), "user": JSON.stringify(user),
"user-roles": JSON.stringify(userRoles), "user-roles": JSON.stringify(userRoles),
"all-roles": JSON.stringify(allRoles), "all-roles": JSON.stringify(allRoles),
"is-current-user-profile": state.authenticatedUser && state.authenticatedUser.user_id === user_id ? "yes" : "no",
"username": state.authenticatedUser ? state.authenticatedUser.username : "Guest", "username": state.authenticatedUser ? state.authenticatedUser.username : "Guest",
"user-is-admin": state.authenticatedUser && state.authenticatedUser.isAdmin ? "yes" : "no" "user-is-admin": state.authenticatedUser && state.authenticatedUser.isAdmin ? "yes" : "no"
} }
}); });
response.write(html); response.write(html);
response.end(); response.end();
}; };
}()); }());

View File

@ -39,6 +39,32 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/manage-user
</$list> </$list>
</ul> </ul>
</div> </div>
</div>
<$reveal type="match" state="is-current-user-profile" text="yes">
<div class="user-profile-management">
<h2>Manage Your Account</h2>
<form class="user-profile-form">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" id="username" name="username" value={{{ [<user>jsonget[username]] }}} />
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" value={{{ [<user>jsonget[email]] }}} />
</div>
<div class="form-group">
<label for="new-password">New Password:</label>
<input type="password" id="new-password" name="new-password" />
</div>
<div class="form-group">
<label for="confirm-password">Confirm New Password:</label>
<input type="password" id="confirm-password" name="confirm-password" />
</div>
<button type="submit" class="update-profile-btn">Update Profile</button>
</form>
</div>
</$reveal>
</div> </div>
<style> <style>
@ -68,9 +94,10 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/manage-user
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-size: 3rem; font-size: 3rem;
* { }
.user-profile-avatar * {
color: #3498db; color: #3498db;
}
} }
.user-profile-name { .user-profile-name {
@ -127,22 +154,47 @@ title: $:/plugins/tiddlywiki/multiwikiserver/templates/manage-user
font-size: 0.9rem; font-size: 0.9rem;
} }
.user-profile-roles-management { .user-profile-management {
margin-top: 2rem; margin-top: 2rem;
padding: 2rem;
border-top: 1px solid #e0e0e0;
} }
.user-profile-roles-management select { .user-profile-management h2 {
margin-right: 1rem; font-size: 1.2rem;
color: #3498db;
margin-bottom: 1rem;
} }
.user-actions { .user-profile-form .form-group {
margin-top: 0.5rem; margin-bottom: 1rem;
} }
.user-actions button {
background: none; .user-profile-form label {
display: block;
margin-bottom: 0.5rem;
font-weight: bold;
color: #555;
}
.user-profile-form input {
width: 100%;
padding: 0.5rem;
border: 1px solid #ccc;
border-radius: 4px;
}
.update-profile-btn {
background: #3498db;
color: #fff;
border: none; border: none;
padding: 0.5rem 1rem;
border-radius: 4px;
cursor: pointer; cursor: pointer;
padding: 0.25rem 0.5rem; font-size: 1rem;
margin-right: 0.5rem; }
.update-profile-btn:hover {
background: #2980b9;
} }
</style> </style>