<commit_before>angular.module('n52.core.station', ['ui.bootstrap'])
        .controller('ModalStationCtrl', ['$scope', '$modalInstance', 'timeseriesService', '$location', 'stationService', 'selection',
            function ($scope, $modalInstance, timeseriesService, $location, stationService, selection) {
                stationService.determineTimeseries(selection.stationId, selection.url);
                $scope.isAllSelected = true;
                $scope.station = stationService.station;
                $scope.phenomenonId = selection.phenomenonId;

                $scope.toggleAll = function () {
                    angular.forEach($scope.station.entry.properties.timeseries, function (ts) {
                        ts.selected = $scope.isAllSelected;
                    });
                };

                $scope.close = function () {
                    $modalInstance.close();
                };

                $scope.toggled = function () {
                    var allSelected = true;
                    angular.forEach($scope.station.entry.properties.timeseries, function (ts) {
                        if (!ts.selected)
                            allSelected = false;
                    });
                    $scope.isAllSelected = allSelected;
                };

                $scope.addTimeseriesSelection = function (phenomenonId) {
                    angular.forEach($scope.station.entry.properties.timeseries, function (timeseries) {
                        if (timeseries.selected && timeseries.phenomenon.id == phenomenonId) {
                            timeseriesService.addTimeseriesById(timeseries.id, selection.url);
                        }
                    });
                    $location.url('/diagram');
                    $modalInstance.close();
                };
            }])
        .service('StationOpener', ['$modal', '$rootScope', 'mapService',
            function ($modal, $rootScope, mapService) {
                clickmarker = function (event, args) {
                    $modal.open({
                        animation: true,
                        templateUrl: 'templates/map/station.html',
                        resolve: {
                            selection: function () {
                                var stationsId;
                                var url;
                                if (args.model) {
                                    stationsId = args.model.stationsId ? args.model.stationsId : "";
                                    url = args.model.url ? args.model.url : "";
                                } else if (args.leafletObject && args.leafletObject.options) {
                                    stationsId = args.leafletObject.options.stationsId ? args.leafletObject.options.stationsId : "";
                                    url = args.leafletObject.options.url ? args.leafletObject.options.url : "";
                                }
                                return {
                                    stationId: stationsId,
                                    phenomenonId: mapService.map.selectedPhenomenonId,
                                    url: url
                                };
                            }
                        },
                        controller: 'ModalStationCtrl'
                    });
                };
                $rootScope.$on('leafletDirectivePath.click', clickmarker);
                $rootScope.$on('leafletDirectiveMarker.click', clickmarker);
            }])
        .service('stationService', ['interfaceService',
            function (interfaceService) {
                var station = {
                    entry: {}
                };
                determineTimeseries = function (stationId, url) {
                    station.entry = {};
                    interfaceService.getStations(stationId, url).then(function (result) {
                        station.entry = result;
                        angular.forEach(result.properties.timeseries, function (timeseries, id) {
                            interfaceService.getTimeseries(id, url).then(function (ts) {
                                angular.extend(timeseries, ts);
                                timeseries.selected = true;
                            });
                        });
                    });
                };

                return {
                    determineTimeseries: determineTimeseries,
                    station: station
                };
            }]);<commit_msg>fix for open only timeseries with matching phenomenon id<commit_after>angular.module('n52.core.station', ['ui.bootstrap'])
        .controller('ModalStationCtrl', ['$scope', '$modalInstance', 'timeseriesService', '$location', 'stationService', 'selection',
            function ($scope, $modalInstance, timeseriesService, $location, stationService, selection) {
                stationService.determineTimeseries(selection.stationId, selection.url);
                $scope.isAllSelected = true;
                $scope.station = stationService.station;
                $scope.phenomenonId = selection.phenomenonId;

                $scope.toggleAll = function () {
                    angular.forEach($scope.station.entry.properties.timeseries, function (ts) {
                        ts.selected = $scope.isAllSelected;
                    });
                };

                $scope.close = function () {
                    $modalInstance.close();
                };

                $scope.toggled = function () {
                    var allSelected = true;
                    angular.forEach($scope.station.entry.properties.timeseries, function (ts) {
                        if (!ts.selected)
                            allSelected = false;
                    });
                    $scope.isAllSelected = allSelected;
                };

                $scope.addTimeseriesSelection = function (phenomenonId) {
                    angular.forEach($scope.station.entry.properties.timeseries, function (timeseries) {
                        if (timeseries.selected && (!phenomenonId || timeseries.phenomenon.id == phenomenonId)) {
                            timeseriesService.addTimeseriesById(timeseries.id, selection.url);
                        }
                    });
                    $location.url('/diagram');
                    $modalInstance.close();
                };
            }])
        .service('StationOpener', ['$modal', '$rootScope', 'mapService',
            function ($modal, $rootScope, mapService) {
                clickmarker = function (event, args) {
                    $modal.open({
                        animation: true,
                        templateUrl: 'templates/map/station.html',
                        resolve: {
                            selection: function () {
                                var stationsId;
                                var url;
                                if (args.model) {
                                    stationsId = args.model.stationsId ? args.model.stationsId : "";
                                    url = args.model.url ? args.model.url : "";
                                } else if (args.leafletObject && args.leafletObject.options) {
                                    stationsId = args.leafletObject.options.stationsId ? args.leafletObject.options.stationsId : "";
                                    url = args.leafletObject.options.url ? args.leafletObject.options.url : "";
                                }
                                return {
                                    stationId: stationsId,
                                    phenomenonId: mapService.map.selectedPhenomenonId,
                                    url: url
                                };
                            }
                        },
                        controller: 'ModalStationCtrl'
                    });
                };
                $rootScope.$on('leafletDirectivePath.click', clickmarker);
                $rootScope.$on('leafletDirectiveMarker.click', clickmarker);
            }])
        .service('stationService', ['interfaceService',
            function (interfaceService) {
                var station = {
                    entry: {}
                };
                determineTimeseries = function (stationId, url) {
                    station.entry = {};
                    interfaceService.getStations(stationId, url).then(function (result) {
                        station.entry = result;
                        angular.forEach(result.properties.timeseries, function (timeseries, id) {
                            interfaceService.getTimeseries(id, url).then(function (ts) {
                                angular.extend(timeseries, ts);
                                timeseries.selected = true;
                            });
                        });
                    });
                };

                return {
                    determineTimeseries: determineTimeseries,
                    station: station
                };
            }]);
{'fraction_non_alphanumeric': 0.09775010921799912, 'fraction_numerical': 0.00043687199650502403, 'mean_word_length': 1.1142923112445162, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4093086', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1885, 'n_words': 309}