summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/ishtar/dashboards/dashboard_main_detail.html
blob: 610457ae3bc0f79d28dcad142c427d2482baa0b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{% load i18n %}
{% load url from future %}
<div class='dashboard' id="{{unique_id}}-tab">
  <div>
    <h4>{% trans "Numbers" %}</h4>
    <p><strong>{% trans "Total:" %}</strong> {{dashboard.total_number}}</p>
    <div class='table'>
    <div id="chart_{{unique_id}}" style="height:400px; width:700px;"></div>
    {% if form %}
    <div class='form'>
    <form method='post' action="{% url 'dashboard-main-detail' item_name %}" id='{{unique_id}}_form'>
      <table>{% csrf_token %}
        {{form}}
      </table>
      <button id="search_{{unique_id}}" class="submit">{% trans "Change" %}</button>
    </form>
    </div>
    {% endif %}
    {% comment %}
    <table>
    {% for idx, lbl, values in dashboard.values %}
      <tr class='idx {% if forloop.counter0|divisibleby:"2" %}even{%else%}odd{%endif%}'>
      <th>{{lbl}}</th>
      {% for value in values %}<td>{{value}}</td>{% endfor%}
      </tr>
    {% endfor%}
    </table>{% endcomment %}
    </div>
    {% if dashboard.periods %}
    <h4>{% trans "By years" %}</h4>
    <ul>
      <li><strong>{% trans "Average:" %}</strong> {{dashboard.average}}</li>
      <li><strong>{% trans "Variance:" %}</strong> {{dashboard.variance}}</li>
      <li><strong>{% trans "Standard deviation:" %}</strong> {{dashboard.standard_deviation}}</li>
      <li><strong>{% trans "Median:" %}</strong> {{dashboard.median}}</li>
      <li><strong>{% trans "Mode:" %}</strong> {{dashboard.mode}}</li>
    </ul>
    {% endif %}
    {% if dashboard.operation_average %}
    <h4>{% trans "By operations" %}</h4>
    <ul>
      <li><strong>{% trans "Average:" %}</strong> {{dashboard.operation_average}}</li>
      <li><strong>{% trans "Variance:" %}</strong> {{dashboard.operation_variance}}</li>
      <li><strong>{% trans "Standard deviation:" %}</strong> {{dashboard.operation_standard_deviation}}</li>
      <li><strong>{% trans "Median:" %}</strong> {{dashboard.operation_median}}</li>
      <li><strong>{% trans "Mode:" %}</strong> {{dashboard.operation_mode}}</li>
    </ul>
    {% endif %}
    <h4>{% trans "Created last" %}</h4>
    <div class='table'>
    <table class='resume'>
      <tr><th>{{lbl}}</th><th>{% trans "Created" %}</th><th></th></tr>
      {% for item in dashboard.lasts %}<tr>
        <td class='ref'>{{item}}</td>
        <td>{{item.history_date}}</td>
        <td>{% if item.get_show_url %}<a href="#" onclick='load_window("{{item.get_show_url}}")'>{%trans "Show"%}</a>{%endif%}</td>
      </tr>{% endfor %}
    </table>
    </div>
    <h4>{% trans "Recent changes" %}</h4>
    <div class='table'>
    <table class='resume'>
      <tr><th>{{lbl}}</th><th>{% trans "Modified" %}</th><th></th></tr>
      {% for item in dashboard.recents %}<tr>
        <td class='ref'>{{item}}</td>
        <td>{{item.history_date}}</td>
        <td>{% if item.get_show_url %}<a href="#" onclick='load_window("{{item.get_show_url}}")'>{%trans "Show"%}</a>{%endif%}</td>
      </tr>{% endfor %}
    </table>
    </div>
  </div>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
var values_{{unique_id}} = [];


{% for idx, lbl, values in dashboard.values %} {% for value in values %}{% ifequal forloop.parentloop.counter0 0 %}
values_{{unique_id}}.push([{{VALUE_QUOTE|safe}}{{value}}{{VALUE_QUOTE|safe}}, 0]);
{% else %}values_{{unique_id}}[{{forloop.counter0}}][1] = {{value}};{% endifequal %}{% endfor%}{% endfor%}

if (values_{{unique_id}}.length > 0){

var showmarker = false;
if (values_{{unique_id}}.length < 25){
    var showmarker = true;
}

var plot_{{unique_id}} = $.jqplot('chart_{{unique_id}}',
    [values_{{unique_id}}], {
      series:[{showMarker:showmarker}],
      axes:{ {%ifequal slicing 'year'%}
        xaxis:{
          label:'{% trans "Year" %}',
          tickOptions: {
            formatString: "%d"
          }
        },{%endifequal%}{%ifequal slicing 'month'%}
        xaxis:{
          label:'{% trans "Month" %}',
          renderer:$.jqplot.DateAxisRenderer,
          tickOptions:{formatString:'%b %Y'},
        },{%endifequal%}
        yaxis:{
          label:'{% trans "Number"%}',
          min:0
        }
      },
      highlighter: {
        show: true,
        sizeAdjust: 7.5
      }
  });

} else {
$('#chart_{{unique_id}}').html("<p class='alert'>{% trans 'No data for theses criteria.' %}</p");
}

$('#search_{{unique_id}}').click(function (){
    $.post("{% url 'dashboard-main-detail' item_name %}",
            $("#{{unique_id}}_form").serialize(),
            function(data){
                $("#{{unique_id}}-tab").parent().html(data);
            });
    return false;
});

{% ifequal item_name 'files' %}
load_jquerydate_after();
load_jquerydate_before();
{% endifequal %}
});
</script>