Skip to content

Commit

Permalink
Merge pull request #223 from MineTrax/v1.0.10-alpha
Browse files Browse the repository at this point in the history
v1.0.10-alpha
  • Loading branch information
Xinecraft authored Feb 4, 2023
2 parents 4254537 + 751286e commit b5a6883
Show file tree
Hide file tree
Showing 160 changed files with 2,450 additions and 1,327 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

![image](https://minetrax.github.io/img/shots/homepage.png)

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/minetrax/minetrax/tests?label=Tests&style=for-the-badge&logo=testcafe&logoColor=white)
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/minetrax/minetrax/laravel-mysql.yml?label=Tests&style=for-the-badge&logo=circleci&logoColor=white)
![Discord](https://img.shields.io/discord/508594544598712330?label=Discord&logo=Discord&logoColor=white&style=for-the-badge)
![Lines of code](https://img.shields.io/tokei/lines/github/minetrax/minetrax?style=for-the-badge&logo=xcode&logoColor=white)
![GitHub Releases](https://img.shields.io/github/v/release/minetrax/minetrax?include_prereleases&style=for-the-badge&logo=github&logoColor=white)
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/Admin/CustomPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public function store(CreateCustomPageRequest $request)
'is_visible' => $request->is_visible,
'is_in_navbar' => $request->is_in_navbar,
'is_redirect' => $request->is_redirect,
'is_sidebar_visible' => $request->is_sidebar_visible,
'is_html_page' => $request->is_html_page,
'redirect_url' => $request->redirect_url,
'created_by' => $request->user()->id,
]);
Expand All @@ -63,6 +65,8 @@ public function update(UpdateCustomPageRequest $request, CustomPage $customPage)
$customPage->path = $request->path;
$customPage->is_visible = $request->is_visible;
$customPage->is_in_navbar = $request->is_in_navbar;
$customPage->is_sidebar_visible = $request->is_sidebar_visible;
$customPage->is_html_page = $request->is_html_page;
$customPage->is_redirect = $request->is_redirect;
$customPage->redirect_url = $request->redirect_url;
$customPage->updated_by = $request->user()->id;
Expand Down
14 changes: 13 additions & 1 deletion app/Http/Controllers/Admin/ServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,22 @@ public function show(Server $server)
return Inertia::render('Admin/Server/ShowServer', [
'server' => $server->load(['country']),
'serverAggrData' => $serverAggrData,
'serverConsoleLogs' => $server->serverConsolelog()->limit(100)->orderByDesc('id')->get()
]);
}

public function getServerConsoleLogs(Server $server, Request $request)
{
$afterId = $request->after;
$this->authorize('view', $server);

$query = $server->serverConsolelog()->orderByDesc('id')->limit(100);
if ($afterId) {
$query->where('id', '>', $afterId);
}

return $query->get();
}

