| OLD | NEW |
| 1 <link rel="import" href="/bower_components/polymer/polymer.html"> | 1 <link rel="import" href="/bower_components/polymer/polymer.html"> |
| 2 <link rel="import" href="/bower_components/iron-ajax/iron-ajax.html"> | 2 <link rel="import" href="/bower_components/iron-ajax/iron-ajax.html"> |
| 3 <link rel="import" href="/bower_components/iron-icon/iron-icon.html"> |
| 3 <link rel="import" href="/bower_components/paper-item/paper-item.html"> | 4 <link rel="import" href="/bower_components/paper-item/paper-item.html"> |
| 4 <link rel="import" href="/bower_components/paper-checkbox/paper-checkbox.html"> | 5 <link rel="import" href="/bower_components/paper-checkbox/paper-checkbox.html"> |
| 5 <link rel="import" href="/bower_components/paper-menu/paper-menu.html"> | 6 <link rel="import" href="/bower_components/paper-menu/paper-menu.html"> |
| 6 | 7 |
| 7 <dom-module id="som-drawer"> | 8 <dom-module id="som-drawer"> |
| 8 <template> | 9 <template> |
| 9 <style> | 10 <style> |
| 11 h2 { |
| 12 box-sizing: border-box; |
| 13 font-size: 24px; |
| 14 font-weight: bold; |
| 15 padding: 0 5px 5px; |
| 16 width: 95%; |
| 17 margin: 15px auto 10px; |
| 18 border-bottom: 1px solid #bbb; |
| 19 } |
| 20 h2 iron-icon { |
| 21 padding-right: 5px; |
| 22 width: 25px; |
| 23 height: 25px; |
| 24 } |
| 25 paper-checkbox { |
| 26 padding-bottom: 10px; |
| 27 } |
| 10 paper-item { | 28 paper-item { |
| 11 font-size: 26px; | 29 padding-left: 42px; |
| 30 font-size: 22px; |
| 12 -webkit-transition: background .3s ease; | 31 -webkit-transition: background .3s ease; |
| 13 transition: background .3s ease; | 32 transition: background .3s ease; |
| 14 } | 33 } |
| 15 paper-item:hover { | 34 paper-item:hover { |
| 16 cursor: pointer; | 35 cursor: pointer; |
| 17 background-color: #eee; | 36 background-color: #eee; |
| 18 } | 37 } |
| 19 paper-checkbox { | |
| 20 padding-bottom: 10px; | |
| 21 } | |
| 22 hr { | |
| 23 width: 90%; | |
| 24 background-color: #000; | |
| 25 } | |
| 26 </style> | 38 </style> |
| 27 <iron-ajax | 39 <iron-ajax |
| 28 auto | 40 auto |
| 29 url="/api/v1/trees" | 41 url="/api/v1/trees" |
| 30 handle-as="json" | 42 handle-as="json" |
| 31 verbose | 43 verbose |
| 32 last-response="{{_treeList}}" | 44 last-response="{{_treeList}}" |
| 33 ></iron-ajax> | 45 ></iron-ajax> |
| 34 <paper-menu attr-for-selected="value" selected="[[tree]]" id="menu"> | 46 <paper-menu attr-for-selected="value" selected="[[tree]]" selectable="paper-
item" id="menu"> |
| 47 <h2><iron-icon icon="folder"></iron-icon>Trees</h2> |
| 35 <template is="dom-repeat" items="[[_treeList]]" as="tree"> | 48 <template is="dom-repeat" items="[[_treeList]]" as="tree"> |
| 36 <paper-item value="[[tree.name]]" on-tap="_onSelected">[[tree.display_na
me]]</paper-item> | 49 <paper-item value="[[tree.name]]" on-tap="_onSelected">[[tree.display_na
me]]</paper-item> |
| 37 </template> | 50 </template> |
| 38 <hr/> | 51 |
| 52 <h2><iron-icon icon="help"></iron-icon>Help</h2> |
| 53 <template is="dom-repeat" items="[[_staticPageList]]" as="page"> |
| 54 <paper-item value="[[page.name]]" on-tap="_onSelected">[[page.displayTex
t]]</paper-item> |
| 55 </template> |
| 56 |
| 57 <h2><iron-icon icon="settings"></iron-icon>Settings</h2> |
| 39 <div class="vertical layout center"> | 58 <div class="vertical layout center"> |
| 40 <paper-checkbox class="center" checked="{{showInfraFailures}}">Show infr
a failures</paper-checkbox> | 59 <paper-checkbox class="center" checked="{{showInfraFailures}}">Show infr
a failures</paper-checkbox> |
| 41 </div> | 60 </div> |
| 42 </paper-menu> | 61 </paper-menu> |
| 43 </template> | 62 </template> |
| 44 <script> | 63 <script> |
| 45 (function() { | 64 (function() { |
| 46 'use strict'; | 65 'use strict'; |
| 47 | 66 |
| 48 Polymer({ | 67 Polymer({ |
| 49 is: 'som-drawer', | 68 is: 'som-drawer', |
| 50 | 69 |
| 51 properties: { | 70 properties: { |
| 52 tree: String, | 71 tree: String, |
| 53 path: { | 72 path: { |
| 54 type: String, | 73 type: String, |
| 55 notify: true | 74 notify: true |
| 56 }, | 75 }, |
| 57 showInfraFailures: { | 76 showInfraFailures: { |
| 58 type: Boolean, | 77 type: Boolean, |
| 59 notify: true, | 78 notify: true, |
| 60 }, | 79 }, |
| 80 _staticPageList: { |
| 81 type: Array, |
| 82 computed: '_computeStaticPageList(staticPages)', |
| 83 value: function() { return []; }, |
| 84 }, |
| 61 _treeList: { | 85 _treeList: { |
| 62 type: Array, | 86 type: Array, |
| 63 value: function() { return []; }, | 87 value: function() { return []; }, |
| 64 }, | 88 }, |
| 65 trees: { | 89 trees: { |
| 66 type: Object, | 90 type: Object, |
| 67 notify: true, | 91 notify: true, |
| 68 computed: '_computeTrees(_treeList)', | 92 computed: '_computeTrees(_treeList)', |
| 69 }, | 93 }, |
| 70 }, | 94 }, |
| 71 | 95 |
| 96 _computeStaticPageList(staticPages) { |
| 97 let pageList = []; |
| 98 for (let key in staticPages) { |
| 99 let page = staticPages[key]; |
| 100 page.name = key; |
| 101 pageList.push(page); |
| 102 } |
| 103 return pageList; |
| 104 }, |
| 105 |
| 72 _computeTrees(treeList) { | 106 _computeTrees(treeList) { |
| 73 let trees = {}; | 107 let trees = {}; |
| 74 treeList.forEach(function(tree) { | 108 treeList.forEach(function(tree) { |
| 75 trees[tree.name] = tree; | 109 trees[tree.name] = tree; |
| 76 }); | 110 }); |
| 77 return trees; | 111 return trees; |
| 78 }, | 112 }, |
| 79 | 113 |
| 80 _onSelected: function(evt) { | 114 _onSelected: function(evt) { |
| 81 this.path = "/" + evt.srcElement.value; | 115 this.path = "/" + evt.srcElement.value; |
| 82 }, | 116 }, |
| 83 }); | 117 }); |
| 84 })(); | 118 })(); |
| 85 </script> | 119 </script> |
| 86 </dom-module> | 120 </dom-module> |
| OLD | NEW |