Add initial pack creation and overview pages

This commit is contained in:
Dane Everitt 2017-03-14 21:18:36 -04:00
parent 2d90187c83
commit 50558db7c3
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
21 changed files with 944 additions and 487 deletions

View File

@ -27,179 +27,124 @@ namespace Pterodactyl\Http\Controllers\Admin;
use Log;
use Alert;
use Storage;
use Pterodactyl\Models;
use Illuminate\Http\Request;
use Pterodactyl\Models\Pack;
use Pterodactyl\Models\Service;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Repositories\ServiceRepository\Pack;
use Pterodactyl\Repositories\PackRepository;
use Pterodactyl\Exceptions\DisplayValidationException;
class PackController extends Controller
{
public function __construct()
/**
* Display listing of all packs on the system.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function index(Request $request)
{
//
$packs = Pack::with('option')->withCount('servers');
if (! is_null($request->input('query'))) {
$packs->search($request->input('query'));
}
return view('admin.packs.index', ['packs' => $packs->paginate(50)]);
}
public function listAll(Request $request)
/**
* Display new pack creation form.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function new(Request $request)
{
return view('admin.services.packs.index', ['services' => Models\Service::all()]);
}
public function listByOption(Request $request, $id)
{
return view('admin.services.packs.byoption', [
'option' => Models\ServiceOption::with('service', 'packs')->findOrFail($id),
return view('admin.packs.new', [
'services' => Service::with('options')->get(),
]);
}
public function listByService(Request $request, $id)
/**
* Display new pack creation modal for use with template upload.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function newTemplate(Request $request)
{
return view('admin.services.packs.byservice', [
'service' => Models\Service::with('options', 'options.packs')->findOrFail($id),
]);
}
public function new(Request $request, $opt = null)
{
return view('admin.services.packs.new', [
'services' => Models\Service::with('options')->get(),
return view('admin.packs.modal', [
'services' => Service::with('options')->get(),
]);
}
public function create(Request $request)
{
$repo = new PackRepository;
try {
$repo = new Pack;
$pack = $repo->create($request->only([
'name', 'version', 'description',
'option', 'selectable', 'visible',
'file_upload',
]));
Alert::success('Successfully created new service!')->flash();
return redirect()->route('admin.services.packs.edit', $pack->id)->withInput();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.packs.new', $request->input('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 occured while attempting to add a new service pack.')->flash();
}
return redirect()->route('admin.services.packs.new', $request->input('option'))->withInput();
}
public function edit(Request $request, $id)
{
$pack = Models\ServicePack::with('option.service')->findOrFail($id);
return view('admin.services.packs.edit', [
'pack' => $pack,
'services' => Models\Service::all()->load('options'),
'files' => Storage::files('packs/' . $pack->uuid),
]);
}
public function update(Request $request, $id)
{
if (! is_null($request->input('action_delete'))) {
try {
$repo = new Pack;
$repo->delete($id);
Alert::success('The requested service pack has been deleted from the system.')->flash();
return redirect()->route('admin.services.packs');
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to delete this pack.')->flash();
}
return redirect()->route('admin.services.packs.edit', $id);
} else {
try {
$repo = new Pack;
$repo->update($id, $request->only([
'name', 'version', 'description',
'option', 'selectable', 'visible',
if ($request->input('action') === 'from_template') {
$pack = $repo->createWithTemplate($request->intersect(['option_id', 'file_upload']));
} else {
$pack = $repo->create($request->intersect([
'name', 'description', 'version', 'option_id',
'selectable', 'visible', 'locked', 'file_upload',
]));
Alert::success('Service pack has been successfully updated.')->flash();
} catch (DisplayValidationException $ex) {
return redirect()->route('admin.services.packs.edit', $id)->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to add edit this pack.')->flash();
}
Alert::success('Pack successfully created on the system.')->flash();
return redirect()->route('admin.services.packs.edit', $id);
}
}
public function export(Request $request, $id, $files = false)
{
$pack = Models\ServicePack::findOrFail($id);
$json = [
'name' => $pack->name,
'version' => $pack->version,
'description' => $pack->dscription,
'selectable' => (bool) $pack->selectable,
'visible' => (bool) $pack->visible,
];
$filename = tempnam(sys_get_temp_dir(), 'pterodactyl_');
if ((bool) $files) {
$zip = new \ZipArchive;
if (! $zip->open($filename, \ZipArchive::CREATE)) {
abort(503, 'Unable to open file for writing.');
}
$files = Storage::files('packs/' . $pack->uuid);
foreach ($files as $file) {
$zip->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file)));
}
$zip->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT));
$zip->close();
return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true);
} else {
$fp = fopen($filename, 'a+');
fwrite($fp, json_encode($json, JSON_PRETTY_PRINT));
fclose($fp);
return response()->download($filename, 'pack-' . $pack->name . '.json', [
'Content-Type' => 'application/json',
])->deleteFileAfterSend(true);
}
}
public function uploadForm(Request $request, $for = null)
{
return view('admin.services.packs.upload', [
'services' => Models\Service::all()->load('options'),
]);
}
public function postUpload(Request $request)
{
try {
$repo = new Pack;
$pack = $repo->createWithTemplate($request->only(['option', 'file_upload']));
Alert::success('Successfully created new service!')->flash();
return redirect()->route('admin.services.packs.edit', $pack->id)->withInput();
} catch (DisplayValidationException $ex) {
return redirect()->back()->withErrors(json_decode($ex->getMessage()))->withInput();
return redirect()->route('admin.packs.view', $pack->id);
} catch(DisplayValidationException $ex) {
return redirect()->route('admin.packs.new')->withErrors(json_decode($ex->getMessage()))->withInput();
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to add a new service pack.')->flash();
Alert::danger('An error occured while attempting to add a new service pack. This error has been logged.')->flash();
}
return redirect()->back();
return redirect()->route('admin.packs.new')->withInput();
}
// public function export(Request $request, $id, $files = false)
// {
// $pack = Models\Pack::findOrFail($id);
// $json = [
// 'name' => $pack->name,
// 'version' => $pack->version,
// 'description' => $pack->dscription,
// 'selectable' => (bool) $pack->selectable,
// 'visible' => (bool) $pack->visible,
// ];
// $filename = tempnam(sys_get_temp_dir(), 'pterodactyl_');
// if ((bool) $files) {
// $zip = new \ZipArchive;
// if (! $zip->open($filename, \ZipArchive::CREATE)) {
// abort(503, 'Unable to open file for writing.');
// }
// $files = Storage::files('packs/' . $pack->uuid);
// foreach ($files as $file) {
// $zip->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file)));
// }
// $zip->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT));
// $zip->close();
// return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true);
// } else {
// $fp = fopen($filename, 'a+');
// fwrite($fp, json_encode($json, JSON_PRETTY_PRINT));
// fclose($fp);
// return response()->download($filename, 'pack-' . $pack->name . '.json', [
// 'Content-Type' => 'application/json',
// ])->deleteFileAfterSend(true);
// }
// }
}

View File

@ -47,7 +47,7 @@ class PackController extends Controller
*/
public function pull(Request $request, $uuid)
{
$pack = Models\ServicePack::where('uuid', $uuid)->first();
$pack = Models\Pack::where('uuid', $uuid)->first();
if (! $pack) {
return response()->json(['error' => 'No such pack.'], 404);
@ -68,7 +68,7 @@ class PackController extends Controller
*/
public function hash(Request $request, $uuid)
{
$pack = Models\ServicePack::where('uuid', $uuid)->first();
$pack = Models\Pack::where('uuid', $uuid)->first();
if (! $pack) {
return response()->json(['error' => 'No such pack.'], 404);

View File

@ -453,43 +453,27 @@ class AdminRoutes
'csrf',
],
], function () use ($router) {
// $router->get('/new/{option?}', [
// 'as' => 'admin.packs.new',
// 'uses' => 'Admin\PackController@new',
// ]);
// $router->post('/new', [
// 'uses' => 'Admin\PackController@create',
// ]);
// $router->get('/upload/{option?}', [
// 'as' => 'admin.packs.uploadForm',
// 'uses' => 'Admin\PackController@uploadForm',
// ]);
// $router->post('/upload', [
// 'uses' => 'Admin\PackController@postUpload',
// ]);
$router->get('/', [
'as' => 'admin.packs',
'uses' => 'Admin\PackController@listAll',
'uses' => 'Admin\PackController@index',
]);
$router->get('/new', [
'as' => 'admin.packs.new',
'uses' => 'Admin\PackController@new',
]);
$router->post('/new', 'Admin\PackController@create');
$router->get('/new/template', [
'as' => 'admin.packs.new.template',
'uses' => 'Admin\PackController@newTemplate',
]);
$router->get('/view/{id}', [
'as' => 'admin.packs.view',
'uses' => 'Admin\PackController@view',
]);
// $router->get('/for/option/{option}', [
// 'as' => 'admin.packs.option',
// 'uses' => 'Admin\PackController@listByOption',
// ]);
// $router->get('/for/service/{service}', [
// 'as' => 'admin.packs.service',
// 'uses' => 'Admin\PackController@listByService',
// ]);
// $router->get('/edit/{pack}', [
// 'as' => 'admin.packs.edit',
// 'uses' => 'Admin\PackController@edit',
// ]);
// $router->post('/edit/{pack}', [
// 'uses' => 'Admin\PackController@update',
// ]);
// $router->get('/edit/{pack}/export/{archive?}', [
// 'as' => 'admin.packs.export',
// 'uses' => 'Admin\PackController@export',
// ]);
});
}
}

