Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #201 from ExpDev07/dev
Browse files Browse the repository at this point in the history
New features and bugfixes
  • Loading branch information
coalaura authored Aug 4, 2021
2 parents 01e4c81 + 12b5245 commit dcf14fa
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
5 changes: 4 additions & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ class Handler extends ExceptionHandler
*/
public function report(Throwable $exception)
{
if ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
if (
$exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException || // 404 doesn't need to be logged to avoid filling the log file
$exception instanceof \Illuminate\Encryption\MissingAppKeyException // /api/players Illuminate\Encryption\MissingAppKeyException: No application encryption key has been specified.
) {
parent::report($exception);
return;
}
Expand Down
26 changes: 19 additions & 7 deletions app/Http/Controllers/PlayerCharacterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ public function index(Request $request): Response
}
}

// Filtering isDeleted.
if ($deleted = $request->input('deleted')) {
if ($deleted === 'yes' || $deleted === 'no') {
if ($deleted === 'yes') {
$query->where('character_deleted', '=', '1');
} else if ($deleted === 'no') {
$query->where('character_deleted', '=', '0');
}
}
}

$query->select([
'character_id', 'steam_identifier', 'first_name', 'last_name', 'gender', 'job_name',
'department_name', 'position_name', 'phone_number',
Expand All @@ -99,13 +110,14 @@ public function index(Request $request): Response

return Inertia::render('Characters/Index', [
'characters' => $characters,
'filters' => $request->all(
'cid',
'name',
'vehicle_plate',
'phone',
'job'
),
'filters' => [
'character_id' => $request->input('character_id'),
'name' => $request->input('name'),
'vehicle_plate' => $request->input('vehicle_plate'),
'phone' => $request->input('phone'),
'job' => $request->input('job'),
'deleted' => $request->input('deleted') ?: 'all',
],
'time' => $end - $start,
'playerMap' => Player::fetchSteamPlayerNameMap($characters->toArray($request), 'steamIdentifier'),
]);
Expand Down
8 changes: 7 additions & 1 deletion app/Http/Middleware/StaffMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ protected function checkSessionLock(): bool

$valid = $lock === $print;
if (!$valid) {
$sDetail = $session->get('session_detail');

LoggingHelper::log($session->getSessionKey(), 'StaffMiddleware session-lock is invalid');
LoggingHelper::log($session->getSessionKey(), $lock . ' != ' . $print);
LoggingHelper::log($session->getSessionKey(), 'current.detail -> ' . json_encode($detail));
LoggingHelper::log($session->getSessionKey(), 'session.detail -> ' . json_encode($session->get('session_detail')));
LoggingHelper::log($session->getSessionKey(), 'session.detail -> ' . json_encode($sDetail));

$this->error = 'Your session is invalid, please refresh this page or log in again.';

if ($sDetail && isset($sDetail['ip']) && $sDetail['ip'] !== $detail['ip']) {
$this->error .= ' (Log-in from new ip)';
}
}

$session->put('session_detail', $detail);
Expand Down
14 changes: 13 additions & 1 deletion resources/js/Pages/Characters/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,23 @@
<input class="block w-full px-4 py-3 mb-3 bg-gray-200 border rounded dark:bg-gray-600" id="phone" placeholder="606-0992" v-model="filters.phone">
</div>
<!-- Job -->
<div class="w-3/4 px-3 mobile:w-full mobile:mb-3">
<div class="w-1/2 px-3 mobile:w-full mobile:mb-3">
<label class="block mb-2" for="job">
{{ t('characters.form.job') }} <sup class="text-muted dark:text-dark-muted">**</sup>
</label>
<input class="block w-full px-4 py-3 mb-3 bg-gray-200 border rounded dark:bg-gray-600" id="job" placeholder="Government Waste Collector Employee" v-model="filters.job">
</div>
<!-- Deletion status -->
<div class="w-1/4 px-3 mobile:w-full mobile:mb-3">
<label class="block mb-2" for="deleted">
{{ t('characters.form.deleted') }} <sup class="text-muted dark:text-dark-muted">*</sup>
</label>
<select class="block w-full px-4 py-3 mb-3 bg-gray-200 dark:bg-gray-600 border rounded" id="deleted" name="deleted" v-model="filters.deleted">
<option value="all">{{ t('global.all') }}</option>
<option value="yes">{{ t('global.yes') }}</option>
<option value="no">{{ t('global.no') }}</option>
</select>
</div>
<!-- Description -->
<div class="w-full px-3 mt-3">
<small class="text-muted dark:text-dark-muted mt-1 leading-4 block">* {{ t('global.search.exact') }}</small>
Expand Down Expand Up @@ -159,6 +170,7 @@ export default {
vehicle_plate: String,
phone: String,
job: String,
deleted: String,
},
playerMap: {
type: Object,
Expand Down
6 changes: 6 additions & 0 deletions resources/js/Pages/Players/Show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@
<span class="text-muted dark:text-dark-muted">
{{ warning.createdAt | formatTime }}
</span>
<sup class="ml-2 italic text-sm text-gray-600 dark:text-gray-400" v-if="warning.updatedAt !== warning.createdAt" :title="t('players.show.warning_edited_title', formatTime(warning.updatedAt))">
{{ t('players.show.warning_edited') }}
</sup>
<button
class="px-3 py-1 ml-4 text-sm font-semibold text-white bg-yellow-500 rounded"
@click="warningEditId = warning.id"
Expand Down Expand Up @@ -627,6 +630,9 @@ export default {
? this.t('players.show.ban', this.player.ban.issuer, this.$options.filters.formatTime(this.player.ban.expireAt))
: this.t('players.ban.forever', this.player.ban.issuer);
},
formatTime(t) {
return this.$options.filters.formatTime(t);
},
async pmPlayer() {
// Send request.
await this.$inertia.post('/players/' + this.player.steamIdentifier + '/staffPM', this.form.pm);
Expand Down
9 changes: 7 additions & 2 deletions resources/js/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"refresh": "Refresh",
"delete": "Delete",
"view_map": "View on Live-Map",
"yes": "Yes",
"no": "No",
"status": {
"online": "Online",
"offline": "Offline",
Expand Down Expand Up @@ -185,7 +187,8 @@
"name": "Full Name",
"plate": "Vehicle Plate",
"job": "Job",
"phone": "Phone Number"
"phone": "Phone Number",
"deleted": "Is Deleted"
},
"result": {
"player": "Player",
Expand Down Expand Up @@ -294,7 +297,9 @@
"panel_logs": "Latest 25 Panel Logs",
"delete_character": "Are you sure you want to delete this character?",
"unload": "Unload Players Character",
"unload_confirm": "Are you sure you want to unload this players character? This will send them to the character selection screen."
"unload_confirm": "Are you sure you want to unload this players character? This will send them to the character selection screen.",
"warning_edited": "Edited",
"warning_edited_title": "Edited on {0}"
},
"form": {
"identifier": "Identifier",
Expand Down

0 comments on commit dcf14fa

Please sign in to comment.