Commit 62261c46 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Limpia código, permite ver charts desde browser

Revisa y limpia gestión de datos de series temporales, en proceso de
unificación con el visor general.

Añade botón de carga de series temporales al listado de estaciones.
parent 3189a962
Loading
Loading
Loading
Loading
+9 −26
Original line number Diff line number Diff line
@@ -33,14 +33,10 @@ define([
		constructor: function(args) {

			this.config = {
				_titleRightButtonsList: [],
				_activeRadius: true,
				noScroll: true,
				propsWidget: {
					omitTitleBar: true,
					resizable: false
				},
				targetReplaceParameter: 'id'
				}
			};

			lang.mixin(this, this.config, args);
@@ -48,16 +44,14 @@ define([

		_setMainConfigurations: function() {

			this._replacePathVariableIdInTarget();

			this.widgetConfigs = this._merge([{
				chart: {
				chartDesign: {
					width: 6,
					height: 6,
					type: [ChartsWithLegendAndToolbarsAndSlider, _ProcessDataDefinitionAndGetTimeSeries],
					props: {
						title: this.i18n.chart,
						target: this.targetChange,
						target: this.target,
						filterConfig: {
							initQuery: {
								size: null
@@ -81,29 +75,18 @@ define([
			}, this.widgetConfigs || {}]);
		},

		_replacePathVariableIdInTarget: function() {
		_buildAndLoadChartData: function(sourceData) {

			var replaceObj = {};
			replaceObj[this.targetReplaceParameter] = this.pathVariableId;
			this._buildChartData(sourceData);

			this.targetChange = lang.replace(this.templateTargetChange, replaceObj);
			this._publish(this._getWidgetInstance('chartDesign').getChannel('SET_PROPS'), {
				chartsData: this.seriesData
			});
		},

		_clearModules: function() {

			var widgetInstance = this._getWidgetInstance('chart');
			this._publish(widgetInstance.getChannel('CLEAR'));
			this._publish(widgetInstance.getChannel('REFRESH'));
		},

		_refreshModules: function() {

			this._replacePathVariableIdInTarget();

			this._publish(this._getWidgetInstance('chart').getChannel('UPDATE_TARGET'), {
				target: this.targetChange,
				refresh: true
			});
			this._publish(this._getWidgetInstance('chartDesign').getChannel('CLEAR'));
		}
	});
});
+2 −14
Original line number Diff line number Diff line
@@ -3,15 +3,11 @@ define([
	, 'app/redmicConfig'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'dojo/aspect'
	, 'dojo/Deferred'
], function(
	ActivityChart
	, redmicConfig
	, declare
	, lang
	, aspect
	, Deferred
) {

	return declare(ActivityChart, {
@@ -21,7 +17,7 @@ define([
		constructor: function(args) {

			this.config = {
				templateTargetChange: redmicConfig.services.timeSeriesTemporalData,
				target: redmicConfig.services.timeSeriesTemporalData,
				activityCategory: ['ft']
			};

@@ -34,15 +30,7 @@ define([

			this._subscribe(this.timeseriesDataChannel, lang.hitch(this, function(data) {

				this._dataList = [];
				this._indexDataList = {};

				this._dataList = this._parseData(data.properties);
				this._generateTimeSeriesData(this._dataList);

				this._publish(this._getWidgetInstance('chart').getChannel('SET_PROPS'), {
					chartsData: this.seriesData
				});
				this._buildAndLoadChartData(data);
			}));
		}
	});
+32 −7
Original line number Diff line number Diff line
@@ -47,7 +47,22 @@ define([
				geographic: {
					props: {
						browserConfig: {
							template: TemplateList
							template: TemplateList,
							rowConfig: {
								buttonsConfig: {
									listButton: [{
										icon: 'fa-bar-chart',
										title: this.i18n.charts,
										btnId: 'showCharts',
										returnItem: true
									},{
										icon: 'fa-map-marker',
										title: this.i18n.map,
										btnId: 'mapCentering',
										returnItem: true
									}]
								}
							}
						}
					}
				}
@@ -60,6 +75,9 @@ define([

			this._subscribe(this.getChildChannel('layerInstance', 'POPUP_LOADED'),
				lang.hitch(this, this._onStationPopupLoaded));

			this._subscribe(this._getWidgetInstance('geographic').getChildChannel('browser', 'BUTTON_EVENT'),
				lang.hitch(this, this._onBrowserShowChartsButtonEvent));
			},

		_onStationPopupLoaded: function(res) {
@@ -69,7 +87,7 @@ define([
			}

			var popupNode = res._contentNode,
				popupData = res._source.feature;
				popupData = res._source.feature.properties;

			if (popupNode && popupData) {
				var showChartsNode = query('.' + this._showChartsButtonClass, popupNode)[0];
@@ -77,10 +95,7 @@ define([
					return;
				}

				showChartsNode.onclick = lang.hitch(this, function(data) {

					this._publish(this.getChannel('TIMESERIES_DATA'), data);
				}, popupData);
				showChartsNode.onclick = lang.hitch(this, this._loadTimeseriesData, popupData);
			}
		},

@@ -90,6 +105,16 @@ define([
				i18n: this.i18n,
				feature: data.feature
			});
		},

		_onBrowserShowChartsButtonEvent: function(evt) {

			this._loadTimeseriesData(evt.item);
		},

		_loadTimeseriesData: function(itemData) {

			this._publish(this.getChannel('TIMESERIES_DATA'), itemData);
		}
	});
});
+6 −5
Original line number Diff line number Diff line
@@ -24,14 +24,15 @@ define([
			};

			lang.mixin(this, this.config);

			aspect.after(this, '_setOwnCallbacksForEvents', lang.hitch(this,
				this._setTimeSeriesSelectionManagementOwnCallbacksForEvents));
		},

		_setTimeSeriesSelectionManagementOwnCallbacksForEvents: function() {
		_buildChartData: function(sourceData) {

			this._dataList = [];
			this._indexDataList = {};

			this._onEvt('HIDE', lang.hitch(this, this._onTimeSeriesSelectionManagementHidden));
			var parsedData = this._parseData(sourceData);
			this._generateTimeSeriesData(parsedData);
		},

		_generateTimeSeriesData: function(listData) {