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 7e27063872981d9dea766c1994ee3e2a62d1ef2d..d9d9cbe45efb58aa31bffbccea3a91f8c4750069 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 d401f3daeb1e764201ea68204bac60107952ee23..3a186c37bce988f292f7cd979f8086c4a2393b59 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() + }) } }) })