From 3f2c58ffd2cdb4e8c670167e54ce8560ab08927a Mon Sep 17 00:00:00 2001 From: recursivetree <60423027+recursivetree@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:28:35 +0200 Subject: [PATCH] styleci --- src/Config/web.characterfilter.php | 22 ++++++- src/Events/CharacterFilterDataUpdate.php | 24 +++++++- src/Http/Composers/CharacterFilter.php | 27 +++++++-- .../Configuration/ScheduleController.php | 10 ++-- .../CharacterFilterDataUpdatedSquads.php | 22 ++++++- .../CharacterFilterDataUpdatedTokens.php | 22 ++++++- src/Models/CharacterSchedulingRule.php | 12 ++-- .../AbstractCharacterFilterObserver.php | 1 - .../CharacterAffiliationObserver.php | 2 +- src/Observers/CharacterAssetObserver.php | 2 +- src/Observers/CharacterRoleObserver.php | 2 +- src/Observers/CharacterSkillObserver.php | 2 +- src/Observers/CharacterTitleObserver.php | 2 +- src/Observers/RefreshTokenObserver.php | 2 +- src/WebServiceProvider.php | 2 +- ...reate_character_scheduling_rules_table.php | 30 ++++++++-- src/resources/lang/en/seat.php | 3 +- .../configuration/schedule/view.blade.php | 57 ++++++++++--------- 18 files changed, 182 insertions(+), 62 deletions(-) diff --git a/src/Config/web.characterfilter.php b/src/Config/web.characterfilter.php index 74a0aa578..f1e3dbf9b 100644 --- a/src/Config/web.characterfilter.php +++ b/src/Config/web.characterfilter.php @@ -1,5 +1,25 @@ 'scopes', 'src' => 'seatcore::fastlookup.scopes', 'path' => 'refresh_token', 'field' => 'scopes', 'label' => 'Scopes'], ['name' => 'character', 'src' => 'seatcore::fastlookup.characters', 'path' => '', 'field' => 'character_id', 'label' => 'Character'], @@ -10,4 +30,4 @@ ['name' => 'skill_level', 'src' => [['id' => 1, 'text' => 'Level 1'], ['id' => 2, 'text' => 'Level 2'], ['id' => 3, 'text' => 'Level 3'], ['id' => 4, 'text' => 'Level 4'], ['id' => 5, 'text' => 'Level 5']], 'path' => 'skills', 'field' => 'trained_skill_level', 'label' => 'Skill Level'], ['name' => 'type', 'src' => 'seatcore::fastlookup.items', 'path' => 'assets', 'field' => 'type_id', 'label' => 'Item'], ['name' => 'role', 'src' => 'seatcore::fastlookup.roles', 'path' => 'corporation_roles', 'field' => 'role', 'label' => 'Role'], -]; \ No newline at end of file +]; diff --git a/src/Events/CharacterFilterDataUpdate.php b/src/Events/CharacterFilterDataUpdate.php index eadacb7b8..415b4ec23 100644 --- a/src/Events/CharacterFilterDataUpdate.php +++ b/src/Events/CharacterFilterDataUpdate.php @@ -1,5 +1,25 @@ character = $character; } -} \ No newline at end of file +} diff --git a/src/Http/Composers/CharacterFilter.php b/src/Http/Composers/CharacterFilter.php index 22c6b32cd..46d1a55aa 100644 --- a/src/Http/Composers/CharacterFilter.php +++ b/src/Http/Composers/CharacterFilter.php @@ -1,7 +1,26 @@ with("characterFilterRules", $newrules); + $view->with('characterFilterRules', $newrules); } -} \ No newline at end of file +} diff --git a/src/Http/Controllers/Configuration/ScheduleController.php b/src/Http/Controllers/Configuration/ScheduleController.php index 304b74ac4..64a9eb6b1 100644 --- a/src/Http/Controllers/Configuration/ScheduleController.php +++ b/src/Http/Controllers/Configuration/ScheduleController.php @@ -96,7 +96,7 @@ public function createSchedulingRule(Request $request) 'filters' => 'required|json', 'name' => 'required|string', 'time' => 'required|numeric', - 'timeunit' => 'required|in:hour,day,week' + 'timeunit' => 'required|in:hour,day,week', ]); // $time_modifier: conversion factor from timeunit to seconds @@ -118,7 +118,7 @@ public function createSchedulingRule(Request $request) $rule->filter = $request->filters; $rule->save(); - RefreshToken::all()->each(function ($token){ + RefreshToken::all()->each(function ($token) { CharacterSchedulingRule::updateRefreshTokenSchedule($token); }); @@ -129,15 +129,15 @@ public function createSchedulingRule(Request $request) public function deleteSchedulingRule(Request $request) { $request->validate([ - 'rule_id' => 'required|numeric' + 'rule_id' => 'required|numeric', ]); CharacterSchedulingRule::destroy($request->rule_id); - RefreshToken::all()->each(function ($token){ + RefreshToken::all()->each(function ($token) { CharacterSchedulingRule::updateRefreshTokenSchedule($token); }); - return redirect()->back()->with('success','Successfully removed character scheduling rule!'); + return redirect()->back()->with('success', 'Successfully removed character scheduling rule!'); } } diff --git a/src/Listeners/CharacterFilterDataUpdatedSquads.php b/src/Listeners/CharacterFilterDataUpdatedSquads.php index 55d41e8c2..82d810e62 100644 --- a/src/Listeners/CharacterFilterDataUpdatedSquads.php +++ b/src/Listeners/CharacterFilterDataUpdatedSquads.php @@ -1,5 +1,25 @@ members()->save($user); }); } -} \ No newline at end of file +} diff --git a/src/Listeners/CharacterFilterDataUpdatedTokens.php b/src/Listeners/CharacterFilterDataUpdatedTokens.php index e27695e86..0dfee262f 100644 --- a/src/Listeners/CharacterFilterDataUpdatedTokens.php +++ b/src/Listeners/CharacterFilterDataUpdatedTokens.php @@ -1,5 +1,25 @@ character->refresh_token); } -} \ No newline at end of file +} diff --git a/src/Models/CharacterSchedulingRule.php b/src/Models/CharacterSchedulingRule.php index 7adafcc62..4f5fbe6f2 100644 --- a/src/Models/CharacterSchedulingRule.php +++ b/src/Models/CharacterSchedulingRule.php @@ -53,9 +53,9 @@ public function getFilters(): stdClass } /** - * Recomputes the update interval of a character and saves it in the refresh_token_schedules table + * Recomputes the update interval of a character and saves it in the refresh_token_schedules table. * - * @param RefreshToken $token + * @param RefreshToken $token * @return void */ public static function updateRefreshTokenSchedule(RefreshToken $token): void @@ -66,9 +66,9 @@ public static function updateRefreshTokenSchedule(RefreshToken $token): void } /** - * Computes the scheduling interval from the character scheduling rules for a character + * Computes the scheduling interval from the character scheduling rules for a character. * - * @param CharacterInfo $character + * @param CharacterInfo $character * @return int */ private static function getCharacterSchedulingInterval(CharacterInfo $character): int @@ -81,6 +81,6 @@ private static function getCharacterSchedulingInterval(CharacterInfo $character) } } - return 60*60; // 1 hour + return 60 * 60; // 1 hour } -} \ No newline at end of file +} diff --git a/src/Observers/AbstractCharacterFilterObserver.php b/src/Observers/AbstractCharacterFilterObserver.php index 1435e4cae..c4b16cfad 100644 --- a/src/Observers/AbstractCharacterFilterObserver.php +++ b/src/Observers/AbstractCharacterFilterObserver.php @@ -26,7 +26,6 @@ use Seat\Eveapi\Models\Character\CharacterInfo; use Seat\Web\Events\CharacterFilterDataUpdate; use Seat\Web\Exceptions\InvalidFilterException; -use Seat\Web\Models\Squads\Squad; use Seat\Web\Models\User; /** diff --git a/src/Observers/CharacterAffiliationObserver.php b/src/Observers/CharacterAffiliationObserver.php index 5586b52e6..116179fa5 100644 --- a/src/Observers/CharacterAffiliationObserver.php +++ b/src/Observers/CharacterAffiliationObserver.php @@ -53,7 +53,7 @@ public function updated(CharacterAffiliation $affiliation) /** * Return the User owning the model which fired the catch event. * - * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event + * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event * @return ?CharacterInfo The character that is affected by this update */ protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo diff --git a/src/Observers/CharacterAssetObserver.php b/src/Observers/CharacterAssetObserver.php index 1e5629bdf..67f2b9f15 100644 --- a/src/Observers/CharacterAssetObserver.php +++ b/src/Observers/CharacterAssetObserver.php @@ -61,7 +61,7 @@ public function deleted(CharacterAsset $asset) /** * Return the User owning the model which fired the catch event. * - * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event + * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event * @return ?CharacterInfo The character that is affected by this update */ protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo diff --git a/src/Observers/CharacterRoleObserver.php b/src/Observers/CharacterRoleObserver.php index 7b64f2c9f..688f6f9b1 100644 --- a/src/Observers/CharacterRoleObserver.php +++ b/src/Observers/CharacterRoleObserver.php @@ -82,7 +82,7 @@ public function deleted(CharacterRole $role) /** * Return the User owning the model which fired the catch event. * - * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event + * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event * @return ?CharacterInfo The character that is affected by this update */ protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo diff --git a/src/Observers/CharacterSkillObserver.php b/src/Observers/CharacterSkillObserver.php index 2ac2ad3a4..f3c7e1820 100644 --- a/src/Observers/CharacterSkillObserver.php +++ b/src/Observers/CharacterSkillObserver.php @@ -74,7 +74,7 @@ protected function findRelatedUser(Model $fired_model): ?User /** * Return the User owning the model which fired the catch event. * - * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event + * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event * @return ?CharacterInfo The character that is affected by this update */ protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo diff --git a/src/Observers/CharacterTitleObserver.php b/src/Observers/CharacterTitleObserver.php index e3a07fb74..d01b033fd 100644 --- a/src/Observers/CharacterTitleObserver.php +++ b/src/Observers/CharacterTitleObserver.php @@ -61,7 +61,7 @@ public function deleted(CharacterTitle $title) /** * Return the User owning the model which fired the catch event. * - * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event + * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event * @return ?CharacterInfo The character that is affected by this update */ protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo diff --git a/src/Observers/RefreshTokenObserver.php b/src/Observers/RefreshTokenObserver.php index a32b1aa14..901e91bef 100644 --- a/src/Observers/RefreshTokenObserver.php +++ b/src/Observers/RefreshTokenObserver.php @@ -103,7 +103,7 @@ public function restored(RefreshToken $token) /** * Return the User owning the model which fired the catch event. * - * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event + * @param \Illuminate\Database\Eloquent\Model $fired_model The model which fired the catch event * @return ?CharacterInfo The character that is affected by this update */ protected function findRelatedCharacter(Model $fired_model): ?CharacterInfo diff --git a/src/WebServiceProvider.php b/src/WebServiceProvider.php index 18159406f..e503a832e 100644 --- a/src/WebServiceProvider.php +++ b/src/WebServiceProvider.php @@ -252,7 +252,7 @@ private function add_view_composers() $this->app['view']->composer([ 'web::squads.edit', 'web::squads.create', - 'web::configuration.schedule.view' + 'web::configuration.schedule.view', ], CharacterFilter::class); } diff --git a/src/database/migrations/2024_08_15_create_character_scheduling_rules_table.php b/src/database/migrations/2024_08_15_create_character_scheduling_rules_table.php index 574d101f7..37d3b6403 100644 --- a/src/database/migrations/2024_08_15_create_character_scheduling_rules_table.php +++ b/src/database/migrations/2024_08_15_create_character_scheduling_rules_table.php @@ -1,6 +1,26 @@ bigIncrements('id'); - $table->string("name"); - $table->integer("interval")->unsigned(); - $table->json("filter"); + $table->string('name'); + $table->integer('interval')->unsigned(); + $table->json('filter'); }); } @@ -29,4 +49,4 @@ public function down() { Schema::drop('character_scheduling_rules'); } -}; \ No newline at end of file +}; diff --git a/src/resources/lang/en/seat.php b/src/resources/lang/en/seat.php index e76a4c8a7..3987b986e 100644 --- a/src/resources/lang/en/seat.php +++ b/src/resources/lang/en/seat.php @@ -380,7 +380,7 @@ 'scheduled_commands' => 'Scheduled Commands', 'choose_prepop' => 'Choose a pre-populated cron expression, or write your own.', 'add_scheduled' => 'Add Scheduled Command', - 'character_scheduling_rule'=>'character scheduling rule', + 'character_scheduling_rule' => 'character scheduling rule', 'character_scheduling_rules' => 'Character Scheduling Rules', 'new_character_scheduling_rule' => 'New Character Scheduling Rule', 'update_interval' => 'Update Interval', @@ -388,7 +388,6 @@ 'character_scheduling_rules_empty' => 'There are no character scheduling rules defined, using a default of one hour for everyone.', 'character_scheduling_rules_default' => 'When no rules apply to a character, an update interval of one hour is used.', - // Security 'category' => 'Category', 'message' => 'Message', diff --git a/src/resources/views/configuration/schedule/view.blade.php b/src/resources/views/configuration/schedule/view.blade.php index ed363f57f..01724c804 100644 --- a/src/resources/views/configuration/schedule/view.blade.php +++ b/src/resources/views/configuration/schedule/view.blade.php @@ -162,7 +162,7 @@ class="btn btn-danger btn-sm confirmlink"> @include('web::components.filters.buttons.filters', ['rules' => [], 'buttonText'=>'Configure Character Filter']) - + - -
- @csrf - - -
- - - @endforeach - - - - @if($scheduling_rules->isEmpty()) - {{trans('web::seat.character_scheduling_rules_empty')}} - @endif - - + @foreach($scheduling_rules as $scheduling_rule) + + {{ $scheduling_rule->name }} + {{ \Carbon\CarbonInterval::seconds($scheduling_rule->interval)->cascade() }} + + + +
+ @csrf + + +
+ + + @endforeach + + @if($scheduling_rules->isEmpty()) + + + {{trans('web::seat.character_scheduling_rules_empty')}} + + + @endif @if(!$scheduling_rules->isEmpty()) @@ -251,10 +254,10 @@ class="btn btn-danger btn-sm confirmlink"> $('input[name="filters"]').val(document.getElementById('filters-btn').dataset.filters); }); - $('.btn-edit-rule').on('click', function (){ - $('#filters-btn').attr('data-filters',$(this).attr('data-filter')) + $('.btn-edit-rule').on('click', function () { + $('#filters-btn').attr('data-filters', $(this).attr('data-filter')) $('#rule-name').val($(this).data('name')) - $('#time').val($(this).data('interval')/3600) + $('#time').val($(this).data('interval') / 3600) $('#timeunit').val("hour") $(this).blur() })