<commit_before>angular
  .module 'tracker.grid'

  .controller 'PageViewController', Array '$scope', '$rootScope', '$http', ($scope, $rootScope, $http) ->

    $scope.getStudyUrl = () ->
      "/api/studies/#{$scope.study.name}/views/#{$scope.view.name}"

    $scope.alerts = []
    $scope.page = {}

    $scope.user = $rootScope.user

    $scope.moment = moment()

    $scope.closeAlert = (index) ->
      $scope.alerts.splice(index, 1)

    $scope.reset = () ->
      $scope.page = {}

    $scope.submit = () ->
      baseUrl = $scope.getStudyUrl()
      payload = $scope.page
      $http
        .post "#{baseUrl}/entities", JSON.stringify {entity: payload}
        .success (response) =>
          $scope.alerts.push {type: 'success', message: "New record written successfully"}
        .error (response) ->
          description = if response?.description then response.description else JSON.stringify(response)
          $scope.alerts.push {type: 'danger', message: "Error writing new record: " + description}



  ## Controller to handle the button used to export a record.
  .controller 'GridActionController', Array '$scope', '$stateParams', ($scope, $stateParams) ->

    $scope.message = undefined
    $scope.identifier = undefined
    $scope.shown = false

    $scope.export = () ->
      location.href = "/api/studies/#{encodeURIComponent($stateParams.studyName)}/views/#{encodeURIComponent($stateParams.viewName)}?page=all&media=xml"


  ## Controller to handle connected users
  .controller 'ConnectedUserController', Array '$scope', 'socketFactory', ($scope, socketFactory) ->
    $scope.currentUsers = ["system"]

    socket = socketFactory()

    socket.on 'userconnect', (event) ->
      console.log 'Got userconnect event', event.data.user
      $scope.$apply () ->
        if not (event.data.user in $scope.currentUsers)
          $scope.currentUsers.push event.data.user
<commit_msg>Added a logic which allows a reset operation and initialization of a form. Resolves #171<commit_after>angular
  .module 'tracker.grid'

  .controller 'PageViewController', Array '$scope', '$rootScope', '$http', ($scope, $rootScope, $http) ->

    $scope.getStudyUrl = () ->
      "/api/studies/#{$scope.study.name}/views/#{$scope.view.name}"

    $scope.alerts = []
    $scope.defaults = {}
    $scope.page = {}

    $scope.user = $rootScope.user

    $scope.moment = moment()

    $scope.saved = false

    $scope.$watchCollection 'defaults', (newValue, oldValue) ->
      return if newValue == oldValue
      for own k, v of newValue
        $scope.page[k] = v

    $scope.closeAlert = (index) ->
      $scope.alerts.splice(index, 1)

    $scope.reset = () ->
      $scope.page = angular.copy($scope.defaults)
      $scope.saved = false

    $scope.submit = () ->
      baseUrl = $scope.getStudyUrl()
      payload = $scope.page
      $http
        .post "#{baseUrl}/entities", JSON.stringify {entity: payload}
        .success (response) =>
          $scope.alerts.push {type: 'success', message: "New record written successfully"}
          $scope.saved = true
        .error (response) ->
          description = if response?.description then response.description else JSON.stringify(response)
          $scope.alerts.push {type: 'danger', message: "Error writing new record: " + description}



  ## Controller to handle the button used to export a record.
  .controller 'GridActionController', Array '$scope', '$stateParams', ($scope, $stateParams) ->

    $scope.message = undefined
    $scope.identifier = undefined
    $scope.shown = false

    $scope.export = () ->
      location.href = "/api/studies/#{encodeURIComponent($stateParams.studyName)}/views/#{encodeURIComponent($stateParams.viewName)}?page=all&media=xml"


  ## Controller to handle connected users
  .controller 'ConnectedUserController', Array '$scope', 'socketFactory', ($scope, socketFactory) ->
    $scope.currentUsers = ["system"]

    socket = socketFactory()

    socket.on 'userconnect', (event) ->
      console.log 'Got userconnect event', event.data.user
      $scope.$apply () ->
        if not (event.data.user in $scope.currentUsers)
          $scope.currentUsers.push event.data.user

{'fraction_non_alphanumeric': 0.15263157894736842, 'fraction_numerical': 0.0011961722488038277, 'mean_word_length': 3.0909980430528377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1204757', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1196, 'n_words': 284}