Skip to content

Commit 52f6076

Browse files
authored
Added a button to display exceptions / log in a modal (#33)
1 parent 0c13878 commit 52f6076

7 files changed

Lines changed: 41 additions & 3 deletions

File tree

src/Controller/JobController.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,26 @@ public function displayDetails(int $id): Response
5555
]);
5656
}
5757

58+
/**
59+
* @Route("/details/log/{id}", name="coderhapsodie.ezdataflow.job.log")
60+
*
61+
* @param int $id
62+
*
63+
* @return Response
64+
*/
65+
public function displayLog(int $id): Response
66+
{
67+
$this->denyAccessUnlessGranted(new Attribute('ezdataflow', 'view'));
68+
$item = $this->jobGateway->find($id);
69+
$log = array_map(function ($line) {
70+
return preg_replace('~#\d+~', "\n$0", $line);
71+
}, $item->getExceptions());
72+
73+
return $this->render('@ezdesign/ezdataflow/Item/log.html.twig', [
74+
'log' => $log,
75+
]);
76+
}
77+
5878
/**
5979
* @Route("/create", name="coderhapsodie.ezdataflow.job.create", methods={"POST"})
6080
*

src/Resources/translations/messages.en.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,18 @@ coderhapsodie.ezdataflow.history.details.request: 'Requested on'
3636
coderhapsodie.ezdataflow.history.details.status: Status
3737
coderhapsodie.ezdataflow.history.details.start: 'Started on'
3838
coderhapsodie.ezdataflow.history.details.end: 'Finished on'
39-
coderhapsodie.ezdataflow.history.details.count: 'Items count'
39+
coderhapsodie.ezdataflow.history.details.count: 'Items successfully processed'
4040
coderhapsodie.ezdataflow.history.details.options: 'Run options'
4141
coderhapsodie.ezdataflow.history.details.errors: Errors
4242
coderhapsodie.ezdataflow.history.details.type: 'Name of the dataflow executed'
43+
coderhapsodie.ezdataflow.history.details.log: 'View log'
4344
coderhapsodie.ezdataflow.workflow.repeating.new.title: 'Add a new repeating dataflow'
4445
coderhapsodie.ezdataflow.workflow.new.cancel: Cancel
4546
coderhapsodie.ezdataflow.workflow.new.submit: Create
4647
coderhapsodie.ezdataflow.history.list.empty: 'No execution yet.'
4748
coderhapsodie.ezdataflow.workflow.list.empty: 'No repeating workflow configured yet'
4849
coderhapsodie.ezdataflow.workflow.history.title: 'Execution history'
50+
coderhapsodie.ezdataflow.workflow.log.title: 'Execution log'
4951
coderhapsodie.ezdataflow.workflow.list.delete: Delete
5052
coderhapsodie.ezdataflow.workflow.delete: 'Are you sure you want to delete this dataflow schedule?'
5153
coderhapsodie.ezdataflow.workflow.create.success: 'Dataflow schedule successfully added.'

src/Resources/translations/messages.fr.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ coderhapsodie.ezdataflow.history.details.count: 'Nombre d''objets mis à jour'
4040
coderhapsodie.ezdataflow.history.details.options: 'Options de lancement'
4141
coderhapsodie.ezdataflow.history.details.errors: Erreurs
4242
coderhapsodie.ezdataflow.history.details.type: 'Nom du dataflow exécuté'
43+
coderhapsodie.ezdataflow.history.details.log: 'Voir le log'
4344
coderhapsodie.ezdataflow.workflow.repeating.new.title: 'Nouvel programmation d''un dataflow récurrent'
4445
coderhapsodie.ezdataflow.workflow.new.cancel: Annuler
4546
coderhapsodie.ezdataflow.workflow.new.submit: Créer
4647
coderhapsodie.ezdataflow.history.list.empty: 'Aucune exécution pour le moment.'
4748
coderhapsodie.ezdataflow.workflow.list.empty: 'Aucun dataflow n''a été programmé.'
4849
coderhapsodie.ezdataflow.workflow.history.title: 'Historique des exécutions'
50+
coderhapsodie.ezdataflow.workflow.log.title: 'Log de l''exécution'
4951
coderhapsodie.ezdataflow.workflow.list.delete: Supprimer
5052
coderhapsodie.ezdataflow.workflow.delete: 'Êtes-vous sûr de vouloir supprimer ce dataflow ?'
5153
coderhapsodie.ezdataflow.workflow.create.success: 'La programmation du dataflow a bien été ajoutée.'

src/Resources/views/themes/admin/ezdataflow/Dashboard/main.html.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
$('.history-details-aware').delegate('.modal-history-details', 'click', function (e) {
4343
e.preventDefault();
4444
$('#modal_content-details').html('');
45+
$('#ez-modal--history-details h3').html("{{ 'coderhapsodie.ezdataflow.workflow.history.title'|trans }}");
46+
if ($(this).hasClass('modal-history-log')) {
47+
$('#ez-modal--history-details h3').html("{{ 'coderhapsodie.ezdataflow.workflow.log.title'|trans }}");
48+
}
4549
$('#ez-modal--history-details').modal('show');
4650
$.ajax(this.href, {
4751
success: function (result) {

src/Resources/views/themes/admin/ezdataflow/Item/details.html.twig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{% import '@ezdesign/ezdataflow/macros.twig' as macros %}
22

33
{% block content %}
4-
5-
<div class="container ez-main-container">
4+
<div class="container ez-main-container history-details-aware">
65
{% if item is not null %}
76
<h2>{{ 'coderhapsodie.ezdataflow.history.job.title'|trans }} n°{{ item.id }}</h2>
87

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{% for line in log %}
2+
<p>{{ line|nl2br }}</p>
3+
{% endfor %}

src/Resources/views/themes/admin/ezdataflow/parts/tab/job_list.html.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
xlink:href="/bundles/ezplatformadminui/img/ez-icons.svg#about-info"></use>
4242
</svg>
4343
</a>
44+
<a href="{{ path('coderhapsodie.ezdataflow.job.log', {id: job.id}) }}"
45+
class="btn btn-icon mx-2 modal-history-details modal-history-log"
46+
title="{{ 'coderhapsodie.ezdataflow.history.details.log'|trans }}">
47+
<svg class="ez-icon ez-icon--small-medium">
48+
<use xmlns:xlink="http://www.w3.org/1999/xlink"
49+
xlink:href="/bundles/ezplatformadminui/img/ez-icons.svg#article"></use>
50+
</svg>
51+
</a>
4452
</td>
4553
</tr>
4654
{% endfor %}

0 commit comments

Comments
 (0)