Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
gestion de certaines actions si donnée vector-db supprimée (closes #78)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocruze committed Jun 1, 2022
1 parent 03bc6c3 commit 3d24843
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
31 changes: 28 additions & 3 deletions assets/js/components/stored-data-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export class StoredDataAction {
this.title = null;
this.message = null;
this.failMessage = null;
this.successMessage = null;

this.successCallback = null;
this.failCallback = null;

this.datastoreId = datastoreId;
this.storedData = storedData;
Expand All @@ -30,9 +34,23 @@ export class StoredDataAction {
callback: (result => {
if (!result) return;

$.post(_self.url, () => { }).fail(() => {
flash.flashAdd(_self.failMessage, 'danger');
});
$.post(_self.url, () => { })
.then(() => {
if (_self.successMessage) {
flash.flashAdd(_self.successMessage, 'success');
}

if (_self.successCallback) {
_self.successCallback();
}
})
.fail(() => {
flash.flashAdd(_self.failMessage, 'danger');

if (_self.failCallback) {
_self.failCallback();
}
});
})
});
}
Expand All @@ -58,8 +76,15 @@ export class RemoveAction extends StoredDataAction {
}
this.message += `Voulez-vous continuer ?</p>`;

this.successMessage = `La donnée ${storedData._id} a été supprimée.`;
this.failMessage = `La suppression de la donnée ${storedData._id} a échoué.`;

this.successCallback = function () {
if (location.pathname.endsWith('/integration')) {
location.href = Routing.generate('plage_datastore_view', { datastoreId: this.datastoreId })
}
}

switch (storedData.status) {
// Suppression d'une donnee de type base Postgres ou de type pyramide
case 'GENERATED':
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/DatastoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function createSandbox()
/**
* Tableau de bord d'un espace de travail.
*
* @Route("/{datastoreId}", name="view", methods={"GET"})
* @Route("/{datastoreId}", name="view", methods={"GET"}, options={"expose"=true})
*/
public function view($datastoreId): Response
{
Expand Down
12 changes: 12 additions & 0 deletions src/Controller/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Components\Workflow\AbstractWorkflow;
use App\Components\Workflow\IntegrationWorkflow;
use App\Components\Workflow\WorkflowRunner;
use App\Constants\StoredDataStatuses;
use App\Constants\UploadTypes;
use App\Exception\AppException;
use App\Exception\PlageApiException;
Expand Down Expand Up @@ -116,6 +117,17 @@ public function getById($datastoreId, $uploadId): Response
public function integration($datastoreId, $uploadId)
{
$upload = $this->plageApi->upload->get($datastoreId, $uploadId);

// rediriger vers le tableau de bord si vectordb est supprimé
if (array_key_exists('vectordb_id', $upload['tags'])) {
$vectordb = $this->plageApi->storedData->get($datastoreId, $upload['tags']['vectordb_id']);
if (StoredDataStatuses::DELETED == $vectordb['status']) {
$this->addFlash('notice', sprintf('La donnée %s a été supprimée', $vectordb['_id']));

return $this->redirectToRoute('plage_datastore_view', ['datastoreId' => $datastoreId]);
}
}

$upload['tags']['workflow_integration_progress'] = json_decode($upload['tags']['workflow_integration_progress'], true);

$workflowClassName = $upload['tags']['workflow_class_name'];
Expand Down
4 changes: 4 additions & 0 deletions templates/pages/stored_data/report.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
{% set pageHelp = 'stored_data.report.generation_failure_help' | trans %}
{% endif %}

{% if stored_data.status == 'DELETED' %}
{% set pageHelp = 'stored_data.report.stored_data_deleted_help' | trans %}
{% endif %}

{% block title %} {{ pageTitle ~ ' - ' ~ parent() }} {% endblock %}

{% set checkTypes = constant('App\\Constants\\UploadCheckTypes::TYPES_LIST') %}
Expand Down
1 change: 1 addition & 0 deletions translations/PlageWebClient.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ stored_data:
generation_title: "Rapport de génération de la pyramide de tuiles vectorielles %stored_data_name%"
generation_help: "Vos tuiles vectorielles ont été générées avec succès à partir de vos données."
generation_failure_help: "Les tuiles vectorielles n'ont pas pu être générées correctement. Vous trouverez ci-dessous des informations techniques concernant les processus exécutés et les problèmes rencontrés."
stored_data_deleted_help: "Cette donnée a été supprimée. Vous ne pouvez plus l'utiliser mais cette page conserve la trace des actions qui l'ont concerné."
step_upload: "Téléversement du fichier"
details: "Détails techniques :"
upload_name: "Nom :"
Expand Down

0 comments on commit 3d24843

Please sign in to comment.