mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
feat: add upstream and aur urls to package info modal
This commit is contained in:
parent
deab8ddae6
commit
3f8b9eaed6
@ -20,6 +20,13 @@
|
||||
<div id="package-info-licenses" class="col-8 col-lg-5"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mt-2">
|
||||
<div class="col-4 col-lg-1" style="text-align: right">upstream</div>
|
||||
<div id="package-info-upstream-url" class="col-8 col-lg-5"></div>
|
||||
<div class="col-4 col-lg-1" style="text-align: right">AUR</div>
|
||||
<div id="package-info-aur-url" class="col-8 col-lg-5"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mt-2">
|
||||
<div class="col-4 col-lg-1" style="text-align: right">packages</div>
|
||||
<div id="package-info-packages" class="col-8 col-lg-5"></div>
|
||||
@ -52,11 +59,13 @@
|
||||
const packageInfoModalHeader = $("#package-info-modal-header");
|
||||
const packageInfo = $("#package-info");
|
||||
packageInfoModal.on("hidden.bs.modal", () => {
|
||||
packageInfoAurUrl.empty();
|
||||
packageInfoDepends.empty();
|
||||
packageInfoGroups.empty();
|
||||
packageInfoLicenses.empty();
|
||||
packageInfoPackager.empty();
|
||||
packageInfoPackages.empty();
|
||||
packageInfoUpstreamUrl.empty();
|
||||
packageInfoVersion.empty();
|
||||
|
||||
packageInfoVariablesDiv.empty();
|
||||
@ -71,11 +80,13 @@
|
||||
const packageInfoLogsInput = $("#package-info-logs-input");
|
||||
const packageInfoLogsCopyButton = $("#package-info-logs-copy-button");
|
||||
|
||||
const packageInfoAurUrl = $("#package-info-aur-url");
|
||||
const packageInfoDepends = $("#package-info-depends");
|
||||
const packageInfoGroups = $("#package-info-groups");
|
||||
const packageInfoLicenses = $("#package-info-licenses");
|
||||
const packageInfoPackager = $("#package-info-packager");
|
||||
const packageInfoPackages = $("#package-info-packages");
|
||||
const packageInfoUpstreamUrl = $("#package-info-upstream-url");
|
||||
const packageInfoVersion = $("#package-info-version");
|
||||
|
||||
const packageInfoVariablesDiv = $("#package-info-variables-div");
|
||||
@ -170,6 +181,8 @@
|
||||
success: response => {
|
||||
const description = response.find(Boolean);
|
||||
const packages = Object.keys(description.package.packages);
|
||||
const aurUrl = description.package.remote.web_url;
|
||||
const upstreamUrls = Object.values(description.package.packages).map(single => single.url);
|
||||
|
||||
packageInfo.text(`${description.package.base} ${description.status.status} at ${new Date(1000 * description.status.timestamp).toISOStringShort()}`);
|
||||
|
||||
@ -177,6 +190,7 @@
|
||||
packageInfoModalHeader.addClass("modal-header");
|
||||
headerClass(description.status.status).forEach(clz => packageInfoModalHeader.addClass(clz));
|
||||
|
||||
packageInfoAurUrl.html(aurUrl ? safeLink(aurUrl, aurUrl, "AUR link").outerHTML : "");
|
||||
packageInfoDepends.html(listToTable(
|
||||
Object.values(description.package.packages)
|
||||
.reduce((accumulator, currentValue) => {
|
||||
@ -189,6 +203,7 @@
|
||||
packageInfoLicenses.html(listToTable(extractListProperties(description.package, "licenses")));
|
||||
packageInfoPackager.text(description.package.packager);
|
||||
packageInfoPackages.html(listToTable(packages));
|
||||
packageInfoUpstreamUrl.html(upstreamUrls.map(url => safeLink(url, url, "upstream link").outerHTML).join("<br>"));
|
||||
packageInfoVersion.text(description.package.version);
|
||||
|
||||
hideInfoControls(false);
|
||||
|
@ -149,7 +149,7 @@
|
||||
const web_url = description.package.remote.web_url;
|
||||
return {
|
||||
id: package_base,
|
||||
base: web_url ? `<a href="${safe(web_url)}" title="${safe(package_base)}">${safe(package_base)}</a>` : safe(package_base),
|
||||
base: web_url ? safeLink(web_url, package_base, package_base).outerHTML : safe(package_base),
|
||||
version: safe(description.package.version),
|
||||
packager: description.package.packager ? safe(description.package.packager) : "",
|
||||
packages: listToTable(Object.keys(description.package.packages)),
|
||||
|
@ -79,6 +79,15 @@
|
||||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
// because I'm tired of safe element generation
|
||||
function safeLink(url, text, title) {
|
||||
const element = document.createElement("a");
|
||||
element.href = url;
|
||||
element.innerText = text;
|
||||
if (title) element.title = title;
|
||||
return element;
|
||||
}
|
||||
|
||||
Date.prototype.toISOStringShort = function() {
|
||||
const pad = number => String(number).padStart(2, "0");
|
||||
return `${this.getFullYear()}-${pad(this.getMonth() + 1)}-${pad(this.getDate())} ${pad(this.getHours())}:${pad(this.getMinutes())}:${pad(this.getSeconds())}`;
|
||||
|
Loading…
Reference in New Issue
Block a user