Merge pull request #609 from warpc/590-build_list_page_change
[refs #590] add time notification and periodic page update
This commit is contained in:
commit
45169faf2f
|
@ -1384,3 +1384,11 @@ hr.bootstrap {
|
|||
filter: alpha(opacity=20);
|
||||
}
|
||||
}
|
||||
|
||||
time.js-relative-date {
|
||||
display: block;
|
||||
}
|
||||
|
||||
div.reloader {
|
||||
float: right;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class Projects::BuildListsController < Projects::BaseController
|
|||
def index
|
||||
@action_url = @project ? search_project_build_lists_path(@project) : search_build_lists_path
|
||||
@filter = BuildList::Filter.new(@project, current_user, params[:filter] || {})
|
||||
@build_lists = @filter.find.scoped(:include => [:save_to_platform, :project, :user, :arch])
|
||||
@build_lists = @filter.find.includes [:save_to_platform, :save_to_repository, :arch, :user => [:groups], :project => [:owner]]
|
||||
@build_lists = @build_lists.recent.paginate :page => params[:page]
|
||||
|
||||
@build_server_status = begin
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
%tr{:id => "row#{build_list_counter}", :class => "#{build_list_status_color(build_list.status)}"}
|
||||
%td= link_to (build_list.bs_id.present? ? build_list.bs_id : t("layout.build_lists.bs_id_not_set")), build_list
|
||||
%td= build_list.human_status
|
||||
%td
|
||||
= build_list.human_status
|
||||
- if BuildList::HUMAN_STATUSES[build_list.status].in? [:build_pending, :build_started, :build_publish]
|
||||
%time.js-relative-date{:datetime => build_list.updated_at.strftime("%FT%T%:z"), :title => build_list.updated_at.strftime("%F %T")}
|
||||
= build_list.updated_at.strftime "%F %T"
|
||||
%td= link_to build_list.project.name_with_owner, build_list.project
|
||||
%td= build_list_version_link(build_list)
|
||||
%td= link_to "#{build_list.save_to_platform.name}/#{build_list.save_to_repository.name}", [build_list.save_to_platform, build_list.save_to_repository]
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
-set_meta_tags :title => t('.title')
|
||||
/ #myTable
|
||||
|
||||
%div.reloader
|
||||
= label_tag :autoreload do
|
||||
= check_box_tag :autoreload, true, true
|
||||
= t("layout.autoreload_page")
|
||||
.both
|
||||
|
||||
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
|
||||
%thead
|
||||
%tr
|
||||
|
@ -13,6 +19,57 @@
|
|||
%tbody= render :partial => 'projects/build_lists/build_list', :collection => @build_lists
|
||||
.both
|
||||
|
||||
:javascript
|
||||
$(function(){
|
||||
// from jQuery.timeago
|
||||
var parseIso8601 = function(iso8601) {
|
||||
var s = $.trim(iso8601);
|
||||
s = s.replace(/\.\d+/,""); // remove milliseconds
|
||||
s = s.replace(/-/,"/").replace(/-/,"/");
|
||||
s = s.replace(/T/," ").replace(/Z/," UTC");
|
||||
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
|
||||
return new Date(s);
|
||||
}
|
||||
var strTimeBetween = function(dt, dt1) {
|
||||
|
||||
var formatNumber = function(num) {
|
||||
return (num < 10) ? "0%d".replace("%d", num) : num
|
||||
}
|
||||
|
||||
var seconds = Math.abs(dt1 - dt) / 1000;
|
||||
var minutes = seconds / 60;
|
||||
var hours = minutes / 60;
|
||||
minutes = Math.round(minutes % 60);
|
||||
hours = Math.round(hours);
|
||||
|
||||
return "%d:%d".replace("%d", formatNumber(hours))
|
||||
.replace("%d", formatNumber(minutes));
|
||||
}
|
||||
// TODO Very, very ugly method.
|
||||
var now = (new Date).getTime();
|
||||
$("time.js-relative-date").each(function() {
|
||||
var time = parseIso8601($(this).attr('datetime')).getTime();
|
||||
$(this).text(strTimeBetween(time, now));
|
||||
});
|
||||
|
||||
var t = null;
|
||||
|
||||
var reloadChange = function() {
|
||||
if ($(this).is(':checked')) {
|
||||
//reload page every 1 minute
|
||||
t = setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 60000);
|
||||
} else {
|
||||
clearTimeout(t);
|
||||
}
|
||||
}
|
||||
|
||||
$('#autoreload').on('change', reloadChange)
|
||||
.trigger('change');
|
||||
|
||||
});
|
||||
|
||||
= will_paginate @build_lists
|
||||
|
||||
= render 'filter'
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
en:
|
||||
layout:
|
||||
autoreload_page: Update page automatically
|
||||
read_more: Read more
|
||||
turned_on: on
|
||||
turned_off: off
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
ru:
|
||||
layout:
|
||||
autoreload_page: Автоматически обновлять страницу
|
||||
read_more: Читать дальше
|
||||
turned_on: включены
|
||||
turned_off: выключены
|
||||
|
|
Loading…
Reference in New Issue