diff --git a/rest/index.php b/rest/index.php index d921b0c5561a0ef78316f08862ba9b9ea26693ed..1a34cd5a5497ad47313e29b3f77f2f93be1f0861 100755 --- a/rest/index.php +++ b/rest/index.php @@ -253,7 +253,6 @@ $app->get('/groups/{id}/privileges/{privilegeId}/parameters', \Group\controllers $app->get('/history', \History\controllers\HistoryController::class . ':get'); $app->get('/history/availableFilters', \History\controllers\HistoryController::class . ':getAvailableFilters'); $app->get('/history/users/{userSerialId}', \History\controllers\HistoryController::class . ':getByUserId'); -$app->get('/history/resources/{resId}/workflow', \History\controllers\HistoryController::class . ':getWorkflowByResourceId'); //BatchHistory $app->get('/batchHistory', \History\controllers\BatchHistoryController::class . ':get'); diff --git a/src/app/history/controllers/HistoryController.php b/src/app/history/controllers/HistoryController.php index 4877a7c23bd4c5ce9ff780d6d158b1adf84bc21b..7d153d2f0ad85e44248d53120e02a9d6967a070f 100755 --- a/src/app/history/controllers/HistoryController.php +++ b/src/app/history/controllers/HistoryController.php @@ -70,30 +70,30 @@ class HistoryController $users = UserModel::get(['select' => ['user_id'], 'where' => ['id in (?)'], 'data' => [$userIds]]); $users = array_column($users, 'user_id'); } - $users = array_merge($users, $userLogins); + $users = array_merge($users, $userLogins); $where[] = 'user_id in (?)'; - $data[] = $users; + $data[] = $users; } if (!empty($queryParams['startDate'])) { $where[] = 'event_date > ?'; - $data[] = $queryParams['startDate']; + $data[] = $queryParams['startDate']; } if (!empty($queryParams['endDate'])) { $where[] = 'event_date < ?'; - $data[] = $queryParams['endDate']; + $data[] = $queryParams['endDate']; } if (!empty($queryParams['resId'])) { $where[] = 'table_name in (?)'; - $data[] = ['res_letterbox', 'res_view_letterbox']; + $data[] = ['res_letterbox', 'res_view_letterbox']; $where[] = 'record_id = ?'; - $data[] = $queryParams['resId']; + $data[] = $queryParams['resId']; } if (!empty($queryParams['onlyActions'])) { $where[] = 'event_type like ?'; - $data[] = 'ACTION#%'; + $data[] = 'ACTION#%'; } $eventTypes = []; @@ -184,22 +184,6 @@ class HistoryController 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) { $queryParams = $request->getQueryParams(); diff --git a/src/app/history/models/HistoryModelAbstract.php b/src/app/history/models/HistoryModelAbstract.php index ad5806de4cd9f698ec87d145e66e69dc1ca6fd51..1013ee8f7e68537420396dd7a0162ce7e717d19b 100755 --- a/src/app/history/models/HistoryModelAbstract.php +++ b/src/app/history/models/HistoryModelAbstract.php @@ -77,22 +77,4 @@ abstract class HistoryModelAbstract 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; - } } diff --git a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html index fa8f592bcb224301c6ff8f9930874ae6cbf1248e..57a006dc7b546b8d851bcdc2434ed7558f9150aa 100644 --- a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html +++ b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.html @@ -10,7 +10,10 @@ {{history.event_date | timeAgo}} </div> <div class="info"> - {{history.info}} + {{history.info | shorten: 110: '...'}} + </div> + <div class="date"> + {{history.userLabel}} </div> </div> <button mat-button *ngIf="histories.length === 3" class="showMore" diff --git a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss index 99a77e53d899bb413657e0d1a6ce385f0e836441..3e3388a2b5c6b794434cc74eac138cc020bb62cf 100644 --- a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss +++ b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.scss @@ -4,7 +4,7 @@ font-size: 13px; width: 100%; display: grid; - grid-template-columns: 15% 85%; + grid-template-columns: 15% 70% 15%; align-items: center; &:nth-child(2n) { diff --git a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts index 9d785d0ebf3cbe58a86f0de040c4b21c920fe612..9f933bc97610dd38898e9576aa3c973b73dd46f1 100644 --- a/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts +++ b/src/frontend/app/history/history-workflow-resume/history-workflow-resume.component.ts @@ -46,7 +46,7 @@ export class HistoryWorkflowResumeComponent implements OnInit { loadHistory(resId: number) { 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) => { this.histories = data.history; }),