SettingsGeneral.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <div class='route_container'>
  3. <div class='h1'>General settings</div>
  4. <p>
  5. <div class='h3'>About me</div>
  6. <p class='p--condensed'>
  7. Write something about yourself to be displayed on your user page
  8. </p>
  9. <fancy-textarea
  10. placeholder='About me description'
  11. v-model='description.value'
  12. :error='description.error'
  13. type='password'
  14. ></fancy-textarea>
  15. <loading-button
  16. class='button button--green'
  17. :loading='description.loading'
  18. @click='saveDescription'
  19. >
  20. Save description
  21. </loading-button>
  22. </p>
  23. </div>
  24. </template>
  25. <script>
  26. import FancyTextarea from '../FancyTextarea'
  27. import LoadingButton from '../LoadingButton'
  28. import AjaxErrorHandler from '../../assets/js/errorHandler'
  29. export default {
  30. name: 'settingsGeneral',
  31. components: {
  32. FancyTextarea,
  33. LoadingButton
  34. },
  35. data () {
  36. return {
  37. description: {
  38. value: '',
  39. loading: false,
  40. error: ''
  41. }
  42. }
  43. },
  44. computed: {},
  45. methods: {
  46. saveDescription () {
  47. this.description.error = ''
  48. this.description.loading = true
  49. this.axios
  50. .put('/api/v1/user/' + this.$store.state.username, {
  51. description: this.description.value
  52. })
  53. .then(res => {
  54. this.description.loading = false
  55. })
  56. .catch(e => {
  57. this.description.loading = false
  58. AjaxErrorHandler(this.$store)(e, error => {
  59. this.description.error = error.message
  60. })
  61. })
  62. }
  63. },
  64. created () {
  65. this.$store.dispatch('setTitle', 'general settings')
  66. this.$nextTick(() => {
  67. this.axios
  68. .get('/api/v1/user/' + this.$store.state.username)
  69. .then(res => {
  70. this.description.value = res.data.description || ''
  71. })
  72. .catch(e => {
  73. AjaxErrorHandler(this.$store)(e)
  74. })
  75. })
  76. }
  77. }
  78. </script>
  79. <style lang='scss' scoped>
  80. @import '../../assets/scss/variables.scss';
  81. </style>