100
app/Models/Pack.php Normal file
View File

@ -0,0 +1,100 @@
<?php
/**
* Pterodactyl - Panel
* 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.
*/
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
use Nicolaslopezj\Searchable\SearchableTrait;
class Pack extends Model
{
use SearchableTrait;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'packs';
/**
* Fields that are mass assignable.
*
* @var array
*/
protected $fillable = [
'option_id', 'name', 'version', 'description', 'selectable', 'visible', 'locked',
];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'option_id' => 'integer',
'selectable' => 'boolean',
'visible' => 'boolean',
'locked' => 'boolean',
];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'packs.name' => 10,
'packs.uuid' => 8,
'service_options.name' => 6,
'service_options.tag' => 5,
'service_options.docker_image' => 5,
'packs.version' => 2,
],
'joins' => [
'service_options' => ['packs.option_id', 'service_options.id'],
],
];
/**
* Gets option associated with a service pack.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function option()
{
return $this->belongsTo(ServiceOption::class);
}
/**
* Gets servers associated with a pack.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function servers()
{
return $this->hasMany(Server::class);
}
}

View File

@ -65,43 +65,50 @@ class Server extends Model
*/
protected $guarded = ['id', 'installed', 'created_at', 'updated_at', 'deleted_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node_id' => 'integer',
'suspended' => 'integer',
'owner_id' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'allocation_id' => 'integer',
'service_id' => 'integer',
'option_id' => 'integer',
'pack_id' => 'integer',
'installed' => 'integer',
];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'node_id' => 'integer',
'suspended' => 'integer',
'owner_id' => 'integer',
'memory' => 'integer',
'swap' => 'integer',
'disk' => 'integer',
'io' => 'integer',
'cpu' => 'integer',
'oom_disabled' => 'integer',
'allocation_id' => 'integer',
'service_id' => 'integer',
'option_id' => 'integer',
'pack_id' => 'integer',
'installed' => 'integer',
];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'servers.name' => 10,
'servers.username' => 10,
'servers.uuidShort' => 9,
'servers.uuid' => 8,
'users.email' => 6,
'users.username' => 6,
'nodes.name' => 2,
],
'joins' => [
'columns' => [
'servers.name' => 10,
'servers.username' => 10,
'servers.uuidShort' => 9,
'servers.uuid' => 8,
'packs.name' => 7,
'users.email' => 6,
'users.username' => 6,
'nodes.name' => 2,
],
'joins' => [
'packs' => ['packs.id', 'servers.pack_id'],
'users' => ['users.id', 'servers.owner_id'],
'nodes' => ['nodes.id', 'servers.node_id'],
],
];
],
];
/**
* Returns a single server specified by UUID.
@ -236,11 +243,11 @@ class Server extends Model
/**
* Gets information for the pack associated with this server.
*
* @return \Illuminate\Database\Eloquent\Relations\HasOne
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function pack()
{
return $this->hasOne(ServicePack::class, 'id', 'pack_id');
return $this->belongsTo(Pack::class);
}
/**

View File

@ -105,7 +105,7 @@ EOF;
public function packs()
{
return $this->hasManyThrough(
'Pterodactyl\Models\ServicePack', 'Pterodactyl\Models\ServiceOption',
'Pterodactyl\Models\Pack', 'Pterodactyl\Models\ServiceOption',
'service_id', 'option_id'
);
}

View File

@ -99,6 +99,6 @@ class ServiceOption extends Model
*/
public function packs()
{
return $this->hasMany(ServicePack::class, 'option_id');
return $this->hasMany(Pack::class, 'option_id');
}
}

