Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated for v4. Improved content and formatting

You can add constants to Mnoemnoe-angular that come from Mnoemnoe, allowing access to important backend information on the frontend. (Currently Mnoe

Info

Note:  This is applicable to mno-enterprise v4.0 and

Mnoe

mnoe-angular v2.0 or above. For previous versions, the process is similar but the files are slightly different.

As most of the settings are now nested under ADMIN_PANEL_CONFIG or DASHBOARD_CONFIG, you shouldn't need to add new constants to add simple settings. Have a look at feature flags instead.


Warning

Never use this to transmit sensible credentials to the frontend. This is easily accessible from the frontend by any visitor (even unauthenticated guests!)



Table of Contents
stylenone



1 - Adding a New Constant

1.1 - Mnoe-angular

In Mnoe-angular, add your new setting to the following file. You can set sensible defaults here in the event that the configuration has not been loaded/fetched from MnoHub yet

This is needed for backward compatibility, in case the constant is not present in the mno-enterprise backend.

Code Block
languagejs
titlesrc/app/index.default-config.coffee
linenumberstrue
# For backward compatibility with the mnoe backend

# Define null/default values for all the constants so that if the backend hasn't been upgraded

# to define this constants you don't get errors like:

#   Uncaught Error: [$injector:unpr] Unknown provider: INTERCOM_IDProvider <- INTERCOM_ID <- AnalyticsSvc

angular.module('mnoEnterprise.defaultConfiguration', [])
   .constant('IMPAC_CONFIG', {})
   .constant('I18N_CONFIG', {})
   .constant('PRICING_CONFIG', {enabled: true})

  .constant('PAYMENTDASHBOARD_CONFIG', {disabled: false})
   .constant('ORGANIZATION_MANAGEMENT', {enabled: true})

  .constant('USER_MANAGEMENT', {enabled: true})

  .constant('DOCK_CONFIG', {enabled: true})

  .constant('DEVELOPER_SECTION_CONFIG', {enabled: false})

  .constant('ONBOARDING_WIZARD_ADMIN_PANEL_CONFIG', {enabled: false})
   .constant('REVIEWS_CONFIG', {enabled: false})

  .constant('QUESTIONS_CONFIG', {enabled: false})

  .constant('MARKETPLACE_CONFIG', {enabled: true, comparison: {enabled: false}})

  .constant('AUDIT_LOG', {enabled: false})

  .constant('GOOGLE_TAG_CONTAINER_ID', null)
   .constant('APP_NAME', null)

  .constant('INTERCOM_ID', null)

  .constant('URL_CONFIG', {})




1.2 - mno-

Mnoe

enterprise

In Mnoe mnoe-enterprise, add your constant to the following the api/app/views/mno_enterprise/config/show.js.coffee file.

Note: This is served to the frontend via the MnoEnterprise::ConfigController#show method. Instance variables can be added to the controller and used in this view.

Code Block
languagejs
titleapi/app/views/mno_enterprise/config/show.js.coffee
linenumberstrue
# Configuration module

#

angular.module('mnoEnterprise.configuration', [])

  .constant('IMPAC_CONFIG', <%= Settings.impac.to_json.html_safe %>)

  .constant('I18N_CONFIG', {
     enabled: <%= Settings.system.i18n.enabled %>,
     available_locales: <%= @available_locales.to_json.html_safe %>,
     preferred_locale: <%= Settings.system.i18n.preferred_locale.to_json.html_safe %>
   })
   .constant('ADMIN_PANEL_CONFIG', <%= Hash(Settings.admin_panel).to_json.html_safe %>)
   .constant('DASHBOARD_CONFIG', <%= Hash(Settings.dashboard).to_json.html_safe %>)

  .constant('GOOGLE_TAG_CONTAINER_ID', <%= MnoEnterprise.google_tag_container.to_json.html_safe %>)

  .constant('INTERCOM_ID', <%= MnoEnterprise.intercom_app_id.to_json.html_safe %>)
   .constant('APP_NAME', <%= MnoEnterprise.app_name.to_json.html_safe %>)

  .constant('URL_CONFIG', <%= Hash(Settings.url_config).to_json.html_safe %>)