pub struct View {}Expand description
A utility struct for rendering application data to the console.
Serves as a namespace for various table rendering functions. All methods are static, making it easy to call formatting functions without needing to instantiate the struct.
Implementations§
Source§impl View
impl View
Sourcepub fn tasks(tasks: &[Task]) -> Result<()>
pub fn tasks(tasks: &[Task]) -> Result<()>
Displays a formatted table of tasks with comprehensive metadata.
Renders a detailed table showing task information including identification numbers, names, completion status, comments, and associated tags.
§Arguments
tasks- A slice ofTaskstructs to display in the table
§Returns
Returns Ok(()) on successful table rendering, or an error if
the table cannot be displayed due to terminal or formatting issues.
Sourcepub fn report(
workday: &Workday,
intervals: &[WorkInterval],
filtered_duration: &TimeDelta,
productivity: &f64,
tasks: &[Task],
) -> Result<()>
pub fn report( workday: &Workday, intervals: &[WorkInterval], filtered_duration: &TimeDelta, productivity: &f64, tasks: &[Task], ) -> Result<()>
Displays a formatted daily work report using pre-calculated intervals.
This method displays the core report data in a structured table format, including work intervals, total time, and productivity metrics calculated using the centralized Productivity module.
§Display Components
- Work Intervals: Detailed breakdown of focused work periods
- Total Duration: Sum of all work intervals (may be filtered)
- Productivity Percentage: Calculated using comprehensive Productivity logic
- Associated Tasks: Tasks completed during the workday for context
The productivity value displayed here is calculated using the same centralized logic used throughout the application for consistency.
§Arguments
workday- The workday record containing start/end timesintervals- Pre-calculated and optionally filtered work intervals for displayfiltered_duration- Sum of displayed interval durationsproductivity- Productivity percentage from centralized Productivity calculationtasks- Tasks completed during the workday for context
Sourcepub fn sum(
(daily_durations, total_duration, average_duration): &(HashMap<NaiveDate, (String, String)>, String, String),
) -> Result<()>
pub fn sum( (daily_durations, total_duration, average_duration): &(HashMap<NaiveDate, (String, String)>, String, String), ) -> Result<()>
Displays a monthly summary of working hours with daily breakdowns.
This method renders a comprehensive monthly view that shows daily work patterns, totals, and averages. It provides both detailed daily data and aggregate statistics to help users understand their work patterns over the entire month.
§Summary Structure
The monthly summary includes:
- Daily Breakdown: Each day with date, hours worked, and workday status
- Total Hours: Cumulative time worked across all days in the month
- Average Hours: Mean daily working time for better pattern analysis
- Work Days: Count of days with recorded work activity
§Data Interpretation
- Workday Hours: Actual time recorded for productive work days
- Rest Day Hours: Default hours applied to weekends and holidays
- Missing Days: Days without any recorded activity (shown as 0:00)
§Arguments
summary_data- A tuple containing:HashMap<NaiveDate, (String, String)>: Daily durations and productivity dataString: Total duration for the entire monthString: Average daily duration across all days
§Returns
Returns Ok(()) on successful summary display, or an error if
table formatting or rendering fails.
§Examples
use kasl::libs::view::View;
use std::collections::HashMap;
let daily_map = HashMap::new();
let total_hours = String::new();
let average_hours = String::new();
let summary_data = (daily_map, total_hours, average_hours);
View::sum(&summary_data)?;Sourcepub fn templates(templates: &[TaskTemplate]) -> Result<()>
pub fn templates(templates: &[TaskTemplate]) -> Result<()>
Displays a formatted table of task templates for reusable task creation.
This method renders a comprehensive view of all available task templates, showing their configuration and usage information. Templates provide a convenient way to create commonly used tasks with pre-filled parameters.
§Template Information
The table displays essential template metadata:
- Template Name: Unique identifier for template selection
- Task Name: Default task title that will be used
- Comment: Pre-configured task description or notes
- Completeness: Default completion percentage for new tasks
§Usage Context
Templates are particularly useful for:
- Recurring tasks with standard parameters
- Team workflows with consistent task structures
- Quick task creation with minimal input required
- Standardized task naming and completion patterns
§Arguments
templates- A slice ofTaskTemplatestructs to display
§Returns
Returns Ok(()) on successful table rendering, or an error if
display operations fail.
§Examples
use kasl::libs::view::View;
use kasl::db::templates::TaskTemplate;
let templates: Vec<TaskTemplate> = vec![/* template instances */];
View::templates(&templates)?;Displays a formatted table of tags for task categorization and organization.
This method provides a comprehensive view of all available tags that can be applied to tasks for organization and filtering purposes. The table shows both the functional and visual aspects of each tag.
§Tag Information
The table displays key tag metadata:
- ID: Unique database identifier for programmatic reference
- NAME: Human-readable tag name used for categorization
- COLOR: Optional color coding for visual organization (if supported)
§Organizational Benefits
Tags provide several organizational advantages:
- Categorization: Group related tasks by project, priority, or type
- Filtering: Quickly find tasks based on specific criteria
- Visual Organization: Color coding for rapid visual identification
- Reporting: Generate reports filtered by specific tag categories
§Color Display
Colors are displayed as text values (hex codes, names, etc.) since terminal color support varies. A dash (-) indicates no color assigned.
§Arguments
tags- A slice ofTagstructs to display in the table
§Returns
Returns Ok(()) on successful table rendering, or an error if
display operations fail.
§Examples
use kasl::libs::view::View;
use kasl::db::tags::Tag;
let tags: Vec<Tag> = vec![/* tag instances */];
View::tags(&tags)?;Sourcepub fn jira_inbox(items: &[JiraInboxItem]) -> Result<()>
pub fn jira_inbox(items: &[JiraInboxItem]) -> Result<()>
Displays active Jira inbox items (pinned, score, then priority).
SUMMARY is truncated to fit the terminal width (same approach as View::tasks).