Skip to content
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 .env.dev.docker
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ PUBLIC_AWS_ACCESS_KEY_ID=null
PUBLIC_AWS_DEFAULT_REGION=null
PUBLIC_AWS_BUCKET=null
PUBLIC_AWS_URL=null
PUBLIC_AWS_ENDPOINT=null
PUBLIC_AWS_PATH_STYLE=null
PUBLIC_AWS_BUCKET_ROOT=null

# --------------------------------------------
Expand All @@ -147,6 +149,8 @@ PRIVATE_AWS_SECRET_ACCESS_KEY=null
PRIVATE_AWS_DEFAULT_REGION=null
PRIVATE_AWS_BUCKET=null
PRIVATE_AWS_URL=null
PRIVATE_AWS_ENDPOINT=null
PRIVATE_AWS_PATH_STYLE=null
PRIVATE_AWS_BUCKET_ROOT=null

# --------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ PUBLIC_AWS_ACCESS_KEY_ID=null
PUBLIC_AWS_DEFAULT_REGION=null
PUBLIC_AWS_BUCKET=null
PUBLIC_AWS_URL=null
PUBLIC_AWS_ENDPOINT=null
PUBLIC_AWS_PATH_STYLE=null
PUBLIC_AWS_BUCKET_ROOT=null

# --------------------------------------------
Expand All @@ -154,6 +156,8 @@ PRIVATE_AWS_SECRET_ACCESS_KEY=null
PRIVATE_AWS_DEFAULT_REGION=null
PRIVATE_AWS_BUCKET=null
PRIVATE_AWS_URL=null
PRIVATE_AWS_ENDPOINT=null
PRIVATE_AWS_PATH_STYLE=null
PRIVATE_AWS_BUCKET_ROOT=null

# --------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ PUBLIC_AWS_ACCESS_KEY_ID=null
PUBLIC_AWS_DEFAULT_REGION=null
PUBLIC_AWS_BUCKET=null
PUBLIC_AWS_URL=null
PUBLIC_AWS_ENDPOINT=null
PUBLIC_AWS_PATH_STYLE=null
PUBLIC_AWS_BUCKET_ROOT=null

# --------------------------------------------
Expand All @@ -153,6 +155,8 @@ PRIVATE_AWS_SECRET_ACCESS_KEY=null
PRIVATE_AWS_DEFAULT_REGION=null
PRIVATE_AWS_BUCKET=null
PRIVATE_AWS_URL=null
PRIVATE_AWS_ENDPOINT=null
PRIVATE_AWS_PATH_STYLE=null
PRIVATE_AWS_BUCKET_ROOT=null

# --------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Api/PredefinedFilterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

class PredefinedFilterController extends Controller
{

protected PredefinedFilterService $service;

public function __construct(PredefinedFilterService $service)
Expand Down Expand Up @@ -125,7 +126,7 @@ public function update(Request $request, int $id): JsonResponse
$validated = $validator->validated();

$updatedPermission = $this->updatePermissions($validated, $filter, $user);
if($updatedPermission !== null) {
if ($updatedPermission !== null) {
return $updatedPermission;
}

Expand Down Expand Up @@ -170,7 +171,7 @@ private function updatePermissions($validated, $filter, $user) {

//create permission
if ((!$currentIsPublic && $newIsPublic)
&& !$filter->userHasPermission($user, 'create')) {
&& !$filter->userHasPermission($user, 'create')) {
return response()->json(['message' => trans('admin/predefinedFilters/message.update.not_allowed_to_change_isPublic')], 403);
}

Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/PredefinedFilterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public function index()


/**
* Show the given Predefined Filter.
*
* @param PredefinedFilter
*/
* Show the given Predefined Filter.
*
* @param PredefinedFilter
*/
public function view(PredefinedFilter $filter) : View|RedirectResponse
{
$user = auth()->user();
Expand All @@ -53,10 +53,10 @@ public function view(PredefinedFilter $filter) : View|RedirectResponse
}

/**
* Delete the given Predefined Filter.
*
* @param int $id
*/
* Delete the given Predefined Filter.
*
* @param int $id
*/
public function destroy($id) : RedirectResponse
{
$user = auth()->user();
Expand Down
2 changes: 2 additions & 0 deletions app/Livewire/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ class Notifications extends Component
*
* @var array<int, array<string,mixed>>
*/

public array $liveAlerts=[];

/**
* Main notification listener.
* We bind both 'showNotification' (your current event) and 'notify' (optional alias).
*/

#[On('showNotification')]
#[On('notify')]
public function notify(
Expand Down
5 changes: 3 additions & 2 deletions app/Livewire/Partials/AdvancedSearch/Modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum AdvancedsearchModalAction: string

class Modal extends Component
{

public $showModal=false;
public AdvancedsearchModalAction $modalActionType;

Expand Down Expand Up @@ -134,7 +135,7 @@ public function savePredefinedFiltersModal(
) {
$this->validate();

if(!$this->validateMaxLenghtForFiltername()) {
if (!$this->validateMaxLenghtForFiltername()) {
return;
}

Expand Down Expand Up @@ -164,7 +165,7 @@ public function savePredefinedFiltersModal(
]);
return;
}
}
} //end if

if ($filter->checkIfNameAlreadyExists($this->name)) {
$this->dispatch('showNotificationInFrontend', [
Expand Down
4 changes: 2 additions & 2 deletions app/Models/PredefinedFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function userHasPermission(User $user, string $action): bool

default:
return false;
} // end switch
} //end switch
}

private function checkPermissions(User $user, $action): bool
Expand Down Expand Up @@ -190,7 +190,7 @@ public function filterAssets(Builder $assets)
return $assets;
}

public function checkIfNameAlreadyExists(string $name, int $id = null): bool
public function checkIfNameAlreadyExists(string $name, int $id=null): bool
{
if ($id === null) {
$query = $this->where('name', '=', $name);
Expand Down
6 changes: 3 additions & 3 deletions app/Presenters/PredefinedFilterPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
class PredefinedFilterPresenter extends Presenter
{
/**
* Json Column Layout for bootstrap table
* @return string
*/
* Json Column Layout for bootstrap table
* @return string
*/

public static function dataTableLayout()
{
Expand Down
18 changes: 9 additions & 9 deletions app/Services/FilterService/FilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function applyMorphRelation($inner, $meta, $value, $operator){
}
}
});
}
} //end foreach
});
}

