Commit 27512eea authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Limpia vista real-time y localiza markers

parent 0076866a
Loading
Loading
Loading
Loading
+70 −142
Original line number Diff line number Diff line
define([
	"app/designs/mapWithSideContent/Controller"
	, "app/designs/mapWithSideContent/layout/MapAndContent"
	, "app/redmicConfig"
	, "dijit/layout/BorderContainer"
	, "dijit/layout/ContentPane"
	, "dijit/layout/TabContainer"
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "redmic/modules/base/_Filter"
	, "redmic/modules/browser/ListImpl"
	, "redmic/modules/browser/_ButtonsInRow"
	, "redmic/modules/browser/_GeoJsonParser"
	, "redmic/modules/browser/_Framework"
	, "redmic/modules/browser/bars/Total"
	, "redmic/modules/map/Atlas"
	, "redmic/modules/map/layer/PruneClusterLayerImpl"
	, "redmic/modules/map/layer/_AddFilter"
	, "redmic/modules/search/TextImpl"
	, "templates/SurveyStationList"
	, "templates/SurveyStationPopup"
	'app/designs/mapWithSideContent/Controller'
	, 'app/designs/mapWithSideContent/layout/MapAndContent'
	, 'app/redmicConfig'
	, 'dijit/layout/BorderContainer'
	, 'dijit/layout/ContentPane'
	, 'dijit/layout/TabContainer'
	, 'dojo/_base/declare'
	, 'dojo/_base/lang'
	, 'redmic/modules/base/_Filter'
	, 'redmic/modules/browser/ListImpl'
	, 'redmic/modules/browser/_ButtonsInRow'
	, 'redmic/modules/browser/_GeoJsonParser'
	, 'redmic/modules/browser/_Framework'
	, 'redmic/modules/browser/bars/Total'
	, "redmic/modules/gateway/MapCenteringGatewayImpl"
	, 'redmic/modules/map/Atlas'
	, 'redmic/modules/map/layer/PruneClusterLayerImpl'
	, 'redmic/modules/search/TextImpl'
	, 'templates/SurveyStationList'
	, 'templates/SurveyStationPopup'
], function(
	Controller
	, Layout
@@ -34,9 +34,9 @@ define([
	, _GeoJsonParser
	, _Framework
	, Total
	, MapCenteringGatewayImpl
	, Atlas
	, PruneClusterLayerImpl
	, _AddFilter
	, TextImpl
	, TemplateList
	, TemplatePopup
@@ -55,24 +55,21 @@ define([
		constructor: function(args) {

			this.config = {
				title: this.i18n["real-time"],
				"class": "",
				title: this.i18n['real-time'],
				'class': '',

				templatePopup: TemplatePopup,

				target: redmicConfig.services.timeSeriesStations,
				layersTarget: redmicConfig.services.timeSeriesStations,

				_layerInstance: null,
				_layerIdPrefix: "realTime",
				layerIdSeparator: "_",

				ownChannel: "realTime",
				ownChannel: 'realTime',

				filterConfig: {
					initQuery: {
						terms: {
							"properties.site.dashboard": true
							'properties.site.dashboard': true
						},
						size: null,
						from: null
@@ -89,8 +86,8 @@ define([
				parentChannel: this.getChannel(),
				target: this.target,
				highlightField: ['properties.site.name'],
				suggestFields: ["properties.site.name", "properties.site.code"],
				searchFields: ["properties.site.name", "properties.site.code"],
				suggestFields: ['properties.site.name', 'properties.site.code'],
				searchFields: ['properties.site.name', 'properties.site.code'],
				initialQuery: this.filterConfig.initQuery,
				itemLabel: null
			}, this.searchConfig || {}]);
@@ -99,19 +96,19 @@ define([
				parentChannel: this.getChannel(),
				target: this.target,
				perms: this.perms,
				selectionIdProperty: "id",
				selectionIdProperty: 'id',
				template: TemplateList,
				rowConfig: {
					buttonsConfig: {
						listButton: [{
							icon: "fa-tachometer",
							btnId: "goToDashboard",
							title: "Go to dashboard",
							icon: 'fa-tachometer',
							btnId: 'goToDashboard',
							title: 'Go to dashboard',
							href: redmicConfig.viewPaths.realTimeDashboard
						},{
							icon: "fa-map-marker",
							title: "map centering",
							btnId: "mapCentering",
							icon: 'fa-map-marker',
							title: 'map centering',
							btnId: 'mapCentering',
							returnItem: true
						}]
					}
@@ -122,20 +119,6 @@ define([
			}, this.browserConfig || {}]);
		},

		_defineSubscriptions: function () {

			this.subscriptionsConfig.push({
				channel: this.filter.getChannel("CHANGED_MODEL"),
				callback: "_subChangedModelFilter"
			},{
				channel: this.filter.getChannel("REQUEST_FILTER"),
				callback: "_subRequestFilter"
			},{
				channel : this.browser.getChannel("BUTTON_EVENT"),
				callback: "_subListBtnEvent"
			});
		},

		_initialize: function() {

			this.searchConfig.queryChannel = this.queryChannel;
@@ -151,36 +134,18 @@ define([
			});

			this.modelChannel = this.filter.modelChannel;
		},

		_afterShow: function(request) {

			if (!this._layerInstance) {

				this._layerInstance = new declare([PruneClusterLayerImpl, _AddFilter])({
			this._layerInstance = new PruneClusterLayerImpl({
				parentChannel: this.getChannel(),
				mapChannel: this.map.getChannel(),
					geoJsonStyle: {
						color: "red",
						weight: 5
					},
					target: this.layersTarget,
					infoTarget: this.layersTarget,
					filterConfig: {
						modelChannel: this.modelChannel
					},
				target: this.target,
				idProperty: 'uuid',
				getPopupContent: lang.hitch(this, this._getPopupContent)
			});
			}

			this._emitEvt('ADD_LAYER', {layer: this._layerInstance});

			this._publish(this._layerInstance.getChannel('REFRESH'));
		},

		_setOwnCallbacksForEvents: function() {

			this._onEvt('HIDE', lang.hitch(this, this._onHide));
			this.mapCenteringGateway = new MapCenteringGatewayImpl({
				parentChannel: this.getChannel()
			});
		},

		postCreate: function() {
@@ -189,24 +154,24 @@ define([

			var browserAndSearchContainer = new BorderContainer({
				title: this.i18n.list,
				'class': "marginedContainer noScrolledContainer"
				'class': 'marginedContainer noScrolledContainer'
			});

			this.gridNode = new ContentPane({
				region: "center",
				region: 'center',
				'class': 'stretchZone'
			});

			this._publish(this.browser.getChannel("SHOW"), {
			this._publish(this.browser.getChannel('SHOW'), {
				node: this.gridNode.domNode
			});

			this.textSearchNode = new ContentPane({
				'class': "topZone",
				region: "top"
				'class': 'topZone',
				region: 'top'
			});

			this._publish(this.textSearch.getChannel("SHOW"), {
			this._publish(this.textSearch.getChannel('SHOW'), {
				node: this.textSearchNode.domNode
			});

@@ -214,40 +179,34 @@ define([
			browserAndSearchContainer.addChild(this.gridNode);

			this.tabs = new TabContainer({
				tabPosition: "top",
				tabPosition: 'top',
				splitter: true,
				region: "right",
				'class': "col-xs-6 col-sm-6 col-md-6 col-lg-5 col-xl-4 mediumTexturedContainer sideTabContainer"
				region: 'right',
				'class': 'col-xs-6 col-sm-6 col-md-6 col-lg-5 col-xl-4 mediumTexturedContainer sideTabContainer'
			});
			this.tabs.addChild(browserAndSearchContainer);
			this.tabs.addChild(this._createAtlas());

			this.contentNode.addChild(this.tabs);
		},

		_subListBtnEvent: function(evt) {

			var callback = "_" + evt.btnId + "Callback";
			this[callback] && this[callback](evt);
		},

		_mapCenteringCallback: function(obj) {
			console.debug("mapCentering ", obj)
		},

		_subChangedModelFilter: function(obj) {

			this.modelChannel = obj.modelChannel;
		},

		_subRequestFilter: function(obj) {
			this._emitEvt('ADD_LAYER', {layer: this._layerInstance});

			this._publish(this._layerInstance.getChildChannel('filter', "REQUEST_FILTER"), obj);
			this._publish(this.mapCenteringGateway.getChannel('ADD_CHANNELS_DEFINITION'), {
				channelsDefinition: [{
					input: this.browser.getChannel('BUTTON_EVENT'),
					output: this._layerInstance.getChannel('SET_CENTER'),
					subMethod: 'setCenter'
				},{
					input: this.browser.getChannel('BUTTON_EVENT'),
					output: this._layerInstance.getChannel("ANIMATE_MARKER"),
					subMethod: 'animateMarker'
				}]
			});
		},

		_getIdFromPath: function(path) {
		_beforeShow: function() {

			return path.split(this.pathSeparator).pop();
			this._emitEvt('REFRESH');
		},

		_getPopupContent: function(data) {
@@ -258,49 +217,18 @@ define([
			});
		},

		_removeDataLayer: function(item) {

			this._removeLayerInstance(item);
		},

		_removeLayerInstance: function(item) {

			this._publish(this._layerInstance.getChannel("CLEAR"));
			this._emitEvt('REMOVE_LAYER', {
				layer: this._layerInstance
			});
			this._publish(this._layerInstance.getChannel("DISCONNECT"));

			this._layerInstance.destroy();
			delete this._layerInstance;
		},

		_createAtlas: function() {

			var cp = new ContentPane({
				title: this.i18n.themes,
				region:"center"
				region:'center'
			});

			this._publish(this.atlas.getChannel("SHOW"), {
			this._publish(this.atlas.getChannel('SHOW'), {
				node: cp.domNode
			});

			return cp;
		},

		_onHide: function() {

		},

		_beforeShow: function() {

			this._emitEvt('REFRESH');
		},

		_getIconKeypadNode: function() {

			return this.textSearchNode.domNode;
		}
	});
});