app/search/server/service/providerService.js
/**
	 * Starts the service (loads provider settings for admin ui, add lister not setting changes, enable current provider
	 */
Starts the service (loads provider settings for admin ui, add lister not setting changes, enable current provider
Starts the service ( loads provider settings for admin ui add lister not setting changes enable current provider
start() {
		SearchLogger.debug('Load data for all providers');
		const { providers } = this;
		settingsRegistry.addGroup('Search', function() {
			const self = this;
			self.add('Search.Provider', 'defaultProvider', {
				type: 'select',
				values: Object.keys(providers).map((key) => ({ key, i18nLabel: providers[key].i18nLabel })),
				public: true,
				i18nLabel: 'Search_Provider',
			});
			Object.keys(providers)
				.filter((key) => providers[key].settings && providers[key].settings.length > 0)
				.forEach(function(key) {
					self.section(providers[key].i18nLabel, function() {
						providers[key].settings.forEach((setting) => {
							const _options = {
								type: setting.type,
								...setting.options,
							};
							_options.enableQuery = _options.enableQuery || [];
							_options.enableQuery.push({
								_id: 'Search.Provider',
								value: key,
							});
							this.add(setting.id, setting.defaultValue, _options);
						});
					});
				});
		});
		const configProvider = _.debounce(Meteor.bindEnvironment(() => {
			const providerId = settings.get('Search.Provider');
			if (providerId) {
				this.use(providerId);
			}
		}), 1000);
		settings.watchByRegex(/^Search\./, configProvider);
	}
start ( ) { SearchLogger . debug ( 'Load data for all providers' ) ; const { providers } = this ; settingsRegistry . addGroup ( 'Search' , function ( ) { const self = this ; self . add ( 'Search.Provider' , 'defaultProvider' , { type : 'select' , values : Object . keys ( providers ) . map ( ( key ) => ( { key , i18nLabel : providers [ key ] . i18nLabel } ) ) , public : true , i18nLabel : 'Search_Provider' , } ) ; Object . keys ( providers ) . filter ( ( key ) => providers [ key ] . settings && providers [ key ] . settings . length > 0 ) . forEach ( function ( key ) { self . section ( providers [ key ] . i18nLabel , function ( ) { providers [ key ] . settings . forEach ( ( setting ) => { const _options = { type : setting . type , ... setting . options , } ; _options . enableQuery = _options . enableQuery || [ ] ; _options . enableQuery . push ( { _id : 'Search.Provider' , value : key , } ) ; this . add ( setting . id , setting . defaultValue , _options ) ; } ) ; } ) ; } ) ; } ) ; const configProvider = _ . debounce ( Meteor . bindEnvironment ( ( ) => { const providerId = settings . get ( 'Search.Provider' ) ; if ( providerId ) { this . use ( providerId ) ; } } ) , 1000 ) ; settings . watchByRegex ( / ^Search\. / , configProvider ) ; }
Starts the service (loads provider settings for admin ui, add lister not setting changes, enable current provider
Starts the service ( loads provider settings for admin ui add lister not setting changes enable current provider
// add settings for admininistration // add listener to react on setting changes // TODO do something with success and errors