View File

@ -1,69 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* 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.
*/
namespace Pterodactyl\Models;
use Illuminate\Database\Eloquent\Model;
class ServicePack extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'service_packs';
/**
* Fields that are not mass assignable.
*
* @var array
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'option' => 'integer',
'build_memory' => 'integer',
'build_swap' => 'integer',
'build_cpu' => 'integer',
'build_io' => 'integer',
'selectable' => 'boolean',
'visible' => 'boolean',
];
/**
* Gets option associated with a service pack.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function option()
{
return $this->belongsTo(ServiceOption::class);
}
}

View File

@ -88,6 +88,11 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
*/
protected $hidden = ['password', 'remember_token', 'totp_secret'];
/**
* Parameters for search querying.
*
* @var array
*/
protected $searchable = [
'columns' => [
'email' => 10,

View File

@ -28,31 +28,36 @@ use DB;
use Uuid;
use Storage;
use Validator;
use Pterodactyl\Models;
use Pterodactyl\Models\Pack;
use Pterodactyl\Services\UuidService;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Exceptions\DisplayValidationException;
class PackRepository
{
public function __construct()
{
//
}
/**
* Creates a new pack on the system.
*
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function create(array $data)
{
$validator = Validator::make($data, [
'name' => 'required|string',
'version' => 'required|string',
'description' => 'sometimes|nullable|string',
'option' => 'required|exists:service_options,id',
'selectable' => 'sometimes|boolean',
'visible' => 'sometimes|boolean',
'selectable' => 'sometimes|required|boolean',
'visible' => 'sometimes|required|boolean',
'locked' => 'sometimes|required|boolean',
'option_id' => 'required|exists:service_options,id',
]);
if ($validator->fails()) {
throw new DisplayValidationException($validator->errors());
throw new DisplayValidationException(json_encode($validator->errors()));
}
if (isset($data['file_upload'])) {
@ -65,33 +70,42 @@ class PackRepository
}
}
DB::beginTransaction();
try {
$uuid = new UuidService;
$pack = Models\ServicePack::create([
'option_id' => $data['option'],
'uuid' => $uuid->generate('service_packs', 'uuid'),
return DB::transaction(function () use ($data) {
$uuid = new UuidService();
$pack = new Pack;
$pack->uuid = $uuid->generate('packs', 'uuid');
$pack->fill([
'option_id' => $data['option_id'],
'name' => $data['name'],
'version' => $data['version'],
'description' => (empty($data['description'])) ? null : $data['description'],
'selectable' => isset($data['selectable']),
'visible' => isset($data['visible']),
]);
'locked' => isset($data['locked']),
])->save();
if (! $pack->exists) {
throw new DisplayException('Model does not exist after creation. Did an event prevent it from saving?');
}
Storage::makeDirectory('packs/' . $pack->uuid);
if (isset($data['file_upload'])) {
$data['file_upload']->storeAs('packs/' . $pack->uuid, 'archive.tar.gz');
}
DB::commit();
} catch (\Exception $ex) {
DB::rollBack();
throw $ex;
}
return $pack;
return $pack;
});
}
/**
* Creates a new pack on the system given a template file.
*
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function createWithTemplate(array $data)
{
if (! isset($data['file_upload'])) {
@ -127,9 +141,10 @@ class PackRepository
'name' => $json->name,
'version' => $json->version,
'description' => $json->description,
'option' => $data['option'],
'option_id' => $data['option_id'],
'selectable' => $json->selectable,
'visible' => $json->visible,
'locked' => $json->locked,
]);
if (! $zip->extractTo(storage_path('app/packs/' . $pack->uuid), 'archive.tar.gz')) {
@ -147,42 +162,67 @@ class PackRepository
'name' => $json->name,
'version' => $json->version,
'description' => $json->description,
'option' => $data['option'],
'option_id' => $data['option_id'],
'selectable' => $json->selectable,
'visible' => $json->visible,
'locked' => $json->locked,
]);
}
}
/**
* Updates a pack on the system.
*
* @param int $id
* @param array $data
* @return \Pterodactyl\Models\Pack
*
* @throws \Pterodactyl\Exceptions\DisplayValidationException
*/
public function update($id, array $data)
{
$validator = Validator::make($data, [
'name' => 'required|string',
'version' => 'required|string',
'description' => 'string',
'option' => 'required|exists:service_options,id',
'selectable' => 'sometimes|boolean',
'visible' => 'sometimes|boolean',
'name' => 'sometimes|required|string',
'version' => 'sometimes|required|string',
'description' => 'sometimes|string',
'selectable' => 'sometimes|required|boolean',
'visible' => 'sometimes|required|boolean',
'locked' => 'sometimes|required|boolean',
]);
if ($validator->fails()) {
throw new DisplayValidationException($validator->errors());
throw new DisplayValidationException(json_encode($validator->errors()));
}
Models\ServicePack::findOrFail($id)->update([
'option_id' => $data['option'],
'name' => $data['name'],
'version' => $data['version'],
$pack = Pack::findOrFail($id);
$pack->fill([
'name' => isset($data['name']) ? $data['name'] : $pack->name,
'version' => isset($data['version']) ? $data['version'] : $pack->version,
'description' => (empty($data['description'])) ? null : $data['description'],
'selectable' => isset($data['selectable']),
'visible' => isset($data['visible']),
]);
'selectable' => isset($data['selectable']) ? $data['selectable'] : $data->selectable,
'visible' => isset($data['visible']) ? $data['visible'] : $data->visible,
'locked' => isset($data['locked']) ? $data['locked'] : $data->locked,
])->save();
return $pack;
}
/**
* Deletes a pack and files from the system.
*
* @param int $id
* @return void
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function delete($id)
{
$pack = Models\ServicePack::findOrFail($id);
// @TODO Check for linked servers; foreign key should block this.
$pack = Models\Pack::withCount('servers')->findOrFail($id);
if ($pack->servers_count > 0) {
throw new DisplayException('Cannot delete a pack from the system if servers are assocaited with it.');
}
DB::transaction(function () use ($pack) {
$pack->delete();
Storage::deleteDirectory('packs/' . $pack->uuid);

View File

@ -156,7 +156,7 @@ class ServerRepository
if (! isset($data['pack_id']) || (int) $data['pack_id'] < 1) {
$data['pack_id'] = null;
} else {
$pack = Models\ServicePack::where('id', $data['pack_id'])->where('option_id', $data['option_id'])->first();
$pack = Models\Pack::where('id', $data['pack_id'])->where('option_id', $data['option_id'])->first();
if (! $pack) {
throw new DisplayException('The requested service pack does not seem to exist for this combination.');
}

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class RenameServicePacksToSingluarPacks extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('service_packs', function (Blueprint $table) {
$table->dropForeign(['option_id']);
});
Schema::rename('service_packs', 'packs');
Schema::table('packs', function (Blueprint $table) {
$table->foreign('option_id')->references('id')->on('service_options');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('packs', function (Blueprint $table) {
$table->dropForeign(['option_id']);
});
Schema::rename('packs', 'service_packs');
Schema::table('service_packs', function (Blueprint $table) {
$table->foreign('option_id')->references('id')->on('service_options');
});
}
}

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddLockedStatusToTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('packs', function (Blueprint $table) {
$table->boolean('locked')->default(false)->after('visible');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('packs', function (Blueprint $table) {
$table->dropColumn('locked');
});
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,231 @@
/**
* Bootsnip - "Bootstrap Checkboxes/Radios"
* Bootstrap 3.2.0 Snippet by i-heart-php <http://bootsnipp.com/i-heart-php>
*
* Copyright (c) 2013 Bootsnipp.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.
*/
.checkbox {
padding-left: 20px;
}
.checkbox label {
display: inline-block;
position: relative;
padding-left: 5px;
}
.checkbox label::before {
content: "";
display: inline-block;
position: absolute;
width: 17px;
height: 17px;
left: 0;
margin-left: -20px;
border: 1px solid #cccccc;
border-radius: 3px;
background-color: #fff;
-webkit-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
-o-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
}
.checkbox label::after {
display: inline-block;
position: absolute;
width: 16px;
height: 16px;
left: 0;
top: 0;
margin-left: -20px;
padding-left: 3px;
padding-top: 1px;
font-size: 11px;
color: #555555;
}
.checkbox input[type="checkbox"] {
opacity: 0;
}
.checkbox input[type="checkbox"]:focus + label::before {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.checkbox input[type="checkbox"]:checked + label::after {
font-family: 'FontAwesome';
content: "\f00c";
}
.checkbox input[type="checkbox"]:disabled + label {
opacity: 0.65;
}
.checkbox input[type="checkbox"]:disabled + label::before {
background-color: #eeeeee;
cursor: not-allowed;
}
.checkbox.checkbox-circle label::before {
border-radius: 50%;
}
.checkbox.checkbox-inline {
margin-top: 0;
}
.checkbox-primary input[type="checkbox"]:checked + label::before {
background-color: #428bca;
border-color: #428bca;
}
.checkbox-primary input[type="checkbox"]:checked + label::after {
color: #fff;
}
.checkbox-danger input[type="checkbox"]:checked + label::before {
background-color: #d9534f;
border-color: #d9534f;
}
.checkbox-danger input[type="checkbox"]:checked + label::after {
color: #fff;
}
.checkbox-info input[type="checkbox"]:checked + label::before {
background-color: #5bc0de;
border-color: #5bc0de;
}
.checkbox-info input[type="checkbox"]:checked + label::after {
color: #fff;
}
.checkbox-warning input[type="checkbox"]:checked + label::before {
background-color: #f0ad4e;
border-color: #f0ad4e;
}
.checkbox-warning input[type="checkbox"]:checked + label::after {
color: #fff;
}
.checkbox-success input[type="checkbox"]:checked + label::before {
background-color: #5cb85c;
border-color: #5cb85c;
}
.checkbox-success input[type="checkbox"]:checked + label::after {
color: #fff;
}
.radio {
padding-left: 20px;
}
.radio label {
display: inline-block;
position: relative;
padding-left: 5px;
}
.radio label::before {
content: "";
display: inline-block;
position: absolute;
width: 17px;
height: 17px;
left: 0;
margin-left: -20px;
border: 1px solid #cccccc;
border-radius: 50%;
background-color: #fff;
-webkit-transition: border 0.15s ease-in-out;
-o-transition: border 0.15s ease-in-out;
transition: border 0.15s ease-in-out;
}
.radio label::after {
display: inline-block;
position: absolute;
content: " ";
width: 11px;
height: 11px;
left: 3px;
top: 3px;
margin-left: -20px;
border-radius: 50%;
background-color: #555555;
-webkit-transform: scale(0, 0);
-ms-transform: scale(0, 0);
-o-transform: scale(0, 0);
transform: scale(0, 0);
-webkit-transition: -webkit-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);
-moz-transition: -moz-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);
-o-transition: -o-transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);
transition: transform 0.1s cubic-bezier(0.8, -0.33, 0.2, 1.33);
}
.radio input[type="radio"] {
opacity: 0;
}
.radio input[type="radio"]:focus + label::before {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.radio input[type="radio"]:checked + label::after {
-webkit-transform: scale(1, 1);
-ms-transform: scale(1, 1);
-o-transform: scale(1, 1);
transform: scale(1, 1);
}
.radio input[type="radio"]:disabled + label {
opacity: 0.65;
}
.radio input[type="radio"]:disabled + label::before {
cursor: not-allowed;
}
.radio.radio-inline {
margin-top: 0;
}
.radio-primary input[type="radio"] + label::after {
background-color: #428bca;
}
.radio-primary input[type="radio"]:checked + label::before {
border-color: #428bca;
}
.radio-primary input[type="radio"]:checked + label::after {
background-color: #428bca;
}
.radio-danger input[type="radio"] + label::after {
background-color: #d9534f;
}
.radio-danger input[type="radio"]:checked + label::before {
border-color: #d9534f;
}
.radio-danger input[type="radio"]:checked + label::after {
background-color: #d9534f;
}
.radio-info input[type="radio"] + label::after {
background-color: #5bc0de;
}
.radio-info input[type="radio"]:checked + label::before {
border-color: #5bc0de;
}
.radio-info input[type="radio"]:checked + label::after {
background-color: #5bc0de;
}
.radio-warning input[type="radio"] + label::after {
background-color: #f0ad4e;
}
.radio-warning input[type="radio"]:checked + label::before {
border-color: #f0ad4e;
}
.radio-warning input[type="radio"]:checked + label::after {
background-color: #f0ad4e;
}
.radio-success input[type="radio"] + label::after {
background-color: #5cb85c;
}
.radio-success input[type="radio"]:checked + label::before {
border-color: #5cb85c;
}
.radio-success input[type="radio"]:checked + label::after {
background-color: #5cb85c;
}

View File

@ -20,6 +20,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
@import 'checkbox.css';
.login-box, .register-box {
width: 40%;
margin: 7% auto
@ -266,3 +268,7 @@ span[aria-labelledby="select2-pUserId-container"] {
.terminal-notify:hover {
opacity: .9;
}
.no-margin-bottom {
margin-bottom: 0 !important;
}

View File

@ -0,0 +1,84 @@
{{-- 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')
List Packs
@endsection
@section('content-header')
<h1>Packs<small>All service packs available on the system.</small></h1>
<ol class="breadcrumb">
<li><a href="{{ route('admin.index') }}">Admin</a></li>
<li class="active">Packs</li>
</ol>
@endsection
@section('content')
<div class="row">
<div class="col-xs-12">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Pack List</h3>
<div class="box-tools">
<form action="{{ route('admin.packs') }}" method="GET">
<div class="input-group input-group-sm" style="width: 300px;">
<input type="text" name="query" class="form-control pull-right" value="{{ request()->input('query') }}" placeholder="Search Packs">
<div class="input-group-btn">
<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
<a href="{{ route('admin.packs.new') }}"><button type="button" class="btn btn-sm btn-primary" style="border-radius: 0 3px 3px 0;margin-left:-1px;">Create New</button></a>
</div>
</div>
</form>
</div>
</div>
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tbody>
<tr>
<th>ID</th>
<th>Pack Name</th>
<th>Version</th>
<th>Description</th>
<th>Option</td>
<th class="text-center">Servers</th>
</tr>
@foreach ($packs as $pack)
<tr>
<td class="middle" data-toggle="tooltip" data-placement="right" title="{{ $pack->uuid }}"><code>{{ $pack->id }}</code></td>
<td class="middle"><a href="{{ route('admin.packs.view', $pack->id) }}">{{ $pack->name }}</a></td>
<td class="middle"><code>{{ $pack->version }}</code></td>
<td class="col-md-6">{{ str_limit($pack->description, 150) }}</td>
<td class="middle"><a href="{{ route('admin.services.option.view', $pack->option->id) }}">{{ $pack->option->name }}</a></td>
<td class="middle text-center">{{ $pack->servers_count }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@if ($packs->hasPages())
<div class="box-footer with-border">
<div class="col-md-12 text-center">{!! $packs->render() !!}</div>
</div>
@endif
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,47 @@
<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form action="{{ route('admin.packs.new') }}" method="POST" enctype="multipart/form-data">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Install Pack from Template</h4>
</div>
<div class="modal-body">
<div class="well" style="margin-bottom:0">
<div class="row">
<div class="col-md-12">
<label for="pOptionIdModal" class="form-label">Associated Service Option:</label>
<select id="pOptionIdModal" name="option_id" class="form-control">
@foreach($services as $service)
<optgroup label="{{ $service->name }}">
@foreach($service->options as $option)
<option value="{{ $option->id }}">{{ $option->name }}</option>
@endforeach
</optgroup>
@endforeach
</select>
<p class="text-muted small">The option that this pack is assocaited with. Only servers that are assigned this option will be able to access this pack.</p>
</div>
</div>
<div class="row" style="margin-top:15px;">
<div class="col-md-12">
<div class="row">
<div class="form-group col-md-12">
<label class="control-label">Package Archive:</label>
<input name="file_upload" type="file" accept=".zip,.json, application/json, application/zip" />
<p class="text-muted"><small>This file should be either the <code>.json</code> template file, or a <code>.zip</code> pack archive containing <code>archive.tar.gz</code> and <code>import.json</code> within.<br /><br />This server is currently configured with the following limits: <code>upload_max_filesize={{ ini_get('upload_max_filesize') }}</code> and <code>post_max_size={{ ini_get('post_max_size') }}</code>. If your file is larger than either of those values this request will fail.</small></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
{!! csrf_field() !!}
<button type="button" class="btn btn-default btn-sm pull-left" data-dismiss="modal">Cancel</button>
<button type="submit" name="action" value="from_template" class="btn btn-primary btn-sm">Install</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,158 @@
{{-- 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')
Packs &rarr; New
@endsection
@section('content-header')
<h1>New Pack<small>Create a new pack on the system.</small></h1>
<ol class="breadcrumb">
<li><a href="{{ route('admin.index') }}">Admin</a></li>
<li><a href="{{ route('admin.packs') }}">Packs</a></li>
<li class="active">New</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 class="active"><a href="{{ route('admin.packs.new') }}">Configure Manually</a></li>
<li><a href="#modal" id="toggleModal">Install From Template</a></li>
</ul>
</div>
</div>
</div>
<form action="{{ route('admin.packs.new') }}" method="POST" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Pack Details</h3>
</div>
<div class="box-body">
<div class="form-group">
<label for="pName" class="form-label">Name</label>
<input name="name" type="text" id="pName" class="form-control" value="{{ old('name') }}" />
<p class="text-muted small">A short but descriptive name of what this pack is. For example, <code>Counter Strike: Source</code> if it is a Counter Strike package.</p>
</div>
<div class="form-group">
<label for="pDescription" class="form-label">Description</label>
<textarea name="description" id="pDescription" class="form-control" rows="8">{{ old('description') }}</textarea>
</div>
<div class="form-group">
<label for="pVersion" class="form-label">Version</label>
<input type="text" name="version" id="pVersion" class="form-control" value="{{ old('version') }}" />
<p class="text-muted small">The version of this package, or the version of the files contained within the package.</p>
</div>
<div class="form-group">
<label for="pOptionId" class="form-label">Associated Option</label>
<select id="pOptionId" name="option_id" class="form-control">
@foreach($services as $service)
<optgroup label="{{ $service->name }}">
@foreach($service->options as $option)
<option value="{{ $option->id }}">{{ $option->name }}</option>
@endforeach
</optgroup>
@endforeach
</select>
<p class="text-muted small">The option that this pack is assocaited with. Only servers that are assigned this option will be able to access this pack.</p>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Pack Configuration</h3>
</div>
<div class="box-body">
<div class="form-group">
<div class="checkbox checkbox-primary no-margin-bottom">
<input id="pSelectable" name="selectable" type="checkbox" value="1" checked/>
<label for="pSelectable">
Selectable
</label>
</div>
<p class="text-muted small">Check this box if user should be able to select this pack to install on their servers.</p>
</div>
<div class="form-group">
<div class="checkbox checkbox-primary no-margin-bottom">
<input id="pVisible" name="visible" type="checkbox" value="1" checked/>
<label for="pVisible">
Visible
</label>
</div>
<p class="text-muted small">Check this box if this pack is visible in the dropdown menu. If this pack is assigned to a server it will be visible regardless of this setting.</p>
</div>
<div class="form-group">
<div class="checkbox checkbox-warning no-margin-bottom">
<input id="pLocked" name="locked" type="checkbox" value="1"/>
<label for="pLocked">
Locked
</label>
</div>
<p class="text-muted small">Check this box if servers assigned this pack should not be able to switch to a different pack.</p>
</div>
<hr />
<div class="form-group no-margin-bottom">
<label for="pFileUpload" class="form-label">Pack Archive</label>
<input type="file" accept=".tar.gz, application/gzip" name="file_upload" class="well well-sm" style="width:100%"/>
<p class="text-muted small">This package file must be a <code>.tar.gz</code> archive of pack files to be decompressed into the server folder.</p>
<p class="text-muted small">If your file is larger than <code>50MB</code> it is recommended to upload it using SFTP. Once you have added this pack to the system, a path will be provided where you should upload the file.</p>
<div class="callout callout-info callout-slim no-margin-bottom">
<p class="text-muted small"><strong>This server is currently configured with the following limits:</strong><br /><code>upload_max_filesize={{ ini_get('upload_max_filesize') }}</code><br /><code>post_max_size={{ ini_get('post_max_size') }}</code><br /><br />If your file is larger than either of those values this request will fail.</p>
</div>
</div>
</div>
<div class="box-footer with-border">
{!! csrf_field() !!}
<button class="btn btn-sm btn-success pull-right" type="submit">Create Pack</button>
</div>
</div>
</div>
</div>
</form>
@endsection
@section('footer-scripts')
@parent
<script>
$('#pOptionId').select2();
$('#toggleModal').on('click', function (event) {
event.preventDefault();
$.ajax({
method: 'GET',
url: Router.route('admin.packs.new.template'),
headers: { 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content') },
}).fail(function (jqXhr) {
console.error(jqXhr);
alert('There was an error trying to create the upload modal.');
}).success(function (data) {
$(data).modal();
$('#pOptionIdModal').select2();
});
});
</script>
@endsection

View File

@ -1,90 +0,0 @@
{{-- 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')
Service Packs for {{ $option->name }}
@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.packs') }}">Packs</a></li>
<li><a href="{{ route('admin.services.packs.service', $option->service->id) }}">{{ $option->service->name }}</a></li>
<li class="active">{{ $option->name }}</li>
</ul>
<h3 class="nopad">Service Packs</h3><hr />
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Pack Name</th>
<th>Version</th>
<th>UUID</th>
<th>Selectable</th>
<th>Visible</th>
</tr>
</thead>
<tbody>
@foreach ($option->packs as $pack)
<tr>
<td><a href="{{ route('admin.services.packs.edit', $pack->id) }}">{{ $pack->name }}</a></td>
<td><code>{{ $pack->version }}</code></td>
<td><code>{{ $pack->uuid }}</code></td>
<td>@if($pack->selectable)<span class="label label-success"><i class="fa fa-check"></i></span>@else<span class="label label-default"><i class="fa fa-times"></i></span>@endif</td>
<td>@if($pack->visible)<span class="label label-success"><i class="fa fa-check"></i></span>@else<span class="label label-default"><i class="fa fa-times"></i></span>@endif</td>
</tr>
@endforeach
<tr>
<td colspan="5">
<a href="{{ route('admin.services.packs.new', $option->id) }}">
<button class="pull-right btn btn-xxs btn-primary"><i class="fa fa-plus"></i></button>
</a>
<a href="#upload" id="toggleUpload">
<button class="pull-right btn btn-xxs btn-default" style="margin-right:5px;"><i class="fa fa-upload"></i> Install from Template</button>
</a>
</td>
</tr>
</tbody>
</table>
</div>
<script>
$(document).ready(function () {
$('#sidebar_links').find("a[href='/admin/services/packs']").addClass('active');
$('#toggleUpload').on('click', function (event) {
event.preventDefault();
var element = $(this);
element.find('button').addClass('disabled');
$.ajax({
method: 'GET',
url: '{{ route('admin.services.packs.uploadForm', $option->id) }}'
}).fail(function (jqXhr) {
console.error(jqXhr);
alert('There was an error trying to create the upload form.');
}).success(function (data) {
$(data).modal();
}).always(function () {
element.find('button').removeClass('disabled');
});
});
});
</script>
@endsection

View File

@ -1,67 +0,0 @@
{{-- 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')
Service Packs for {{ $service->name }}
@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.packs') }}">Packs</a></li>
<li class="active">{{ $service->name }}</li>
</ul>
<h3 class="nopad">Service Packs</h3><hr />
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Service Option</th>
<th>Total Packs</th>
</tr>
</thead>
<tbody>
@foreach ($service->options as $option)
<tr>
<td><a href="{{ route('admin.services.packs.option', $option->id) }}">{{ $option->name }}</a></td>
<td>{{ $option->packs->count() }}</td>
</tr>
@endforeach
<tr>
<td colspan="2">
<a href="{{ route('admin.services.packs.new') }}">
<button class="pull-right btn btn-xxs btn-primary"><i class="fa fa-plus"></i></button>
</a>
<a href="{{ route('admin.services.packs.new') }}">
<button class="pull-right btn btn-xxs btn-default" style="margin-right:5px;"><i class="fa fa-upload"></i> Install from Template</button>
</a>
</td>
</tr>
</tbody>
</table>
</div>
<script>
$(document).ready(function () {
$('#sidebar_links').find("a[href='/admin/services/packs']").addClass('active');
});
</script>
@endsection