def live_runs(request, instrument): """ Display the list of latest runs @param instrument: instrument name """ # Get instrument instrument_id = get_object_or_404(Instrument, name=instrument.lower()) # Update URL update_url = reverse('dasmon:get_update', args=[instrument]) timeframe = 12 if 'days' in request.GET: try: timeframe = int(request.GET['days']) * 24 except: # If we can't cast to an integer, use default pass run_list, first_run, last_run = view_util.get_live_runs(instrument_id=instrument_id, timeframe=timeframe) breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id) template_values = {'instrument':instrument.upper(), 'breadcrumbs':breadcrumbs, 'update_url':update_url, 'run_list':run_list, 'first_run_id':first_run, 'last_run_id': last_run } template_values = report.view_util.fill_template_values(request, **template_values) template_values = users.view_util.fill_template_values(request, **template_values) template_values = view_util.fill_template_values(request, **template_values) return render(request, 'dasmon/live_runs.html', template_values)
def live_runs(request, instrument): """ Display the list of latest runs @param instrument: instrument name """ # Get instrument instrument_id = get_object_or_404(Instrument, name=instrument.lower()) # Update URL update_url = reverse('dasmon:get_update', args=[instrument]) timeframe = 12 if 'days' in request.GET: try: timeframe = int(request.GET['days']) * 24 except: # If we can't cast to an integer, use default pass # The format query string allows us to return json json_format = request.GET.get('format', 'html') == 'json' run_list, first_run, last_run = view_util.get_live_runs(instrument_id=instrument_id, timeframe=timeframe, as_html=not json_format) if json_format: data_info = dict(runs=run_list, instrument=instrument.upper()) data_info = view_util.fill_template_values(request, **data_info) response = HttpResponse(json.dumps(data_info), content_type="application/json") response['Connection'] = 'close' response['Content-Length'] = len(response.content) return response breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id) template_values = {'instrument':instrument.upper(), 'breadcrumbs':breadcrumbs, 'update_url':update_url, 'run_list':run_list, 'first_run_id':first_run, 'last_run_id': last_run } template_values = report.view_util.fill_template_values(request, **template_values) template_values = users.view_util.fill_template_values(request, **template_values) template_values = view_util.fill_template_values(request, **template_values) return render(request, 'dasmon/live_runs.html', template_values)
def run_summary(request): """ Dashboard view showing available instruments """ global_status_url = reverse(settings.LANDING_VIEW, args=[]) base_instr_url = reverse('dasmon:live_monitor', args=['aaaa']) base_instr_url = base_instr_url.replace('/aaaa', '') base_run_url = reverse('report:instrument_summary', args=['aaaa']) base_run_url = base_run_url.replace('/aaaa', '') runs, first_run, last_run = view_util.get_live_runs() template_values = {'run_list': runs, 'first_run_id': first_run, 'last_run_id': last_run, 'base_instrument_url': base_instr_url, 'base_run_url': base_run_url, 'breadcrumbs': "<a href='%s'>home</a> › dashboard" % global_status_url, } template_values = users.view_util.fill_template_values(request, **template_values) return render(request, 'dasmon/run_summary.html', template_values)