From c0ac7147f0af04483cd142a11601fe82d9ced04e Mon Sep 17 00:00:00 2001 From: Jonathan Niles Date: Thu, 15 Dec 2016 11:49:50 +0100 Subject: [PATCH] perf(settings): use translate directive This commit modifies the tree and settings page to use the `translate` directive instead of the translate filter. This result in an average decrease of `$watchers` by 50%. The original page average was 648 `$watchers` with the tree fully expanded, but falls to 351 `$watchers` by using the translate directive. This commit determines the validity of #1074 and closes #1074. --- client/src/index.html | 2 +- client/src/js/components/bhLoadingButton.js | 4 +- client/src/partials/settings/settings.html | 37 ++++++++++--------- client/src/partials/settings/settings.js | 10 ++--- .../partials/templates/navigation.tmpl.html | 14 +++---- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/client/src/index.html b/client/src/index.html index 83c826de6c..68167ee1c4 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -68,7 +68,7 @@

{{ AppCtrl.project.name }}<
  • - {{ "SETTINGS.TITLE" | translate }} + SETTINGS.TITLE
  • diff --git a/client/src/js/components/bhLoadingButton.js b/client/src/js/components/bhLoadingButton.js index 52f3efe328..79f0728308 100644 --- a/client/src/js/components/bhLoadingButton.js +++ b/client/src/js/components/bhLoadingButton.js @@ -8,8 +8,8 @@ angular.module('bhima.components') transclude: true, template : '', controller : LoadingButtonController }); diff --git a/client/src/partials/settings/settings.html b/client/src/partials/settings/settings.html index 70128cb72b..228effb3cd 100644 --- a/client/src/partials/settings/settings.html +++ b/client/src/partials/settings/settings.html @@ -1,8 +1,8 @@
      -
    1. {{ "HOME.BHIMA" | translate }}
    2. -
    3. {{ "SETTINGS.TITLE" | translate }}
    4. +
    5. HOME.BHIMA
    6. +
    7. SETTINGS.TITLE
    @@ -12,21 +12,21 @@
    - +
    - +
    @@ -34,46 +34,47 @@ class="btn btn-default" ng-click="SettingsCtrl.back()" data-back-button> - {{ "FORM.BUTTONS.BACK" | translate }} + + FORM.BUTTONS.BACK - {{ "SETTINGS.BUG_LINK" | translate }} + SETTINGS.BUG_LINK
    +
    -
    - {{ "SYSTEM.INFORMATION" | translate }} -
    +
    SYSTEM.INFORMATION
    -
    {{ "SYSTEM.PLATFORM" | translate }}
    +
    SYSTEM.PLATFORM
    {{ SettingsCtrl.system.platform }}
    -
    {{ "SYSTEM.CPUS" | translate }}
    +
    SYSTEM.CPUS
    {{ SettingsCtrl.system.numCPUs }}
    -
    {{ "SYSTEM.MACHINE_UPTIME" | translate }}
    +
    SYSTEM.MACHINE_UPTIME
    {{ SettingsCtrl.system.machineUptime | amDurationFormat }}
    -
    {{ "SYSTEM.PROCESS_UPTIME" | translate }}
    +
    SYSTEM.PROCESS_UPTIME
    {{ SettingsCtrl.system.processUptime | amDurationFormat }}
    -
    {{ "SYSTEM.MEMORY_USAGE" | translate }}
    +
    SYSTEM.MEMORY_USAGE
    {{ SettingsCtrl.system.memoryUsage | number }}%
    -
    {{ "SYSTEM.VERSION" | translate }}
    +
    SYSTEM.VERSION
    {{ SettingsCtrl.system.version }}
    diff --git a/client/src/partials/settings/settings.js b/client/src/partials/settings/settings.js index c72df7f992..7ab64d61e8 100644 --- a/client/src/partials/settings/settings.js +++ b/client/src/partials/settings/settings.js @@ -17,7 +17,7 @@ SettingsController.$inject = [ function SettingsController(Languages, Session, Constants, $translate, Notify, $window, System) { var vm = this; - vm.back = function () { $window.history.back(); }; + vm.back = function back() { $window.history.back(); }; // load settings from services vm.settings = { language : Languages.key }; @@ -28,10 +28,10 @@ function SettingsController(Languages, Session, Constants, $translate, Notify, $ /** bind the language service for use in the view */ Languages.read() - .then(function (languages) { - vm.languages = languages; - }) - .catch(Notify.handleError); + .then(function (languages) { + vm.languages = languages; + }) + .catch(Notify.handleError); // formatting or bug report var emailAddress = Constants.settings.CONTACT_EMAIL; diff --git a/client/src/partials/templates/navigation.tmpl.html b/client/src/partials/templates/navigation.tmpl.html index d766a2de25..af27a5260c 100644 --- a/client/src/partials/templates/navigation.tmpl.html +++ b/client/src/partials/templates/navigation.tmpl.html @@ -1,7 +1,7 @@
      @@ -16,7 +16,7 @@ 'fa-folder-open' : unit.open && unit.children.length > 0, 'fa-folder' : !unit.open && unit.children.length > 0}"> - {{ unit.key | translate }} + {{unit.key}}