Project

General

Profile

« Previous | Next » 

Revision 3a555277

Added by Tom Caspy almost 9 years ago

fixes #1881 - adding auto refresh button to dashboard

View differences:

app/assets/javascripts/dashboard.js
$(document).on('ContentLoad', function(){start_gridster()});
$(document).on('ContentLoad', function(){start_gridster(); auto_refresh()});
$(document).on("click",".widget_control .minimize" ,function(){ hide_widget(this);});
$(document).on("click",".widget_control .remove" ,function(){ remove_widget(this);});
var refresh_timeout;
function auto_refresh(){
var element = $(".auto-refresh");
clearTimeout(refresh_timeout);
if (element[0]) {
refresh_timeout = setTimeout(function(){
if ($(".auto-refresh").hasClass("on")) {
Turbolinks.visit(location.toString());
}
},60000);
}
}
function start_gridster(){
var gridster = $(".gridster>ul").gridster({
widget_margins: [10, 10],
app/assets/stylesheets/dashboard.scss
margin-top: 80px;
float: right;
}
.auto-refresh {
a {
border: none;
background: none;
}
margin-left: 5px;
&.on a {
color: #005C7E;
}
&.off a {
color: #ccc;
}
}
app/helpers/dashboard_helper.rb
widgets_to_add
end
),
documentation_button
documentation_button,
auto_refresh_button(:defaults_to => true)
]
end
......
:disabled_hosts => "#92A8CD"
}
end
def auto_refresh_button(options = {})
on = options[:defaults_to] ? "on" : "off"
if params[:auto_refresh].present?
on = params[:auto_refresh] == "0" ? "off" : "on"
end
if on == "on"
tooltip = _("Auto refresh on")
else
tooltip = _("Auto refresh off")
end
link = link_to(icon_text("refresh"), {:auto_refresh => (on == "on" ? "0" : "1")}, { :'data-original-title' => tooltip, :rel => 'twipsy' })
"<div class='btn-toolbar pull-right auto-refresh #{on}'>#{link}</div>"
end
end

Also available in: Unified diff