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-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 |
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 | ||
---|---|---|
|
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
# 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-
Mnoeenterprise
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
# 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 %>) |