update connector button progress

This commit is contained in:
rusefi 2020-08-30 00:39:08 -04:00
parent 23a9c490bf
commit 8970f0d417
4 changed files with 28 additions and 20 deletions

View File

@ -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));

View File

@ -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);

View File

@ -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() {

View File

@ -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);