Skip to content

Commit

Permalink
2.0.01
Browse files Browse the repository at this point in the history
  • Loading branch information
ToWipf committed Apr 7, 2023
1 parent 43b776e commit ca027f1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/target/
/files/
/angular-app/package-lock.json
/angular-app/node_modules/
/angular-app/dist/
/angular-app/.angular/cache/
/src/main/resources/META-INF/resources/app/
*auth.db
*jasmarty.db
*.db
*jasmarty.jar
2 changes: 1 addition & 1 deletion angular-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jasmarty-app",
"version": "2.0.00",
"version": "2.0.01",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0 --port 3000 --disable-host-check",
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/wipf/jasmarty/logic/base/MainHome.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class MainHome {
ListeTypeService listeTypeDB;

private static final Logger LOGGER = Logger.getLogger("_MainHome_");
public static final String VERSION = "2.0.00";
public static final String VERSION = "2.0.01";

/**
* Stop App
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/wipf/jasmarty/logic/base/WipfConfigVW.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.wipf.jasmarty.logic.base;


import java.util.List;
import java.util.UUID;

Expand Down Expand Up @@ -47,6 +46,7 @@ public List<WipfConfig> getAll() {
* @return
*
*/
@Transactional // TODO Warum ist das nötig? (Grafana)
public String getConfParamString(String sConfParam) {
WipfConfig wc = WipfConfig.findByKey(sConfParam).firstResult();
if (wc != null) {
Expand All @@ -60,6 +60,7 @@ public String getConfParamString(String sConfParam) {
* @return
*
*/
@Transactional // TODO Warum ist das nötig? (punke)
public Integer getConfParamInteger(String sConfParam) {
try {
WipfConfig wc = WipfConfig.findByKey(sConfParam).firstResult();
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/wipf/jasmarty/logic/telegram/TAppGrafana.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public String telegramMenuehHeizung(Telegram t) {
try {
return sendGrafanaPictureToTelegram(t.getChatID(), "ydVqZGkgk/heizung", sPanelId, sTeil2_Zeit);
} catch (Exception e) {
e.printStackTrace();
return "Fehler 112 " + e;
}
} else {
Expand Down Expand Up @@ -181,7 +182,7 @@ public String telegramMenueSolar(Telegram t) {
try {
return sendGrafanaPictureToTelegram(t.getChatID(), "8wFrHwb4k/ubersicht-solar", sPanelId, sTeil2_Zeit);
} catch (Exception e) {
return "Fehler 113 " + e;
return "Fehler 115 " + e;
}
} else {
return "Fehlerhafte Eingabe\nHilfe mit 'dev'";
Expand Down Expand Up @@ -211,15 +212,12 @@ private Boolean validateInput(String sTeil1_Was, String sTeil2_Zeit) {
* @return
* @throws IOException
*/
private String sendGrafanaPictureToTelegram(Long nChatId, String sDashboard, String sPanel, String sTime)
throws Exception {
private String sendGrafanaPictureToTelegram(Long nChatId, String sDashboard, String sPanel, String sTime) {

// http://192.168.2.11:3000/render/d-solo/ydVqZGkgk/heizung?orgId=1&panelId=3&from=now-7d&to=now
String sGrafanaHost = wipfConfig.getConfParamString("grafana_host");

String sFilename = "grafana_" + (nChatId + sDashboard + sPanel + sTime + ".png").replace('/', '-');
fileVw.saveFileToDisk(sGrafanaHost + "/render/d-solo/" + sDashboard + "?orgId=1&panelId=" + sPanel
+ "&from=now-" + sTime + "&to=now", sFilename);
fileVw.saveFileToDisk(sGrafanaHost + "/render/d-solo/" + sDashboard + "?orgId=1&panelId=" + sPanel + "&from=now-" + sTime + "&to=now", sFilename);

sendAndReceive.sendDocumentToTelegram(nChatId, sFilename);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public String sendDocumentToTelegram(Telegram t) {
* @return
* @throws IOException
*/
public String sendDocumentToTelegram(Long nChatId, String sFilePath) throws Exception {
public String sendDocumentToTelegram(Long nChatId, String sFilePath) {
return sendFileToTelegram(nChatId, fileVw.getFile(sFilePath));
}

Expand Down Expand Up @@ -418,14 +418,20 @@ public void sendMsgToAdmin(String sMsg) {
* @return
* @throws Exception
*/
private String sendFileToTelegram(Long nChatId, File f) throws Exception {
MultipartUtility multipart = new MultipartUtility("https://api.telegram.org/" + getBotKeyFromCache() + "/sendDocument?chat_id=" + nChatId, "UTF-8");
// multipart.addFormField("param_name_1", "param_value");
multipart.addFilePart("document", f);
String response = multipart.finish();
private String sendFileToTelegram(Long nChatId, File f) {
LOGGER.info("upload File to " + nChatId + " / " + f.getPath());
JSONObject jo = new JSONObject(response);
return (jo.get("ok").toString());
try {
MultipartUtility multipart;
multipart = new MultipartUtility("https://api.telegram.org/" + getBotKeyFromCache() + "/sendDocument?chat_id=" + nChatId, "UTF-8");
// multipart.addFormField("param_name_1", "param_value");
multipart.addFilePart("document", f);
String response = multipart.finish();
JSONObject jo = new JSONObject(response);
return (jo.get("ok").toString());
} catch (IOException | WipfException e) {
e.printStackTrace();
return "Fehler 116 " + e;
}
}

}

0 comments on commit ca027f1

Please sign in to comment.