iobroker.telegram-menu 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,23 +11,17 @@
11
11
 
12
12
  **Tests:** ![Test and Release](https://github.com/MiRo1310/ioBroker.telegram-menu/workflows/Test%20and%20Release/badge.svg)
13
13
 
14
- ## telegram-menu adapter for ioBroker
14
+ ## ioBroker telegram-menu adapter
15
15
 
16
16
  Easily create Telegram Menus
17
17
 
18
18
  You can create a separate menu for each user, or you can use the global user to generate the same menu for all users.
19
19
 
20
- ### Navigation
20
+ ## Documentation
21
21
 
22
- - The call text is called by the button, both must have the same name
23
- - Buttons should be seperate by , and rows by &&
24
- - All users must be spelled exactly as they are created in telegram
22
+ [🇺🇸 Documentation](./docs/en/README.md)
25
23
 
26
- ### SetState
27
-
28
- ### GetState
29
-
30
- - You can place the Value in the Text with the Placeholder of &&
24
+ [🇩🇪 Dokumentation](./docs/de/README.md)
31
25
 
32
26
  ## Changelog
33
27
 
@@ -35,6 +29,10 @@ You can create a separate menu for each user, or you can use the global user to
35
29
  Placeholder for the next version (at the beginning of the line):
36
30
  ### **WORK IN PROGRESS**
37
31
  -->
32
+ ### 0.0.8 (2023-05-01)
33
+
34
+ - Send Grafana Diagrams
35
+
38
36
  ### 0.0.7 (2023-04-23)
39
37
 
40
38
  - Bugs fixed
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Globaler Benutzer aktiv",
21
21
  "Instanze": "Instanz",
22
22
  "Navigation": "Navigation",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Bitte speichern Sie die Nav-Einstellungen, bevor Sie zu den Aktionen gehen !!!",
23
24
  "Save": "Speichern",
24
25
  "Select": "Wählen",
25
26
  "Settings": "Einstellungen",
@@ -1,31 +1,35 @@
1
1
  {
2
- "Action": "Action",
3
- "Add": "add",
4
- "Add && as a placeholder for the value in the text": "Add && as a placeholder for the value in the text",
5
- "Add && as a placeholder for the value in the text": "Add && as a placeholder for the value in the text",
6
- "Add Global User": "Add Global User",
7
- "Add new Action": "Add new Action",
8
- "Add new Navigation": "Add new Navigation",
9
- "Add new User": "Add new User",
10
- "Add new Username": "Add new Username",
11
- "All User from Telegram, seperate with": "All User from Telegram, seperate with",
12
- "Call": "Call",
13
- "Call Text": "Call Text",
14
- "Cancel": "Cancel",
15
- "Choose a trigger": "Choose a trigger",
16
- "Choose your option": "Choose your option",
17
- "Close": "Close",
18
- "Delete User": "Delete User",
19
- "Each entry may only occur once in the complete navigation": "Each entry may only occur once in the complete navigation",
20
- "Global User activ": "Global user activ",
21
- "Instanze": "Instanze",
22
- "Navigation": "Navigation",
23
- "Save": "Save",
24
- "Select": "Select",
25
- "Settings": "Settings",
26
- "Startside": "Startside",
27
- "Trigger": "Trigger",
28
- "Value": "Value",
29
- "What is to do?": "What is to do?",
30
- "telegram-menu adapter settings": "Adapter settings for telegram-menu"
2
+ "Action": "Action",
3
+ "Add": "add",
4
+ "Add && as a placeholder for the value in the text": "Add && as a placeholder for the value in the text",
5
+ "Add && as a placeholder for the value in the text": "Add && as a placeholder for the value in the text",
6
+ "Add Global User": "Add Global User",
7
+ "Add new Action": "Add new Action",
8
+ "Add new Navigation": "Add new Navigation",
9
+ "Add new User": "Add new User",
10
+ "Add new Username": "Add new Username",
11
+ "All User from Telegram, seperate with": "All User from Telegram, seperate with",
12
+ "Call": "Call",
13
+ "Call Text": "Call Text",
14
+ "Cancel": "Cancel",
15
+ "Choose a trigger": "Choose a trigger",
16
+ "Choose your option": "Choose your option",
17
+ "Close": "Close",
18
+ "Delete User": "Delete User",
19
+ "Each entry may only occur once in the complete navigation": "Each entry may only occur once in the complete navigation",
20
+ "Global User activ": "Global user activ",
21
+ "Instanze": "Instanze",
22
+ "Navigation": "Navigation",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Please Save the Nav Settings before you go to the aktions !!!",
24
+ "Save": "Save",
25
+ "Select": "Select",
26
+ "Settings": "Settings",
27
+ "Startside": "Startside",
28
+ "Trigger": "Trigger",
29
+ "Value": "Value",
30
+ "What is to do?": "What is to do?",
31
+ "telegram-menu adapter settings": "Adapter settings for telegram-menu",
32
+ "Directory": "Directory",
33
+ "Filename": "Filename",
34
+ "Delay (ms)": "Delay (ms)"
31
35
  }
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Actividad de usuario global",
21
21
  "Instanze": "Instancia",
22
22
  "Navigation": "Navegación",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "¡Guarde la configuración de navegación antes de ir a las acciones!",
23
24
  "Save": "Ahorrar",
24
25
  "Select": "Seleccionar",
25
26
  "Settings": "Ajustes",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Activation globale de l'utilisateur",
21
21
  "Instanze": "Instantané",
22
22
  "Navigation": "La navigation",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Veuillez enregistrer les paramètres de navigation avant de vous rendre aux aktions !!!",
23
24
  "Save": "Sauvegarder",
24
25
  "Select": "Sélectionner",
25
26
  "Settings": "Paramètres",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Utente globale attivo",
21
21
  "Instanze": "Istanza",
22
22
  "Navigation": "Navigazione",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Si prega di salvare le impostazioni di navigazione prima di andare alle azioni!!!",
23
24
  "Save": "Salva",
24
25
  "Select": "Selezionare",
25
26
  "Settings": "Impostazioni",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Globale gebruiker actief",
21
21
  "Instanze": "Instanze",
22
22
  "Navigation": "Navigatie",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Sla de navigatie-instellingen op voordat u naar de acties gaat !!!",
23
24
  "Save": "Redden",
24
25
  "Select": "Selecteer",
25
26
  "Settings": "Instellingen",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Globalna aktywność użytkowników",
21
21
  "Instanze": "Instancja",
22
22
  "Navigation": "Nawigacja",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Zapisz ustawienia nawigacji, zanim przejdziesz do działań !!!",
23
24
  "Save": "Ratować",
24
25
  "Select": "Wybierać",
25
26
  "Settings": "Ustawienia",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Atividade global do usuário",
21
21
  "Instanze": "instância",
22
22
  "Navigation": "Navegação",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Salve as configurações de navegação antes de ir para as ações !!!",
23
24
  "Save": "Salvar",
24
25
  "Select": "Selecione",
25
26
  "Settings": "Configurações",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Активность глобального пользователя",
21
21
  "Instanze": "Инстанц",
22
22
  "Navigation": "Навигация",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Пожалуйста, сохраните настройки навигации, прежде чем переходить к действиям !!!",
23
24
  "Save": "Сохранять",
24
25
  "Select": "Выбирать",
25
26
  "Settings": "Настройки",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "Глобальна активність користувачів",
21
21
  "Instanze": "Instanze",
22
22
  "Navigation": "Навігація",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "Будь ласка, збережіть налаштування навігації, перш ніж переходити до дій !!!",
23
24
  "Save": "зберегти",
24
25
  "Select": "Виберіть",
25
26
  "Settings": "Налаштування",
@@ -20,6 +20,7 @@
20
20
  "Global User activ": "全球用户活跃度",
21
21
  "Instanze": "瞬间",
22
22
  "Navigation": "导航",
23
+ "Please Save the Nav Settings before you go to the aktions !!!": "请在进行操作之前保存导航设置!!!",
23
24
  "Save": "节省",
24
25
  "Select": "选择",
25
26
  "Settings": "设置",
@@ -265,7 +265,8 @@
265
265
  })
