mirror of
https://github.com/bitinflow/expose.git
synced 2026-03-18 07:55:55 +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\Http\Server as HttpServer;
|
||||||
use App\Server\Connections\ConnectionManager;
|
use App\Server\Connections\ConnectionManager;
|
||||||
use App\Server\Http\Controllers\Admin\DeleteUsersController;
|
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\ListSitesController;
|
||||||
use App\Server\Http\Controllers\Admin\ListUsersController;
|
use App\Server\Http\Controllers\Admin\ListUsersController;
|
||||||
use App\Server\Http\Controllers\Admin\RedirectToUsersController;
|
use App\Server\Http\Controllers\Admin\RedirectToUsersController;
|
||||||
@@ -120,6 +121,7 @@ class Factory
|
|||||||
$this->router->post('/users', StoreUsersController::class, $adminCondition);
|
$this->router->post('/users', StoreUsersController::class, $adminCondition);
|
||||||
$this->router->delete('/users/{id}', DeleteUsersController::class, $adminCondition);
|
$this->router->delete('/users/{id}', DeleteUsersController::class, $adminCondition);
|
||||||
$this->router->get('/sites', ListSitesController::class, $adminCondition);
|
$this->router->get('/sites', ListSitesController::class, $adminCondition);
|
||||||
|
$this->router->delete('/sites/{id}', DisconnectSiteController::class, $adminCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function bindConfiguration()
|
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)
|
public function handle(Request $request, ConnectionInterface $httpConnection)
|
||||||
{
|
{
|
||||||
try {
|
$sites = $this->getView($httpConnection, 'server.sites.index', [
|
||||||
$sites = $this->getView($httpConnection, 'server.sites.index', [
|
'scheme' => $this->configuration->port() === 443 ? 'https' : 'http',
|
||||||
'scheme' => $this->configuration->port() === 443 ? 'https' : 'http',
|
'configuration' => $this->configuration,
|
||||||
'configuration' => $this->configuration,
|
'sites' => $this->connectionManager->getConnections()
|
||||||
'sites' => $this->connectionManager->getConnections()
|
]);
|
||||||
]);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
dump($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
$httpConnection->send(
|
$httpConnection->send(
|
||||||
respond_html($sites)
|
respond_html($sites)
|
||||||
|
|||||||
@@ -21,23 +21,24 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="bg-white">
|
<tbody class="bg-white">
|
||||||
{% for site in sites %}
|
<tr v-for="site in sites">
|
||||||
<tr>
|
|
||||||
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 text-sm leading-5 font-medium text-gray-900">
|
<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>
|
||||||
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 text-sm leading-5 text-gray-500">
|
<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>
|
||||||
<td class="px-6 py-4 whitespace-no-wrap border-b border-gray-200 text-sm leading-5 text-gray-500">
|
<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>
|
||||||
<td class="px-6 py-4 whitespace-no-wrap text-right border-b border-gray-200 text-sm leading-5 font-medium">
|
<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>
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,40 +53,17 @@
|
|||||||
delimiters: ['@{', '}'],
|
delimiters: ['@{', '}'],
|
||||||
|
|
||||||
data: {
|
data: {
|
||||||
userForm: {
|
sites: {{ sites|json_encode|raw }}
|
||||||
name: '',
|
|
||||||
errors: {},
|
|
||||||
},
|
|
||||||
users: {{ users|json_encode|raw }}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
deleteUser(user) {
|
disconnectSite(id) {
|
||||||
fetch('/expose/users/' + user.id, {
|
fetch('/sites/' + id, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
return response.json();
|
return response.json();
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
this.users = this.users.filter(u => u.id !== user.id);
|
this.sites = data.sites;
|
||||||
});
|
|
||||||
},
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
deleteUser(user) {
|
deleteUser(user) {
|
||||||
fetch('/expose/users/delete/'+user.id, {
|
fetch('/users/delete/'+user.id, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
return response.json();
|
return response.json();
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveUser() {
|
saveUser() {
|
||||||
fetch('/expose/users', {
|
fetch('/users', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
|
|||||||
Reference in New Issue
Block a user