Skip to content

Commit

Permalink
Add table sorting.
Browse files Browse the repository at this point in the history
  • Loading branch information
francois2metz committed Jul 26, 2023
1 parent 00662a4 commit dac476f
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h2 class="pt-3">Dependency Pulse</h2>
<p class="fw-light">pulse representing "pulse check", an indication of a dependency's activity; the time since the release of the latest available version of a dependency (including pre-release). Measured in "libyears".</p>
<canvas id="pulseChart"></canvas>
<h2 class="pt-3">Last run result</h2>
<table class="table table-striped">
<table id="rawResult" class="table table-striped">
<thead>
<tr>
<th scope="col">Dependency</th>
Expand Down
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"bootstrap": "^5.3.0",
"chai": "^4.3.7",
"chart.js": "^4.3.0",
"datatables.net-bs": "^1.13.5",
"mocha": "^10.2.0",
"parcel": "^2.9.3",
"sinon": "^15.1.2"
Expand Down
10 changes: 10 additions & 0 deletions src/web.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import Chart from 'chart.js/auto';
import DataTable from 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css'
import { parseFile, replaceRepositoryWithSafeChar } from './utils.mjs';

const PATH = process.env.REPOSITORY_URL || `https://raw.githubusercontent.com/1024pix/dependency-drift-tracker/main`;

let driftChart;
let pulseChart;
let table;
const historyFiles = {};

function formatFloat(number) {
Expand Down Expand Up @@ -128,6 +131,7 @@ async function displayChart(line) {
}

async function displayLastRun(line) {
if (table) table.destroy();
const response = await fetch(`${PATH}/data/last-run-${replaceRepositoryWithSafeChar(line)}.json`);
const data = await response.json();

Expand All @@ -145,6 +149,12 @@ async function displayLastRun(line) {
createTd(tr, formatFloat(d.pulse));
tbody.appendChild(tr);
});

table = new DataTable('#rawResult', {
paging: false,
searching: false,
info: false,
});
}

function selectButton({ repository, path }) {
Expand Down

0 comments on commit dac476f

Please sign in to comment.