[Bps-public-commit] r14931 - in Pushmi/trunk: . Pushmi-Admin/lib/Pushmi/Admin Pushmi-Admin/lib/Pushmi/Admin/Action Pushmi-Admin/lib/Pushmi/Admin/Event Pushmi-Admin/lib/Pushmi/Admin/Model Pushmi-Admin/share/web/static/css
alexmv at bestpractical.com
alexmv at bestpractical.com
Fri Aug 8 16:22:12 EDT 2008
Author: alexmv
Date: Fri Aug 8 16:22:09 2008
New Revision: 14931
Added:
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Event/Inactive.pm
Modified:
Pushmi/trunk/ (props changed)
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Event/ReplicaStatus.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Watcher.pm
Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css
Log:
r35518 at kohr-ah: chmrr | 2008-08-07 15:47:50 -0400
* More removal of trailing slashes in SVN urls
* Better progressbar support
* Fix a mirror => dav_root change missed previously
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin.pm Fri Aug 8 16:22:09 2008
@@ -26,9 +26,9 @@
eval {
my ($baton, $ref) = SVN::Core::auth_open_helper(undef);
my $ra = SVN::Ra->new( url => $url, config => undef, auth => $baton);
- $props->{root} = $ra->get_repos_root;
+ $props->{root} = $ra->get_repos_root; $props->{root} =~ s{/+$}{};
$props->{rev} = $ra->get_latest_revnum;
- $props->{date} = 1e6 * str2time($ra->rev_prop($props->{rev}, 'svn:date'));
+ $props->{date} = str2time($ra->rev_prop($props->{rev}, 'svn:date'));
};
warn "$@" if $@;
alarm 0;
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Action/CreateReplica.pm Fri Aug 8 16:22:09 2008
@@ -19,7 +19,7 @@
my $props = Pushmi::Admin->svn_info_for($url);
- return $self->validation_error( url => "Read of $url failed\n" ) unless $props;
+ return $self->validation_error( url => "Read of $url failed" ) unless $props;
$self->argument_value( url => $props->{root} );
return $self->validation_ok("url");
}
Added: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Event/Inactive.pm
==============================================================================
--- (empty file)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Event/Inactive.pm Fri Aug 8 16:22:09 2008
@@ -0,0 +1,19 @@
+package Pushmi::Admin::Event::Inactive;
+use strict;
+use warnings;
+use base 'Pushmi::Admin::Event';
+
+sub match {
+ my $self = shift;
+ my $query = shift;
+
+ return if $query->{id} and $self->data->{id} != $query->{id};
+ return 1;
+}
+
+sub render_arguments {
+ my $self = shift;
+ return ( id => $self->data->{id} );
+}
+
+1;
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Event/ReplicaStatus.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Event/ReplicaStatus.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Event/ReplicaStatus.pm Fri Aug 8 16:22:09 2008
@@ -7,12 +7,17 @@
my $self = shift;
my $query = shift;
- return $self->data->{id} == $query->{id} if $query->{id};
+ return if $query->{id} and $self->data->{id} != $query->{id};
+ if ($query->{tostatus}) {
+ return if $self->data->{new} eq $self->data->{old};
+ return if $self->data->{new} ne $query->{tostatus};
+ }
return 1;
}
sub render_arguments {
- %{$_[0]->data};
+ my $self = shift;
+ return ( id => $self->data->{id} );
}
1;
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Model/Replica.pm Fri Aug 8 16:22:09 2008
@@ -231,8 +231,9 @@
sub time_delta {
my $self = shift;
my ($time) = @_;
+ return "???" unless defined $time;
my $d = Time::Duration::duration(
- time - $time / 1e6 );
+ time - $time );
return $d if $d eq "just now";
return "$d ago";
}
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/View.pm Fri Aug 8 16:22:09 2008
@@ -13,14 +13,24 @@
my $replicas = Pushmi::Admin::Model::ReplicaCollection->new;
$replicas->unlimit;
div {
- { id is 'replica_list', class is 'roundbox' };
+ { id is 'replica-list', class is 'roundbox' };
h2 {"Current replicas"};
while ( my $replica = $replicas->next ) {
- render_region(
- name => "summary-" . $replica->id,
- path => "/fragments/summary",
- arguments => { id => $replica->id }
- );
+ div {
+ { class is 'replica-element' };
+ render_region(
+ name => "summary-" . $replica->id,
+ path => "/fragments/summary",
+ arguments => { id => $replica->id }
+ );
+ div {
+ render_region(
+ name => "progress-" . $replica->id,
+ arguments => {id => $replica->id},
+ path => "/fragments/progressbar",
+ );
+ };
+ };
}
};
@@ -55,13 +65,13 @@
Jifty->web->redirect('/') unless $new->argument_value("url");
my $data = Pushmi::Admin->svn_info_for( $new->argument_value("url") );
my $changed
- = DateTime->from_epoch( epoch => $data->{date} / 1e6 );
+ = DateTime->from_epoch( epoch => $data->{date} );
$changed->set_time_zone("EST");
div {
{ id is 'new_replica', class is 'roundbox' };
h2 {"Add a new replica"};
div {
- { id is 'replica_status', class is 'roundbox' };
+ { id is 'replica-status', class is 'roundbox' };
h3 { $new->argument_value("url") }
p { $data->{rev} . " revisions" } p {
"Last modified on " . $changed->ymd . ", at " . $changed->hms;
@@ -70,7 +80,7 @@
form {
$new->argument_value(
- mirror => Pushmi::Admin::Model::Replica->_clean_name(
+ dav_root => Pushmi::Admin::Model::Replica->_clean_name(
$new->argument_value("name")
)
);
@@ -106,7 +116,7 @@
if ($replica->remote_revision) {
my $progress = int(($replica->local_revision / $replica->remote_revision) * 100);
- outs_raw( qq{<script>if (jQuery("#progress")) jQuery("#progress").progressBar($progress)</script>} );
+ outs_raw( qq{<script>if (jQuery("#progress-$id")) jQuery("#progress-$id").progressBar($progress)</script>} );
}
# Add a PubSub watcher, if need be
@@ -146,7 +156,7 @@
render_param(
$sync => "bootstrap" );
- form_submit( label => "Start mirroring", onclick => {submit => $sync, region => "progress-".$replica->id, replace_with => "/fragments/progressbar", effect => "Appear"} );
+ form_submit( label => "Start mirroring", onclick => {submit => $sync} );
}
} elsif ( $replica->status ne "failed" ) {
h2 {"Replica health"};
@@ -168,7 +178,7 @@
my $sync = Jifty->web->new_action( class => "Sync", );
render_param(
$sync => "replica" => default_value => $replica->id );
- form_submit( label => "Force an update now", onclick => {submit => $sync, region => "progress-".$replica->id, replace_with => "/fragments/progressbar", effect => "Appear"} );
+ form_submit( label => "Force an update now", onclick => {submit => $sync} );
}
}
} else {
@@ -186,13 +196,30 @@
template 'fragments/progressbar' => sub {
my $id = get('id');
my $replica = Pushmi::Admin::Model::Replica->load($id);
+
+ Jifty->subs->add(
+ class => 'ReplicaStatus',
+ queries => [{ id => $id, tostatus => "loading" }],
+ mode => 'Replace',
+ region => Jifty->web->qualified_region,
+ render_with => '/fragments/progressbar',
+ effect => 'Appear',
+ );
+
+ Jifty->subs->add(
+ class => 'Inactive',
+ queries => [{ id => $id }],
+ mode => 'Replace',
+ region => Jifty->web->qualified_region,
+ render_with => '/fragments/progressbar',
+ );
+
return unless $replica->remote_revision;
- return if $replica->remote_revision eq $replica->local_revision;
return unless $replica->status eq "loading";
my $progress = int(($replica->local_revision / $replica->remote_revision) * 100);
- outs_raw( q{<script>jQuery(document).ready(function() {jQuery("#progress").progressBar();})</script>} );
- span {{ class is "progressBar", id is "progress"}; $progress . "%" };
+ outs_raw( qq{<script>jQuery(document).ready(function() {jQuery("#progress-$id").progressBar();})</script>} );
+ span {{ class is "progressbar", id is "progress-$id"}; $progress . "%" };
};
template 'replica' => page { title => "About " . get("replica")->name } content {
@@ -205,9 +232,13 @@
path => "/fragments/summary",
arguments => { id => $replica->id },
);
- my @args;
- @args = (pqth => "/fragments/progressbar") if $replica->status eq "loading";
- div { render_region( name => "progress-" . $replica->id, arguments => {id => $replica->id}, @args ) };
+ div {
+ render_region(
+ name => "progress-" . $replica->id,
+ arguments => {id => $replica->id},
+ path => "/fragments/progressbar",
+ );
+ };
};
Modified: Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Watcher.pm
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Watcher.pm (original)
+++ Pushmi/trunk/Pushmi-Admin/lib/Pushmi/Admin/Watcher.pm Fri Aug 8 16:22:09 2008
@@ -16,6 +16,8 @@
sub new {
my ($class, $id) = @_;
my $previous = "";
+ my $short = "";
+ my $inactive = 0;
my $pool = SVN::Pool->new_default;
@@ -33,9 +35,16 @@
if ($replica->long_status ne $previous) {
print STDERR "@{[$replica->clean_name]}: NEW STATUS: @{[$replica->long_status]}\n";
Pushmi::Admin::Event::ReplicaStatus->new(
- { id => $id }
+ { id => $id, old => $short, new => $replica->status }
+ )->publish;
+ $inactive = 0;
+ } elsif (++$inactive == 5 and $replica->status ne "loading") {
+ print STDERR "@{[$replica->clean_name]}: 5 second inactivity timer\n";
+ Pushmi::Admin::Event::Inactive->new(
+ { id => $id, status => $replica->status }
)->publish;
}
+ $short = $replica->status;
$previous = $replica->long_status;
$pool->clear;
sleep 1;
Modified: Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css
==============================================================================
--- Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css (original)
+++ Pushmi/trunk/Pushmi-Admin/share/web/static/css/app.css Fri Aug 8 16:22:09 2008
@@ -112,18 +112,21 @@
/* Replica summaries, lists, and status lights */
-#replica_status {
+#replica-status {
background: #223;
}
-#replica_list .replica {
+#replica-list .replica-element {
+ margin: 1em 0;
+}
+
+#replica-list .replica-element + .replica-element {
border-top: 1px solid #334;
}
.replica {
clear: left;
padding-left: 60px;
- margin: 1em 0;
}
.replica.status-light {
@@ -139,9 +142,10 @@
/* Progressbar */
-#progress {
+.progressbar {
text-align: center;
display: block;
+ margin: 1em 0;
}
More information about the Bps-public-commit
mailing list