{"id":1137,"date":"2020-12-24T17:18:19","date_gmt":"2020-12-24T16:18:19","guid":{"rendered":"https:\/\/next-hack.com\/?p=1137"},"modified":"2021-01-01T23:16:59","modified_gmt":"2021-01-01T22:16:59","slug":"emoncms-customize-it-ii","status":"publish","type":"post","link":"https:\/\/next-hack.com\/index.php\/2020\/12\/24\/emoncms-customize-it-ii\/","title":{"rendered":"Emoncms &#8211; customize it (II)"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"72\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/167991_low.png\" alt=\"\" class=\"wp-image-1123\"\/><\/figure>\n\n\n\n<p>On the <a href=\"https:\/\/next-hack.com\/index.php\/2020\/12\/08\/emoncms-customize-it-i\/\">previous<\/a> article of this section, we described how to perform a first customization on a LED widget on our nice <a rel=\"noreferrer noopener\" href=\"https:\/\/emoncms.org\/\" data-type=\"URL\" data-id=\"https:\/\/emoncms.org\/\" target=\"_blank\">Emoncms<\/a> visualization interface. Now it&#8217;s time to go on and teach you some further hints, which aim is to introduce you how you can yourself peep inside the code to modify the elements according to your needs.<br>So this time we are going to customize the so called &#8220;containers&#8221;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Containers<\/h3>\n\n\n\n<p>If you need to draw a layout of the page in order to organize widgets according a common field of application, you need to use containers. Containers are just a graphical support consisting in a squared coloured background or a squared coloured border. By default only white and gray backgrounds or a blue line border are available.<br>Let&#8217;s see an example of how different colours can be used to organize and improve the view, before entering into the coding details.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"803\" height=\"494\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/bordersExample.png\" alt=\"\" class=\"wp-image-1142\"\/><figcaption>1: Different color borders use<\/figcaption><\/figure>\n\n\n\n<p>In the above example (fig. 1) different colour borders have been used to define at first glance different scopes. A red border refers to UPS power lines, a green border refers to motor generator power line, and a black one refers to main grid supply.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1278\" height=\"344\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/backgroundExample.png\" alt=\"\" class=\"wp-image-1143\"\/><figcaption>2: Different backgounds<\/figcaption><\/figure>\n\n\n\n<p>In the above figure (fig. 2) gray background squares have been used to gather widgets of the same field of interactions. While black background squares have been used to create a sort of footer menu to navigate into detail pages.<\/p>\n\n\n\n<p>So it&#8217;s time see how we can customize <a rel=\"noreferrer noopener\" href=\"https:\/\/emoncms.org\" data-type=\"URL\" data-id=\"https:\/\/emoncms.org\" target=\"_blank\">emoncms<\/a> containers to fit our needs.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">How to:<\/h4>\n\n\n\n<p>First of all, we again remind you to make a backup of your existing configuration or to work on a test environment till you get familiar with the following steps. What we are doing is really easily affordable by anyone with just the basic knowledge of coding.<\/p>\n\n\n\n<p>Once backup is done or test environment available, we should get access to the webserver folder. Depending on your environment and preferences (we are using Debian, and it&#8217;s under \/var\/www\/ ) you&#8217;ll have an emoncms folder containing multiple folders and files. We should go into <code>.\/emoncms\/Modules\/dashboard\/Views\/js\/<\/code> once there you can list the content and you&#8217;ll find a file named <code>widget.css<\/code> and anoter named <code>widgetlist.js<\/code><\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"202\" height=\"228\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/containerDefault.png\" alt=\"\" class=\"wp-image-1154\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-center\">3: Default menu<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"229\" height=\"282\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/containerBasic.png\" alt=\"\" class=\"wp-image-1155\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-center\">4: Default containers<\/p>\n<\/div>\n<\/div>\n\n\n\n<p>The first of the two files defines the graphical aspects of the containers, the latter is necessary to provide the visualization on the drop down list (fig. 3). We can see below the content of our interest in those files.<br><\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-2 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"378\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/widgetOrig.png\" alt=\"\" class=\"wp-image-1157\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-center\">5: widget.css<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"489\" height=\"337\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/widgetlistOrig.png\" alt=\"\" class=\"wp-image-1158\"\/><\/figure>\n\n\n\n<p class=\"has-text-align-center\">6: widgetlist.js<\/p>\n<\/div>\n<\/div>\n\n\n\n<p>Probably you have already guessed what we are going to do now. We would like to add a Container-Black container. So we edit the file wideget.css with our favourite editor (we use vi) and we create a new section:<\/p>\n\n\n\n<p><code>.Container-Black {<br>background: none repeat scroll 0 0 #000;<br>border: 1px solid #888;<br>box-shadow: 0 4px 10px -1px rgba(200, 200, 200, 0.7);<br>margin: 0px;<br>padding: 0px;<br>}<\/code><\/p>\n\n\n\n<p>Colors are in the usual hex rgb scheme (#rrggbb <a rel=\"noreferrer noopener\" href=\"https:\/\/tools.timodenk.com\/?p=rgb-to-hex-conversion\" target=\"_blank\">rgb to hex<\/a> &#8211; shorten version in this case #rgb). Then we need to edit the widgetlist.js to add the newly created container just after the <code>Container-Grey<\/code> item.<\/p>\n\n\n\n<p><code>\"Container-Black\":<br>{<br>\"offsetx\":-100,\"offsety\":-180,\"width\":200,\"height\":360,<br>\"menu\":\"Containers\",<br>\"html\":\"\"<br>},<\/code><\/p>\n\n\n\n<p>Mind the &#8220;,&#8221; at the end of the last line!<br>If everything went fine we can now see the Container-Black on our editing menu and add it to our Dashboard.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-3 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"216\" height=\"225\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/menuPlusSolid.png\" alt=\"\" class=\"wp-image-1160\"\/><figcaption>7: Menu with Container-Black<\/figcaption><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"220\" height=\"270\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/containerPlusSolid.png\" alt=\"\" class=\"wp-image-1161\"\/><figcaption>8: Container-Black<\/figcaption><\/figure><\/div>\n<\/div>\n<\/div>\n\n\n\n<p>After creating a solid container, we are goingto show you how to create also a coloured border container. So let&#8217;s go back to our <code>widget.css<\/code> and add the following lines after the &#8220;<code>Container-BlueLine<\/code>&#8220;<\/p>\n\n\n\n<p><code>.Container-BlackLine {<br><br>border: 3px solid #000000;<br>box-shadow: 0px 0px 2px 2px rgba(200, 200, 200, 0.7);<br>margin: 0px;<br>padding: 0px;<br>}<br><br>.Container-WhiteLine {<br><br>border: 3px solid #ffffff;<br>box-shadow: 0px 0px 2px 2px rgba(200, 200, 200, 0.7);<br>margin: 0px;<br>padding: 0px;<br>}<br><br>.Container-GreenLine {<br><br>border: 3px solid #009900;<br>box-shadow: 0px 0px 2px 2px rgba(200, 200, 200, 0.7);<br>margin: 0px;<br>padding: 0px;<br>}<br><br>.Container-RedLine {<br><br>border: 3px solid #FF0000;<br>box-shadow: 0px 0px 2px 2px rgba(200, 200, 200, 0.7);<br>margin: 0px;<br>padding: 0px;<br>}<\/code><\/p>\n\n\n\n<p>We are creating some containers with empty filling and coloured border: <em>Black, White, Green and Red<\/em>.<br>We have just to add them to the <code>widgetlist.js<\/code> file to make them available and usable in our dashboard.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"Container-BlueLine\":\n{\n  \"offsetx\":-100,\"offsety\":-180,\"width\":200,\"height\":360,\n  \"menu\":\"Containers\",\n  \"html\":\"\"\n},\n\"Container-BlackLine\":\n{\n  \"offsetx\":-100,\"offsety\":-180,\"width\":200,\"height\":360,\n  \"menu\":\"Containers\",\n  \"html\":\"\"\n},\n\"Container-WhiteLine\":\n{\n  \"offsetx\":-100,\"offsety\":-180,\"width\":200,\"height\":360,\n  \"menu\":\"Containers\",\n  \"html\":\"\"\n},\n\"Container-GreenLine\":\n{\n  \"offsetx\":-100,\"offsety\":-180,\"width\":200,\"height\":360,\n  \"menu\":\"Containers\",\n  \"html\":\"\"\n},\n\"Container-RedLine\":\n{\n  \"offsetx\":-100,\"offsety\":-180,\"width\":200,\"height\":360,\n  \"menu\":\"Containers\",\n  \"html\":\"\"\n} &lt;--- comma should miss here!!! as this is the last item\n}; &lt;--- this is the end of the section, don't remove<\/code><\/pre>\n\n\n\n<p>Mind not to copy our notes &#8220;&lt;&#8212;&#8221; with the code, and don&#8217;t duplicate the blue-line which is already present in you file.<br>After this you should have a full menu of different containers to use. And of course, you can make your owns according to your needs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"378\" src=\"https:\/\/next-hack.com\/wp-content\/uploads\/2020\/12\/fullCustom.png\" alt=\"\" class=\"wp-image-1165\"\/><figcaption>9: Full customization<\/figcaption><\/figure>\n\n\n\n<p>On fig. 9 you can see all the customization we did in this example. Now you&#8217;re able to go further! See you for new hints on the next article.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On the previous article of this section, we described how to perform a first customization on a LED widget on our nice Emoncms visualization interface. Now it&#8217;s time to go on and teach you some further hints, which aim is&#8230; <a class=\"read-more-button\" href=\"https:\/\/next-hack.com\/index.php\/2020\/12\/24\/emoncms-customize-it-ii\/\">(READ MORE)<\/a><\/p>\n","protected":false},"author":3,"featured_media":1175,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[32,34,35,1],"tags":[36],"class_list":["post-1137","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all-projects","category-building-automation","category-emoncms","category-general-hacks","tag-emoncms"],"_links":{"self":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts\/1137"}],"collection":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/comments?post=1137"}],"version-history":[{"count":28,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts\/1137\/revisions"}],"predecessor-version":[{"id":1174,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/posts\/1137\/revisions\/1174"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/media\/1175"}],"wp:attachment":[{"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/media?parent=1137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/categories?post=1137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/next-hack.com\/index.php\/wp-json\/wp\/v2\/tags?post=1137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}