cmd/pkgserver: pagination bugfix
This commit is contained in:
@@ -7,10 +7,10 @@ class PackageIndexEntry {
|
|||||||
report: boolean
|
report: boolean
|
||||||
}
|
}
|
||||||
function toHTML(entry: PackageIndexEntry): HTMLTableRowElement {
|
function toHTML(entry: PackageIndexEntry): HTMLTableRowElement {
|
||||||
let v = entry.version !== null ? `<span>${escapeHtml(entry.version)}</span>` : ""
|
let v = entry.version != null ? `<span>${escapeHtml(entry.version)}</span>` : ""
|
||||||
let s = entry.size !== null ? `<p>Size: ${toByteSizeString(entry.size)} (${entry.size})</p>` : ""
|
let s = entry.size != null ? `<p>Size: ${toByteSizeString(entry.size)} (${entry.size})</p>` : ""
|
||||||
let d = entry.description !== null ? `<p>${escapeHtml(entry.description)}</p>` : ""
|
let d = entry.description != null ? `<p>${escapeHtml(entry.description)}</p>` : ""
|
||||||
let w = entry.website !== null ? `<a href="${encodeURI(entry.website)}">Website</a>` : ""
|
let w = entry.website != null ? `<a href="${encodeURI(entry.website)}">Website</a>` : ""
|
||||||
let r = entry.report ? `Log (<a href=\"${encodeURI('/api/v1/status/' + entry.name)}\">View</a> | <a href=\"${encodeURI('/status/' + entry.name)}\">Download</a>)` : ""
|
let r = entry.report ? `Log (<a href=\"${encodeURI('/api/v1/status/' + entry.name)}\">View</a> | <a href=\"${encodeURI('/status/' + entry.name)}\">Download</a>)` : ""
|
||||||
let row = <HTMLTableRowElement>(document.createElement('tr'))
|
let row = <HTMLTableRowElement>(document.createElement('tr'))
|
||||||
row.innerHTML = `<td>
|
row.innerHTML = `<td>
|
||||||
@@ -24,7 +24,7 @@ function toHTML(entry: PackageIndexEntry): HTMLTableRowElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toByteSizeString(bytes: number): string {
|
function toByteSizeString(bytes: number): string {
|
||||||
if(bytes < 1024) return `${bytes}B`
|
if(bytes == null || bytes < 1024) return `${bytes}B`
|
||||||
if(bytes < Math.pow(1024, 2)) return `${(bytes/1024).toFixed(2)}kiB`
|
if(bytes < Math.pow(1024, 2)) return `${(bytes/1024).toFixed(2)}kiB`
|
||||||
if(bytes < Math.pow(1024, 3)) return `${(bytes/Math.pow(1024, 2)).toFixed(2)}MiB`
|
if(bytes < Math.pow(1024, 3)) return `${(bytes/Math.pow(1024, 2)).toFixed(2)}MiB`
|
||||||
if(bytes < Math.pow(1024, 4)) return `${(bytes/Math.pow(1024, 3)).toFixed(2)}GiB`
|
if(bytes < Math.pow(1024, 4)) return `${(bytes/Math.pow(1024, 3)).toFixed(2)}GiB`
|
||||||
@@ -50,7 +50,7 @@ class GetPayload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum SortOrders {
|
enum SortOrders {
|
||||||
DeclarationAscending = 0,
|
DeclarationAscending,
|
||||||
DeclarationDescending,
|
DeclarationDescending,
|
||||||
NameAscending,
|
NameAscending,
|
||||||
NameDescending
|
NameDescending
|
||||||
@@ -128,6 +128,7 @@ function nextPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function escapeHtml(str: string): string {
|
function escapeHtml(str: string): string {
|
||||||
|
if(str === undefined) return ""
|
||||||
return str
|
return str
|
||||||
.replace(/&/g, '&')
|
.replace(/&/g, '&')
|
||||||
.replace(/</g, '<')
|
.replace(/</g, '<')
|
||||||
|
|||||||
Reference in New Issue
Block a user