/**
  * Get pending and exotic migrations.
  *
  * @param StructuredStatusInterface $status
  *
  * @return Div
  */
 public function getIndex(StructuredStatusInterface $status)
 {
     $report = $status->generateReport();
     return new Div([], [new ConferenceStructuredStatisticsPresenter($report), new Card([], [new CardHeader([], 'Pending Migrations'), Std::firstBias(count($report->getIdle()) > 0, function () use($report) {
         return new SimpleTable(['-', 'Name'], Std::map(function ($name) {
             return [new Italic(['class' => ['fa', 'fa-circle-o', 'text-warning']]), $name];
         }, $report->getIdle()));
     }, function () {
         return new Div(['class' => 'card-block text-center'], ['There are no pending migrations.']);
     })]), new Card([], [new CardHeader([], 'Exotic Migrations'), Std::firstBias(count($report->getUnknown()) > 0, function () use($report) {
         return new SimpleTable(['-', 'Name'], Std::map(function ($name) {
             return [new Italic(['class' => ['fa', 'fa-times-circle', 'text-danger']]), $name];
         }, $report->getUnknown()));
     }, function () {
         return new Div(['class' => 'card-block text-center'], ['There are no exotic migrations.']);
     })])]);
 }
Example #2
0
 /**
  * A shortcut for fast-and-easy API calls: If the provided Spec result is
  * invalid, then a validation response is sent, otherwise the result of
  * the provided callback is sent.
  *
  * @param SpecResult $result
  * @param Closure $onSuccess
  *
  * @deprecated Use ApiCheckableRequests
  * @return mixed
  */
 public static function flow(SpecResult $result, Closure $onSuccess)
 {
     return Std::firstBias($result->failed(), function () use($result) {
         return self::makeFromSpec($result)->toResponse();
     }, $onSuccess);
 }
 /**
  * Render the object into a string.
  *
  * @return mixed
  */
 public function render()
 {
     return Std::firstBias($this->paginator->hasPages(), function () {
         return new CardBlock(['class' => 'card-block text-center'], new BootstrapFourPaginatorPresenter($this->paginator));
     }, '');
 }
Example #4
0
 /**
  * Check that the spec matches and overlay help messaged.
  *
  * The resulting SpecResult instance should have more user-friendly
  * messages. This allows one to use Specs for validation on a website or
  * even an API.
  *
  * @param array $input
  *
  * @return SpecResult
  */
 public function check(array $input)
 {
     $result = $this->spec->check($input);
     return new SpecResult($result->getMissing(), Arr::walkCopy($result->getFailed(), function ($key, $value, &$array, $path) {
         $array[$key] = Std::coalesce(Std::firstBias(Arr::dotGet($this->messages, Std::nonempty($path, $key)) !== null, [Arr::dotGet($this->messages, Std::nonempty($path, $key))], null), Std::firstBias($value instanceof AbstractConstraint, function () use($value) {
             return $value->getDescription();
         }, null), Std::firstBias(is_array($value), function () use($value) {
             return array_map(function (AbstractConstraint $item) {
                 return $item->getDescription();
             }, $value);
         }, $value));
     }, true, '', false), $result->getStatus());
 }
 /**
  * Render a table showing jobs.
  *
  * @param Paginator $jobs
  *
  * @return mixed
  */
 protected function renderJobsTable(Paginator $jobs)
 {
     return Std::firstBias(count($jobs->items()) > 0, function () use($jobs) {
         return new SimpleTable(['ID', 'Task', 'State', 'Runs', 'Created At', 'Duration'], Std::map(function (Job $job) {
             return [$job->id, $job->state, $job->task, $job->attempts, $job->created_at->toDayDateTimeString(), $job->getExecutionTime()];
         }, $jobs->items()));
     }, function () {
         return new CardBlock(['class' => 'card-block text-center'], [new Paragraph([], [new Italic(['class' => 'fa fa-4x fa-search text-light'])]), 'No jobs found matching the specified criteria.']);
     });
 }
 /**
  * Get problematic modules.
  *
  * @param DashboardInterface $dashboard
  *
  * @return Div
  */
 public function getIssues(DashboardInterface $dashboard)
 {
     $exceptions = Std::map(function (Exception $exception, $moduleName) {
         return new Div([], [new Div(['class' => 'card card-inverted'], [new CardBlock([], [new HeaderSix(['class' => 'text-muted'], $moduleName), new Bold([], get_class($exception) . ': '), $exception->getMessage(), new Div(['class' => 'collapse p-t', 'id' => 'stack'], new PreformattedText(['class' => 'pre-scrollable'], $exception->getTraceAsString()))]), new Div(['class' => 'card-footer text-muted'], [new Row([], [new Column(['medium' => 6], [basename($exception->getFile()) . ':' . $exception->getLine()]), new Column(['medium' => 6, 'class' => 'text-xs-right'], new Button(['href' => '#', 'class' => ['btn', 'btn-sm', 'btn-primary-outline'], 'data-toggle' => 'collapse', 'data-target' => '#stack', 'aria-expanded' => 'false', 'aria-controls' => '#stack'], 'Toggle stacktrace'))])])])]);
     }, $dashboard->getFailedModules());
     return new Div([], [new Div(['class' => 'card'], [new Div(['class' => 'card-header'], 'Module issues'), new Div(['class' => 'card-block'], ['Below you will find a list of all the modules that ', 'failed to load. If one or more failed to load, it is ', 'not necessarily a bad thing. If you do not intend to ', 'use the component covered by the module, you may ', 'safely ignore it.'])]), new HorizontalLine([]), new Div([], Std::firstBias(count($dashboard->getFailedModules()) > 0, $exceptions, function () {
         return new Card(['class' => 'card card-block text-center'], ['All modules seem fine!']);
     }))]);
 }