Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix API + refactoring #1142

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Http/Controllers/API/ApplicationBlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function store(StoreApplicationBlockRequest $request)
abort_if(Gate::denies('application_block_create'), Response::HTTP_FORBIDDEN, '403 Forbidden');

$applicationblock = ApplicationBlock::create($request->all());
$applicationblock->applications()->sync($request->input('applications', []));

return response()->json($applicationblock, 201);
}
Expand All @@ -43,6 +44,9 @@ public function update(UpdateApplicationBlockRequest $request, ApplicationBlock
abort_if(Gate::denies('application_block_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');

$applicationBlock->update($request->all());

if ($request->has('applications'))
$applicationblock->applications()->sync($request->input('applications', []));

return response()->json();
}
Expand Down
22 changes: 16 additions & 6 deletions app/Http/Controllers/API/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function store(StoreApplicationRequest $request)
$application->processes()->sync($request->input('processes', []));
$application->services()->sync($request->input('services', []));
$application->databases()->sync($request->input('databases', []));
$application->logical_servers()->sync($request->input('logical_servers', []));
$application->logicalServers()->sync($request->input('logical_servers', []));

return response()->json($application, 201);
}
Expand All @@ -47,11 +47,21 @@ public function update(UpdateApplicationRequest $request, MApplication $applicat
abort_if(Gate::denies('m_application_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');

$application->update($request->all());
$application->entities()->sync($request->input('entities', []));
$application->processes()->sync($request->input('processes', []));
$application->services()->sync($request->input('services', []));
$application->databases()->sync($request->input('databases', []));
$application->logical_servers()->sync($request->input('logical_servers', []));

if ($request->has('entities'))
$application->entities()->sync($request->input('entities', []));
if ($request->has('processes'))
$application->processes()->sync($request->input('processes', []));
if ($request->has('activities'))
$application->activities()->sync($request->input('activities', []));
if ($request->has('services'))
$application->services()->sync($request->input('services', []));
if ($request->has('databases'))
$application->databases()->sync($request->input('databases', []));
if ($request->has('logical_servers'))
$application->logicalServers()->sync($request->input('logical_servers', []));
if ($request->has('application_services'))
$application->services()->sync($request->input('application_services', []));

return response()->json();
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Admin/CartographyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,9 @@ public function cartography(Request $request)
}

$textRun = $this->addTextRunRow($table, trans('cruds.application.fields.logical_servers'));
foreach ($application->logical_servers as $logical_server) {
foreach ($application->logicalServers as $logical_server) {
$textRun->addLink('LOGICAL_SERVER'.$logical_server->id, $logical_server->name, CartographyController::FANCYLINKSTYLE, null, true);
if ($application->logical_servers->last() !== $logical_server) {
if ($application->logicalServers->last() !== $logical_server) {
$textRun->addText(', ');
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/Admin/MApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function store(StoreMApplicationRequest $request)
$application->services()->sync($request->input('services', []));
$application->databases()->sync($request->input('databases', []));
$application->cartographers()->sync($request->input('cartographers', []));
$application->logical_servers()->sync($request->input('logical_servers', []));
$application->logicalServers()->sync($request->input('logical_servers', []));

// Attribution du role pour les nouveaux cartographes
$this->cartographerService->attributeCartographerRole($application);
Expand Down Expand Up @@ -318,7 +318,7 @@ public function update(UpdateMApplicationRequest $request, MApplication $applica
$application->services()->sync($request->input('services', []));
$application->databases()->sync($request->input('databases', []));
$application->cartographers()->sync($request->input('cartographers', []));
$application->logical_servers()->sync($request->input('logical_servers', []));
$application->logicalServers()->sync($request->input('logical_servers', []));

// Attribution du role pour les nouveaux cartographes
$this->cartographerService->attributeCartographerRole($application);
Expand All @@ -330,7 +330,7 @@ public function show(MApplication $application)
{
abort_if(Gate::denies('m_application_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');

$application->load('entities', 'entity_resp', 'processes', 'services', 'databases', 'logical_servers', 'application_block', 'applicationSourceFluxes', 'applicationDestFluxes', 'cartographers');
$application->load('entities', 'entity_resp', 'processes', 'services', 'databases', 'logicalServers', 'application_block', 'applicationSourceFluxes', 'applicationDestFluxes', 'cartographers');
// Chargement des évènements
$this->eventService->getLoadAppEvents($application);

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Admin/MApplicationLogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function store(StoreMApplicationRequest $request)
$application->services()->sync($request->input('services', []));
$application->databases()->sync($request->input('databases', []));
$application->cartographers()->sync($request->input('cartographers', []));
$application->logical_servers()->sync($request->input('logical_servers', []));
$application->logicalServers()->sync($request->input('logical_servers', []));

// Attribution du role pour les nouveaux cartographes
$this->cartographerService->attributeCartographerRole($application);
Expand Down Expand Up @@ -147,7 +147,7 @@ public function update(UpdateMApplicationRequest $request, MApplication $applica
$application->services()->sync($request->input('services', []));
$application->databases()->sync($request->input('databases', []));
$application->cartographers()->sync($request->input('cartographers', []));
$application->logical_servers()->sync($request->input('logical_servers', []));
$application->logicalServers()->sync($request->input('logical_servers', []));

// Attribution du role pour les nouveaux cartographes
$this->cartographerService->attributeCartographerRole($application);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Admin/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ public function applicationsByBlocks()
$sheet->setCellValue(self::col($i++) . $row, $application->rpo);

$sheet->setCellValue(self::col($i++) . $row, $application->documentation);
$sheet->setCellValue(self::col($i++) . $row, $application->logical_servers->implode('name', ', '));
$sheet->setCellValue(self::col($i++) . $row, $application->logicalServers->implode('name', ', '));
$res = null;

// Done: request improved
Expand Down
4 changes: 3 additions & 1 deletion app/MApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class MApplication extends Model
'security_need_a',
'security_need_t',
'security_need_auth',
'rto',
'rpo',
'external',
'attributes',
'patching_frequency',
Expand Down Expand Up @@ -144,7 +146,7 @@ public function workstations()
return $this->belongsToMany(Workstation::class)->orderBy('name');
}

public function logical_servers()
public function logicalServers()
{
return $this->belongsToMany(LogicalServer::class)->orderBy('name');
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/applications/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@
{{ trans('cruds.application.fields.logical_servers') }}
</th>
<td>
@foreach($application->logical_servers as $logical_server)
@foreach($application->logicalServers as $logical_server)
<a href='{{ route("admin.logical-servers.show", $logical_server->id) }}'>{{ $logical_server->name }}</a>
@if(!$loop->last)
,
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/reports/applications.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
<tr>
<th>{{ trans("cruds.application.fields.logical_servers_helper") }}</th>
<td>
@foreach($application->logical_servers as $logical_server)
@foreach($application->logicalServers as $logical_server)
<a href="/admin/report/logical_infrastructure#LOGICAL_SERVER{{$logical_server->id}}">{{ $logical_server->name }}</a>
@if(!$loop->last)
,
Expand Down