Skip to content

Commit

Permalink
lazy-load evaluation errors
Browse files Browse the repository at this point in the history
Closes NixOS#1362

(cherry picked from commit b45f473)
  • Loading branch information
ajs124 authored and Ma27 committed Mar 13, 2024
1 parent d18e5e1 commit 928ef52
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 36 deletions.
9 changes: 9 additions & 0 deletions src/lib/Hydra/Controller/Jobset.pm
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,15 @@ sub evals_GET {
);
}

sub errors :Chained('jobsetChain') :PathPart('errors') :Args(0) :ActionClass('REST') { }

sub errors_GET {
my ($self, $c) = @_;

$c->stash->{template} = 'eval-error.tt';

$self->status_ok($c, entity => $c->stash->{jobset});
}

# Redirect to the latest finished evaluation of this jobset.
sub latest_eval : Chained('jobsetChain') PathPart('latest-eval') {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/Hydra/Controller/JobsetEval.pm
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ sub view_GET {
);
}

sub errors :Chained('evalChain') :PathPart('errors') :Args(0) :ActionClass('REST') { }

sub errors_GET {
my ($self, $c) = @_;

$c->stash->{template} = 'eval-error.tt';

$self->status_ok($c, entity => $c->stash->{eval});
}

sub create_jobset : Chained('evalChain') PathPart('create-jobset') Args(0) {
my ($self, $c) = @_;
Expand Down
26 changes: 26 additions & 0 deletions src/root/eval-error.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[% PROCESS common.tt %]
<!DOCTYPE html>

<html lang="en">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
[% INCLUDE style.tt %]
</head>

<body>

<div class="tab-content tab-pane">
<div id="tabs-errors" class="">
[% IF jobset %]
<p>Errors occurred at [% INCLUDE renderDateTime timestamp=(jobset.errortime || jobset.lastcheckedtime) %].</p>
<div class="card bg-light"><div class="card-body"><pre>[% HTML.escape(jobset.fetcherrormsg || jobset.errormsg) %]</pre></div></div>
[% ELSIF eval %]
<p>Errors occurred at [% INCLUDE renderDateTime timestamp=(eval.evaluationerror.errortime || eval.timestamp) %].</p>
<div class="card bg-light"><div class="card-body"><pre>[% HTML.escape(eval.evaluationerror.errormsg) %]</pre></div></div>
[% END %]
</div>
</div>
</body>
</html>
10 changes: 1 addition & 9 deletions src/root/jobset-eval.tt
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,6 @@ c.uri_for(c.controller('JobsetEval').action_for('view'),

<div class="tab-content">

[% IF eval.evaluationerror.errormsg %]
<div id="tabs-errors" class="tab-pane">
<p>Errors occurred at [% INCLUDE renderDateTime timestamp=(eval.evaluationerror.errortime || eval.timestamp) %].</p>
<div class="card bg-light"><div class="card-body"><pre>[% HTML.escape(eval.evaluationerror.errormsg) %]</pre></div></div>
</div>
[% END %]

<div id="tabs-aborted" class="tab-pane">
[% INCLUDE renderSome builds=aborted tabname="#tabs-aborted" %]
</div>
Expand Down Expand Up @@ -174,8 +167,7 @@ c.uri_for(c.controller('JobsetEval').action_for('view'),

[% IF eval.evaluationerror.errormsg %]
<div id="tabs-errors" class="tab-pane">
<p>Errors occurred at [% INCLUDE renderDateTime timestamp=(eval.evaluationerror.errortime || eval.timestamp) %].</p>
<div class="card bg-light"><div class="card-body"><pre>[% HTML.escape(eval.evaluationerror.errormsg) %]</pre></div></div>
<iframe src="[% c.uri_for(c.controller('JobsetEval').action_for('errors'), [eval.id], params) %]" loading="lazy" frameBorder="0" width="100%"></iframe>
</div>
[% END %]
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/root/jobset.tt
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@

[% IF jobset.errormsg || jobset.fetcherrormsg %]
<div id="tabs-errors" class="tab-pane">
<p>Errors occurred at [% INCLUDE renderDateTime timestamp=(jobset.errortime || jobset.lastcheckedtime) %].</p>
<div class="card bg-light"><div class="card-body"><pre>[% HTML.escape(jobset.fetcherrormsg || jobset.errormsg) %]</pre></div></div>
<iframe src="[% c.uri_for('/jobset' project.name jobset.name "errors") %]" loading="lazy" frameBorder="0" width="100%"></iframe>
</div>
[% END %]

Expand Down
26 changes: 1 addition & 25 deletions src/root/layout.tt
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,7 @@

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

<script type="text/javascript" src="[% c.uri_for("/static/js/jquery/jquery-3.4.1.min.js") %]"></script>
<script type="text/javascript" src="[% c.uri_for("/static/js/jquery/jquery-ui-1.10.4.min.js") %]"></script>
<script type="text/javascript" src="[% c.uri_for("/static/js/moment/moment-2.24.0.min.js") %]"></script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link href="[% c.uri_for("/static/fontawesome/css/all.css") %]" rel="stylesheet" />
<script type="text/javascript" src="[% c.uri_for("/static/js/popper.min.js") %]"></script>
<script type="text/javascript" src="[% c.uri_for("/static/bootstrap/js/bootstrap.min.js") %]"></script>
<link href="[% c.uri_for("/static/bootstrap/css/bootstrap.min.css") %]" rel="stylesheet" />

<!-- hydra.css may need to be moved to before boostrap to make the @media rule work. -->
<link rel="stylesheet" href="[% c.uri_for("/static/css/hydra.css") %]" type="text/css" />
<link rel="stylesheet" href="[% c.uri_for("/static/css/rotated-th.css") %]" type="text/css" />

<style>
.popover { max-width: 40%; }
</style>

<script type="text/javascript" src="[% c.uri_for("/static/js/bootbox.min.js") %]"></script>

<link rel="stylesheet" href="[% c.uri_for("/static/css/tree.css") %]" type="text/css" />

<script type="text/javascript" src="[% c.uri_for("/static/js/common.js") %]"></script>
[% INCLUDE style.tt %]

[% IF c.config.enable_google_login %]
<meta name="google-signin-client_id" content="[% c.config.google_client_id %]">
Expand Down
6 changes: 6 additions & 0 deletions src/root/static/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ $(document).ready(function() {
el.addClass("is-local");
}
});

[...document.getElementsByTagName("iframe")].forEach((element) => {
element.contentWindow.addEventListener("DOMContentLoaded", (_) => {
element.style.height = element.contentWindow.document.body.scrollHeight + 'px';
})
})
});

