def get_update(request, instrument): """ Ajax call to get updates behind the scenes @param instrument: instrument name """ # Get instrument instrument_id = get_object_or_404(Instrument, name=instrument.lower()) # Get last experiment and last run data_dict = report.view_util.get_current_status(instrument_id) data_dict['variables'] = view_util.get_cached_variables(instrument_id, monitored_only=False) localtime = timezone.now() df = dateformat.DateFormat(localtime) recording_status = {"key": "recording_status", "value": view_util.is_running(instrument_id), "timestamp": df.format(settings.DATETIME_FORMAT), } data_dict['variables'].append(recording_status) # Get current DAS health status das_status = view_util.get_system_health(instrument_id) data_dict['das_status'] = das_status data_dict['live_plot_data'] = view_util.get_live_variables(request, instrument_id) # Recent run info data_dict = view_util.get_live_runs_update(request, instrument_id, None, **data_dict) response = HttpResponse(json.dumps(data_dict), content_type="application/json") response['Connection'] = 'close' response['Content-Length'] = len(response.content) return response
def summary_update(request): """ Response to AJAX call to get updated health info for all instruments """ # Get the system health status data_dict = {'instruments':view_util.get_instrument_status_summary(), 'postprocess_status':view_util.get_system_health() } response = HttpResponse(json.dumps(data_dict), content_type="application/json") response['Connection'] = 'close' response['Content-Length'] = len(response.content) return response
def expert_status(request): """ Internal status for development team """ # Get the system health status global_status_url = reverse(settings.LANDING_VIEW, args=[]) template_values = {'instruments': view_util.get_instrument_status_summary(), 'breadcrumbs': "<a href='%s'>home</a> › dashboard" % global_status_url, 'postprocess_status': view_util.get_system_health(), 'update_url': reverse('dasmon:dashboard_update'), 'central_services_url': reverse('dasmon:diagnostics', args=['common']) } template_values = users.view_util.fill_template_values(request, **template_values) return render(request, 'dasmon/expert_status.html', template_values)
def dashboard(request): """ Dashboard view showing available instruments """ # Get the system health status global_status_url = reverse(settings.LANDING_VIEW, args=[]) template_values = {'instruments': view_util.get_instrument_status_summary(), 'data': view_util.get_dashboard_data(), 'breadcrumbs': "<a href='%s'>home</a> › dashboard" % global_status_url, 'postprocess_status': view_util.get_system_health(), 'update_url': reverse('dasmon:dashboard_update')+'?plots', 'central_services_url': reverse('dasmon:diagnostics', args=['common']) } template_values = users.view_util.fill_template_values(request, **template_values) return render(request, 'dasmon/dashboard.html', template_values)