mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-22 09:02:28 +01:00
Really basic initial implementation of service management
This commit is contained in:
parent
5500dcc4d5
commit
ad5e253a07
145
app/Http/Controllers/Admin/ServiceController.php
Normal file
145
app/Http/Controllers/Admin/ServiceController.php
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
namespace Pterodactyl\Http\Controllers\Admin;
|
||||
|
||||
use Alert;
|
||||
use DB;
|
||||
use Log;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Repositories\ServiceRepository;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
use Pterodactyl\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function getIndex(Request $request)
|
||||
{
|
||||
return view('admin.services.index', [
|
||||
'services' => Models\Service::all()
|
||||
]);
|
||||
}
|
||||
|
||||
public function getNew(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function postNew(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function getService(Request $request, $service)
|
||||
{
|
||||
return view('admin.services.view', [
|
||||
'service' => Models\Service::findOrFail($service),
|
||||
'options' => Models\ServiceOptions::select(
|
||||
'service_options.*',
|
||||
DB::raw('(SELECT COUNT(*) FROM servers WHERE servers.option = service_options.id) as c_servers')
|
||||
)->where('parent_service', $service)->get()
|
||||
]);
|
||||
}
|
||||
|
||||
public function postService(Request $request, $service)
|
||||
{
|
||||
try {
|
||||
$repo = new ServiceRepository\Service;
|
||||
$repo->update($service, $request->except([
|
||||
'_token'
|
||||
]));
|
||||
Alert::success('Successfully updated this service.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.services.service', $service)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An error occurred while attempting to update this service.')->flash();
|
||||
}
|
||||
return redirect()->route('admin.services.service', $service)->withInput();
|
||||
}
|
||||
|
||||
public function getOption(Request $request, $option)
|
||||
{
|
||||
$opt = Models\ServiceOptions::findOrFail($option);
|
||||
return view('admin.services.options.view', [
|
||||
'service' => Models\Service::findOrFail($opt->parent_service),
|
||||
'option' => $opt,
|
||||
'variables' => Models\ServiceVariables::where('option_id', $option)->get(),
|
||||
'servers' => Models\Server::select('servers.*', 'users.email as a_ownerEmail')
|
||||
->join('users', 'users.id', '=', 'servers.owner')
|
||||
->where('option', $option)
|
||||
->paginate(10)
|
||||
]);
|
||||
}
|
||||
|
||||
public function postOption(Request $request, $option)
|
||||
{
|
||||
// editing option
|
||||
}
|
||||
|
||||
public function postOptionVariable(Request $request, $option, $variable)
|
||||
{
|
||||
if ($variable === 'new') {
|
||||
// adding new variable
|
||||
} else {
|
||||
try {
|
||||
$repo = new ServiceRepository\Variable;
|
||||
|
||||
// Because of the way old() works on the display side we prefix all of the variables with thier ID
|
||||
// We need to remove that prefix here since the repo doesn't want it.
|
||||
$data = [];
|
||||
foreach($request->except(['_token']) as $id => $val) {
|
||||
$data[str_replace($variable.'_', '', $id)] = $val;
|
||||
}
|
||||
$repo->update($variable, $data);
|
||||
Alert::success('Successfully updated variable.')->flash();
|
||||
} catch (DisplayValidationException $ex) {
|
||||
$data = [];
|
||||
foreach(json_decode($ex->getMessage(), true) as $id => $val) {
|
||||
$data[$variable.'_'.$id] = $val;
|
||||
}
|
||||
return redirect()->route('admin.services.option', $option)->withErrors((object) $data)->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An error occurred while attempting to update this service.')->flash();
|
||||
}
|
||||
return redirect()->route('admin.services.option', $option)->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -334,6 +334,44 @@ class AdminRoutes {
|
||||
]);
|
||||
});
|
||||
|
||||
// Service Routes
|
||||
$router->group([
|
||||
'prefix' => 'admin/services',
|
||||
'middleware' => [
|
||||
'auth',
|
||||
'admin',
|
||||
'csrf'
|
||||
]
|
||||
], function () use ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'admin.services',
|
||||
'uses' => 'Admin\ServiceController@getIndex'
|
||||
]);
|
||||
|
||||
$router->get('/service/{id}', [
|
||||
'as' => 'admin.services.service',
|
||||
'uses' => 'Admin\ServiceController@getService'
|
||||
]);
|
||||
|
||||
$router->post('/service/{id}', [
|
||||
'uses' => 'Admin\ServiceController@postService'
|
||||
]);
|
||||
|
||||
$router->get('/option/{id}', [
|
||||
'as' => 'admin.services.option',
|
||||
'uses' => 'Admin\ServiceController@getOption'
|
||||
]);
|
||||
|
||||
$router->post('/option/{id}', [
|
||||
'uses' => 'Admin\ServiceController@postOption'
|
||||
]);
|
||||
|
||||
$router->post('/option/{option}/{variable}', [
|
||||
'as' => 'admin.services.option.variable',
|
||||
'uses' => 'Admin\ServiceController@postOptionVariable'
|
||||
]);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,4 +35,11 @@ class Service extends Model
|
||||
*/
|
||||
protected $table = 'services';
|
||||
|
||||
/**
|
||||
* Fields that are not mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,13 @@ class ServiceOptions extends Model
|
||||
*/
|
||||
protected $table = 'service_options';
|
||||
|
||||
/**
|
||||
* Fields that are not mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* Cast values to correct type.
|
||||
*
|
||||
|
@ -35,6 +35,13 @@ class ServiceVariables extends Model
|
||||
*/
|
||||
protected $table = 'service_variables';
|
||||
|
||||
/**
|
||||
* Fields that are not mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $guarded = ['id', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* Cast values to correct type.
|
||||
*
|
||||
|
48
app/Repositories/ServiceRepository/Option.php
Normal file
48
app/Repositories/ServiceRepository/Option.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
namespace Pterodactyl\Repositories\ServiceRepository;
|
||||
|
||||
use DB;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class Option
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update($id, array $data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
63
app/Repositories/ServiceRepository/Service.php
Normal file
63
app/Repositories/ServiceRepository/Service.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
namespace Pterodactyl\Repositories\ServiceRepository;
|
||||
|
||||
use DB;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class Service
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update($id, array $data)
|
||||
{
|
||||
$service = Models\Service::findOrFail($id);
|
||||
|
||||
$validator = Validator::make($data, [
|
||||
'name' => 'sometimes|required|string|min:1|max:255',
|
||||
'description' => 'sometimes|required|string',
|
||||
'file' => 'sometimes|required|regex:/^[\w.-]{1,50}$/',
|
||||
'executable' => 'sometimes|required|max:255|regex:/^(.*)$/',
|
||||
'startup' => 'sometimes|required|string'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
throw new DisplayValidationException($validator->errors());
|
||||
}
|
||||
|
||||
$service->fill($data);
|
||||
$service->save();
|
||||
}
|
||||
|
||||
}
|
77
app/Repositories/ServiceRepository/Variable.php
Normal file
77
app/Repositories/ServiceRepository/Variable.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
namespace Pterodactyl\Repositories\ServiceRepository;
|
||||
|
||||
use DB;
|
||||
use Validator;
|
||||
|
||||
use Pterodactyl\Models;
|
||||
use Pterodactyl\Services\UuidService;
|
||||
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Exceptions\DisplayValidationException;
|
||||
|
||||
class Variable
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function update($id, array $data)
|
||||
{
|
||||
$variable = Models\ServiceVariables::findOrFail($id);
|
||||
|
||||
$validator = Validator::make($data, [
|
||||
'name' => 'sometimes|required|string|min:1|max:255',
|
||||
'description' => 'sometimes|required|string',
|
||||
'env_variable' => 'sometimes|required|regex:/^[\w]{1,255}$/',
|
||||
'default_value' => 'sometimes|required|string',
|
||||
'user_viewable' => 'sometimes|required|numeric|size:1',
|
||||
'user_editable' => 'sometimes|required|numeric|size:1',
|
||||
'required' => 'sometimes|required|numeric|size:1',
|
||||
'regex' => 'sometimes|required|string|min:1'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
throw new DisplayValidationException($validator->errors());
|
||||
}
|
||||
|
||||
$data['default_value'] = (isset($data['default_value'])) ? $data['default_value'] : $variable->default_value;
|
||||
$data['regex'] = (isset($data['regex'])) ? $data['regex'] : $variable->regex;
|
||||
|
||||
if (!preg_match($data['regex'], $data['default_value'])) {
|
||||
throw new DisplayException('The default value you entered cannot violate the regex requirements.');
|
||||
}
|
||||
|
||||
$data['user_viewable'] = (isset($data['user_viewable']) && in_array((int) $data['user_viewable'], [0, 1])) ? $data['user_viewable'] : $variable->user_viewable;
|
||||
$data['user_editable'] = (isset($data['user_editable']) && in_array((int) $data['user_editable'], [0, 1])) ? $data['user_editable'] : $variable->user_editable;
|
||||
$data['required'] = (isset($data['required']) && in_array((int) $data['required'], [0, 1])) ? $data['required'] : $variable->required;
|
||||
|
||||
$variable->fill($data);
|
||||
$variable->save();
|
||||
}
|
||||
|
||||
}
|
55
resources/views/admin/services/index.blade.php
Normal file
55
resources/views/admin/services/index.blade.php
Normal file
@ -0,0 +1,55 @@
|
||||
{{-- Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com> --}}
|
||||
|
||||
{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}}
|
||||
{{-- of this software and associated documentation files (the "Software"), to deal --}}
|
||||
{{-- in the Software without restriction, including without limitation the rights --}}
|
||||
{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}}
|
||||
{{-- copies of the Software, and to permit persons to whom the Software is --}}
|
||||
{{-- furnished to do so, subject to the following conditions: --}}
|
||||
|
||||
{{-- The above copyright notice and this permission notice shall be included in all --}}
|
||||
{{-- copies or substantial portions of the Software. --}}
|
||||
|
||||
{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}}
|
||||
{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}}
|
||||
{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}}
|
||||
{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}}
|
||||
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
|
||||
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
|
||||
{{-- SOFTWARE. --}}
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Manage Services
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="col-md-12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/admin">Admin Control</a></li>
|
||||
<li class="active">Services</li>
|
||||
</ul>
|
||||
<h3 class="nopad">Server Services</h3><hr />
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Service Type</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($services as $service)
|
||||
<tr>
|
||||
<td><a href="{{ route('admin.services.service', $service->id) }}">{{ $service->name }}</a></td>
|
||||
<td>{!! $service->description !!}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#sidebar_links').find("a[href='/admin/services']").addClass('active');
|
||||
});
|
||||
</script>
|
||||
@endsection
|
0
resources/views/admin/services/new.blade.php
Normal file
0
resources/views/admin/services/new.blade.php
Normal file
140
resources/views/admin/services/options/view.blade.php
Normal file
140
resources/views/admin/services/options/view.blade.php
Normal file
@ -0,0 +1,140 @@
|
||||
{{-- Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com> --}}
|
||||
|
||||
{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}}
|
||||
{{-- of this software and associated documentation files (the "Software"), to deal --}}
|
||||
{{-- in the Software without restriction, including without limitation the rights --}}
|
||||
{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}}
|
||||
{{-- copies of the Software, and to permit persons to whom the Software is --}}
|
||||
{{-- furnished to do so, subject to the following conditions: --}}
|
||||
|
||||
{{-- The above copyright notice and this permission notice shall be included in all --}}
|
||||
{{-- copies or substantial portions of the Software. --}}
|
||||
|
||||
{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}}
|
||||
{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}}
|
||||
{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}}
|
||||
{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}}
|
||||
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
|
||||
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
|
||||
{{-- SOFTWARE. --}}
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Manage Services
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="col-md-12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/admin">Admin Control</a></li>
|
||||
<li><a href="/admin/services">Services</a></li>
|
||||
<li><a href="{{ route('admin.services.service', $service->id) }}">{{ $service->name }}</a></li>
|
||||
<li class="active">{{ $option->name }}</li>
|
||||
</ul>
|
||||
<h3 class="nopad">Servers</h3>
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Owner</th>
|
||||
<th>Connection</th>
|
||||
<th>Updated</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($servers as $server)
|
||||
<tr>
|
||||
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
|
||||
<td><a href="{{ route('admin.accounts.view', $server->owner) }}">{{ $server->a_ownerEmail }}</a></td>
|
||||
<td><code>{{ $server->ip }}:{{ $server->port }}</code></td>
|
||||
<td>{{ $server->updated_at }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 class="nopad">Option Variables</h3><hr />
|
||||
@foreach($variables as $variable)
|
||||
<form action="{{ route('admin.services.option.variable', [ 'option' => $option->id, 'variable' => $variable->id ]) }}" method="POST">
|
||||
<div class="well">
|
||||
<div class="row">
|
||||
<div class="col-md-6 form-group">
|
||||
<label class="control-label">Variable Name:</label>
|
||||
<div>
|
||||
<input type="text" name="{{ $variable->id }}_name" class="form-control" value="{{ old($variable->id.'_name', $variable->name) }}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 form-group">
|
||||
<label class="control-label">Variable Description:</label>
|
||||
<div>
|
||||
<textarea name="{{ $variable->id }}_description" class="form-control" rows="2">{{ old($variable->id.'_description', $variable->description) }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 form-group">
|
||||
<label class="control-label">Environment Variable:</label>
|
||||
<div>
|
||||
<input type="text" name="{{ $variable->id }}_env_variable" id="env_var" class="form-control" value="{{ old($variable->id.'_env_variable', $variable->env_variable) }}" />
|
||||
<p class="text-muted"><small>Accessed in startup by using <code>{{{{ $variable->env_variable }}}}</code> prameter.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 form-group">
|
||||
<label class="control-label">Default Value:</label>
|
||||
<div>
|
||||
<input type="text" name="{{ $variable->id }}_default_value" class="form-control" value="{{ old($variable->id.'_default_value', $variable->default_value) }}" />
|
||||
<p class="text-muted"><small>The default value to use for this field.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 form-group">
|
||||
<label class="control-label">Regex:</label>
|
||||
<div>
|
||||
<input type="text" name="{{ $variable->id }}_regex" class="form-control" value="{{ old($variable->id.'_regex', $variable->regex) }}" />
|
||||
<p class="text-muted"><small>Regex code to use when verifying the contents of the field.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row fuelux">
|
||||
<div class="col-md-4">
|
||||
<div class="checkbox highlight">
|
||||
<label class="checkbox-custom highlight" data-initialize="checkbox">
|
||||
<input class="sr-only" name="{{ $variable->id }}_user_viewable" type="checkbox" value="1" @if((int) old($variable->id.'_user_viewable', $variable->user_viewable) === 1)checked="checked"@endif> <strong>User Viewable</strong>
|
||||
<p class="text-muted"><small>Can users view this variable?</small><p>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="checkbox highlight">
|
||||
<label class="checkbox-custom highlight" data-initialize="checkbox">
|
||||
<input class="sr-only" name="{{ $variable->id }}_user_editable" type="checkbox" value="1" @if((int) old($variable->id.'_user_editable', $variable->user_editable) === 1)checked="checked"@endif> <strong>User Editable</strong>
|
||||
<p class="text-muted"><small>Can users edit this variable?</small><p>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="checkbox highlight">
|
||||
<label class="checkbox-custom highlight" data-initialize="checkbox">
|
||||
<input class="sr-only" name="{{ $variable->id }}_required" type="checkbox" value="1" @if((int) old($variable->id.'_required', $variable->required) === 1)checked="checked"@endif> <strong>Required</strong>
|
||||
<p class="text-muted"><small>This this variable required?</small><p>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" class="btn btn-sm btn-success pull-right" value="Update Variable" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endforeach
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#sidebar_links').find("a[href='/admin/services']").addClass('active');
|
||||
$('#env_var').on('keyup', function () {
|
||||
$(this).parent().find('code').html('{{' + escape($(this).val()) + '}}');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
118
resources/views/admin/services/view.blade.php
Normal file
118
resources/views/admin/services/view.blade.php
Normal file
@ -0,0 +1,118 @@
|
||||
{{-- Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com> --}}
|
||||
|
||||
{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}}
|
||||
{{-- of this software and associated documentation files (the "Software"), to deal --}}
|
||||
{{-- in the Software without restriction, including without limitation the rights --}}
|
||||
{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}}
|
||||
{{-- copies of the Software, and to permit persons to whom the Software is --}}
|
||||
{{-- furnished to do so, subject to the following conditions: --}}
|
||||
|
||||
{{-- The above copyright notice and this permission notice shall be included in all --}}
|
||||
{{-- copies or substantial portions of the Software. --}}
|
||||
|
||||
{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}}
|
||||
{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}}
|
||||
{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}}
|
||||
{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}}
|
||||
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
|
||||
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
|
||||
{{-- SOFTWARE. --}}
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Manage Services
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="col-md-12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/admin">Admin Control</a></li>
|
||||
<li><a href="/admin/services">Services</a></li>
|
||||
<li class="active">{{ $service->name }}</li>
|
||||
</ul>
|
||||
<h3 class="nopad">Service Options</h3><hr />
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Option Name</th>
|
||||
<th>Description</th>
|
||||
<th>Docker Image</th>
|
||||
<th>Tag</th>
|
||||
<th class="text-center">Servers</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($options as $option)
|
||||
<tr>
|
||||
<td><a href="{{ route('admin.services.option', $option->id) }}">{{ $option->name }}</a></td>
|
||||
<td>{!! $option->description !!}</td>
|
||||
<td><code>{{ $option->docker_image }}</code></td>
|
||||
<td><code>{{ $option->tag }}</code></td>
|
||||
<td class="text-center">{{ $option->c_servers }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="well">
|
||||
<form action="{{ route('admin.services.service', $service->id) }}" method="POST">
|
||||
<div class="row">
|
||||
<div class="col-md-6 form-group">
|
||||
<label class="control-label">Service Name:</label>
|
||||
<div>
|
||||
<input type="text" name="name" class="form-control" value="{{ old('name', $service->name) }}" />
|
||||
<p class="text-muted"><small>This should be a descriptive category name that emcompasses all of the options within the service.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 form-group">
|
||||
<label class="control-label">Service Description:</label>
|
||||
<div>
|
||||
<textarea name="description" class="form-control" rows="4">{{ old('description', $service->description) }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 form-group">
|
||||
<label class="control-label">Service Configuration File:</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">/src/services/</span>
|
||||
<input type="text" name="file" class="form-control" value="{{ old('file', $service->file) }}" />
|
||||
<span class="input-group-addon">/index.js</span>
|
||||
</div>
|
||||
<p class="text-muted"><small>This should be the name of the folder on the daemon that contains all of the service logic. Changing this can have unintended effects on servers or causes errors to occur.</small></p>
|
||||
</div>
|
||||
<div class="col-md-6 form-group">
|
||||
<label class="control-label">Display Executable:</label>
|
||||
<div>
|
||||
<input type="text" name="executable" class="form-control" value="{{ old('executable', $service->executable) }}" />
|
||||
</div>
|
||||
<p class="text-muted"><small>Changing this has no effect on operation of the daemon, it is simply used for display purposes on the panel. This can be changed per-option.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 form-group">
|
||||
<label class="control-label">Default Startup:</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon" id="disp_exec">{{ $service->executable }}</span>
|
||||
<input type="text" name="startup" class="form-control" value="{{ old('startup', $service->startup) }}" />
|
||||
</div>
|
||||
<p class="text-muted"><small>This is the default startup that will be used for all servers created using this service. This can be changed per-option.</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{!! csrf_field() !!}
|
||||
<input type="submit" class="btn btn-sm btn-primary" value="Save Changes" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#sidebar_links').find("a[href='/admin/services']").addClass('active');
|
||||
$('input[name="executable"]').on('keyup', function() {
|
||||
$("#disp_exec").html(escape($(this).val()));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
Loading…
Reference in New Issue
Block a user