9_User_Profile_Interface - Anisan/osysHome-Users GitHub Wiki
Relevant source files
The following files were used as context for generating this wiki page:
The User Profile Interface provides a comprehensive screen for viewing and editing user account information within the osysHome-Users system. This interface allows administrators to manage user profiles including username, role assignments, home page settings, timezone preferences, and API key generation. It also supports avatar image uploading for users.
For information about the list view of all users, see User List Interface. For password management functionality, see Password Management Interface.
Sources: templates/user.html:1-159, forms/UserForm.py:1-14
The User Profile Interface is organized into a two-column layout for optimal usability:
flowchart TD
subgraph "User Profile Interface"
A["Profile Header"] --> B["Avatar Section"]
A --> C["Profile Form"]
subgraph "Avatar Section"
B --> B1["Profile Image"]
B --> B2["Upload Button"]
B --> B3["User Info Display"]
end
subgraph "Profile Form"
C --> C1["Username Field"]
C --> C2["Role Selector"]
C --> C3["Home Page Field"]
C --> C4["Timezone Field"]
C --> C5["API Key Field with Generator"]
C --> C6["Submit/Cancel Buttons"]
end
B2 --> D["Upload Modal"]
subgraph "Upload Modal"
D --> D1["File Selection"]
D --> D2["Upload/Cancel Buttons"]
end
end
Sources: templates/user.html:30-92, templates/user.html:94-116
The left column contains:
- Profile Picture Display: Shows the user's avatar image in a circular frame
- Upload Button: Allows changing the avatar image via a modal dialog
- Basic User Info: Displays the username, role, and last login timestamp
When no image is specified or if the image URL is invalid, the system displays a default avatar from the static assets directory.
Sources: templates/user.html:31-48
The right column contains the editable form with the following fields:
| Field Name | Description | Type |
|---|---|---|
| Username | User's login identifier | Text field |
| Role | User's permission level | Dropdown (Admin/Editor/User/Guest) |
| Home Page | Default landing page | Text field |
| Timezone | User's local timezone | Text field |
| API Key | Authentication token for API access | Text field with generator |
Sources: templates/user.html:50-90, forms/UserForm.py:6-13
The avatar upload feature enables users to personalize their profiles with custom images:
sequenceDiagram
participant User
participant Interface as "User Profile Interface"
participant UploadModal as "Upload Modal"
participant AJAX as "AJAX Handler"
participant Server as "Server Backend"
User->>Interface: Click upload button
Interface->>UploadModal: Open modal dialog
User->>UploadModal: Select image file
User->>UploadModal: Click "Upload"
UploadModal->>AJAX: Submit form data
AJAX->>Server: POST request to "Users?op=upload_image"
Server-->>AJAX: Return image URL
AJAX->>Interface: Update avatar display
AJAX->>UploadModal: Close modal
The upload system uses AJAX to submit the image without a full page reload, providing a seamless user experience.
Sources: templates/user.html:94-140
The interface includes a secure API key generator that creates cryptographically strong random keys for API authentication:
flowchart TD
A["Generate Key Button"] -->|"Click"| B["generateSecureKey() Function"]
B -->|"Uses"| C["Web Crypto API"]
C -->|"Creates"| D["Random Values"]
D -->|"Formats as"| E["Hyphenated String"]
E -->|"Updates"| F["API Key Field"]
The generated keys follow a format of randomly selected alphanumeric characters with hyphens inserted every four characters for readability.
Sources: templates/user.html:141-157
The user profile form is implemented using Flask-WTF, which provides form validation and CSRF protection:
classDiagram
class UserForm {
+StringField username
+StringField image
+SelectField role
+StringField home_page
+StringField apikey
+StringField timezone
+SubmitField submit
}
class Flask_Template {
+render_form()
+handle_submission()
}
UserForm -- Flask_Template: used by
The UserForm class defines all the fields needed for user profile management, with appropriate validators to ensure data integrity.
Sources: forms/UserForm.py:6-13
The user profile template extends a common admin layout and incorporates several key components:
- Breadcrumb Navigation: Shows the hierarchical position within the application
- Form Error Display: Shows validation errors when applicable
- Bootstrap-based Layout: Utilizes responsive grid system for layout control
- Modal Component: For avatar upload functionality
- JavaScript Handlers: For API key generation and image upload
The template uses Jinja2 templating to render the form fields dynamically and handle form submission.
Sources: templates/user.html:1-6, templates/user.html:7-15, templates/user.html:52-89
The interface uses custom CSS to style the avatar container and the upload button:
.avatar_box {
position: relative;
width: 150px;
height: 150px;
}
.upload-btn {
position: absolute;
bottom: 0px;
right: 0px;
border-radius: 50%;
}
This CSS positions the upload button overlaid on the bottom-right corner of the avatar image, creating an intuitive UI for image management.
Sources: templates/user.html:16-29
When a user profile is updated, the system follows this data flow:
sequenceDiagram
participant User
participant Form as "User Profile Form"
participant Backend as "Plugin Controller"
participant Core as "Application Core"
participant DB as "Data Storage"
User->>Form: Edit profile fields
User->>Form: Submit form
Form->>Backend: POST form data
Backend->>Form: Validate input
alt Invalid input
Backend-->>Form: Return with errors
Form-->>User: Display validation errors
else Valid input
Backend->>Core: setProperty() calls
Core->>DB: Update user properties
DB-->>Core: Confirmation
Core-->>Backend: Success status
Backend-->>User: Redirect to User List
end
This process ensures data integrity while providing appropriate feedback to users.
Sources: templates/user.html:53-88
The User Profile Interface integrates with the broader user management system as follows:
flowchart TD
A["User List Interface"] -->|"Edit User"| B["User Profile Interface"]
B -->|"Submit"| C["Plugin Controller"]
B -->|"Cancel"| A
C -->|"Update"| D["User Data Storage"]
C -->|"Redirect"| A
E["Password Management Interface"] -.->|"Related to"| B
subgraph "Forms"
F["UserForm.py"]
end
subgraph "Templates"
G["user.html"]
end
B -->|"Uses"| F
B -->|"Renders"| G
This integration ensures a cohesive user management experience within the larger application framework.