aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb
blob: d056480a983d611804fc6df92976458305f882ca (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
<% content_for :script do %>
  <script data-main="<%= ApplicationController.root_context -%>/javascripts/measures/app.js" src="<%= ApplicationController.root_context -%>/javascripts/third-party/require.js"></script>
<% end %>


<div class="navigator">
  <div class="navigator-header">
    <%= render :partial => 'search_header' -%>
  </div>
  <div class="navigator-filters"></div>
  <div class="navigator-results">
    <%= render :partial => 'search_body' -%>
  </div>
</div>


<script id="filter-bar-template" type="text/x-handlebars-template">
  <form method="get" action="<%= ApplicationController.root_context -%>/measures/search">
    <% if @filter.id %>
      <input type="hidden" name="id" value="<%= h @filter.id -%>">
    <% end %>
    <% if @filter.display %>
      <input type="hidden" name="display" value="<%= h @filter.display.key -%>"/>
      <%
         @filter.display.url_params.each do |k_v_array|
           if k_v_array[1].is_a?(String)
      %>
          <%= hidden_field_tag k_v_array[0], k_v_array[1] -%>
        <% else
             k_v_array[1].each do |string_val|
        %>
            <%= hidden_field_tag "#{k_v_array[0]}[]", string_val -%>
          <% end
             end
             end
             end
          %>

    <div class="navigator-filters-list"></div>
    <button class="navigator-filter-submit"><%= message('search_verb') -%></button>
  </form>
</script>


<%= render :partial => '/navigator/filter_templates' -%>


<script>
  jQuery('html').addClass('navigator-page measures-page');

  window.SS = typeof window.SS === 'object' ? window.SS : {};

  _.extend(window.SS, {
    qualifiers: <%= render :partial => 'measures/qualifiers' -%>,
    languages: <%= render :partial => 'measures/languages' -%>,
    <% condition_metrics = Metric.all.select { |m| m.numeric? && !m.hidden } %>
    metrics: <%= condition_metrics.to_json -%>,
    metricPeriods: {
      '1': '<%= Api::Utils.period_label(1) -%>',
      '2': '<%= Api::Utils.period_label(2) -%>',
      '3': '<%= Api::Utils.period_label(3) -%>'
    },
    favorites: <%= render :partial => 'measures/favourites2' -%>,
    workDuration: {
      days: '<%= message('work_duration.x_days') -%>',
      hours: '<%= message('work_duration.x_hours') -%>',
      minutes: '<%= message('work_duration.x_minutes') -%>'
    },

    phrases: {
      'any':            '<%= escape_javascript message('any') -%>',
      'anytime':        '<%= escape_javascript message('anytime') -%>',
      'all':            '<%= escape_javascript message('all') -%>',
      'manage':         '<%= escape_javascript message('manage') -%>',
      'to':             '<%= escape_javascript message('to.downcase') -%>',
      'value':          '<%= escape_javascript message('value') -%>',
      'components':     '<%= escape_javascript message('measure_filter.criteria.components') -%>',
      'age':            '<%= escape_javascript message('measure_filter.criteria.age') -%>',
      'alert':          '<%= escape_javascript message('measure_filter.criteria.alert') -%>',
      'componentsOf':   '<%= escape_javascript message('measure_filter.criteria.components_of') -%>',
      'date':           '<%= escape_javascript message('measure_filter.criteria.date') -%>',
      'favoritesOnly':  '<%= escape_javascript message('measure_filter.criteria.only_favorites') -%>',
      'keyContains':    '<%= escape_javascript message('measure_filter.criteria.key_contains') -%>',
      'language':       '<%= escape_javascript message('measure_filter.criteria.language') -%>',
      'lastAnalysis':   '<%= escape_javascript message('measure_filter.criteria.last_analysis') -%>',
      'metric':         '<%= escape_javascript message('measure_filter.criteria.metric') -%>',
      'notSet':         '<%= escape_javascript message('measure_filter.criteria.metric.not_set') -%>',
      'nameContains':   '<%= escape_javascript message('measure_filter.name_contains') -%>',
      'moreCriteria':   '<%= escape_javascript message('measure_filter.more_criteria') -%>',
      'error':          '<%= escape_javascript message('measure_filter.criteria.alert.error') -%>',
      'warning':        '<%= escape_javascript message('measure_filter.criteria.alert.warn') -%>',
      'ok':             '<%= escape_javascript message('measure_filter.criteria.alert.ok') -%>',
      'days':           '<%= escape_javascript message('measure_filter.criteria.age.days') -%>',
      'filtersList':    '<%= escape_javascript message('measure_filter.filter_list') -%>',

      'work_duration': {
        'x_days': '<%= escape_javascript message('work_duration.x_days') -%>',
        'x_hours': '<%= escape_javascript message('work_duration.x_hours') -%>',
        'x_minutes': '<%= escape_javascript message('work_duration.x_minutes') -%>'
      }
    }
  });



  var queryParams = [
    { key: 'qualifiers[]', value: <%= @filter.criteria['qualifiers'].to_json -%> },
    { key: 'alertLevels[]', value: <%= @filter.criteria['alertLevels'].to_json -%> },
    { key: 'fromDate', value: '<%= h @filter.criteria['fromDate'] -%>' },
    { key: 'toDate', value: '<%= h @filter.criteria['toDate'] -%>' },
    { key: 'ageMinDays', value: '<%= h @filter.criteria('ageMinDays') -%>' },
    { key: 'ageMaxDays', value: '<%= h @filter.criteria['ageMaxDays'] -%>' },
    <% if @filter.base_resource %>
    { key: 'base', value: ['<%= h @filter.base_resource.key -%>'], text: ['<%= h @filter.base_resource.name(true) -%>'] },
    <% end %>
    { key: 'onFavourites', value: <%= @filter.criteria['onFavourites']=='true' -%> },
    { key: 'keySearch', value: '<%= h @filter.criteria['keySearch'] -%>' },
    { key: 'languages[]', value: <%= @filter.criteria['languages'].to_json -%> },

    <% for i in 1..3 %>
      <% unless @filter.criteria("c#{i}_metric").blank? %>
      { key: '<%= "c#{i}_metric" -%>', value: '<%= h @filter.criteria("c#{i}_metric") -%>' },
      { key: '<%= "c#{i}_period" -%>', value: '<%= h @filter.criteria("c#{i}_period") -%>' },
      { key: '<%= "c#{i}_op" -%>', value: '<%= h @filter.criteria("c#{i}_op") -%>' },
      { key: '<%= "c#{i}_val" -%>', value: '<%= h @filter.criteria("c#{i}_val") -%>' },
      <% end %>
    <% end %>

    { key: 'nameSearch', value: '<%= h @filter.criteria['nameSearch'] -%>' }
  ];
</script>