SettingsGeneral.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. import logger from '../../assets/js/logger'
  30. export default {
  31. name: 'settingsGeneral',
  32. components: {
  33. FancyTextarea,
  34. LoadingButton
  35. },
  36. data () {
  37. return {
  38. description: {
  39. value: '',
  40. loading: false,
  41. error: ''
  42. }
  43. }
  44. },
  45. computed: {},
  46. methods: {
  47. saveDescription () {
  48. this.description.error = ''
  49. this.description.loading = true
  50. this.axios
  51. .put('/api/v1/user/' + this.$store.state.username, {
  52. description: this.description.value
  53. })
  54. .then(res => {
  55. this.description.loading = false
  56. })
  57. .catch(e => {
  58. this.description.loading = false
  59. AjaxErrorHandler(this.$store)(e, error => {
  60. this.description.error = error.message
  61. })
  62. })
  63. }
  64. },
  65. created () {
  66. this.$store.dispatch('setTitle', 'general settings')
  67. this.$nextTick(() => {
  68. this.axios
  69. .get('/api/v1/user/' + this.$store.state.username)
  70. .then(res => {
  71. this.description.value = res.data.description || ''
  72. })
  73. .catch(e => {
  74. AjaxErrorHandler(this.$store)(e)
  75. })
  76. })
  77. logger('settingsGeneral')
  78. }
  79. }
  80. </script>
  81. <style lang='scss' scoped>
  82. @media (max-width: 420px) {
  83. .h1 {
  84. display: none;
  85. }
  86. }
  87. </style>