Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (ZMSKVR-225): improving traffic light and adding to workstation #935

Merged
merged 4 commits into from
Mar 18, 2025

Conversation

matthilo96
Copy link
Contributor

@matthilo96 matthilo96 commented Mar 13, 2025

Pull Request Checklist (Feature Branch to next):

  • Ich habe die neuesten Änderungen aus dem next Branch in meinen Feature-Branch gemergt.
  • Das Code-Review wurde abgeschlossen.
  • Fachliche Tests wurden durchgeführt und sind abgeschlossen.

Summary by CodeRabbit

  • New Features

    • Enhanced the workstation page with integrated client view updates.
    • Introduced an interactive control for calling the next customer.
    • Added a dynamic footer that displays real-time waiting metrics with visual indicators.
    • Improved traffic light status display based on the number of waiting customers.
  • Refactor

    • Streamlined waiting information by removing outdated timing and workstation details for a cleaner, more intuitive interface.
    • Updated HTML structure and styles for better readability and maintainability.

Copy link
Contributor

coderabbitai bot commented Mar 13, 2025

Walkthrough

This pull request enhances the workstation page by adding conditional logic to load the client next view in several JavaScript methods. In the backend, the readResponse() method now creates a current date variable and includes additional workstation data in its response. The Twig templates have been updated: the footer template has had waiting time details removed; the next template now replaces a link with a button and adds a metrics section; and the info template consolidates traffic light indicators for waiting customers.

Changes

Files Change Summary
zmsadmin/js/page/workstation/index.js Added conditional checks in methods (e.g., onQueueProcess, onReserveProcess, onChangeProcess, onSaveProcess, loadReloadPartials) to call loadClientNext() when on the workstation page.
zmsadmin/src/Zmsadmin/WorkstationProcess.php Enhanced readResponse() by introducing $selectedDate (using DateTime), passing it to Helper\WorkstationInfo::getInfoBoxData, and returning both workstationInfo and $selectedDate in the response.
zmsadmin/templates/block/process/footer.twig Removed waiting time estimate and tooltip code.
zmsadmin/templates/block/process/next.twig Replaced an <a> tag with a <button> and added a footer section with dynamic metrics and traffic light indicators.
zmsadmin/templates/block/queue/info.twig Restructured the traffic light display using a new waiting_customers variable.

Sequence Diagram(s)

sequenceDiagram
  participant User as User
  participant JS as Workstation JS View
  participant PHP as WorkstationProcess
  participant Twig as Template Renderer

  User->>JS: Interact with workstation page
  JS->>JS: Perform conditional check (if page == "workstation")
  JS->>PHP: Request to load client next data
  PHP->>PHP: Process readResponse() (set selectedDate & workstationInfo)
  PHP->>Twig: Return updated data
  Twig->>User: Render UI with new button, metrics, and traffic light indicators
Loading

Poem

I'm a bouncy bunny with a coding flair,
Hopping through changes with agile care.
Conditions check and data flows anew,
With buttons and lights to guide each view.
In the code garden, I joyfully play—
Celebrating updates in my own rabbit way!
🐰💻


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Free

📥 Commits

Reviewing files that changed from the base of the PR and between 05a0283 and 1ca7586.

