editor.html 9.2 KB

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