Add subuser support to tasks
Also allow task creation…
This commit is contained in:
parent
9b4a0ed143
commit
9fb0cb420e
5 changed files with 187 additions and 80 deletions
|
@ -71,7 +71,24 @@ class TaskController extends Controller
|
|||
|
||||
public function postNew(Request $request, $uuid)
|
||||
{
|
||||
dd($request->input());
|
||||
$server = Models\Server::getByUUID($uuid);
|
||||
$this->authorize('create-task', $server);
|
||||
|
||||
try {
|
||||
$repo = new Repositories\TaskRepository;
|
||||
$repo->create($server->id, $request->except([
|
||||
'_token'
|
||||
]));
|
||||
} catch (DisplayValidationException $ex) {
|
||||
return redirect()->route('server.tasks', $uuid)->withErrors(json_decode($ex->getMessage()))->withInput();
|
||||
} catch (DisplayException $ex) {
|
||||
Alert::danger($ex->getMessage())->flash();
|
||||
} catch (\Exception $ex) {
|
||||
Log::error($ex);
|
||||
Alert::danger('An unknown error occured while attempting to create this task.')->flash();
|
||||
}
|
||||
return redirect()->route('server.tasks', $uuid);
|
||||
|
||||
}
|
||||
|
||||
public function getView(Request $request, $uuid, $id)
|
||||
|
|
|
@ -106,12 +106,12 @@ class TaskRepository
|
|||
$validator = Validator::make($data, [
|
||||
'action' => 'string|required',
|
||||
'data' => 'string|required',
|
||||
'year' => 'string|sometimes|required',
|
||||
'day_of_week' => 'string|sometimes|required',
|
||||
'month' => 'string|sometimes|required',
|
||||
'day_of_month' => 'string|sometimes|required',
|
||||
'hour' => 'string|sometimes|required',
|
||||
'minute' => 'string|sometimes|required'
|
||||
'year' => 'string|sometimes',
|
||||
'day_of_week' => 'string|sometimes',
|
||||
'month' => 'string|sometimes',
|
||||
'day_of_month' => 'string|sometimes',
|
||||
'hour' => 'string|sometimes',
|
||||
'minute' => 'string|sometimes'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
|
@ -124,7 +124,7 @@ class TaskRepository
|
|||
|
||||
$cron = $this->defaults;
|
||||
foreach ($this->defaults as $setting => $value) {
|
||||
if (array_key_exists($setting, $data)) {
|
||||
if (array_key_exists($setting, $data) && !is_null($data[$setting]) && $data[$setting] !== '') {
|
||||
$cron[$setting] = $data[$setting];
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ class TaskRepository
|
|||
$cron['year']
|
||||
));
|
||||
} catch (\Exception $ex) {
|
||||
throw new DisplayException($ex);
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
$task = new Models\Task;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue