Skip to content
Snippets Groups Projects
Select Git revision
  • fix-index.html-encoding
  • develop default protected
  • document-loglevel
  • master
  • 1.0.1
  • 1121-download
  • plugins-v3
  • 876-http-signature
  • plugins-v2
  • plugins
  • 1.0.1
  • 1.0
  • 1.0-rc1
  • 0.21.2
  • 0.21.1
  • 0.21
  • 0.21-rc2
  • 0.21-rc1
  • 0.20.1
  • 0.20.0
  • 0.20.0-rc1
  • 0.19.1
  • 0.19.0
  • 0.19.0-rc2
  • 0.19.0-rc1
  • 0.18.3
  • 0.18.2
  • 0.18.1
  • 0.18
  • 0.17
30 results

instance.js

Blame
  • Forked from funkwhale / funkwhale
    7774 commits behind the upstream repository.
    instance.js 1.14 KiB
    import axios from 'axios'
    import logger from '@/logging'
    import _ from 'lodash'
    
    export default {
      namespaced: true,
      state: {
        settings: {
          users: {
            registration_enabled: {
              value: true
            }
          },
          raven: {
            front_enabled: {
              value: false
            },
            front_dsn: {
              value: null
            }
          }
        }
      },
      mutations: {
        settings: (state, value) => {
          _.merge(state.settings, value)
        }
      },
      actions: {
        // Send a request to the login URL and save the returned JWT
        fetchSettings ({commit}, payload) {
          return axios.get('instance/settings/').then(response => {
            logger.default.info('Successfully fetched instance settings')
            let sections = {}
            response.data.forEach(e => {
              sections[e.section] = {}
            })
            response.data.forEach(e => {
              sections[e.section][e.name] = e
            })
            commit('settings', sections)
            if (payload && payload.callback) {
              payload.callback()
            }
          }, response => {
            logger.default.error('Error while fetching settings', response.data)
          })
        }
      }
    }