Commit ec730ea9 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Implementa módulo ExternalConfig y lo integra

Se usa el nuevo módulo para pedir configuración dinámica del lado del
servidor, empleando localStorage para almacenarla y controlar su
caducidad. Se incluye extensión para que otros módulos se comuniquen con
él.

Se integra con la vista de StacBrowser para obtener la URL a incrustar.
parent 651f2abb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -250,6 +250,7 @@ define([], function() {
		'themes': baseUri + 'themes',
		'thematicType': baseUri + 'thematictypes',
		'getToken': '/oauth/token',
		'getExternalConfig': '/config',
		'logout': baseUri + 'oauth/token/revoke',
		'unit': baseUri + 'units',
		'unitType': baseUri + 'unittypes',
+25 −3
Original line number Diff line number Diff line
@@ -3,14 +3,16 @@ define([
	, 'app/designs/embeddedContent/Layout'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'redmic/modules/base/_ExternalConfig'
], function(
	Controller
	, Layout
	, declare
	, lang
	, _ExternalConfig
) {

	return declare([Layout, Controller], {
	return declare([Layout, Controller, _ExternalConfig], {
		//	summary:
		//		Vista de STAC Browser incrustado.
		//	description:
@@ -19,14 +21,34 @@ define([
		constructor: function (args) {

			this.config = {
				embeddedContentUrl: 'https://stac-browser.pre-devops.grafcan.es'
				embeddedContentUrl: null,
				embeddedContentUrlPropertyName: 'stacBrowserViewEmbeddedContentUrl'
			};

			lang.mixin(this, this.config, args);
		},

		_initialize: function() {
		_setOwnCallbacksForEvents: function() {

			this._onEvt('GOT_EXTERNAL_CONFIG', lang.hitch(this._onGotExternalConfig))
		},

		postCreate: function() {

			this.inherited(arguments);

			this._emitEvt('GET_EXTERNAL_CONFIG', {
				propertyName: this.embeddedContentUrlPropertyName
			})
		},

		_onGotExternalConfig: function(evt) {

			var configValue = evt[this.embeddedContentUrlPropertyName];

			this._publish(this.getChannel('SET_PROPS'), {
				embeddedContentUrl: configValue
			})
		}
	});
});
+4 −2
Original line number Diff line number Diff line
@@ -11,17 +11,19 @@ define([
	, has
	, RedmicLocalStorage
) {

	var Credentials = declare(Evented, {
		//	summary:
		//		Almacén de las credenciales del usuario.
		//	description:
		//		TODO: ahora mismo, este componente hace más que trabajar con credenciales, remodelado pendiente!
		//		Engloba los datos de acceso del usuario actual y permite interactuar con ellos.
		//		Listo para importar y usar, con instancia persistente (sólo se crea una vez).

		//	validProps: Array
		//		Propiedades permitidas para el control del usuario.
		validProps: ['accessToken', 'userId', 'userName', 'userEmail', 'userRole', 'allowedModules', 'cookiesAccepted',
			'selectIds'],
			'selectIds', 'externalConfig', 'externalConfigTimestamp'],


		constructor: function(args) {
+14 −8
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ define([
	, 'redmic/modules/base/_Module'
	, 'redmic/modules/base/_Store'
	, 'redmic/modules/base/Loading'
	, 'redmic/modules/components/ExternalConfig'
	, 'redmic/modules/store/RestManagerImpl'
	, 'templates/LoadingCustom'
], function(
@@ -42,6 +43,7 @@ define([
	, _Module
	, _Store
	, Loading
	, ExternalConfig
	, RestManagerImpl
	, LoadingCustomTemplate
) {
@@ -87,6 +89,8 @@ define([
		//		Instancia del módulo de control de rutas de acceso.
		//	_credentials: Object
		//		Instancia del módulo de control de permisos y accesos de usuario.
		//	_externalConfig: Object
		//		Instancia del módulo de obtención de configuración externa, del lado del servidor.
		//	_moduleStore: Object
		//		Instancia del módulo de control de los módulos vista a los que el usuario puede acceder.
		//	_loading: Object
@@ -118,18 +122,18 @@ define([
			};

			lang.mixin(this, this.config, args);
		},

		_initialize: function() {

			var parentChannel = this.getChannel();

			this._router = new Router({
				parentChannel: this.getChannel(),
				parentChannel: parentChannel,
				globalContext: getGlobalContext()
			});

			new CookieLoader();
		},

		_initialize: function() {

			var parentChannel = this.getChannel();

			new RestManagerImpl({
				parentChannel: parentChannel
@@ -155,6 +159,10 @@ define([
				parentChannel: parentChannel
			});

			this._externalConfig = new ExternalConfig({
				parentChannel: parentChannel
			});

			this._moduleStore = new ModuleStore({
				parentChannel: parentChannel
			});
@@ -202,8 +210,6 @@ define([
		postCreate: function() {

			this._emitEvt('GET_CREDENTIALS');

			this.inherited(arguments);
		},

		_subCredentialsRemoved: function() {
+2 −3
Original line number Diff line number Diff line
@@ -55,12 +55,11 @@ define([
			};

			lang.mixin(this, this.config, args);

			this._setRouterListeners();
		},

		_initialize: function() {

			this._setRouterListeners();
		},

		_defineSubscriptions: function() {
Loading