You need to sign in or sign up before continuing.
admin-dev-flags.vue 2.74 KB
Newer Older
1 2 3 4 5
<template lang='pug'>
  v-container(fluid, grid-list-lg)
    v-layout(row, wrap)
      v-flex(xs12)
        .admin-header
6
          img(src='/_assets/svg/icon-console.svg', alt='Developer Tools', style='width: 80px;')
7 8
          .admin-header-title
            .headline.primary--text Developer Tools
9
            .subtitle-1.grey--text Flags
10 11
          v-spacer
          v-btn(color='success', depressed, @click='save', large)
12
            v-icon(left) mdi-check
13 14
            span {{$t('common:actions.apply')}}

15
        v-card.mt-3(:class='$vuetify.theme.dark ? `grey darken-3-d5` : `white grey--text text--darken-3`')
16
          v-alert(color='red', :value='true', icon='mdi-alert', dark, prominent)
17 18 19
            span Do NOT enable these flags unless you know what you're doing!
            .caption Doing so may result in data loss or broken installation!
          v-card-text
Nick's avatar
Nick committed
20 21 22 23 24 25
            v-switch.mt-3(
              color='primary'
              hint='Log detailed debug info on LDAP/AD login attempts.'
              persistent-hint
              label='LDAP Debug'
              v-model='flags.ldapdebug'
26
              inset
Nick's avatar
Nick committed
27 28
            )
            v-divider.mt-3
29 30 31 32 33 34
            v-switch.mt-3(
              color='red'
              hint='Log all queries made to the database to console.'
              persistent-hint
              label='SQL Query Logging'
              v-model='flags.sqllog'
35
              inset
36 37 38 39 40 41
            )
</template>

<script>
import _ from 'lodash'

Nick's avatar
Nick committed
42 43 44
import flagsQuery from 'gql/admin/dev/dev-query-flags.gql'
import flagsMutation from 'gql/admin/dev/dev-mutation-save-flags.gql'

45 46 47 48 49 50 51 52 53
export default {
  data() {
    return {
      flags: {
        sqllog: false
      }
    }
  },
  methods: {
Nick's avatar
Nick committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    async save() {
      try {
        await this.$apollo.mutate({
          mutation: flagsMutation,
          variables: {
            flags: _.transform(this.flags, (result, value, key) => {
              result.push({ key, value })
            }, [])
          },
          watchLoading (isLoading) {
            this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-dev-flags-update')
          }
        })
        this.$store.commit('showNotification', {
          style: 'success',
          message: 'Flags applied successfully.',
          icon: 'check'
        })
      } catch (err) {
        this.$store.commit('pushGraphError', err)
      }
    }
  },
  apollo: {
    flags: {
      query: flagsQuery,
      fetchPolicy: 'network-only',
      update: (data) => _.transform(data.system.flags, (result, row) => {
        _.set(result, row.key, row.value)
      }, {}),
      watchLoading (isLoading) {
        this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-dev-flags-refresh')
      }
87 88 89 90 91 92 93 94
    }
  }
}
</script>

<style lang='scss'>

</style>