<commit_before>/*
 * Copyright (C) 2013 <EMAIL> (<EMAIL>)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
angular.module('demoApp.controllers', []).
    controller('ChargingStationController',
        ['$scope', '$http', '$interval', function ($scope, $http, $interval) {
            $scope.init = function () {
                $scope.getChargingStations();
                if(!$scope.chargingStationTimer) {
                    $scope.chargingStationTimer = $scope.startGetChargingStationsTimer();
                }
            };

            $scope.$on('$destroy', function destroy() {
                $interval.cancel($scope.chargingStationTimer);
                delete $scope.chargingStationTimer;
            });

            $scope.startGetChargingStationsTimer = function () {
                return $interval(function () {
                    $scope.getChargingStations();
                }, 5000);
            };

            $scope.getChargingStations = function () {
                $http({
                    url: 'rest/operator-api/charging-stations',
                    method: 'GET',
                    data: ''
                }).success(function (response) {
                    $scope.chargingStations = response;
                }).error(function () {
                    console.log('Error getting charging stations, cancel polling.');
                    $interval.cancel($scope.chargingStationTimer);
                    delete $scope.chargingStationTimer;
                });
            };

            $scope.registerChargingStation = function (chargingStation) {
                var cs = chargingStation;

                $http({
                    url: 'rest/operator-api/charging-stations/' + chargingStation.id + '/commands',
                    method: 'POST',
                    data: ['Register', {
                        'configuration': {
                            'evses': [
                                {
                                    'evseId': 1,
                                    'connectors': [
                                        {
                                            'maxAmp': 32,
                                            'phase': 3,
                                            'voltage': 240,
                                            'chargingProtocol': 'MODE3',
                                            'current': 'AC',
                                            'connectorType': 'TESLA'
                                        }
                                    ]
                                },
                                {
                                    'evseId': 2,
                                    'connectors': [
                                        {
                                            'maxAmp': 32,
                                            'phase': 3,
                                            'voltage': 240,
                                            'chargingProtocol': 'MODE3',
                                            'current': 'AC',
                                            'connectorType': 'TESLA'
                                        }
                                    ]
                                }
                            ],
                            'settings': {
                                'key': 'value',
                                'key2': 'value2'
                            }
                        }
                    }]
                }).success(function (response) {
                    console.log('registered');
                    cs.accepted = true;
                });
            };

            $scope.resetChargingStation = function (chargingStation, type) {
                var resetType = 'soft';

                if (type == 'hard') {
                    resetType = 'hard';
                }

                $http({
                    url: 'rest/operator-api/charging-stations/' + chargingStation.id + '/commands',
                    method: 'POST',
                    data: ['ResetChargingStation', {
                        'type': resetType
                    }]
                }).success(function (response) {
                    console.log('reset requested');
                });
            };

            $scope.startTransaction = function (chargingStation) {<commit_msg>Removed obsolete JSON from Register call in samples<commit_after>/*
 * Copyright (C) 2013 Motown.IO (<EMAIL>)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
angular.module('demoApp.controllers', []).
    controller('ChargingStationController',
        ['$scope', '$http', '$interval', function ($scope, $http, $interval) {
            $scope.init = function () {
                $scope.getChargingStations();
                if(!$scope.chargingStationTimer) {
                    $scope.chargingStationTimer = $scope.startGetChargingStationsTimer();
                }
            };

            $scope.$on('$destroy', function destroy() {
                $interval.cancel($scope.chargingStationTimer);
                delete $scope.chargingStationTimer;
            });

            $scope.startGetChargingStationsTimer = function () {
                return $interval(function () {
                    $scope.getChargingStations();
                }, 5000);
            };

            $scope.getChargingStations = function () {
                $http({
                    url: 'rest/operator-api/charging-stations',
                    method: 'GET',
                    data: ''
                }).success(function (response) {
                    $scope.chargingStations = response;
                }).error(function () {
                    console.log('Error getting charging stations, cancel polling.');
                    $interval.cancel($scope.chargingStationTimer);
                    delete $scope.chargingStationTimer;
                });
            };

            $scope.registerChargingStation = function (chargingStation) {
                var cs = chargingStation;

                $http({
                    url: 'rest/operator-api/charging-stations/' + chargingStation.id + '/commands',
                    method: 'POST',
                    data: ['Register', {
                    }]
                }).success(function (response) {
                    console.log('registered');
                    cs.accepted = true;
                });
            };

            $scope.resetChargingStation = function (chargingStation, type) {
                var resetType = 'soft';

                if (type == 'hard') {
                    resetType = 'hard';
                }

                $http({
                    url: 'rest/operator-api/charging-stations/' + chargingStation.id + '/commands',
                    method: 'POST',
                    data: ['ResetChargingStation', {
                        'type': resetType
                    }]
                }).success(function (response) {
                    console.log('reset requested');
                });
            };

            $scope.startTransaction = function (chargingStation) {
{'fraction_non_alphanumeric': 0.10252346702425942, 'fraction_numerical': 0.005120078020236499, 'mean_word_length': 1.1003584229390682, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2891117', 'n_tokens_mistral': 1856, 'n_tokens_neox': 1694, 'n_words': 410}