266
266
  // New Row in Action
267
267
  $("#btn_action_newRow").on("click", function () {
268
- $(`#tab_${$("#select_action").val()} tbody`).append(newTrInAction($("#select_action").val()))
268
+ const rows = $("#tab_pic tbody tr").length
269
+ $(`#tab_${$("#select_action").val()} tbody`).append(newTrInAction($("#select_action").val(), undefined, rows))
269
270
  $("#btn_action_set").attr("disabled", "disabled")
270
271
  })
271
272
  // Global delete Hide Table
@@ -283,6 +284,7 @@
283
284
  } else $(this).find("i").html("expand_more")
284
285
  })
285
286
  // Save from Action Input Field
287
+ //SECTION - Save 1
286
288
  $("#btn_action_set").on("click", function () {
287
289
  // Wieder sichtbar machen, wenn du edit disabled gesetzt wurde
288
290
  $("#select_action").removeAttr("disabled")
@@ -290,7 +292,9 @@
290
292
  let $table = $(`#tab_${action} tbody`)
291
293
  let result = {
292
294
  IDs: [],
295
+ picSendDelay: [],
293
296
  values: [],
297
+ fileName: [],
294
298
  checkboxes: [],
295
299
  text: [],
296
300
  trigger: $("#select_trigger").val(),
@@ -321,6 +325,17 @@
321
325
  result.checkboxes.push($(this).is(":checked"))
322
326
  })
323
327
  }
328
+ if (action === "pic") {
329
+ $($table).find(`input.pic_IDs`).each(function () {
330
+ result.IDs.push($(this).val())
331
+ })
332
+ $($table).find(`input.pic_fileName`).each(function () {
333
+ result.fileName.push($(this).val())
334
+ })
335
+ $($table).find(`input.pic_picSendDelay`).each(function () {
336
+ result.picSendDelay.push($(this).val())
337
+ })
338
+ }
324
339
  generatActionRow(activeUser, action, result, rowToUpdate)
325
340
  _onChange()
326
341
  resetModal()
