Skip to content

Commit

Permalink
frontend, api: Link to correct folder in dashboard events
Browse files Browse the repository at this point in the history
  • Loading branch information
pschlan committed Oct 26, 2023
1 parent 80e6808 commit 7c56517
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
24 changes: 18 additions & 6 deletions api/apimethods/GetDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,31 @@ public function validateRequest($request) {
}

public function execute($request, $sessionToken, $language) {
$jobs = (new JobManager($sessionToken))->getJobs();
if (!$jobs) {
throw new InternalErrorAPIException();
}

$jobIdToFolderId = [];
foreach ($jobs->jobs as $job) {
$jobIdToFolderId[$job->jobId] = $job->folderId;
}

$events = (new HistoryManager($sessionToken))->getUserEvents();
$events = array_map(function ($item) {
$events = array_map(function ($item) use ($jobIdToFolderId) {
$event = new stdClass;
$event->type = get_class($item);
$event->details = $item;

if ($event->type === 'HistoryItem') {
$event->details->jobFolderId = isset($jobIdToFolderId[$item->jobId])
? $jobIdToFolderId[$item->jobId]
: 0;
}

return $event;
}, $events);

$jobs = (new JobManager($sessionToken))->getJobs();
if (!$jobs) {
throw new InternalErrorAPIException();
}

$userProfile = (new UserManager($sessionToken))->getProfile();

$result = (object)[
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default function Dashboard() {
size='small'
startIcon={<DetailsIcon />}
className={classes.actionButton}
onClick={() => history.push('/jobs/' + event.details.jobId + '/history')}
onClick={() => history.push('/jobs' + (event.details.jobFolderId === 0 ? '' : '/folders/' + event.details.jobFolderId) + '/' + event.details.jobId + '/history')}
>
{t('common.details')}
</Button>
Expand Down

0 comments on commit 7c56517

Please sign in to comment.