Add task management views
This commit is contained in:
parent
aea9b020c5
commit
0e23f87724
7 changed files with 473 additions and 20 deletions
|
@ -26,6 +26,7 @@ namespace Pterodactyl\Http\Controllers\Server;
|
||||||
|
|
||||||
use Log;
|
use Log;
|
||||||
use Alert;
|
use Alert;
|
||||||
|
use Javascript;
|
||||||
use Pterodactyl\Models;
|
use Pterodactyl\Models;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Pterodactyl\Repositories;
|
use Pterodactyl\Repositories;
|
||||||
|
@ -44,14 +45,20 @@ class TaskController extends Controller
|
||||||
{
|
{
|
||||||
$server = Models\Server::getByUUID($uuid);
|
$server = Models\Server::getByUUID($uuid);
|
||||||
$this->authorize('list-tasks', $server);
|
$this->authorize('list-tasks', $server);
|
||||||
|
$node = Models\Node::find($server->node);
|
||||||
|
|
||||||
|
Javascript::put([
|
||||||
|
'server' => collect($server->makeVisible('daemonSecret'))->only(['uuid', 'uuidShort', 'daemonSecret', 'username']),
|
||||||
|
'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'),
|
||||||
|
]);
|
||||||
|
|
||||||
return view('server.tasks.index', [
|
return view('server.tasks.index', [
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'node' => Models\Node::findOrFail($server->node),
|
'node' => $node,
|
||||||
'tasks' => Models\Task::where('server', $server->id)->get(),
|
'tasks' => Models\Task::where('server', $server->id)->get(),
|
||||||
'actions' => [
|
'actions' => [
|
||||||
'command' => 'Send Command',
|
'command' => trans('server.tasks.actions.command'),
|
||||||
'power' => 'Set Power Status',
|
'power' => trans('server.tasks.actions.power'),
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -60,10 +67,15 @@ class TaskController extends Controller
|
||||||
{
|
{
|
||||||
$server = Models\Server::getByUUID($uuid);
|
$server = Models\Server::getByUUID($uuid);
|
||||||
$this->authorize('create-task', $server);
|
$this->authorize('create-task', $server);
|
||||||
|
$node = Models\Node::find($server->node);
|
||||||
|
|
||||||
|
Javascript::put([
|
||||||
|
'server' => collect($server->makeVisible('daemonSecret'))->only(['uuid', 'uuidShort', 'daemonSecret', 'username']),
|
||||||
|
'node' => collect($node)->only('fqdn', 'scheme', 'daemonListen'),
|
||||||
|
]);
|
||||||
return view('server.tasks.new', [
|
return view('server.tasks.new', [
|
||||||
'server' => $server,
|
'server' => $server,
|
||||||
'node' => Models\Node::findOrFail($server->node),
|
'node' => $node,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +89,9 @@ class TaskController extends Controller
|
||||||
$repo->create($server->id, $request->except([
|
$repo->create($server->id, $request->except([
|
||||||
'_token',
|
'_token',
|
||||||
]));
|
]));
|
||||||
|
return redirect()->route('server.tasks', $uuid);
|
||||||
} catch (DisplayValidationException $ex) {
|
} catch (DisplayValidationException $ex) {
|
||||||
return redirect()->route('server.tasks', $uuid)->withErrors(json_decode($ex->getMessage()))->withInput();
|
return redirect()->route('server.tasks.new', $uuid)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||||
} catch (DisplayException $ex) {
|
} catch (DisplayException $ex) {
|
||||||
Alert::danger($ex->getMessage())->flash();
|
Alert::danger($ex->getMessage())->flash();
|
||||||
} catch (\Exception $ex) {
|
} catch (\Exception $ex) {
|
||||||
|
@ -86,19 +99,7 @@ class TaskController extends Controller
|
||||||
Alert::danger('An unknown error occured while attempting to create this task.')->flash();
|
Alert::danger('An unknown error occured while attempting to create this task.')->flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->route('server.tasks', $uuid);
|
return redirect()->route('server.tasks.new', $uuid);
|
||||||
}
|
|
||||||
|
|
||||||
public function getView(Request $request, $uuid, $id)
|
|
||||||
{
|
|
||||||
$server = Models\Server::getByUUID($uuid);
|
|
||||||
$this->authorize('view-task', $server);
|
|
||||||
|
|
||||||
return view('server.tasks.view', [
|
|
||||||
'server' => $server,
|
|
||||||
'node' => Models\Node::findOrFail($server->node),
|
|
||||||
'task' => Models\Task::where('id', $id)->where('server', $server->id)->firstOrFail(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteTask(Request $request, $uuid, $id)
|
public function deleteTask(Request $request, $uuid, $id)
|
||||||
|
|
102
public/themes/pterodactyl/js/frontend/tasks.js
Normal file
102
public/themes/pterodactyl/js/frontend/tasks.js
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
// Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com>
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all
|
||||||
|
// copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
// SOFTWARE.
|
||||||
|
(function initTaskFunctions() {
|
||||||
|
$('[data-action="delete-task"]').click(function (event) {
|
||||||
|
var self = $(this);
|
||||||
|
swal({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Delete Task?',
|
||||||
|
text: 'Are you sure you want to delete this task? There is no undo.',
|
||||||
|
showCancelButton: true,
|
||||||
|
allowOutsideClick: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
confirmButtonText: 'Delete Task',
|
||||||
|
confirmButtonColor: '#d9534f',
|
||||||
|
showLoaderOnConfirm: true
|
||||||
|
}, function () {
|
||||||
|
$.ajax({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: Router.route('server.tasks.delete', {
|
||||||
|
server: Pterodactyl.server.uuidShort,
|
||||||
|
id: self.data('id'),
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content'),
|
||||||
|
}
|
||||||
|
}).done(function (data) {
|
||||||
|
swal({
|
||||||
|
type: 'success',
|
||||||
|
title: '',
|
||||||
|
text: 'Task has been deleted.'
|
||||||
|
});
|
||||||
|
self.parent().parent().slideUp();
|
||||||
|
}).fail(function (jqXHR) {
|
||||||
|
console.error(jqXHR);
|
||||||
|
swal({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Whoops!',
|
||||||
|
text: 'An error occured while attempting to delete this task.'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('[data-action="toggle-task"]').click(function (event) {
|
||||||
|
var self = $(this);
|
||||||
|
swal({
|
||||||
|
type: 'info',
|
||||||
|
title: 'Toggle Task',
|
||||||
|
text: 'This will toggle the selected task.',
|
||||||
|
showCancelButton: true,
|
||||||
|
allowOutsideClick: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
confirmButtonText: 'Continue',
|
||||||
|
showLoaderOnConfirm: true
|
||||||
|
}, function () {
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
url: Router.route('server.tasks.toggle', {
|
||||||
|
server: Pterodactyl.server.uuidShort,
|
||||||
|
id: self.data('id'),
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content'),
|
||||||
|
}
|
||||||
|
}).done(function (data) {
|
||||||
|
swal({
|
||||||
|
type: 'success',
|
||||||
|
title: '',
|
||||||
|
text: 'Task has been toggled.'
|
||||||
|
});
|
||||||
|
if (data.status !== 1) {
|
||||||
|
self.parent().parent().addClass('muted muted-hover');
|
||||||
|
} else {
|
||||||
|
self.parent().parent().removeClass('muted muted-hover');
|
||||||
|
}
|
||||||
|
}).fail(function (jqXHR) {
|
||||||
|
console.error(jqXHR);
|
||||||
|
swal({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Whoops!',
|
||||||
|
text: 'An error occured while attempting to toggle this task.'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
|
@ -6,6 +6,37 @@ return [
|
||||||
'header' => 'Server Console',
|
'header' => 'Server Console',
|
||||||
'header_sub' => 'Control your server in real time.',
|
'header_sub' => 'Control your server in real time.',
|
||||||
],
|
],
|
||||||
|
'tasks' => [
|
||||||
|
'header' => 'Scheduled Tasks',
|
||||||
|
'header_sub' => 'Automate your server.',
|
||||||
|
'current' => 'Current Scheduled Tasks',
|
||||||
|
'actions' => [
|
||||||
|
'command' => 'Send Command',
|
||||||
|
'power' => 'Send Power Toggle',
|
||||||
|
],
|
||||||
|
'new_task' => 'Add New Task',
|
||||||
|
'toggle' => 'Toggle Status',
|
||||||
|
'new' => [
|
||||||
|
'header' => 'New Task',
|
||||||
|
'header_sub' => 'Create a new scheduled task for this server.',
|
||||||
|
'day_of_week' => 'Day of Week',
|
||||||
|
'custom' => 'Custom Value',
|
||||||
|
'day_of_month' => 'Day of Month',
|
||||||
|
'hour' => 'Hour',
|
||||||
|
'minute' => 'Minute',
|
||||||
|
'sun' => 'Sunday',
|
||||||
|
'mon' => 'Monday',
|
||||||
|
'tues' => 'Tuesday',
|
||||||
|
'wed' => 'Wednesday',
|
||||||
|
'thurs' => 'Thursday',
|
||||||
|
'fri' => 'Friday',
|
||||||
|
'sat' => 'Saturday',
|
||||||
|
'submit' => 'Create Task',
|
||||||
|
'type' => 'Task Type',
|
||||||
|
'payload' => 'Task Payload',
|
||||||
|
'payload_help' => 'For example, if you selected <code>Send Command</code> enter the command here. If you selected <code>Send Power Option</code> put the power action here (e.g. <code>restart</code>).',
|
||||||
|
],
|
||||||
|
],
|
||||||
'users' => [
|
'users' => [
|
||||||
'header' => 'Manage Users',
|
'header' => 'Manage Users',
|
||||||
'header_sub' => 'Control who can access your server.',
|
'header_sub' => 'Control who can access your server.',
|
||||||
|
|
|
@ -51,4 +51,12 @@ return [
|
||||||
'none' => 'None',
|
'none' => 'None',
|
||||||
'cancel' => 'Cancel',
|
'cancel' => 'Cancel',
|
||||||
'created_at' => 'Created At',
|
'created_at' => 'Created At',
|
||||||
|
'action' => 'Action',
|
||||||
|
'data' => 'Data',
|
||||||
|
'queued' => 'Queued',
|
||||||
|
'last_run' => 'Last Run',
|
||||||
|
'next_run' => 'Next Run',
|
||||||
|
'yes' => 'Yes',
|
||||||
|
'no' => 'No',
|
||||||
|
'delete' => 'Delete',
|
||||||
];
|
];
|
||||||
|
|
|
@ -166,11 +166,15 @@
|
||||||
<i class="fa fa-users"></i> <span>Subusers</span>
|
<i class="fa fa-users"></i> <span>Subusers</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li
|
||||||
|
@if(in_array(Route::currentRouteName(), ['server.tasks', 'server.tasks.new']))
|
||||||
|
class="active"
|
||||||
|
@endif
|
||||||
|
>
|
||||||
<a href="{{ route('server.tasks', $server->uuidShort)}}">
|
<a href="{{ route('server.tasks', $server->uuidShort)}}">
|
||||||
<i class="fa fa-clock-o"></i> <span>@lang('navigation.server.task_management')</span>
|
<i class="fa fa-clock-o"></i> <span>@lang('navigation.server.task_management')</span>
|
||||||
<span class="pull-right-container">
|
<span class="pull-right-container">
|
||||||
<span class="label label-primary pull-right">4</span>
|
<span class="label label-primary pull-right">{{ \Pterodactyl\Models\Task::select('id')->where('server', $server->id)->where('active', 1)->count() }}</span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
99
resources/themes/pterodactyl/server/tasks/index.blade.php
Normal file
99
resources/themes/pterodactyl/server/tasks/index.blade.php
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
{{-- Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com> --}}
|
||||||
|
|
||||||
|
{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}}
|
||||||
|
{{-- of this software and associated documentation files (the "Software"), to deal --}}
|
||||||
|
{{-- in the Software without restriction, including without limitation the rights --}}
|
||||||
|
{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}}
|
||||||
|
{{-- copies of the Software, and to permit persons to whom the Software is --}}
|
||||||
|
{{-- furnished to do so, subject to the following conditions: --}}
|
||||||
|
|
||||||
|
{{-- The above copyright notice and this permission notice shall be included in all --}}
|
||||||
|
{{-- copies or substantial portions of the Software. --}}
|
||||||
|
|
||||||
|
{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}}
|
||||||
|
{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}}
|
||||||
|
{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}}
|
||||||
|
{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}}
|
||||||
|
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
|
||||||
|
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
|
||||||
|
{{-- SOFTWARE. --}}
|
||||||
|
@extends('layouts.master')
|
||||||
|
|
||||||
|
@section('title')
|
||||||
|
@lang('server.tasks.header')
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content-header')
|
||||||
|
<h1>@lang('server.tasks.header')<small>@lang('server.tasks.header_sub')</small></h1>
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li><a href="{{ route('index') }}">@lang('strings.home')</a></li>
|
||||||
|
<li><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></li>
|
||||||
|
<li class="active">@lang('navigation.server.task_management')</li>
|
||||||
|
</ol>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">@lang('server.tasks.current')</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body table-responsive no-padding">
|
||||||
|
<table class="table table-hover">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>@lang('strings.action')</th>
|
||||||
|
<th>@lang('strings.data')</th>
|
||||||
|
<th>@lang('strings.queued')</th>
|
||||||
|
<th>@lang('strings.last_run')</th>
|
||||||
|
<th>@lang('strings.next_run')</th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
@foreach($tasks as $task)
|
||||||
|
<tr @if($task->active === 0)class="muted muted-hover"@endif>
|
||||||
|
<td class="middle">{{ $actions[$task->action] }}</td>
|
||||||
|
<td class="middle"><code>{{ $task->data }}</code></td>
|
||||||
|
<td class="middle">
|
||||||
|
@if ($task->queued)
|
||||||
|
<span class="label label-success">@lang('strings.yes')</span>
|
||||||
|
@else
|
||||||
|
<span class="label label-default">@lang('strings.no')</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td class="middle">{{ Carbon::parse($task->last_run)->toDayDateTimeString() }}<br /><span class="text-muted small">({{ Carbon::parse($task->last_run)->diffForHumans() }})</span></td>
|
||||||
|
<td class="middle">
|
||||||
|
@if($task->active !== 0)
|
||||||
|
{{ Carbon::parse($task->next_run)->toDayDateTimeString() }}<br /><span class="text-muted small">({{ Carbon::parse($task->next_run)->diffForHumans() }})</span>
|
||||||
|
@else
|
||||||
|
<em>n/a</em>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
@can('delete-task', $server)
|
||||||
|
<td class="text-center middle"><a href="#" data-action="delete-task" data-id="{{ $task->id }}"><i class="fa fa-fw fa-trash-o text-danger" data-toggle="tooltip" data-placement="top" title="@lang('strings.delete')"></i></a></td>
|
||||||
|
@endcan
|
||||||
|
@can('toggle-task', $server)
|
||||||
|
<td class="text-center middle"><a href="#" data-action="toggle-task" data-active="{{ $task->active }}" data-id="{{ $task->id }}"><i class="fa fa-fw fa-eye-slash text-primary" data-toggle="tooltip" data-placement="top" title="@lang('server.tasks.toggle')"></i></a></td>
|
||||||
|
@endcan
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="box-footer">
|
||||||
|
<a href="{{ route('server.tasks.new', $server->uuidShort) }}">
|
||||||
|
<button class="btn btn-sm btn-primary">@lang('server.tasks.new_task')</button>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('footer-scripts')
|
||||||
|
@parent
|
||||||
|
{!! Theme::js('js/frontend/server.socket.js') !!}
|
||||||
|
{!! Theme::js('js/frontend/tasks.js') !!}
|
||||||
|
@endsection
|
208
resources/themes/pterodactyl/server/tasks/new.blade.php
Normal file
208
resources/themes/pterodactyl/server/tasks/new.blade.php
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
{{-- Copyright (c) 2015 - 2016 Dane Everitt <dane@daneeveritt.com> --}}
|
||||||
|
|
||||||
|
{{-- Permission is hereby granted, free of charge, to any person obtaining a copy --}}
|
||||||
|
{{-- of this software and associated documentation files (the "Software"), to deal --}}
|
||||||
|
{{-- in the Software without restriction, including without limitation the rights --}}
|
||||||
|
{{-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell --}}
|
||||||
|
{{-- copies of the Software, and to permit persons to whom the Software is --}}
|
||||||
|
{{-- furnished to do so, subject to the following conditions: --}}
|
||||||
|
|
||||||
|
{{-- The above copyright notice and this permission notice shall be included in all --}}
|
||||||
|
{{-- copies or substantial portions of the Software. --}}
|
||||||
|
|
||||||
|
{{-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --}}
|
||||||
|
{{-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --}}
|
||||||
|
{{-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --}}
|
||||||
|
{{-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --}}
|
||||||
|
{{-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --}}
|
||||||
|
{{-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --}}
|
||||||
|
{{-- SOFTWARE. --}}
|
||||||
|
@extends('layouts.master')
|
||||||
|
|
||||||
|
@section('title')
|
||||||
|
@lang('server.tasks.new.header')
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
{{-- This has to be loaded before the AdminLTE theme to avoid dropdown issues. --}}
|
||||||
|
{!! Theme::css('vendor/select2/select2.min.css') !!}
|
||||||
|
@parent
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content-header')
|
||||||
|
<h1>@lang('server.tasks.new.header')<small>@lang('server.tasks.new.header_sub')</small></h1>
|
||||||
|
<ol class="breadcrumb">
|
||||||
|
<li><a href="{{ route('index') }}">@lang('strings.home')</a></li>
|
||||||
|
<li><a href="{{ route('server.index', $server->uuidShort) }}">{{ $server->name }}</a></li>
|
||||||
|
<li><a href="{{ route('server.tasks', $server->uuidShort) }}">@lang('navigation.server.task_management')</a></li>
|
||||||
|
<li class="active">@lang('server.tasks.new_task')</li>
|
||||||
|
</ol>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<form action="{{ route('server.tasks.new', $server->uuidShort) }}" method="POST">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-3 col-sm-6">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">@lang('server.tasks.new.day_of_week')</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<div>
|
||||||
|
<select data-action="update-field" data-field="day_of_week" class="form-control" multiple>
|
||||||
|
<option value="0">@lang('server.tasks.new.sun')</option>
|
||||||
|
<option value="1">@lang('server.tasks.new.mon')</option>
|
||||||
|
<option value="2">@lang('server.tasks.new.tues')</option>
|
||||||
|
<option value="3">@lang('server.tasks.new.wed')</option>
|
||||||
|
<option value="4">@lang('server.tasks.new.thurs')</option>
|
||||||
|
<option value="5">@lang('server.tasks.new.fri')</option>
|
||||||
|
<option value="6">@lang('server.tasks.new.sat')</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label class="control-label">@lang('server.tasks.new.custom')</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control" name="day_of_week" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-sm-6">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">@lang('server.tasks.new.day_of_month')</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<div>
|
||||||
|
<select data-action="update-field" data-field="day_of_month" class="form-control" multiple>
|
||||||
|
@foreach(range(1, 31) as $i)
|
||||||
|
<option value="{{ $i }}">{{ $i }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label class="control-label">@lang('server.tasks.new.custom')</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control" name="day_of_month" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-sm-6">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">@lang('server.tasks.new.hour')</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<div>
|
||||||
|
<select data-action="update-field" data-field="hour" class="form-control" multiple>
|
||||||
|
@foreach(range(0, 23) as $i)
|
||||||
|
<option value="{{ $i }}">{{ str_pad($i, 2, '0', STR_PAD_LEFT) }}:00</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label class="control-label">@lang('server.tasks.new.custom')</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control" name="hour" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 col-sm-6">
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">@lang('server.tasks.new.minute')</h3>
|
||||||
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<div>
|
||||||
|
<select data-action="update-field" data-field="minute" class="form-control" multiple>
|
||||||
|
@foreach(range(0, 55) as $i)
|
||||||
|
@if($i % 5 === 0)
|
||||||
|
<option value="{{ $i }}">_ _:{{ str_pad($i, 2, '0', STR_PAD_LEFT) }}</option>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-12">
|
||||||
|
<label class="control-label">@lang('server.tasks.new.custom')</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" class="form-control" name="minute" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12">
|
||||||
|
<div class="box box-primary">
|
||||||
|
<div class="box-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label class="control-label">@lang('server.tasks.new.type'):</label>
|
||||||
|
<div>
|
||||||
|
<select name="action" class="form-control">
|
||||||
|
<option value="command">@lang('server.tasks.actions.command')</option>
|
||||||
|
<option value="power">@lang('server.tasks.actions.power')</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-8">
|
||||||
|
<label class="control-label">@lang('server.tasks.new.payload'):</label>
|
||||||
|
<div>
|
||||||
|
<input type="text" name="data" class="form-control" value="{{ old('data') }}">
|
||||||
|
<span class="text-muted small">@lang('server.tasks.new.payload_help')</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="box-footer with-border">
|
||||||
|
{!! csrf_field() !!}
|
||||||
|
<button type="submit" class="btn btn-sm btn-success">@lang('server.tasks.new.submit')</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('footer-scripts')
|
||||||
|
@parent
|
||||||
|
{!! Theme::js('js/frontend/server.socket.js') !!}
|
||||||
|
{!! Theme::js('vendor/select2/select2.full.min.js') !!}
|
||||||
|
<script>
|
||||||
|
$('select[name="action"]').select2();
|
||||||
|
$('[data-action="update-field"]').on('change', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var updateField = $(this).data('field');
|
||||||
|
var selected = $(this).map(function (i, opt) {
|
||||||
|
return $(opt).val();
|
||||||
|
}).toArray();
|
||||||
|
if (selected.length === $(this).find('option').length) {
|
||||||
|
$('input[name=' + updateField + ']').val('*');
|
||||||
|
} else {
|
||||||
|
$('input[name=' + updateField + ']').val(selected.join(','));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
Loading…
Reference in a new issue