-
Notifications
You must be signed in to change notification settings - Fork 5
Dist landing page #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ThisUsedToBeAnEmail
wants to merge
6
commits into
cpan-testers:master
Choose a base branch
from
ThisUsedToBeAnEmail:dist-landing-page
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
92ce577
commit so you can see?
81159f0
new template file dist/search.html.ep
0662141
dist landing page
a743e1d
remove debugging
3d38af6
allow partial searches on dist page
d7d753f
add validation to the search input only allow a-zA-Z0-9\- characters
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
|
|
||
| <h1>Search Distributions</h1> | ||
|
|
||
| <form class="form-inline"> | ||
| <form id="search-form" class="form-inline"> | ||
| <div class="form-group"> | ||
| <label for="search">Search:</label> | ||
| <input id="search" class="form-control" | ||
|
|
@@ -19,7 +19,7 @@ | |
|
|
||
| <h2>Results</h2> | ||
|
|
||
| <table class="table table-striped"> | ||
| <table id="popular" class="table table-striped"> | ||
| <thead> | ||
| <tr> | ||
| <th>Distribution</th> | ||
|
|
@@ -28,70 +28,124 @@ | |
| <th class="text-center">Reports</th> | ||
| <th class="text-center">Pass</th> | ||
| <th class="text-center">Fail</th> | ||
| <th class="text-center">Unkn</th> | ||
| <th class="text-center">NA</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <template> | ||
| <tr> | ||
| <td> | ||
| <a data-id="dist" href="/dist/Statocles">Statocles</a> | ||
| </td> | ||
| <td data-id="version">0.066</td> | ||
| <td> | ||
| <time data-id="released">2015-01-11 00:12:34</time> | ||
| </td> | ||
| <td data-id="total" class="text-center"> | ||
| 12 | ||
| </td> | ||
| <td data-id="pass" class="bg-success text-center"> | ||
| 11 | ||
| </td> | ||
| <td data-id="fail" class="text-center"> | ||
| 1 | ||
| </td> | ||
| <td data-id="unknown" class="text-center"> | ||
| 1 | ||
| </td> | ||
| <td data-id="na" class="text-center"> | ||
| 1 | ||
| </td> | ||
| </tr> | ||
| </template> | ||
|
|
||
| <tr> | ||
| <td> | ||
| <a href="/dist/Statocles">Statocles</a> | ||
| </td> | ||
| <td>0.066</td> | ||
| <td> | ||
| <time>2015-01-11 00:12:34</time> | ||
| </td> | ||
| <td class="text-center"> | ||
| 12 | ||
| </td> | ||
| <td class="bg-success text-center"> | ||
| 11 | ||
| </td> | ||
| <td class="bg-warning text-center"> | ||
| 1 | ||
| </td> | ||
| </tr> | ||
|
|
||
| <tr> | ||
| <td> | ||
| <a href="/dist/Beam-Wire">Beam-Wire</a> | ||
| </td> | ||
| <td>1.011</td> | ||
| <td> | ||
| <time>2015-01-10 01:24:12</time> | ||
| </td> | ||
| <td class="text-center"> | ||
| 50 | ||
| </td> | ||
| <td class="bg-success text-center"> | ||
| 50 | ||
| </td> | ||
| <td class="bg-success text-center"> | ||
| 0 | ||
| </td> | ||
| </tr> | ||
|
|
||
| <tr> | ||
| <td> | ||
| <a href="/dist/Import-Base">Import-Base</a> | ||
| </td> | ||
| <td>1.001</td> | ||
| <td> | ||
| <time>2015-01-07 01:24:12</time> | ||
| </td> | ||
| <td class="text-center"> | ||
| 74 | ||
| </td> | ||
| <td class="bg-success text-center"> | ||
| 70 | ||
| </td> | ||
| <td class="bg-warning text-center"> | ||
| 4 | ||
| </td> | ||
| </tr> | ||
|
|
||
| </tbody> | ||
| </table> | ||
| <script> | ||
| (function () { | ||
|
|
||
| let Dist = function (dists) { | ||
| this.search_form = document.querySelector('#search-form'); | ||
| this.tbody = document.querySelector('#popular tbody'); | ||
| this.template = this.tbody.querySelector('template'); | ||
| this.init(dists); | ||
| }; | ||
|
|
||
| Dist.prototype = { | ||
| init: function (dists) { | ||
| this.setupEvents(); | ||
| this.poll(dists, 0); | ||
| }, | ||
| setupEvents: function () { | ||
| let self = this; | ||
| let input = self.search_form.querySelector('input#search'); | ||
| self.search_form.addEventListener('submit', function (evt) { | ||
| evt.preventDefault(); | ||
| self.request('/dist/valid', { dist: input.value }, function (res) { | ||
| if (res.ok) { | ||
| window.location.pathname = '/dist/' + input.value; | ||
| } else { | ||
| alert('Distribution with the name ' + input.value + ' not found'); | ||
| } | ||
| }); | ||
| }); | ||
| }, | ||
| poll: function (dists, inc) { | ||
| let self = this; | ||
| if (inc < 10) inc++; | ||
| let pdists = dists.splice(0, inc); | ||
| console.log(dists); | ||
| self.request('/dist', { dists: pdists }, function (res) { | ||
| res.dists.forEach(function (dist) { | ||
| self.render_dist(dist); | ||
| }); | ||
| if (dists.length > 0) self.poll(dists, inc); | ||
| }); | ||
| }, | ||
| request: function (url, params, cb) { | ||
| fetch(url, { | ||
| method: "POST", | ||
| body: JSON.stringify(params), | ||
| }).then(function (res) { | ||
| return res.json(); | ||
| }).then(function (res) { | ||
| cb(res); | ||
| }).catch(function (res) { | ||
| console.log(res); | ||
| }); | ||
| }, | ||
| render_dist: function (dist) { | ||
| let tr = this.template.content.cloneNode(true); | ||
| let name = tr.querySelector('[data-id="dist"]'); | ||
| name.innerText = dist.dist; | ||
| name.href = '/dist/' + dist.dist; | ||
| dist.total = dist.pass + dist.fail + dist.unknown + dist.na; | ||
| ['version', 'released', 'total', 'pass'].forEach(function (n) { | ||
| tr.querySelector('[data-id="' + n + '"]').innerText = dist[n]; | ||
| }); | ||
| let fail = tr.querySelector('[data-id="fail"]'); | ||
| fail.innerText = dist.fail; | ||
| fail.classList.add(dist.fail ? 'bg-danger' : 'bg-success'); | ||
| ['unknown', 'na'].forEach(function (n) { | ||
| let x = tr.querySelector('[data-id="' + n + '"]'); | ||
| x.innerText = dist[n]; | ||
| x.classList.add(dist[n] ? 'bg-warning' : 'bg-success'); | ||
| }); | ||
| this.tbody.appendChild(tr); | ||
| } | ||
| }; | ||
|
|
||
| let dists = [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be better as |
||
| % for my $dist (@$dists) { | ||
| "<%= $dist %>", | ||
| % } | ||
| ]; | ||
|
|
||
| new Dist(dists); | ||
| })(); | ||
| </script> | ||
| </div> | ||
| </div> | ||
| </div> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use arrow functions, you can get rid of the need to do
let self = this;: