Example #1
0
def reorder_dashboard(request, dashboard_id):
    dashboard = dashboard_model.get_by_id(dashboard_id)

    return render_to_response('dashboards/reorder.html', {
        "dashboard": dashboard,
    },
                              context_instance=RequestContext(request))
Example #2
0
def edit_dashboard(request, dashboard_id):
    dashboard = dashboard_model.get_by_id(dashboard_id)

    all_servers = server_model.get_all(account_id=request.account_id)
    all_healthchecks = health_checks_model.get_all()

    return render(request, 'dashboards/edit.html', {
        "dashboard": dashboard,
        "all_servers": all_servers,
        "all_healthchecks": all_healthchecks
    })
Example #3
0
def edit_dashboard(request, dashboard_id):
    dashboard = dashboard_model.get_by_id(dashboard_id)

    all_servers = server_model.get_all(account_id=request.account_id)
    all_healthchecks = health_checks_model.get_all()

    return render(request, 'dashboards/edit.html', {
        "dashboard": dashboard,
        "all_servers": all_servers,
        "all_healthchecks": all_healthchecks
    })
Example #4
0
def edit_dashboard(request, dashboard_id):
    dashboard = dashboard_model.get_by_id(dashboard_id)

    all_servers = server_model.get_all(account_id=request.account_id)
    all_healthchecks = health_checks_model.get_all()

    return render_to_response('dashboards/edit.html', {
        "dashboard": dashboard,
        "all_servers": all_servers,
        "all_healthchecks": all_healthchecks
    },
                              context_instance=RequestContext(request))
Example #5
0
def view_dashboard(request, dashboard_id):
    enddate = request.GET.get('enddate')
    duration = request.GET.get('duration', 1800)
    duration = int(duration)

    now_unix = datetime_to_unixtime(request.now)
    max_date = now_unix * 1000

    if enddate:
        date_to = int(enddate)
    else:
        date_to = now_unix

    date_from = date_to - int(duration)

    all_dashboards = dashboard_model.get_all(account_id=request.account_id)
    all_existing_server_ids = server_model.get_all_ids()
    dashboard = dashboard_model.get_by_id(dashboard_id)
    all_metrics = dashboard_metrics_model.get_all(
        account_id=request.account_id, dashboard_id=dashboard_id)

    metrics_array = _fill_metrics_arrays(all_metrics=all_metrics)

    if len(all_metrics) == 0:
        messages.add_message(request, messages.INFO,
                             'To view this dashboard add at least 1 metric')
        return redirect(
            reverse('edit_dashboard', kwargs={'dashboard_id': dashboard_id}))

    return render_to_response(
        'dashboards/view.html', {
            "all_dashboards": all_dashboards,
            "duration": duration,
            "selected_charts": metrics_array['charts'],
            "health_checks": metrics_array['health_checks'],
            "date_from": date_from,
            "date_to": date_to,
            "now": now_unix,
            "max_date": max_date,
            "dashboard": dashboard,
            "enddate": enddate,
            "all_existing_server_ids": all_existing_server_ids
        },
        context_instance=RequestContext(request))
Example #6
0
def public_dashboard(request, account_id, dashboard_id):
    enddate = request.GET.get('enddate')
    duration = request.GET.get('duration', 1800)
    duration = int(duration)

    now_unix = datetime_to_unixtime(request.now)
    max_date = now_unix * 1000

    if enddate:
        date_to = int(enddate)
    else:
        date_to = now_unix

    date_from = date_to - int(duration)

    dashboard = dashboard_model.get_by_id(dashboard_id)

    public = dashboard.get('shared', False)
    if public == False:
        raise Http404


    all_metrics = dashboard_metrics_model.get_all(
        dashboard_id=dashboard_id,
        public=public)

    all_existing_server_ids = server_model.get_all_ids()

    metrics_array = _fill_metrics_arrays(all_metrics=all_metrics)
    
    return render(request, 'dashboards/public.html', {
        "account_id": account_id,
        "duration": duration,
        "health_checks": metrics_array['health_checks'],
        "selected_charts": metrics_array['charts'],
        "date_from" : date_from,
        "date_to" : date_to,
        "now": now_unix,
        "max_date": max_date,
        "dashboard": dashboard,
        "enddate": enddate,
        "all_existing_server_ids": all_existing_server_ids
    })
Example #7
0
def public_dashboard(request, account_id, dashboard_id):
    enddate = request.GET.get('enddate')
    duration = request.GET.get('duration', 1800)
    duration = int(duration)

    now_unix = datetime_to_unixtime(request.now)
    max_date = now_unix * 1000

    if enddate:
        date_to = int(enddate)
    else:
        date_to = now_unix

    date_from = date_to - int(duration)

    dashboard = dashboard_model.get_by_id(dashboard_id)

    public = dashboard.get('shared', False)
    if public == False:
        raise Http404


    all_metrics = dashboard_metrics_model.get_all(
        dashboard_id=dashboard_id,
        public=public)

    all_existing_server_ids = server_model.get_all_ids()

    metrics_array = _fill_metrics_arrays(all_metrics=all_metrics)
    
    return render(request, 'dashboards/public.html', {
        "account_id": account_id,
        "duration": duration,
        "health_checks": metrics_array['health_checks'],
        "selected_charts": metrics_array['charts'],
        "date_from" : date_from,
        "date_to" : date_to,
        "now": now_unix,
        "max_date": max_date,
        "dashboard": dashboard,
        "enddate": enddate,
        "all_existing_server_ids": all_existing_server_ids
    })
Example #8
0
def view_dashboard(request, dashboard_id):
    enddate = request.GET.get('enddate')
    duration = request.GET.get('duration', 1800)
    duration = int(duration)

    now_unix = datetime_to_unixtime(request.now)
    max_date = now_unix * 1000

    if enddate:
        date_to = int(enddate)
    else:
        date_to = now_unix

    date_from = date_to - int(duration)

    all_dashboards = dashboard_model.get_all(account_id=request.account_id)
    all_existing_server_ids = server_model.get_all_ids()
    dashboard = dashboard_model.get_by_id(dashboard_id)
    all_metrics = dashboard_metrics_model.get_all(account_id=request.account_id, dashboard_id=dashboard_id)


    metrics_array = _fill_metrics_arrays(all_metrics=all_metrics)


    if len(all_metrics) == 0:
        messages.add_message(request, messages.INFO, 'To view this dashboard add at least 1 metric')
        return redirect(reverse('edit_dashboard', kwargs={'dashboard_id': dashboard_id}))

    return render(request, 'dashboards/view.html', {
        "all_dashboards": all_dashboards,
        "duration": duration,
        "selected_charts": metrics_array['charts'],
        "health_checks": metrics_array['health_checks'],
        "date_from" : date_from,
        "date_to" : date_to,
        "now": now_unix,
        "max_date": max_date,
        "dashboard": dashboard,
        "enddate": enddate,
        "all_existing_server_ids": all_existing_server_ids
    })
Example #9
0
def reorder_dashboard(request, dashboard_id):
    dashboard = dashboard_model.get_by_id(dashboard_id)

    return render(request, 'dashboards/reorder.html', {
        "dashboard": dashboard,
    })
Example #10
0
def reorder_dashboard(request, dashboard_id):
    dashboard = dashboard_model.get_by_id(dashboard_id)

    return render(request, 'dashboards/reorder.html', {
        "dashboard": dashboard,
    })