Finish pack management in Admin CP

This commit is contained in:
Dane Everitt 2017-03-15 20:52:37 -04:00
parent 4730309589
commit 1c47b2ed55
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
13 changed files with 352 additions and 455 deletions

View file

@ -80,6 +80,12 @@ class PackController extends Controller
]); ]);
} }
/**
* Handle create pack request and route user to location.
*
* @param Request $request
* @return \Illuminate\View\View
*/
public function create(Request $request) public function create(Request $request)
{ {
$repo = new PackRepository; $repo = new PackRepository;
@ -108,43 +114,102 @@ class PackController extends Controller
return redirect()->route('admin.packs.new')->withInput(); return redirect()->route('admin.packs.new')->withInput();
} }
/**
* Display pack view template to user.
*
* @param Request $request
* @param int $id
* @return \Illuminate\View\View
*/
public function view(Request $request, $id)
{
return view('admin.packs.view', [
'pack' => Pack::with('servers.node', 'servers.user')->findOrFail($id),
'services' => Service::with('options')->get(),
]);
}
// public function export(Request $request, $id, $files = false) /**
// { * Handle updating or deleting pack information.
// $pack = Models\Pack::findOrFail($id); *
// $json = [ * @param Request $request
// 'name' => $pack->name, * @param int $id
// 'version' => $pack->version, * @return \Illuminate\Response\RedirectResponse
// 'description' => $pack->dscription, */
// 'selectable' => (bool) $pack->selectable, public function update(Request $request, $id)
// 'visible' => (bool) $pack->visible, {
// ]; $repo = new PackRepository;
// $filename = tempnam(sys_get_temp_dir(), 'pterodactyl_'); try {
// if ((bool) $files) { if ($request->input('action') !== 'delete') {
// $zip = new \ZipArchive; $pack = $repo->update($id, $request->intersect([
// if (! $zip->open($filename, \ZipArchive::CREATE)) { 'name', 'description', 'version',
// abort(503, 'Unable to open file for writing.'); 'option_id', 'selectable', 'visible', 'locked'
// } ]));
Alert::success('Pack successfully updated.')->flash();
} else {
$repo->delete($id);
Alert::success('Pack was successfully deleted from the system.')->flash();
// $files = Storage::files('packs/' . $pack->uuid); return redirect()->route('admin.packs');
// foreach ($files as $file) { }
// $zip->addFile(storage_path('app/' . $file), basename(storage_path('app/' . $file))); } catch(DisplayValidationException $ex) {
// } return redirect()->route('admin.packs.view', $id)->withErrors(json_decode($ex->getMessage()));
} catch (DisplayException $ex) {
Alert::danger($ex->getMessage())->flash();
} catch (\Exception $ex) {
Log::error($ex);
Alert::danger('An error occured while attempting to edit this service pack. This error has been logged.')->flash();
}
// $zip->addFromString('import.json', json_encode($json, JSON_PRETTY_PRINT)); return redirect()->route('admin.packs.view', $id);
// $zip->close(); }
// return response()->download($filename, 'pack-' . $pack->name . '.zip')->deleteFileAfterSend(true); /**
// } else { * Creates an archive of the pack and downloads it to the browser.
// $fp = fopen($filename, 'a+'); *
// fwrite($fp, json_encode($json, JSON_PRETTY_PRINT)); * @param Request $request
// fclose($fp); * @param int $id
* @param bool $files
* @return \Illuminate\Response\BinaryFileResponse
*/
public function export(Request $request, $id, $files = false)
{
$pack = Pack::findOrFail($id);
$json = [
'name' => $pack->name,
'version' => $pack->version,
'description' => $pack->description,
'selectable' => $pack->selectable,
'visible' => $pack->visible,
'locked' => $pack->locked,
];
// return response()->download($filename, 'pack-' . $pack->name . '.json', [ $filename = tempnam(sys_get_temp_dir(), 'pterodactyl_');
// 'Content-Type' => 'application/json', if ($files === 'with-files') {
// ])->deleteFileAfterSend(true); $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

@ -98,10 +98,6 @@ class RemoteController extends Controller
], 403); ], 403);
} }
// Passes Validation, Setup Notifications
$notify = new NotificationService($server);
$notify->pass($request->input('notification'));
return response('', 201); return response('', 201);
} }

View file

@ -474,6 +474,13 @@ class AdminRoutes
'as' => 'admin.packs.view', 'as' => 'admin.packs.view',
'uses' => 'Admin\PackController@view', 'uses' => 'Admin\PackController@view',
]); ]);
$router->post('/view/{id}', 'Admin\PackController@update');
$router->post('/view/{id}/export/{files?}', [
'as' => 'admin.packs.view.export',
'uses' => 'Admin\PackController@export',
]);
}); });
} }
} }

View file

@ -24,6 +24,8 @@
namespace Pterodactyl\Models; namespace Pterodactyl\Models;
use File;
use Storage;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Nicolaslopezj\Searchable\SearchableTrait; use Nicolaslopezj\Searchable\SearchableTrait;
@ -78,6 +80,29 @@ class Pack extends Model
], ],
]; ];
/**
* Returns all of the archived files for a given pack.
*
* @param bool $collection
* @return \Illuminate\Support\Collection|object
*/
public function files($collection = false)
{
$files = collect(Storage::files('packs/' . $this->uuid));
$files = $files->map(function ($item) {
$path = storage_path('app/' . $item);
return (object) [
'name' => basename($item),
'hash' => sha1_file($path),
'size' => File::humanReadableSize($path),
];
});
return ($collection) ? $files : (object) $files->all();
}
/** /**
* Gets option associated with a service pack. * Gets option associated with a service pack.
* *

View file

@ -22,41 +22,31 @@
* SOFTWARE. * SOFTWARE.
*/ */
namespace Pterodactyl\Services; namespace Pterodactyl\Providers;
use Pterodactyl\Models\Server; use File;
use Pterodactyl\Notifications\Daemon; use Illuminate\Support\ServiceProvider;
class NotificationService class MacroServiceProvider extends ServiceProvider
{ {
protected $server;
protected $user;
/** /**
* Daemon will pass an event name, this matches that event name with the notification to send. * Bootstrap the application services.
* @var array *
* @return void
*/ */
protected $types = [ public function boot()
// 'crashed' => 'CrashNotification',
// 'started' => 'StartNotification',
// 'stopped' => 'StopNotification',
// 'rebuild' => 'RebuildNotification'
];
public function __construct(Server $server)
{ {
$this->server = $server; File::macro('humanReadableSize', function ($path, $precision = 2) {
$size = File::size($path);
static $units = ['B', 'kB', 'MB', 'GB', 'TB'];
$i = 0;
while (($size / 1024) > 0.9) {
$size = $size / 1024;
$i++;
} }
public function pass(array $notification) return round($size, ($i < 2) ? 0 : $precision) . ' ' . $units[$i];
{ });
if (! $notification->type) {
return;
}
if (class_exists($this->types[$notification->type]::class)) {
$user->notify(new $this->types[$notification->type]($notification->payload));
}
} }
} }

View file

