Page MenuHomeSoftware Heritage

D1727.id7098.diff
No OneTemporary

D1727.id7098.diff

diff --git a/cypress/integration/vault.spec.js b/cypress/integration/vault.spec.js
--- a/cypress/integration/vault.spec.js
+++ b/cypress/integration/vault.spec.js
@@ -23,6 +23,8 @@
cy.contains('.dropdown-item', objectType)
.click();
+ cy.wait('@checkVaultCookingTask');
+
cy.get('.modal-dialog')
.contains('button:visible', 'Ok')
.click();
@@ -113,21 +115,28 @@
// Stub responses when requesting the vault API to simulate
// a task has been created
+
+ cy.route({
+ method: 'GET',
+ url: this.vaultDirectoryUrl,
+ response: {'exception': 'NotFoundExc'}
+ }).as('checkVaultCookingTask');
+
cy.route({
method: 'POST',
url: this.vaultDirectoryUrl,
response: this.genVaultDirCookingResponse('new')
}).as('createVaultCookingTask');
+ // Create a vault cooking task through the GUI
+ createVaultCookingTask('as tarball');
+
cy.route({
method: 'GET',
url: this.vaultDirectoryUrl,
response: this.genVaultDirCookingResponse('new')
}).as('checkVaultCookingTask');
- // Create a vault cooking task through the GUI
- createVaultCookingTask('Directory');
-
cy.wait('@createVaultCookingTask');
// Check that a redirection to the vault UI has been performed
@@ -185,21 +194,28 @@
// Stub responses when requesting the vault API to simulate
// a task has been created
+
+ cy.route({
+ method: 'GET',
+ url: this.vaultRevisionUrl,
+ response: {'exception': 'NotFoundExc'}
+ }).as('checkVaultCookingTask');
+
cy.route({
method: 'POST',
url: this.vaultRevisionUrl,
response: this.genVaultRevCookingResponse('new')
}).as('createVaultCookingTask');
+ // Create a vault cooking task through the GUI
+ createVaultCookingTask('as git');
+
cy.route({
method: 'GET',
url: this.vaultRevisionUrl,
response: this.genVaultRevCookingResponse('new')
}).as('checkVaultCookingTask');
- // Create a vault cooking task through the GUI
- createVaultCookingTask('Revision');
-
cy.wait('@createVaultCookingTask');
// Check that a redirection to the vault UI has been performed
diff --git a/swh/web/assets/src/bundles/vault/vault-create-tasks.js b/swh/web/assets/src/bundles/vault/vault-create-tasks.js
--- a/swh/web/assets/src/bundles/vault/vault-create-tasks.js
+++ b/swh/web/assets/src/bundles/vault/vault-create-tasks.js
@@ -7,6 +7,27 @@
import {handleFetchError, csrfPost} from 'utils/functions';
+export function vaultRequest(objectType, objectId) {
+ let vaultUrl;
+ if (objectType === 'directory') {
+ vaultUrl = Urls.api_1_vault_cook_directory(objectId);
+ } else {
+ vaultUrl = Urls.api_1_vault_cook_revision_gitfast(objectId);
+ }
+ // check if object has already been cooked
+ fetch(vaultUrl)
+ .then(response => response.json())
+ .then(data => {
+ // object needs to be cooked
+ if (data.exception === 'NotFoundExc') {
+ $(`#vault-cook-${objectType}-modal`).modal('show');
+ // object has been cooked and is in the vault cache
+ } else if (data.status === 'done') {
+ $(`#vault-fetch-${objectType}-modal`).modal('show');
+ }
+ });
+}
+
function addVaultCookingTask(cookingTask) {
let vaultCookingTasks = JSON.parse(localStorage.getItem('swh-vault-cooking-tasks'));
if (!vaultCookingTasks) {
@@ -64,6 +85,16 @@
}
}
+export function fetchDirectoryArchive(directoryId) {
+ $('#vault-fetch-directory-modal').modal('hide');
+ const vaultUrl = Urls.api_1_vault_cook_directory(directoryId);
+ fetch(vaultUrl)
+ .then(response => response.json())
+ .then(data => {
+ swh.vault.fetchCookedObject(data.fetch_url);
+ });
+}
+
export function cookRevisionArchive(revisionId) {
let email = $('#swh-vault-revision-email').val().trim();
if (!email || validateEmail(email)) {
@@ -78,3 +109,13 @@
$('#invalid-email-modal').modal('show');
}
}
+
+export function fetchRevisionArchive(revisionId) {
+ $('#vault-fetch-directory-modal').modal('hide');
+ const vaultUrl = Urls.api_1_vault_cook_revision_gitfast(revisionId);
+ fetch(vaultUrl)
+ .then(response => response.json())
+ .then(data => {
+ swh.vault.fetchCookedObject(data.fetch_url);
+ });
+}
diff --git a/swh/web/templates/browse/vault-ui.html b/swh/web/templates/browse/vault-ui.html
--- a/swh/web/templates/browse/vault-ui.html
+++ b/swh/web/templates/browse/vault-ui.html
@@ -1,7 +1,7 @@
{% extends "./layout.html" %}
{% comment %}
-Copyright (C) 2017-2018 The Software Heritage developers
+Copyright (C) 2017-2019 The Software Heritage developers
See the AUTHORS file at the top-level directory of this distribution
License: GNU Affero General Public License version 3, or any later version
See top-level LICENSE file for more information
@@ -37,31 +37,7 @@
<tbody></tbody>
</table>
</div>
-<iframe id="vault-fetch-iframe" style="display:none;"></iframe>
-<div class="modal fade" id="vault-recook-object-modal" tabindex="-1" role="dialog" aria-labelledby="vault-recook-object-modal-label" aria-hidden="true">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <h6 class="modal-title" id="vault-recook-object-modal-label">Download link no more available</h6>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">&times;</span>
- </button>
- </div>
- <div class="modal-body">
- <p>
- The requested archive is no more available to download from the Software Heritage Vault.
- </p>
- <p>
- Do you want to cook it again ?
- </p>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Cancel</button>
- <button type="button" class="btn btn-default btn-sm" onclick="swh.vault.recookObject()">Ok</button>
- </div>
- </div>
- </div>
-</div>
+{% include "includes/vault-common.html" %}
<script>
swh.webapp.initPage('vault');
swh.vault.initUi();
diff --git a/swh/web/templates/browse/vault-ui.html b/swh/web/templates/includes/vault-common.html
copy from swh/web/templates/browse/vault-ui.html
copy to swh/web/templates/includes/vault-common.html
--- a/swh/web/templates/browse/vault-ui.html
+++ b/swh/web/templates/includes/vault-common.html
@@ -1,42 +1,10 @@
-{% extends "./layout.html" %}
-
{% comment %}
-Copyright (C) 2017-2018 The Software Heritage developers
+Copyright (C) 2019 The Software Heritage developers
See the AUTHORS file at the top-level directory of this distribution
License: GNU Affero General Public License version 3, or any later version
See top-level LICENSE file for more information
{% endcomment %}
-{% load render_bundle from webpack_loader %}
-
-{% block navbar-content %}
-<h4>Download archived software</h4>
-{% endblock %}
-
-{% block browse-content %}
-<p>
- This interface enables to track the status of the different Software Heritage
- Vault cooking tasks created while browsing the archive.
-</p>
-<p>
- Once a cooking task is finished, a link will be made available in order to
- download the associated archive.
-</p>
-<button type="button" class="btn btn-default btn-sm" id="vault-remove-tasks">Remove selected tasks</button>
-<div class="table-responsive mt-3">
- <table class="table swh-table swh-table-striped swh-vault-table" id="vault-cooking-tasks">
- <thead>
- <tr>
- <th><input type="checkbox" id="vault-tasks-toggle-selection"/></th>
- <th style="width: 100px">Object type</th>
- <th>Object id</th>
- <th style="width: 350px">Cooking status</th>
- <th style="width: 320px"></th>
- </tr>
- </thead>
- <tbody></tbody>
- </table>
-</div>
<iframe id="vault-fetch-iframe" style="display:none;"></iframe>
<div class="modal fade" id="vault-recook-object-modal" tabindex="-1" role="dialog" aria-labelledby="vault-recook-object-modal-label" aria-hidden="true">
<div class="modal-dialog">
@@ -61,9 +29,4 @@
</div>
</div>
</div>
-</div>
-<script>
- swh.webapp.initPage('vault');
- swh.vault.initUi();
-</script>
-{% endblock %}
+</div>
\ No newline at end of file
diff --git a/swh/web/templates/includes/vault-create-tasks.html b/swh/web/templates/includes/vault-create-tasks.html
--- a/swh/web/templates/includes/vault-create-tasks.html
+++ b/swh/web/templates/includes/vault-create-tasks.html
@@ -16,13 +16,13 @@
</a>
<div class="dropdown-menu">
{% if vault_cooking.directory_context %}
- <button class="dropdown-item" type="button" tabindex="-1" data-toggle="modal" data-target="#vault-cook-directory-modal">
- <i class="{{ swh_object_icons.directory }} fa-fw" aria-hidden="true"></i>Directory
+ <button class="dropdown-item" type="button" tabindex="-1" onclick="swh.vault.vaultRequest('directory', '{{ vault_cooking.directory_id }}')">
+ <i class="{{ swh_object_icons.directory }} fa-fw" aria-hidden="true"></i>as tarball
</button>
{% endif %}
{% if vault_cooking.revision_context %}
- <button class="dropdown-item" type="button" tabindex="-1" data-toggle="modal" data-target="#vault-cook-revision-modal">
- <i class="{{ swh_object_icons.revision }} fa-fw"></i>Revision
+ <button class="dropdown-item" type="button" tabindex="-1" onclick="swh.vault.vaultRequest('revision', '{{ vault_cooking.revision_id }}')">
+ <i class="{{ swh_object_icons.revision }} fa-fw"></i>as git
</button>
{% endif %}
</div>
@@ -42,8 +42,12 @@
<div class="modal-body">
<p>
You have requested the cooking of the directory with identifier <strong>{{ vault_cooking.directory_id }}</strong>
- into a standard tar.gz archive.
+ into a standard <code>tar.gz archive</code>.
</p>
+ <p>
+ Once downloaded, the directory can be extracted with the following command:
+ </p>
+ <p><code>$ tar xvzf {{ vault_cooking.directory_id }}.tar.gz</code></p>
<p>
Are you sure you want to continue ?
</p>
@@ -62,6 +66,36 @@
</div>
</div>
+ <div class="modal fade" id="vault-fetch-directory-modal" tabindex="-1" role="dialog" aria-labelledby="vault-fetch-directory-modal-label" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h6 class="modal-title" id="vault-fetch-directory-modal-label">Download a directory from the Software Heritage Vault</h6>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <p>
+ You have requested the download of the directory with identifier <strong>{{ vault_cooking.directory_id }}</strong>
+ as a standard <code>tar.gz archive</code>.
+ </p>
+ <p>
+ Once downloaded, the directory can be extracted with the following command:
+ </p>
+ <p><code>$ tar xvzf {{ vault_cooking.directory_id }}.tar.gz</code></p>
+ <p>
+ Are you sure you want to continue ?
+ </p>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Cancel</button>
+ <button type="button" class="btn btn-default btn-sm" onclick="swh.vault.fetchDirectoryArchive('{{ vault_cooking.directory_id }}')">Ok</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
<div class="modal fade" id="vault-cook-revision-modal" tabindex="-1" role="dialog" aria-labelledby="vault-cook-revision-modal-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
@@ -73,8 +107,15 @@
</div>
<div class="modal-body">
<p>
- You have requested the cooking of the revision with identifier <strong>{{ vault_cooking.revision_id }}</strong>
- into a git fast-import archive.
+ You have requested the cooking of the history heading to revision with identifier <strong>{{ vault_cooking.revision_id }}</strong>
+ into a <code>git fast-import archive<code>.
+ </p>
+ <p>
+ Once downloaded, the git repository can be imported with the following commands:
+ </p>
+ <p>
+ <code>$ git init</code><br/>
+ <code>$ zcat {{ vault_cooking.revision_id }}.gitfast.gz | git fast-import</code>
</p>
<p>
Are you sure you want to continue ?
@@ -94,6 +135,39 @@
</div>
</div>
+ <div class="modal fade" id="vault-fetch-revision-modal" tabindex="-1" role="dialog" aria-labelledby="vault-fetch-revision-modal-label" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h6 class="modal-title" id="vault-fetch-revision-modal-label">Download a revision from the Software Heritage Vault</h6>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">&times;</span>
+ </button>
+ </div>
+ <div class="modal-body">
+ <p>
+ You have requested the download of the history heading to revision with identifier <strong>{{ vault_cooking.revision_id }}</strong>
+ as a <code>git fast-import archive<code>.
+ </p>
+ <p>
+ Once downloaded, the git repository can be imported with the following commands:
+ </p>
+ <p>
+ <code>$ git init</code><br/>
+ <code>$ zcat {{ vault_cooking.revision_id }}.gitfast.gz | git fast-import</code>
+ </p>
+ <p>
+ Are you sure you want to continue ?
+ </p>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Cancel</button>
+ <button type="button" class="btn btn-default btn-sm" onclick="swh.vault.fetchRevisionArchive('{{ vault_cooking.revision_id }}')">Ok</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
<div class="modal fade" id="invalid-email-modal" tabindex="-1" role="dialog" aria-labelledby="invalid-email-modal-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
@@ -111,4 +185,6 @@
</div>
</div>
+ {% include "includes/vault-common.html" %}
+
{% endif %}

File Metadata

Mime Type
text/plain
Expires
Nov 4 2024, 8:45 PM (11 w, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3220780

Event Timeline