CalibreDashboard

A flow to search in a calibre (EBook-management) Database and present results with FlowFuse Dashboard 2.0

Example

[{"id":"e204e0588d4a2427","type":"tab","label":"CalibreDashboard v1.0","disabled":false,"info":"1. make a forlder for static files\n2. add this folder to settings.js (httpStatic)\n3. edit Config-Node\n\n","env":[]},{"id":"e9432e76f4ad4476","type":"ui-dropdown","z":"e204e0588d4a2427","group":"791594e68a16b741","name":"","label":"Tags:","tooltip":"","order":2,"width":0,"height":0,"passthru":false,"multiple":false,"chips":false,"clearable":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","typeIsComboBox":false,"x":790,"y":120,"wires":[["58af8ff26eefb25f","be42f5cb976729f7","66a67391e22cf3fa","b314a0bfb177776f"]]},{"id":"be859a0616e1ccfb","type":"ui-table","z":"e204e0588d4a2427","group":"791594e68a16b741","name":"","label":"text","order":3,"width":0,"height":0,"maxrows":"25","passthru":false,"autocols":false,"showSearch":false,"selectionType":"click","columns":[{"title":"Titel","key":"title","type":"text","width":"","align":"start"},{"title":"Autor(en)","key":"authors","type":"text","width":"","align":"start"},{"title":"Datum","key":"formatedtimestamp","type":"text","width":"150px","align":"start"},{"title":"Größe","key":"formatedsize","type":"text","width":"40","align":"end"},{"title":"Format","key":"extension","type":"text","width":"80px","align":"end"},{"title":"","key":"coverpath","type":"html","width":"80px","align":"end"}],"mobileBreakpoint":"sm","mobileBreakpointType":"defaults","x":1090,"y":300,"wires":[["6bbfe783b00da15c"]]},{"id":"8d3af2a2cc9bcd32","type":"array-loop","z":"e204e0588d4a2427","name":"","key":"bookid","keyType":"msg","reset":true,"resetValue":"value-null","array":"books","arrayType":"msg","x":410,"y":300,"wires":[["44b9c6c535fe9f89"],["d10a7f80bd60cdaf"]]},{"id":"7b06c20532bbafa4","type":"change","z":"e204e0588d4a2427","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"books","tot":"msg"},{"t":"delete","p":"rc","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":200,"wires":[["8d3af2a2cc9bcd32"]]},{"id":"d10a7f80bd60cdaf","type":"change","z":"e204e0588d4a2427","name":"","rules":[{"t":"set","p":"source","pt":"msg","to":"payload.cover","tot":"msg"},{"t":"set","p":"localFilename","pt":"msg","to":"$flowContext(\"staticpath\") & \"cover_\" & payload.id & \".jpg\"","tot":"jsonata"},{"t":"set","p":"coverpath","pt":"msg","to":"$flowContext(\"webstaticpath\") & \"cover_\" & payload.id & \".jpg\"","tot":"jsonata"},{"t":"set","p":"book","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":380,"wires":[["88b94345b24f2b15"]]},{"id":"7434bc8ad985b396","type":"change","z":"e204e0588d4a2427","name":"nocover","rules":[{"t":"set","p":"coverpath","pt":"msg","to":"$flowContext(\"webstaticpath\") & \"nocover.jpg\"","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":520,"wires":[["0b5daa6fe344d369"]]},{"id":"0b5daa6fe344d369","type":"function","z":"e204e0588d4a2427","name":"function 99","func":"function formatBytes(bytes) {\n    const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];\n    if (bytes === 0) return '0 Bytes';\n    \n    const i = Math.floor(Math.log(bytes) / Math.log(1024));\n    const formattedSize = (bytes / Math.pow(1024, i)).toFixed(2);\n    \n    return `${formattedSize} ${sizes[i]}`;\n}\n\nmsg.books[msg.bookid][\"coverpath\"] = \"<img src='\" + msg.coverpath + \"' width='80px' border='1px'></img>\"\nif (msg.book.formats.length > 0){\n    msg.books[msg.bookid][\"extension\"] = msg.book.formats[0].substring(msg.book.formats[0].lastIndexOf('.') + 1).toUpperCase();\n    msg.books[msg.bookid][\"formatedsize\"] = formatBytes(msg.book.size);\n} else {\n    msg.books[msg.bookid][\"extension\"] = \"\"\n    msg.books[msg.bookid][\"formatedsize\"] = \"\"\n}\n// Datum in ein Date-Objekt umwandeln\nconst date = new Date(msg.book.timestamp);\nmsg.books[msg.bookid][\"formatedtimestamp\"] = date.toISOString().split('T')[0];\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1110,"y":380,"wires":[["8d3af2a2cc9bcd32"]]},{"id":"44b9c6c535fe9f89","type":"change","z":"e204e0588d4a2427","name":"optimize msg","rules":[{"t":"move","p":"books","pt":"msg","to":"payload","tot":"msg"},{"t":"delete","p":"source","pt":"msg"},{"t":"delete","p":"book","pt":"msg"},{"t":"delete","p":"timestamp","pt":"msg"},{"t":"delete","p":"localFilename","pt":"msg"},{"t":"delete","p":"bookid","pt":"msg"},{"t":"delete","p":"columns","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":300,"wires":[["be859a0616e1ccfb"]]},{"id":"665a1e491dfdff36","type":"jimp-image","z":"e204e0588d4a2427","name":"scale cover","data":"source","dataType":"msg","ret":"buf","parameter1":"80","parameter1Type":"num","parameter2":"","parameter2Type":"auto","parameter3":"","parameter3Type":"msg","parameter4":"","parameter4Type":"msg","parameter5":"","parameter5Type":"msg","parameter6":"","parameter6Type":"msg","parameter7":"","parameter7Type":"msg","parameter8":"","parameter8Type":"msg","sendProperty":"payload","sendPropertyType":"msg","parameterCount":3,"jimpFunction":"scaleToFit","selectedJimpFunction":{"name":"scaleToFit","fn":"scaleToFit","description":"scale the image to the largest size that fits inside the given width and height. One of the w or h parameters can be set to automatic (\"Jimp.AUTO\" or -1).","parameters":[{"name":"w","type":"num|auto","required":true,"hint":"the width to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"h","type":"num|auto","required":true,"hint":"the height to resize the image to (or \"Jimp.AUTO\" or -1)"},{"name":"mode","type":"resizeMode","required":false,"hint":"a scaling method (e.g. Jimp.RESIZE_BEZIER)"}]},"x":890,"y":500,"wires":[["adf54a91679372af"]]},{"id":"adf54a91679372af","type":"file","z":"e204e0588d4a2427","name":"write thumb","filename":"localFilename","filenameType":"msg","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":1030,"y":460,"wires":[["0b5daa6fe344d369"]]},{"id":"f7917e51429717ca","type":"fs-access","z":"e204e0588d4a2427","name":"thumb exist?","path":"","pathType":"str","filename":"localFilename","filenameType":"msg","accessRead":true,"accessWrite":false,"x":830,"y":380,"wires":[["0b5daa6fe344d369"],["665a1e491dfdff36"]]},{"id":"c26c066a96093053","type":"fs-access","z":"e204e0588d4a2427","name":"cover exist?","path":"","pathType":"str","filename":"source","filenameType":"msg","accessRead":true,"accessWrite":false,"x":630,"y":420,"wires":[["f7917e51429717ca"],["7434bc8ad985b396"]]},{"id":"fb1c51c67bd56d7a","type":"change","z":"e204e0588d4a2427","name":"clear table","rules":[{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":240,"wires":[["be859a0616e1ccfb"]]},{"id":"f3831df93bd5be3f","type":"ui-template","z":"e204e0588d4a2427","group":"791594e68a16b741","page":"","ui":"","name":"Frame","order":4,"width":"12","height":"12","head":"","format":"<template>\n    <div>\n        <iframe :src=\"msg.payload\" style=\"border: none; width: 100%; height:100%\"></iframe>\n    </div>\n</template>","storeOutMessages":true,"passthru":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":1090,"y":640,"wires":[[]]},{"id":"6bbfe783b00da15c","type":"random-string","z":"e204e0588d4a2427","size":16,"characters":"","property":"random","x":160,"y":640,"wires":[["f713855d01377db0"]]},{"id":"a74c9467ad96edf2","type":"change","z":"e204e0588d4a2427","name":"","rules":[{"t":"set","p":"source","pt":"msg","to":"payload.formats[0]","tot":"msg"},{"t":"set","p":"destination","pt":"msg","to":"$flowContext(\"staticpath\") & filename & \"_\" & random & \".\" & extension","tot":"jsonata"},{"t":"set","p":"webpath","pt":"msg","to":"$flowContext(\"webstaticpath\") & filename & \"_\" & random & \".\" & extension","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":640,"wires":[["c1e89a4b23a32bb7"]]},{"id":"c1e89a4b23a32bb7","type":"fs-copy-move","z":"e204e0588d4a2427","oper":"cp","srcPath":"","srcPathType":"str","srcFilename":"source","srcFilenameType":"msg","dstPath":"","dstPathType":"str","dstFilename":"destination","dstFilenameType":"msg","overwrite":true,"name":"","x":720,"y":640,"wires":[["b98d8aa7387c5bc2"]]},{"id":"d71456dd359727ce","type":"exec","z":"e204e0588d4a2427","command":"calibredb list_categories -r tags -c ","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"all tags","x":260,"y":140,"wires":[["3c2885c120c00ba8"],[],[]]},{"id":"ca3c3c4c05bd2c98","type":"inject","z":"e204e0588d4a2427","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"--with-library \" & $flowContext(\"calibredb\")","payloadType":"jsonata","x":90,"y":140,"wires":[["d71456dd359727ce"]]},{"id":"3c2885c120c00ba8","type":"csv","z":"e204e0588d4a2427","name":"","spec":"rfc","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\r\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":410,"y":120,"wires":[["8cd3e051e25d170d"]]},{"id":"8cd3e051e25d170d","type":"change","z":"e204e0588d4a2427","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload.tag_name","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":120,"wires":[["e9432e76f4ad4476"]]},{"id":"943f7ca0ef5873ee","type":"exec","z":"e204e0588d4a2427","command":"calibredb ","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"books","x":350,"y":220,"wires":[["206388293ee76751"],[],[]]},{"id":"206388293ee76751","type":"json","z":"e204e0588d4a2427","name":"","property":"payload","action":"","pretty":false,"x":530,"y":200,"wires":[["7b06c20532bbafa4"]]},{"id":"58af8ff26eefb25f","type":"change","z":"e204e0588d4a2427","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"list --for-machine -s tags:\\\"\" & \tpayload & \"\\\" --with-library \" & \t$flowContext(\"calibredb\") & \t\" --fields id,authors,title,timestamp,cover,formats,size\"\t","tot":"jsonata"},{"t":"delete","p":"options","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":220,"wires":[["943f7ca0ef5873ee"]]},{"id":"d41cb51c31bfe1a6","type":"config","z":"e204e0588d4a2427","name":"","properties":[{"p":"calibredb","pt":"flow","to":"/calibredb/","tot":"str"},{"p":"staticpath","pt":"flow","to":"/home/user/staticarchiv/","tot":"str"},{"p":"webstaticpath","pt":"flow","to":"https://example.com/node-red/staticarchiv/","tot":"str"}],"active":true,"x":90,"y":40,"wires":[]},{"id":"f713855d01377db0","type":"function","z":"e204e0588d4a2427","name":"filename op","func":"// Extrahiere den Dateinamen ohne Erweiterung\nconst fileNameWithExtension = msg.payload.formats[0].split('/').pop();\nmsg.filename = fileNameWithExtension.substring(0, fileNameWithExtension.lastIndexOf('.'));\nmsg.extension = fileNameWithExtension.split('.').pop();\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":640,"wires":[["a74c9467ad96edf2"]]},{"id":"b98d8aa7387c5bc2","type":"change","z":"e204e0588d4a2427","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"webpath","tot":"msg"},{"t":"delete","p":"action","pt":"msg"},{"t":"delete","p":"random","pt":"msg"},{"t":"delete","p":"filename","pt":"msg"},{"t":"delete","p":"destination","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":640,"wires":[["f3831df93bd5be3f"]]},{"id":"53973371d75a3228","type":"ui-text-input","z":"e204e0588d4a2427","group":"791594e68a16b741","name":"search input","label":"Suche","order":1,"width":0,"height":0,"topic":"topic","topicType":"msg","mode":"text","tooltip":"","delay":300,"passthru":false,"sendOnDelay":false,"sendOnBlur":false,"sendOnEnter":true,"className":"","clearable":true,"sendOnClear":false,"icon":"","iconPosition":"left","iconInnerPosition":"inside","x":110,"y":480,"wires":[["b14436189805ee17","da99fd7c8fd8b497","9fe1f01e14ac06ac","6cfbb18de23c5ed5"]]},{"id":"b14436189805ee17","type":"change","z":"e204e0588d4a2427","name":"search","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"list --for-machine -s \\\"author:\" & payload & \t\" or title:\" & payload & \t\" or tags:\" & payload & \"\\\" --with-library \" & \t$flowContext(\"calibredb\") & \t\" --fields id,authors,title,timestamp,cover,formats,size\"\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":440,"wires":[["943f7ca0ef5873ee"]]},{"id":"2364b75af11f05bc","type":"change","z":"e204e0588d4a2427","name":"clear selection","rules":[{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":60,"wires":[["e9432e76f4ad4476"]]},{"id":"2c99124e383f00fb","type":"change","z":"e204e0588d4a2427","name":"clear search","rules":[{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":130,"y":420,"wires":[["53973371d75a3228"]]},{"id":"0b46c12451a8bc8c","type":"link in","z":"e204e0588d4a2427","name":"clear table","links":["be42f5cb976729f7","da99fd7c8fd8b497"],"x":965,"y":240,"wires":[["fb1c51c67bd56d7a"]]},{"id":"be42f5cb976729f7","type":"link out","z":"e204e0588d4a2427","name":"link out 3","mode":"link","links":["0b46c12451a8bc8c"],"x":905,"y":120,"wires":[]},{"id":"da99fd7c8fd8b497","type":"link out","z":"e204e0588d4a2427","name":"link out 4","mode":"link","links":["0b46c12451a8bc8c"],"x":245,"y":480,"wires":[]},{"id":"9e83541eb90363f5","type":"link in","z":"e204e0588d4a2427","name":"clear selection","links":["9fe1f01e14ac06ac"],"x":625,"y":60,"wires":[["2364b75af11f05bc"]]},{"id":"9fe1f01e14ac06ac","type":"link out","z":"e204e0588d4a2427","name":"link out 5","mode":"link","links":["9e83541eb90363f5"],"x":245,"y":520,"wires":[]},{"id":"7ec985d6bf3a4bf4","type":"link in","z":"e204e0588d4a2427","name":"clear search","links":["66a67391e22cf3fa"],"x":25,"y":420,"wires":[["2c99124e383f00fb"]]},{"id":"66a67391e22cf3fa","type":"link out","z":"e204e0588d4a2427","name":"link out 6","mode":"link","links":["7ec985d6bf3a4bf4"],"x":905,"y":80,"wires":[]},{"id":"7ace1fa8ea516803","type":"change","z":"e204e0588d4a2427","name":"clear content","rules":[{"t":"set","p":"payload","pt":"msg","to":"about:blank","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1040,"y":580,"wires":[["f3831df93bd5be3f"]]},{"id":"6571297129e6f03c","type":"link in","z":"e204e0588d4a2427","name":"clear iframe","links":["6cfbb18de23c5ed5","b314a0bfb177776f"],"x":935,"y":580,"wires":[["7ace1fa8ea516803"]]},{"id":"6cfbb18de23c5ed5","type":"link out","z":"e204e0588d4a2427","name":"link out 7","mode":"link","links":["6571297129e6f03c"],"x":245,"y":560,"wires":[]},{"id":"b314a0bfb177776f","type":"link out","z":"e204e0588d4a2427","name":"link out 8","mode":"link","links":["6571297129e6f03c"],"x":905,"y":160,"wires":[]},{"id":"88b94345b24f2b15","type":"switch","z":"e204e0588d4a2427","name":"","property":"payload.cover","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":440,"wires":[["c26c066a96093053"],["7434bc8ad985b396"]]},{"id":"791594e68a16b741","type":"ui-group","name":"Group Name","page":"f43bc662814d3993","width":"12","height":"1","order":1,"showTitle":false,"className":"","visible":"true","disabled":"false"},{"id":"f43bc662814d3993","type":"ui-page","name":"Archiv","ui":"ae9941931eba4fdb","path":"/archiv","icon":"home","layout":"grid","theme":"d380cff3ad86b3e6","order":2,"className":"","visible":"false","disabled":"true"},{"id":"ae9941931eba4fdb","type":"ui-base","name":"My Dashboard","path":"/dashboard","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control","ui-table","ui-dropdown"],"showPathInSidebar":false,"showPageTitle":true,"navigationStyle":"default","titleBarStyle":"default"},{"id":"d380cff3ad86b3e6","type":"ui-theme","name":"Default Theme","colors":{"surface":"#ffffff","primary":"#0094ce","bgPage":"#eeeeee","groupBg":"#ffffff","groupOutline":"#cccccc"},"sizes":{"pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

Flow Info

Created 2 months, 3 weeks ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x13)
  • csv (x1)
  • exec (x2)
  • file (x1)
  • function (x2)
  • inject (x1)
  • json (x1)
  • link in (x4)
  • link out (x6)
  • switch (x1)
Other

Tags

  • calibre
  • ebooks
  • web
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option