mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-13 13:35:54 +00:00
wip
This commit is contained in:
@@ -51,4 +51,9 @@ class ControlConnection
|
||||
],
|
||||
]));
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
$this->socket->close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\Contracts\UserRepository;
|
||||
use App\Http\Server as HttpServer;
|
||||
use App\Server\Connections\ConnectionManager;
|
||||
use App\Server\Http\Controllers\Admin\DeleteUsersController;
|
||||
use App\Server\Http\Controllers\Admin\DisconnectSiteController;
|
||||
use App\Server\Http\Controllers\Admin\ListSitesController;
|
||||
use App\Server\Http\Controllers\Admin\ListUsersController;
|
||||
use App\Server\Http\Controllers\Admin\RedirectToUsersController;
|
||||
@@ -120,6 +121,7 @@ class Factory
|
||||
$this->router->post('/users', StoreUsersController::class, $adminCondition);
|
||||
$this->router->delete('/users/{id}', DeleteUsersController::class, $adminCondition);
|
||||
$this->router->get('/sites', ListSitesController::class, $adminCondition);
|
||||
$this->router->delete('/sites/{id}', DisconnectSiteController::class, $adminCondition);
|
||||
}
|
||||
|
||||
protected function bindConfiguration()
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Server\Http\Controllers\Admin;
|
||||
|
||||
use App\Contracts\ConnectionManager;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Server\Configuration;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Http\Request;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use function GuzzleHttp\Psr7\str;
|
||||
use function GuzzleHttp\Psr7\stream_for;
|
||||
|
||||
class DisconnectSiteController extends AdminController
|
||||
{
|
||||
/** @var ConnectionManager */
|
||||
protected $connectionManager;
|
||||
|
||||
/** @var Configuration */
|
||||
protected $configuration;
|
||||
|
||||
public function __construct(ConnectionManager $connectionManager)
|
||||
{
|
||||
$this->connectionManager = $connectionManager;
|
||||
}
|
||||
|
||||
public function handle(Request $request, ConnectionInterface $httpConnection)
|
||||
{
|
||||
$connection = $this->connectionManager->findControlConnectionForClientId($request->get('id'));
|
||||
|
||||
if (! is_null($connection)) {
|
||||
$connection->close();
|
||||
|
||||
$this->connectionManager->removeControlConnection($connection);
|
||||
}
|
||||
|
||||
$httpConnection->send(respond_json([
|
||||
'sites' => $this->connectionManager->getConnections()
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -27,15 +27,11 @@ class ListSitesController extends AdminController
|
||||
|
||||
public function handle(Request $request, ConnectionInterface $httpConnection)
|
||||
{
|
||||
try {
|
||||
$sites = $this->getView($httpConnection, 'server.sites.index', [
|
||||
'scheme' => $this->configuration->port() === 443 ? 'https' : 'http',
|
||||
'configuration' => $this->configuration,
|
||||
'sites' => $this->connectionManager->getConnections()
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
dump($e->getMessage());
|
||||
}
|
||||
$sites = $this->getView($httpConnection, 'server.sites.index', [
|
||||
'scheme' => $this->configuration->port() === 443 ? 'https' : 'http',
|
||||
'configuration' => $this->configuration,
|
||||
'sites' => $this->connectionManager->getConnections()
|
||||
]);
|
||||
|
||||
$httpConnection->send(
|
||||
respond_html($sites)
|
||||
|
||||
@@ -21,23 +21,24 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white">
|
||||
{% for site in sites %}
|
||||
<tr>
|
||||
<tr v-for="site in sites">
|
||||
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 text-sm leading-5 font-medium text-gray-900">
|
||||
{{ site.host }}
|
||||
@{ site.host }
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 text-sm leading-5 text-gray-500">
|
||||
{{ site.subdomain }}.{{ configuration.hostname()}}:{{ configuration.port() }}
|
||||
@{ site.subdomain }.{{ configuration.hostname()}}:{{ configuration.port() }}
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 text-sm leading-5 text-gray-500">
|
||||
{{ site.shared_at }}
|
||||
@{ site.shared_at }
|
||||
</td>
|
||||
<td class="px-6 py-4 whitespace-no-wrap text-right border-b border-gray-200 text-sm leading-5 font-medium">
|
||||
<a href="{{ scheme }}://{{ site.subdomain }}.{{ configuration.hostname()}}:{{ configuration.port() }}" target="_blank"
|
||||
<a :href="'{{ scheme|raw }}://'+site.subdomain+'.{{ configuration.hostname()}}:{{ configuration.port() }}'" target="_blank"
|
||||
class="text-indigo-600 hover:text-indigo-900">Visit</a>
|
||||
<a href="#"
|
||||
@click.prevent="disconnectSite(site.client_id)"
|
||||
class="pl-2 text-red-600 hover:text-red-900">Disconnect</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -52,40 +53,17 @@
|
||||
delimiters: ['@{', '}'],
|
||||
|
||||
data: {
|
||||
userForm: {
|
||||
name: '',
|
||||
errors: {},
|
||||
},
|
||||
users: {{ users|json_encode|raw }}
|
||||
sites: {{ sites|json_encode|raw }}
|
||||
},
|
||||
|
||||
methods: {
|
||||
deleteUser(user) {
|
||||
fetch('/expose/users/' + user.id, {
|
||||
disconnectSite(id) {
|
||||
fetch('/sites/' + id, {
|
||||
method: 'DELETE',
|
||||
}).then((response) => {
|
||||
return response.json();
|
||||
}).then((data) => {
|
||||
this.users = this.users.filter(u => u.id !== user.id);
|
||||
});
|
||||
},
|
||||
saveUser() {
|
||||
fetch('/expose/users', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(this.userForm)
|
||||
}).then((response) => {
|
||||
return response.json();
|
||||
}).then((data) => {
|
||||
if (data.user) {
|
||||
this.userForm.errors = {};
|
||||
this.users.unshift(data.user);
|
||||
}
|
||||
if (data.errors) {
|
||||
this.userForm.errors = data.errors;
|
||||
}
|
||||
this.sites = data.sites;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
|
||||
methods: {
|
||||
deleteUser(user) {
|
||||
fetch('/expose/users/delete/'+user.id, {
|
||||
fetch('/users/delete/'+user.id, {
|
||||
method: 'DELETE',
|
||||
}).then((response) => {
|
||||
return response.json();
|
||||
@@ -69,7 +69,7 @@
|
||||
});
|
||||
},
|
||||
saveUser() {
|
||||
fetch('/expose/users', {
|
||||
fetch('/users', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
Reference in New Issue
Block a user