Get titles from DB

This commit is contained in:
genuineparts 2025-06-09 15:45:29 +02:00
parent 6b8a1444df
commit 9dc2c7d9d0

View file

@ -107,85 +107,96 @@ public class Main {
}
}
private static String createOutput(String user){
private static String createOutput(String user) {
List<String> title = new ArrayList<>();
try {
ResultSet rsu = MariaDB.load_user(user);
if (rsu != null) {
while (rsu.next()) {
title.add(rsu.getString("title"));
}
}
rsu.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
JSONObject dat = new JSONObject();
Date updatetime = new Date(time);
dat.put("interval",conf.getInt("refreshTime")*1000);
dat.put("interval", conf.getInt("refreshTime") * 1000);
JSONArray display = new JSONArray();
JSONObject monitor1 = new JSONObject();
monitor1.put("label","Zug");
monitor1.put("label", "Zug");
JSONArray layout = new JSONArray();
JSONObject text1 = new JSONObject();
text1.put("type","text");
text1.put("x",120);
text1.put("y",120);
text1.put("text","Abfahrten");
text1.put("font",2);
text1.put("color",conf.getString("textcolormain"));
text1.put("background",conf.getString("bgcolormain"));
text1.put("type", "text");
text1.put("x", 120);
text1.put("y", 120);
text1.put("text", "Abfahrten");
text1.put("font", 2);
text1.put("color", conf.getString("textcolormain"));
text1.put("background", conf.getString("bgcolormain"));
JSONObject text2 = new JSONObject();
text2.put("type","text");
text2.put("x",120);
text2.put("y",170);
text2.put("type", "text");
text2.put("x", 120);
text2.put("y", 170);
text2.put("text", dateFormat.format(updatetime));
text2.put("color",conf.getString("textcolorupdate"));
text2.put("font",2);
text2.put("background",conf.getString("bgcolormain"));
text2.put("color", conf.getString("textcolorupdate"));
text2.put("font", 2);
text2.put("background", conf.getString("bgcolormain"));
JSONObject text3 = new JSONObject();
text3.put("type","text");
text3.put("x",120);
text3.put("y",210);
text3.put("text", "Ver. "+version);
text3.put("color",conf.getString("textcolorupdate"));
text3.put("font",2);
text3.put("background",conf.getString("bgcolormain"));
text3.put("type", "text");
text3.put("x", 120);
text3.put("y", 210);
text3.put("text", "Ver. " + version);
text3.put("color", conf.getString("textcolorupdate"));
text3.put("font", 2);
text3.put("background", conf.getString("bgcolormain"));
layout.put(text3);
layout.put(text2);
layout.put(text1);
monitor1.put("data",layout);
monitor1.put("labelColor",conf.getString("textcolormain"));
monitor1.put("color",conf.getString("textcolormain"));
monitor1.put("background",conf.getString("bgcolormain"));
monitor1.put("data", layout);
monitor1.put("labelColor", conf.getString("textcolormain"));
monitor1.put("color", conf.getString("textcolormain"));
monitor1.put("background", conf.getString("bgcolormain"));
display.put(monitor1);
JSONObject monitor2 = new JSONObject();
monitor2.put("label",conf.getString("monitors.monitor1.Title"));
monitor2.put("labelColor",conf.getString("labelcolor"));
monitor2.put("fullDraw",true);
monitor2.put("label", title.get(0));
monitor2.put("labelColor", conf.getString("labelcolor"));
monitor2.put("fullDraw", true);
int zug1 = udata.get(user).get("1");
makeLabel(monitor2, zug1);
display.put(monitor2);
JSONObject monitor3 = new JSONObject();
monitor3.put("label",conf.getString("monitors.monitor2.Title"));
monitor3.put("labelColor",conf.getString("labelcolor"));
monitor3.put("fullDraw",true);
monitor3.put("label", title.get(1));
monitor3.put("labelColor", conf.getString("labelcolor"));
monitor3.put("fullDraw", true);
int zug2 = udata.get(user).get("2");
makeLabel(monitor3, zug2);
display.put(monitor3);
JSONObject monitor4 = new JSONObject();
monitor4.put("label",conf.getString("monitors.monitor3.Title"));
monitor4.put("labelColor",conf.getString("labelcolor"));
monitor4.put("fullDraw",true);
monitor4.put("label", title.get(2));
monitor4.put("labelColor", conf.getString("labelcolor"));
monitor4.put("fullDraw", true);
int zug3 = udata.get(user).get("3");
makeLabel(monitor4, zug3);
display.put(monitor4);
JSONObject monitor5 = new JSONObject();
monitor5.put("label",conf.getString("monitors.monitor4.Title"));
monitor5.put("labelColor",conf.getString("labelcolor"));
monitor5.put("fullDraw",true);
monitor5.put("label", title.get(3));
monitor5.put("labelColor", conf.getString("labelcolor"));
monitor5.put("fullDraw", true);
int zug4 = udata.get(user).get("4");
makeLabel(monitor5, zug4);
display.put(monitor5);
dat.put("displays",display);
System.out.println(display);
dat.put("displays", display);
return dat.toString();
}
private static void makeLabel(JSONObject Monitor, int zeit){
private static void makeLabel(JSONObject Monitor, int zeit){
if(zeit != 0){
Monitor.put("color",conf.getString("textcolordelay"));
Monitor.put("background",conf.getString("bgcolordelay"));