Skip to content

Commit

Permalink
dashboard show redis version
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Oct 20, 2024
1 parent ed10030 commit a514ed5
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 8 deletions.
7 changes: 3 additions & 4 deletions app/Console/Commands/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
use NexusPlugin\PostLike\PostLikeRepository;
use NexusPlugin\StickyPromotion\Models\StickyPromotion;
use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator;
use NexusPlugin\Tracker\TrackerRepository;
use NexusPlugin\Work\Models\RoleWork;
use NexusPlugin\Work\WorkRepository;
use PhpIP\IP;
Expand Down Expand Up @@ -100,10 +101,8 @@ public function __construct()
*/
public function handle()
{
$ip = "44,
55,
444,65 5 32";
$result = preg_split("/[\r\n\s,,]+/", trim($ip));
$tool = new TrackerRepository();
$result = $tool->checkStatus();
dd($result);
}

Expand Down
13 changes: 11 additions & 2 deletions app/Repositories/DashboardRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Carbon\Carbon;
use Filament\Facades\Filament;
use Illuminate\Support\Facades\DB;
use Nexus\Database\NexusDB;

class DashboardRepository extends BaseRepository
{
Expand Down Expand Up @@ -51,18 +52,26 @@ public function getSystemInfo(): array
'text' => nexus_trans("dashboard.system_info.$name"),
'value' => DB::select(DB::raw('select version() as info'))[0]->info,
];
$name = 'os';
// $name = 'os';
// $result[$name] = [
// 'name' => $name,
// 'text' => nexus_trans("dashboard.system_info.$name"),
// 'value' => PHP_OS,
// ];
$name = 'redis_version';
$result[$name] = [
'name' => $name,
'text' => nexus_trans("dashboard.system_info.$name"),
'value' => PHP_OS,
'value' => NexusDB::redis()->info()['redis_version'],
];

$name = 'server_software';
$result[$name] = [
'name' => $name,
'text' => nexus_trans("dashboard.system_info.$name"),
'value' => $_SERVER['SERVER_SOFTWARE'] ?? '',
];

$name = 'load_average';
$result[$name] = [
'name' => $name,
Expand Down
22 changes: 22 additions & 0 deletions app/Repositories/ToolRepository.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace App\Repositories;

use App\Http\Middleware\Locale;
use App\Models\Invite;
use App\Models\Message;
use App\Models\News;
Expand Down Expand Up @@ -503,4 +504,25 @@ public function removeDuplicatePeer()
}
}
}

public function sendAlarmEmail(string $subjectTransKey, array $subjectTransContext, string $msgTransKey, array $msgTransContext): void
{
$receiverUid = get_setting("system.alarm_email_receiver");
if (empty($receiverUid)) {
$locale = Locale::getDefault();
$subject = nexus_trans($subjectTransKey, $subjectTransContext, $locale);
$msg = nexus_trans($msgTransKey, $msgTransContext, $locale);
do_log(sprintf("%s - %s", $subject, $msg), "error");
} else {
$receiverUidArr = preg_split("/[\r\n\s,,]+/", $receiverUid);
$users = User::query()->whereIn("id", $receiverUidArr)->get(User::$commonFields);
foreach ($users as $user) {
$locale = $user->locale;
$subject = nexus_trans($subjectTransKey, $subjectTransContext, $locale);
$msg = nexus_trans($msgTransKey, $msgTransContext, $locale);
$result = $this->sendMail($user->email, $subject, $msg);
do_log(sprintf("send msg: %s result: %s", $msg, var_export($result, true)), $result ? "info" : "error");
}
}
}
}
2 changes: 1 addition & 1 deletion include/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5319,7 +5319,7 @@ function torrentTags($tags = 0, $type = 'checkbox')
return $html;
}

function saveSetting($prefix, $nameAndValue, $autoload = 'yes')
function saveSetting(string $prefix, array $nameAndValue, string $autoload = 'yes'): void
{
$prefix = strtolower($prefix);
$datetimeNow = date('Y-m-d H:i:s');
Expand Down
7 changes: 6 additions & 1 deletion nexus/Plugin/BasePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public function getNexusView($name): string

public function trans($name): string
{
return nexus_trans(sprintf("%s::%s", static::ID, $name));
return nexus_trans($this->getTransKey($name));
}

public function getTransKey($name): string
{
return sprintf("%s::%s", static::ID, $name);
}

public static function getInstance(): static
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'server_software' => 'Web software',
'load_average' => 'Server load average',
'filament_version' => 'Filament version',
'redis_version' => 'Redis version',
],
'latest_user' => [
'page_title' => 'User latest',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/zh_CN/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'server_software' => 'Web 软件',
'load_average' => '服务器平均负载',
'filament_version' => 'Filament 版本',
'redis_version' => 'Redis 版本',
],
'latest_user' => [
'page_title' => '最新用户',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/zh_TW/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'server_software' => 'Web 軟件',
'load_average' => '服務器平均負載',
'filament_version' => 'Filament 版本',
'redis_version' => 'Redis 版本',
],
'latest_user' => [
'page_title' => '最新用戶',
Expand Down

0 comments on commit a514ed5

Please sign in to comment.