From 9422c9d2a75c5f3465f1c1925d8c109f0fb478ae Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 22 Feb 2013 18:05:04 +0100 Subject: [PATCH] Optimise clickable rows Set a click handler on the table instead of on every row. This should be faster on large tables. Also, it's easier to use: you just set the clickable-rows class on the table, and the row-link class on the element that contains the "main" link of the row. --- src/root/build.tt | 6 +++--- src/root/channel-contents.tt | 6 +++--- src/root/common.tt | 18 +++++++++--------- src/root/layout.tt | 7 +++++++ src/root/overview.tt | 6 +++--- src/root/project.tt | 13 ++++++------- src/root/view.tt | 7 +++---- 7 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/root/build.tt b/src/root/build.tt index 382d7b5e..12a4f357 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -15,7 +15,7 @@ [% END %] [% BLOCK renderBuildSteps %] - +
@@ -24,7 +24,7 @@ [% IF ( type == "All" ) || ( type == "Failed" && step.status != 0 ) || ( type == "Running" && step.busy == 1 ) %] [% has_log = log_exists(step.drvpath); log = c.uri_for('/build' build.id 'nixlog' step.stepnr); %] - + [% END %] diff --git a/src/root/channel-contents.tt b/src/root/channel-contents.tt index b03ee4e0..7d82512f 100644 --- a/src/root/channel-contents.tt +++ b/src/root/channel-contents.tt @@ -32,7 +32,7 @@ install the package simply by clicking on the packages below.

This channel contains the following packages.

-
NrWhatDurationMachineStatus
[% step.stepnr %] [% IF step.type == 0 %] @@ -53,7 +53,7 @@ [% ELSE %] Failed: [% HTML.escape(step.errormsg) %] [% END %] - [%%] [%+ IF has_log; INCLUDE renderLogLinks url=log; END %] + [%%] [%+ IF has_log; INCLUDE renderLogLinks url=log inRow=1; END %]
+
@@ -50,9 +50,9 @@ install the package simply by clicking on the packages below.

[% b = pkg.build %] [% uri = "${curUri}/pkg/${pkg.name}.nixpkg" %] - + - +
[% b.id %][% b.get_column('releasename') || b.nixname %][% b.get_column('releasename') || b.nixname %] [% b.system %] [% IF b.homepage %] diff --git a/src/root/common.tt b/src/root/common.tt index f3ba0e39..d691bc8d 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -24,12 +24,12 @@ END; BLOCK renderProjectName %] -[% project %] +[% project %] [% END; BLOCK renderJobsetName %] -[% jobset %] +[% jobset %] [% END; @@ -62,7 +62,7 @@ END; BLOCK renderBuildListHeader %] - +
[% IF !hideResultInfo %] @@ -95,7 +95,7 @@ BLOCK renderBuildListHeader %] BLOCK renderBuildListBody; FOREACH build IN builds; %] - + [% IF !hideResultInfo %] [% END %] - + [% IF showSchedulingInfo %] [% END %] @@ -382,7 +382,7 @@ END; BLOCK renderEvals %] -
[% INCLUDE renderBuildStatusIcon size=16 busy=(showSchedulingInfo ? 1 : 0) buildstatus=build.buildstatus %] @@ -104,7 +104,7 @@ BLOCK renderBuildListBody; [% IF showSchedulingInfo %] [% IF build.busy %]Started[% ELSE %]Queued[% END %][% build.id %][% build.id %][% build.priority %]
+
[% IF !jobset && !build %] @@ -398,11 +398,11 @@ BLOCK renderEvals %] [% FOREACH e IN evals; eval = e.eval; link = c.uri_for(c.controller('JobsetEval').action_for('view'), [eval.id]) %] - + [% IF !jobset && !build %] [% END %] - +
[% INCLUDE renderFullJobsetName project=eval.get_column('project') jobset=eval.get_column('jobset') %][% eval.id %][% eval.id %] [% INCLUDE renderDateTime timestamp = eval.timestamp %] [% IF e.changedInputs.size > 0; @@ -440,7 +440,7 @@ BLOCK renderEvals %] BLOCK renderLogLinks %] -(log, raw, tail) +(log, raw, tail) [% END; diff --git a/src/root/layout.tt b/src/root/layout.tt index 970723f6..7f388236 100644 --- a/src/root/layout.tt +++ b/src/root/layout.tt @@ -72,6 +72,13 @@ }); }); + $("table.clickable-rows").click(function(event) { + if ($(event.target).closest("a").length) return; + link = $(event.target).parents("tr").find("a.row-link"); + if (link.length == 1) + window.location = link.attr("href"); + }); + }); diff --git a/src/root/overview.tt b/src/root/overview.tt index 968c15dc..30fa5e6f 100644 --- a/src/root/overview.tt +++ b/src/root/overview.tt @@ -15,7 +15,7 @@

The following projects are hosted on this server:

- +
@@ -25,8 +25,8 @@ [% FOREACH p IN projects %] - - + + diff --git a/src/root/project.tt b/src/root/project.tt index d6a07bcc..383084f2 100644 --- a/src/root/project.tt +++ b/src/root/project.tt @@ -14,7 +14,7 @@ [% IF project.jobsets.size > 0 %]

This project has the following jobsets:

-
Id
[% INCLUDE renderProjectName project = p.name %]
[% INCLUDE renderProjectName project=p.name inRow=1 %] [% HTML.escape(p.displayname) %] [% WRAPPER maybeLink uri=p.homepage %][% HTML.escape(p.description) %][% END %]
+
@@ -27,7 +27,7 @@ [% FOREACH j IN jobsets %] [% successrate = 0 %] - + - + [% IF j.get_column('nrtotal') > 0 %] @@ -119,7 +119,7 @@

This project has made the following releases:

-
[% IF j.get_column('nrscheduled') > 0 %] Scheduled @@ -39,7 +39,7 @@ All Failed [% END %] [% INCLUDE renderJobsetName project = project.name jobset = j.name %][% INCLUDE renderJobsetName project=project.name jobset=j.name inRow=1 %] [% HTML.escape(j.description) %] [% INCLUDE renderDateTime timestamp = j.lastcheckedtime %]
+
@@ -128,9 +128,8 @@ [% FOREACH release IN releases %] - [% link = c.uri_for('/release' project.name release.name) %] - - + + [% END %] diff --git a/src/root/view.tt b/src/root/view.tt index e5311f6f..231687b2 100644 --- a/src/root/view.tt +++ b/src/root/view.tt @@ -9,7 +9,7 @@

Showing results [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + results.size %] out of [% totalResults %].

-
Name
[% release.name %]
[% release.name %] [% INCLUDE renderDateTime timestamp = release.timestamp %]
+
@@ -24,8 +24,7 @@ [% FOREACH result IN results %] - [% link = c.uri_for('/view' project.name view.name result.id) %] - + - +
[% IF result.status == 0 %] @@ -35,7 +34,7 @@ [% END %] [% result.id %][% result.id %] [% IF result.releasename %] [% result.releasename %]