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

Rastrea páginas no cargadas desde App

Permite cargar cookies inmediatamente e importa el componente necesario
para ello en vistas ajenas al componente principal App. Hasta ahora no
se registraban las visitas a estas páginas, pero resulta crucial saber
cuantos accesos hay a la página de error o navegador no soportado, por
ejemplo.
parent efa90453
Loading
Loading
Loading
Loading
+17 −13
Original line number Diff line number Diff line
define([
	'alertify/alertify.min'
	, 'src/redmicConfig'
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/i18n!app/nls/translation"
	, "src/util/Credentials"
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/i18n!app/nls/translation'
	, 'src/util/Credentials'
], function(
	alertify
	, redmicConfig
@@ -13,6 +13,7 @@ define([
	, i18n
	, Credentials
) {

	return declare(null, {
		//	summary:
		//		Widget encargado de la carga y aviso de cookies.
@@ -23,15 +24,17 @@ define([
		//		Retraso para mostrar el aviso de cookies.
		//	hideTimeout: Integer
		//		Retraso para ocultar el aviso de cookies.
		//	omitWarning: Boolean
		//		Procede a cargar las cookies sin preguntar, para casos donde es indispensable.
		//	warningText: String
		//		Contenido a mostrar en el aviso de cookies.


		constructor: function(args) {

			this.config = {
				showTimeout: 500,
				hideTimeout: 14500,
				omitWarning: false,
				warningText: '<span class="cookies fa fa-exclamation-circle"></span> ' + i18n.cookiesWarning +
					'<a href="/terms-and-conditions" d-state-url="true">' +
					i18n.here + '</a>.'
@@ -48,13 +51,13 @@ define([
			//	tags:
			//		private

			if (!Credentials.has("cookiesAccepted")) {
				this._onCookiesAcceptedHandler = Credentials.on("changed:cookiesAccepted", lang.hitch(this,
			if (this.omitWarning || Credentials.has('cookiesAccepted')) {
				this._loadCookies();
			} else {
				this._onCookiesAcceptedHandler = Credentials.on('changed:cookiesAccepted', lang.hitch(this,
					this._loadCookies));

				this._showWarning();
			} else {
				this._loadCookies();
			}
		},

@@ -67,7 +70,7 @@ define([
			this._showTimeoutHandler = setTimeout(lang.hitch(this, function() {
				// Si pasa el tiempo de la alerta o le hacemos click, aceptamos
				// TODO pasar a notification
				this._cookiesNotificationHandler = alertify.notify(this.warningText, "message", this.hideTimeout / 1000,
				this._cookiesNotificationHandler = alertify.notify(this.warningText, 'message', this.hideTimeout / 1000,
					lang.hitch(this, this._acceptCookies));
			}), this.showTimeout);
		},
@@ -78,7 +81,7 @@ define([
			//	tags:
			//		private

			Credentials.set("cookiesAccepted", "true");
			Credentials.set('cookiesAccepted', 'true');
		},

		_loadCookies: function() {
@@ -91,7 +94,8 @@ define([
			this._onCookiesAcceptedHandler && this._onCookiesAcceptedHandler.remove();
			this._cookiesNotificationHandler && this._cookiesNotificationHandler.dismiss();

			if (window.location.hostname.indexOf('redmic.es') !== -1) {
			var isProduction = (/true/i).test(redmicConfig.getEnvVariableValue('envProduction'));
			if (isProduction) {
				this._googleAnalytics();
			}
		},
+14 −7
Original line number Diff line number Diff line
define([
	"dijit/form/Button"
	'dijit/form/Button'
	, 'dojo/_base/declare'
	, 'src/app/component/CookieLoader'

	, "dojo/domReady!"
	, 'dojo/domReady!'
], function(
	Button
	, declare
	, CookieLoader
) {

	return declare(null, {

		constructor: function() {

			new Button({
				'class': "primary",
				label: "Go back",
				'class': 'primary',
				label: 'Go back',
				onClick: function() {

					window.location = "/";
					location.href = '/';
				}
			}).placeAt("goBack");
			}).placeAt('goBack');

			new CookieLoader({
				omitWarning: true
			});
		}
	});
});
+8 −2
Original line number Diff line number Diff line
@@ -3,12 +3,14 @@ define([
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/request'
	, 'src/app/component/CookieLoader'
	, 'src/util/RedmicLocalStorage'
], function(
	redmicConfig
	, declare
	, lang
	, request
	, CookieLoader
	, RedmicLocalStorage
) {

@@ -22,6 +24,10 @@ define([
				token: this.token
			};

			new CookieLoader({
				omitWarning: true
			});

			this._activateAccount(data);
		},

@@ -59,12 +65,12 @@ define([

		_goBack: function() {

			window.location = '/';
			location.href = '/';
		},

		_goError: function() {

			window.location = '/404';
			location.href = '/404';
		}
	});
});
+6 −6
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ define([
	, "dojo/_base/lang"
	, "dojo/text!./templates/NoSupportBrowser.html"
	, "dojo/i18n!./nls/translation"
	, 'src/app/component/CookieLoader'
], function(
	_TemplatedMixin
	, _WidgetBase
@@ -14,6 +15,7 @@ define([
	, lang
	, template
	, i18n
	, CookieLoader
){
	return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
		//	summary:
@@ -34,12 +36,10 @@ define([
			};

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

		postCreate: function() {

			this.inherited(arguments);
			new CookieLoader({
				omitWarning: true
			});
		}

	});
});