-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy pathbuiltInCode.ts
More file actions
36 lines (31 loc) · 1.26 KB
/
builtInCode.ts
File metadata and controls
36 lines (31 loc) · 1.26 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
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { generateUrl } from '@nextcloud/router'
import { getCapabilities, capabilitiesService } from './capabilities'
import axios from '@nextcloud/axios'
const wopiUrl = getCapabilities()?.config?.wopi_url
const isConfigured = wopiUrl !== ''
const appWebRoots = window._oc_appswebroots
const isCodeInstalled = appWebRoots?.richdocumentscode !== undefined || appWebRoots?.richdocumentscode_arm64 !== undefined
const shouldAutoSetupCode = !isConfigured && isCodeInstalled
const autoSetupBuiltInCodeServerIfNeeded = async () => {
if (!isCodeInstalled || !shouldAutoSetupCode || !window.oc_isadmin) {
return
}
const result = await axios.get(generateUrl('apps/richdocuments/autosetup'))
if (result?.data?.capabilities) {
capabilitiesService.setCapabilities(result?.data?.capabilities)
} else {
const { showError } = await import('@nextcloud/dialogs')
showError('Could not autoconfigure built-in CODE server, click to open the admin settings for further details: ' + result?.data?.message, {
onClick: () => {
window.location.href = generateUrl('settings/admin/richdocuments')
},
})
}
}
export {
autoSetupBuiltInCodeServerIfNeeded,
}