use Cubist\Util\Files\Files;
use Cubist\Util\Text;
+use Exception;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
trait Accessibility
if ($linkData['type'] == Link::SHOWLINK && $linkData['target'] !== 'hide') {
$ids = explode(',', str_replace(' ', '', $linkData['to']));
- $close = ($linkData['close_button'] && $linkData['close_button'] !== 'none');
+ $close = (isset($linkData['close_button']) && $linkData['close_button'] && $linkData['close_button'] !== 'none');
foreach ($ids as $id) {
$show = (str_starts_with($id, '-'));
$id = trim($id, '+- ');
use Cubist\Backpack\Magic\Fields\Integer;
use Cubist\Backpack\Magic\Fields\Text;
use Cubist\Backpack\Magic\Fields\Textarea;
+use Illuminate\Support\Facades\Cache;
class FluidbookHealthIssues extends ToolboxModel
{
const TYPE_MISSING_FILE = 1;
const TYPE_QRCODE_NOT_READABLE = 2;
- const CRIT_ERROR = 'error';
- const CRIT_WARNING = 'warning';
- const CRIT_INFO = 'info';
+ const CRIT_ERROR = 5;
+ const CRIT_WARNING = 3;
+ const CRIT_INFO = 2;
protected $table = 'fluidbook_health_issue';
protected $_options = ['name' => 'fluidbook-health',
parent::setFields();
$this->addField('fluidbook', FluidbookID::class, __('Fluidbook'));
+ $this->addField('criticality', Integer::class, __('Criticité'));
$this->addField('type', Integer::class, __('Type'));
$this->addField('data', Textarea::class, __('Détails'));
$this->addField('count', Integer::class, __('Nombre d\'occurences'));
if (is_array($data)) {
$data = json_encode($data);
}
+ $d = static::getTypeData($fluidbookId);
$issue = self::withoutGlobalScopes()->where('fluidbook', $fluidbookId)->where('type', $type)->where('data', $data)->first();
+ $crit = $d[$type]['criticality'];
if (!$issue) {
- $issue = new self(['fluidbook' => $fluidbookId, 'type' => $type, 'data' => $data, 'count' => 0]);
+ $issue = new self(['criticality' => $crit, 'fluidbook' => $fluidbookId, 'type' => $type, 'data' => $data, 'count' => 0]);
}
$issue->count++;
$issue->save();
+
+ $has = static::hasIssue($fluidbookId);
+
+ if ($has === false || $has < $crit) {
+ Cache::set('audit_fluidbook_hasissue_' . $fluidbookId, $crit);
+ }
}
- public static function getIssues($fluidbookId)
+ protected static function getTypeData($fluidbookId)
{
/*
- * __('Le chemin ":path" est introuvable')
- * __('Le QRcode du lien :uid (page :page) n\'a pas pu être décodé')
- */
-
- $d = [
+ * __('Le chemin ":path" est introuvable')
+ * __('Le QRcode du lien :uid (page :page) n\'a pas pu être décodé')
+ */
+ return [
static::TYPE_MISSING_FILE =>
[
'summary' => __('Erreur 404'),
- 'criticality' => self::CRIT_ERROR, 'text' => 'Le chemin ":path" est introuvable',
+ 'criticality' => self::CRIT_ERROR,
+ 'text' => 'Le chemin ":path" est introuvable',
],
static::TYPE_QRCODE_NOT_READABLE =>
],
];
+
+ }
+
+
+ public static function getIssues($fluidbookId)
+ {
+ $d = static::getTypeData($fluidbookId);
+
$issues = static::withoutGlobalScopes()->where('fluidbook', $fluidbookId)->orderBy('updated_at', 'DESC')->get();
$res = [];
foreach ($issues as $issue) {
public static function deleteIssues($fluidbookId)
{
static::withoutGlobalScopes()->where('fluidbook', $fluidbookId)->forceDelete();
+ Cache::set('audit_fluidbook_hasissue_' . $fluidbookId, false);
+ }
+
+ public static function hasIssue($fluidbookId)
+ {
+ return Cache::rememberForever('audit_fluidbook_hasissue_' . $fluidbookId, function () use ($fluidbookId) {
+ try {
+ return static::withoutGlobalScopes()->where('fluidbook', $fluidbookId)->orderBy('criticality', 'ASC')->firstOrFail()->criticality;
+ } catch (\Exception $e) {
+ return 0;
+ }
+ });
}
}
-{"version":3,"sources":["audit.less"],"names":[],"mappings":"AAAA;EACI,gBAAA;;AAGJ;AAAwB;EACpB,eAAA;;AAGJ;EACI,WAAA;;AAGJ;EACI,cAAA;;AAGJ;EACI,kBAAA;EACA,eAAA;EACA,gBAAA","file":"audit.css"}
\ No newline at end of file
+{"version":3,"sources":["audit.less"],"names":[],"mappings":"AAEA;EACI,gBAAA;;AAGJ;AAAwB;EACpB,eAAA;;AAGJ;EACI,WAAA;;AAGJ;EACI,cAAA;;AAGJ;EACI,kBAAA;EACA,eAAA;EACA,gBAAA","file":"audit.css"}
\ No newline at end of file
+@import 'variables';
+
h2 {
margin-top: 30px;
}
}
.la-exclamation-circle {
- color: #c00;
+ color: @error;
}
.la-exclamation-triangle {
- color: #F74D07;
+ color: @warning;
}
-.message{
+.message {
text-align: center;
font-size: 130%;
margin-top: 60px;
+@import 'variables';
+
@primary: #467fcf;
@primary-hover: darken(@primary, 5%);
@primary-border: darken(@primary, 10%);
top: 6px
}
+[data-crit] {
+ position: relative;;
+
+ &:after {
+ content: '';
+ position: absolute;
+ right: 5px;
+ bottom: 5px;
+ display: block;
+ width: 10px;
+ height: 10px;
+ background-color: transparent;
+ border-radius: 50%;
+ }
+}
+
+
+[data-crit="5"] {
+ &:after {
+ background-color: @error;
+ }
+}
+
+[data-crit="3"] {
+ &:after {
+ background-color: @warning;
+ }
+}
+
+
@import 'context-menu';
--- /dev/null
+@error: #c00;
+@warning: #F74D07;
@if(\Illuminate\Support\Facades\Cache::get('fluidbook_auditing_'.$id))
<p class="message">{{__('Audit en cours... Veuillez patienter quelques instants')}}</p>
<script>setTimeout(function () {
- //window.location.reload();
+ window.location.reload();
}, 5000)</script>
@else
-
- <a href="{{route('fluidbook_audit_refresh',['id'=>$id])}}" class="btn btn-primary" data-style="zoom-in"><span
+ <a href="{{route('fluidbook_audit_refresh',['id'=>$id])}}" class="btn btn-primary"
+ data-style="zoom-in"><span
class="ladda-label">
<i class="las la-redo-alt"></i> {{__('Relancer l\'audit')}}</span></a>
<a href="{{route('fluidbook_audit_reset',['id'=>$id])}}" class="btn btn-primary"
data-style="zoom-in"><span class="ladda-label">
<i class="las la-sync"></i> {{__('Effacer les erreurs et relancer l\'audit')}}</span></a>
- <table
- class="sortable bg-white table table-striped table-hover nowrap rounded shadow-xs border-xs mt-2 dataTable dtr-inline">
- <thead>
- <tr>
- <th>{{__('Criticité')}}</th>
- <th>{{__('Type')}}</th>
- <th>{{__('Détails')}}</th>
- <th>{{__('Nombre')}}</th>
- <th>{{__('Date')}}</th>
- <th>{{__('Corriger le problème')}}</th>
- </tr>
- </thead>
- <tbody>
-
- @foreach($issues as $issue)
+ @if(count($issues)===0)
+ <p class="message">{{__('Aucun problème n\'a été repéré lors de l\'audit')}}</p>
+ @else
+
+ <table
+ class="sortable bg-white table table-striped table-hover nowrap rounded shadow-xs border-xs mt-2 dataTable dtr-inline">
+ <thead>
<tr>
- <td sorttable_customkey="{{$issue['criticality']}}">{!! $icons[$issue['criticality']] !!}</td>
- <td sorttable_customkey="{{$issue['type']}}">{{$issue['summary']}}</td>
- <td>{!! $issue['text'] !!}</td>
- <td>{{$issue['count']}}</td>
- <td>{{$issue['last']}}</td>
- <td>{!! $issue['fix'] !!}</td>
+ <th>{{__('Criticité')}}</th>
+ <th>{{__('Type')}}</th>
+ <th>{{__('Détails')}}</th>
+ <th>{{__('Nombre')}}</th>
+ <th>{{__('Date')}}</th>
+ <th>{{__('Corriger le problème')}}</th>
</tr>
- @endforeach
- </tbody>
- </table>
+ </thead>
+ <tbody>
+
+ @foreach($issues as $issue)
+ <tr>
+ <td sorttable_customkey="{{$issue['criticality']}}">{!! $icons[$issue['criticality']] !!}</td>
+ <td sorttable_customkey="{{$issue['type']}}">{{$issue['summary']}}</td>
+ <td>{!! $issue['text'] !!}</td>
+ <td>{{$issue['count']}}</td>
+ <td>{{$issue['last']}}</td>
+ <td>{!! $issue['fix'] !!}</td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ @endif
@endif
@endsection
{{-- __('!! Paramètres des fluidbooks') --}}
@if( $entry->allowsAudit())
<a class="btn btn-sm btn-link" href="/fluidbook-publication/{{ $entry->id }}/audit"
- data-toggle="tooltip"
- title="{{__('Audit de la publication')}}"><img class="la audit" src="/images/icons/icon-audit.svg"> {{__('Audit')}}
+ data-toggle="tooltip" data-crit="{{\App\Models\FluidbookHealthIssues::hasIssue($entry->id)}}"
+ title="{{__('Audit de la publication')}}"><img class="la audit"
+ src="/images/icons/icon-audit.svg"> {{__('Audit')}}
</a>
@endif