workflow controller

This commit is contained in:
Arno Kaimbacher 2019-02-12 12:21:35 +01:00
parent 6068889e68
commit 7c6654398d
18 changed files with 687 additions and 470 deletions

View File

@ -6,6 +6,7 @@ use App\Models\Dataset;
use App\Models\Project;
use App\Models\License;
use App\Models\Title;
use App\Models\Description;
use App\Http\Requests\DocumentRequest;
use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
@ -26,7 +27,7 @@ class DatasetController extends Controller
$builder = Dataset::query();
//$registers = array();
$filter = $request->input('search');
$filter = $request->input('filter');
if (null !== ($request->input('state'))) {
$state = $request->input('state');
@ -52,7 +53,7 @@ class DatasetController extends Controller
//$perPage = $request->get('perPage', 20);
$documents = $builder
->paginate(8);
return view('settings.document.document', compact('documents'));
return view('settings.document.document', compact('documents', 'state', 'filter'));
}
/**
@ -180,7 +181,7 @@ class DatasetController extends Controller
$abstracts = $request->input('abstracts');
if (is_array($abstracts) && count($abstracts) > 0) {
foreach ($abstracts as $key => $formAbstract) {
$abstract = Title::findOrFail($key);
$abstract = Description::findOrFail($key);
$abstract->value = $formAbstract['value'];
$abstract->language = $formAbstract['language'];
$abstract->save();

View File

@ -0,0 +1,60 @@
<?php
namespace App\Http\Controllers\Settings;
use App\Http\Controllers\Controller;
// use App\Http\Requests\ProjectRequest;
// use App\Models\Project;
// use Illuminate\Http\RedirectResponse;
// use Illuminate\Http\Request;
use App\Models\Dataset;
use Illuminate\View\View;
class WorkflowController extends Controller
{
public function __construct()
{
//$this->middleware('auth');
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$builder = Dataset::query();
$datasets = $builder
//->where('server_state', 'inprogress')
->whereIn('server_state', ['unpublished'])
->get();
return view('workflow.index', compact('datasets'));
}
public function changestate($id, $targetState)
{
// $docId = $this->getRequest()->getParam('docId');
// $targetState = $this->getRequest()->getParam('targetState');
//$document = $this->_documentsHelper->getDocumentForId($docId);
$dataset = Dataset::findOrFail($id);
// Check if valid target state
// if (!$this->_workflowHelper->isValidState($targetState)) {
// }
try {
//$this->_workflowHelper->changeState($document, $targetState);
$dataset->setServerState($targetState);
// if ($targetState == 'published') {
// $this->_sendNotification($document, $form);
// }
$dataset->save();
session()->flash('flash_message', 'You have puplished 1 dataset!');
return redirect()->route('settings.review.index');
} catch (Exception $e) {
//return $this->_redirectTo('index', array('failure' => $e->getMessage()), 'documents', 'admin');
}
}
}

View File

@ -17,7 +17,7 @@ class RedirectIfAuthenticated
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
return redirect('/home');
}
return $next($request);

View File

@ -0,0 +1,7 @@
<?php
namespace App\Library\Util;
class SolrIndexIndexer
{
protected $data;
}

View File

@ -165,7 +165,7 @@ trait DatasetExtension
* @param string $name Name of the requested field.
* @return Field The requested field instance. If no such instance can be found, null is returned.
*/
protected function getField($name)
public function getField($name)
{
if (isset($this->fields[$name])) {
return $this->fields[$name];

View File

@ -213,6 +213,12 @@ class Dataset extends Model
->server_date_published;
}
public function setServerState($targetType)
{
$this->attributes['server_state'] = $targetType;
//$this->server_state = $targetType;
}
public function hasProject()
{
return $this->project()->exists();

View File

@ -0,0 +1,90 @@
<?php
namespace App\Observers;
//php artisan make:observer DatasetObserver --model=Models\Dataset
use App\Models\Dataset;
use Illuminate\Support\Facades\Log;
class DatasetObserver
{
/**
* Handle the dataset "created" event.
*
* @param \App\Models\Dataset $dataset
* @return void
*/
public function created(Dataset $dataset)
{
//
}
/**
* Handle the dataset "updated" event.
*
* @param \App\Models\Dataset $dataset
* @return void
*/
public function updated(Dataset $dataset)
{
// only index Opus_Document instances
if (false === ($dataset instanceof Dataset)) {
return;
}
// if ($dataset->getServerState() !== 'published') {
// if ($model->getServerState() !== 'temporary') {
// $this->removeDocumentFromIndexById($model->getId());
// }
// return;
// }
$this->addDatasetToIndex($dataset);
}
/**
* Handle the dataset "deleted" event.
*
* @param \App\Models\Dataset $dataset
* @return void
*/
public function deleted(Dataset $dataset)
{
//
}
/**
* Handle the dataset "restored" event.
*
* @param \App\Models\Dataset $dataset
* @return void
*/
public function restored(Dataset $dataset)
{
//
}
/**
* Handle the dataset "force deleted" event.
*
* @param \App\Models\Dataset $dataset
* @return void
*/
public function forceDeleted(Dataset $dataset)
{
//
}
/**
* Helper method to add dataset to index.
*
* @param Opus_Document $document
* @return void
*/
private function addDatasetToIndex(Dataset $dataset)
{
$datasetId = $dataset->id;
Log::debug(__METHOD__ . ': ' . 'Adding index job for document ' . $datasetId . '.');
}
}

View File

@ -1,6 +1,8 @@
<?php
namespace App\Providers;
use App\Models\Dataset;
use App\Observers\DatasetObserver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
@ -12,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
//
Dataset::observe(DatasetObserver::class);
}
/**
@ -26,9 +28,9 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->bind(
'Illuminate\Contracts\Auth\Registrar'
// 'App\Services\Registrar'
);
// $this->app->bind(
// 'Illuminate\Contracts\Auth\Registrar'
// // 'App\Services\Registrar'
// );
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
//
}
}

View File

@ -69,7 +69,7 @@ class RouteServiceProvider extends ServiceProvider
protected function mapApiRoutes()
{
Route::middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}

View File

@ -8,15 +8,15 @@
"license": "MIT",
"type": "project",
"require": {
"php": ">=7.0.0",
"davejamesmiller/laravel-breadcrumbs": "4.x",
"dimsav/laravel-translatable": "8.*",
"php": "^7.1.3",
"davejamesmiller/laravel-breadcrumbs": "5.x",
"dimsav/laravel-translatable": "9.*",
"felixkiss/uniquewith-validator": "^3.1",
"fideloper/proxy": "~3.3",
"fideloper/proxy": "^4.0",
"hieu-le/active": "^3.5",
"laravel/framework": "5.5.*",
"laravel/tinker": "~1.0",
"laravelcollective/html": "^5.5.0",
"laravel/framework": "5.6.*",
"laravel/tinker": "^1.0",
"laravelcollective/html": "^5.6",
"mcamara/laravel-localization": "^1.3",
"solarium/solarium": "^3.8",
"yajra/laravel-datatables-oracle": "^8.8",
@ -24,7 +24,7 @@
},
"require-dev": {
"fzaninotto/faker": "^1.8",
"phpunit/phpunit": "~6.0",
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "^3.3"
},
"autoload": {

838
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -122,6 +122,7 @@ return [
*/
'log' => 'single',
//debug, info, notice, warning, error, critical, alert, emergency.
'log_level' => env('APP_LOG_LEVEL', 'debug'),
/*
@ -176,6 +177,7 @@ return [
* Application Service Providers...
*/
'App\Providers\AppServiceProvider',
App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
'App\Providers\ConfigServiceProvider',
'App\Providers\EventServiceProvider',
@ -203,6 +205,7 @@ return [
'Artisan' => 'Illuminate\Support\Facades\Artisan',
'Auth' => 'Illuminate\Support\Facades\Auth',
'Blade' => 'Illuminate\Support\Facades\Blade',
'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
'Bus' => 'Illuminate\Support\Facades\Bus',
'Cache' => 'Illuminate\Support\Facades\Cache',
'Config' => 'Illuminate\Support\Facades\Config',
@ -212,12 +215,14 @@ return [
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
'Event' => 'Illuminate\Support\Facades\Event',
'File' => 'Illuminate\Support\Facades\File',
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => 'Illuminate\Support\Facades\Hash',
'Input' => 'Illuminate\Support\Facades\Input',
'Inspiring' => 'Illuminate\Foundation\Inspiring',
// 'Inspiring' => 'Illuminate\Foundation\Inspiring',
'Lang' => 'Illuminate\Support\Facades\Lang',
'Log' => 'Illuminate\Support\Facades\Log',
'Mail' => 'Illuminate\Support\Facades\Mail',
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => 'Illuminate\Support\Facades\Password',
'Queue' => 'Illuminate\Support\Facades\Queue',
'Redirect' => 'Illuminate\Support\Facades\Redirect',

View File

@ -26,8 +26,13 @@
</rewrite>
<defaultDocument>
<files>
<remove value="index.php" />
<add value="index.php" />
<clear />
<add value="index.php" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
</files>
</defaultDocument>
</system.webServer>

View File

@ -14,10 +14,10 @@
<div class="sidebar-simplesearch pure-u-1">
{!! Form::open(array('route' => 'settings.document','method' => 'GET', 'class'=>'pure-form')) !!}
<p>
{!! Form::text('search', null, array('class'=>'pure-u-1 pure-u-md-1-2', 'placeholder'=>'filter for the title...')) !!}
{!! Form::text('filter', (isset($filter)) ? $filter : '', array('class'=>'pure-u-1 pure-u-md-1-2', 'placeholder'=>'filter for the title...')) !!}
<div class="select pure-u-1 pure-u-md-1-2">
{!! Form::select('state', Config::get('enums.server_states'), 'published', ['class' => 'pure-u-1', 'onchange' => "this.form.submit()"]) !!}
{!! Form::select('state', Config::get('enums.server_states'), (isset($state)) ? $state : 'published', ['class' => 'pure-u-1', 'onchange' => "this.form.submit()"]) !!}
</div>
<div class="pure-u-1 pure-u-md-1-2">

View File

@ -95,8 +95,8 @@
<li class="pure-menu-item {{ Route::is('publish.dataset.create') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('publish.dataset.create') }}"><i class="fa fa-upload"></i> Create</a>
</li>
<li class="pure-menu-item {{ Route::is('publish.dataset.index') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('publish.dataset.index') }}"><i class="fa fa-upload"></i> Publish created datasets</a>
<li class="pure-menu-item {{ Route::is('settings.review') ? 'active' : '' }}">
<a class="pure-menu-link" href="{{ URL::route('settings.review.index') }}"><i class="fa fa-upload"></i> Release unpublished datasets</a>
</li>
</ul>
</li>

View File

@ -0,0 +1,50 @@
@extends('settings.layouts.app')
@section('content')
<div class="header">
<h3 class="header-title">
<i class="fa fa-file"></i> Datasets to be processed
</h3>
</div>
<div class="pure-g box-content">
<div class="pure-u-1">
<table class="pure-table pure-table-horizontal">
<thead>
<th>Dataset Title</th>
<th>ID</th>
<th>Server State</th>
</thead>
<tbody>
@foreach($datasets as $dataset)
<tr>
<td>
@if ($dataset->titles()->first())
{{ $dataset->titles()->first()->value }}
@else
no title
@endif
</td>
<td>
{{ $dataset->id }}
</td>
<td>
{{ $dataset->server_state }}
</td>
<td>
@if ($dataset->server_state == "unpublished")
<a href="{{ URL::route('settings.review.changestate',['id' => $dataset->id, 'targetState' => 'published']) }}" class="pure-button button-small is-success">Publish</a>
{{-- <a href="" class="pure-button button-small is-success">Restrict</a> --}}
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@stop

View File

@ -119,6 +119,13 @@ Route::group(
]);
// //For DataTables
Route::get('pages/get', ['uses' => 'PagesTableController@get'])->name('page.get');
Route::get('review', [
'as' => 'review.index', 'uses' => 'WorkflowController@index',
]);
Route::get('review/changestate/{id}/changestate/{targetState}', [
'as' => 'review.changestate', 'uses' => 'WorkflowController@changestate',
]);
}
);