From 8970f0d4176ec0702303712ee0b3b82b47171f26 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 30 Aug 2020 00:39:08 -0400 Subject: [PATCH] update connector button progress --- .../com/rusefi/server/SessionDetails.java | 1 - .../com/rusefi/tools/online/ProxyClient.java | 3 +- .../rusefi/tools/online/PublicSession.java | 8 ++++- .../java/com/rusefi/ts_plugin/RemoteTab.java | 36 ++++++++++--------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/java_console/io/src/main/java/com/rusefi/server/SessionDetails.java b/java_console/io/src/main/java/com/rusefi/server/SessionDetails.java index 7c56bc99cc..48d4ab125a 100644 --- a/java_console/io/src/main/java/com/rusefi/server/SessionDetails.java +++ b/java_console/io/src/main/java/com/rusefi/server/SessionDetails.java @@ -77,7 +77,6 @@ public class SessionDetails { String authToken = (String) jsonObject.get(AUTH_TOKEN); long oneTimeCode = (Long) jsonObject.get(VEHICLE_TOKEN); long connectorVersion = (long) jsonObject.get(CONNECTOR_VERSION); - String age = (String) jsonObject.get(AGE); NetworkConnector.Implementation implementation = NetworkConnector.Implementation.find((String) jsonObject.get(IMPLEMENTATION)); ControllerInfo controllerInfo = ControllerInfo.valueOf((String) jsonObject.get(CONTROLLER)); diff --git a/java_console/io/src/main/java/com/rusefi/tools/online/ProxyClient.java b/java_console/io/src/main/java/com/rusefi/tools/online/ProxyClient.java index 03d0c8c6d7..15f07cf4ba 100644 --- a/java_console/io/src/main/java/com/rusefi/tools/online/ProxyClient.java +++ b/java_console/io/src/main/java/com/rusefi/tools/online/ProxyClient.java @@ -56,7 +56,8 @@ public class ProxyClient { boolean isUsed = (Boolean) element.get(IS_USED); String ownerName = (String) element.get(OWNER); String age = (String) element.get(SessionDetails.AGE); - userLists.add(new PublicSession(vehicleOwner, ci, isUsed, ownerName, age)); + String implementation = (String) element.get(SessionDetails.IMPLEMENTATION); + userLists.add(new PublicSession(vehicleOwner, ci, isUsed, ownerName, age, implementation)); } System.out.println("object=" + array); diff --git a/java_console/io/src/main/java/com/rusefi/tools/online/PublicSession.java b/java_console/io/src/main/java/com/rusefi/tools/online/PublicSession.java index b2fc0f0347..99ca3c8236 100644 --- a/java_console/io/src/main/java/com/rusefi/tools/online/PublicSession.java +++ b/java_console/io/src/main/java/com/rusefi/tools/online/PublicSession.java @@ -15,13 +15,19 @@ public class PublicSession { */ private final String tunerName; private final String age; + private final String implementation; - public PublicSession(UserDetails vehicleOwner, ControllerInfo controllerInfo, boolean isUsed, String tunerName, String age) { + public PublicSession(UserDetails vehicleOwner, ControllerInfo controllerInfo, boolean isUsed, String tunerName, String age, String implementation) { this.vehicleOwner = vehicleOwner; this.controllerInfo = controllerInfo; this.isUsed = isUsed; this.tunerName = tunerName; this.age = age; + this.implementation = implementation; + } + + public String getImplementation() { + return implementation; } public String getAge() { diff --git a/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java b/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java index 30dc22244c..bf617d4bb9 100644 --- a/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java +++ b/java_tools/ts_plugin/src/main/java/com/rusefi/ts_plugin/RemoteTab.java @@ -173,36 +173,38 @@ public class RemoteTab { if (publicSession.isUsed()) { bottomPanel.add(new JLabel(" Used by " + publicSession.getTunerName())); } else { - JButton connect = new JButton("Connect to " + publicSession.getVehicleOwner().getUserName()); + JButton connect = new JButton("Connect to " + publicSession.getVehicleOwner().getUserName() + " ECU"); connect.addActionListener(event -> connectToProxy(publicSession)); bottomPanel.add(connect); if (InstanceAuthContext.isOurController(publicSession.getVehicleOwner().getUserId())) { - JButton updateSoftware = new JButton("Update Connector"); - updateSoftware.addActionListener(new AbstractAction() { - @Override - public void actionPerformed(ActionEvent e) { - try { - LocalApplicationProxy.requestSoftwareUpdate(HttpUtil.PROXY_JSON_API_HTTP_PORT, - getApplicationRequest(publicSession)); - } catch (IOException ioException) { - ioException.printStackTrace(); - } - } - }); - bottomPanel.add(updateSoftware); - } + if (publicSession.getImplementation().equals(NetworkConnector.Implementation.SBC.name())) { + + JButton updateSoftware = new JButton("Update Remote Connector Software"); + updateSoftware.addActionListener(new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + try { + LocalApplicationProxy.requestSoftwareUpdate(HttpUtil.PROXY_JSON_API_HTTP_PORT, + getApplicationRequest(publicSession)); + updateSoftware.setText("Update requested"); + } catch (IOException ioException) { + ioException.printStackTrace(); + } + } + }); + bottomPanel.add(updateSoftware); + } + } } JPanel userPanel = new JPanel(new BorderLayout()); - JPanel infoLine = new JPanel(new FlowLayout()); infoLine.add(new JLabel("Age " + publicSession.getAge())); infoLine.add(getSignatureDownload(controllerInfo)); - userPanel.add(topLine, BorderLayout.NORTH); userPanel.add(infoLine, BorderLayout.CENTER); userPanel.add(bottomPanel, BorderLayout.SOUTH);