public function showPerformanceMonitor(Server $server, Request $request)
{
$this->authorize('view', $server);
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Controllers\Controller;
use App\Models\Badge;
use App\Models\Country;
use App\Models\Role;
use App\Models\User;
use App\Notifications\UserYouAreBanned;
Expand All @@ -19,7 +20,7 @@ public function index()
{
$this->authorize('viewAny', User::class);

$users = User::query()->paginate(10);
$users = User::with('country:id,name,iso_code')->paginate(10);

$users->each(function ($user) {
$user->append('dob_string_with_year');
Expand Down Expand Up @@ -112,11 +113,13 @@ public function edit(User $user)

$rolesList = Role::query()->pluck('display_name', 'name');
$badgesList = Badge::query()->get(['name', 'id']);
$countryList = Country::get(['name', 'id']);

return Inertia::render('Admin/User/EditUser', [
'userData' => $user->load('badges'),
'userData' => $user->load(['badges', 'country:id,name']),
'rolesList' => $rolesList,
'badgesList' => $badgesList,
'countryList' => $countryList
]);
}

Expand Down Expand Up @@ -145,7 +148,8 @@ public function update(Request $request, User $user)
'show_gender' => ['required', 'boolean'],
'profile_photo_source' => ['nullable', 'in:gravatar,linked_player'],
'verified' => ['required', 'boolean'],
'badges' => ['sometimes', 'nullable', 'array', 'exists:badges,id']
'badges' => ['sometimes', 'nullable', 'array', 'exists:badges,id'],
'country_id' => ['required', 'exists:countries,id']
]);

$social_links = [
Expand Down Expand Up @@ -173,6 +177,7 @@ public function update(Request $request, User $user)
$user->social_links = $social_links;
$user->settings = $settings;
$user->about = $request->about ?? null;
$user->country_id = $request->country_id;

// if verified_at was null and now verified is true then mark it as verified & vice versa
if ($request->verified && !$user->verified_at) {
Expand Down
24 changes: 17 additions & 7 deletions app/Http/Controllers/ServerChatlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,24 @@

class ServerChatlogController extends Controller
{
public function index($server)
public function index($server, Request $request)
{
return ServerChatlog::orderByDesc('id')
// AfterId for polling API.
$afterId = $request->after;

$query = ServerChatlog::orderByDesc('id')
->where('server_id', $server)
->whereNull('channel')->limit(50)->get()
->map(function($data) {
->whereNull('channel');

if ($afterId) {
// What? Can we expect to get 100 chatlog within 6 seconds polling interval? No I guess...
$query->where('id', '>', $afterId)->limit(100);
} else {
$query->limit(50);
}

return $query->get()
->map(function ($data) {
$data->data = MinecraftColorUtils::convertToHTML($data->data);
return $data;
});
Expand All @@ -28,16 +40,14 @@ public function sendToServer(Server $server, Request $request)
'message' => 'required|string|min:1|max:255'
]);



$user = $request->user();
$userDisplayName = $user->username;
$webMessageFormat = $user->role_web_message_format;

if ($webMessageFormat) {
$userDisplayName = str_replace("{USERNAME}", $userDisplayName, $webMessageFormat);
} else {
$userDisplayName = $userDisplayName.'&r';
$userDisplayName = $userDisplayName . '&r';
}

$webQuery = new MinecraftWebQuery($server->ip_address, $server->webquery_port);
Expand Down
16 changes: 13 additions & 3 deletions app/Http/Controllers/ShoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,20 @@

class ShoutController extends Controller
{
public function index()
public function index(Request $request)
{
$shouts = Shout::with('user:id,username,name,profile_photo_path,settings')->latest()->limit(5)->get();
return $shouts;
// AfterId for polling API.
$afterId = $request->after;
$shouts = Shout::with('user:id,username,name,profile_photo_path,settings')->latest();

if ($afterId) {
// What? Can we expect to get 100 chatlog within 6 seconds polling interval? No I guess...
$shouts->where('id', '>', $afterId)->limit(50);
} else {
$shouts->limit(5);
}

return $shouts->get();
}

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Requests/CreateCustomPageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public function rules()
'title' => 'required|max:255|string',
'path' => 'required|max:100|alpha_dash|unique:custom_pages',
'is_visible' => 'required|boolean',
'is_sidebar_visible' => 'required|boolean',
'is_in_navbar' => 'required|boolean',
'is_redirect' => 'required|boolean',
'is_html_page' => 'required|boolean',
'redirect_url' => 'nullable|required_if:is_redirect,true|url',
'body' => 'nullable|required_if:is_redirect,false|string',
];
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Requests/UpdateCustomPageRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public function rules()
Rule::unique('custom_pages')->ignore($this->route('customPage')),
],
'is_visible' => 'required|boolean',
'is_sidebar_visible' => 'required|boolean',
'is_in_navbar' => 'required|boolean',
'is_redirect' => 'required|boolean',
'is_html_page' => 'required|boolean',
'redirect_url' => 'nullable|required_if:is_redirect,true|url',
'body' => 'nullable|required_if:is_redirect,false|string',
];
Expand Down
5 changes: 5 additions & 0 deletions app/Models/CustomPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class CustomPage extends BaseModel
'is_visible' => 'boolean',
'is_in_navbar' => 'boolean',
'is_redirect' => 'boolean',
'is_sidebar_visible' => 'boolean',
'is_html_page' => 'boolean',
];

public function scopeVisible($query)
Expand All @@ -27,6 +29,9 @@ public function scopeNavbar($query)

public function getBodyHtmlAttribute(): string
{
if ($this->is_html_page) {
return $this->body;
}
$converter = new GithubFlavoredMarkdownConverter();
return $converter->convertToHtml($this->body);
}
Expand Down
4 changes: 4 additions & 0 deletions app/View/Components/PhpVarsToJsTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ class PhpVarsToJsTransformer extends Component
{
public function render()
{
$useWebsockets = config("broadcasting.default") == "pusher" || config("broadcasting.default") == "ably";
$useWebsockets = $useWebsockets && config("broadcasting.connections." . config("broadcasting.default") . ".key");

$pusher = [
"USE_WEBSOCKETS" => $useWebsockets,
"VITE_PUSHER_APP_KEY" => config("broadcasting.connections.pusher.key"),
"VITE_PUSHER_HOST" => config("broadcasting.connections.pusher._pusher_host"),
"VITE_PUSHER_PORT" => config("broadcasting.connections.pusher._pusher_port"),
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
],
"license": "MIT",
"require": {
"php": "^8.1",
"php": ">=8.1",
"ext-json": "*",
"ext-sockets": "*",
"bensampo/laravel-enum": "^5.3",
Expand All @@ -20,7 +20,7 @@
"doctrine/dbal": "^3.5",
"geoip2/geoip2": "^2.12",
"guzzlehttp/guzzle": "^7.4",
"inertiajs/inertia-laravel": "^0.5.2",
"inertiajs/inertia-laravel": "^0.6.0",
"intervention/imagecache": "^2.5",
"laravel/framework": "^9.36",
"laravel/jetstream": "^2.12",
Expand Down
Loading

0 comments on commit b5a6883

Please sign in to comment.