mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
Merge pull request #1862 from alicebob/removegraph
'Remove Graph' links on the /graph page
This commit is contained in:
commit
f9533754d1
File diff suppressed because one or more lines are too long
|
@ -8,6 +8,7 @@ Handlebars.registerHelper('pathPrefix', function() { return PATH_PREFIX; });
|
|||
|
||||
Prometheus.Graph = function(element, options) {
|
||||
this.el = element;
|
||||
this.graphHtml = null;
|
||||
this.options = options;
|
||||
this.changeHandler = null;
|
||||
this.rickshawGraph = null;
|
||||
|
@ -45,8 +46,8 @@ Prometheus.Graph.prototype.initialize = function() {
|
|||
|
||||
// Draw graph controls and container from Handlebars template.
|
||||
|
||||
var graphHtml = graphTemplate(self.options);
|
||||
self.el.append(graphHtml);
|
||||
self.graphHtml = $(graphTemplate(self.options));
|
||||
self.el.append(self.graphHtml);
|
||||
|
||||
// Get references to all the interesting elements in the graph container and
|
||||
// bind event handlers.
|
||||
|
@ -164,6 +165,12 @@ Prometheus.Graph.prototype.initialize = function() {
|
|||
self.expr.focus(); // refocusing
|
||||
});
|
||||
|
||||
var removeBtn = graphWrapper.find("[name=remove]");
|
||||
removeBtn.click(function() {
|
||||
self.remove();
|
||||
return false;
|
||||
});
|
||||
|
||||
self.populateInsertableMetrics();
|
||||
|
||||
if (self.expr.val()) {
|
||||
|
@ -612,6 +619,13 @@ Prometheus.Graph.prototype.handleConsoleResponse = function(data, textStatus) {
|
|||
}
|
||||
};
|
||||
|
||||
Prometheus.Graph.prototype.remove = function() {
|
||||
var self = this;
|
||||
$(self.graphHtml).remove();
|
||||
graphs = graphs.filter(function(e) {return e !== self});
|
||||
storeGraphOptionsInURL();
|
||||
};
|
||||
|
||||
function parseGraphOptionsFromURL() {
|
||||
var hashOptions = window.location.hash.slice(1);
|
||||
if (!hashOptions) {
|
||||
|
|
|
@ -124,5 +124,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 text-right">
|
||||
<a name="remove" href="#">Remove Graph</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue