Skip to content
Snippets Groups Projects
Verified Commit 5872ebeb authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #12091 TIME 0:30 display userLabel in history resume

parent d8d7c256
No related branches found
No related tags found
No related merge requests found
...@@ -253,7 +253,6 @@ $app->get('/groups/{id}/privileges/{privilegeId}/parameters', \Group\controllers ...@@ -253,7 +253,6 @@ $app->get('/groups/{id}/privileges/{privilegeId}/parameters', \Group\controllers
$app->get('/history', \History\controllers\HistoryController::class . ':get'); $app->get('/history', \History\controllers\HistoryController::class . ':get');
$app->get('/history/availableFilters', \History\controllers\HistoryController::class . ':getAvailableFilters'); $app->get('/history/availableFilters', \History\controllers\HistoryController::class . ':getAvailableFilters');
$app->get('/history/users/{userSerialId}', \History\controllers\HistoryController::class . ':getByUserId'); $app->get('/history/users/{userSerialId}', \History\controllers\HistoryController::class . ':getByUserId');
$app->get('/history/resources/{resId}/workflow', \History\controllers\HistoryController::class . ':getWorkflowByResourceId');
//BatchHistory //BatchHistory
$app->get('/batchHistory', \History\controllers\BatchHistoryController::class . ':get'); $app->get('/batchHistory', \History\controllers\BatchHistoryController::class . ':get');
......
...@@ -70,30 +70,30 @@ class HistoryController ...@@ -70,30 +70,30 @@ class HistoryController
$users = UserModel::get(['select' => ['user_id'], 'where' => ['id in (?)'], 'data' => [$userIds]]); $users = UserModel::get(['select' => ['user_id'], 'where' => ['id in (?)'], 'data' => [$userIds]]);
$users = array_column($users, 'user_id'); $users = array_column($users, 'user_id');
} }
$users = array_merge($users, $userLogins); $users = array_merge($users, $userLogins);
$where[] = 'user_id in (?)'; $where[] = 'user_id in (?)';
$data[] = $users; $data[] = $users;
} }
if (!empty($queryParams['startDate'])) { if (!empty($queryParams['startDate'])) {
$where[] = 'event_date > ?'; $where[] = 'event_date > ?';
$data[] = $queryParams['startDate']; $data[] = $queryParams['startDate'];
} }
if (!empty($queryParams['endDate'])) { if (!empty($queryParams['endDate'])) {
$where[] = 'event_date < ?'; $where[] = 'event_date < ?';
$data[] = $queryParams['endDate']; $data[] = $queryParams['endDate'];
} }
if (!empty($queryParams['resId'])) { if (!empty($queryParams['resId'])) {
$where[] = 'table_name in (?)'; $where[] = 'table_name in (?)';
$data[] = ['res_letterbox', 'res_view_letterbox']; $data[] = ['res_letterbox', 'res_view_letterbox'];
$where[] = 'record_id = ?'; $where[] = 'record_id = ?';
$data[] = $queryParams['resId']; $data[] = $queryParams['resId'];
} }
if (!empty($queryParams['onlyActions'])) { if (!empty($queryParams['onlyActions'])) {
$where[] = 'event_type like ?'; $where[] = 'event_type like ?';
$data[] = 'ACTION#%'; $data[] = 'ACTION#%';
} }
$eventTypes = []; $eventTypes = [];
...@@ -184,22 +184,6 @@ class HistoryController ...@@ -184,22 +184,6 @@ class HistoryController
return $response->withJson(['histories' => $aHistories]); return $response->withJson(['histories' => $aHistories]);
} }
public function getWorkflowByResourceId(Request $request, Response $response, array $args)
{
if (!Validator::intVal()->validate($args['resId']) || !ResController::hasRightByResId(['resId' => [$args['resId']], 'userId' => $GLOBALS['id']])) {
return $response->withStatus(403)->withJson(['errors' => 'Document out of perimeter']);
}
$queryParams = $request->getQueryParams();
if (!empty($queryParams['limit']) && !Validator::intVal()->validate($queryParams['limit'])) {
return $response->withStatus(403)->withJson(['errors' => 'Query limit is not an int val']);
}
$history = HistoryModel::getWorkflowByResourceId(['resId' => $args['resId'], 'select' => ['info', 'event_date'], 'limit' => (int)$queryParams['limit']]);
return $response->withJson(['history' => $history]);
}
public function getAvailableFilters(Request $request, Response $response) public function getAvailableFilters(Request $request, Response $response)
{ {
$queryParams = $request->getQueryParams(); $queryParams = $request->getQueryParams();
......
...@@ -77,22 +77,4 @@ abstract class HistoryModelAbstract ...@@ -77,22 +77,4 @@ abstract class HistoryModelAbstract
return $aHistories; return $aHistories;
} }
public static function getWorkflowByResourceId(array $args)
{
ValidatorModel::notEmpty($args, ['resId']);
ValidatorModel::stringType($args, ['resId']);
ValidatorModel::intVal($args, ['limit']);
$history = DatabaseModel::select([
'select' => empty($args['select']) ? ['*'] : $args['select'],
'table' => ['history, users'],
'where' => ['table_name in (?)', 'record_id = ?', 'event_id NOT LIKE ?', 'event_type LIKE ?', 'history.user_id = users.user_id'],
'data' => [['res_letterbox', 'res_view_letterbox'], $args['resId'], '^[0-9]+$', 'ACTION#%'],
'order_by' => ['event_date DESC'],
'limit' => empty($args['limit']) ? 500 : $args['limit']
]);
return $history;
}
} }
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
{{history.event_date | timeAgo}} {{history.event_date | timeAgo}}
</div> </div>
<div class="info"> <div class="info">
{{history.info}} {{history.info | shorten: 110: '...'}}
</div>
<div class="date">
{{history.userLabel}}
</div> </div>
</div> </div>
<button mat-button *ngIf="histories.length === 3" class="showMore" <button mat-button *ngIf="histories.length === 3" class="showMore"
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
font-size: 13px; font-size: 13px;
width: 100%; width: 100%;
display: grid; display: grid;
grid-template-columns: 15% 85%; grid-template-columns: 15% 70% 15%;
align-items: center; align-items: center;
&:nth-child(2n) { &:nth-child(2n) {
......
...@@ -46,7 +46,7 @@ export class HistoryWorkflowResumeComponent implements OnInit { ...@@ -46,7 +46,7 @@ export class HistoryWorkflowResumeComponent implements OnInit {
loadHistory(resId: number) { loadHistory(resId: number) {
this.loading = true; this.loading = true;
this.http.get(`../../rest/history/resources/${resId}/workflow?limit=3`).pipe( this.http.get(`../../rest/history?resId=${resId}&limit=3&onlyActions=true`).pipe(
tap((data: any) => { tap((data: any) => {
this.histories = data.history; this.histories = data.history;
}), }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment