Skip to content

Commit

Permalink
#10 - wip - crud - for report dataview json_runtime_configuration, js…
Browse files Browse the repository at this point in the history
…_modules.
  • Loading branch information
spo committed Oct 25, 2024
1 parent 3b8d91b commit e9a1787
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions app/Http/Controllers/ReportDataViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ public function updateQuery(Request $request, ReportDataView $reportDataView): J
return $this->successResponse(new ReportDataViewResource($reportDataView), 'The data view has been updated.');
}

public function updateJsonRuntimeConfiguration(Request $request, ReportDataView $reportDataView): JsonResponse
{
$this->genericAuthorize($request, $reportDataView, true, 'update');

$reportDataView->update(['json_runtime_configuration' => $request->get('json_runtime_configuration')]);

// $this->_reportUpdate($reportDataView);

return $this->successResponse(new ReportDataViewResource($reportDataView), 'The data view has been updated.');
}

public function run(ReportDataView $reportDataView, ConnectorService $connectorService, Request $request): JsonResponse
{
$this->genericAuthorize($request, $reportDataView, true, 'index');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/ReportDataView.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ReportDataView extends JsonResource
public function toArray($request): array
{
$loggedUserHasRoleDev = User::searchIfLoggedUserHasUiRoleGrant(RoleGrants::PERMISSION_EDIT, RoleGrants::RESOURCE_REPORT_DATA_VIEW);
$json_runtime_configuration = (!$loggedUserHasRoleDev && !is_null($this->js_runtime_configuration)) ? base64_encode(gzcompress(Minifier::minify($this->js_init))) : $this->js_init;
$json_runtime_configuration = (!$loggedUserHasRoleDev && !is_null($this->json_runtime_configuration)) ? base64_encode(gzcompress(Minifier::minify($this->json_runtime_configuration))) : $this->json_runtime_configuration;

return [
'id' => $this->id,
Expand Down
1 change: 0 additions & 1 deletion app/Models/ReportDataView.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Carbon;
Expand Down
9 changes: 9 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,15 @@
->name('report-data-view.query')
->middleware('auth:sanctum');

Route::apiResource('report-data-view', App\Http\Controllers\ReportDataViewController::class)->middleware('auth:sanctum');
Route::put('/report-data-view/{report_data_view}/json-runtime-configuration', 'App\Http\Controllers\ReportDataViewController@updateJsonRuntimeConfiguration')
->name('report-data-view.json-runtime-configuration')
->middleware('auth:sanctum');

Route::put('/report-data-view/{report_data_view}/js-module-import', 'App\Http\Controllers\ReportDataViewController@updateQuery')
->name('report-data-view.query')
->middleware('auth:sanctum');

Route::post('report-data-view/{report_data_view}/run', 'App\Http\Controllers\ReportDataViewController@run')
->name('report-data-view.run')
->middleware('auth:sanctum');
Expand Down

0 comments on commit e9a1787

Please sign in to comment.