From 465ca59e4ceaf8e656a03c0a889b0f732252bf3b Mon Sep 17 00:00:00 2001 From: "J.H. Artworks" <98522442+jhartworks@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:58:41 +0200 Subject: [PATCH] Add files via upload --- Trello Read Cards/form.json | 23 +++++++ Trello Read Cards/module.json | 14 ++++ Trello Read Cards/module.php | 117 ++++++++++++++++++++++++++++++++++ library.json | 13 ++++ 4 files changed, 167 insertions(+) create mode 100644 Trello Read Cards/form.json create mode 100644 Trello Read Cards/module.json create mode 100644 Trello Read Cards/module.php create mode 100644 library.json diff --git a/Trello Read Cards/form.json b/Trello Read Cards/form.json new file mode 100644 index 0000000..75eedee --- /dev/null +++ b/Trello Read Cards/form.json @@ -0,0 +1,23 @@ +{ + "elements": + [ + { "type": "Label", "caption": "Trello Properties" }, + { "type": "ValidationTextBox", "name": "TrelloBoardId", "caption": "Trello Board-ID" }, + { "type": "ValidationTextBox", "name": "TrelloApiKey", "caption": "Trello API-Key" }, + { "type": "ValidationTextBox", "name": "TrelloApiToken", "caption": "Trello API-Token" }, + { "type": "NumberSpinner", "name": "Updateintervall", "caption": "Minutes" }, + { "type": "Label", "caption": "HTML-Box Properties" }, + { "type": "ValidationTextBox", "name": "BgColor", "caption": "Backgoundcolor as HEX or HTML-Color" }, + { "type": "ValidationTextBox", "name": "FontColor", "caption": "Fontcolor as HEX or HTML-Color" }, + { "type": "ValidationTextBox", "name": "FontSize", "caption": "Fontsize as px or rem" }, + { "type": "ValidationTextBox", "name": "HoverColor", "caption": "Hovercolor as HEX or HTML-Color" } + ], + "actions": + [ + { "type": "Button", "label": "Update", "onClick": "TRC_Update($id);" } + ], + "status": + [ + + ] +} \ No newline at end of file diff --git a/Trello Read Cards/module.json b/Trello Read Cards/module.json new file mode 100644 index 0000000..a1f3af3 --- /dev/null +++ b/Trello Read Cards/module.json @@ -0,0 +1,14 @@ +{ + "id": "{907267F9-9AEA-9AA3-E88D-F38E450341AD}", + "name": "Trello Read Cards", + "type": 3, + "vendor": "Trello", + "aliases": + [ + ], + "url": "https://jh-artworks.com", + "parentRequirements": [], + "childRequirements": [], + "implemented": [], + "prefix": "TRC" +} \ No newline at end of file diff --git a/Trello Read Cards/module.php b/Trello Read Cards/module.php new file mode 100644 index 0000000..00b3e7b --- /dev/null +++ b/Trello Read Cards/module.php @@ -0,0 +1,117 @@ + +// Klassendefinition +class TrelloReadCards extends IPSModule { + // Überschreibt die interne IPS_Create($id) Funktion + public function Create() { + // Diese Zeile nicht löschen. + parent::Create(); + + $this->RegisterPropertyString("TrelloBoardId",""); + $this->RegisterPropertyString("TrelloApiKey",""); + $this->RegisterPropertyString("TrelloApiToken",""); + + $this->RegisterPropertyString("BgColor","#4CAF50"); + $this->RegisterPropertyString("FontColor","white"); + $this->RegisterPropertyString("FontSize","1.5rem"); + $this->RegisterPropertyString("HoverColor","lightblue"); + + $this->RegisterTimer("Update", 0, 'TRC_Update('.$this->InstanceID.');'); + $this->RegisterPropertyInteger("Updateintervall",5); + } + + // Überschreibt die intere IPS_ApplyChanges($id) Funktion + public function ApplyChanges() { + // Diese Zeile nicht löschen + parent::ApplyChanges(); + $this->SetTimerInterval("Update", $this->ReadPropertyInteger("Updateintervall") * 60 * 1000); + } + /** + * Die folgenden Funktionen stehen automatisch zur Verfügung, wenn das Modul über die "Module Control" eingefügt wurden. + * Die Funktionen werden, mit dem selbst eingerichteten Prefix, in PHP und JSON-RPC wiefolgt zur Verfügung gestellt: + * + * DWM_SendMessage($id); + * + */ + public function Update() { + + // Discord webhook URL + $boardid = $this->ReadPropertyString("TrelloBoardId"); + $apikey = $this->ReadPropertyString("TrelloApiKey"); + $apitoken = $this->ReadPropertyString("TrelloApiToken"); + $bgcolor = $this->ReadPropertyString("BgColor"); + $fontcolor = $this->ReadPropertyString("FontColor"); + $fontsize = $this->ReadPropertyString("FontSize"); + $hovercolor = $this->ReadPropertyString("HoverColor"); + + $url ='https://api.trello.com/1/boards/'.$boardid.'/lists?key='.$apikey.'&token='.$apitoken.''; ///get all lists on board + $ch = curl_init(); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_URL, $url); + $output = curl_exec($ch); + curl_close($ch); + $content = json_decode($output, true); + + + $lists=$content; + foreach ($lists as $list) + { + + + $url = 'https://api.trello.com/1/lists/'.$list['id'].'/cards?key='.$apikey.'&token='.$apitoken.''; ///get all cards on list + $ch = curl_init(); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_URL, $url); + $output = curl_exec($ch); + curl_close($ch); + $content = json_decode($output, true); + ///print_r($list['name']); + $allcardsFull[$list['name']]=$content; + } + ////print_r($allcardsFull); + + + + + $style = ' + + '; + $keyindex =0; + $keys = array_keys($allcardsFull); + foreach ($allcardsFull as $cardfull){ + + $tdhtml =''; + + + foreach($cardfull as $card) { + + $tdhtml .= '