Expand Down Expand Up @@ -292,18 +292,18 @@ protected function applyAssignedToAsset($inner, $assignedValue, $operator){
// Use a whereExists subquery that selects a real column (b.id) — no DB::raw required.
$inner->where(function ($q) use ($assignedValue, $operator) {
$q->whereNotNull('assets.assigned_to')
->where('assets.assigned_type', Asset::class)
->where('assets.assigned_type', Asset::class)
->whereExists(function ($sub) use ($assignedValue, $operator) {
$sub->from('assets as b')
->select('b.id')
->select('b.id')
->whereColumn('b.id', 'assets.assigned_to')
->where(function ($q2) use ($assignedValue, $operator) {
if ($operator === 'equals') {
$q2->where('b.asset_tag', '=', $assignedValue)
->orWhere('b.name', '=', $assignedValue);
->orWhere('b.name', '=', $assignedValue);
} else {
$q2->where('b.asset_tag', 'LIKE', '%' . $assignedValue . '%')
->orWhere('b.name', 'LIKE', '%' . $assignedValue . '%');
->orWhere('b.name', 'LIKE', '%' . $assignedValue . '%');
}
});
});
Expand Down Expand Up @@ -433,9 +433,9 @@ public function applyDateRangeFilter($query, $qualifiedField, $filters, bool $is
\Carbon\Carbon::parse($start)->startOfDay(),
\Carbon\Carbon::parse($end)->endOfDay(),
]);
} elseif ($start) {
} else if ($start) {
$query->where($qualifiedField, '>=', \Carbon\Carbon::parse($start)->startOfDay());
} elseif ($end) {
} else if ($end) {
$query->where($qualifiedField, '<=', \Carbon\Carbon::parse($end)->endOfDay());
}
} else {
Expand All @@ -444,9 +444,9 @@ public function applyDateRangeFilter($query, $qualifiedField, $filters, bool $is
\Carbon\Carbon::parse($start)->toDateString(),
\Carbon\Carbon::parse($end)->toDateString(),
]);
} elseif ($start) {
} else if ($start) {
$query->whereDate($qualifiedField, '>=', \Carbon\Carbon::parse($start)->toDateString());
} elseif ($end) {
} else if ($end) {
$query->whereDate($qualifiedField, '<=', \Carbon\Carbon::parse($end)->toDateString());
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/Services/PredefinedFilterPermissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function delete(int $id): void
public function deletePermissionByFilterId($filterId): void
{
$permissions = PredefinedFilterPermission::where('predefined_filter_id', '=', $filterId)->get();
foreach($permissions as $permission) {
foreach ($permissions as $permission) {
$permission->delete();
}
}
Expand Down
21 changes: 11 additions & 10 deletions app/Services/PredefinedFilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getFilterWithIdAndNameValues(int $id)
break;
default:
break;
} // end switch
} //end switch

