editor.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <div ng-controller="TemplateEditorCtrl" ng-init="init()">
  2. <div class="gf-box-header">
  3. <div class="gf-box-title">
  4. <i class="fa fa-code"></i>
  5. Templating
  6. </div>
  7. <div class="tabs">
  8. <ul class="nav nav-tabs">
  9. <li ng-class="{active: mode === 'list'}">
  10. <a ng-click="mode = 'list';">Variables</a>
  11. </li>
  12. <li ng-class="{active: mode === 'edit'}" ng-show="mode === 'edit'">
  13. <a>{{current.name}}</a>
  14. </li>
  15. <li ng-class="{active: mode === 'new'}">
  16. <a ng-click="mode = 'new';">
  17. <i class="fa fa-plus"></i>
  18. New
  19. </a>
  20. </li>
  21. </ul>
  22. </div>
  23. <button class="gf-box-header-close-btn" ng-click="dismiss();dashboard.refresh();">
  24. <i class="fa fa-remove"></i>
  25. </button>
  26. </div>
  27. <div class="gf-box-body">
  28. <div ng-if="mode === 'list'">
  29. <div class="editor-row row">
  30. <div style="max-width: 1024px">
  31. <div ng-if="variables.length === 0">
  32. <em>No template variables defined</em>
  33. </div>
  34. <table class="grafana-options-table">
  35. <tr ng-repeat="variable in variables">
  36. <td style="width: 1%">
  37. <span class="template-variable">
  38. ${{variable.name}}
  39. </span>
  40. </td>
  41. <td class="max-width" style="max-width: 200px;">
  42. {{variable.query}}
  43. </td>
  44. <td style="width: 1%">
  45. <a ng-click="edit(variable)" class="btn btn-inverse btn-small">
  46. <i class="fa fa-edit"></i>
  47. Edit
  48. </a>
  49. </td>
  50. <td style="width: 1%">
  51. <a ng-click="duplicate(variable)" class="btn btn-inverse btn-small">
  52. Duplicate
  53. </a>
  54. </td>
  55. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
  56. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
  57. <td style="width: 1%">
  58. <a ng-click="removeVariable(variable)" class="btn btn-danger btn-small">
  59. <i class="fa fa-remove"></i>
  60. </a>
  61. </td>
  62. </tr>
  63. </table>
  64. </div>
  65. </div>
  66. </div>
  67. <div ng-if="mode === 'edit' || mode === 'new'">
  68. <h5>Variable</h5>
  69. <div class="gf-form-group">
  70. <div class="gf-form-inline">
  71. <div class="gf-form">
  72. <span class="gf-form-label width-7">Name</span>
  73. <input type="text" class="gf-form-input max-width-14" placeholder="name" ng-model='current.name'></input>
  74. </div>
  75. <div class="gf-form">
  76. <span class="gf-form-label width-7">Type</span>
  77. <div class="gf-form-select-wrapper max-width-10">
  78. <select class="gf-form-input max-width-10" ng-model="current.type" ng-options="f for f in ['query', 'interval', 'custom']" ng-change="typeChanged()"></select>
  79. </div>
  80. </div>
  81. <div class="gf-form">
  82. <span class="gf-form-label width-7" ng-show="current.type === 'query'">Data source</span>
  83. <div class="gf-form-select-wrapper" ng-show="current.type === 'query'">
  84. <select class="gf-form-input max-width-14" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources"></select>
  85. </div>
  86. </div>
  87. </div>
  88. <h5>Value Options</h5>
  89. <div ng-show="current.type === 'interval'" class="gf-form-group">
  90. <div class="gf-form">
  91. <span class="gf-form-label width-7">Values</span>
  92. <input type="text" class="gf-form-input max-width-28" placeholder="name" ng-model='current.query' placeholder="1m,10m,1h,6h,1d,7d" ng-model-onblur ng-change="runQuery()"></input>
  93. </div>
  94. <div class="gf-form">
  95. <editor-checkbox text="Include auto interval" model="current.auto" change="runQuery()"></editor-checkbox>
  96. <span class="gf-form-label" ng-show="current.auto">
  97. Auto interval steps <tip>How many times should the current time range be divided to calculate the value</tip>
  98. </span>
  99. <div class="gf-form-select-wrapper max-width-10">
  100. <select class="gf-form-input" ng-model="current.auto_count" ng-options="f for f in [3,5,10,30,50,100,200]" ng-change="runQuery()"></select>
  101. </div>
  102. </div>
  103. </div>
  104. <div ng-show="current.type === 'custom'" class="gf-form-group">
  105. <div class="gf-form">
  106. <span class="gf-form-label width-13">Values seperated by comma</span>
  107. <input type="text" class="gf-form-input max-width-22" ng-model='current.query' ng-blur="runQuery()" placeholder="1, 10, 20, myvalue"></input>
  108. </div>
  109. <div class="gf-form ">
  110. <editor-checkbox class="width-13" text="All value" model="current.includeAll" change="runQuery()"></editor-checkbox>
  111. <input ng-show="current.includeAll" type="text" class="gf-form-input max-width-22" ng-model='current.options[0].value' style="margin-left: 4px;"></input>
  112. </div>
  113. <div class="gf-form">
  114. <span class="gf-form-label width-13" ng-show="current.includeAll">All format</span>
  115. <div class="gf-form-select-wrapper max-width-10" ng-show="current.includeAll">
  116. <select class="gf-form-input" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values', 'lucene', 'pipe']"></select>
  117. </div>
  118. </div>
  119. </div>
  120. <div ng-show="current.type === 'query'" class="gf-form-group">
  121. <div class="gf-form">
  122. <span class="gf-form-label width-7">Query</span>
  123. <input type="text" class="gf-form-input" ng-model='current.query' placeholder="metric name or tags query" ng-model-onblur ng-change="runQuery()"></input>
  124. </div>
  125. <div class="gf-form">
  126. <span class="gf-form-label width-7">
  127. Regex
  128. <tip>Optional, if you want to extract part of a series name or metric node segment</tip>
  129. </span>
  130. <input type="text" class="gf-form-input" ng-model='current.regex' placeholder="/.*-(.*)-.*/" ng-model-onblur ng-change="runQuery()"></input>
  131. </div>
  132. <div class="gf-form">
  133. <editor-checkbox class="width-13" text="All value" model="current.includeAll" change="runQuery()"></editor-checkbox>
  134. <input ng-show="current.includeAll" type="text" class="gf-form-input" ng-model='current.options[0].value'></input>
  135. <span class="gf-form-label" ng-show="current.includeAll">All format</span>
  136. <div class="gf-form-select-wrapper max-width-10" ng-show="current.includeAll">
  137. <select class="gf-form-input" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values', 'lucene', 'pipe']"></select>
  138. </div>
  139. </div>
  140. <div class="gf-form">
  141. <editor-checkbox class="width-13" text="Refresh on load" model="current.refresh"></editor-checkbox>
  142. <tip>Check if you want values to be updated on dashboard load, will slow down dashboard load time</tip>
  143. </div>
  144. </div>
  145. <div class="row">
  146. <div class="col-md-6">
  147. <div class="gf-form-group">
  148. <h5>Display options</h5>
  149. <div class="gf-form">
  150. <span class="gf-form-label width-8">Variable Label</span>
  151. <input type="text" class="gf-form-input max-width-12" ng-model='current.label' placeholder=""></input>
  152. <editor-checkbox class="width-13" text="Hide label" model="current.hideLabel" change="runQuery()"></editor-checkbox>
  153. </div>
  154. </div>
  155. </div>
  156. <div class="col-md-6" ng-hide="current.type === 'interval'">
  157. <div class="gf-form-group" >
  158. <h5>Multi-value selection <tip>Enables multiple values to be selected at the same time</tip></h5>
  159. <div class="gf-form">
  160. <editor-checkbox text="Enable" model="current.multi" change="runQuery()"></editor-checkbox>
  161. <span class="gf-form-label" ng-show="current.multi">Multi format</span>
  162. <div class="gf-form-select-wrapper max-width-10" ng-show="current.multi">
  163. <select class="gf-form-input" ng-model="current.multiFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'regex values', 'lucene', 'pipe']"></select>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="gf-form-group" ng-if="current.type === 'query'">
  170. <h5>Value groups/tags (Experimental feature)</h5>
  171. <div class="gf-form">
  172. <editor-checkbox text="Enable" model="current.useTags" change="runQuery()"></editor-checkbox>
  173. </div>
  174. <div class="gf-form last" ng-if="current.useTags">
  175. <span class="gf-form-label width-10">Tags query</span>
  176. <input type="text" class="gf-form-input" ng-model='current.tagsQuery' placeholder="metric name or tags query" ng-model-onblur></input>
  177. </div>
  178. <div class="gf-form" ng-if="current.useTags">
  179. <li class="gf-form-label width-10">Tag values query</li>
  180. <input type="text" class="gf-form-input" ng-model='current.tagValuesQuery' placeholder="apps.$tag.*" ng-model-onblur></input>
  181. </div>
  182. </div>
  183. <div class="gf-form-group">
  184. <h5>Preview of values (shows max 20)</h5>
  185. <div class="gf-form">
  186. <span class="gf-form-label" ng-repeat="option in current.options | limitTo: 20">
  187. {{option.text}}
  188. </span>
  189. </div>
  190. </div>
  191. </div>
  192. <div class="gf-form-button-row" style="margin-top: 20px">
  193. <button type="button" class="btn btn-success" ng-show="mode === 'edit'" ng-click="update();">Update</button>
  194. <button type="button" class="btn btn-success" ng-show="mode === 'new'" ng-click="add();">Add</button>
  195. </div>
  196. </div>
  197. </div>