Skip to content

Comments

Implemented alert statements and removed scrollbar #10

Merged
deb-cod merged 5 commits intotalview:masterfrom
kollucharan:alert
Feb 13, 2025
Merged

Implemented alert statements and removed scrollbar #10
deb-cod merged 5 commits intotalview:masterfrom
kollucharan:alert

Conversation

@kollucharan
Copy link

@kollucharan kollucharan commented Feb 11, 2025

PR Type

Enhancement


Description

  • Enhanced internet speed test UI with improved feedback messages.

  • Added detailed instructions for improving internet connection speed.

  • Updated logic for classifying and displaying network metrics.

  • Improved styling and layout for better user experience.


Changes walkthrough 📝

Relevant files
Enhancement
standalone.php
Enhanced speed test functionality and UI improvements       

docker/standalone.php

  • Added detailed instructions for improving internet speed.
  • Enhanced UI feedback for speed test results.
  • Improved classification logic for network metrics.
  • Updated styles for better user experience.
  • +862/-713
    index.html
    Improved speed test logic and UI feedback                               

    index.html

  • Added instructions for improving internet speed.
  • Enhanced feedback messages for speed test results.
  • Updated styles for better visual feedback.
  • Improved logic for handling test states and results.
  • +148/-4 

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @qodo-code-review
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Typo Bug

    Variable name typo 'mesage' instead of 'message' in multiple places in ToShowStatus() function could cause undefined variable errors

      message = " Your Upload Speed is less than recommended threshold";
      flag2 = true;
    }
    
    if (uiData?.pingStatus > 50 && uiData?.jitterStatus > 30) {
      if (!flag2)
        mesage =
          "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
      else {
        message += ", and we detected high jitter and ping. ";
      }
    } else if (uiData?.jitterStatus > 30) {
      if (!flag2)
        mesage =
          "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
    Performance

    Multiple redundant string concatenations and DOM manipulations in ToShowStatus() function could be optimized by building message string first and updating DOM once

      I("dlText").textContent = "";
      I("ulText").textContent = "";
      I("pingText").textContent = "";
      I("jitText").textContent = "";
    }
    
    function ToShowStatus() {
      // console.log("Function Called");
    
      I("message").classList.remove("Loader");
    
      message = "";
    
      if (uiData?.dlStatus < 1 && uiData?.ulStatus < 1) {
        message =
          "Upload and download speeds are below the recommended threshold";
        flag2 = true;
      } else if (uiData?.dlStatus < 1) {
        message = "Your Download Speed is less than recommended threshold";
        flag2 = true;
      } else if (uiData?.ulStatus < 1) {
        message = " Your Upload Speed is less than recommended threshold";
        flag2 = true;
      }
    
      if (uiData?.pingStatus > 50 && uiData?.jitterStatus > 30) {
        if (!flag2)
          mesage =
            "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
        else {
          message += ", and we detected high jitter and ping. ";
        }
      } else if (uiData?.jitterStatus > 30) {
        if (!flag2)
          mesage =
            "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
        else {
          message += ", and we detected high jitter. ";
        }
      } else if (uiData?.pingStatus > 50) {
        if (!flag2)
          mesage =
            "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
        else {
          message += ", and we detected high Ping. ";
        }
      }
    
      if (
        !message &&
        ((uiData?.ulStatus >= 1 && uiData?.ulStatus < 5) ||
          (uiData?.dlStatus >= 1 && uiData?.dlStatus < 5))
      ) {
        message =
          "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit: <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
      }
    
      if (
        uiData?.dlStatus >= 5 &&
        uiData?.ulStatus >= 5 &&
        uiData?.pingStatus <= 50 &&
        uiData?.jitterStatus <= 30
      ) {
        message =
          "Your network speed meets the requirements for the session. You’re all set.";
        flag = true;
      }
    
      if (!flag) {
        if (flag2) {
          message +=
            " Please check your connection settings and try again. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a> ";
        }
        document.querySelector("#instructions").innerHTML = instructionsare;
      }
    Error Handling

    Missing error handling for network request failures and edge cases in speed test logic

      }
    }
    
    //UI CODE
    var uiData = null;
    
    function startStop() {
      flag = false;
      flag2 = false;
    
      I("instructions").innerHTML = "";
    
      if (prevTestState == 4) {
        clearmessage();
      }
    
      if (s.getState() == 3) {
        //speedtest is running, abort
        s.abort();
        data = null;
        // prevTestState = null;
        I("startStopBtn").className = "";
        I("message").innerHTML = "";
        I("message").classList.remove("Loader");
        initUI();
      } else {
        //test is not running, begin
        I("message").innerHTML = "Test in progress...";
        I("message").classList.add("Loader");
        I("startStopBtn").className = "running";
        I("shareArea").style.display = "none";
        s.onupdate = function (data) {
          uiData = data;
        };
        s.onend = function (aborted) {
          I("startStopBtn").className = "";
          updateUI(true);
          if (!aborted) {
            //if testId is present, show sharing panel, otherwise do nothing
            // I("startStopBtn").textContent = "Try Again";
            I("startStopBtn").className = "new-class";
            try {
              var testId = uiData.testId;
              if (testId != null) {
                var shareURL =
                  window.location.href.substring(
                    0,
                    window.location.href.lastIndexOf("/")
                  ) +
                  "/results/?id=" +
                  testId;
                console.log("ShareURL: ", shareURL);
                // I("resultsImg").src = shareURL;
                I("resultsURL").value = shareURL;
                I("testId").innerHTML = testId;
                I("shareArea").style.display = "";
              }
            } catch (e) {}
          }
        };
        s.start();
      }
    }

    @qodo-code-review
    Copy link

    qodo-code-review bot commented Feb 11, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix undefined variable reference
    Suggestion Impact:Fixed the typo by renaming 'mesage' to 'message' in three different conditions in the code

    code diff:

    -            mesage =
    +            message =
                   "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
               else {
                 message += ", and we detected high jitter and ping. ";
               }
             } else if (uiData?.jitterStatus > 30) {
               if (!flag2)
    -            mesage =
    +            message =
                   "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
               else {
                 message += ", and we detected high jitter. ";
               }
             } else if (uiData?.pingStatus > 50) {
               if (!flag2)
    -            mesage =
    +            message =

    Fix the typo in variable name 'mesage' which will cause undefined variable
    reference in multiple conditions. This could lead to the message not being
    displayed properly.

    index.html [321-323]

     if (!flag2)
    -  mesage =
    +  message =
         "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
    • Apply this suggestion
    Suggestion importance[1-10]: 10

    __

    Why: The typo 'mesage' instead of 'message' is a critical bug that would cause undefined variable errors and break the functionality of displaying important network status messages to users. This same typo appears in multiple places in the code.

    High
    Fix undefined variable reference
    Suggestion Impact:Fixed the typo by renaming 'mesage' to 'message' in three different conditions in the code

    code diff:

    -            mesage =
    +            message =
                   "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
               else {
                 message += ", and we detected high jitter and ping. ";
               }
             } else if (uiData?.jitterStatus > 30) {
               if (!flag2)
    -            mesage =
    +            message =
                   "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
               else {
                 message += ", and we detected high jitter. ";
               }
             } else if (uiData?.pingStatus > 50) {
               if (!flag2)
    -            mesage =
    +            message =

    Fix the undefined variable 'ul_element' in the updateUlColor() function's
    default case to use 'ul_text_element' instead, preventing potential runtime
    errors.

    docker/standalone.php [121-122]

     default:
    -  ul_element.style.color = "#111827";
    +  ul_text_element.style.color = "#111827";
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    __

    Why: Using undefined variable 'ul_element' instead of 'ul_text_element' would cause a runtime error when the default case is hit, breaking the upload speed color indicator functionality.

    High
    Fix variable name typo
    Suggestion Impact:Fixed the typo by renaming 'mesage' to 'message' in multiple places in the code

    code diff:

    -            mesage =
    +            message =
                   "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
               else {
                 message += ", and we detected high jitter and ping. ";
               }
             } else if (uiData?.jitterStatus > 30) {
               if (!flag2)
    -            mesage =
    +            message =
                   "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
               else {
                 message += ", and we detected high jitter. ";
               }
             } else if (uiData?.pingStatus > 50) {
               if (!flag2)
    -            mesage =
    +            message =

    Fix the typo in the variable name 'mesage' to 'message' in the ToShowStatus()
    function to ensure proper message display when ping and jitter thresholds are
    exceeded.

    docker/standalone.php [327-329]

     if (!flag2)
    -  mesage =
    +  message =
         "It is recommended to meet threshold speed for a seamless experience. While you can still start with the session, you might encounter errors due to low bandwidth. For help, visit : <a href= https://talview.freshdesk.com/support/solutions/articles/11000129970-steps-to-perform-a-network-test target='_blank'>Talview Support</a>";
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    __

    Why: The typo in variable name 'mesage' would cause the message to not display properly, potentially breaking the user feedback functionality for network performance issues.

    Medium

    @kollucharan kollucharan changed the title Alert Implemented alert statements and removed scrollbar Feb 11, 2025
    <li> Close apps that you don’t need, as they can slow down your connection.</li>
    <li> Make sure no one else is using the internet while you’re testing. Things like watching/ video streaming will slow down the connection.</li>
    </ul>`;

    Copy link

    Choose a reason for hiding this comment

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

    format it properly

    index.html Outdated
    var status = uiData.testState;
    // I("ip").textContent = uiData.clientIp;

    //console.log(uiData);
    Copy link

    Choose a reason for hiding this comment

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

    remove the console logs

    index.html Outdated
    </div>

    <div id="message"></div>
    <div id="instructions"></div>
    Copy link

    @deb-cod deb-cod Feb 11, 2025

    Choose a reason for hiding this comment

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

    refactor the occurances of message and instructions try for slow-speed-error-message and slow-speed-error-instruction respectively.

    Copy link
    Author

    @kollucharan kollucharan Feb 11, 2025

    Choose a reason for hiding this comment

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

    i have refactored the instructions to slow-speed-error-instruction ,i will rename the message to statusMessage

    @kollucharan kollucharan requested a review from deb-cod February 11, 2025 11:01
    @deb-cod
    Copy link

    deb-cod commented Feb 13, 2025

    @kollucharan , kindly get the update form @sushmitatalview regarding the scroll bar whether we need scroll bar or not

    @deb-cod
    Copy link

    deb-cod commented Feb 13, 2025

    @kollucharan , build is failing, kindly look into that

    Copy link

    @deb-cod deb-cod left a comment

    Choose a reason for hiding this comment

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

    LGTM

    @deb-cod deb-cod merged commit 231d6bd into talview:master Feb 13, 2025
    1 check failed
    @kollucharan
    Copy link
    Author

    @sushmitatalview , as confirmed from you keeping the UI as shown to you

    @kollucharan kollucharan deleted the alert branch February 13, 2025 08:49
    @sushmitatalview
    Copy link

    @sushmitatalview , as confirmed from you keeping the UI as shown to you

    Sure , you can remove the scroll bar as discussed. @kollucharan

    @sushmitatalview
    Copy link

    Tested the UI updates, looks good.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants