4747
4848 <!-- Webdav URL-->
4949 <NcAppSettingsSection id =" webdav" :title =" t('files', 'Webdav')" >
50- <NcInputField type =" text" readonly =" readonly" :value =" webdavUrl" />
50+ <NcInputField id =" webdav-url-input"
51+ :show-trailing-button =" true"
52+ :success =" webdavUrlCopied"
53+ :trailing-button-label =" t('files', 'Copy to clipboard')"
54+ :value =" webdavUrl"
55+ readonly =" readonly"
56+ type =" url"
57+ @focus =" $event.target.select()"
58+ @trailing-button-click =" copyCloudId" >
59+ <template #trailing-button-icon >
60+ <Clipboard :size =" 20" />
61+ </template >
62+ </NcInputField >
5163 <em >
5264 <a :href =" webdavDocs" target =" _blank" rel =" noreferrer noopener" >
5365 {{ t('files', 'Use this address to access your Files via WebDAV') }} ↗
6173import NcAppSettingsDialog from ' @nextcloud/vue/dist/Components/NcAppSettingsDialog.js'
6274import NcAppSettingsSection from ' @nextcloud/vue/dist/Components/NcAppSettingsSection.js'
6375import NcCheckboxRadioSwitch from ' @nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
76+ import Clipboard from ' vue-material-design-icons/Clipboard.vue'
6477import NcInputField from ' @nextcloud/vue/dist/Components/NcInputField'
6578import Setting from ' ../components/Setting.vue'
6679
80+ import { emit } from ' @nextcloud/event-bus'
6781import { generateRemoteUrl , generateUrl } from ' @nextcloud/router'
6882import { getCurrentUser } from ' @nextcloud/auth'
6983import { loadState } from ' @nextcloud/initial-state'
70- import { emit } from ' @nextcloud/event-bus'
71- import axios from ' @nextcloud/axios'
84+ import { showError , showSuccess } from ' @nextcloud/dialogs'
7285import { translate } from ' @nextcloud/l10n'
86+ import axios from ' @nextcloud/axios'
7387
7488const userConfig = loadState (' files' , ' config' , {
7589 show_hidden: false ,
@@ -79,6 +93,7 @@ const userConfig = loadState('files', 'config', {
7993export default {
8094 name: ' Settings' ,
8195 components: {
96+ Clipboard,
8297 NcAppSettingsDialog,
8398 NcAppSettingsSection,
8499 NcCheckboxRadioSwitch,
@@ -104,6 +119,7 @@ export default {
104119 // Webdav infos
105120 webdavUrl: generateRemoteUrl (' dav/files/' + encodeURIComponent (getCurrentUser ()? .uid )),
106121 webdavDocs: ' https://docs.nextcloud.com/server/stable/go.php?to=user-webdav' ,
122+ webdavUrlCopied: false ,
107123 }
108124 },
109125
@@ -129,6 +145,23 @@ export default {
129145 })
130146 },
131147
148+ async copyCloudId () {
149+ document .querySelector (' input#webdav-url-input' ).select ()
150+
151+ if (! navigator .clipboard ) {
152+ // Clipboard API not available
153+ showError (t (' files' , ' Clipboard is not available' ))
154+ return
155+ }
156+
157+ await navigator .clipboard .writeText (this .webdavUrl )
158+ this .webdavUrlCopied = true
159+ showSuccess (t (' files' , ' Webdav URL copied to clipboard' ))
160+ setTimeout (() => {
161+ this .webdavUrlCopied = false
162+ }, 5000 )
163+ },
164+
132165 t: translate,
133166 },
134167}
0 commit comments