1 $(document).ready(function() {
2 // reset options and reload page
3 $('#new_report').click(function() {
4 var current_report = $('input[name=type]').val();
5 var base_uri = _site_domain + _index_page + '/' + _current_uri;
6 var uri_xtra = current_report == 'avail' ? '' : '?type=sla';
7 self.location.href = base_uri + uri_xtra;
10 $('#include_trends').click(function() {
12 $('#include_trends_scaling').attr('disabled', false);
14 $('#include_trends_scaling').attr('disabled', true);
15 $('#include_trends_scaling').attr('checked', false);
19 $("#report_period").bind('change', function() {
20 show_calendar($(this).attr('value'));
22 show_calendar($("#report_period").attr('value'));
24 $('.autofill').click(function() {
25 var the_val = $(this).siblings('input').val();
27 if (!confirm(_reports_propagate.replace('this value', the_val+'%'))) {
30 set_report_form_values(the_val);
32 if (!confirm(_reports_propagate_remove)) {
35 set_report_form_values('');
39 $("#new_schedule_btn").click(function() {$('.schedule_error').hide();})
41 $('#filename').blur(function() {
42 // Make sure the filename is explicit by adding it when focus leaves input
44 var filename = input.val();
48 if(!filename.match(/\.(csv|pdf)$/)) {
54 $('#include_trends').live('click', function(ev) {
55 if (ev.target.checked)
56 $('.trend_options').show();
58 $('.trend_options').hide();
61 $('#sla_report_id').on('change', function(ev) {
62 var sla_id = $(this).attr('value');
64 // don't try to fetch sla values when we have no id
67 show_progress('progress', _wait_str);
68 var url = _site_domain + _index_page + '/sla/per_month_sla_for_report';
69 var data = {sla_id: sla_id}
74 complete: function() {
75 $('#progress').hide();
78 $.notify(_reports_error + ': Unable to fetch saved sla values...', {'sticky':true});
80 success: function(data) {
81 for (var i = 0; i < data.length; i++) {
82 var input = $('#month_' + i);
83 if (input.is(':disabled') || !data[i]) {
89 $('.sla_values').show();
96 // Propagate sla values
97 function set_report_form_values(the_val)
100 var field_name = 'month_' + i;
101 var input = $("#"+field_name);
102 if (input.attr('disabled')) {
103 input.attr('value', '');
105 input.attr('value', the_val);
111 * create ajax call to reports/fetch_field_value
112 * to fetch a specific field value and asssign it to html element.
114 function fetch_field_value(type, id, elem_id)
117 url: _site_domain + _index_page + '/reports/fetch_field_value?id=' + id + '&type=' + type,
118 success: function(data) {
119 $('#' + elem_id).text(data);