Commit 5c3a8d34 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Merge branch 'dev' into 'master'

Dev

See merge request redmic-project/client/web!35
parents aadd62d1 02f0a48d
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -18,22 +18,21 @@ services:
      mode: replicated
      replicas: 1
      labels:
        traefik.port: '${PORT}'
        traefik.docker.network: traefik-net
        traefik.default.frontend.rule: Host:${PUBLIC_HOSTNAME}
        traefik.es.frontend.rule: Host:es.${PUBLIC_HOSTNAME}
        traefik.es.frontend.redirect.regex: ^(.*):\\/\\/es\\.(.*)$$
        traefik.es.frontend.redirect.replacement: $$1://$$2
        traefik.es.frontend.redirect.permanent: 'true'
        traefik.redirect.frontend.rule: HostRegexp:{subdomain:www|es}.${PUBLIC_HOSTNAME}
        traefik.redirect.frontend.redirect.regex: ^(.*):\\/\\/\\w+\\.(.*)$$
        traefik.redirect.frontend.redirect.replacement: $$1://$$2
        traefik.redirect.frontend.redirect.permanent: 'true'
        traefik.en.frontend.rule: Host:en.${PUBLIC_HOSTNAME}
        traefik.en.frontend.headers.customRequestHeaders: content-language:en
        traefik.backend: web
        traefik.frontend.errors.5xx.status: 500-599
        traefik.frontend.errors.5xx.backend: static-pages-static-pages-static-pages
        traefik.frontend.errors.5xx.query: '/web-5xx/'
        traefik.backend: web
        traefik.port: '${PORT}'
      restart_policy:
        delay: 30s
        window: 2m
        delay: 10s
        window: 1m
      resources:
        limits:
          cpus: '2'
