You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.2 KiB

  1. <template lang='pug'>
  2. v-container(fluid, grid-list-lg)
  3. v-layout(row, wrap)
  4. v-flex(xs12)
  5. .admin-header
  6. img.animated.fadeInUp(src='/_assets/svg/icon-winter.svg', alt='Mail', style='width: 80px;')
  7. .admin-header-title
  8. .headline.primary--text.animated.fadeInLeft {{ $t('admin:webhooks.title') }}
  9. .subtitle-1.grey--text.animated.fadeInLeft.wait-p4s {{ $t('admin:webhooks.subtitle') }}
  10. v-spacer
  11. v-btn.animated.fadeInDown(color='success', depressed, @click='save', large, disabled)
  12. v-icon(left) check
  13. span {{$t('common:actions.apply')}}
  14. v-flex(lg3, xs12)
  15. v-card.animated.fadeInUp
  16. v-toolbar(flat, color='primary', dark, dense)
  17. .subtitle-1 Webhooks
  18. v-spacer
  19. v-btn(outline, small)
  20. v-icon.mr-2 add
  21. span New
  22. v-list(two-line, dense).py-0
  23. template(v-for='(str, idx) in hooks')
  24. v-list-item(:key='str.key', @click='selectedHook = str.key')
  25. v-list-item-avatar
  26. v-icon(color='primary', v-if='str.isEnabled', v-ripple, @click='str.isEnabled = false') check_box
  27. v-icon(color='grey', v-else, v-ripple, @click='str.isEnabled = true') check_box_outline_blank
  28. v-list-item-content
  29. v-list-item-title.body-2(:class='!str.isAvailable ? `grey--text` : (selectedHook === str.key ? `primary--text` : ``)') {{ str.title }}
  30. v-list-item-sub-title.caption(:class='!str.isAvailable ? `grey--text text--lighten-1` : (selectedHook === str.key ? `blue--text ` : ``)') {{ str.description }}
  31. v-list-item-avatar(v-if='selectedHook === str.key')
  32. v-icon.animated.fadeInLeft(color='primary') arrow_forward_ios
  33. v-divider(v-if='idx < hooks.length - 1')
  34. v-flex(xs12, lg9)
  35. v-card.wiki-form.animated.fadeInUp.wait-p2s
  36. v-toolbar(color='primary', dense, flat, dark)
  37. .subtitle-1 {{hook.title}}
  38. v-card-text
  39. v-form
  40. .authlogo
  41. img(:src='hook.logo', :alt='hook.title')
  42. .caption.pt-3 {{hook.description}}
  43. .caption.pb-3: a(:href='hook.website') {{hook.website}}
  44. .body-2(v-if='hook.isEnabled')
  45. span This hook is
  46. </template>
  47. <script>
  48. import _ from 'lodash'
  49. // import { get } from 'vuex-pathify'
  50. import mailConfigQuery from 'gql/admin/mail/mail-query-config.gql'
  51. import mailUpdateConfigMutation from 'gql/admin/mail/mail-mutation-save-config.gql'
  52. export default {
  53. data() {
  54. return {
  55. hooks: [],
  56. selectedHook: ''
  57. }
  58. },
  59. computed: {
  60. hook() {
  61. return _.find(this.hooks, ['id', this.selectedHook]) || {}
  62. }
  63. },
  64. methods: {
  65. async save () {
  66. try {
  67. await this.$apollo.mutate({
  68. mutation: mailUpdateConfigMutation,
  69. variables: {
  70. senderName: this.config.senderName || '',
  71. senderEmail: this.config.senderEmail || '',
  72. host: this.config.host || '',
  73. port: _.toSafeInteger(this.config.port) || 0,
  74. secure: this.config.secure || false,
  75. user: this.config.user || '',
  76. pass: this.config.pass || '',
  77. useDKIM: this.config.useDKIM || false,
  78. dkimDomainName: this.config.dkimDomainName || '',
  79. dkimKeySelector: this.config.dkimKeySelector || '',
  80. dkimPrivateKey: this.config.dkimPrivateKey || ''
  81. },
  82. watchLoading (isLoading) {
  83. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-mail-update')
  84. }
  85. })
  86. this.$store.commit('showNotification', {
  87. style: 'success',
  88. message: 'Configuration saved successfully.',
  89. icon: 'check'
  90. })
  91. } catch (err) {
  92. this.$store.commit('pushGraphError', err)
  93. }
  94. }
  95. },
  96. apollo: {
  97. hooks: {
  98. query: mailConfigQuery,
  99. fetchPolicy: 'network-only',
  100. update: (data) => _.cloneDeep(data.mail.config),
  101. watchLoading (isLoading) {
  102. this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-mail-refresh')
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang='scss'>
  109. </style>