admin-theme.component.js 1.33 KB
Newer Older
NGPixel's avatar
NGPixel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
'use strict'

export default {
  name: 'admin-theme',
  props: ['themedata'],
  data() {
    return {
      primary: 'indigo',
      alt: 'blue-grey',
      footer: 'blue-grey',
      codedark: 'true',
      codecolorize: 'true'
    }
  },
15 16 17 18 19 20 21 22 23 24 25
  watch: {
    primary(val) {
      this.$root.changeTheme(this.$data)
    },
    alt(val) {
      this.$root.changeTheme(this.$data)
    },
    footer(val) {
      this.$root.changeTheme(this.$data)
    }
  },
NGPixel's avatar
NGPixel committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
  methods: {
    saveTheme() {
      let self = this
      this.$http.post(window.location.href, self.$data).then(resp => {
        self.$store.dispatch('alert', {
          style: 'green',
          icon: 'check',
          msg: 'Theme settings have been applied successfully.'
        })
      }).catch(err => {
        self.$store.dispatch('alert', {
          style: 'red',
          icon: 'square-cross',
          msg: 'Error: ' + err.body.msg
        })
      })
    },
    resetTheme() {
      this.primary = 'indigo'
      this.alt = 'blue-grey'
      this.footer = 'blue-grey'
      this.codedark = 'true'
      this.codecolorize = 'true'
    }
  },
  mounted() {
    let theme = JSON.parse(this.themedata)
    this.primary = theme.primary
    this.alt = theme.alt
    this.footer = theme.footer
    this.codedark = theme.code.dark.toString()
    this.codecolorize = theme.code.colorize.toString()
  }
}