@ -177,12 +177,14 @@ class PackRepository
* @param array $data * @param array $data
* @return \Pterodactyl\Models\Pack * @return \Pterodactyl\Models\Pack
* *
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\DisplayValidationException * @throws \Pterodactyl\Exceptions\DisplayValidationException
*/ */
public function update($id, array $data) public function update($id, array $data)
{ {
$validator = Validator::make($data, [ $validator = Validator::make($data, [
'name' => 'sometimes|required|string', 'name' => 'sometimes|required|string',
'option_id' => 'sometimes|required|exists:service_options,id',
'version' => 'sometimes|required|string', 'version' => 'sometimes|required|string',
'description' => 'sometimes|string', 'description' => 'sometimes|string',
'selectable' => 'sometimes|required|boolean', 'selectable' => 'sometimes|required|boolean',
@ -194,14 +196,20 @@ class PackRepository
throw new DisplayValidationException(json_encode($validator->errors())); throw new DisplayValidationException(json_encode($validator->errors()));
} }
$pack = Pack::findOrFail($id); $pack = Pack::withCount('servers')->findOrFail($id);
if ($pack->servers_count > 0 && (isset($data['option_id']) && (int) $data['option_id'] !== $pack->option_id)) {
throw new DisplayException('You cannot modify the associated option if servers are attached to a pack.');
}
$pack->fill([ $pack->fill([
'name' => isset($data['name']) ? $data['name'] : $pack->name, 'name' => isset($data['name']) ? $data['name'] : $pack->name,
'option_id' => isset($data['option_id']) ? $data['option_id'] : $pack->option_id,
'version' => isset($data['version']) ? $data['version'] : $pack->version, 'version' => isset($data['version']) ? $data['version'] : $pack->version,
'description' => (empty($data['description'])) ? null : $data['description'], 'description' => (empty($data['description'])) ? null : $data['description'],
'selectable' => isset($data['selectable']) ? $data['selectable'] : $data->selectable, 'selectable' => isset($data['selectable']),
'visible' => isset($data['visible']) ? $data['visible'] : $data->visible, 'visible' => isset($data['visible']),
'locked' => isset($data['locked']) ? $data['locked'] : $data->locked, 'locked' => isset($data['locked']),
])->save(); ])->save();
return $pack; return $pack;

View file

View file

@ -150,6 +150,7 @@ return [
Pterodactyl\Providers\AuthServiceProvider::class, Pterodactyl\Providers\AuthServiceProvider::class,
Pterodactyl\Providers\EventServiceProvider::class, Pterodactyl\Providers\EventServiceProvider::class,
Pterodactyl\Providers\RouteServiceProvider::class, Pterodactyl\Providers\RouteServiceProvider::class,
Pterodactyl\Providers\MacroServiceProvider::class,
Pterodactyl\Providers\PhraseAppTranslationProvider::class, Pterodactyl\Providers\PhraseAppTranslationProvider::class,
/* /*

View file

@ -0,0 +1,192 @@
{{-- 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; View &rarr; {{ $pack->name }}
@endsection
@section('content-header')
<h1>{{ $pack->name }}<small>{{ str_limit($pack->description, 60) }}</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">{{ $pack->name }}</li>
</ol>
@endsection
@section('content')
<form action="{{ route('admin.packs.view', $pack->id) }}" method="POST">
<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="{{ $pack->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">{{ $pack->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="{{ $pack->version }}" />
<p class="text-muted small">The version of this package, or the version of the files contained within the package.</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">
<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 }}" {{ $pack->option_id !== $option->id ?: 'selected' }}>{{ $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. This assigned option <em>cannot</em> be changed if servers are attached to this pack.</p>
</div>
<div class="form-group">
<div class="checkbox checkbox-primary no-margin-bottom">
<input id="pSelectable" name="selectable" type="checkbox" value="1" {{ ! $pack->selectable ?: '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" {{ ! $pack->visible ?: '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" {{ ! $pack->locked ?: 'checked' }}/>
<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>
</div>
<div class="box-footer with-border">
{!! csrf_field() !!}
<button name="action" value="delete" class="btn btn-sm btn-danger pull-left muted muted-hover" type="submit"><i class="fa fa-trash-o"></i></button>
<button name="action" value="edit" class="btn btn-sm btn-primary pull-right" type="submit">Save</button>
</div>
</div>
</div>
</div>
</form>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Stored Files</h3>
</div>
<div class="box-body no-padding table-responsive">
<table class="table table-hover">
<tr>
<th>Name</th>
<th>SHA1 Hash</th>
<th>File Size</th>
</tr>
@foreach($pack->files() as $file)
<tr>
<td>{{ $file->name }}</td>
<td><code>{{ $file->hash }}</code></td>
<td>{{ $file->size }}</td>
</tr>
@endforeach
</table>
</div>
<div class="box-footer">
<p class="text-muted small">If you would like to modified the stored pack you will need to upload a new <code>archive.tar.gz</code> to the location defined below.</p>
<p class="text-muted small"><strong>Storage Location:</strong> <code>{{ storage_path('app/packs/' . $pack->uuid) }}</code></p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Servers Using This Pack</h3>
</div>
<div class="box-body no-padding table-responsive">
<table class="table table-hover">
<tr>
<th>ID</th>
<th>Server Name</th>
<th>Node</th>
<th>Owner</th>
</tr>
@foreach($pack->servers as $server)
<tr>
<td><code>{{ $server->uuidShort }}</code></td>
<td><a href="{{ route('admin.servers.view', $server->id) }}">{{ $server->name }}</a></td>
<td><a href="{{ route('admin.nodes.view', $server->node->id) }}">{{ $server->node->name }}</a></td>
<td><a href="{{ route('admin.users.view', $server->user->id) }}">{{ $server->user->email }}</a></td>
</tr>
@endforeach
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-5 col-md-offset-7 col-xs-offset-6">
<form action="{{ route('admin.packs.view.export', $pack->id) }}" method="POST">
{!! csrf_field() !!}
<button type="submit" class="btn btn-sm btn-success pull-right">Export</button>
</form>
<form action="{{ route('admin.packs.view.export', ['id' => $pack->id, 'files' => 'with-files']) }}" method="POST">
{!! csrf_field() !!}
<button type="submit" class="btn btn-sm pull-right muted muted-hover" style="margin-right:10px;">Export with Archive</button>
</form>
</div>
</div>
@endsection
@section('footer-scripts')
@parent
<script>
$('#pOptionId').select2();
</script>
@endsection

View file

@ -1,160 +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')
Add New Service Pack
@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', $pack->option->service->id) }}">{{ $pack->option->service->name }}</a></li>
<li><a href="{{ route('admin.services.packs.option', $pack->option->id) }}">{{ $pack->option->name }}</a></li>
<li class="active">{{ $pack->name }} ({{ $pack->version }})</li>
</ul>
<h3 class="nopad">Manage Service Pack</h3><hr />
<form action="{{ route('admin.services.packs.edit', $pack->id) }}" method="POST">
<div class="row">
<div class="col-md-6 form-group">
<label class="control-label">Pack Name:</label>
<div>
<input type="text" name="name" value="{{ old('name', $pack->name) }}" placeholder="My Awesome Pack" class="form-control" />
<p class="text-muted"><small>The name of the pack which will be seen in dropdown menus and to users.</small></p>
</div>
</div>
<div class="col-md-6 form-group">
<label class="control-label">Pack Version:</label>
<div>
<input type="text" name="version" value="{{ old('version', $pack->version) }}" placeholder="v0.8.1" class="form-control" />
<p class="text-muted"><small>The version of the program included in this pack.</small></p>
</div>
</div>
<div class="col-md-12 form-group">
<label class="control-label">Description:</label>
<div>
<textarea name="description" class="form-control" rows="3">{{ old('description', $pack->description) }}</textarea>
<p class="text-muted"><small>Provide a description of the pack which will be shown to users.</small></p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label class="control-label">Associated Service Option:</label>
<select name="option" class="form-control">
@foreach($services as $service)
<option disabled>{{ $service->name }}</option>
@foreach($service->options as $option)
<option value="{{ $option->id }}" @if($pack->option_id === $option->id)selected="selected"@endif>&nbsp;&nbsp; -- {{ $option->name }}</option>
@endforeach
@endforeach
</select>
</div>
<div class="col-md-3 fuelux">
<label class="control-label">&nbsp;</label>
<div>
<label class="checkbox-formheight checkbox-custom checkbox-inline highlight" data-initialize="checkbox">
<input class="sr-only" type="checkbox" name="selectable" value="1" @if($pack->selectable)checked="checked"@endif> User Selectable
</label>
</div>
</div>
<div class="col-md-3 fuelux">
<label class="control-label">&nbsp;</label>
<div>
<label class="checkbox-formheight checkbox-custom checkbox-inline highlight" data-initialize="checkbox">
<input class="sr-only" type="checkbox" name="visible" value="1" @if($pack->visible)checked="checked"@endif> Visible
</label>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<h5 class="nopad">Package Archive</h5>
<div class="well" style="margin-bottom:0">
<div class="row">
<div class="form-group col-md-12">
@if(count($files) > 1)
<div class="alert alert-danger"><strong>Warning!</strong> Service packs should only contain a single pack archive in <code>.tar.gz</code> format. We've detected more than one file for this pack.</div>
@endif
<table class="table table-striped">
<thead>
<tr>
<th>Filename</th>
<th>File Size</th>
<th>SHA1 Hash</th>
<th>Last Modified</th>
</tr>
</thead>
<tbody>
@foreach($files as &$file)
<tr>
<td>{{ basename($file) }}</td>
<td><code>{{ Storage::size($file) }}</code> Bytes</td>
<td><code>{{ sha1_file(storage_path('app/' . $file)) }}</code></td>
<td>{{ Carbon::createFromTimestamp(Storage::lastModified($file))->toDateTimeString() }}</td>
</tr>
@endforeach
</tbody>
</table>
<p class="text-muted"><small>If you wish to modify or upload a new file it should be uploaded to <code>{{ storage_path('app/packs/' . $pack->uuid) }}</code> as <code>archive.tar.gz</code>.</small></p>
</div>
</div>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<div class="form-group">
{!! csrf_field() !!}
<input type="submit" name="action_submit" class="btn btn-sm btn-primary" value="Edit Service Pack" />
<button type="submit" name="action_delete" class="pull-right btn btn-sm btn-danger"><i class="fa fa-times"></i> Delete</button>
<a href="{{ route('admin.services.packs.export', $pack->id) }}"><button type="button" class="pull-right btn btn-sm btn-default" style="margin-right:10px;"><i class="fa fa-file"></i> Export</button></a>
<a href="{{ route('admin.services.packs.export', [ $pack->id, 'true' ]) }}"><button type="button" class="pull-right btn btn-sm btn-default" style="margin-right:10px;"><i class="fa fa-download"></i> Export with Files</button></a>
</div>
</div>
</form>
</div>
{!! Theme::js('js/vendor/ace/ace.js') !!}
{!! Theme::js('js/vendor/ace/ext-modelist.js') !!}
<script type="text/javascript">
$(document).ready(function () {
$('#sidebar_links').find("a[href='/admin/services/packs']").addClass('active');
const Editor = ace.edit('build_script');
Editor.setTheme('ace/theme/chrome');
Editor.getSession().setUseWrapMode(true);
Editor.setShowPrintMargin(false);
Editor.getSession().setMode('ace/mode/sh');
Editor.setOptions({
minLines: 12,
maxLines: Infinity
});
Editor.on('change', event => {
$('#editor_contents').val(Editor.getValue());
});
});
</script>
@endsection

View file

@ -1,47 +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
@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">Packs</li>
</ul>
<h3 class="nopad">Service Packs</h3><hr />
<div class="row">
@foreach ($services as $service)
<div class="col-md-6">
<a href="{{ route('admin.services.packs.service', $service->id) }}"><button class="btn btn-lg btn-primary" style="width:100%;margin-bottom:25px;">{{ $service->name }}</button></a>
</div>
@endforeach
</div>
</div>
<script>
$(document).ready(function () {
$('#sidebar_links').find("a[href='/admin/services/packs']").addClass('active');
});
</script>
@endsection

View file

@ -1,135 +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')
Add New Service Pack
@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">New Service Pack</li>
</ul>
<h3 class="nopad">New Service Pack</h3><hr />
<form action="{{ route('admin.services.packs.new') }}" method="POST" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6 form-group">
<label class="control-label">Pack Name:</label>
<div>
<input type="text" name="name" value="{{ old('name') }}" placeholder="My Awesome Pack" class="form-control" />
<p class="text-muted"><small>The name of the pack which will be seen in dropdown menus and to users.</small></p>
</div>
</div>
<div class="col-md-6 form-group">
<label class="control-label">Pack Version:</label>
<div>
<input type="text" name="version" value="{{ old('version') }}" placeholder="v0.8.1" class="form-control" />
<p class="text-muted"><small>The version of the program included in this pack.</small></p>
</div>
</div>
<div class="col-md-12 form-group">
<label class="control-label">Description:</label>
<div>
<textarea name="description" class="form-control" rows="3">{{ old('description') }}</textarea>
<p class="text-muted"><small>Provide a description of the pack which will be shown to users.</small></p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label class="control-label">Associated Service Option:</label>
<select name="option" class="form-control">
@foreach($services as $service)
<option disabled>{{ $service->name }}</option>
@foreach($service->options as $option)
<option value="{{ $option->id }}" @if((int) request()->option === $option->id)selected="selected"@endif>&nbsp;&nbsp; -- {{ $option->name }}</option>
@endforeach
@endforeach
</select>
</div>
<div class="col-md-3 fuelux">
<label class="control-label">&nbsp;</label>
<div>
<label class="checkbox-formheight checkbox-custom checkbox-inline highlight" data-initialize="checkbox">
<input class="sr-only" type="checkbox" name="selectable" value="1"> User Selectable
</label>
</div>
</div>
<div class="col-md-3 fuelux">
<label class="control-label">&nbsp;</label>
<div>
<label class="checkbox-formheight checkbox-custom checkbox-inline highlight" data-initialize="checkbox">
<input class="sr-only" type="checkbox" name="visible" value="1"> Visible
</label>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-12">
<h5 class="nopad">File Upload</h5>
<div class="well" style="margin-bottom:0">
<div class="row">
<div class="form-group col-md-12">
<label class="control-label">Package Archive:</label>
<input name="file_upload" type="file" accept=".tar.gz, application/gzip" />
<p class="text-muted"><small>This package file must be a <code>.tar.gz</code> archive of files to use for either building or running this pack.<br /><br />If your file is larger than <code>20MB</code> we recommend uploading it using SFTP. Once you have added this pack to the system, a path will be provided where you should upload the file.
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>
<hr />
<div class="row">
<div class="col-md-12">
<div class="form-group">
{!! csrf_field() !!}
<input type="submit" class="btn btn-sm btn-primary" value="Add Service Pack" />
</div>
</div>
</form>
</div>
{!! Theme::js('js/vendor/ace/ace.js') !!}
{!! Theme::js('js/vendor/ace/ext-modelist.js') !!}
<script type="text/javascript">
$(document).ready(function () {
$('#sidebar_links').find("a[href='/admin/services/packs']").addClass('active');
const Editor = ace.edit('build_script');
Editor.setTheme('ace/theme/chrome');
Editor.getSession().setUseWrapMode(true);
Editor.setShowPrintMargin(false);
Editor.getSession().setMode('ace/mode/sh');
Editor.setOptions({
minLines: 12,
maxLines: Infinity
});
Editor.setValue('{{ old('build_script') }}');
Editor.on('change', event => {
$('#editor_contents').val(Editor.getValue());
});
});
</script>
@endsection

View file

@ -1,45 +0,0 @@
<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form action="{{ route('admin.services.packs.uploadForm') }}" 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 class="control-label">Associated Service Option:</label>
<select name="option" class="form-control">
@foreach($services as $service)
<option disabled>{{ $service->name }}</option>
@foreach($service->options as $option)
<option value="{{ $option->id }}" @if((int) request()->option === $option->id)selected="selected"@endif>&nbsp;&nbsp; -- {{ $option->name }}</option>
@endforeach
@endforeach
</select>
</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.(zip|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" data-dismiss="modal">Cancel</button>
<input type="submit" class="btn btn-primary btn-sm" value="Install" />
</div>
</form>
</div>
</div>
</div>