Add mount_server table, fix wrong field type on other many to many tables, add routes for mounting and unmounting mounts on a server, finish server admin mounts page
This commit is contained in:
parent
a0900b8b94
commit
0eb29dac9c
|
@ -178,6 +178,8 @@ class ServerViewController extends Controller
|
||||||
*/
|
*/
|
||||||
public function mounts(Request $request, Server $server)
|
public function mounts(Request $request, Server $server)
|
||||||
{
|
{
|
||||||
|
$server->load('mounts');
|
||||||
|
|
||||||
return $this->view->make('admin.servers.view.mounts', [
|
return $this->view->make('admin.servers.view.mounts', [
|
||||||
'mounts' => $this->mountRepository->getMountListForServer($server),
|
'mounts' => $this->mountRepository->getMountListForServer($server),
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
|
|
|
@ -378,4 +378,34 @@ class ServersController extends Controller
|
||||||
|
|
||||||
return response('', 204);
|
return response('', 204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a mount to a server.
|
||||||
|
*
|
||||||
|
* @param Server $server
|
||||||
|
* @param int $mount_id
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function addMount(Server $server, int $mount_id)
|
||||||
|
{
|
||||||
|
$server->mounts()->attach($mount_id);
|
||||||
|
|
||||||
|
$this->alert->success('Mount was added successfully.')->flash();
|
||||||
|
return redirect()->route('admin.servers.view.mounts', $server->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a mount from a server.
|
||||||
|
*
|
||||||
|
* @param Server $server
|
||||||
|
* @param int $mount_id
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function deleteMount(Server $server, int $mount_id)
|
||||||
|
{
|
||||||
|
$server->mounts()->detach($mount_id);
|
||||||
|
|
||||||
|
$this->alert->success('Mount was removed successfully.')->flash();
|
||||||
|
return redirect()->route('admin.servers.view.mounts', $server->id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,9 @@ namespace Pterodactyl\Models;
|
||||||
* @property bool $read_only
|
* @property bool $read_only
|
||||||
* @property bool $user_mountable
|
* @property bool $user_mountable
|
||||||
*
|
*
|
||||||
* @property \Illuminate\Database\Eloquent\Relations\BelongsToMany $eggs
|
* @property \Pterodactyl\Models\Egg[]|\Illuminate\Database\Eloquent\Collection $eggs
|
||||||
* @property \Illuminate\Database\Eloquent\Relations\BelongsToMany $nodes
|
* @property \Pterodactyl\Models\Node[]|\Illuminate\Database\Eloquent\Collection $nodes
|
||||||
|
* @property \Pterodactyl\Models\Server[]|\Illuminate\Database\Eloquent\Collection $servers
|
||||||
*/
|
*/
|
||||||
class Mount extends Model
|
class Mount extends Model
|
||||||
{
|
{
|
||||||
|
@ -94,4 +95,14 @@ class Mount extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Node::class);
|
return $this->belongsToMany(Node::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all servers that have this mount assigned.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
|
*/
|
||||||
|
public function servers()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Server::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ use Znck\Eloquent\Traits\BelongsToThrough;
|
||||||
* @property \Pterodactyl\Models\DaemonKey[]|\Illuminate\Database\Eloquent\Collection $keys
|
* @property \Pterodactyl\Models\DaemonKey[]|\Illuminate\Database\Eloquent\Collection $keys
|
||||||
* @property \Pterodactyl\Models\ServerTransfer $transfer
|
* @property \Pterodactyl\Models\ServerTransfer $transfer
|
||||||
* @property \Pterodactyl\Models\Backup[]|\Illuminate\Database\Eloquent\Collection $backups
|
* @property \Pterodactyl\Models\Backup[]|\Illuminate\Database\Eloquent\Collection $backups
|
||||||
|
* @property \Pterodactyl\Models\Mount[]|\Illuminate\Database\Eloquent\Collection $mounts
|
||||||
*/
|
*/
|
||||||
class Server extends Model
|
class Server extends Model
|
||||||
{
|
{
|
||||||
|
@ -351,4 +352,14 @@ class Server extends Model
|
||||||
{
|
{
|
||||||
return $this->hasMany(Backup::class);
|
return $this->hasMany(Backup::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all mounts that have this server has mounted.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
|
*/
|
||||||
|
public function mounts()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Mount::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,14 +26,14 @@ class AddMountsTable extends Migration
|
||||||
|
|
||||||
Schema::create('egg_mount', function (Blueprint $table) {
|
Schema::create('egg_mount', function (Blueprint $table) {
|
||||||
$table->integer('egg_id');
|
$table->integer('egg_id');
|
||||||
$table->char('mount_id', 36);
|
$table->integer('mount_id');
|
||||||
|
|
||||||
$table->unique(['egg_id', 'mount_id']);
|
$table->unique(['egg_id', 'mount_id']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::create('mount_node', function (Blueprint $table) {
|
Schema::create('mount_node', function (Blueprint $table) {
|
||||||
$table->integer('node_id');
|
$table->integer('node_id');
|
||||||
$table->char('mount_id', 36);
|
$table->integer('mount_id');
|
||||||
|
|
||||||
$table->unique(['node_id', 'mount_id']);
|
$table->unique(['node_id', 'mount_id']);
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddMountServerTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('mount_server', function (Blueprint $table) {
|
||||||
|
$table->integer('server_id');
|
||||||
|
$table->integer('mount_id');
|
||||||
|
|
||||||
|
$table->unique(['server_id', 'mount_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('mount_server');
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,21 +41,33 @@
|
||||||
<td class="middle"><a href="{{ route('admin.mounts.view', $mount->id) }}">{{ $mount->name }}</a></td>
|
<td class="middle"><a href="{{ route('admin.mounts.view', $mount->id) }}">{{ $mount->name }}</a></td>
|
||||||
<td class="middle"><code>{{ $mount->source }}</code></td>
|
<td class="middle"><code>{{ $mount->source }}</code></td>
|
||||||
<td class="col-sm-2 middle"><code>{{ $mount->target }}</code></td>
|
<td class="col-sm-2 middle"><code>{{ $mount->target }}</code></td>
|
||||||
<td class="col-sm-2 middle">
|
|
||||||
@if ($mount->id == 2)
|
|
||||||
<span class="label label-primary">Unmounted</span>
|
|
||||||
@else
|
|
||||||
<span class="label label-success">Mounted</span>
|
|
||||||
@endif
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td class="col-sm-1 middle">
|
@if (! in_array($mount->id, $server->mounts->pluck('id')->toArray()))
|
||||||
@if ($mount->id == 2)
|
<td class="col-sm-2 middle">
|
||||||
<button data-action="mount" data-id="{{ $mount->id }}" class="btn btn-xs btn-success"><i class="fa fa-plus"></i></button>
|
<span class="label label-primary">Unmounted</span>
|
||||||
@else
|
</td>
|
||||||
<button data-action="unmount" data-id="{{ $mount->id }}" class="btn btn-xs btn-danger"><i class="fa fa-times"></i></button>
|
|
||||||
@endif
|
<td class="col-sm-1 middle">
|
||||||
</td>
|
<form action="{{ route('admin.servers.view.mounts.toggle', [ 'server' => $server->id, 'mount' => $mount->id ]) }}" method="POST">
|
||||||
|
{!! csrf_field() !!}
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-xs btn-success"><i class="fa fa-plus"></i></button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
@else
|
||||||
|
<td class="col-sm-2 middle">
|
||||||
|
<span class="label label-success">Mounted</span>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td class="col-sm-1 middle">
|
||||||
|
<form action="{{ route('admin.servers.view.mounts.toggle', [ 'server' => $server->id, 'mount' => $mount->id ]) }}" method="POST">
|
||||||
|
@method('DELETE')
|
||||||
|
{!! csrf_field() !!}
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-xs btn-danger"><i class="fa fa-times"></i></button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
@endif
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
|
@ -64,7 +76,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('footer-scripts')
|
|
||||||
@parent
|
|
||||||
@endsection
|
|
||||||
|
|
|
@ -123,6 +123,7 @@ Route::group(['prefix' => 'servers'], function () {
|
||||||
Route::post('/view/{server}/build', 'ServersController@updateBuild');
|
Route::post('/view/{server}/build', 'ServersController@updateBuild');
|
||||||
Route::post('/view/{server}/startup', 'ServersController@saveStartup');
|
Route::post('/view/{server}/startup', 'ServersController@saveStartup');
|
||||||
Route::post('/view/{server}/database', 'ServersController@newDatabase');
|
Route::post('/view/{server}/database', 'ServersController@newDatabase');
|
||||||
|
Route::post('/view/{server}/mounts/{mount}', 'ServersController@addMount')->name('admin.servers.view.mounts.toggle');
|
||||||
Route::post('/view/{server}/manage/toggle', 'ServersController@toggleInstall')->name('admin.servers.view.manage.toggle');
|
Route::post('/view/{server}/manage/toggle', 'ServersController@toggleInstall')->name('admin.servers.view.manage.toggle');
|
||||||
Route::post('/view/{server}/manage/suspension', 'ServersController@manageSuspension')->name('admin.servers.view.manage.suspension');
|
Route::post('/view/{server}/manage/suspension', 'ServersController@manageSuspension')->name('admin.servers.view.manage.suspension');
|
||||||
Route::post('/view/{server}/manage/reinstall', 'ServersController@reinstallServer')->name('admin.servers.view.manage.reinstall');
|
Route::post('/view/{server}/manage/reinstall', 'ServersController@reinstallServer')->name('admin.servers.view.manage.reinstall');
|
||||||
|
@ -133,6 +134,7 @@ Route::group(['prefix' => 'servers'], function () {
|
||||||
Route::patch('/view/{server}/database', 'ServersController@resetDatabasePassword');
|
Route::patch('/view/{server}/database', 'ServersController@resetDatabasePassword');
|
||||||
|
|
||||||
Route::delete('/view/{server}/database/{database}/delete', 'ServersController@deleteDatabase')->name('admin.servers.view.database.delete');
|
Route::delete('/view/{server}/database/{database}/delete', 'ServersController@deleteDatabase')->name('admin.servers.view.database.delete');
|
||||||
|
Route::delete('/view/{server}/mounts/{mount}', 'ServersController@deleteMount');
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue