Skip to content

Commit

Permalink
small fixes in http request
Browse files Browse the repository at this point in the history
  • Loading branch information
MiRo1310 committed Jan 26, 2024
1 parent 585d43d commit 192ea9c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion admin/build/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions admin/build/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admin/src/lib/entrys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const tabValues = [
{ name: "user", val: "", headline: "User", width: "20%" },
{ name: "password", val: "", headline: "Password", password: true, width: "20%" },
{ name: "filename", val: "http-request-photo.jpg", headline: "Filename", width: "20%", required: true },
{ name: "delay", val: 5000, headline: "Delay (ms)", width: "20%", type: "number", required: true },
// { name: "delay", val: 5000, headline: "Delay (ms)", width: "20%", type: "number", required: true },
],
popupCard: { buttons: { add: true, remove: true }, width: "99%", height: "70%" },
},
Expand Down
6 changes: 2 additions & 4 deletions admin/src/pages/TabAction/Action/ActionCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ class ActionCard extends Component {
let value = true;
let valueRowValuesAndSwitch = true;
let row = this.state.newRow;
this.props.entrys.forEach((entry) => {
console.log("test");
if (!entry.checkbox && entry.required) {
console.log("entry", entry);
this.props.entrys.forEach((entry) => {
if (!entry.checkbox && entry.required) {
// Wenn der Wert nicht vorhanden ist, dadurch das evtl eine neues Element in entrys hinzugefügt wurde
if (!row[entry.name]) row[entry.name] = [""];
row[entry.name].forEach((val, index) => {
Expand Down
5 changes: 5 additions & 0 deletions docs/de/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ menu:back
- Theme, es können verschieden Themes aus dem Echarts Adapter eingestellt werden, z.B.`auto, default, dark, dark-bold, dark-blue, gray, vintage, macarons, infographic, shine, roma, azul, blue, royal, tech-blue, red, red-velvet, green`
- Dateiname, individueller Dateiname.  **Wichtig ist das in den Einstellungen ein Verzeichnis angegeben ist mit voller Schreibberechtigung**

### HTTP Request

- hiermit ist es möglich einen Http Request ab zu senden, mit und ohne Authentification. Als erstes muss die Url angegeben werden, User und Passwort sind optional, wenn diese nicht benötigt werden einfach leer lassen. Als Dateiname kann der vorkonfiguriert Name stehen bleiben.


### Settings

- Telegram-Instanz, hier kann man zischen den Instanzen wählen wenn man mehrere installiert hat
Expand Down
2 changes: 1 addition & 1 deletion lib/js/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ function generateActions(_this, action, userObject) {
objName: "httpRequest",
name: "httpRequest",
loop: "url",
elements: [{ name: "url" }, { name: "user" }, { name: "password" }, { name: "filename" }, { name: "delay" }],
elements: [{ name: "url" }, { name: "user" }, { name: "password" }, { name: "filename" }],
},
];

Expand Down
7 changes: 2 additions & 5 deletions lib/js/httpRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ async function httpRequest(_this, parts, userToSend, instanceTelegram, resize_ke
const password = part.password;
const method = "get";

/* prettier-ignore */
axios(
user
? {
Expand All @@ -31,14 +32,10 @@ async function httpRequest(_this, parts, userToSend, instanceTelegram, resize_ke
try {
fs.writeFileSync(imagePath, Buffer.from(response.data), "binary");
_this.log.debug("Bild erfolgreich gespeichert:", imagePath);
sendToTelegram(_this, user, imagePath, [], instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID, "");
} catch (error) {
_this.log.error("Fehler beim Speichern des Bildes:", error);
}

// Hier könntest du weitere Aktionen durchführen, z.B. iobroker-Objekt aktualisieren
setTimeout(() => {
sendToTelegram(_this, user, imagePath, [], instanceTelegram, resize_keyboard, one_time_keyboard, userListWithChatID, "");
}, part.delay);
})
.catch(function (response) {
//handle error
Expand Down

0 comments on commit 192ea9c

Please sign in to comment.