if ($model) {
$values[] = [
Expand All @@ -134,7 +134,7 @@ public function getFilterWithIdAndNameValues(int $id)
];
}
$filter['value'] = $values;
}
} // end foreach

}
}
Expand Down Expand Up @@ -176,18 +176,18 @@ public function updateFilter(PredefinedFilter $filter, array $validated): Predef
if (array_key_exists('permissions', $validated)) {
$currentlySetPermssions = $this->predefinedFilterPermissionService->getPermissionsByPredefinedFilterId($filter->id);
$newPermissions = $validated['permissions'];
$permission_diff = $this->syncPermissions($currentlySetPermssions->toArray(), $newPermissions);
$permissionDiff = $this->syncPermissions($currentlySetPermssions->toArray(), $newPermissions);

try {
DB::transaction(function () use ($permission_diff, $filter) {
if (!empty($permission_diff['to_delete'])) {
foreach ($permission_diff['to_delete'] as $permission) {
DB::transaction(function () use ($permissionDiff, $filter) {
if (!empty($permissionDiff['to_delete'])) {
foreach ($permissionDiff['to_delete'] as $permission) {
$this->predefinedFilterPermissionService->deletePermissionByFilterId($permission['predefined_filter_id']);
}
}

if (!empty($permission_diff['to_add'])) {
foreach ($permission_diff['to_add'] as $permission) {
if (!empty($permissionDiff['to_add'])) {
foreach ($permissionDiff['to_add'] as $permission) {
$permission['predefined_filter_id'] = $filter->id;
$this->predefinedFilterPermissionService->store($permission);
}
Expand All @@ -196,6 +196,7 @@ public function updateFilter(PredefinedFilter $filter, array $validated): Predef
} catch (Throwable $e) {
// If any exception occurs, the transaction is automatically rolled back.
Log::error($e->getMessage());

}
}

Expand All @@ -216,7 +217,7 @@ public function selectList(Request $request, bool $visibilityInName=false): Leng
->get(['id', 'name', 'created_by', 'is_public']);

$viewableFilters = $filters->filter(fn($f) => $f->userHasPermission($user, 'view'))
->pluck('id');
->pluck('id');

$query = PredefinedFilter::select(['id', 'name', 'is_public'])
->whereIn('id', $viewableFilters);
Expand Down Expand Up @@ -250,7 +251,7 @@ protected function applySearchFilter($query, Request $request): void
$query->where('is_public', 0);
$search = preg_replace('/^(PRIVATE:|' . preg_quote($private, '/') . ')/i', '', $search);

} elseif (str_starts_with($upper, 'PUBLIC:') || str_starts_with($upper, $public)) {
} else if (str_starts_with($upper, 'PUBLIC:') || str_starts_with($upper, $public)) {
$query->where('is_public', 1);
$search = preg_replace('/^(PUBLIC:|' . preg_quote($public, '/') . ')/i', '', $search);
}
Expand Down
6 changes: 5 additions & 1 deletion config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
'region' => env('PUBLIC_AWS_DEFAULT_REGION'),
'bucket' => env('PUBLIC_AWS_BUCKET'),
'url' => env('PUBLIC_AWS_URL'),
'endpoint' => env('PUBLIC_AWS_ENDPOINT'),
'use_path_style_endpoint' => env('PUBLIC_AWS_PATH_STYLE'),
'root' => env('PUBLIC_AWS_BUCKET_ROOT'),
'visibility' => 'public'
],
Expand All @@ -78,6 +80,8 @@
'region' => env('PRIVATE_AWS_DEFAULT_REGION'),
'bucket' => env('PRIVATE_AWS_BUCKET'),
'url' => env('PRIVATE_AWS_URL'),
'endpoint' => env('PRIVATE_AWS_ENDPOINT'),
'use_path_style_endpoint' => env('PRIVATE_AWS_PATH_STYLE'),
'root' => env('PRIVATE_AWS_BUCKET_ROOT'),
'visibility' => 'private'
],
Expand Down Expand Up @@ -168,4 +172,4 @@
$config['allowed_upload_extensions_for_validator'] = implode(',', $config['allowed_upload_extensions_array']);
$config['allowed_upload_extensions'] = '.'.implode(', .', $config['allowed_upload_extensions_array']);

return $config;
return $config;
2 changes: 1 addition & 1 deletion database/seeders/PredefinedFilterPermissionSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function run(): void
'created_by' => $user->id,
]);
}
}catch (\Exception $e) {
} catch (\Exception $e) {
Log::debug($e);
}
}
Expand Down
Loading