-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathSettingsServer.vue
More file actions
65 lines (60 loc) · 1.84 KB
/
SettingsServer.vue
File metadata and controls
65 lines (60 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!--
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<NcSettingsSection
:name="t('firstrunwizard', 'Server address')"
:description="t('firstrunwizard', 'Use this link to connect your apps and desktop client to this server:')">
<NcInputField
id="endpoint-url"
:class="$style.input"
:label="t('firstrunwizard', 'Server address')"
show-trailing-button
readonly
:model-value="url"
@trailing-button-click="onCopyContent">
<template #trailing-button-icon>
<NcIconSvgWrapper :path="copyIcon" />
</template>
</NcInputField>
</NcSettingsSection>
</template>
<script setup lang="ts">
import { mdiCheck, mdiContentCopy } from '@mdi/js'
import { showSuccess } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import { getBaseUrl } from '@nextcloud/router'
import { ref } from 'vue'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import NcInputField from '@nextcloud/vue/components/NcInputField'
import NcSettingsSection from '@nextcloud/vue/components/NcSettingsSection'
const url = getBaseUrl()
const copyIcon = ref(mdiContentCopy)
const pendingTimeout = ref(0)
/**
* Copy the base URL to the clipboard
*/
function onCopyContent() {
try {
window.navigator.clipboard.writeText(url)
showSuccess(t('firstrunwizard', 'URL copied'))
// Reset pending resets
if (pendingTimeout.value) {
window.clearTimeout(pendingTimeout.value)
}
// Update the icon to check to show success
copyIcon.value = mdiCheck
pendingTimeout.value = window.setTimeout(() => {
copyIcon.value = mdiContentCopy
}, 3000)
} catch {
window.prompt(t('firstrunwizard', 'Could not copy the URL, please copy manually'), url)
}
}
</script>
<style module>
.input {
max-width: min(50vw, 450px) !important;
}
</style>