templating_editor.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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-success 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-option">
  52. <div class="editor-row">
  53. <div class="editor-option">
  54. <label class="small">Variable name</label>
  55. <input type="text" class="input-medium" ng-model='current.name' placeholder="name" required></input>
  56. </div>
  57. <div class="editor-option">
  58. <label class="small">Type</label>
  59. <select class="input-medium" ng-model="current.type" ng-options="f for f in ['query', 'interval', 'custom']" ng-change="typeChanged()"></select>
  60. </div>
  61. <div class="editor-option" ng-show="current.type === 'query'">
  62. <label class="small">Datasource</label>
  63. <select class="input input-medium" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources"></select>
  64. </div>
  65. <editor-opt-bool text="Refresh on load" show-if="current.type === 'query'"
  66. tip="Check if you want values to be updated on dashboard load, will slow down dashboard load time"
  67. model="current.refresh"></editor-opt-bool>
  68. </div>
  69. <div ng-show="current.type === 'interval'">
  70. <div class="editor-row">
  71. <div class="editor-option">
  72. <label class="small">Values</label>
  73. <input type="text" class="input-xxlarge" ng-model='current.query' ng-blur="runQuery()" placeholder="name"></input>
  74. </div>
  75. </div>
  76. <div class="editor-row">
  77. <editor-opt-bool text="Include auto interval" model="current.auto" change="runQuery()"></editor-opt-bool>
  78. <div class="editor-option" ng-show="current.auto">
  79. <label class="small">Auto interval steps <tip>How many steps, roughly, the interval is rounded and will not always match this count<tip></label>
  80. <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>
  81. </div>
  82. </div>
  83. </div>
  84. <div ng-show="current.type === 'custom'">
  85. <div class="editor-row">
  86. <div class="editor-option">
  87. <label class="small">Values seperated by comma</label>
  88. <input type="text" class="input-xxlarge" ng-model='current.query' ng-blur="runQuery()" placeholder="1, 10, 20, myvalue"></input>
  89. </div>
  90. </div>
  91. </div>
  92. <div ng-show="current.type === 'query'">
  93. <div class="editor-row">
  94. <div class="editor-option form-inline">
  95. <label class="small">Variable values query</label>
  96. <input type="text" class="input-xxlarge" ng-model='current.query' placeholder="apps.servers.*"></input>
  97. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'Execute query'" data-placement="right"><i class="fa fa-play"></i></button>
  98. </div>
  99. </div>
  100. <div class="editor-row" style="margin: 15px 0">
  101. <div class="editor-option form-inline">
  102. <label class="small">regex (optional, if you want to extract part of a series name or metric node segment)</label>
  103. <input type="text" class="input-xxlarge" ng-model='current.regex' placeholder="/.*-(.*)-.*/"></input>
  104. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'execute query'" data-placement="right"><i class="fa fa-play"></i></button>
  105. </div>
  106. </div>
  107. <div class="editor-row" style="margin: 15px 0">
  108. <editor-opt-bool text="All option" model="current.includeAll" change="runQuery()"></editor-opt-bool>
  109. <div class="editor-option" ng-show="current.includeAll">
  110. <label class="small">All format</label>
  111. <select class="input-medium" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values']"></select>
  112. </div>
  113. <div class="editor-option" ng-show="current.includeAll">
  114. <label class="small">All value</label>
  115. <input type="text" class="input-xlarge" ng-model='current.options[0].value'></input>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="editor-option">
  121. <div class="editor-row">
  122. <div class="editor-option" >
  123. <label class="small">Variable values (showing 20/{{current.options.length}})</label>
  124. <ul class="grafana-options-list">
  125. <li ng-repeat="option in current.options | limitTo: 20">
  126. {{option.text}}
  127. </li>
  128. </ul>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <button type="button" class="btn btn-success" ng-show="editor.index === 2" ng-click="update();">Update</button>
  134. <button type="button" class="btn btn-success" ng-show="editor.index === 1" ng-click="add();">Add</button>
  135. </div>
  136. </div>