Add function file editing, and move all service file items into database
This commit is contained in:
parent
d585294289
commit
419031e0cd
12 changed files with 298 additions and 404 deletions
|
@ -26,7 +26,6 @@ namespace Pterodactyl\Http\Controllers\Admin;
|
|||
|
||||
use Log;
|
||||
use Alert;
|
||||
use Storage;
|
||||
use Pterodactyl\Models;
|
||||
use Illuminate\Http\Request;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
|
@ -74,6 +73,18 @@ class ServiceController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return function editing view for a service.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function viewFunctions(Request $request, $id)
|
||||
{
|
||||
return view('admin.services.functions', ['service' => Models\Service::findOrFail($id)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle post action for new service.
|
||||
*
|
||||
|
@ -113,11 +124,12 @@ class ServiceController extends Controller
|
|||
public function edit(Request $request, $id)
|
||||
{
|
||||
$repo = new ServiceRepository;
|
||||
$redirectTo = ($request->input('redirect_to')) ? 'admin.services.view.functions' : 'admin.services.view';
|
||||
|
||||
try {
|
||||
if ($request->input('action') !== 'delete') {
|
||||
$repo->update($id, $request->intersect([
|
||||
'name', 'description', 'folder', 'startup',
|
||||
'name', 'description', 'folder', 'startup', 'index_file',
|
||||
]));
|
||||
Alert::success('Service has been updated successfully.')->flash();
|
||||
} else {
|
||||
|
@ -127,7 +139,7 @@ class ServiceController extends Controller
|
|||
return redirect()->route('admin.services');
|
||||
}
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('admin.services.view', $id)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
return redirect()->route($redirectTo, $id)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch (\Exception $ex) {
|
||||
|
@ -135,193 +147,18 @@ class ServiceController extends Controller
|
|||
Alert::danger('An error occurred while attempting to update this service. This error has been logged.')->flash();
|
||||
}
|
||||
|
||||
return redirect()->route('admin.services.view', $id);
|
||||
return redirect()->route($redirectTo, $id);
|
||||
}
|
||||
|
||||
// public function getOption(Request $request, $service, $option)
|
||||
// {
|
||||
// $option = Models\ServiceOption::with('service', 'variables')->findOrFail($option);
|
||||
// $option->setRelation('servers', $option->servers()->with('user')->paginate(25));
|
||||
//
|
||||
// return view('admin.services.options.view', ['option' => $option]);
|
||||
// }
|
||||
//
|
||||
// public function postOption(Request $request, $service, $option)
|
||||
// {
|
||||
// try {
|
||||
// $repo = new ServiceRepository\Option;
|
||||
// $repo->update($option, $request->only([
|
||||
// 'name', 'description', 'tag',
|
||||
// 'executable', 'docker_image', 'startup',
|
||||
// ]));
|
||||
// Alert::success('Option settings successfully updated.')->flash();
|
||||
// } catch (DisplayValidationException $ex) {
|
||||
// return redirect()->route('admin.services.option', [$service, $option])->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
// } catch (\Exception $ex) {
|
||||
// Log::error($ex);
|
||||
// Alert::danger('An error occured while attempting to modify this option.')->flash();
|
||||
// }
|
||||
//
|
||||
// return redirect()->route('admin.services.option', [$service, $option])->withInput();
|
||||
// }
|
||||
//
|
||||
// public function deleteOption(Request $request, $service, $option)
|
||||
// {
|
||||
// try {
|
||||
// $repo = new ServiceRepository\Option;
|
||||
// $repo->delete($option);
|
||||
//
|
||||
// Alert::success('Successfully deleted that option.')->flash();
|
||||
//
|
||||
// return redirect()->route('admin.services.service', $service);
|
||||
// } catch (DisplayException $ex) {
|
||||
// Alert::danger($ex->getMessage())->flash();
|
||||
// } catch (\Exception $ex) {
|
||||
// Log::error($ex);
|
||||
// Alert::danger('An error was encountered while attempting to delete this option.')->flash();
|
||||
// }
|
||||
//
|
||||
// return redirect()->route('admin.services.option', [$service, $option]);
|
||||
// }
|
||||
//
|
||||
// public function postOptionVariable(Request $request, $service, $option, $variable)
|
||||
// {
|
||||
// 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 = [
|
||||
// 'user_viewable' => '0',
|
||||
// 'user_editable' => '0',
|
||||
// 'required' => '0',
|
||||
// ];
|
||||
// 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', [$service, $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', [$service, $option])->withInput();
|
||||
// }
|
||||
//
|
||||
// public function getNewVariable(Request $request, $service, $option)
|
||||
// {
|
||||
// return view('admin.services.options.variable', [
|
||||
// 'option' => Models\ServiceOption::with('service')->findOrFail($option),
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function postNewVariable(Request $request, $service, $option)
|
||||
// {
|
||||
// try {
|
||||
// $repo = new ServiceRepository\Variable;
|
||||
// $repo->create($option, $request->only([
|
||||
// 'name', 'description', 'env_variable',
|
||||
// 'default_value', 'user_viewable',
|
||||
// 'user_editable', 'required', 'regex',
|
||||
// ]));
|
||||
// Alert::success('Successfully added new variable to this option.')->flash();
|
||||
//
|
||||
// return redirect()->route('admin.services.option', [$service, $option]);
|
||||
// } catch (DisplayValidationException $ex) {
|
||||
// return redirect()->route('admin.services.option.variable.new', [$service, $option])->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 add this variable.')->flash();
|
||||
// }
|
||||
//
|
||||
// return redirect()->route('admin.services.option.variable.new', [$service, $option])->withInput();
|
||||
// }
|
||||
//
|
||||
// public function newOption(Request $request, $service)
|
||||
// {
|
||||
// return view('admin.services.options.new', [
|
||||
// 'service' => Models\Service::findOrFail($service),
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function postNewOption(Request $request, $service)
|
||||
// {
|
||||
// try {
|
||||
// $repo = new ServiceRepository\Option;
|
||||
// $id = $repo->create($service, $request->except([
|
||||
// '_token',
|
||||
// ]));
|
||||
// Alert::success('Successfully created new service option.')->flash();
|
||||
//
|
||||
// return redirect()->route('admin.services.option', [$service, $id]);
|
||||
// } catch (DisplayValidationException $ex) {
|
||||
// return redirect()->route('admin.services.option.new', $service)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
// } catch (\Exception $ex) {
|
||||
// Log::error($ex);
|
||||
// Alert::danger('An error occured while attempting to add this service option.')->flash();
|
||||
// }
|
||||
//
|
||||
// return redirect()->route('admin.services.option.new', $service)->withInput();
|
||||
// }
|
||||
//
|
||||
// public function deleteVariable(Request $request, $service, $option, $variable)
|
||||
// {
|
||||
// try {
|
||||
// $repo = new ServiceRepository\Variable;
|
||||
// $repo->delete($variable);
|
||||
// Alert::success('Deleted variable.')->flash();
|
||||
// } catch (DisplayException $ex) {
|
||||
// Alert::danger($ex->getMessage())->flash();
|
||||
// } catch (\Exception $ex) {
|
||||
// Log::error($ex);
|
||||
// Alert::danger('An error occured while attempting to delete that variable.')->flash();
|
||||
// }
|
||||
//
|
||||
// return redirect()->route('admin.services.option', [$service, $option]);
|
||||
// }
|
||||
//
|
||||
// public function getConfiguration(Request $request, $serviceId)
|
||||
// {
|
||||
// $service = Models\Service::findOrFail($serviceId);
|
||||
//
|
||||
// return view('admin.services.config', [
|
||||
// 'service' => $service,
|
||||
// 'contents' => [
|
||||
// 'json' => Storage::get('services/' . $service->file . '/main.json'),
|
||||
// 'index' => Storage::get('services/' . $service->file . '/index.js'),
|
||||
// ],
|
||||
// ]);
|
||||
// }
|
||||
//
|
||||
// public function postConfiguration(Request $request, $serviceId)
|
||||
// {
|
||||
// try {
|
||||
// $repo = new ServiceRepository\Service;
|
||||
// $repo->updateFile($serviceId, $request->only(['file', 'contents']));
|
||||
//
|
||||
// return response('', 204);
|
||||
// } catch (DisplayException $ex) {
|
||||
// return response()->json([
|
||||
// 'error' => $ex->getMessage(),
|
||||
// ], 503);
|
||||
// } catch (\Exception $ex) {
|
||||
// Log::error($ex);
|
||||
//
|
||||
// return response()->json([
|
||||
// 'error' => 'An error occured while attempting to save the file.',
|
||||
// ], 503);
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* Edits function file for a service.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Response\RedirectResponse
|
||||
*/
|
||||
public function editFunctions(Request $request, $id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -403,8 +403,11 @@ class AdminRoutes
|
|||
'uses' => 'Admin\ServiceController@view',
|
||||
]);
|
||||
|
||||
$router->post('/view/{id}', [
|
||||
'uses' => 'Admin\ServiceController@edit',
|
||||
$router->post('/view/{id}', 'Admin\ServiceController@edit');
|
||||
|
||||
$router->get('/view/{id}/functions', [
|
||||
'as' => 'admin.services.view.functions',
|
||||
'uses' => 'Admin\ServiceController@viewFunctions',
|
||||
]);
|
||||
|
||||
$router->delete('/view/{id}', [
|
||||
|
|
|
@ -41,9 +41,52 @@ class Service extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'description', 'folder', 'startup',
|
||||
'name', 'description', 'folder', 'startup', 'index_file',
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the default contents of the index.js file for a service.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function defaultIndexFile()
|
||||
{
|
||||
return <<<EOF
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
const _ = require('lodash');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {}
|
||||
|
||||
module.exports = Service;
|
||||
EOF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all service options associated with this service.
|
||||
*
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace Pterodactyl\Repositories;
|
|||
|
||||
use DB;
|
||||
use Uuid;
|
||||
use Storage;
|
||||
use Validator;
|
||||
use Pterodactyl\Models\Service;
|
||||
use Pterodactyl\Models\ServiceVariable;
|
||||
|
@ -55,7 +54,7 @@ class ServiceRepository
|
|||
throw new DisplayValidationException($validator->errors());
|
||||
}
|
||||
|
||||
$service = DB::transaction(function () use ($data) {
|
||||
return DB::transaction(function () use ($data) {
|
||||
$service = new Service;
|
||||
$service->author = config('pterodactyl.service.author');
|
||||
$service->fill([
|
||||
|
@ -63,6 +62,7 @@ class ServiceRepository
|
|||
'description' => (isset($data['description'])) ? $data['description'] : null,
|
||||
'folder' => $data['folder'],
|
||||
'startup' => (isset($data['startup'])) ? $data['startup'] : null,
|
||||
'index_file' => $service->defaultIndexFile(),
|
||||
])->save();
|
||||
|
||||
// It is possible for an event to return false or throw an exception
|
||||
|
@ -73,12 +73,8 @@ class ServiceRepository
|
|||
throw new \Exception('Service model was created however the response appears to be invalid. Did an event fire wrongly?');
|
||||
}
|
||||
|
||||
Storage::copy('services/.templates/index.js', 'services/' . $service->folder . '/index.js');
|
||||
|
||||
return $service;
|
||||
});
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,6 +93,7 @@ class ServiceRepository
|
|||
'description' => 'sometimes|required|nullable|string',
|
||||
'folder' => 'sometimes|required|regex:/^[\w.-]{1,50}$/',
|
||||
'startup' => 'sometimes|required|nullable|string',
|
||||
'index_file' => 'sometimes|required|string',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -104,15 +101,8 @@ class ServiceRepository
|
|||
}
|
||||
|
||||
return DB::transaction(function () use ($data, $service) {
|
||||
$moveFiles = (isset($data['folder']) && $data['folder'] !== $service->folder);
|
||||
$oldFolder = $service->folder;
|
||||
|
||||
$service->fill($data)->save();
|
||||
|
||||
if ($moveFiles) {
|
||||
Storage::move(sprintf('services/%s/index.js', $oldFolder), sprintf('services/%s/index.js', $service->folder));
|
||||
}
|
||||
|
||||
return $service;
|
||||
});
|
||||
}
|
||||
|
@ -137,41 +127,6 @@ class ServiceRepository
|
|||
}
|
||||
|
||||
$service->delete();
|
||||
Storage::deleteDirectory('services/' . $service->folder);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a service file on the system.
|
||||
*
|
||||
* @param int $id
|
||||
* @param array $data
|
||||
* @return void
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
// public function updateFile($id, array $data)
|
||||
// {
|
||||
// $service = Service::findOrFail($id);
|
||||
//
|
||||
// $validator = Validator::make($data, [
|
||||
// 'file' => 'required|in:index',
|
||||
// 'contents' => 'required|string',
|
||||
// ]);
|
||||
//
|
||||
// if ($validator->fails()) {
|
||||
// throw new DisplayValidationException($validator->errors());
|
||||
// }
|
||||
//
|
||||
// $filepath = 'services/' . $service->folder . '/' . $filename;
|
||||
// $backup = 'services/.bak/' . str_random(12) . '.bak';
|
||||
//
|
||||
// try {
|
||||
// Storage::move($filepath, $backup);
|
||||
// Storage::put($filepath, $data['contents']);
|
||||
// } catch (\Exception $ex) {
|
||||
// Storage::move($backup, $filepath);
|
||||
// throw $ex;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
use Pterodactyl\Models\Service;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class MoveFunctionsFromFileToDatabase extends Migration
|
||||
{
|
||||
|
||||
private $default = <<<EOF
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
const _ = require('lodash');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {}
|
||||
|
||||
module.exports = Service;
|
||||
EOF;
|
||||
|
||||
private $default_mc = <<<EOF
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
const _ = require('lodash');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {
|
||||
onConsole(data) {
|
||||
// Hide the output spam from Bungeecord getting pinged.
|
||||
if (_.endsWith(data, '<-> InitialHandler has connected')) return;
|
||||
return super.onConsole(data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Service;
|
||||
EOF;
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->text('index_file')->after('startup');
|
||||
});
|
||||
|
||||
DB::transaction(function () {
|
||||
Service::where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('folder', '!=', 'minecraft')->update([
|
||||
'index_file' => $this->default,
|
||||
]);
|
||||
|
||||
Service::where('author', 'ptrdctyl-v040-11e6-8b77-86f30ca893d3')->where('folder', 'minecraft')->update([
|
||||
'index_file' => $this->default_mc,
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('services', function (Blueprint $table) {
|
||||
$table->dropColumn('index_file');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
{{-- Copyright (c) 2015 - 2017 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')
|
||||
Services → {{ $service->name }} → Functions
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
<h1>{{ $service->name }}<small>Extend the default daemon functions using this service file.</small></h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('admin.index') }}">Admin</a></li>
|
||||
<li><a href="{{ route('admin.services') }}">Services</a></li>
|
||||
<li><a href="{{ route('admin.services.view', $service->id) }}">{{ $service->name }}</a></li>
|
||||
<li class="active">Functions</li>
|
||||
</ol>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="nav-tabs-custom nav-tabs-floating">
|
||||
<ul class="nav nav-tabs">
|
||||
<li><a href="{{ route('admin.services.view', $service->id) }}">Overview</a></li>
|
||||
<li class="active"><a href="{{ route('admin.services.view.functions', $service->id) }}">Functions</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Functions Control</h3>
|
||||
</div>
|
||||
<form action="{{ route('admin.services.view', $service->id) }}" method="POST">
|
||||
<div class="box-body no-padding">
|
||||
<div id="editor_index"style="height:500px">{{ $service->index_file }}</div>
|
||||
<textarea name="index_file" class="hidden"></textarea>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
{!! csrf_field() !!}
|
||||
<input type="hidden" name="redirect_to" value="functions" />
|
||||
<button type="submit" name="action" value="edit" class="btn btn-sm btn-success pull-right">Save File</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('footer-scripts')
|
||||
@parent
|
||||
{!! Theme::js('js/vendor/ace/ace.js') !!}
|
||||
{!! Theme::js('js/vendor/ace/ext-modelist.js') !!}
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
const Editor = ace.edit('editor_index');
|
||||
const Modelist = ace.require('ace/ext/modelist')
|
||||
|
||||
Editor.setTheme('ace/theme/chrome');
|
||||
Editor.getSession().setMode('ace/mode/javascript');
|
||||
Editor.getSession().setUseWrapMode(true);
|
||||
Editor.setShowPrintMargin(false);
|
||||
|
||||
$('form').on('submit', function (e) {
|
||||
$('textarea[name="index_file"]').val(Editor.getValue());
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
|
@ -20,7 +20,7 @@
|
|||
@extends('layouts.admin')
|
||||
|
||||
@section('title')
|
||||
Services: {{ $service->name }}
|
||||
Services → {{ $service->name }}
|
||||
@endsection
|
||||
|
||||
@section('content-header')
|
||||
|
@ -33,6 +33,16 @@
|
|||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="nav-tabs-custom nav-tabs-floating">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="{{ route('admin.services.view', $service->id) }}">Overview</a></li>
|
||||
<li><a href="{{ route('admin.services.view.functions', $service->id) }}">Functions</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form action="{{ route('admin.services.view', $service->id) }}" method="POST">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {}
|
||||
|
||||
module.exports = Service;
|
|
@ -1,38 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
const _ = require('lodash');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {
|
||||
onConsole(data) {
|
||||
// Hide the output spam from Bungeecord getting pinged.
|
||||
if (_.endsWith(data, '<-> InitialHandler has connected')) return;
|
||||
return super.onConsole(data);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Service;
|
|
@ -1,31 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {}
|
||||
|
||||
module.exports = Service;
|
|
@ -1,31 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {}
|
||||
|
||||
module.exports = Service;
|
|
@ -1,31 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Pterodactyl - Daemon
|
||||
* Copyright (c) 2015 - 2017 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.
|
||||
*/
|
||||
const rfr = require('rfr');
|
||||
|
||||
const Core = rfr('src/services/index.js');
|
||||
|
||||
class Service extends Core {}
|
||||
|
||||
module.exports = Service;
|
Loading…
Reference in a new issue