diff --git a/dist/js/debug-item-composer.min.js b/dist/js/debug-item-composer.min.js deleted file mode 100644 index 880e8749..00000000 --- a/dist/js/debug-item-composer.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(drupalSettings){"use strict";document.querySelectorAll("[data-since]").forEach((e=>{e.innerText=function(e){const t=new Date(e),a=new Date-t,n=[{name:"milliseconds",val:1e3},{name:"seconds",val:6e4},{name:"minutes",val:36e5},{name:"hours",val:864e5},{name:"days",val:307584e5},{name:"years",val:307584e6}];for(let e=0;e0&&(r=Math.round(a/n[e-1].val)),`${r} ${t.name} ago`}}return"forever ago"}(e.dataset.since)})),document.querySelectorAll("[data-package][data-version]").forEach((function(e){const t=e.dataset.package,a=e.dataset.version;var n={method:"GET",headers:new Headers,redirect:"follow"};if(drupalSettings&&drupalSettings.path&&drupalSettings.path.pathPrefix){const r=`${drupalSettings.path.baseUrl}${drupalSettings.path.pathPrefix}api/v1/package?name=${t}&version=${a}`;fetch(r,n).then((e=>e.text())).then((t=>{const a=JSON.parse(t);a.latestVersion?e.innerText=a.latestVersion:e.innerText="Unknown";const n=e.parentElement.querySelector("td:first-of-type");a.isLatest||(n.style="color: red")})).catch((e=>console.log("error",e)))}else console.error("drupalSettings.path.pathPrefix not found")}))}(drupalSettings); \ No newline at end of file diff --git a/hdbt_admin.libraries.yml b/hdbt_admin.libraries.yml index ff962719..9cc73e3e 100644 --- a/hdbt_admin.libraries.yml +++ b/hdbt_admin.libraries.yml @@ -36,13 +36,6 @@ updating-news-auto-toggle: dependencies: - core/once -debug-item-composer: - js: - dist/js/debug-item-composer.min.js: {} - version: 1.x - dependencies: - - core/drupalSettings - global-styling: version: 1.x css: diff --git a/src/js/debug-item-composer.js b/src/js/debug-item-composer.js deleted file mode 100644 index ae248f74..00000000 --- a/src/js/debug-item-composer.js +++ /dev/null @@ -1,73 +0,0 @@ -(function (drupalSettings) { - 'use strict'; - - function since(msString) { - const then = new Date(msString); - const now = new Date(); - const ms = now - then; - const sinceArr = [ - { name: 'milliseconds', val: 1000 }, - { name: 'seconds', val: 60 * 1000 }, - { name: 'minutes', val: 60 * 60 * 1000 }, - { name: 'hours', val: 24 * 60 * 60 * 1000 }, - { name: 'days', val: 356 * 24 * 60 * 60 * 1000 }, - { name: 'years', val: 10 * 356 * 24 * 60 * 60 * 1000 }, - ]; - - for (let i = 0; i < sinceArr.length; i++) { - const item = sinceArr[i]; - if (ms < item.val) { - let msNum = ms; - if (i > 0) { - msNum = Math.round(ms / sinceArr[i - 1].val); - } - return `${msNum} ${item.name} ago`; - } - } - return 'forever ago'; - } - - document.querySelectorAll('[data-since]') - .forEach((sinceCell) => { - sinceCell.innerText = since(sinceCell.dataset.since); - } - ); - - - function getLatest(element) { - const packageName = element.dataset.package; - const packageVersion = element.dataset.version; - - var requestOptions = { - method: 'GET', - headers: new Headers(), - redirect: 'follow' - }; - - if (drupalSettings && drupalSettings.path && drupalSettings.path.pathPrefix) { - const apiUrl = `${drupalSettings.path.baseUrl}${drupalSettings.path.pathPrefix}api/v1/package?name=${packageName}&version=${packageVersion}`; - - fetch(apiUrl, requestOptions) - .then(response => response.text()) - .then(result => { - const resultObj = JSON.parse(result); - - if (resultObj.latestVersion) { - element.innerText = resultObj.latestVersion; - } else { - element.innerText = 'Unknown'; - } - const versionElement = element.parentElement.querySelector('td:first-of-type'); - if (!resultObj.isLatest) { - versionElement.style = 'color: red'; - } - } - ) - .catch(error => console.log('error', error)); - } else { - console.error('drupalSettings.path.pathPrefix not found'); - } - } - document.querySelectorAll('[data-package][data-version]').forEach(getLatest); - -})(drupalSettings); diff --git a/templates/module/helfi_debug/debug-item--composer.html.twig b/templates/module/helfi_debug/debug-item--composer.html.twig index d2a08a15..8371b34e 100644 --- a/templates/module/helfi_debug/debug-item--composer.html.twig +++ b/templates/module/helfi_debug/debug-item--composer.html.twig @@ -17,19 +17,15 @@ * - data: An array of data returned by your plugin's collect() method. */ #} -{{ attach_library('hdbt_admin/debug-item-composer') }} - -{{ id }} {{ label }} +

{{ label }}

- - @@ -41,7 +37,6 @@ - @@ -57,3 +52,7 @@ {% endfor %}
Package VersionUpdated Timestamp ReleasesLatest
{{ package.version }} Loading.. {{ package.time }}
+ +

+ View outdated composer packages with: composer show "drupal/helfi_*" "drupal/hdbt*" --outdated +