Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape timeline JSON properly #1075

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/assets/javascripts/miq_timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,22 @@
}
};
})(ManageIQ);

function miqInitTimeline(json) {
if (!json) {
return;
}

var parsed = JSON.parse(json);

var start, end;
if (!ManageIQ.calendar.calDateFrom || !ManageIQ.calendar.calDateTo) {
end = new Date();
start = new Date(end - 24 * 60 * 60 * 1000 * 7);
} else {
start = new Date(ManageIQ.calendar.calDateFrom);
end = new Date(ManageIQ.calendar.calDateTo);
}

ManageIQ.Timeline.load(parsed, start, end);
}
2 changes: 1 addition & 1 deletion app/views/dashboard/_tl_detail.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- elsif @report
#chart_placeholder{:style => 'position: relative'}
= render(:partial => 'layouts/timeline',
:locals => {:tl_json => @tl_json || {},
:locals => {:tl_json => @tl_json,
:data_action => "timeline_data"})
- if @report.filter_summary
= @report.filter_summary
Expand Down
14 changes: 2 additions & 12 deletions app/views/layouts/_timeline.html.haml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
- tl_json ||= nil
%script{:type => "text/javascript"}
- if tl_json
var json = JSON.parse('#{tl_json}'.replace(/"/g, '"'));
var start, end;
if (!ManageIQ.calendar.calDateFrom || !ManageIQ.calendar.calDateTo) {
end = new Date();
start = new Date(end - 24 * 60 * 60 * 1000 * 7);
} else {
start = new Date(ManageIQ.calendar.calDateFrom);
end = new Date(ManageIQ.calendar.calDateTo);
}
ManageIQ.Timeline.load(json, start, end);
:javascript
miqInitTimeline('#{j_str tl_json}');
2 changes: 1 addition & 1 deletion app/views/layouts/_tl_detail.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%fieldset
#chart_placeholder{:style => 'position: relative'}
= render(:partial => 'layouts/timeline',
:locals => {:tl_json => @tl_json || {},
:locals => {:tl_json => @tl_json,
:data_action => "timeline_data"})
- else
.timeline-empty-state
Expand Down
2 changes: 1 addition & 1 deletion app/views/miq_capacity/_bottlenecks_tl_detail.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- elsif @sb[:bottlenecks][:report]
#chart_placeholder{:style => 'position: relative'}
= render(:partial => "layouts/timeline",
:locals => {:tl_json => @tl_json || {},
:locals => {:tl_json => @tl_json,
:position_time => session[:tl_position]})
- if @sb[:bottlenecks][:report].filter_summary
= @sb[:bottlenecks][:report].filter_summary
Expand Down