<commit_before><script lang="coffee">
import Session  from '@/shared/services/session'
import Records  from '@/shared/services/records'
import EventBus from '@/shared/services/event_bus'
import Gravatar from 'vue-gravatar';
import { capitalize } from 'lodash-es'
import AppConfig from '@/shared/services/app_config'
import Flash   from '@/shared/services/flash'
import { onError } from '@/shared/helpers/form'

export default
  components:
    'v-gravatar': Gravatar
  props:
    close: Function
  data: ->
    user: Session.user().clone()
    providers: AppConfig.identityProviders
    uploading: false
    progress: 0
  methods:
    capitalize: capitalize
    iconClass: (provider) ->
      "mdi-" + if (provider == 'saml') then 'key-variant' else provider

    providerColor: (provider) ->
      switch provider
        when 'facebook' then '#3b5998'
        when 'google' then '#dd4b39'
        when 'slack' then '#e9a820'
        when 'saml' then @$vuetify.theme.themes.light.primary

    selectProvider: (provider) ->
      window.location = "#{provider.href}?back_to=#{window.location.href}"

    selectFile: ->
      @$refs.fileInput.click()

    uploadFile: ->
      @uploading = true
      Records.users.remote.onUploadSuccess = (response) =>
        Records.import response
        EventBus.$emit 'closeModal'
        @uploading = false
      Records.users.remote.upload('upload_avatar', @$refs.fileInput.files[0], {}, (args) => @progress = args.loaded / args.total * 100)

    submit: (kind) ->
      @user.avatarKind = kind
      Records.users.updateProfile(@user)
      .then =>
        Flash.success 'profile_page.messages.picture_changed'
        EventBus.$emit 'closeModal'
      .catch onError(@user)

  created: -><commit_msg>emit update profile after uploading a profile picture<commit_after><script lang="coffee">
import Session  from '@/shared/services/session'
import Records  from '@/shared/services/records'
import EventBus from '@/shared/services/event_bus'
import Gravatar from 'vue-gravatar';
import { capitalize } from 'lodash-es'
import AppConfig from '@/shared/services/app_config'
import Flash   from '@/shared/services/flash'
import { onError } from '@/shared/helpers/form'

export default
  components:
    'v-gravatar': Gravatar
  props:
    close: Function
  data: ->
    user: Session.user().clone()
    providers: AppConfig.identityProviders
    uploading: false
    progress: 0
  methods:
    capitalize: capitalize
    iconClass: (provider) ->
      "mdi-" + if (provider == 'saml') then 'key-variant' else provider

    providerColor: (provider) ->
      switch provider
        when 'facebook' then '#3b5998'
        when 'google' then '#dd4b39'
        when 'slack' then '#e9a820'
        when 'saml' then @$vuetify.theme.themes.light.primary

    selectProvider: (provider) ->
      window.location = "#{provider.href}?back_to=#{window.location.href}"

    selectFile: ->
      @$refs.fileInput.click()

    uploadFile: ->
      @uploading = true
      Records.users.remote.onUploadSuccess = (response) =>
        Records.import response
        EventBus.$emit 'updateProfile'
        EventBus.$emit 'closeModal'
        @uploading = false
      Records.users.remote.upload('upload_avatar', @$refs.fileInput.files[0], {}, (args) => @progress = args.loaded / args.total * 100)

    submit: (kind) ->
      @user.avatarKind = kind
      Records.users.updateProfile(@user)
      .then =>
        Flash.success 'profile_page.messages.picture_changed'
        EventBus.$emit 'updateProfile'
        EventBus.$emit 'closeModal'
      .catch onError(@user)

  created: ->
{'fraction_non_alphanumeric': 0.13137472283813748, 'fraction_numerical': 0.009423503325942351, 'mean_word_length': 3.1198630136986303, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6641147', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1073, 'n_words': 253}