<commit_before>(function () {
  'use strict';

  angular
    .module('openSenseMapApp')
    .controller('EditBoxSensorsController', EditBoxSensorsController);

  EditBoxSensorsController.$inject = ['boxData', 'notifications', 'SensorIcons', 'AccountService'];

  function EditBoxSensorsController (boxData, notifications, SensorIcons, AccountService) {
    var vm = this;
    vm.sensors = [];
    vm.icons = [];

    vm.addSensor = addSensor;
    vm.deleteSensor = deleteSensor;
    vm.saveSensor = saveSensor;
    vm.cancelSensor = cancelSensor;
    vm.editSensor = editSensor;
    vm.getIcon = getIcon;
    vm.setIcon = setIcon;
    vm.undo = undo;

    vm.save = save;

    activate();

    ////

    function activate () {
      if (angular.isDefined(boxData.sensors)) {
        angular.copy(boxData.sensors, vm.sensors);
      }
      vm.icons = SensorIcons;
    }

    function save () {
      return AccountService.updateBox(boxData._id, {sensors: vm.sensors})
        .then(function (response) {
          angular.copy(response.data, boxData);
          notifications.addAlert('info', 'NOTIFICATION_BOX_UPDATE_SUCCESS');
        })
        .catch(function (error) {
          console.log('ERROR RESPONSE');
          console.log(error);
          notifications.addAlert('danger', 'NOTIFICATION_BOX_UPDATE_FAILED');
        });<commit_msg>fix edit sensors in updateBox<commit_after>(function () {
  'use strict';

  angular
    .module('openSenseMapApp')
    .controller('EditBoxSensorsController', EditBoxSensorsController);

  EditBoxSensorsController.$inject = ['boxData', 'notifications', 'SensorIcons', 'AccountService'];

  function EditBoxSensorsController (boxData, notifications, SensorIcons, AccountService) {
    var vm = this;
    vm.sensors = [];
    vm.icons = [];

    vm.addSensor = addSensor;
    vm.deleteSensor = deleteSensor;
    vm.saveSensor = saveSensor;
    vm.cancelSensor = cancelSensor;
    vm.editSensor = editSensor;
    vm.getIcon = getIcon;
    vm.setIcon = setIcon;
    vm.undo = undo;

    vm.save = save;

    activate();

    ////

    function activate () {
      if (angular.isDefined(boxData.sensors)) {
        angular.copy(boxData.sensors, vm.sensors);
      }
      vm.icons = SensorIcons;
    }

    function save () {
      return AccountService.updateBox(boxData._id, {sensors: vm.sensors})
        .then(function (response) {
          angular.copy(response.data, boxData);
          angular.copy(boxData.sensors, vm.sensors);
          notifications.addAlert('info', 'NOTIFICATION_BOX_UPDATE_SUCCESS');
        })
        .catch(function (error) {
          console.log('ERROR RESPONSE');
          console.log(error);
          notifications.addAlert('danger', 'NOTIFICATION_BOX_UPDATE_FAILED');
        });
{'fraction_non_alphanumeric': 0.12857660268018833, 'fraction_numerical': 0.0, 'mean_word_length': 2.9344729344729346, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4435399', 'n_tokens_mistral': 849, 'n_tokens_neox': 832, 'n_words': 144}