Removed dep on API
[ninja.git] / application / views / summary / js / summary.js
blobb15270b6a3cb881cb8345c7ce20d969f4df849ff
1 $(document).ready(function() {
2 $('#report_mode_form input').on('change', function() {
3 set_report_mode(this.value);
4 });
5 set_report_mode($('#report_mode_form input:checked').val());
7 $("#report_period").bind('change', function() {
8 show_calendar($(this).val());
9 });
10 show_calendar($('#report_period').val());
12 // reset options and reload page
13 $('#new_report').click(function() {
14 var base_uri = _site_domain + _index_page + '/' + _current_uri;
15 self.location.href = base_uri;
16 });
18 $('.comments').editable(_site_domain + _index_page + '/alert_history/add_comment', {
19 data: function(value) {
20 var that = $(this);
21 that.addClass('editing-comments').on('blur', 'input', function() {
22 that.removeClass('editing-comments');
23 });
24 return $(value).filter('.content').text()
26 submitdata: function(value, settings) {
27 $(this).removeClass('editing-comments');
28 var eventrow = $(this).parents('.eventrow');
29 return {
30 timestamp: eventrow.data('timestamp'),
31 event_type: eventrow.data('statecode'),
32 host_name: eventrow.data('hostname'),
33 service_description: eventrow.data('servicename'),
34 comment: $('input', this).val() // (today) you cannot use value, because it's the original HTML
37 width: 'none'
38 });
40 $('.toggle-long-output').on('click', function() {
41 var toggler = $(this);
42 var span = toggler.parent().siblings('.alert-history-long-output');
43 if (toggler.text() === '+') {
44 toggler.text('-');
45 span.show();
46 } else if (toggler.text() === '-') {
47 toggler.text('+');
48 span.hide();
50 });
51 });
53 function set_report_mode(type)
55 switch (type) {
56 case 'standard':
57 $('.standard').show();
58 $('.custom').hide();
59 break;
60 case 'custom':
61 $('.standard').hide();
62 $('.custom').show();
63 break;