-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #159 from WKHAllen/dev
Release 1.2.2
- Loading branch information
Showing
13 changed files
with
194 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function selectColor(number) { | ||
var hue = Math.round(number * 137.508) % 360; // golden angle approximation | ||
return `hsl(${hue}, 100%, 50%)`; | ||
} | ||
|
||
function generateColors(numColors) { | ||
var colors = []; | ||
for (let i = 0; i < numColors; i++) { | ||
colors.push(selectColor(i)); | ||
} | ||
return colors; | ||
} | ||
|
||
function getRowsData() { | ||
var tables = []; | ||
var rows = []; | ||
|
||
$('#rows-table').find($('tr')).find($('.rows-table-table')) | ||
.each(function() { | ||
tables.push($(this).text()); | ||
}); | ||
|
||
$('#rows-table').find($('tr')).find($('.rows-table-rows')) | ||
.each(function() { | ||
rows.push($(this).text()); | ||
}); | ||
|
||
return { tables, rows }; | ||
} | ||
|
||
function createChart() { | ||
var img = new Image(); | ||
img.src = 'https://www.norsebooks.com/img/favicon.png'; | ||
|
||
var rowsData = getRowsData(); | ||
var colors = generateColors(rowsData.tables.length); | ||
var ctx = document.getElementById('rows-chart').getContext('2d'); | ||
var chart = new Chart(ctx, { | ||
type: 'doughnut', | ||
data: { | ||
labels: rowsData.tables, | ||
datasets: [{ | ||
data: rowsData.rows, | ||
backgroundColor: colors | ||
}] | ||
} | ||
}); | ||
} | ||
|
||
$(() => { | ||
createChart(); | ||
}); |
File renamed without changes.
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<script type="text/javascript" src="/js/column-sort.js"></script> | ||
<div class="container"> | ||
<h1 class="centered">Books</h1> | ||
<p class="justified">This page contains relevant information on books. To sort by a column, click on the column header. <a href="/admin">Click here</a> to return to the admin page.</p> | ||
<table class="table table-striped table-hover table-sm"> | ||
<thead> | ||
<tr> | ||
<th scope="col"><a href="?orderBy=title" id="title-header">Title</a></th> | ||
<th scope="col"><a href="?orderBy=author" id="author-header">Author</a></th> | ||
<th scope="col"><a href="?orderBy=listedBy" id="listedBy-header">Listed by</a></th> | ||
<th scope="col"><a href="?orderBy=department" id="department-header">Department</a></th> | ||
<th scope="col"><a href="?orderBy=courseNumber" id="courseNumber-header">Course number</a></th> | ||
<th scope="col"><a href="?orderBy=price" id="price-header">Price</a></th> | ||
<th scope="col"><a href="?orderBy=listedTimestamp" id="listedTimestamp-header">Listed</a></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each books}} | ||
<tr> | ||
<td><a href="/book/{{this.bookid}}">{{this.title}}</a></td> | ||
<td>{{this.author}}</td> | ||
<td>{{this.listedby}}</td> | ||
<td>{{this.department}}</td> | ||
<td>{{this.coursenumber}}</td> | ||
<td>${{this.price}}</td> | ||
<td class="timestamp">{{this.listedtimestamp}}</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
<span class="hidden" id="order-by">{{orderBy}}</span> | ||
<span class="hidden" id="order-direction">{{orderDirection}}</span> | ||
</div> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script> | ||
<script type="text/javascript" src="/js/admin-rows.js"></script> | ||
<div class="container"> | ||
<h1 class="centered">Database Rows</h1> | ||
<p class="justified">This page shows how the database is divided. See the chart or the table below to see how many rows each table uses. <a href="/admin">Click here</a> to return to the admin page.</p> | ||
<div id="rows-chart-container"> | ||
<canvas id="rows-chart" width="400" height="400"></canvas> | ||
</div> | ||
<table class="table table-striped table-hover table-sm"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Table</th> | ||
<th scope="col">Rows</th> | ||
</tr> | ||
</thead> | ||
<tbody id="rows-table"> | ||
{{#each tables}} | ||
<tr> | ||
<td class="rows-table-table">{{this.table}}</td> | ||
<td class="rows-table-rows">{{this.rows}}</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> |
This file contains 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 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