added link to QR-Code for opening plan on mobile devices

This commit is contained in:
Stephan Richter
2020-10-11 14:17:00 +02:00
parent 7774b10871
commit 412e31e0c4
4 changed files with 13 additions and 7 deletions

View File

@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.srsoftware</groupId> <groupId>de.srsoftware</groupId>
<artifactId>web4rail</artifactId> <artifactId>web4rail</artifactId>
<version>0.6.4</version> <version>0.6.5</version>
<name>Web4Rail</name> <name>Web4Rail</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<description>Java Model Railway Control</description> <description>Java Model Railway Control</description>

View File

@@ -178,8 +178,11 @@ function request(data){
function runAction(ev){ function runAction(ev){
var clicked = ev.target; var clicked = ev.target;
var realm = clicked.hasAttribute('class') ? clicked.getAttribute('class') : null; var realm = clicked.hasAttribute('class') ? clicked.getAttribute('class') : null;
//console.log("runAction: ",{action: clicked.id, realm:realm}); console.log("runAction: ",{action: clicked.id, realm:realm});
return request({action:ev.target.id,realm:realm}); // TODO: ask for name if (clicked.id == 'qrcode'){
window.open("https://api.qrserver.com/v1/create-qr-code/?data="+window.location.href,'_blank');
return false;
} else return request({action:ev.target.id,realm:realm}); // TODO: ask for name
} }
function stream(ev){ function stream(ev){

View File

@@ -8,6 +8,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.URI; import java.net.URI;
import java.net.URLDecoder; import java.net.URLDecoder;
@@ -48,7 +49,7 @@ public class Application implements Constants{
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
plan = new Plan(); plan = new Plan();
} }
Desktop.getDesktop().browse(URI.create("http://localhost:"+config.getInt(PORT)+"/plan")); Desktop.getDesktop().browse(URI.create("http://"+InetAddress.getLocalHost().getHostName()+":"+config.getInt(PORT)+"/plan"));
} }
private static Object handle(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { private static Object handle(HashMap<String, String> params) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {

View File

@@ -95,6 +95,7 @@ public class Plan implements Constants{
private static final String Y = "y"; private static final String Y = "y";
private static final String DIRECTION = "direction"; private static final String DIRECTION = "direction";
private static final HashMap<OutputStreamWriter,Integer> clients = new HashMap<OutputStreamWriter, Integer>(); private static final HashMap<OutputStreamWriter,Integer> clients = new HashMap<OutputStreamWriter, Integer>();
private static final String ACTION_QR = "qrcode";
public HashMap<String,Tile> tiles = new HashMap<String,Tile>(); public HashMap<String,Tile> tiles = new HashMap<String,Tile>();
private HashSet<Block> blocks = new HashSet<Block>(); private HashSet<Block> blocks = new HashSet<Block>();
@@ -112,9 +113,10 @@ public class Plan implements Constants{
private Tag actionMenu() throws IOException { private Tag actionMenu() throws IOException {
Tag actionMenu = new Tag("div").clazz("actions").content(t("Actions")); Tag actionMenu = new Tag("div").clazz("actions").content(t("Actions"));
Tag actions = new Tag("div").clazz("list").content(""); Tag actions = new Tag("div").clazz("list").content("");
new Div("power").clazz(REALM_CU).content(t("Toggle power")).addTo(actions); new Div(ACTION_POWER).clazz(REALM_CU).content(t("Toggle power")).addTo(actions);
new Div("save").clazz(REALM_PLAN).content(t("Save plan")).addTo(actions); new Div(ACTION_SAVE).clazz(REALM_PLAN).content(t("Save plan")).addTo(actions);
new Div("analyze").clazz(REALM_PLAN).content(t("Analyze plan")).addTo(actions); new Div(ACTION_ANALYZE).clazz(REALM_PLAN).content(t("Analyze plan")).addTo(actions);
new Div(ACTION_QR).clazz(REALM_PLAN).content(t("QR-Code")).addTo(actions);
return actions.addTo(actionMenu); return actions.addTo(actionMenu);
} }