summaryrefslogtreecommitdiff
path: root/app/views/projects/pipelines/charts/_pipelines.haml
blob: be884448087397605b883e0cdb8d68205cfd10ab (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
%h4= _("Pipelines charts")
%p
   
  %span.cgreen
    = icon("circle")
    = s_("Pipeline|success")
   
  %span.cgray
    = icon("circle")
    = s_("Pipeline|all")

.prepend-top-default
  %p.light
    = _("Jobs for last week")
    (#{date_from_to(Date.today - 7.days, Date.today)})
  %canvas#weekChart{ height: 200 }

.prepend-top-default
  %p.light
    = _("Jobs for last month")
    (#{date_from_to(Date.today - 30.days, Date.today)})
  %canvas#monthChart{ height: 200 }

.prepend-top-default
  %p.light
    = _("Jobs for last year")
  %canvas#yearChart.padded{ height: 250 }

- [:week, :month, :year].each do |scope|
  :javascript
    var data = {
      labels : #{@charts[scope].labels.to_json},
      datasets : [
        {
          fillColor : "#7f8fa4",
          strokeColor : "#7f8fa4",
          pointColor : "#7f8fa4",
          pointStrokeColor : "#EEE",
          data : #{@charts[scope].total.to_json}
        },
        {
          fillColor : "#44aa22",
          strokeColor : "#44aa22",
          pointColor : "#44aa22",
          pointStrokeColor : "#fff",
          data : #{@charts[scope].success.to_json}
        }
      ]
    }
    var ctx = $("##{scope}Chart").get(0).getContext("2d");
    var options = { scaleOverlay: true, responsive: true, maintainAspectRatio: false };
    if (window.innerWidth < 768) {
      // Scale fonts if window width lower than 768px (iPad portrait)
      options.scaleFontSize = 8
    }
    new Chart(ctx).Line(data, options);