From 617200f3aebbed6c8405367280a567d526e0bc80 Mon Sep 17 00:00:00 2001 From: tobias <thinkdifferent055@gmail.com> Date: Sun, 21 Nov 2021 20:08:23 +0100 Subject: [PATCH] #174 - Show error messages on remote connection failed --- .../resources/plugin/webapi/lang/base_de.properties | 2 ++ .../de/tobias/playpad/plugin/api/WebApiPlugin.scala | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/resources/plugin/webapi/lang/base_de.properties b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/resources/plugin/webapi/lang/base_de.properties index 7e270638..d9d9cbe4 100644 --- a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/resources/plugin/webapi/lang/base_de.properties +++ b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/resources/plugin/webapi/lang/base_de.properties @@ -13,6 +13,8 @@ webapi-settings.remote.port=Port webapi-settings.remote.add=Hinzuf\u00FCgen webapi-settings.remote.remove=L\u00F6schen +webapi-settings.remote.error.connection=Fehler beim Verbinden zu PlayWall {} ({}) + Trigger.RemoteCart.Name=Remote Kachel remotetrigger.label.action=Aktion f\u00FCr Kacheln: diff --git a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala index d401f3da..3a186c37 100644 --- a/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala +++ b/PlayWallPlugins/PlayWallPluginWebAPI/src/main/scala/de/tobias/playpad/plugin/api/WebApiPlugin.scala @@ -7,15 +7,19 @@ import de.thecodelabs.storage.settings.{Storage, StorageTypes} import de.thecodelabs.utils.application.ApplicationUtils import de.thecodelabs.utils.application.container.PathType import de.thecodelabs.utils.threading.Worker +import de.thecodelabs.utils.ui.Alerts import de.thecodelabs.utils.util.Localization import de.tobias.playpad.PlayPadPlugin import de.tobias.playpad.api.{PlayPadClient, PlayPadClientImpl} +import de.tobias.playpad.plugin.api.WebApiPlugin.connectToRemoteInstances import de.tobias.playpad.plugin.api.client.WebApiRemoteConnectionStateListener import de.tobias.playpad.plugin.api.settings.{WebApiRemoteSettings, WebApiSettings, WebApiSettingsViewController} import de.tobias.playpad.plugin.api.websocket.WebSocketHandler import de.tobias.playpad.plugin.api.websocket.listener.{PadStatusListener, ProjectListener} import de.tobias.playpad.plugin.{Module, PlayPadPluginStub} +import javafx.application.Platform import javafx.collections.{FXCollections, ObservableMap} +import javafx.scene.control.Alert.AlertType import spark.{Request, Response, Spark} import java.nio.file.{Files, Path} @@ -54,6 +58,7 @@ class WebApiPlugin extends PlayPadPluginStub with PluginArtifact { Logger.info(f"Start WebAPI on port ${webApiSettings.getPort}") } + connectToRemoteInstances(webApiSettings) PlayPadPlugin.getInstance().addGlobalSettingsTab(() => new WebApiSettingsViewController(webApiSettings)) PlayPadPlugin.getInstance().addMainViewListener(new WebApiRemoteConnectionStateListener) @@ -93,7 +98,13 @@ object WebApiPlugin { client.connect(5) Logger.info(s"Connected to remote PlayWall: ${remote.getName}") } catch { - case e: Exception => Logger.error(e) + case e: Exception => + Logger.error(e) + Platform.runLater(() => { + Alerts.getInstance().createAlert(AlertType.ERROR, null, + Localization.getString("webapi-settings.remote.error.connection", remote.getName, e.toString)) + .show() + }) } }) }) -- GitLab