admin-theme.component.js 1.3 KB

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