diff --git a/assets/css/opencast.scss b/assets/css/opencast.scss index b433b250d..8f2b9703e 100644 --- a/assets/css/opencast.scss +++ b/assets/css/opencast.scss @@ -717,6 +717,11 @@ h2.oc--loadingbar, .oc--loadingbar-title { text-align: right; margin-right: 10px; } + + .oc--admin--server-icons { + float: left; + margin-top: 8px; + } } .oc--admin--server-data { diff --git a/lib/Models/Config.php b/lib/Models/Config.php index 2426442fe..10c7fefca 100644 --- a/lib/Models/Config.php +++ b/lib/Models/Config.php @@ -189,13 +189,24 @@ public function updateEndpoints($container) $comp = $services_client->getRESTComponents(); } catch(\Exception $e) { - return [ - 'type' => 'error', - 'text' => sprintf( - _('%s'), - $e->getMessage() - ) - ]; + if (str_starts_with($e->getMessage(), 'cURL error 6')) { + return [ + 'type' => 'error', + 'text' => sprintf( + _('Die angegebene URL %s konnte nicht gefunden werden. Überprüfen Sie bitte ihre Eingabe und versuchen Sie es erneut.'), + $service_host + ) + ]; + } + else { + return [ + 'type' => 'error', + 'text' => sprintf( + _('%s'), + $e->getMessage() + ) + ]; + } } } catch (AccessDeniedException $e) { Endpoints::removeEndpoint($this->id, 'services'); @@ -203,7 +214,7 @@ public function updateEndpoints($container) $message = [ 'type' => 'error', 'text' => sprintf( - _('Fehlerhafte Zugangsdaten für die Opencast Installation mit der URL "%s". Überprüfen Sie bitte die eingebenen Daten.'), + _('Fehlerhafte Zugangsdaten für die Opencast Installation mit der URL "%s". Überprüfen Sie bitte die eingegebenen Daten.'), $service_host ) ]; @@ -252,8 +263,6 @@ public function updateEndpoints($container) 'type' => 'success', 'text' => implode('', $success_message) ]; - - $config_checked = true; } } else { $message = [ diff --git a/lib/Routes/Config/ConfigAdd.php b/lib/Routes/Config/ConfigAdd.php index dfcf39f26..51a52450d 100644 --- a/lib/Routes/Config/ConfigAdd.php +++ b/lib/Routes/Config/ConfigAdd.php @@ -25,7 +25,6 @@ public function __invoke(Request $request, Response $response, $args) $json = $this->getRequestData($request); - $config_checked = false; $duplicate_url = false; // check, if a config with the same data already exists: @@ -68,7 +67,7 @@ public function __invoke(Request $request, Response $response, $args) $ret_config = array_merge($ret_config, $ret_config['settings']); unset($ret_config['settings']); - if ($config_checked) { + if ($message['type'] == 'success') { $lti = LtiHelper::getLaunchData($config->id); return $this->createResponse([ diff --git a/lib/Routes/Config/ConfigEdit.php b/lib/Routes/Config/ConfigEdit.php index b994a1ae9..705b1c545 100644 --- a/lib/Routes/Config/ConfigEdit.php +++ b/lib/Routes/Config/ConfigEdit.php @@ -24,7 +24,6 @@ public function __invoke(Request $request, Response $response, $args) $json = $this->getRequestData($request); - $config_checked = false; $duplicate_url = false; $config = Config::find($args['id']); @@ -49,7 +48,7 @@ public function __invoke(Request $request, Response $response, $args) $ret_config = array_merge($ret_config, $ret_config['settings']); unset($ret_config['settings']); - if ($config_checked) { + if ($message['type'] == 'success') { $lti = LtiHelper::getLaunchData($config->id); return $this->createResponse([ diff --git a/vueapp/components/Config/EditServer.vue b/vueapp/components/Config/EditServer.vue index 778ff99f0..a0554cc4b 100644 --- a/vueapp/components/Config/EditServer.vue +++ b/vueapp/components/Config/EditServer.vue @@ -26,7 +26,7 @@ @updateValue="updateValue" /> - + @@ -34,7 +34,7 @@ - { this.disabled = false; @@ -193,10 +198,10 @@ export default { deleteConfig() { if (confirm(this.$gettext('Sind Sie sicher, dass Sie die Serverkonfiguration löschen möchten? Die damit verbundenen Videos werden danach nicht mehr in Stud.IP zur Verfügung stehen!'))) { - if (this.id == 'new') { + if (this.currentId == 'new') { this.currentConfig = {} } else { - this.$store.dispatch('configDelete', this.id) + this.$store.dispatch('configDelete', this.currentId) .then(() => { this.$store.dispatch('configListRead'); this.$store.dispatch('addMessage', { @@ -212,43 +217,88 @@ export default { }, checkConfigResponse(data) { - if (data.lti !== undefined) { - this.checkLti(data.lti); - } if (data.message !== undefined) { - this.$store.dispatch('addMessage', { - type: data.message.type, - text: data.message.text - }); + if (data.message.type === 'error') { + this.$store.dispatch('addMessage', { + type: data.message.type, + text: data.message.text + }); + return; + } + else if (data.message.type === 'success') { + // Check if LTI connection is available + let lti_checked = false; + this.checkLti(data.lti).then((result) => { + lti_checked = result; + }); + + if (this.currentId !== 'new') { + // Just show success message if server was edited + this.$store.dispatch('addMessage', { + type: data.message.type, + text: data.message.text + }); + } + else { + // On create, scroll to the default workflow configuration + this.$store.dispatch('addMessage', { + type: data.message.type, + text: data.message.text + ' Sie können nun die Standardworkflows einstellen oder die Konfiguration abschließen.' + }); + + this.newId = data.config.id; + this.$store.dispatch('simpleConfigListRead'); - if(data.message.type == 'success'){ - this.$emit('close'); + let view = this; + // We need to wait for a short time so the component is actually visible + setTimeout(() => { + view.$refs['workflow-form'].$el.scrollIntoView({ + behavior: 'smooth' + }); + }, 10); + } + + if (!lti_checked) { + // Show LTI error + this.postLtiCheckFailedMessage(); + } + else if (this.currentId !== 'new') { + // Only close dialog, if lti successfull and no new server was created + this.$emit('close'); + } + + return; } } + + this.$store.dispatch('addMessage', { + type: 'error', + text: this.$gettext('Bei der Konfiguration ist ein Fehler aufgetreten. Versuchen Sie es bitte erneut.') + }); }, async checkLti(data) { - let view = this; - await this.$store.dispatch('authenticateLti'); // make an lti call to make sure it worked, there are some caveats though... // - already succesful calls will not be revoked // - unsuccesful calls will persist even if it worked now - axios({ - url: data[0].launch_url, - method: "GET", - withCredentials: true, - }).then(({ data }) => { - if (data.user_id == undefined) { - view.postLtiCheckFailedMessage(); + try { + const response = await axios({ + url: data[0].launch_url, + method: "GET", + withCredentials: true, + }); + + if (response.user_id == undefined) { + return false; } else { - view.postLtiCheckSucceededMessage(); + return true; } - }).catch(function (error) { - view.postLtiCheckFailedMessage(); - }); + } catch (error) { + return false; + } }, postLtiCheckFailedMessage() @@ -264,14 +314,6 @@ export default { }); }, - postLtiCheckSucceededMessage() - { - this.$store.dispatch('addMessage', { - type: 'success', - text: this.$gettext('Die LTI-Konfiguration wurde erfolgreich überprüft!') - }); - }, - updateValue(setting, newValue) { this.currentConfig[setting.name] = newValue; }, @@ -280,9 +322,9 @@ export default { mounted() { this.$store.dispatch('clearMessages'); - if (this.id !== 'new') { + if (this.currentId !== 'new') { if (!this.config) { - this.$store.dispatch('configRead', this.id) + this.$store.dispatch('configRead', this.currentId) .then(() => { this.currentConfig = this.configStore; }); diff --git a/vueapp/components/Config/ServerCard.vue b/vueapp/components/Config/ServerCard.vue index 5cf15dd3e..b54e4e36e 100644 --- a/vueapp/components/Config/ServerCard.vue +++ b/vueapp/components/Config/ServerCard.vue @@ -2,10 +2,13 @@ - + #{{ config.id }} - + + + + + @@ -27,13 +30,16 @@