mirror of https://github.com/YGGverse/HLState.git
ghost
11 months ago
19 changed files with 389 additions and 365 deletions
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
/* |
||||
* Welcome to your app's main JavaScript file! |
||||
* |
||||
* This file will be included onto the page via the importmap() Twig function, |
||||
* which should already be in your base.html.twig. |
||||
*/ |
||||
import './styles/app.css' |
||||
|
||||
console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉') |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
import { startStimulusApp } from '@symfony/stimulus-bundle'; |
||||
|
||||
const app = startStimulusApp(); |
||||
// register any custom, 3rd party controllers here
|
||||
// app.register('some_controller_name', SomeImportedController);
|
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
{ |
||||
"controllers": { |
||||
"@symfony/ux-turbo": { |
||||
"turbo-core": { |
||||
"enabled": true, |
||||
"fetch": "eager" |
||||
}, |
||||
"mercure-turbo-stream": { |
||||
"enabled": false, |
||||
"fetch": "eager" |
||||
} |
||||
} |
||||
}, |
||||
"entrypoints": [] |
||||
} |
@ -1,16 +0,0 @@
@@ -1,16 +0,0 @@
|
||||
import { Controller } from '@hotwired/stimulus'; |
||||
|
||||
/* |
||||
* This is an example Stimulus controller! |
||||
* |
||||
* Any element with a data-controller="hello" attribute will cause |
||||
* this controller to be executed. The name "hello" comes from the filename: |
||||
* hello_controller.js -> "hello" |
||||
* |
||||
* Delete this file or adapt it for your use! |
||||
*/ |
||||
export default class extends Controller { |
||||
connect() { |
||||
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js'; |
||||
} |
||||
} |
@ -1,3 +0,0 @@
@@ -1,3 +0,0 @@
|
||||
body { |
||||
background-color: skyblue; |
||||
} |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
framework: |
||||
asset_mapper: |
||||
# The paths to make available to the asset mapper. |
||||
paths: |
||||
- assets/ |
@ -1,6 +1,10 @@
@@ -1,6 +1,10 @@
|
||||
twig: |
||||
default_path: '%kernel.project_dir%/templates' |
||||
|
||||
globals: |
||||
app: |
||||
version: '%app.version%' |
||||
name: '%app.name%' |
||||
theme: '%app.theme%' |
||||
when@test: |
||||
twig: |
||||
strict_variables: true |
||||
|
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
<?php |
||||
|
||||
/** |
||||
* Returns the importmap for this application. |
||||
* |
||||
* - "path" is a path inside the asset mapper system. Use the |
||||
* "debug:asset-map" command to see the full list of paths. |
||||
* |
||||
* - "entrypoint" (JavaScript only) set to true for any module that will |
||||
* be used as an "entrypoint" (and passed to the importmap() Twig function). |
||||
* |
||||
* The "importmap:require" command can be used to add new entries to this file. |
||||
* |
||||
* This file has been auto-generated by the importmap commands. |
||||
*/ |
||||
return [ |
||||
'app' => [ |
||||
'path' => './assets/app.js', |
||||
'entrypoint' => true, |
||||
], |
||||
'@hotwired/stimulus' => [ |
||||
'version' => '3.2.2', |
||||
], |
||||
'@symfony/stimulus-bundle' => [ |
||||
'path' => './vendor/symfony/stimulus-bundle/assets/dist/loader.js', |
||||
], |
||||
'@hotwired/turbo' => [ |
||||
'version' => '7.3.0', |
||||
], |
||||
]; |
@ -0,0 +1,124 @@
@@ -0,0 +1,124 @@
|
||||
* |
||||
{ |
||||
/* apply defaults */ |
||||
margin: 0; |
||||
padding: 0; |
||||
|
||||
/* allow draw */ |
||||
font-family: monospace; |
||||
|
||||
/* adaptive */ |
||||
color-scheme: light dark; |
||||
|
||||
/* vars */ |
||||
--container-max-width: 768px; |
||||
--color-warning: #ee784e; |
||||
--color-error: #ff6363; |
||||
--color-default: #999; |
||||
} |
||||
|
||||
*::placeholder |
||||
{ |
||||
font-size: 12px; |
||||
} |
||||
|
||||
hr { |
||||
background-color: var(--color-default); |
||||
border: none; |
||||
color: var(--color-default); |
||||
height: 1px; |
||||
margin: 8px 0; |
||||
} |
||||
|
||||
h1 |
||||
{ |
||||
font-size: 16px; |
||||
} |
||||
|
||||
h2 |
||||
{ |
||||
font-size: 14px; |
||||
} |
||||
|
||||
h3 |
||||
{ |
||||
font-size: 13px; |
||||
} |
||||
|
||||
a, a:active, a:visited |
||||
{ |
||||
color: var(--color-warning); |
||||
} |
||||
|
||||
table |
||||
{ |
||||
width: 100%; |
||||
border-collapse: collapse; |
||||
border: 1px solid var(--color-default); |
||||
} |
||||
|
||||
table th, |
||||
table td |
||||
{ |
||||
border: 1px solid var(--color-default); |
||||
padding: 4px; |
||||
} |
||||
|
||||
header |
||||
{ |
||||
display: block; |
||||
margin: 16px auto; |
||||
max-width: var(--container-max-width); |
||||
} |
||||
|
||||
main |
||||
{ |
||||
display: block; |
||||
margin: 16px auto; |
||||
max-width: var(--container-max-width); |
||||
} |
||||
|
||||
footer |
||||
{ |
||||
display: block; |
||||
margin: 16px auto; |
||||
max-width: var(--container-max-width); |
||||
} |
||||
|
||||
/* framework */ |
||||
.text-align-left |
||||
{ |
||||
text-align: left; |
||||
} |
||||
|
||||
.text-align-center |
||||
{ |
||||
text-align: center; |
||||
} |
||||
|
||||
.text-align-right |
||||
{ |
||||
text-align: right; |
||||
} |
||||
|
||||
.border-default |
||||
{ |
||||
border: 1px var(--color-default) solid; |
||||
} |
||||
|
||||
.padding-8-px |
||||
{ |
||||
padding: 8px; |
||||
} |
||||
|
||||
.padding-y-8-px |
||||
{ |
||||
padding-bottom: 8px; |
||||
padding-top: 8px; |
||||
} |
||||
|
||||
.margin-y-8-px |
||||
{ |
||||
margin-bottom: 8px; |
||||
margin-top: 8px; |
||||
} |
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
<?php |
||||
|
||||
namespace App\Controller; |
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
||||
use Symfony\Contracts\Translation\TranslatorInterface; |
||||
|
||||
use Symfony\Component\Routing\Annotation\Route; |
||||
use Symfony\Component\HttpFoundation\Response; |
||||
use Symfony\Component\HttpFoundation\Request; |
||||
|
||||
class MainController extends AbstractController |
||||
{ |
||||
#[Route( |
||||
'/', |
||||
name: 'main_index', |
||||
methods: |
||||
[ |
||||
'GET' |
||||
] |
||||
)] |
||||
public function index( |
||||
?Request $request |
||||
): Response |
||||
{ |
||||
// Get HLServers config |
||||
if ($hlservers = file_get_contents($this->getParameter('app.hlservers'))) |
||||
{ |
||||
$hlservers = json_decode($hlservers); |
||||
} |
||||
|
||||
else |
||||
{ |
||||
$hlservers = []; |
||||
} |
||||
|
||||
// Collect servers info |
||||
$servers = []; |
||||
|
||||
foreach ($hlservers as $hlserver) |
||||
{ |
||||
try |
||||
{ |
||||
$server = new \xPaw\SourceQuery\SourceQuery(); |
||||
|
||||
$server->Connect( |
||||
$hlserver->host, |
||||
$hlserver->port |
||||
); |
||||
|
||||
if ($server->Ping()) |
||||
{ |
||||
if ($info = (array) $server->GetInfo()) |
||||
{ |
||||
$servers[] = [ |
||||
'host' => $hlserver->host, |
||||
'port' => $hlserver->port, |
||||
'alias' => $hlserver->alias, |
||||
'info' => $info, |
||||
'online' => empty($info['Players']) ? [] : (array) $server->GetPlayers() |
||||
]; |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
catch (Exception $error) |
||||
{ |
||||
continue; |
||||
} |
||||
|
||||
finally |
||||
{ |
||||
$server->Disconnect(); |
||||
} |
||||
} |
||||
|
||||
return $this->render( |
||||
'default/main/index.html.twig', |
||||
[ |
||||
'request' => $request, |
||||
'servers' => $servers |
||||
] |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>{% block head_title_content %}{{ app.name }}{% endblock %}</title> |
||||
<link rel="stylesheet" type="text/css" href="{{ url('main_index') }}css/default.css?{{ app.version }}"/> |
||||
</head> |
||||
<body> |
||||
{% block header_container %} |
||||
<header> |
||||
{% block header_content %} |
||||
<div class="text-align-right"> |
||||
<strong> |
||||
{{ app.name }} |
||||
</strong> |
||||
</div> |
||||
{% endblock %} |
||||
</header> |
||||
{% endblock %} |
||||
{% block main_container %} |
||||
<main> |
||||
{% block main_content %}{% endblock %} |
||||
</main> |
||||
{% endblock %} |
||||
{% block footer_container %} |
||||
<footer> |
||||
{% block footer_content %} |
||||
<div class="text-align-right"> |
||||
<small> |
||||
{{ 'Powered by' | trans }} |
||||
<a href="https://github.com/YGGverse/HLState" target="_blank">HLState</a> |
||||
</small> |
||||
</div> |
||||
{% endblock %} |
||||
</footer> |
||||
{% endblock %} |
||||
</body> |
||||
</html> |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
{% extends 'default/layout.html.twig' %} |
||||
{% block main_content %} |
||||
{% for server in servers %} |
||||
<div class="border-default padding-8-px margin-y-8-px"> |
||||
<h2>{{ server.info.HostName }}</h2> |
||||
<hr /> |
||||
<h3 class="padding-y-8-px text-align-right">{{ 'Address' | trans }}</h3> |
||||
<div> |
||||
{{ server.host }}:{{ server.port }} |
||||
</div> |
||||
{% if server.alias %} |
||||
<h3 class="padding-y-8-px text-align-right">{{ 'Aliases' | trans }}</h3> |
||||
{% for alias in server.alias %} |
||||
<div> |
||||
{{ alias.host }}:{{ alias.port }} |
||||
</div> |
||||
{% endfor %} |
||||
{% endif %} |
||||
{% if server.info %} |
||||
<h3 class="padding-y-8-px text-align-right">{{ 'Info' | trans }}</h3> |
||||
<table> |
||||
{% for key, value in server.info %} |
||||
<tr> |
||||
<td class="text-align-left">{{ key }}</td> |
||||
<td class="text-align-left">{{ value }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
{% endif %} |
||||
{% if server.online %} |
||||
<h3 class="padding-y-8-px text-align-right">{{ 'Online' | trans }}</h3> |
||||
<table> |
||||
<tr> |
||||
<th class="text-align-left">{{ 'Name' | trans }}</th> |
||||
<th class="text-align-center">{{ 'Frags' | trans }}</th> |
||||
<th class="text-align-center">{{ 'Time' | trans }}</th> |
||||
</tr> |
||||
{% for player in server.online %} |
||||
<tr> |
||||
<td class="text-align-left">{{ player.Name }}</td> |
||||
<td class="text-align-center">{{ player.Frags }}</td> |
||||
<td class="text-align-center"> |
||||
{% if player.TimeF == '59:59' %} |
||||
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="currentColor" viewBox="0 0 16 16"> |
||||
<path d="M5.68 5.792 7.345 7.75 5.681 9.708a2.75 2.75 0 1 1 0-3.916ZM8 6.978 6.416 5.113l-.014-.015a3.75 3.75 0 1 0 0 5.304l.014-.015L8 8.522l1.584 1.865.014.015a3.75 3.75 0 1 0 0-5.304l-.014.015zm.656.772 1.663-1.958a2.75 2.75 0 1 1 0 3.916z"/> |
||||
</svg> |
||||
{% else %} |
||||
{{ player.TimeF }} |
||||
{% endif %} |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
{% endif %} |
||||
</div> |
||||
{% endfor %} |
||||
{% endblock %} |
Loading…
Reference in new issue