@@ -336,7 +351,7 @@
336
351
  $("#select_trigger").on("change", function () {
337
352
  showTrigger = true
338
353
  if ($(this).val() == null) showTrigger = false
339
- showSelectModal(showTrigger, show)
354
+ showSelectModal(showTrigger, true)
340
355
  })
341
356
  // Inputs if its not ""
342
357
  $(".modal-content").on("input ", function () {
@@ -352,7 +367,7 @@
352
367
  showTrigger = true;
353
368
  // Select_action deaktivieren
354
369
  $("#select_action").attr("disabled", "disabled")
355
- // Select Button Aktivieren
370
+ // Select Button Aktivieren
356
371
  $("#btn_action_set").removeAttr("disabled")
357
372
  $("#btn_action_newRow").show()
358
373
  let action = $(this).parents("tbody").attr("data-name")
@@ -421,6 +436,7 @@
421
436
  <option value="" disabled selected class="translate">Choose your option</option>
422
437
  <option value="get">GetState</option>
423
438
  <option value="set">SetState</option>
439
+ <option value="pic">Send Picture</option>
424
440
  </select>
425
441
  <label class="translate">What is to do?</label>
426
442
  </div>
@@ -499,12 +515,35 @@
499
515
  <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" disabled><i
500
516
  class="material-icons">delete</i></a></td>
501
517
  </td>
502
-
503
518
  </tr>
504
519
  </tbody>
505
-
506
520
  </table>
507
-
521
+ <table id="tab_pic" class="resetHide">
522
+ <thead>
523
+ <tr>
524
+ <th>Rendering url</th>
525
+ <th style="width: 15%;" class="translate">Filename</th>
526
+ <th style="width: 8%;" class="translate">Delay (ms)</th>
527
+ <th style="width: 3%;"></th>
528
+ </tr>
529
+ </thead>
530
+ <tbody class="table-lines table-values">
531
+ <tr>
532
+ <td> <input class="pic_IDs resetInput checkValue" type="text">
533
+ </td>
534
+ <td> <input class="pic_fileName resetInput checkValue" type="text"
535
+ placeholder="grafana1.png" value="grafana1.png">
536
+ </td>
537
+ <td>
538
+ <input class="pic_picSendDelay resetInput" type="text" placeholder="5000"
539
+ value="5000">
540
+ </td>
541
+ <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" disabled><i
542
+ class="material-icons">delete</i></a></td>
543
+ </td>
544
+ </tr>
545
+ </tbody>
546
+ </table>
508
547
  </div>
509
548
  <div class="modal-footer">
510
549
  <a class="modal-action modal-close waves-effect waves-green btn btn-set" disabled
@@ -513,7 +552,6 @@
513
552
  <a class="modal-action modal-close waves-effect waves-green btn btn-close" id="btn_action_close"><i
514
553
  class="large material-icons left ">close</i><span class="translate">Close</span></a>
515
554
  </div>
516
-
517
555
  </div>
518
556
  <div class="row" id="user_menu">
519
557
  <a class="btn-add btn-floating btn-small waves-effect waves-light blue disabled translateT"
@@ -522,7 +560,6 @@
522
560
  title="Delete User"><i class="material-icons">delete</i></a>
523
561
  <a class="btn-add btn-floating btn-large waves-effect waves-light blue disabled translateT"
524
562
  id="addGlobalUser" title="Add Global User"><i class="material-icons">group_add</i></a>
525
-
526
563
  <div class="input-field col s3">
527
564
  <input id="username" type="text" class="validate">
528
565
  <label for="username" class="translate">Add new Username</label>
@@ -534,8 +571,6 @@
534
571
  </ul>
535
572
  </div>
536
573
  </div>
537
-
538
-
539
574
  <div class="row">
540
575
  <div class="col s12">
541
576
  <div class="col s2">
@@ -560,14 +595,13 @@
560
595
  </div>
561
596
  </div>
562
597
  </div>
563
- <div class="row">
564
- <div class="col s12 ">
565
- <p class="infoText translate">Each entry may only occur once in the complete navigation</p>
566
- </div>
567
- </div>
568
598
  </header>
569
599
  <div id="tab-nav" class="">
570
600
  <div class="row">
601
+ <div class="col s12 ">
602
+ <p class=" infoText translate">Each entry may only occur once in the complete navigation</p>
603
+ <p class="infoText translate">Please Save the Nav Settings before you go to the aktions !!!</p>
604
+ </div>
571
605
  <div class="col s12">
572
606
  <div class="table-values-div saveTable" id="navigation">
573
607
  <table id="table_nav" class="" style="width: 100%;">
@@ -589,10 +623,7 @@
589
623
 
590
624
  </div>
591
625
  </div>
592
- <div id="tab-action">
593
-
594
- </div>
595
-
626
+ <div id="tab-action"></div>
596
627
  <div id="tab-settings">
597
628
  <div class=" row">
598
629
  <div class="col s12">
@@ -640,6 +671,18 @@
640
671
  </div>
641
672
  </div>
642
673
 
674
+ <div class="row distance">
675
+ <div class="input-field col s6">
676
+ <input id="tokenGrafana" type="text" class="validate value">
677
+ <label for="tokenGrafana">Token Grafana</label>
678
+ </div>
679
+ <div class="input-field col s4">
680
+ <input id="directory" type="text" class="validate value"
681
+ placeholder="/opt/iobroker/grafana/" value="/opt/iobroker/grafana/">
682
+ <label for="directory" class="translate">Directory</label>
683
+ </div>
684
+ </div>
685
+
643
686
 
644
687
  </div>
645
688
 
@@ -34,7 +34,7 @@ function navElement(user) {
34
34
  <tr class="startRow">
35
35
  <td><input type="text" data-name="call" class="isString nav-call translateV startside" value="Startside" ></td>
36
36
  <td><input type="text" data-name="value" class="isString nav-value " value="Licht, Steckdose && Iobroker, Heizung"></td>
37
- <td><input type="text" data-name="text" class="isString nav-text" value="Wählen Sie eine Aktion"></td>
37
+ <td><input type="text" data-name="text" class="isString nav-text" value="Wähle eine Aktion"></td>
38
38
 
39
39
  <td style="width: 5%;"></td>
40
40
  </tr>
@@ -51,46 +51,37 @@ function createSelectTrigger(list) {
51
51
  }
52
52
 
53
53
  // Row in Action Popup
54
- function newTrInAction(val, array) {
54
+ function newTrInAction(val, array, rows) {
55
55
  if (!array) {
56
- array = ["", "", "checked", "", ""];
56
+ array = ["", "", "checked", "", "", 5000, `grafana${rows + 1}.png`];
57
57
  }
58
58
  if (val === "get")
59
59
  return /*html*/ `<tr class="onResetDelete">
60
- <td> <input class="get_id checkValue" value="${array[0]}" type="text">
61
- </td>
62
- <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID"
63
- title="Get ID"><i class="material-icons">edit</i></a></td>
64
- <td>
65
- <input class="get_text checkValue" type="text" value="${array[1]}">
66
- </td>
67
- <td><label>
68
- <input type="checkbox" class="filled-in newline_checkbox" ${array[2]} />
69
- <span></span>
70
- </label></td>
71
- <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" ><i
72
- class="material-icons">delete</i></a></td>
73
- </td>
60
+ <td> <input class="get_id checkValue" value="${array[0]}" type="text"></td>
61
+ <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID" title="Get ID"><i class="material-icons">edit</i></a></td>
62
+ <td><input class="get_text checkValue" type="text" value="${array[1]}"></td>
63
+ <td><label><input type="checkbox" class="filled-in newline_checkbox" ${array[2]} /><span></span></label></td>
64
+ <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" ><i class="material-icons">delete</i></a></td>
74
65
  </tr>`;
75
66
  if (val === "set")
76
67
  return /*html*/ `<tr class="onResetDelete">
77
- <td> <input class="set_id checkValue" type="text" value="${array[0]}">
78
- </td>
79
- <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID"
80
- title="Get ID"><i class="material-icons">edit</i></a></td>
81
- <td>
82
- <input class="set_value checkValueSwitch" type="text" value="${array[3]}">
83
- </td>
84
- <td><label>
85
- <input type="checkbox" class="filled-in switch_checkbox" ${array[4]}/>
86
- <span></span>
87
- </label></td>
88
- <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red"><i
89
- class="material-icons">delete</i></a></td>
90
- </td>
68
+ <td> <input class="set_id checkValue" type="text" value="${array[0]}"></td>
69
+ <td><a class="btn-floating btn-small waves-effect waves-light blue btn_getID" title="Get ID"><i class="material-icons">edit</i></a></td>
70
+ <td><input class="set_value checkValueSwitch" type="text" value="${array[3]}"></td>
71
+ <td><label><input type="checkbox" class="filled-in switch_checkbox" ${array[4]}/><span></span></label></td>
72
+ <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red"><i class="material-icons">delete</i></a></td>
73
+
74
+ </tr>`;
75
+ if (val === "pic")
76
+ return /*html*/ `<tr class="onResetDelete">
77
+ <td><input class="pic_IDs checkValue" type="text" value="${array[0]}"></td>
78
+ <td><input class="pic_fileName checkValue" type="text" placeholder="grafanaX.png" value="${array[6]}"></td>
79
+ <td><input class="pic_picSendDelay " type="text" placeholder="5000" value="${array[5]}"></td>
80
+ <td><a class="deleteRow btn-floating btn-small waves-effect waves-light red" disabled><i class="material-icons">delete</i></a></td>
81
+
91
82
  </tr>`;
92
83
  }
93
-
84
+ //SECTION - Save 2
94
85
  function actionElement(user) {
95
86
  return /*html*/ `<div class="row user_${user}">
96
87
  <div class="col s12">
@@ -137,11 +128,35 @@ function actionElement(user) {
137
128
  </tbody>
138
129
  </table>
139
130
  </div>
131
+ <div>
132
+ <p class="showHideMenu" style="width: 100%; background: #64b5f6"><i class="material-icons">chevron_right</i>Send Picture</p>
133
+ <table style="display: none;" class="text-small saveTable">
134
+ <thead>
135
+ <tr>
136
+ <th style="width: 10%">Trigger</th>
137
+ <th data-name="IDs" data-type="string">
138
+ Rendering url</th>
139
+ <th data-name="fileName" data-type="string" class="translate" style="width: 10%">Filename</th>
140
+ <!-- <th data-name="value" data-type="string" >
141
+ Text</th> -->
142
+ <th style="width: 8%">Delay</th>
143
+ <th style="width: 2%"></th>
144
+ <th data-name="delete" style="width: 2%;">
145
+ </th>
146
+ </tr>
147
+ </thead>
148
+ <tbody name=${user} data-name="pic" class="table_pic table-lines table-values">
149
+ </tbody>
150
+ </table>
151
+ </div>
152
+ <div >
153
+ </div>
140
154
  </div>
141
155
  </div>`;
142
156
  }
143
-
157
+ //SECTION - Save 3
144
158
  function newTableRow_Action(action, result) {
159
+ console.log("ACTION " + action);
145
160
  if (action === "get") {
146
161
  return /*html*/ `<tr>
147
162
  <td data-name="trigger">${result.trigger}</td>
@@ -159,6 +174,15 @@ function newTableRow_Action(action, result) {
159
174
  <td>${insertVal(result, "values")}</td>
160
175
  <td>${insertVal(result, "checkboxes")}</td>
161
176
  ${actionDeleteButton}
177
+ ${editButton}
178
+ </tr>`;
179
+ if (action === "pic")
180
+ return /*html*/ `<tr>
181
+ <td data-name="trigger">${result.trigger}</td>
182
+ <td>${insertVal(result, "IDs")}</td>
183
+ <td>${insertVal(result, "fileName")}</td>
184
+ <td>${insertVal(result, "picSendDelay")}</td>
185
+ ${actionDeleteButton}
162
186
  ${editButton}
163
187
  </tr>`;
164
188
  }
package/admin/js/main.js CHANGED
@@ -56,7 +56,7 @@ function createUser(id, users) {
56
56
  $("#tab-action").append(actionElement(user));
57
57
  });
58
58
  }
59
-
59
+ //SECTION - Save 5 Save to Object
60
60
  function table2Values(id) {
61
61
  let oldName;
62
62
  const $tbodys = $(id).find("tbody");
@@ -71,7 +71,7 @@ function table2Values(id) {
71
71
  // console.log(this);
72
72
 
73
73
  const nav = [];
74
- let actionSet, actionGet;
74
+ let actionSet, actionGet, actionPic;
75
75
  const $tbody = $(this);
76
76
 
77
77
  const $trs = $tbody.find("tr");
@@ -84,11 +84,13 @@ function table2Values(id) {
84
84
  obj = {
85
85
  get: [],
86
86
  set: [],
87
+ pic: [],
87
88
  };
88
89
  }
89
90
  i++;
90
91
  actionSet = {};
91
92
  actionGet = {};
93
+ actionPic = {};
92
94
  $trs.each(function () {
93
95
  const dataName = $tbody.attr("data-name");
94
96
  if (dataName === "nav") {
@@ -124,6 +126,17 @@ function table2Values(id) {
124
126
  obj.get.push(actionGet);
125
127
  }
126
128
  }
129
+ if (dataName === "pic") {
130
+ actionPic = {
131
+ IDs: dataToArray(this, "p[data-name='IDs']"),
132
+ picSendDelay: dataToArray(this, "p[data-name='picSendDelay']"),
133
+ fileName: dataToArray(this, "p[data-name='fileName']"),
134
+ trigger: dataToArray(this, "td[data-name='trigger']"),
135
+ };
136
+ if (actionPic && actionPic.IDs) {
137
+ obj.pic.push(actionPic);
138
+ }
139
+ }
127
140
  });
128
141
  object.action[saveName] = obj;
129
142
  });
@@ -247,10 +260,10 @@ function showSelectModal(showTrigger, show) {
247
260
  if (show && showTrigger) $("#btn_action_set").removeAttr("disabled");
248
261
  else $("#btn_action_set").attr("disabled", "disabled");
249
262
  }
250
-
263
+ //SECTION - Save 4 edit Values
251
264
  function insertEditValues(action, $this) {
252
265
  const IDs = valuesToArray($this, "p[data-name='IDs']");
253
- let newline, switchs, values, texts;
266
+ let newline, switchs, values, texts, picSendDelay, fileName;
254
267
 
255
268
  if (action == "set") {
256
269
  switchs = valuesToArray($this, "p[data-name='checkboxes']");
@@ -260,12 +273,19 @@ function insertEditValues(action, $this) {
260
273
  newline = valuesToArray($this, "p[data-name='checkboxes']");
261
274
  texts = valuesToArray($this, "p[data-name='text']");
262
275
  }
276
+ if (action == "pic") {
277
+ picSendDelay = valuesToArray($this, "p[data-name='picSendDelay']");
278
+ fileName = valuesToArray($this, "p[data-name='fileName']");
279
+ }
263
280
  IDs.forEach(function (element, key) {
264
281
  if (key == 0) {
265
282
  $(`#tab_${action} tbody input.set_id`).val(IDs[0].trim());
266
283
  $(`#tab_${action} tbody input.get_id`).val(IDs[0].trim());
284
+ $(`#tab_${action} tbody input.pic_IDs`).val(IDs[0].trim());
267
285
  if (values) $(`#tab_${action} tbody input.set_value`).val(values[0].trim());
268
286
  if (texts) $(`#tab_${action} tbody input.get_text`).val(texts[0].trim());
287
+ if (picSendDelay) $(`#tab_${action} tbody input.pic_picSendDelay`).val(picSendDelay[0].trim());
288
+ if (fileName) $(`#tab_${action} tbody input.pic_fileName`).val(fileName[0].trim());
269
289
 
270
290
  if (switchs && switchs[0].trim() == "true") {
271
291
  $(`#tab_${action} tbody input.switch_checkbox`).attr("checked", "checked");
@@ -278,13 +298,17 @@ function insertEditValues(action, $this) {
278
298
  let _newline = "",
279
299
  _switch = "",
280
300
  _values = "",
281
- _texts = "";
301
+ _texts = "",
302
+ _picSendDelay = "",
303
+ _fileName = "";
282
304
 
283
305
  if (newline && newline[key].trim() == "true") _newline = "checked";
284
306
  if (switchs && switchs[key].trim() == "true") _switch = "checked";
285
307
  if (values) _values = values[key].trim();
286
308
  if (texts) _texts = texts[key].trim();
287
- const array = [IDs[key].trim(), _texts, _newline, _values, _switch];
309
+ if (picSendDelay) _picSendDelay = picSendDelay[key].trim();
310
+ if (fileName) _fileName = fileName[key].trim();
311
+ const array = [IDs[key].trim(), _texts, _newline, _values, _switch, _picSendDelay, _fileName];
288
312
  $(`#tab_${$("#select_action").val()} tbody`).append(newTrInAction($("#select_action").val(), array));
289
313
  }
290
314
  });
package/admin/style.css CHANGED
@@ -102,5 +102,16 @@ table th {
102
102
  text-align: center;
103
103
  color: #ce3a3a;
104
104
  margin: 0;
105
+ margin-bottom: 5px;
105
106
  text-decoration: underline;
106
107
  }
108
+
109
+ header {
110
+ margin: 0 !important;
111
+ }
112
+ .row {
113
+ margin-bottom: 5px !important;
114
+ }
115
+ .distance {
116
+ margin-top: 30px !important;
117
+ }
package/admin/words.js CHANGED
@@ -37,4 +37,5 @@ systemDictionary = {
37
37
  "Value": { "en": "Value", "de": "Wert", "ru": "Ценить", "pt": "Valor", "nl": "Waarde", "fr": "Valeur", "it": "Valore", "es": "Valor", "pl": "Wartość", "uk": "Значення", "zh-cn": "价值"},
38
38
  "What is to do?": { "en": "What is to do?", "de": "Was ist zu tun?", "ru": "Что делать?", "pt": "O que fazer?", "nl": "Wat is er te doen?", "fr": "Que faire ?", "it": "Cosa fare?", "es": "¿Qué hay que hacer?", "pl": "Co robić?", "uk": "Що робити?", "zh-cn": "怎么办?"},
39
39
  "telegram-menu adapter settings": { "en": "Adapter settings for telegram-menu", "de": "Adaptereinstellungen für Telegram-Menü", "ru": "Настройки адаптера для телеграм-меню", "pt": "Configurações do adaptador para menu de telegrama", "nl": "Adapterinstellingen voor telegrammenu", "fr": "Paramètres de l'adaptateur pour le menu télégramme", "it": "Impostazioni dell'adattatore per il menu del telegramma", "es": "Configuración del adaptador para el menú de telegramas", "pl": "Ustawienia adaptera dla menu telegramu", "uk": "Налаштування адаптера для telegram-меню", "zh-cn": "电报菜单的适配器设置"},
40
+ "Please Save the Nav Settings before you go to the aktions !!!": {"en": "Please Save the Nav Settings before you go to the aktions !!!", "de": "Bitte speichern Sie die Nav-Einstellungen, bevor Sie zu den Aktionen gehen !!!", "ru": "Пожалуйста, сохраните настройки навигации, прежде чем переходить к действиям !!!", "pt": "Salve as configurações de navegação antes de ir para as ações !!!", "nl": "Sla de navigatie-instellingen op voordat u naar de acties gaat !!!", "fr": "Veuillez enregistrer les paramètres de navigation avant de vous rendre aux aktions !!!", "it": "Si prega di salvare le impostazioni di navigazione prima di andare alle azioni!!!", "es": "¡Guarde la configuración de navegación antes de ir a las acciones!", "pl": "Zapisz ustawienia nawigacji, zanim przejdziesz do działań !!!", "uk": "Будь ласка, збережіть налаштування навігації, перш ніж переходити до дій !!!", "zh-cn": "请在进行操作之前保存导航设置!!!"},
40
41
  };
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "telegram-menu",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "news": {
6
+ "0.0.8": {
7
+ "en": "Send Grafana Diagrams",
8
+ "de": "Grafana-Diagramme senden",
9
+ "ru": "Отправить Grafana Диаграммы",
10
+ "pt": "Enviar Diagramas de Grafana",
11
+ "nl": "Stuur Grafana Diagram",
12
+ "fr": "Envoyer Diagrammes de Grafana",
13
+ "it": "Invia diagrammi Grafana",
14
+ "es": "Enviar diagramas de Grafana",
15
+ "pl": "Senna Diagram",
16
+ "uk": "Відправити граматику Grafana",
17
+ "zh-cn": "Send Grafana Diagram"
18
+ },
6
19
  "0.0.7": {
7
20
  "en": "Bugs fixed\nTranslate",
8
21
  "de": "Fehler behoben\nÜbersetzung",
@@ -125,7 +138,9 @@
125
138
  "checkbox": [],
126
139
  "usersForGlobal": "",
127
140
  "users": [],
128
- "startsides": []
141
+ "startsides": [],
142
+ "tokenGrafana": "",
143
+ "directory": ""
129
144
  },
130
145
  "objects": [],
131
146
  "instanceObjects": [
package/lib/js/action.js CHANGED
@@ -112,6 +112,9 @@ function generateActions(_this, action, nameObj) {
112
112
  try {
113
113
  _this.log.debug("action set: " + JSON.stringify(action.set));
114
114
  _this.log.debug("action get: " + JSON.stringify(action.get));
115
+ _this.log.debug("action pic: " + JSON.stringify(action.pic));
116
+ _this.log.debug("action : " + JSON.stringify(action));
117
+
115
118
  action.set.forEach(function (element, key) {
116
119
  if (key == 0) nameObj[element.trigger] = { switch: [] };
117
120
  nameObj[element.trigger] = { switch: [] };
@@ -148,7 +151,21 @@ function generateActions(_this, action, nameObj) {
148
151
  nameObj[element.trigger].getData.push(newObj);
149
152
  });
150
153
  });
151
- _this.log.debug("Obj set + get: " + JSON.stringify(nameObj));
154
+ action.pic.forEach(function (element, key) {
155
+ _this.log.debug("Pic ");
156
+ nameObj[element.trigger] = { sendPic: [] };
157
+ if (key == 0) nameObj[element.trigger] = { sendPic: [] };
158
+ element.IDs.forEach(function (id, key) {
159
+ const newObj = {
160
+ id: element.IDs[key],
161
+ delay: element.picSendDelay[key],
162
+ fileName: element.fileName[key],
163
+ };
164
+ _this.log.debug("Element Pic: " + JSON.stringify(element));
165
+ _this.log.debug("Trigger: " + JSON.stringify(element.trigger));
166
+ nameObj[element.trigger].sendPic.push(newObj);
167
+ });
168
+ });
152
169
  return nameObj;
153
170
  } catch (err) {
154
171
  console.log("Error generateActions: " + err);
package/main.js CHANGED
@@ -7,6 +7,7 @@
7
7
  // The adapter-core module gives you access to the core ioBroker functions
8
8
  // you need to create an adapter
9
9
  const utils = require("@iobroker/adapter-core");
10
+ const { exec } = require("child_process");
10
11
  const sendToTelegram = require("./lib/js/telegram").sendToTelegram;
11
12
  const editArrayButtons = require("./lib/js/action").editArrayButtons;
12
13
  const generateNewObjectStructure = require("./lib/js/action").generateNewObjectStructure;
@@ -15,6 +16,8 @@ const generateActions = require("./lib/js/action").generateActions;
15
16
  // const wertUebermitteln = require("./lib/js/action").wertUebermitteln;
16
17
 
17
18
  const telegramID = "telegram.0.communicate.request";
19
+ let timeouts = [];
20
+ let timeoutKey = 0;
18
21
 
19
22
  // Load your modules here, e.g.:
20
23
  // const fs = require("fs");
@@ -34,11 +37,6 @@ class TelegramMenu extends utils.Adapter {
34
37
  this.on("message", this.onMessage.bind(this));
35
38
  this.on("unload", this.onUnload.bind(this));
36
39
  }
37
-
38
- /**
39
- * Is called when databases are connected and adapter received configuration.
40
- */
41
-
42
40
  async onReady() {
43
41
  this.setState("info.connection", false, true);
44
42
  const datapoint = `${this.config.instance}.info.connection`;
@@ -73,29 +71,33 @@ class TelegramMenu extends utils.Adapter {
73
71
  this.log.debug("Action " + JSON.stringify(action));
74
72
  try {
75
73
  for (const name in nav) {
76
- this.log.debug("Name " + JSON.stringify(name));
77
74
  const value = await editArrayButtons(nav[name], this);
78
- this.log.debug("Array Buttons: " + JSON.stringify(value));
79
75
  menu.data[name] = await generateNewObjectStructure(_this, value);
80
76
  this.log.debug("New Structure: " + JSON.stringify(menu.data[name]));
81
77
  menu.data[name] = await generateActions(_this, action[name], menu.data[name]);
78
+ this.log.debug("Name " + JSON.stringify(name));
79
+ this.log.debug("Array Buttons: " + JSON.stringify(value));
80
+
82
81
  this.log.debug("Gen. Actions: " + JSON.stringify(menu.data[name]));
83
82
  }
84
83
  } catch (err) {
85
84
  this.log.error("Error generateNav: " + JSON.stringify(err));
86
85
  }
86
+
87
87
  const checkbox = this.config.checkbox;
88
- this.log.debug("Checkbox " + JSON.stringify(checkbox));
89
88
  const globalUserActiv = this.config.checkbox[0]["globalUserActiv"];
90
89
  const one_time_keyboard = this.config.checkbox[2]["oneTiKey"];
91
90
  const resize_keyboard = this.config.checkbox[1]["resKey"];
92
-
93
91
  const userList = this.config.users;
94
92
  const globalUserList = this.config.usersForGlobal.split(",");
93
+ const startsides = this.config.startsides;
94
+ let token = this.config.tokenGrafana;
95
+ const directoryPicture = this.config.directory;
96
+
97
+ this.log.debug("Checkbox " + JSON.stringify(checkbox));
95
98
  this.log.debug("UserList: " + JSON.stringify(userList));
96
99
  this.log.debug("Global User Activ: " + JSON.stringify(globalUserActiv));
97
100
  this.log.debug("Global User List: " + JSON.stringify(globalUserList));
98
- const startsides = this.config.startsides;
99
101
 
100
102
  if (globalUserActiv) {
101
103
  this.log.debug("Global Users sendto ");
@@ -241,6 +243,41 @@ class TelegramMenu extends utils.Adapter {
241
243
  this.log.error("Error Getdata: " + JSON.stringify(error));
242
244
  }
243
245
  }
246
+ if (part.sendPic) {
247
+ this.log.debug("Send Picture");
248
+
249
+ part.sendPic.forEach((element) => {
250
+ // this.log.debug("Element " + JSON.stringify(element));
251
+ token = token.trim();
252
+ const url = element.id;
253
+ const newUrl = url.replace(/&amp;/g, "&");
254
+ exec(
255
+ `curl -H "Authorisation: Bearer ${token}" "${newUrl}" > ${directoryPicture}${element.fileName}`,
256
+ );
257
+ this.log.debug(
258
+ "url " +
259
+ `curl -H "Authorisation: Bearer ${token}" "${newUrl}" > ${directoryPicture}${element.fileName}`,
260
+ );
261
+ timeoutKey += 1;
262
+ const path = `${directoryPicture}${element.fileName}`;
263
+ const timeout = setTimeout(async () => {
264
+ this.sendTo(
265
+ "telegram",
266
+ path,
267
+
268
+ function (res) {
269
+ console.log("Sent to " + res + " users!");
270
+ },
271
+ );
272
+
273
+ let timeoutToClear = {};
274
+ timeoutToClear = timeouts.filter((item) => item.key == timeoutKey);
275
+ clearTimeout(timeoutToClear.timeout);
276
+ timeouts = timeouts.filter((item) => item.key !== timeoutKey);
277
+ }, element.delay);
278
+ timeouts.push({ key: timeoutKey, timeout: timeout });
279
+ });
280
+ }
244
281
  } else {
245
282
  if (typeof userToSend == "string")
246
283
  sendToTelegram(this, userToSend, "Eintrag wurde nicht gefunden!");
@@ -313,7 +350,9 @@ class TelegramMenu extends utils.Adapter {
313
350
  onUnload(callback) {
314
351
  try {
315
352
  // Here you must clear all timeouts or intervals that may still be active
316
- // clearTimeout(timeout1);
353
+ timeouts.forEach((element) => {
354
+ clearTimeout(element.timeout);
355
+ });
317
356
  // clearTimeout(timeout2);
318
357
  // ...
319
358
  // clearInterval(interval1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.telegram-menu",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Easily create Telegram Menus",
5
5
  "author": {
6
6
  "name": "MiRo1310",
@@ -31,23 +31,23 @@
31
31
  "@iobroker/adapter-dev": "^1.2.0",
32
32
  "@iobroker/testing": "^4.1.0",
33
33
  "@tsconfig/node16": "^1.0.3",
34
- "@types/chai": "^4.3.4",
34
+ "@types/chai": "^4.3.5",
35
35
  "@types/chai-as-promised": "^7.1.5",
36
36
  "@types/jquery": "^3.5.16",
37
37
  "@types/mocha": "^10.0.1",
38
- "@types/node": "^18.15.11",
38
+ "@types/node": "^18.16.3",
39
39
  "@types/proxyquire": "^1.3.28",
40
40
  "@types/sinon": "^10.0.13",
41
41
  "@types/sinon-chai": "^3.2.9",
42
42
  "chai": "^4.3.7",
43
43
  "chai-as-promised": "^7.1.1",
44
- "eslint": "^8.38.0",
44
+ "eslint": "^8.39.0",
45
45
  "eslint-config-prettier": "^8.8.0",
46
46
  "eslint-plugin-prettier": "^4.2.1",
47
47
  "mocha": "^10.2.0",
48
- "prettier": "^2.8.7",
48
+ "prettier": "^2.8.8",
49
49
  "proxyquire": "^2.1.3",
50
- "sinon": "^15.0.3",
50
+ "sinon": "^15.0.4",
51
51
  "sinon-chai": "^3.7.0",
52
52
  "typescript": "~5.0.4"
53
53
  },