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 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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('federatedfilesharing', 'Federated Cloud Sharing')"
  24. :description="t('federatedfilesharing', 'Adjust how people can share between servers. This includes shares between users on this server as well if they are using federated sharing.')"
  25. :doc-url="sharingFederatedDocUrl">
  26. <CheckboxRadioSwitch type="switch"
  27. :checked.sync="outgoingServer2serverShareEnabled"
  28. @update:checked="update('outgoing_server2server_share_enabled', outgoingServer2serverShareEnabled)">
  29. {{ t('federatedfilesharing', 'Allow users on this server to send shares to other servers (this option also allows WebDAV access to public shares)') }}
  30. </CheckboxRadioSwitch>
  31. <CheckboxRadioSwitch type="switch"
  32. :checked.sync="incomingServer2serverShareEnabled"
  33. @update:checked="update('incoming_server2server_share_enabled', incomingServer2serverShareEnabled)">
  34. {{ t('federatedfilesharing', 'Allow users on this server to receive shares from other servers') }}
  35. </CheckboxRadioSwitch>
  36. <CheckboxRadioSwitch v-if="federatedGroupSharingSupported"
  37. type="switch"
  38. :checked.sync="outgoingServer2serverGroupShareEnabled"
  39. @update:checked="update('outgoing_server2server_group_share_enabled', outgoingServer2serverGroupShareEnabled)">
  40. {{ t('federatedfilesharing', 'Allow users on this server to send shares to groups on other servers') }}
  41. </CheckboxRadioSwitch>
  42. <CheckboxRadioSwitch v-if="federatedGroupSharingSupported"
  43. type="switch"
  44. :checked.sync="incomingServer2serverGroupShareEnabled"
  45. @update:checked="update('incoming_server2server_group_share_enabled', incomingServer2serverGroupShareEnabled)">
  46. {{ t('federatedfilesharing', 'Allow users on this server to receive group shares from other servers') }}
  47. </CheckboxRadioSwitch>
  48. <CheckboxRadioSwitch type="switch"
  49. :checked.sync="lookupServerEnabled"
  50. @update:checked="update('lookupServerEnabled', lookupServerEnabled)">
  51. {{ t('federatedfilesharing', 'Search global and public address book for users') }}
  52. </CheckboxRadioSwitch>
  53. <CheckboxRadioSwitch type="switch"
  54. :checked.sync="lookupServerUploadEnabled"
  55. @update:checked="update('lookupServerUploadEnabled', lookupServerUploadEnabled)">
  56. {{ t('federatedfilesharing', 'Allow users to publish their data to a global and public address book') }}
  57. </CheckboxRadioSwitch>
  58. </SettingsSection>
  59. </template>
  60. <script>
  61. import CheckboxRadioSwitch from '@nextcloud/vue/dist/Components/CheckboxRadioSwitch'
  62. import SettingsSection from '@nextcloud/vue/dist/Components/SettingsSection'
  63. import { loadState } from '@nextcloud/initial-state'
  64. import { showError } from '@nextcloud/dialogs'
  65. import axios from '@nextcloud/axios'
  66. import { generateOcsUrl } from '@nextcloud/router'
  67. import confirmPassword from '@nextcloud/password-confirmation'
  68. export default {
  69. name: 'AdminSettings',
  70. components: {
  71. CheckboxRadioSwitch,
  72. SettingsSection,
  73. },
  74. data() {
  75. return {
  76. outgoingServer2serverShareEnabled: loadState('federatedfilesharing', 'outgoingServer2serverShareEnabled'),
  77. incomingServer2serverShareEnabled: loadState('federatedfilesharing', 'incomingServer2serverShareEnabled'),
  78. outgoingServer2serverGroupShareEnabled: loadState('federatedfilesharing', 'outgoingServer2serverGroupShareEnabled'),
  79. incomingServer2serverGroupShareEnabled: loadState('federatedfilesharing', 'incomingServer2serverGroupShareEnabled'),
  80. federatedGroupSharingSupported: loadState('federatedfilesharing', 'federatedGroupSharingSupported'),
  81. lookupServerEnabled: loadState('federatedfilesharing', 'lookupServerEnabled'),
  82. lookupServerUploadEnabled: loadState('federatedfilesharing', 'lookupServerUploadEnabled'),
  83. internalOnly: loadState('federatedfilesharing', 'internalOnly'),
  84. sharingFederatedDocUrl: loadState('federatedfilesharing', 'sharingFederatedDocUrl'),
  85. }
  86. },
  87. methods: {
  88. async update(key, value) {
  89. await confirmPassword()
  90. const url = generateOcsUrl('/apps/provisioning_api/api/v1/config/apps/{appId}/{key}', {
  91. appId: 'files_sharing',
  92. key,
  93. })
  94. const stringValue = value ? 'yes' : 'no'
  95. try {
  96. const { data } = await axios.post(url, {
  97. value: stringValue,
  98. })
  99. this.handleResponse({
  100. status: data.ocs?.meta?.status,
  101. })
  102. } catch (e) {
  103. this.handleResponse({
  104. errorMessage: t('federatedfilesharing', 'Unable to update federated files sharing config'),
  105. error: e,
  106. })
  107. }
  108. },
  109. async handleResponse({ status, errorMessage, error }) {
  110. if (status !== 'ok') {
  111. showError(errorMessage)
  112. console.error(errorMessage, error)
  113. }
  114. },
  115. }
  116. }
  117. </script>