From 0bd69be42b242b651c25410d0cb6646042b7ff81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Sat, 25 Jan 2020 15:48:45 +0100 Subject: Fetch demo servers only when requested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/components/AdminSettings.vue | 49 ++++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/components/AdminSettings.vue b/src/components/AdminSettings.vue index 5515cbe2..b8fb644b 100644 --- a/src/components/AdminSettings.vue +++ b/src/components/AdminSettings.vue @@ -71,16 +71,32 @@
-
-
-

{{ t('richdocuments', 'You can use a demo server provided by Collabora and other service providers for giving Collabora Online a try.') }}

-

+ :disabled="updating" @input="fetchDemoServers"> +
+

+ {{ t('richdocuments', 'You can use a demo server provided by Collabora and other service providers for giving Collabora Online a try.') }} +

+
+

+ {{ t('richdocuments', 'Loading available demo servers …') }} +

+

+

+ {{ t('richdocuments', 'No available demo servers found.') }} +

+ +

+ + {{ t('richdocuments', 'Documents opened with the demo server configured will be sent to a 3rd party server. Only use this for evaluating Collabora Online.') }}
+ {{ providerDescription }} +
+

@@ -196,8 +212,9 @@ export default { }, data() { return { - serverMode: 'custom', + serverMode: '', serverError: SERVER_STATE_OK, + demoServers: null, updating: false, groups: [], tags: [], @@ -227,8 +244,8 @@ export default { } }, computed: { - demoServers() { - return this.initial.demo_servers + providerDescription() { + return t('richdocuments', 'Contact {0} to get an own installation.', [this.settings.demoUrl.provider_name]) }, isSetup() { return this.serverError === SERVER_STATE_OK @@ -261,9 +278,18 @@ export default { this.uiVisible.canonical_webroot = this.settings.canonical_webroot !== '' this.uiVisible.external_apps = this.settings.external_apps !== '' + this.demoServers = this.initial.demo_servers this.checkIfDemoServerIsActive() }, methods: { + async fetchDemoServers() { + try { + const result = await axios.get(generateUrl('/apps/richdocuments/settings/demo')) + this.demoServers = result.data + } catch (e) { + this.demoServers = [] + } + }, update() { this.updating = true let settings = this.settings @@ -271,7 +297,7 @@ export default { this.updating = false }).catch((error) => { this.updating = false - OC.Notification.showTemporary('Failed to save settings') + OC.Notification.showTemporary(t('richdocuments', 'Failed to save settings')) console.error(error) }) }, @@ -348,7 +374,10 @@ export default { } }, checkIfDemoServerIsActive() { - this.settings.demoUrl = this.initial.demo_servers.find((server) => server.demo_url === this.settings.wopi_url) + this.settings.demoUrl = this.demoServers.find((server) => server.demo_url === this.settings.wopi_url) + if (this.settings.wopi_url !== '') { + this.serverMode = 'custom' + } if (this.settings.demoUrl) { this.serverMode = 'demo' } -- cgit v1.2.3