Skip to content

Commit

Permalink
cherrypicking revs 610,611 from lp:~octplane/graphite/url_management
Browse files Browse the repository at this point in the history
  • Loading branch information
cdavis committed Dec 5, 2011
1 parent 2102ada commit db7ef77
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
16 changes: 9 additions & 7 deletions webapp/content/js/jquery.graphite.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
var latestPosition = null;
var autocompleteoptions = {
minChars: 0,
selectFirst: false
selectFirst: false,
matchCase: true //Metrics can be case sensitive
};
var markings = [];

Expand Down Expand Up @@ -291,7 +292,7 @@
var metric = $(this);
update_metric_row(metric);
});
get_events(graph.find("#eventdesc"))
get_events(graph.find("#eventdesc"), "#eventcount")
render();
}

Expand Down Expand Up @@ -334,9 +335,9 @@
var build_url_events = function (tags) {
when = build_when()
if (tags == "*") {
return '/events/get_data?'+when
return SLASH+'events/get_data?'+when
} else {
return '/events/get_data?'+when+'&tags='+tags;
return SLASH+'events/get_data?'+when+'&tags='+tags;
}
}

Expand Down Expand Up @@ -368,7 +369,7 @@

}

var get_events = function(events_text) {
var get_events = function(events_text, event_count) {
if (events_text.val() == "") {
events_text.removeClass("ajaxworking");
events_text.removeClass("ajaxerror");
Expand All @@ -382,13 +383,14 @@
events_text.removeClass("ajaxerror");
events_text.removeClass("ajaxworking");
markings = [];
$(event_count).text(req_data.length);
for (i in req_data) {
row = req_data[i];
markings.push({
color: '#000',
lineWidth: 1,
xaxis: { from: row.when*1000, to: row.when*1000 },
text:'<a href="/events/'+row.id+'/">'+row.what+'<a>'
text:'<a href="'+SLASH+'events/'+row.id+'/">'+row.what+'<a>'
});
}
render();
Expand Down Expand Up @@ -493,7 +495,7 @@
if(e.which===13) { // on enter
// add row
edit.blur();
get_events(edit);
get_events(edit, "#eventcount");
}
});
});
Expand Down
10 changes: 8 additions & 2 deletions webapp/graphite/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from graphite.events import models
from graphite.render.attime import parseATTime
from django.core.urlresolvers import get_script_prefix



def to_timestamp(dt):
Expand All @@ -23,14 +25,18 @@ def default(self, obj):

def view_events(request):
if request.method == "GET":
context = dict(events=fetch(request))
context = { 'events' : fetch(request),
'slash' : get_script_prefix()
}
return render_to_response("events.html", context)
else:
return post_event(request)

def detail(request, event_id):
e = get_object_or_404(models.Event, pk=event_id)
context = dict(event=e)
context = { 'event' : e,
'slash' : get_script_prefix()
}
return render_to_response("event.html", context)


Expand Down
24 changes: 17 additions & 7 deletions webapp/graphite/graphlot/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from graphite.render.views import parseOptions
from graphite.render.evaluator import evaluateTarget
from graphite.storage import STORE
from django.core.urlresolvers import get_script_prefix



def graphlot_render(request):
Expand All @@ -21,8 +23,13 @@ def graphlot_render(request):
untiltime = request.GET.get('until', "-0hour")
fromtime = request.GET.get('from', "-24hour")
events = request.GET.get('events', "")
context = dict(metric_list=metrics, fromtime=fromtime, untiltime=untiltime,
events=events)
context = {
'metric_list' : metrics,
'fromtime' : fromtime,
'untiltime' : untiltime,
'events' : events,
'slash' : get_script_prefix()
}
return render_to_response("graphlot.html", context)

def get_data(request):
Expand Down Expand Up @@ -64,18 +71,21 @@ def find_metric(request):

def header(request):
"View for the header frame of the browser UI"
context = {}
context['user'] = request.user
context['profile'] = getProfile(request)
context['documentation_url'] = settings.DOCUMENTATION_URL
context = {
'user' : request.user,
'profile' : getProfile(request),
'documentation_url' : settings.DOCUMENTATION_URL,
'slash' : get_script_prefix()
}
return render_to_response("browserHeader.html", context)


def browser(request):
"View for the top-level frame of the browser UI"
context = {
'queryString' : request.GET.urlencode(),
'target' : request.GET.get('target')
'target' : request.GET.get('target'),
'slash' : get_script_prefix()
}
if context['queryString']:
context['queryString'] = context['queryString'].replace('#','%23')
Expand Down
4 changes: 2 additions & 2 deletions webapp/graphite/templates/events.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ <h1>graphite events</h1>
{% else %}
<br/>No events. Add events using
<a href="/admin/events/event/">the admin interface</a> or by posting
(eg, curl -X POST http://localhost:8000/events/ -d
'{"what": "Something Interesting"}')
(eg, curl -X POST http://localhost:8000{{slash}}events/ -d
'{"what": "Something Interesting", "tags" : "tag1 "}')
{% endif %}
</table>
</div>
Expand Down
4 changes: 3 additions & 1 deletion webapp/graphite/templates/graphlot.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

<script type="text/javascript">

var SLASH='{{slash}}';

$(document).ready(function () {
$('.graphite').graphiteGraph();
});
Expand Down Expand Up @@ -58,7 +60,7 @@ <h1>graphlot</h1>

<table id="rowlist" class="styledtable" style="float:left">
<tr><th style="width:750px">events</th></tr>
<tr id="eventsrow"><td><input class="event_tags" style="width:600px" type="text" id="eventdesc" value="{{events}}"/></td></tr>
<tr id="eventsrow"><td><input class="event_tags" style="width:600px" type="text" id="eventdesc" value="{{events}}"/>(<span id="eventcount">0</span>)</td></tr>
</table>

<table id="rowlist" class="styledtable" style="float:left">
Expand Down

0 comments on commit db7ef77

Please sign in to comment.