diff --git a/spf/core/static/js/main.js b/spf/core/static/js/main.js index 3aa057f..39745a1 100644 --- a/spf/core/static/js/main.js +++ b/spf/core/static/js/main.js @@ -1,6 +1,6 @@ -function createMessage(msg){ +function createMessage(msg, alert_class){ divAlert = document.createElement('div'); - divAlert.classList.add('alert', 'alert-danger', 'alert-dismissible', 'fade', 'show', 'is-no-rounded', 'm-0', 'p-2'); + divAlert.classList.add('alert', alert_class, 'alert-dismissible', 'fade', 'show', 'is-no-rounded', 'm-0', 'p-2'); divAlert.setAttribute('role', 'alert'); divContainer = document.createElement('div'); @@ -34,31 +34,34 @@ function ingressPackageDownloadToggleSpinner(){ function ingressPackageDownloadCreateTable(data){ tableBody = document.getElementById('resultSearchPackagesTableBody') - for (k in data['doc_pkg']){ - els = data['doc_pkg'][k]; + counter = 1 + for (k in data['doc_pkgs']){ + els = data['doc_pkgs'][k]; row = tableBody.insertRow(-1); - aResult = document.createElement('a') - aResult.text = els['name']; - aResult.href = els['uri']; - aResult.classList.add('link'); - tdUri = row.insertCell(-1); - tdUri.appendChild(aResult); + tdUri.innerHTML = counter; + + aPkgName = document.createElement('a') + aPkgName.text = els['name']; + aPkgName.href = els['uri']; + aPkgName.classList.add('link'); + + tdPkgName = row.insertCell(-1); + tdPkgName.appendChild(aPkgName); - tdCreated = row.insertCell(-1); - tdCreated.innerHTML = els['created']; + tdCreated = row.insertCell(-1) + tdCreated.innerHTML = new Date(els['created']); - tdUpdated = row.insertCell(-1); - tdUpdated.innerHTML = els['updated']; + counter += 1; } - if (data['doc_pkg'].length > 0) { + if (data['doc_pkgs'].length > 0) { document.getElementById('resultSearchPackages').style.display = 'block'; } else { var divBaseMessages = document.getElementById('baseMessages'); for (k in data['errors']){ - element_message = createMessage(data['errors'][k]); + element_message = createMessage(data['errors'][k], 'alert-danger'); divBaseMessages.append(element_message); } } diff --git a/spf/core/templates/ingress/package_download.html b/spf/core/templates/ingress/package_download.html index 588b0aa..f205bf7 100644 --- a/spf/core/templates/ingress/package_download.html +++ b/spf/core/templates/ingress/package_download.html @@ -40,9 +40,9 @@