Skip to content

Commit 38ddeb9

Browse files
authored
Merge pull request #33 from itk-dev/feature/5708-rerun-popover
Popover
2 parents b45fba8 + d611650 commit 38ddeb9

File tree

16 files changed

+317
-16
lines changed

16 files changed

+317
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
* [PR-33](https://github.com/itk-dev/rpa-process-overview/pull/33)
11+
* Add popover with more info and rerun option
1012
* [PR-31](https://github.com/itk-dev/rpa-process-overview/pull/31)
1113
* Used Mysql database.
1214
* Cleaned up entities.

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
- [x] Add light mode
88
- [x] Localizable texts in svelte
99
- [x] Proper error handling
10+
- [x] Add successful state when sure what api returns on rerun

scripts/api/fixtures.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,27 @@ def create_data(self, seed: int = 19750523) -> None:
9393
started_at = started_at + timedelta(seconds=fake.pyint(1, 1000))
9494
finished_at = started_at + timedelta(seconds=fake.pyint(3, 42))
9595
failure = None
96+
is_rerunnable = False
9697
if index == failed_step_index:
98+
is_rerunnable = fake.boolean()
9799
status = StepRunStatus.FAILED
98100
occurred_at = (finished_at - timedelta(seconds=-fake.pyint(0, 3))).isoformat()
99101
finished_at = None
100102
failure = {
101103
"code": fake.pyint(1, 7),
102104
"message": fake.sentence(),
103-
"retryable": fake.boolean(),
105+
"retryable": is_rerunnable,
104106
"occurred_at": occurred_at,
105107
}
106108
step_run = ProcessStepRun(
107109
status=status,
108110
started_at=started_at if status != StepRunStatus.PENDING else None,
109111
finished_at=finished_at if status != StepRunStatus.PENDING else None,
110112
process=process,
113+
can_rerun=is_rerunnable if status == StepRunStatus.FAILED else False,
111114
run=run,
112115
step=steps[index],
113-
# An event listener show set this.
116+
# An event listener should set this.
114117
step_index=index,
115118
failure=failure,
116119
)

src/Controller/ProcessOverviewController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public function show(ProcessOverviewGroup $group, ProcessOverview $overview): Re
4040
'Go to next page' => t('Go to next page'),
4141
'Missing data' => t('Missing data'),
4242
'Failed processes' => t('Failed processes'),
43+
'The process was restarted' => t('The process was restarted'),
44+
'An error occurred when the process was restarted' => t('An error occurred when the process was restarted'),
45+
'Rerun step' => t('Rerun step'),
46+
'Finished at' => t('Finished at'),
47+
'Failed at' => t('Failed at'),
48+
'Error code' => t('Error code'),
4349
'Loading data...' => t('Loading data...'),
4450
'of' => t('of'),
4551
'An error occurred while fetching the data' => t('An error occurred while fetching the data'),
@@ -77,6 +83,14 @@ public function getRawRunFieldValue(Request $request, ProcessOverview $overview,
7783
return new JsonResponse($data);
7884
}
7985

86+
#[Route('/{overview}/runs/{run}/rerun', name: 'rerun', methods: [Request::METHOD_POST])]
87+
public function rerun(Request $request, ProcessOverview $overview, string $run, ProcessOverviewHelper $helper): Response
88+
{
89+
$data = $helper->rerun($request, $overview, $run);
90+
91+
return new JsonResponse($data);
92+
}
93+
8094
#[Route('/{overview}/search', name: 'search')]
8195
public function search(Request $request, ProcessOverview $overview, ProcessOverviewHelper $helper): Response
8296
{

src/DataSourceHelper.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public function getProcessRun(DataSource $dataSource, string $processId, string
3636
return $this->get($dataSource, 'runs/'.$runId);
3737
}
3838

39+
public function rerun(DataSource $dataSource, string $runId): array
40+
{
41+
return $this->post($dataSource, 'step-runs/'.$runId.'/rerun');
42+
}
43+
3944
private function get(DataSource $dataSource, string $path, array $query = []): array
4045
{
4146
$url = $this->buildUrl($dataSource, $path, $query);
@@ -45,6 +50,15 @@ private function get(DataSource $dataSource, string $path, array $query = []): a
4550
return $response->toArray();
4651
}
4752

53+
private function post(DataSource $dataSource, string $path, array $query = []): array
54+
{
55+
$url = $this->buildUrl($dataSource, $path, $query);
56+
$options = $this->buildOptions($dataSource);
57+
$response = $this->httpClient->request(Request::METHOD_POST, $url, $options);
58+
59+
return $response->toArray();
60+
}
61+
4862
private function buildUrl(DataSource $dataSource, string $path, array $query): string
4963
{
5064
$url = $dataSource->getUrl();

src/ProcessOverviewHelper.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,20 @@ function (array $col) use ($overview, $item) {
8686
},
8787
$metadataColumns
8888
),
89-
array_map(static fn (array $step) => $step + ['type' => 'step'], $steps),
89+
array_map(
90+
function (array $step) use ($overview) {
91+
return $step + [
92+
'type' => 'step',
93+
'rerun_url' => $step['can_rerun'] ? $this->urlGenerator->generate('process_overview_rerun',
94+
[
95+
'group' => $overview->getGroup()->getId(),
96+
'overview' => $overview->getId(),
97+
'run' => $step['id'],
98+
], UrlGeneratorInterface::ABSOLUTE_URL) : null,
99+
];
100+
},
101+
$steps
102+
),
90103
);
91104
}
92105

@@ -124,6 +137,7 @@ public function getRawRunFieldValue(Request $request, ProcessOverview $overview,
124137
{
125138
$datasource = $overview->getDataSource();
126139
$processId = $overview->getProcessId();
140+
127141
if (empty($datasource) || empty($processId)) {
128142
return [];
129143
}
@@ -136,6 +150,17 @@ public function getRawRunFieldValue(Request $request, ProcessOverview $overview,
136150
];
137151
}
138152

153+
public function rerun(Request $request, ProcessOverview $overview, string $run)
154+
{
155+
$datasource = $overview->getDataSource();
156+
$processId = $overview->getProcessId();
157+
if (empty($datasource) || empty($processId)) {
158+
return [];
159+
}
160+
161+
return $this->dataSourceHelper->rerun($datasource, $run);
162+
}
163+
139164
private function getArrayValue(array $array, string $key): mixed
140165
{
141166
$propertyPath = '['.str_replace('.', '][', $key).']';

widgets/package-lock.json

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

widgets/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
"svelte-standalone": "^2.2.0",
2525
"typescript": "^5.0.0",
2626
"vite": "^7.0.4"
27+
},
28+
"dependencies": {
29+
"dayjs": "^1.11.18"
2730
}
2831
}

widgets/src/_standalone/ProcessOverview/Pagination.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</script>
3232

3333
<div
34-
class="flex items-center overflow-y-scroll justify-between border-t border-neutral-400 dark:border-neutral-700 px-4 py-3"
34+
class="flex items-center justify-between border-t border-neutral-400 dark:border-neutral-700 px-4 py-3"
3535
>
3636
<div class="min-w-[200px] flex items-center text-sm dark:text-gray-300">
3737
<!-- Todo find a way to handle placeholders -->

widgets/src/_standalone/ProcessOverview/index.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<h2 class="text-neutral-900 dark:text-white my-3 mb-5">{t('Missing data')}</h2>
7272
{:else}
7373
<div
74-
class="flex flex-col overflow-scroll border bg-gray-100 dark:bg-gray-900 border-neutral-300 dark:border-neutral-800 rounded-md mb-5"
74+
class="flex flex-col border bg-gray-100 dark:bg-gray-900 border-neutral-300 dark:border-neutral-800 rounded-md mb-5"
7575
>
7676
<div
7777
class="p-3 dark:text-white font-medium bg-gray-200 dark:bg-gray-800 flex items-center border-b border-neutral-300 dark:border-neutral-800"

0 commit comments

Comments
 (0)