Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/assets/browse/origin-search.js
/** | /** | ||||
* Copyright (C) 2018-2021 The Software Heritage developers | * Copyright (C) 2018-2022 The Software Heritage developers | ||||
* See the AUTHORS file at the top-level directory of this distribution | * See the AUTHORS file at the top-level directory of this distribution | ||||
* License: GNU Affero General Public License version 3, or any later version | * License: GNU Affero General Public License version 3, or any later version | ||||
* See top-level LICENSE file for more information | * See top-level LICENSE file for more information | ||||
*/ | */ | ||||
import {handleFetchError, errorMessageFromResponse, isArchivedOrigin} from 'utils/functions'; | import {errorMessageFromResponse, handleFetchError, isArchivedOrigin} from 'utils/functions'; | ||||
const limit = 100; | const limit = 100; | ||||
const linksPrev = []; | const linksPrev = []; | ||||
let linkNext = null; | let linkNext = null; | ||||
let linkCurrent = null; | let linkCurrent = null; | ||||
let inSearch = false; | let inSearch = false; | ||||
function parseLinkHeader(s) { | function parseLinkHeader(s) { | ||||
Show All 31 Lines | for (const [i, origin] of origins.entries()) { | ||||
`<a href="${browseUrl}">${origin.url}</a></td>`; | `<a href="${browseUrl}">${origin.url}</a></td>`; | ||||
tableRow += | tableRow += | ||||
`<td class="swh-visit-status" id="visit-status-origin-${i}">` + | `<td class="swh-visit-status" id="visit-status-origin-${i}">` + | ||||
'<i title="Checking archiving status" class="mdi mdi-sync mdi-spin mdi-fw"></i>' + | '<i title="Checking archiving status" class="mdi mdi-sync mdi-spin mdi-fw"></i>' + | ||||
'Checking</td>'; | 'Checking</td>'; | ||||
tableRow += '</tr>'; | tableRow += '</tr>'; | ||||
table.append(tableRow); | table.append(tableRow); | ||||
// get async latest visit snapshot and update visit status icon | // get async latest visit snapshot and update visit status icon | ||||
let latestSnapshotUrl = Urls.api_1_origin_visit_latest(origin.url); | let latestSnapshotUrl = Urls.api_1_origin_visit_latest(encodeURIComponent(origin.url)); | ||||
latestSnapshotUrl += '?require_snapshot=true'; | latestSnapshotUrl += '?require_snapshot=true'; | ||||
promises.push(fetch(latestSnapshotUrl)); | promises.push(fetch(latestSnapshotUrl)); | ||||
} | } | ||||
const responses = await Promise.all(promises); | const responses = await Promise.all(promises); | ||||
const responsesData = await Promise.all(responses.map(r => r.json())); | const responsesData = await Promise.all(responses.map(r => r.json())); | ||||
for (let i = 0; i < responses.length; ++i) { | for (let i = 0; i < responses.length; ++i) { | ||||
const response = responses[i]; | const response = responses[i]; | ||||
const data = responsesData[i]; | const data = responsesData[i]; | ||||
▲ Show 20 Lines • Show All 207 Lines • Show Last 20 Lines |