templating_editor.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <div ng-controller="TemplateEditorCtrl" ng-init="init()"> <div class="dashboard-editor-header">
  2. <div class="dashboard-editor-title">
  3. <i class="fa fa-code"></i>
  4. Templating
  5. </div>
  6. <div ng-model="editor.index" bs-tabs style="text-transform:capitalize;">
  7. <div ng-repeat="tab in ['Variables', 'Add', 'Edit']" data-title="{{tab}}">
  8. </div>
  9. </div>
  10. </div>
  11. <div class="dashboard-editor-body">
  12. <div ng-if="editor.index == 0">
  13. <div class="editor-row row">
  14. <div class="span8">
  15. <div ng-if="variables.length === 0">
  16. <em>No template variables defined</em>
  17. </div>
  18. <table class="grafana-options-table">
  19. <tr ng-repeat="variable in variables">
  20. <td style="width: 1%">
  21. <span class="template-variable">
  22. ${{variable.name}}
  23. </span>
  24. </td>
  25. <td class="max-width" style="max-width: 200px;">
  26. {{variable.query}}
  27. </td>
  28. <td style="width: 1%">
  29. <a ng-click="edit(variable)" class="btn btn-success btn-small">
  30. <i class="fa fa-edit"></i>
  31. Edit
  32. </a>
  33. </td>
  34. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index-1)" ng-hide="$first" class="pointer fa fa-arrow-up"></i></td>
  35. <td style="width: 1%"><i ng-click="_.move(variables,$index,$index+1)" ng-hide="$last" class="pointer fa fa-arrow-down"></i></td>
  36. <td style="width: 1%">
  37. <a ng-click="removeVariable(variable)" class="btn btn-danger btn-small">
  38. <i class="fa fa-remove"></i>
  39. </a>
  40. </td>
  41. </tr>
  42. </table>
  43. </div>
  44. </div>
  45. </div>
  46. <div ng-if="editor.index == 1 || (editor.index == 2 && !currentIsNew)">
  47. <div class="row">
  48. <div class="editor-option">
  49. <div class="editor-row">
  50. <div class="editor-option">
  51. <label class="small">Variable name</label>
  52. <input type="text" class="input-medium" ng-model='current.name' placeholder="name" required></input>
  53. </div>
  54. <div class="editor-option">
  55. <label class="small">Type</label>
  56. <select class="input-medium" ng-model="current.type" ng-options="f for f in ['query', 'interval', 'custom']" ng-change="typeChanged()"></select>
  57. </div>
  58. <div class="editor-option" ng-show="current.type === 'query'">
  59. <label class="small">Datasource</label>
  60. <select class="input input-medium" ng-model="current.datasource" ng-options="f.value as f.name for f in datasources"></select>
  61. </div>
  62. <editor-opt-bool text="Refresh on load" show-if="current.type === 'query'"
  63. tip="Check if you want values to be updated on dashboard load, will slow down dashboard load time"
  64. model="current.refresh"></editor-opt-bool>
  65. </div>
  66. <div ng-show="current.type === 'interval'">
  67. <div class="editor-row">
  68. <div class="editor-option">
  69. <label class="small">Values</label>
  70. <input type="text" class="input-xxlarge" ng-model='current.query' ng-blur="runQuery()" placeholder="name"></input>
  71. </div>
  72. </div>
  73. <div class="editor-row">
  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. <div class="editor-row">
  91. <div class="editor-option form-inline">
  92. <label class="small">Variable values query</label>
  93. <input type="text" class="input-xxlarge" ng-model='current.query' placeholder="apps.servers.*"></input>
  94. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'Execute query'" data-placement="right"><i class="fa fa-play"></i></button>
  95. </div>
  96. </div>
  97. <div class="editor-row" style="margin: 15px 0">
  98. <div class="editor-option form-inline">
  99. <label class="small">regex (optional, if you want to extract part of a series name or metric node segment)</label>
  100. <input type="text" class="input-xxlarge" ng-model='current.regex' placeholder="/.*-(.*)-.*/"></input>
  101. <button class="btn btn-small btn-success" ng-click="runQuery()" bs-tooltip="'execute query'" data-placement="right"><i class="fa fa-play"></i></button>
  102. </div>
  103. </div>
  104. <div class="editor-row" style="margin: 15px 0">
  105. <editor-opt-bool text="All option" model="current.includeAll" change="runQuery()"></editor-opt-bool>
  106. <div class="editor-option" ng-show="current.includeAll">
  107. <label class="small">All format</label>
  108. <select class="input-medium" ng-model="current.allFormat" ng-change="runQuery()" ng-options="f for f in ['glob', 'wildcard', 'regex wildcard', 'regex values']"></select>
  109. </div>
  110. <div class="editor-option" ng-show="current.includeAll">
  111. <label class="small">All value</label>
  112. <input type="text" class="input-xlarge" ng-model='current.options[0].value'></input>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. <div class="editor-option">
  118. <div class="editor-row">
  119. <div class="editor-option" >
  120. <label class="small">Variable values (showing 20/{{current.options.length}})</label>
  121. <ul class="grafana-options-list">
  122. <li ng-repeat="option in current.options | limitTo: 20">
  123. {{option.text}}
  124. </li>
  125. </ul>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. <div class="dashboard-editor-footer">
  133. <button type="button" class="btn btn-success pull-left" ng-show="editor.index === 2" ng-click="update();">Update</button>
  134. <button type="button" class="btn btn-success pull-left" ng-show="editor.index === 1" ng-click="add();">Add</button>
  135. <button type="button" class="btn btn-success pull-right" ng-click="dismiss();">Close</button>
  136. </div>
  137. </div>