dependencies dependencies cluster_ProviderConfigurationModule cluster_ProviderConfigurationModule_declarations cluster_ProviderConfigurationModule_ProviderConfigurationComponent_providers cluster_ProviderConfigurationModule_imports cluster_ProviderConfigurationModule_exports ProviderConfigurationComponent ProviderConfigurationComponent ProviderConfigurationModule ProviderConfigurationModule ProviderConfigurationComponent->ProviderConfigurationModule ProviderConfigurationComponent ProviderConfigurationComponent ProviderConfigurationModule->ProviderConfigurationComponent ProviderConfigurationService ProviderConfigurationService ProviderConfigurationService->ProviderConfigurationComponent ProviderDefinitionsService ProviderDefinitionsService ProviderDefinitionsService->ProviderConfigurationComponent CommonModule CommonModule CommonModule->ProviderConfigurationModule CoreModule CoreModule CoreModule->ProviderConfigurationModule DynamicFormsModule DynamicFormsModule DynamicFormsModule->ProviderConfigurationModule

File

core/provider-configuration/provider-configuration.module.ts

Methods

Static config
config(config: DynamicProviderConfig[])
Parameters :
Name Type Optional
config DynamicProviderConfig[] No
Returns : ModuleWithProviders<ProviderConfigurationModule>

Provider configuration

When imported and configured properly this module will add one or more provider configuratin views to your application. Provider configuration views allow you to select a provider from a list of predefined providers and save credentials and other configuration data for that provider. The form where you enter your configiration and credentials is generated based on a JSON schema defined for the selected provider. Configuration can later be updated or deleted. Only one active provider configuration is currently supported, i.e. if you select a different provider from the list your old configuration will be overwritten by the new one. An exampple of a provider configuration view is the SMS provider:

Example provider configuration page

How to use

The ProviderConfigurationModule can be imported directly in your root module (usually called AppModule) or in any other module* within your application by calling its static config method. You can import ProviderConfigurationModule in more than one module as well as pass an array of DynamicProviderConfig objects. Each object will create a separate provider configuration view.

In order for routing and navigation to work properly for your provider configuration views you must import ProviderConfigurationModule by calling its static config method within eagerly loaded modules. Should you use it in lazy loaded modules then you need to import the module directly without calling its config method. In this case you should take care of registering the ProviderConfigurationComponent on the route(s) you need and provide a configuration object with layout and endpoint properties as route data.

You can define where and when your view will appear using the navigation property of DynamicProviderConfig. It will create a navigator node for your view allowing you to define its position via the parent and priority properties. Should your view appear in navigation only conditionally you can provide one or more guards that would check the necessary conditions.

ProviderConfigurationModule.config([
  {
    navigation: {
      label: 'Your provider name',
      path: 'path/to/configuration/view',
      icon: 'envelope-o',
      parent: 'Parent node',
      priority: 1000,
      canActivate: [YourFirstGuard, YourSecondGuard]
    },
    layout: { ... },
    endpoint: { ... }
  }
])

In the canActivate method of your guard you should not rely on the ActivatedRouteSnapshot and RouterStateSnapshot as those will be undefined.

Layout

You can customize all of the labels and messages in the provider configuration view. To do so provide the messages in the layout object of your DynamicProviderConfig. More details on the particular properties can be found in DynamicProviderLayoutConfig.

Endpoints

For every provider configuration view you need to define two endpoints. Your configured definitionsEndpoint endpoint should return an array of ProviderDefinition objects. These will be the available providers to select from. Once a provider has been selected from the list a configuration form will be displayed based on its JSON schema defined in the schema property. The configurationEndpoint should support CRUD operations for your provider configuration types. It should support ProviderProperties objects where the provider property should be used on both sides to identify the provider the configuration should be applied to.

ProviderConfigurationModule.config([
  {
    navigation: { ... },
    layout: { ... },
    endpoint: {
      definitionsEndpoint: {
        baseUrl: 'service/demo/providers',
        listUrl: 'definitions'
      },
      configurationEndpoint: {
        baseUrl: 'service/demo/providers',
        listUrl: 'configuration'
      }
    }
  }
])

results matching ""

    No results matching ""