diff --git a/script.js b/script.js index c162a0bc3002a5c5107414d7e2c56f496e907ab2..35282e08830348d7fd49f7f40f796738d0645590 100644 --- a/script.js +++ b/script.js @@ -76,21 +76,28 @@ function updateDirectLink(profileSlug, path) { } function loadBuildStatus() { - window.fetch(serviceUrl + '/profile/all') - .then(response => response.json()) - .then(json => { - this.console.log(json); - for (const i in json.jobs) { - let job = json.jobs[i]; - elm = this.document.getElementById('build-' + job.name); - - if (elm) { - elm.classList.add(job.status); - elm.innerText = job.status; - elm.insertAdjacentHTML('afterend', '<span class="build-log">(open <a href="' + job.web_url + '">build log</a> #' + job.id + ' from ' + new Date(job.created_at).toLocaleString() + ')</span>'); + getProfiles().then(profiles => { + for (const i in profiles) { + let profile = profiles[i]; + + let elm = document.getElementById('build-' + profile.slug); + if (elm) { + let build = profile.last_build; + if (build) { + elm.classList.add(build.status); + elm.innerText = build.status; + + let date = new Date(build.started_at).toLocaleString(); + let text = '<a href="' + build.web_url + '">#' + build.id + '</a> from ' + date + ' ran for ' + build.duration + ' secs, triggered by <a href="' + build.user.web_url + '">' + build.user.name + '</a>'; + elm.insertAdjacentHTML('afterend', '<span title="' + build.commit.message + '" class="build-details">' + text + '</span>'); + } + else { + elm.classList.add('unknown'); + elm.innerText = 'unknown'; } } - }); + } + }); } function insertVersionCollapsibles() { @@ -130,9 +137,9 @@ function insertVersionCollapsibles() { coll.insertAdjacentElement('beforebegin', btn) btn.addEventListener('click', () => { - window.fetch(apiBaseUrl + '/versions/' + slug + '/' + repo) - .then((response) => response.json()) - .then((pkgs) => { + fetch(serviceUrl + '/profile/api/' + slug + '/versions/' + repo) + .then(response => response.json()) + .then(pkgs => { tbl = document.createElement('table'); tbl.classList.add('versions') tbl.insertAdjacentHTML('afterbegin', '<th>Name</th><th>Version</th>'); diff --git a/style.css b/style.css index c3dd43281975a557a7d940f6d7abedaccfa86ee8..26e8421e1b0a28a2acf7882d6c6e3ec18bf23905 100644 --- a/style.css +++ b/style.css @@ -8,7 +8,7 @@ span.build-badge { padding: 0px 6px; } -span.build-log { +span.build-details { padding-left: 10px; }