+1 −1
Original line number Diff line number Diff line
{
  "name": "REDMIC",
  "version": "0.14.1",
  "version": "0.15.0",
  "author": "REDMIC",
  "homepage": "https://gitlab.com/redmic-project/client/web/blob/master/README.md",
  "description": "Integrated marine data repository of Canary Islands - Client",
+2 −5
Original line number Diff line number Diff line
@@ -8,12 +8,9 @@ function(
		//	summary:
		//		Gestiona los errores de los request
		//	description:
		//		Permite gestionar los errores de las peticiónes a la API
		//		Permite gestionar los errores de las peticiones a la API

		_errorAvailable: function(res) {

			var error = res.error,
				status = error.response && error.response.status;
		_errorAvailable: function(error, status) {

			if (status === 404) {
				this._goTo404();
+171 −108
Original line number Diff line number Diff line
define([
	"app/designs/base/_Main"
	, "app/designs/chart/Controller"
	, "app/designs/chart/layout/TopContent"
	, "app/redmicConfig"
	'app/designs/base/_Main'
	, 'app/designs/chart/Controller'
	, 'app/designs/chart/layout/TopContent'
	, 'app/redmicConfig'
	, 'd3/d3.min'
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "redmic/modules/base/_Filter"
	, "redmic/modules/base/_Store"
	, "redmic/modules/chart/layer/ChartLayer/WindRoseChartImpl"
	, "redmic/modules/chart/layer/ChartLayer/_ObtainableValue"
	, "redmic/modules/chart/Toolbar/SliderSelectorImpl"
	, "redmic/modules/chart/Toolbar/GridManagementImpl"
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'moment/moment.min'
	, 'redmic/modules/base/_Store'
	, 'redmic/modules/chart/layer/ChartLayer/WindRoseChartImpl'
	, 'redmic/modules/chart/layer/ChartLayer/_ObtainableValue'
	, 'redmic/modules/chart/Toolbar/DateFilterImpl'
	, 'redmic/modules/chart/Toolbar/GridManagementImpl'
	, 'redmic/modules/chart/Toolbar/SliderSelectorImpl'
], function (
	_Main
	, Controller
@@ -20,40 +21,44 @@ define([
	, d3
	, declare
	, lang
	, _Filter
	, moment
	, _Store
	, WindRoseChartImpl
	, _ObtainableValue
	, SliderSelectorImpl
	, DateFilterImpl
	, GridManagementImpl
	, SliderSelectorImpl
){
	return declare([TopContentLayout, Controller, _Main, _Filter, _Store], {
	return declare([TopContentLayout, Controller, _Main, _Store], {
		//	summary:
		//		Gráfica de multi rosa de los vientos con barra de herramientas.
		//		Gráfica de rosa de los vientos multinivel con barra de herramientas.

		constructor: function(args) {

			this.config = {
				ownChannel: "multiPieChartWithToolbar",
				ownChannel: 'multiPieChartWithToolbar',
				events: {
					ADD_LAYER: "addLayer",
					REMOVE_LAYER: "removeLayer"
					ADD_LAYER: 'addLayer',
					REMOVE_LAYER: 'removeLayer'
				},
				actions: {
				},

				target: redmicConfig.services.timeSeriesWindRose,
				_unit: '%',

				_domainSplit: 4,
				_domainSplit: 5,
				_minDomainSplit: 1,
				_maxDomainSplit: 10,

				_directionSplitPow: 2,
				_minDirectionSplitPow: 1,
				_maxDirectionSplitPow: 5,
				_directionSplitMultiplier: 2,
				_minDirectionSplitMultiplier: 1,
				_maxDirectionSplitMultiplier: 9,

				_chartInstances: {},
				_marginForLabels: 30
				_marginForLabels: 30,

				directionDataDefinitionIds: [],
				speedDataDefinitionIds: []
			};

			lang.mixin(this, this.config, args);
@@ -71,29 +76,19 @@ define([
			this._directionSplitSelector = new SliderSelectorImpl({
				parentChannel: this.getChannel(),
				title: this.i18n.directions,
				iconClass: 'fa-arrows-alt',
				sliderConfig: {
					inputProps: {
						minimum: this._minDirectionSplitPow,
						maximum: this._maxDirectionSplitPow,
						labels: this._getDirectionLabels(this._minDirectionSplitPow, this._maxDirectionSplitPow),
						value: this._directionSplitPow
					}
				}
				iconClass: 'fa-compass',
				value: this._directionSplitMultiplier,
				range: [this._minDirectionSplitMultiplier, this._maxDirectionSplitMultiplier],
				labels: this._getDirectionLabels()
			});

			this._domainSplitSelector = new SliderSelectorImpl({
				parentChannel: this.getChannel(),
				title: this.i18n.domainLevels,
				iconClass: 'fa-scissors',
				sliderConfig: {
					inputProps: {
						minimum: this._minDomainSplit,
						maximum: this._maxDomainSplit,
						labels: this._getDomainLabels(this._minDomainSplit, this._maxDomainSplit),
						value: this._domainSplit
					}
				}
				iconClass: 'fa-sort',
				value: this._domainSplit,
				range: [this._minDomainSplit, this._maxDomainSplit],
				labels: this._getDomainLabels()
			});

			this.gridManagementConfig = this._merge([{
@@ -102,19 +97,26 @@ define([
			}, this.gridManagementConfig || {}]);

			this.gridManagement = new GridManagementImpl(this.gridManagementConfig);

			this.dateFilter = new DateFilterImpl({
				parentChannel: this.getChannel()
			});
		},

		_defineMainSubscriptions: function() {

			this.subscriptionsConfig.push({
				channel : this._directionSplitSelector.getChannel("TOOL_ACTUATED"),
				callback: "_subDirectionSplitSelectorToolActuated"
				channel : this._directionSplitSelector.getChannel('TOOL_ACTUATED'),
				callback: '_subDirectionSplitSelectorToolActuated'
			},{
				channel : this._domainSplitSelector.getChannel('TOOL_ACTUATED'),
				callback: '_subDomainSplitSelectorToolActuated'
			},{
				channel : this._domainSplitSelector.getChannel("TOOL_ACTUATED"),
				callback: "_subDomainSplitSelectorToolActuated"
				channel : this.dateFilter.getChannel('TOOL_ACTUATED'),
				callback: '_subDateFilterToolActuated'
			},{
				channel : this.chartsContainer.getChannel("SHOWN"),
				callback: "_subChartsContainerShown"
				channel : this.chartsContainer.getChannel('SHOWN'),
				callback: '_subChartsContainerShown'
			});
		},

@@ -122,10 +124,10 @@ define([

			this.publicationsConfig.push({
				event: 'ADD_LAYER',
				channel: this.chartsContainer.getChannel("ADD_LAYER")
				channel: this.chartsContainer.getChannel('ADD_LAYER')
			},{
				event: 'REMOVE_LAYER',
				channel: this.chartsContainer.getChannel("REMOVE_LAYER")
				channel: this.chartsContainer.getChannel('REMOVE_LAYER')
			});
		},

@@ -133,61 +135,77 @@ define([

			this.inherited(arguments);

			this._publish(this._directionSplitSelector.getChannel("SHOW"), {
			this._publish(this._directionSplitSelector.getChannel('SHOW'), {
				node: this.buttonsContainerChartsTopNode
			});

			this._publish(this._domainSplitSelector.getChannel('SHOW'), {
				node: this.buttonsContainerChartsTopNode
			});

			this._publish(this._domainSplitSelector.getChannel("SHOW"), {
			this._publish(this.gridManagement.getChannel('SHOW'), {
				node: this.buttonsContainerChartsTopNode
			});

			this._publish(this.gridManagement.getChannel("SHOW"), {
			this._publish(this.dateFilter.getChannel('SHOW'), {
				node: this.buttonsContainerChartsTopNode
			});

			this._publish(this.chartsContainer.getChannel("SET_PROPS"), {
			this._publish(this.chartsContainer.getChannel('SET_PROPS'), {
				buttonsContainer: this.buttonsContainerChartsTopNode
			});
		},

		_getDirectionLabels: function(start, end) {
		_getDirectionLabels: function() {

			var labels = [];
			for (var i = start; i <= end; i++) {
				labels.push(Math.pow(2, i));
			for (var i = this._minDirectionSplitMultiplier; i <= this._maxDirectionSplitMultiplier; i++) {
				labels.push(4 * i);
			}

			return labels;
		},

		_getDomainLabels: function(start, end) {
		_getDomainLabels: function() {

			var labels = [];
			for (var i = start; i <= end; i++) {
			for (var i = this._minDomainSplit; i <= this._maxDomainSplit; i++) {
				labels.push(i);
			}

			return labels;
		},

		_onTargetPropSet: function(res) {

		_addToQueryChartsData: function(query) {
			this._clearDateRange();

			this._emitEvt('ADD_TO_QUERY', {
				query: query
			this._updateQuery();
		},

		_requestChartsData: function() {

			this._emitEvt('REQUEST', {
				target: this.target,
				method: 'POST',
				query: this._queryObj
			});
		},

		_clearDateRange: function() {

			this._prepareChartsForNextData();
			this._startDate = null;
			this._endDate = null;
		},

		_prepareChartsForNextData: function() {
		_clearCharts: function() {

			this._publish(this.chartsContainer.getChannel('CLEAR'));

			for (var i in this._chartInstances) {
				var instance = this._chartInstances[i];

				this._emitEvt('REMOVE_LAYER', {
					layerId: instance.getOwnChannel()
				});
				this._publish(instance.getChannel('DESTROY'));
				delete this._chartInstances[i];
			}
		},
@@ -195,64 +213,108 @@ define([
		_dataAvailable: function(res) {

			var data = res.data,
				chartsData = data.data,
				limits = data.limits;
				status = res.status;

			if (status !== 200) {
				return;
			}

			this._chartsData = {
				data: chartsData,
				parameterName: "%"
				data: data.data,
				parameterName: this._unit
			};

			this._limits = limits;
			this._limits = data.limits;

			this._stats = data.stats;

			this._updateCharts();
		},

		_subDirectionSplitSelectorToolActuated: function(req) {
		_subDirectionSplitSelectorToolActuated: function(res) {

			var value = req.value;
			var value = res.value;

			this._directionSplitPow = value;
			this._directionSplitMultiplier = value;

			this._addToQueryChartsData({
				"dateLimits": {
					"startDate":"2012-01-18T20:34:00.000Z",
					"endDate":"2017-08-12T07:33:00.000Z"
			this._updateQuery();
		},
				"terms": {
					"dataDefinition": {
						"speed": 111,
						"direction": 112

		_subDomainSplitSelectorToolActuated: function(res) {

			var value = res.value;

			this._domainSplit = value;

			this._updateQuery();
		},
					"numSectors": Math.pow(2, this._directionSplitPow)
				}
			});

		_subDateFilterToolActuated: function(res) {

			var value = res.value;

			this._startDate = value.startDate;
			this._endDate = value.endDate;

			this._updateQuery();
		},

		_subDomainSplitSelectorToolActuated: function(req) {
		_updateQuery: function() {

			var value = req.value;
			if (!this.speedDataDefinitionIds.length || !this.directionDataDefinitionIds.length) {
				return;
			}

			this._domainSplit = value;
			if (!this._startDate || !this._endDate) {
				var currentDate = moment();
				this._endDate = currentDate.toISOString();
				this._startDate = currentDate.subtract(1, 'days').toISOString();
			}

			this._addToQueryChartsData({
				"dateLimits": {
					"startDate":"2012-01-18T20:34:00.000Z",
					"endDate":"2017-08-12T07:33:00.000Z"
			this._queryObj = {
				dateLimits: {
					startDate: this._startDate,
					endDate: this._endDate
				},
				"terms": {
					"dataDefinition": {
						"speed": 111,
						"direction": 112
				terms: {
					dataDefinition: {
						speed: this.speedDataDefinitionIds,
						direction: this.directionDataDefinitionIds
					},
					"numSplits": this._domainSplit
					timeInterval: this.timeInterval,
					numSectors: 4 * this._directionSplitMultiplier,
					numSplits: this._domainSplit
				}
			};

			if (this._chartsData) {
				this._clearCharts();
			}
			this._updateChartsLegendTitle();
			this._requestChartsData();
		},

		_updateChartsLegendTitle: function() {

			if (!this._startDate || !this._endDate) {
				return;
			}

			var param = this.i18n.speed,
				dateFormat = 'YYYY-MM-DD hh:mm:ss',
				humanizedStartDate = moment(this._startDate).format(dateFormat),
				humanizedEndDate = moment(this._endDate).format(dateFormat),
				dateRange = humanizedStartDate + ' - ' + humanizedEndDate,
				legendTitle = param + ' (' + this.sourceUnit + ') | ' + dateRange;

			this._publish(this.chartsContainer.getChannel('SET_PROPS'), {
				legendTitle: legendTitle
			});
		},

		_subChartsContainerShown: function() {

			this._emitEvt("REFRESH");
			//this._requestChartsData();
		},

		_updateCharts: function() {
@@ -262,17 +324,20 @@ define([
			for (var i = 0; i < this._domainSplit; i++) {
				this._updateChart(i, colorScale(i));
			}

			this._publish(this.chartsContainer.getChannel('SET_PROPS'), {
				summaryData: this._stats
			});
		},

		_getColorScale: function() {

			var colorReferences = ["#0000ff", "#00ffff", "#00ff00", "#ffff00", "#ff0000"],
			var colorReferences = ['#0000ff', '#00ffff', '#00ff00', '#ffff00', '#ff0000'],
				maxDomainLevelIndex = this._domainSplit - 1,
				scaleDomain, scaleRange;

			if (!maxDomainLevelIndex) {
				scaleDomain = [0, maxDomainLevelIndex];

				scaleRange = [colorReferences[0], colorReferences[0]];
			} else {
				scaleDomain = [0, maxDomainLevelIndex / 4, maxDomainLevelIndex / 3, maxDomainLevelIndex / 2,
@@ -307,13 +372,11 @@ define([

		_getLayerLabel: function(i) {

			var param = this.i18n.frequency,
				unit = '<unit>',	// TODO habrá que cogerlo del datadefinition
				limits = this._limits[i],
			var limits = this._limits[i],
				min = limits.min,
				max = limits.max;

			return param + ' (' + min + ' - ' + max + ' ' + unit + ')';
			return '[' + min + ' - ' + max + ')';
		},

		_createChartLayer: function(layerConfig) {
@@ -335,7 +398,7 @@ define([

		_addDataToChart: function(i) {

			this._publish(this._chartInstances[i].getChannel("ADD_DATA"), this._chartsData);
			this._publish(this._chartInstances[i].getChannel('ADD_DATA'), this._chartsData);
		}
	});
});
+1 −3
Original line number Diff line number Diff line
@@ -186,10 +186,8 @@ define([
			return false;
		},

		_errorAvailable: function(res) {
		_errorAvailable: function(error) {

			var error = res.error,
				status = error.response && error.response.status;
		},

		_updateCallback: function(data) {
Loading