More schedule changes

This commit is contained in:
Dane Everitt 2017-09-13 21:46:43 -05:00
parent 457c910c35
commit 7f76684453
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
20 changed files with 365 additions and 348 deletions

View file

@ -18,7 +18,7 @@ return [
'create_file' => 'Create File',
'upload_files' => 'Upload Files',
'subusers' => 'Subusers',
'task_management' => 'Task Management',
'schedules' => 'Schedules',
'configuration' => 'Configuration',
'port_allocations' => 'Port Allocations',
'sftp_settings' => 'SFTP Settings',

View file

@ -7,17 +7,30 @@ return [
'header_sub' => 'Control your server in real time.',
],
'schedule' => [
'header' => 'Schedule Manager',
'header_sub' => 'Manage all of this server\'s schedules in one place.',
'current' => 'Current Schedules',
'new' => [
'header' => 'Create New Schedule',
'header_sub' => 'Create a new set of scheduled tasks for this server.',
'submit' => 'Create Schedule',
],
'manage' => [
'header' => 'Manage Schedule',
'submit' => 'Update Schedule',
'delete' => 'Delete Schedule',
],
'task' => [
'time' => 'After',
'action' => 'Perform Action',
'payload' => 'With Payload',
'add_more' => 'Add Another Task',
],
'actions' => [
'command' => 'Send Command',
'power' => 'Power Action',
],
'unnamed' => 'Unnamed Schedule',
'setup' => 'Schedule Setup',
'day_of_week' => 'Day of Week',
'day_of_month' => 'Day of Month',
@ -89,7 +102,7 @@ return [
'file_header' => 'File Management',
'subuser_header' => 'Subuser Management',
'server_header' => 'Server Management',
'task_header' => 'Task Management',
'task_header' => 'Schedule Management',
'sftp_header' => 'SFTP Management',
'database_header' => 'Database Management',
'power_start' => [
@ -188,29 +201,33 @@ return [
'title' => 'Edit Startup Command',
'description' => 'Allows a user to modify startup variables for a server.',
],
'list_tasks' => [
'title' => 'List Tasks',
'description' => 'Allows a user to list all tasks (enabled and disabled) on a server.',
'list_schedules' => [
'title' => 'List Schedules',
'description' => 'Allows a user to list all schedules (enabled and disabled) for this server.',
],
'view_task' => [
'title' => 'View Task',
'description' => 'Allows a user to view a specific task\'s details.',
'view_schedule' => [
'title' => 'View Schedule',
'description' => 'Allows a user to view a specific schedule\'s details including all of the assigned tasks.',
],
'toggle_task' => [
'title' => 'Toggle Task',
'description' => 'Allows a user to toggle a task on or off.',
'toggle_schedule' => [
'title' => 'Toggle Schedule',
'description' => 'Allows a user to toggle a schedule to be active or inactive.',
],
'queue_task' => [
'title' => 'Queue Task',
'description' => 'Allows a user to queue a task to run on next cycle.',
'queue_schedule' => [
'title' => 'Queue Schedule',
'description' => 'Allows a user to queue a schedule to run it\'s tasks on the next process cycle.',
],
'create_task' => [
'title' => 'Create Task',
'description' => 'Allows a user to create new tasks.',
'edit_schedule' => [
'title' => 'Edit Schedule',
'description' => 'Allows a user to edit a schedule including all of the schedule\'s tasks. This will allow the user to remove individual tasks, but not delete the schedule itself.',
],
'delete_task' => [
'title' => 'Delete Task',
'description' => 'Allows a user to delete a task.',
'create_schedule' => [
'title' => 'Create Schedule',
'description' => 'Allows a user to create a new schedule.',
],
'delete_schedule' => [
'title' => 'Delete Schedule',
'description' => 'Allows a user to delete a schedule from the server.',
],
'view_sftp' => [
'title' => 'View SFTP Details',

View file

@ -74,4 +74,13 @@ return [
'tasks' => 'Tasks',
'seconds' => 'Seconds',
'minutes' => 'Minutes',
'days' => [
'sun' => 'Sunday',
'mon' => 'Monday',
'tues' => 'Tuesday',
'wed' => 'Wednesday',
'thurs' => 'Thursday',
'fri' => 'Friday',
'sat' => 'Saturday',
],
];

View file

@ -157,12 +157,12 @@
@endcan
@can('list-tasks', $server)
<li
@if(starts_with(Route::currentRouteName(), 'server.tasks'))
@if(starts_with(Route::currentRouteName(), 'server.schedules'))
class="active"
@endif
>
<a href="{{ route('server.tasks', $server->uuidShort)}}">
<i class="fa fa-clock-o"></i> <span>@lang('navigation.server.task_management')</span>
<a href="{{ route('server.schedules', $server->uuidShort)}}">
<i class="fa fa-clock-o"></i> <span>@lang('navigation.server.schedules')</span>
<span class="pull-right-container">
<span class="label label-primary pull-right">{{ \Pterodactyl\Models\Schedule::select('id')->where('server_id', $server->id)->where('is_active', 1)->count() }}</span>
</span>

View file

@ -5,14 +5,14 @@
<label class="control-label">@lang('server.schedule.task.time')</label>
<div class="row">
<div class="col-xs-4">
<select name="chain[time_value][]" class="form-control">
<select name="tasks[time_value][]" class="form-control">
@foreach(range(0, 59) as $number)
<option value="{{ $number }}">{{ $number }}</option>
@endforeach
</select>
</div>
<div class="col-xs-8">
<select name="chain[time_interval][]" class="form-control">
<select name="tasks[time_interval][]" class="form-control">
<option value="s">@lang('strings.seconds')</option>
<option value="m">@lang('strings.minutes')</option>
</select>
@ -22,16 +22,16 @@
<div class="form-group col-md-3">
<label class="control-label">@lang('server.schedule.task.action')</label>
<div>
<select name="chain[action][]" class="form-control">
<option value="command">@lang('server.tasks.actions.command')</option>
<option value="power">@lang('server.tasks.actions.power')</option>
<select name="tasks[action][]" class="form-control">
<option value="command">@lang('server.schedule.actions.command')</option>
<option value="power">@lang('server.schedule.actions.power')</option>
</select>
</div>
</div>
<div class="form-group col-md-6">
<label class="control-label">@lang('server.schedule.task.payload')</label>
<div data-attribute="remove-task-element">
<input type="text" name="chain[payload][]" class="form-control">
<input type="text" name="tasks[payload][]" class="form-control">
<div class="input-group-btn hidden">
<button type="button" class="btn btn-danger" data-action="remove-task"><i class="fa fa-close"></i></button>
</div>

View file

@ -20,15 +20,15 @@
@extends('layouts.master')
@section('title')
@lang('server.tasks.header')
@lang('server.schedules.header')
@endsection
@section('content-header')
<h1>@lang('server.tasks.header')<small>@lang('server.tasks.header_sub')</small></h1>
<h1>@lang('server.schedule.header')<small>@lang('server.schedule.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>
<li class="active">@lang('navigation.server.schedules')</li>
</ol>
@endsection
@ -37,9 +37,9 @@
<div class="col-xs-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">@lang('server.tasks.current')</h3>
<h3 class="box-title">@lang('server.schedule.current')</h3>
<div class="box-tools">
<a href="{{ route('server.tasks.new', $server->uuidShort) }}"><button class="btn btn-primary btn-sm">Create New</button></a>
<a href="{{ route('server.schedules.new', $server->uuidShort) }}"><button class="btn btn-primary btn-sm">Create New</button></a>
</div>
</div>
<div class="box-body table-responsive no-padding">
@ -58,9 +58,9 @@
<tr @if(! $schedule->is_active)class="muted muted-hover"@endif>
<td class="middle">
@can('edit-schedule', $server)
<a href="{{ route('server.tasks.view', ['server' => $server->uuidShort, '$schedule' => $schedule->hashid]) }}">{{ $schedule->name }}</a>
<a href="{{ route('server.schedules.view', ['server' => $server->uuidShort, '$schedule' => $schedule->hashid]) }}">{{ $schedule->name }}</a>
@else
{{ $schedule->name }}
{{ $schedule->name ?? trans('server.schedule.unnamed') }}
@endcan
</td>
<td class="middle text-center">
@ -90,10 +90,10 @@
@endif
</td>
@can('delete-schedule', $server)
<td class="text-center middle"><a href="#" data-action="delete-task" data-taskid="{{ $schedule->hashid }}"><i class="fa fa-fw fa-trash-o text-danger" data-toggle="tooltip" data-placement="top" title="@lang('strings.delete')"></i></a></td>
<td class="text-center middle"><a href="#" data-action="delete-schedule" data-schedule-id="{{ $schedule->hashid }}"><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-schedule', $server)
<td class="text-center middle"><a href="#" data-action="toggle-task" data-active="{{ $schedule->active }}" data-taskid="{{ $schedule->hashid }}"><i class="fa fa-fw fa-eye-slash text-primary" data-toggle="tooltip" data-placement="top" title="@lang('server.tasks.toggle')"></i></a></td>
<td class="text-center middle"><a href="#" data-action="toggle-schedule" data-active="{{ $schedule->active }}" data-schedule-id="{{ $schedule->hashid }}"><i class="fa fa-fw fa-eye-slash text-primary" data-toggle="tooltip" data-placement="top" title="@lang('server.schedules.toggle')"></i></a></td>
@endcan
</tr>
@endforeach

View file

@ -20,7 +20,7 @@
@extends('layouts.master')
@section('title')
@lang('server.tasks.new.header')
@lang('server.schedules.new.header')
@endsection
@section('scripts')
@ -34,13 +34,13 @@
<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><a href="{{ route('server.schedules', $server->uuidShort) }}">@lang('navigation.server.schedules')</a></li>
<li class="active">@lang('server.schedule.new.header')</li>
</ol>
@endsection
@section('content')
<form action="{{ route('server.tasks.new', $server->uuidShort) }}" method="POST">
<form action="{{ route('server.schedules.new', $server->uuidShort) }}" method="POST">
<div class="row">
<div class="col-xs-12">
<div class="box box-primary">
@ -61,26 +61,26 @@
<div class="form-group">
<label for="scheduleDayOfWeek" class="control-label">@lang('server.schedule.day_of_week')</label>
<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 data-action="update-field" data-field="cron_day_of_week" class="form-control" multiple>
<option value="0">@lang('strings.days.sun')</option>
<option value="1">@lang('strings.days.mon')</option>
<option value="2">@lang('strings.days.tues')</option>
<option value="3">@lang('strings.days.wed')</option>
<option value="4">@lang('strings.days.thurs')</option>
<option value="5">@lang('strings.days.fri')</option>
<option value="6">@lang('strings.days.sat')</option>
</select>
</div>
</div>
<div class="form-group">
<input type="text" id="scheduleDayOfWeek" class="form-control" name="day_of_week" value="{{ old('day_of_week') }}" />
<input type="text" id="scheduleDayOfWeek" class="form-control" name="cron_day_of_week" value="{{ old('cron_day_of_week') }}" />
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="form-group">
<label for="scheduleDayOfMonth" class="control-label">@lang('server.schedule.day_of_month')</label>
<div>
<select data-action="update-field" data-field="day_of_month" class="form-control" multiple>
<select data-action="update-field" data-field="cron_day_of_month" class="form-control" multiple>
@foreach(range(1, 31) as $i)
<option value="{{ $i }}">{{ $i }}</option>
@endforeach
@ -88,14 +88,14 @@
</div>
</div>
<div class="form-group">
<input type="text" id="scheduleDayOfMonth" class="form-control" name="day_of_month" value="{{ old('day_of_month') }}" />
<input type="text" id="scheduleDayOfMonth" class="form-control" name="cron_day_of_month" value="{{ old('cron_day_of_month') }}" />
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="form-group col-md-12">
<label for="scheduleHour" class="control-label">@lang('server.schedule.hour')</label>
<div>
<select data-action="update-field" data-field="hour" class="form-control" multiple>
<select data-action="update-field" data-field="cron_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
@ -103,14 +103,14 @@
</div>
</div>
<div class="form-group col-md-12">
<input type="text" id="scheduleHour" class="form-control" name="hour" value="{{ old('hour') }}" />
<input type="text" id="scheduleHour" class="form-control" name="cron_hour" value="{{ old('cron_hour') }}" />
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="form-group">
<label for="scheduleMinute" class="control-label">@lang('server.schedule.minute')</label>
<div>
<select data-action="update-field" data-field="minute" class="form-control" multiple>
<select data-action="update-field" data-field="cron_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>
@ -120,7 +120,7 @@
</div>
</div>
<div class="form-group">
<input type="text" id="scheduleMinute" class="form-control" name="minute" value="{{ old('minute') }}" />
<input type="text" id="scheduleMinute" class="form-control" name="cron_minute" value="{{ old('cron_minute') }}" />
</div>
</div>
</div>
@ -136,7 +136,7 @@
<div class="box box-primary" id="containsTaskList">
@include('partials.schedules.task-template')
<div class="box-footer with-border" id="taskAppendBefore">
<div class="pull-left">
<div>
<p class="text-muted small">@lang('server.schedule.task_help')</p>
</div>
<div class="pull-right">

View file

@ -0,0 +1,177 @@
{{-- 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.master')
@section('title')
@lang('server.schedules.edit.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.schedule.manage.header')<small>{{ $schedule->name }}</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.schedules', $server->uuidShort) }}">@lang('navigation.server.schedules')</a></li>
<li class="active">@lang('server.schedule.manage.header')</li>
</ol>
@endsection
@section('content')
<form action="{{ route('server.schedules.view', ['server' => $server->uuidShort, 'schedule' => $schedule->hashid]) }}" method="POST">
<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-xs-12">
<label class="control-label" for="scheduleName">@lang('strings.name') <span class="field-optional"></span></label>
<div>
<input type="text" name="name" class="form-control" id="scheduleName" value="{{ old('name', $schedule->name) }}" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-3">
<div class="form-group">
<label for="scheduleDayOfWeek" class="control-label">@lang('server.schedule.day_of_week')</label>
<div>
<select data-action="update-field" data-field="cron_day_of_week" class="form-control" multiple>
<option value="0">@lang('strings.days.sun')</option>
<option value="1">@lang('strings.days.mon')</option>
<option value="2">@lang('strings.days.tues')</option>
<option value="3">@lang('strings.days.wed')</option>
<option value="4">@lang('strings.days.thurs')</option>
<option value="5">@lang('strings.days.fri')</option>
<option value="6">@lang('strings.days.sat')</option>
</select>
</div>
</div>
<div class="form-group">
<input type="text" id="scheduleDayOfWeek" class="form-control" name="cron_day_of_week" value="{{ old('cron_day_of_week', $schedule->cron_day_of_week) }}" />
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="form-group">
<label for="scheduleDayOfMonth" class="control-label">@lang('server.schedule.day_of_month')</label>
<div>
<select data-action="update-field" data-field="cron_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">
<input type="text" id="scheduleDayOfMonth" class="form-control" name="cron_day_of_month" value="{{ old('cron_day_of_month', $schedule->cron_day_of_month) }}" />
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="form-group col-md-12">
<label for="scheduleHour" class="control-label">@lang('server.schedule.hour')</label>
<div>
<select data-action="update-field" data-field="cron_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">
<input type="text" id="scheduleHour" class="form-control" name="cron_hour" value="{{ old('cron_hour', $schedule->cron_hour) }}" />
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="form-group">
<label for="scheduleMinute" class="control-label">@lang('server.schedule.minute')</label>
<div>
<select data-action="update-field" data-field="cron_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">
<input type="text" id="scheduleMinute" class="form-control" name="cron_minute" value="{{ old('cron_minute', $schedule->cron_minute) }}" />
</div>
</div>
</div>
</div>
<div class="box-footer with-border">
<p class="small text-muted no-margin-bottom">@lang('server.schedule.time_help')</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="box box-primary" id="containsTaskList">
@include('partials.schedules.task-template')
<div class="box-footer with-border" id="taskAppendBefore">
<div>
<p class="text-muted small">@lang('server.schedule.task_help')</p>
</div>
<div class="pull-left">
<button type="submit" class="btn btn-sm btn-danger muted muted-hover" id="deleteButton" name="_method" value="DELETE"><i class="fa fa-trash-o"></i></button>
</div>
<div class="pull-right">
{!! csrf_field() !!}
<button type="button" class="btn btn-sm btn-default" data-action="add-new-task"><i class="fa fa-plus"></i> @lang('server.schedule.task.add_more')</button>
<button type="submit" class="btn btn-sm btn-success" name="_method" value="PATCH">@lang('server.schedule.manage.submit')</button>
</div>
</div>
</div>
</div>
</div>
</form>
@endsection
@section('footer-scripts')
@parent
{!! Theme::js('js/frontend/server.socket.js') !!}
{!! Theme::js('vendor/select2/select2.full.min.js') !!}
{!! Theme::js('js/frontend/tasks/view-actions.js') !!}
<script>
$(document).ready(function () {
$('#deleteButton').on('mouseenter', function () {
$(this).find('i').html(' @lang('server.schedule.manage.delete')');
}).on('mouseleave', function () {
$(this).find('i').html('');
});
$.each(Pterodactyl.tasks, function (index, value) {
var element = (index !== 0) ? $('button[data-action="add-new-task"]').trigger('click').data('element') : $('div[data-target="task-clone"]');
var timeValue = (value.time_offset > 59) ? value.time_offset / 60 : value.time_offset;
var timeInterval = (value.time_offset > 59) ? 'm' : 's';
element.find('select[name="tasks[time_value][]"]').val(timeValue).trigger('change');
element.find('select[name="tasks[time_interval][]"]').val(timeInterval).trigger('change');
element.find('select[name="tasks[action][]"]').val(value.action).trigger('change');
element.find('input[name="tasks[payload][]"]').val(value.payload);
});
});
</script>
@endsection

View file

@ -1,230 +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.master')
@section('title')
@lang('server.tasks.edit.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.edit.header')<small>{{ $task->name }}</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.users.update')</li>
</ol>
@endsection
@section('content')
<form action="{{ route('server.tasks.view', ['server' => $server->uuidShort, 'task' => $task->hashid]) }}" method="POST">
<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-xs-12">
<label class="control-label">@lang('server.tasks.new.task_name'):</label>
<div>
<input type="text" name="name" class="form-control" value="{{ old('name', $task->name) }}" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<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" value="{{ old('day_of_week', $task->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" value="{{ old('day_of_month', $task->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" value="{{ old('hour', $task->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" value="{{ old('minute', $task->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" @if($task->action === 'command')selected @endif>@lang('server.tasks.actions.command')</option>
<option value="power" @if($task->action === 'power')selected @endif>@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', $task->data) }}">
<span class="text-muted small">@lang('server.tasks.new.payload_help')</span>
</div>
</div>
</div>
</div>
<div class="box-footer with-border" id="chainLastSegment">
<div class="pull-left">
<p class="text-muted small">Times for chain arguments are relative to the previous argument.</p>
</div>
<div class="pull-right">
{!! csrf_field() !!}
<button type="button" class="btn btn-sm btn-default" data-action="add-chain"><i class="fa fa-plus"></i> New Chain Argument</button>
<button type="submit" name="_method" value="PATCH" class="btn btn-sm btn-success">@lang('server.tasks.edit.submit')</button>
</div>
</div>
</div>
</div>
</div>
</form>
@include('partials.tasks.chain-template')
@endsection
@section('footer-scripts')
@parent
{!! Theme::js('js/frontend/server.socket.js') !!}
{!! Theme::js('vendor/select2/select2.full.min.js') !!}
{!! Theme::js('js/frontend/tasks/view-actions.js') !!}
<script>
$(document).ready(function () {
$.each(Pterodactyl.chained, function (index, value) {
var element = $('button[data-action="add-chain"]').trigger('click').data('element');
var timeValue = (value.chain_delay > 60) ? value.chain_delay / 60 : value.chain_delay;
var timeInterval = (value.chain_delay > 60) ? 'm' : 's';
element.find('select[name="chain[time_value][]"]').val(timeValue).trigger('change');
element.find('select[name="chain[time_interval][]"]').val(timeInterval).trigger('change');
element.find('select[name="chain[action][]"]').val(value.action).trigger('change');
element.find('input[name="chain[payload][]"]').val(value.data);
});
});
</script>
@endsection