📒 Files selected for processing (1)
  • zmsadmin/js/page/workstation/index.js (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • zmsadmin/js/page/workstation/index.js

Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@matthilo96 matthilo96 changed the title improving traffic light and adding to workstation feat (ZMSKVR-225): improving traffic light and adding to workstation Mar 13, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (8)
zmsadmin/js/page/workstation/index.js (2)

74-74: Remove commented-out console.log statement.

There's a commented-out console.log statement that should be removed. According to coding guidelines, console.log should be replaced with proper logging.

-        //console.log('Component: Workstation', this, options);

399-400: Consider adding workstation check for consistency.

Similar to other methods, you might want to add a check for the workstation page here in the onNextProcess method for consistency.

 if ('counter' == this.page)
     this.loadQueueInfo();
+if ('workstation' == this.page)
+    this.loadClientNext();
 this.loadQueueTable();
zmsadmin/templates/block/queue/info.twig (1)

153-193: Consider moving styles to external CSS file.

While the inline styles work correctly, consider moving them to an external CSS file for better maintainability and adherence to separation of concerns.

This would involve:

  1. Creating or updating a CSS file in your styles directory
  2. Moving these style definitions there
  3. Removing the inline <style> tag from this template
zmsadmin/templates/block/process/next.twig (5)

34-49: Consider enhancing accessibility of the traffic light indicators

The traffic light indicators rely solely on color to convey information, which can be problematic for users with color vision deficiencies. Consider adding text labels or icons alongside the colors to make the status more accessible.

<li class="traffic-light {% if waiting_customers >= 0 and waiting_customers <= 10 %}green
        {% elseif waiting_customers >= 11 and waiting_customers <= 20 %}yellow
        {% elseif waiting_customers >= 21 and waiting_customers <= 40 %}orange
        {% elseif waiting_customers >= 41 %}red
        {% endif %}">                        
    <div class="cell middle">
-   <h4 class="wartende">{% trans %}Wartende{% endtrans %}:</h4>
+   <h4 class="wartende">
+       <span class="status-indicator" aria-hidden="true">
+           {% if waiting_customers >= 0 and waiting_customers <= 10 %}●{% elseif waiting_customers >= 11 and waiting_customers <= 20 %}●{% elseif waiting_customers >= 21 and waiting_customers <= 40 %}●{% elseif waiting_customers >= 41 %}●{% endif %}
+       </span>
+       {% trans %}Wartende{% endtrans %}:
+       <span class="sr-only">
+           {% if waiting_customers >= 0 and waiting_customers <= 10 %}{% trans %}Niedrige Auslastung{% endtrans %}
+           {% elseif waiting_customers >= 11 and waiting_customers <= 20 %}{% trans %}Mittlere Auslastung{% endtrans %}
+           {% elseif waiting_customers >= 21 and waiting_customers <= 40 %}{% trans %}Hohe Auslastung{% endtrans %}
+           {% elseif waiting_customers >= 41 %}{% trans %}Sehr hohe Auslastung{% endtrans %}
+           {% endif %}
+       </span>
+   </h4>
    </div>
    <div class="cell right">
        <span class="waiting-count">{{ workstationInfo.waitingClientsEffective }}</span>
    </div>
</li>

38-42: Consider making traffic light thresholds configurable

The hardcoded thresholds for traffic light colors (0-10, 11-20, 21-40, 41+) may need to be adjusted based on the specific context or workload patterns of different installations. Consider making these thresholds configurable through application settings.


87-140: Move inline styles to external stylesheet

While the inline styles work, moving them to an external stylesheet would improve maintainability and follow separation of concerns principles. Also, some of the styles use fixed pixel values or percentage-based positioning which may not be responsive across different screen sizes.

Consider:

  1. Moving these styles to an external CSS file
  2. Using more responsive layout techniques (flexbox/grid)
  3. Using relative units (em, rem) instead of pixels where appropriate
  4. Adding media queries for different screen sizes

For example:

/* In your external stylesheet */
.footer-separator {
  margin-top: 1rem;
  border-top: 1px solid #ddd;
  padding-top: 1rem;
}

.traffic-light {
  display: flex;
  width: 100%;
}

/* Rest of the styles... */

119-121: Improve positioning for waiting count

The fixed padding (padding-left: 58%) for the waiting count may cause layout issues on different screen sizes. Consider using flexbox properties like justify-content for more flexible positioning.

.waiting-count {
    font-size: 16px;
    font-weight: bold;                
    display: flex;
-   padding-left: 58%;
-   padding-top: 14px;
+   padding: 0.875rem 0;
}

.cell.right {
    display: flex;
    align-items: center;
+   justify-content: flex-end;
+   padding-right: 1rem;
}

124-138: Consider using CSS variables for traffic light colors

Using CSS variables for the traffic light colors would make them easier to adjust and maintain consistency.

<style>
+   :root {
+       --color-green: rgba(0, 255, 0, 0.5);
+       --color-yellow: rgba(255, 255, 0, 0.5);
+       --color-orange: rgba(255, 127, 0, 0.5);
+       --color-red: rgba(255, 0, 0, 0.5);
+   }

    /* ... other styles ... */
    
    .green {
-       background-color: rgba(0, 255, 0, 0.5);  /* Green */
+       background-color: var(--color-green);
    }

    .yellow {
-       background-color: rgba(255, 255, 0, 0.5);  /* Yellow */
+       background-color: var(--color-yellow);
    }

    .orange {
-       background-color: rgba(255, 127, 0, 0.5);  /* Orange */
+       background-color: var(--color-orange);
    }

    .red {
-       background-color: rgba(255, 0, 0, 0.5);  /* Red */
+       background-color: var(--color-red);
    }
</style>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00f9dcb and 0182b46.

📒 Files selected for processing (5)
  • zmsadmin/js/page/workstation/index.js (6 hunks)
  • zmsadmin/src/Zmsadmin/WorkstationProcess.php (3 hunks)
  • zmsadmin/templates/block/process/footer.twig (1 hunks)
  • zmsadmin/templates/block/process/next.twig (1 hunks)
  • zmsadmin/templates/block/queue/info.twig (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.{js,jsx,ts,tsx}`: Flag any usage of console.log() as i...

**/*.{js,jsx,ts,tsx}: Flag any usage of console.log() as it should be replaced with proper logging:

  1. For development: Use proper debug tools or logging libraries
  2. For production: Remove console.log() statements or use structured logging
  3. For errors: Use error tracking services (e.g., Sentry)
  4. For debugging: Consider using debug libraries that can be enabled/disabled

Example replacement:

// Instead of:
console.log('User data:', userData);

// Use:
logger.debug('Processing user data', { userData });
// or for development only:
if (process.env.NODE_ENV === 'development') {
  debug('User data:', userData);
}
  • zmsadmin/js/page/workstation/index.js
`**/*.php`: Flag any usage of error_log() as it should be re...

**/*.php: Flag any usage of error_log() as it should be replaced with proper logging mechanisms:

  1. For error handling: Use a proper logging framework with error levels (PSR-3 LoggerInterface)
  2. For debugging: Use a dedicated debug logger or remove debug statements
  3. For CLI output: Use a CLI output handler or symfony/console
  4. For application events: Use structured logging with proper log levels

Example replacement:

// Instead of:
error_log("Import failed - " . $e->getMessage());

// Use:
$logger->error("Import failed", ['error' => $e->getMessage()]);
  • zmsadmin/src/Zmsadmin/WorkstationProcess.php
🪛 GitHub Actions: Combined Workflow
zmsadmin/src/Zmsadmin/WorkstationProcess.php

[error] 39-39: Whitespace found at end of line. PHPCBF can fix the marked sniff violations automatically.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (15)
zmsadmin/src/Zmsadmin/WorkstationProcess.php (3)

10-10: Added DateTime import looks good.

The addition of the DateTime import is appropriate for the new functionality being added.


29-29: Appropriate creation of current date variable.

The creation of the $selectedDate variable using DateTime properly formats the current date in the 'Y-m-d' format needed for subsequent operations.


44-46: Good addition of workstation data to render context.

The addition of workstationInfo and selectedDate to the template context appropriately enhances the data available for the templates to use.

zmsadmin/templates/block/process/footer.twig (1)

1-3: Clean simplification of footer template.

The simplification of the footer template is good, removing unnecessary waiting time details which have been moved elsewhere, leaving only the time element.

zmsadmin/js/page/workstation/index.js (6)

206-207: Good addition of client next view loading.

The conditional code to load the client next view when on the workstation page is a good addition, ensuring consistent UI updates after queue processing.


239-240: Good addition of client next view loading.

The conditional code to load the client next view when on the workstation page is a good addition, ensuring consistent UI updates after reserving a process.


265-266: Good addition of client next view loading.

The conditional code to load the client next view when on the workstation page is a good addition, ensuring consistent UI updates after changing a process.


293-294: Good addition of client next view loading.

The conditional code to load the client next view when on the workstation page is a good addition, ensuring consistent UI updates after saving a process.


353-354: Good addition of client next view loading.

The conditional code to load the client next view when on the workstation page is a good addition, ensuring consistent UI updates after deleting a process.


539-540: Good addition of client next view loading.

The conditional code to load the client next view when on the workstation page is a good addition, ensuring consistent UI updates during partial reloads.

zmsadmin/templates/block/queue/info.twig (1)

138-151: Good implementation of traffic light indicators.

The traffic light implementation effectively visualizes the number of waiting customers through color-coded indicators, making it easier for staff to quickly assess the current load.

zmsadmin/templates/block/process/next.twig (4)

25-26: Button implementation looks good!

The button element is more semantically correct for this action than an anchor tag, improving accessibility and following best practices for interactive elements that trigger actions rather than navigate to new pages.


31-32: Simple but effective separator!

The footer separator provides a clear visual distinction between sections. The styling is applied inline but is minimal and appropriate for this purpose.


71-83: Good handling of different time formats

The conditional rendering of waiting time estimates is well-implemented, with appropriate formatting for times over 2 hours and a clear indication when the waiting time is unknown.


50-66: Great addition of waiting time metrics

The addition of average waiting times for both appointment and spontaneous customers provides valuable information at a glance. The layout is clean and the information is presented clearly.

Comment on lines 38 to 39
$workstationInfo = Helper\WorkstationInfo::getInfoBoxData($workstation, $selectedDate);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix whitespace at end of line.

There's trailing whitespace at the end of line 39 which should be removed to comply with coding standards.

-$workstationInfo = Helper\WorkstationInfo::getInfoBoxData($workstation, $selectedDate);
-        
+$workstationInfo = Helper\WorkstationInfo::getInfoBoxData($workstation, $selectedDate);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$workstationInfo = Helper\WorkstationInfo::getInfoBoxData($workstation, $selectedDate);
$workstationInfo = Helper\WorkstationInfo::getInfoBoxData($workstation, $selectedDate);
🧰 Tools
🪛 GitHub Actions: Combined Workflow

[error] 39-39: Whitespace found at end of line. PHPCBF can fix the marked sniff violations automatically.

Deleted Whitespace
Deleted whitespace at End of line 38
@matthilo96 matthilo96 merged commit f4b0984 into next Mar 18, 2025
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants