Skip to content
Snippets Groups Projects
Verified Commit b934beec authored by Damien's avatar Damien
Browse files

FEAT #11266 TIME 2:00 Get indexing informations

parent 3cec5272
No related branches found
No related tags found
No related merge requests found
......@@ -179,6 +179,7 @@ $app->get('/groups/{id}', \Group\controllers\GroupController::class . ':getById'
$app->put('/groups/{id}', \Group\controllers\GroupController::class . ':update');
$app->delete('/groups/{id}', \Group\controllers\GroupController::class . ':delete');
$app->get('/groups/{id}/details', \Group\controllers\GroupController::class . ':getDetailledById');
$app->get('/groups/{id}/indexing', \Group\controllers\GroupController::class . ':getIndexingDetailsById');
$app->put('/groups/{id}/services/{serviceId}', \Group\controllers\GroupController::class . ':updateService');
$app->put('/groups/{id}/reassign/{newGroupId}', \Group\controllers\GroupController::class . ':reassignUsers');
......
......@@ -32,6 +32,12 @@ UPDATE res_attachments SET fulltext_result = 'ERROR' WHERE fulltext_result = '-1
UPDATE res_version_attachments SET fulltext_result = 'SUCCESS' WHERE fulltext_result = '1' OR fulltext_result = '2';
UPDATE res_version_attachments SET fulltext_result = 'ERROR' WHERE fulltext_result = '-1' OR fulltext_result = '-2';
/* GROUPS INDEXING */
ALTER TABLE usergroups DROP COLUMN IF EXISTS can_index;
ALTER TABLE usergroups ADD COLUMN can_index boolean NOT NULL DEFAULT FALSE;
ALTER TABLE usergroups DROP COLUMN IF EXISTS indexation_parameters;
ALTER TABLE usergroups ADD COLUMN indexation_parameters jsonb NOT NULL DEFAULT '{"actions" : {}, "entities" : [], "keywords" : []}';
/* REFACTORING */
ALTER TABLE res_letterbox DROP COLUMN IF EXISTS converter_result;
......
......@@ -2,7 +2,9 @@
namespace Group\controllers;
use Action\models\ActionModel;
use Basket\models\GroupBasketModel;
use Entity\models\EntityModel;
use Group\models\ServiceModel;
use Group\models\GroupModel;
use Respect\Validation\Validator;
......@@ -130,7 +132,7 @@ class GroupController
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
$group = GroupModel::getById(['id' => $aArgs['id']]);
$group = GroupModel::getById(['id' => $aArgs['id'], 'select' => ['id', 'group_id', 'group_desc', 'enabled']]);
if (empty($group)) {
return $response->withStatus(400)->withJson(['errors' => 'Group not found']);
}
......@@ -205,6 +207,51 @@ class GroupController
return $response->withJson(['success' => 'success']);
}
public function getIndexingDetailsById(Request $request, Response $response, array $args)
{
if (!ServiceModel::hasService(['id' => 'admin_groups', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin'])) {
return $response->withStatus(403)->withJson(['errors' => 'Service forbidden']);
}
$group = GroupModel::getById(['id' => $args['id'], 'select' => ['can_index', 'indexation_parameters']]);
if (empty($group)) {
return $response->withStatus(400)->withJson(['errors' => 'Group not found']);
}
$group['indexation_parameters'] = json_decode($group['indexation_parameters'], true);
$allActions = ActionModel::get(['select' => ['id', 'label_action'], 'where' => ['component in (?)'], 'data' => [['confirmAction', 'closeMailAction']]]);
$allEntities = EntityModel::get([
'select' => ['e1.id', 'e1.entity_id', 'e1.entity_label', 'e2.id as parent_id'],
'table' => ['entities e1', 'entities e2'],
'left_join' => ['e1.parent_entity_id = e2.entity_id'],
'where' => ['e1.enabled = ?'],
'data' => ['Y']
]);
foreach ($allEntities as $key => $value) {
$allEntities[$key]['id'] = $value['id'];
if (empty($value['parent_id'])) {
$allEntities[$key]['parent'] = '#';
$allEntities[$key]['icon'] = "fa fa-building";
} else {
$allEntities[$key]['parent'] = $value['parent_id'];
$allEntities[$key]['icon'] = "fa fa-sitemap";
}
$allEntities[$key]['state']['opened'] = false;
$allEntities[$key]['allowed'] = true;
if (in_array($value['id'], $group['indexation_parameters']['entities'])) {
$allEntities[$key]['state']['opened'] = true;
$allEntities[$key]['state']['selected'] = true;
}
$allEntities[$key]['text'] = $value['entity_label'];
}
return $response->withJson(['group' => $group, 'actions' => $allActions, 'entities' => $allEntities]);
}
public static function getGroupsClause(array $aArgs)
{
ValidatorModel::notEmpty($aArgs, ['userId']);
......
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