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.

AdminSettings.vue 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!--
  2. - @copyright 2022 Carl Schwan <carl@carlschwan.eu>
  3. -
  4. - @author Carl Schwan <carl@carlschwan.eu>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -
  21. -->
  22. <template>
  23. <SettingsSection :title="t('sharebymail', 'Share by mail')"
  24. :description="t('sharebymail', 'Allows users to share a personalized link to a file or folder by putting in an email address.')">
  25. <CheckboxRadioSwitch type="switch"
  26. :checked.sync="sendPasswordMail"
  27. @update:checked="update('sendpasswordmail', sendPasswordMail)">
  28. {{ t('sharebymail', 'Send password by mail') }}
  29. </CheckboxRadioSwitch>
  30. <CheckboxRadioSwitch type="switch"
  31. :checked.sync="replyToInitiator"
  32. @update:checked="update('replyToInitiator', replyToInitiator)">
  33. {{ t('sharebymail', 'Reply to initiator') }}
  34. </CheckboxRadioSwitch>
  35. </SettingsSection>
  36. </template>
  37. <script>
  38. import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/CheckboxRadioSwitch'
  39. import SettingsSection from '@nextcloud/vue/dist/Components/SettingsSection'
  40. import { loadState } from '@nextcloud/initial-state'
  41. import { showError } from '@nextcloud/dialogs'
  42. import axios from '@nextcloud/axios'
  43. import { generateOcsUrl } from '@nextcloud/router'
  44. import confirmPassword from '@nextcloud/password-confirmation'
  45. export default {
  46. name: 'AdminSettings',
  47. components: {
  48. CheckboxRadioSwitch,
  49. SettingsSection,
  50. },
  51. data() {
  52. return {
  53. sendPasswordMail: loadState('sharebymail', 'sendPasswordMail'),
  54. replyToInitiator: loadState('sharebymail', 'replyToInitiator'),
  55. }
  56. },
  57. methods: {
  58. async update(key, value) {
  59. await confirmPassword()
  60. const url = generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/{appId}/{key}', {
  61. appId: 'sharebymail',
  62. key,
  63. })
  64. const stringValue = value ? 'yes' : 'no'
  65. try {
  66. const { data } = await axios.post(url, {
  67. value: stringValue,
  68. })
  69. this.handleResponse({
  70. status: data.ocs?.meta?.status,
  71. })
  72. } catch (e) {
  73. this.handleResponse({
  74. errorMessage: t('sharebymail', 'Unable to update share by mail config'),
  75. error: e,
  76. })
  77. }
  78. },
  79. async handleResponse({ status, errorMessage, error }) {
  80. if (status !== 'ok') {
  81. showError(errorMessage)
  82. console.error(errorMessage, error)
  83. }
  84. },
  85. },
  86. }
  87. </script>