var tabsLoaded = {};
Expand Down
24 changes: 24 additions & 0 deletions src/root/style.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<script type="text/javascript" src="[% c.uri_for("/static/js/jquery/jquery-3.4.1.min.js") %]"></script>
<script type="text/javascript" src="[% c.uri_for("/static/js/jquery/jquery-ui-1.10.4.min.js") %]"></script>
<script type="text/javascript" src="[% c.uri_for("/static/js/moment/moment-2.24.0.min.js") %]"></script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link href="[% c.uri_for("/static/fontawesome/css/all.css") %]" rel="stylesheet" />
<script type="text/javascript" src="[% c.uri_for("/static/js/popper.min.js") %]"></script>
<script type="text/javascript" src="[% c.uri_for("/static/bootstrap/js/bootstrap.min.js") %]"></script>
<link href="[% c.uri_for("/static/bootstrap/css/bootstrap.min.css") %]" rel="stylesheet" />

<!-- hydra.css may need to be moved to before boostrap to make the @media rule work. -->
<link rel="stylesheet" href="[% c.uri_for("/static/css/hydra.css") %]" type="text/css" />
<link rel="stylesheet" href="[% c.uri_for("/static/css/rotated-th.css") %]" type="text/css" />

<style>
.popover { max-width: 40%; }
</style>

<script type="text/javascript" src="[% c.uri_for("/static/js/bootbox.min.js") %]"></script>

<link rel="stylesheet" href="[% c.uri_for("/static/css/tree.css") %]" type="text/css" />

<script type="text/javascript" src="[% c.uri_for("/static/js/common.js") %]"></script>
5 changes: 5 additions & 0 deletions t/Hydra/Controller/Jobset/evals.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ subtest "/jobset/PROJECT/JOBSET/evals" => sub {
ok($jobsetevals->is_success, "The page showing the jobset evals returns 200.");
};

subtest "/jobset/PROJECT/JOBSET/errors" => sub {
my $jobsetevals = request(GET '/jobset/' . $project->name . '/' . $jobset->name . '/errors');
ok($jobsetevals->is_success, "The page showing the jobset eval errors returns 200.");
};

done_testing;
4 changes: 4 additions & 0 deletions t/Hydra/Controller/JobsetEval/fetch.t
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ subtest "Fetching the eval's overview" => sub {
is($fetch->code, 200, "channel page is 200");
};

subtest "Fetching the eval's overview" => sub {
my $fetch = request(GET '/eval/' . $eval->id, '/errors');
is($fetch->code, 200, "errors page is 200");
};


done_testing;

0 comments on commit 928ef52

Please sign in to comment.