? NPM Resource Changed ? ? Pending

User tests: Successful: Unsuccessful:

avatar bembelimen
bembelimen
18 Feb 2019

Pull Request for Issue #23675 .

Summary of Changes

Moves the database query calls from the system dashboard to AJAX to improve performance.

Testing Instructions

See: #23675

Expected result

Approx 25-30 queries

Actual result

More than 400 queries

avatar bembelimen bembelimen - open - 18 Feb 2019
avatar bembelimen bembelimen - change - 18 Feb 2019
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 18 Feb 2019
Category Administration com_cpanel Language & Strings JavaScript Repository
avatar dgrammatiko
dgrammatiko - comment - 18 Feb 2019

@bembelimen sorry but the javascript is really bad, zero checks. Why is Joomla the perfect software that will run on the perfect browsers?

Please consider copy pasting this:

/**
 * @copyright  Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
((document, Joomla) => {
  'use strict';

  const init = () => {
    // Cleanup
    document.removeEventListener('DOMContentLoaded', init);

    // Get the elements
     const elements = [].slice.call(document.querySelectorAll('.system-counter'));

    if (elements.count) {
      elements.forEach((element) => {
        const type = element.getAttribute('data-type');

        if (type && Joomla && Joomla.request && typeof Joomla.request === 'function') {
          Joomla.request({
            url: 'index.php?option=com_cpanel&task=system.loadSystemInfo&format=json',
            method: 'POST',
            data: `type=${type}`,
            onSuccess: (resp) => {
              let responnse;
              try {
                response = JSON.parse(resp);
              } catch (error) {
                throw new Error('Failed to parse JSON')
              }

              if (response.error || !response.success) {
                element.classList.remove('fa-spin');
                element.classList.remove('fa-spinner');
                element.classList.add('text-danger');
                element.classList.add('fa-remove');
              } else if (response.data) {
                const elem = document.createElement('span');

                elem.classList.add('pull-right');
                elem.classList.add('badge');
                elem.classList.add('badge-pill');
                elem.classList.add('badge-warning');
                elem.innerHTML = response.data;

                element.parentNode.replaceChild(elem, element);
              } else {
                element.classList.remove('fa-spin');
                element.classList.remove('fa-spinner');
                element.classList.add('fa-check');
                element.classList.add('text-success');
              }
            },
            onError: () => {
              element.classList.remove('fa-spin');
              element.classList.remove('fa-spinner');
              element.classList.add('text-danger');
              element.classList.add('fa-remove');
            }
          });
        }
      });
    }
  }

  document.addEventListener('DOMContentLoaded', init);
})(document, Joomla);
avatar bembelimen
bembelimen - comment - 18 Feb 2019

Sure, thanks for the improvement, would you like to do a PR against my repo, so your name is listed?

avatar dgrammatiko
dgrammatiko - comment - 18 Feb 2019

nah...

avatar bembelimen bembelimen - change - 18 Feb 2019
Labels Added: ? ?
avatar chmst
chmst - comment - 19 Feb 2019

A huge improvement! Thank you @bembelimen and @dgrammatiko.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar chmst
chmst - comment - 19 Feb 2019

I have tested this item successfully on 1ca1e7a


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar chmst chmst - test_item - 19 Feb 2019 - Tested successfully
avatar infograf768
infograf768 - comment - 19 Feb 2019

Some issues here;

  1. There was a reason why I used &#x200E; in<?php echo '&#x200E;' . Text::_($item->getBadge()); ?> in my former PR for this page.
    It was to cope with RTL when displaying Joomla versions as in the future we may have versions containing latin letters.
  2. I also have issues here concerning Extensions Update. My test here is installing and older French Language pack. It displays a correct badge before patch, not after patch.

Both issues can be seen below:

BEFORE PATCH:
screen shot 2019-02-19 at 11 51 54

AFTER PATCH:

screen shot 2019-02-19 at 11 57 29

avatar bembelimen bembelimen - change - 19 Feb 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - change - 19 Feb 2019
Category Administration com_cpanel Language & Strings JavaScript Repository Administration com_cpanel Language & Strings JavaScript Repository NPM Change
avatar bembelimen
bembelimen - comment - 19 Feb 2019
avatar infograf768 infograf768 - change - 19 Feb 2019
Labels Added: NPM Resource Changed
Removed: ?
avatar infograf768
infograf768 - comment - 20 Feb 2019

I have tested this item successfully on b54eaf1


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar infograf768 infograf768 - test_item - 20 Feb 2019 - Tested successfully
avatar infograf768
infograf768 - comment - 21 Feb 2019

I have tested this item successfully on 7529f15


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar infograf768 infograf768 - test_item - 21 Feb 2019 - Tested successfully
avatar chmst
chmst - comment - 21 Feb 2019

I have tested this item successfully on 7529f15


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar chmst
chmst - comment - 21 Feb 2019

I have tested this item successfully on 7529f15


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar chmst chmst - test_item - 21 Feb 2019 - Tested successfully
avatar Quy Quy - change - 21 Feb 2019
Status Pending Ready to Commit
avatar Quy
Quy - comment - 21 Feb 2019

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar Quy
Quy - comment - 21 Feb 2019

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/23936.

avatar wilsonge wilsonge - change - 22 Feb 2019
Labels Added: ?
avatar wilsonge wilsonge - change - 22 Feb 2019
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2019-02-22 12:00:28
Closed_By wilsonge
avatar wilsonge wilsonge - close - 22 Feb 2019
avatar wilsonge wilsonge - merge - 22 Feb 2019
avatar wilsonge
wilsonge - comment - 22 Feb 2019

Nice improvement - thanks!

Add a Comment

Login with GitHub to post a comment