workflow releasing datasets
This commit is contained in:
parent
ec127b9457
commit
de80de9d88
18 changed files with 355 additions and 107 deletions
|
@ -1,14 +1,19 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Publish;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Exceptions\GeneralException;
|
||||
// use App\Http\Requests\ProjectRequest;
|
||||
// use App\Models\Project;
|
||||
// use Illuminate\Http\RedirectResponse;
|
||||
// use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Dataset;
|
||||
use Illuminate\View\View;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class WorkflowController extends Controller
|
||||
{
|
||||
|
@ -17,34 +22,122 @@ class WorkflowController extends Controller
|
|||
//$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function review()
|
||||
{
|
||||
$builder = Dataset::query();
|
||||
$datasets = $builder
|
||||
//->where('server_state', 'inprogress')
|
||||
->whereIn('server_state', ['unpublished'])
|
||||
->get();
|
||||
return view('workflow.review', compact('datasets'));
|
||||
}
|
||||
|
||||
public function release()
|
||||
public function index(): View
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user_id = $user->id;
|
||||
|
||||
$builder = Dataset::query();
|
||||
$datasets = $builder
|
||||
->where('server_state', 'inprogress')
|
||||
->where('account_id', $user_id)
|
||||
->get();
|
||||
return view('workflow.release', compact('datasets'));
|
||||
$myDatasets = $builder
|
||||
->whereIn('server_state', ['inprogress', 'released'])
|
||||
->where('account_id', $user_id)
|
||||
->with('user:id,login')
|
||||
->get();
|
||||
return view('workflow.index', [
|
||||
'datasets' => $myDatasets,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function release($id): View
|
||||
{
|
||||
$dataset = Dataset::with('user:id,login')->findOrFail($id);
|
||||
// $editors = User::whereHas('roles', function ($q) {
|
||||
// $q->where('login', 'admin');
|
||||
// })->pluck('login', 'id');
|
||||
$editors = User::with(['roles' => function ($query) {
|
||||
$query->where('name', 'reviewer');
|
||||
}])
|
||||
->pluck('login', 'id');
|
||||
//$editors = Role::where('name', 'reviewer')->first()->users;
|
||||
|
||||
return view('workflow.release', [
|
||||
'dataset' => $dataset,
|
||||
'editors' => $editors,
|
||||
]);
|
||||
}
|
||||
|
||||
public function releaseUpdate(Request $request, $id)
|
||||
{
|
||||
$dataset = Dataset::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
$input['server_state'] = 'released';
|
||||
|
||||
if ($dataset->update($input)) {
|
||||
// event(new PageUpdated($page));
|
||||
return redirect()
|
||||
->route('publish.workflow.index')
|
||||
->with('flash_message', 'You have released your dataset!');
|
||||
}
|
||||
throw new GeneralException(trans('exceptions.publish.release.update_error'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function delete($id): RedirectResponse
|
||||
{
|
||||
$dataset = Dataset::with('files')->findOrFail($id);
|
||||
if ($dataset->server_state != "inprogress") {
|
||||
session()->flash(
|
||||
'flash_message',
|
||||
'You cannot delete this datastet!'
|
||||
. ' There status of this dataset is '
|
||||
. $dataset->server_state
|
||||
. ' !'
|
||||
);
|
||||
return redirect()->route('settings.project');
|
||||
} else {
|
||||
if ($dataset->files->count() > 0) {
|
||||
foreach ($dataset->files as $file) {
|
||||
if (isset($file->path_name)) {
|
||||
Storage::delete($file->path_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
$dataset->delete();
|
||||
session()->flash('flash_message', 'You have been deleted 1 dataset!');
|
||||
return redirect()->route('publish.workflow.index');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function indexReleased()
|
||||
{
|
||||
$builder = Dataset::query();
|
||||
$datasets = $builder
|
||||
//->where('server_state', 'inprogress')
|
||||
->whereIn('server_state', ['released'])
|
||||
->get();
|
||||
return view('workflow.review', compact('datasets'));
|
||||
}
|
||||
|
||||
// public function release()
|
||||
// {
|
||||
// $user = Auth::user();
|
||||
// $user_id = $user->id;
|
||||
|
||||
// $builder = Dataset::query();
|
||||
// $datasets = $builder
|
||||
// ->where('server_state', 'inprogress')
|
||||
// ->where('account_id', $user_id)
|
||||
// ->get();
|
||||
// return view('workflow.release', compact('datasets'));
|
||||
// }
|
||||
|
||||
public function changestate($id, $targetState)
|
||||
{
|
||||
// $docId = $this->getRequest()->getParam('docId');
|
||||
|
@ -64,7 +157,7 @@ class WorkflowController extends Controller
|
|||
if ($targetState == 'published') {
|
||||
//$this->_sendNotification($document, $form);
|
||||
$time = new \Illuminate\Support\Carbon();
|
||||
$dataset->server_date_published = $time;
|
||||
$dataset->server_date_published = $time;
|
||||
session()->flash('flash_message', 'You have puplished 1 dataset!');
|
||||
}
|
||||
$dataset->save();
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue