templating_editor.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 ng-model="editor.index" bs-tabs style="text-transform:capitalize;">
  8. <div ng-repeat="tab in ['Variables', 'Add', 'Edit']" data-title="{{tab}}">
  9. </div>
  10. </div>
  11. <button class="gf-box-header-close-btn" ng-click="dismiss();dashboard.refresh();">
  12. <i class="fa fa-remove"></i>
  13. </button>
  14. </div>
  15. <div class="gf-box-body">
  16. <div ng-if="editor.index == 0">
  17. <div class="editor-row row">
  18. <div class="span8">
  19. <div ng-if="variables.length === 0">
  20. <em>No template variables defined</em>
  21. </div>
  22. <table class="grafana-options-table">
  23. <tr ng-repeat="variable in variables">
  24. <td style="width: 1%">
  25. <span class="template-variable">
  26. ${{variable.name}}
  27. </span>
  28. </td>
  29. <td class="max-width" style="max-width: 200px;">
  30. {{variable.query}}
  31. </td>
  32. <td style="width: 1%">
  33. <a ng-click="edit(variable)" class="btn btn-inverse btn-small">
  34. <i class="fa fa-edit"></i>
  35. Edit
  36. </a>
  37. </td>
  38. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
  39. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
  40. <td style="width: 1%">
  41. <a ng-click="removeVariable(variable)" class="btn btn-danger btn-small">
  42. <i class="fa fa-remove"></i>
  43. </a>
  44. </td>
  45. </tr>
  46. </table>
  47. </div>
  48. </div>
  49. </div>
  50. <div ng-if="editor.index == 1 || (editor.index == 2 && !currentIsNew)">
  51. <div class="editor-row">
  52. <div class="section">
  53. <h5>General</h5>
  54. <div class="editor-row">
  55. <div class="editor-option">
  56. <label class="small">Variable name</label>
  57. <input type="text" class="input-medium" ng-model='current.name' placeholder="name" required></input>
  58. </div>
  59. <div class="editor-option">
  60. <label class="small">Type</label>
  61. <select class="input-small" ng-model="current.type" ng-options="f for f in ['query', 'interval', 'custom']" ng-change="typeChanged()"></select>
  62. </div>
  63. <div class="editor-option" ng-show="current.type === 'query'">
  64. <label class="small">Datasource</label>
  65. <select class="input input-medium" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources"></select>
  66. </div>
  67. </div>
  68. <div ng-show="current.type === 'interval'">
  69. <div class="editor-row">
  70. <div class="editor-option">
  71. <label class="small">Values</label>
  72. <input type="text" class="input-large" ng-model='current.query' ng-blur="runQuery()" placeholder="name"></input>
  73. </div>
  74. <editor-opt-bool text="Include auto interval" model="current.auto" change="runQuery()"></editor-opt-bool>
  75. <div class="editor-option" ng-show="current.auto">
  76. <label class="small">Auto interval steps <tip>How many steps, roughly, the interval is rounded and will not always match this count<tip></label>
  77. <select class="input-mini" ng-model="current.auto_count" ng-options="f for f in [3,5,10,30,50,100,200]" ng-change="runQuery()"></select>
  78. </div>
  79. </div>
  80. </div>
  81. <div ng-show="current.type === 'custom'">
  82. <div class="editor-row">
  83. <div class="editor-option">
  84. <label class="small">Values seperated by comma</label>
  85. <input type="text" class="input-xxlarge" ng-model='current.query' ng-blur="runQuery()" placeholder="1, 10, 20, myvalue"></input>
  86. </div>
  87. </div>
  88. </div>
  89. <div ng-show="current.type === 'query'">
  90. <h5>Values Query</h5>
  91. <div class="editor-row">
  92. <div class="editor-option form-inline">
  93. <label class="small">Variable values query</label>
  94. <input type="text" class="input-xxlarge" ng-model='current.query' placeholder="apps.servers.*"></input>
  95. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'Execute query'" data-placement="right"><i class="fa fa-play"></i></button>
  96. </div>
  97. </div>
  98. <div class="editor-row" style="margin: 15px 0">
  99. <div class="editor-option form-inline">
  100. <label class="small">regex (optional, if you want to extract part of a series name or metric node segment)</label>
  101. <input type="text" class="input-xxlarge" ng-model='current.regex' placeholder="/.*-(.*)-.*/"></input>
  102. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'execute query'" data-placement="right"><i class="fa fa-play"></i></button>
  103. </div>
  104. </div>
  105. <div class="editor-row" style="margin: 15px 0">
  106. <editor-opt-bool text="Refresh on load" show-if="current.type === 'query'"
  107. tip="Check if you want values to be updated on dashboard load, will slow down dashboard load time"
  108. model="current.refresh"></editor-opt-bool>
  109. <editor-opt-bool text="All option" model="current.includeAll" change="runQuery()"></editor-opt-bool>
  110. <div class="editor-option" ng-show="current.includeAll">
  111. <label class="small">All format</label>
  112. <select class="input-medium" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values']"></select>
  113. </div>
  114. <div class="editor-option" ng-show="current.includeAll">
  115. <label class="small">All value</label>
  116. <input type="text" class="input-xlarge" ng-model='current.options[0].value'></input>
  117. </div>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="section">
  122. <div class="section">
  123. <h5>Display options</h5>
  124. <div class="editor-option">
  125. <label class="small">Variable label</label>
  126. <input type="text" class="input-medium" ng-model='current.label' placeholder=""></input>
  127. </div>
  128. <editor-opt-bool text="Hide Label" model="current.hideLabel"></editor-opt-bool>
  129. </div>
  130. <div class="section">
  131. <h5>Multi-value selection <tip>Enables multiple values to be selected at the same time</tip></h5>
  132. <editor-opt-bool text="Enable" model="current.multi"></editor-opt-bool>
  133. <div class="editor-option" ng-show="current.multi">
  134. <label class="small">Multi value format</label>
  135. <select class="input-medium" ng-model="current.multiFormat" ng-options="f for f in ['glob', 'regex values']"></select>
  136. </div>
  137. </div>
  138. <div class="editor-row" style="margin: 15px 0">
  139. <div class="editor-option" >
  140. <label class="small">Variable values (shows max 20)</label>
  141. <ul class="grafana-options-list">
  142. <li ng-repeat="option in current.options | limitTo: 20">
  143. {{option.text}}
  144. </li>
  145. </ul>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <button type="button" class="btn btn-success pull-right" ng-show="editor.index === 2" ng-click="update();">Update</button>
  151. <button type="button" class="btn btn-success pull-right" ng-show="editor.index === 1" ng-click="add();">Add</button>
  152. <div class="clearfix"></div>
  153. </div>
  154. </div>