Explorar o código

移除datacard

jqh %!s(int64=5) %!d(string=hai) anos
pai
achega
e804c9a5c2

+ 0 - 217
src/Widgets/DataCard/Card.php

@@ -1,217 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Widgets\DataCard;
-
-use Dcat\Admin\Admin;
-use Dcat\Admin\Widgets\Dropdown;
-use Dcat\Admin\Widgets\HasAjaxRequest;
-use Dcat\Admin\Widgets\Widget;
-use Illuminate\Contracts\Support\Renderable;
-use Illuminate\Support\Str;
-
-class Card extends Widget
-{
-    use HasAjaxRequest;
-
-    protected $view = 'admin::widgets.data-card';
-
-    protected $options = [
-        'title'         => null,
-        'description'   => null,
-        'tools'         => [],
-        'progress'      => [],
-        'content'       => ['left'  => '', 'right' => ''],
-
-        'show_tool_shadow' => false,
-    ];
-
-    public function __construct($title = null, $description = null)
-    {
-        $this->title($title);
-        $this->description($description);
-
-        $this->class('card-box')
-            ->style('height:160px')
-            ->id('smc_'.Str::random(8));
-    }
-
-    public function showToolShadow()
-    {
-        $this->options['show_tool_shadow'] = true;
-
-        return $this;
-    }
-
-    public function title($title)
-    {
-        $this->options['title'] = $title;
-
-        return $this;
-    }
-
-    public function description($content)
-    {
-        $this->options['description'] = $content;
-
-        return $this;
-    }
-
-    /**
-     * @param $number
-     *
-     * @return $this
-     */
-    public function number($number)
-    {
-        return $this->content("<number>$number</number>");
-    }
-
-    /**
-     * @param string|\Closure|Renderable $content
-     * @param string                     $position
-     *
-     * @return $this
-     */
-    public function content($content, string $position = 'left')
-    {
-        $this->options['content'][$position] = $this->toString($content);
-
-        return $this;
-    }
-
-    /**
-     * @param string|\Closure|Renderable $content
-     *
-     * @return $this
-     */
-    public function rightContent($content)
-    {
-        return $this->content($content, 'right');
-    }
-
-    /**
-     * @param int    $number
-     * @param string $style
-     *
-     * @return $this
-     */
-    public function progress($number, $style = 'primary')
-    {
-        $this->options['progress'] = [
-            'percent' => $number,
-            'style'   => $style,
-        ];
-
-        return $this;
-    }
-
-    /**
-     * @param string|\Closure|Renderable $content
-     *
-     * @return $this
-     */
-    public function tool($content)
-    {
-        $this->options['tools'][] = $this->toString($content);
-
-        return $this;
-    }
-
-    /**
-     * @param array       $options
-     * @param \Closure    $builder
-     * @param string|null $defaultLabel
-     *
-     * @return $this
-     */
-    public function dropdown(array $options, \Closure $builder, ?string $defaultLabel = null)
-    {
-        return $this->tool(
-            Dropdown::make($options)
-                ->click()
-                ->button($defaultLabel)
-                ->buttonClass('btn btn-xs btn-light')
-                ->map($builder)
-        );
-    }
-
-    /**
-     * Setup scripts.
-     *
-     * @return string
-     */
-    protected function script()
-    {
-        if (! $this->allowBuildRequestScript()) {
-            return;
-        }
-
-        $this->setupFetchScript();
-
-        return $this->buildRequestScript();
-    }
-
-    /**
-     * @return void
-     */
-    protected function setupFetchScript()
-    {
-        $id = $this->getHtmlAttribute('id');
-
-        $this->fetching(
-            <<<JS
-var card = $('#{$id}');   
-card.loading({style:'bottom:20px'})      
-JS
-        );
-
-        $this->fetched(
-            <<<'JS'
-if (!response.status) {
-    return Dcat.error(response.message || 'Server internal error.');
-}     
-var w = (response.progress || 0) + '%', pg = card.find('.progress-bar');
- 
-card.loading(false)
-card.find('.right-content').html(response.content.right || '');
-card.find('.main-content').html(response.content.left || '');
-pg.css({width: 0});
-setTimeout(function(){ pg.css({width: w});}, 150);
-JS
-        );
-    }
-
-    /**
-     * @return string
-     */
-    public function render()
-    {
-        $this->script = $this->script();
-
-        return parent::render(); // TODO: Change the autogenerated stub
-    }
-
-    /**
-     * @return array
-     */
-    public function buildJsonResponseArray()
-    {
-        return [
-            'status'   => 1,
-            'content'  => &$this->options['content'],
-            'progress' => $this->options['progress']['percent'] ?? 0,
-        ];
-    }
-
-    /**
-     * Return JsonResponse instance.
-     *
-     * @param array $data
-     *
-     * @return \Illuminate\Http\JsonResponse
-     */
-    public function toJsonResponse(array $data = [])
-    {
-        return response()->json(array_merge($this->buildJsonResponseArray(), $data));
-    }
-}

+ 0 - 169
src/Widgets/DataCard/DoughnutChartCard.php

@@ -1,169 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Widgets\DataCard;
-
-use Dcat\Admin\Widgets\Chart\Doughnut;
-use Illuminate\Contracts\Support\Arrayable;
-
-class DoughnutChartCard extends Card
-{
-    protected $view = 'admin::widgets.data-card.chart';
-
-    /**
-     * @var Doughnut
-     */
-    protected $chart;
-
-    /**
-     * @var array
-     */
-    public $dotColors = [];
-
-    /**
-     * @var array
-     */
-    protected $dots = [];
-
-    public function __construct($title = null, $description = null)
-    {
-        $this->setupChart();
-        $this->setupDotColors();
-
-        parent::__construct($title, $description);
-    }
-
-    protected function setupChart()
-    {
-        $this->options['chart'] = $this->chart =
-            Doughnut::make()
-            ->cutoutPercentage(65)
-            ->responsive(false) // 去掉自适应,这里固定大小即可,否则手机端显示会有问题
-            ->height('85px')
-            ->width('85px')
-            ->setHtmlAttribute('width', '85px')
-            ->setHtmlAttribute('height', '85px')
-            ->disableLegend();
-    }
-
-    protected function setupDotColors()
-    {
-        $this->dotColors = $this->chart->colors;
-    }
-
-    /**
-     * @param \Closure|array $builder
-     * @param array          $data
-     *
-     * @return $this
-     */
-    public function chart($builder, array $data = [])
-    {
-        if ($builder) {
-            if ($builder instanceof \Closure) {
-                $builder($this->chart);
-            } elseif (is_array($builder) || $builder instanceof Arrayable) {
-                $this->chart->labels($builder);
-            }
-        }
-
-        $data && $this->chart->add($data);
-
-        return $this;
-    }
-
-    public function orange()
-    {
-        $this->chart->orange();
-
-        $this->setupDotColors();
-
-        return $this;
-    }
-
-    public function green()
-    {
-        $this->chart->green();
-
-        $this->setupDotColors();
-
-        return $this;
-    }
-
-    public function purple()
-    {
-        $this->chart->purple();
-
-        $this->setupDotColors();
-
-        return $this;
-    }
-
-    public function blue()
-    {
-        $this->chart->blue();
-
-        $this->setupDotColors();
-
-        return $this;
-    }
-
-    public function dot($content)
-    {
-        $this->dots[] = function () use (&$content) {
-            $color = array_shift($this->dotColors);
-
-            $content = $this->toString($content);
-
-            $point = "<i class='fa fa-circle' style='font-size:14px;color:$color;'></i>";
-
-            $this->options['content']['left'] .= <<<HTML
-<div style='margin:-16px 0 5px;'>
-
-    <span style="font-size:13px;color:#414750" >
-    {$point}  &nbsp; $content
-    </span>
-    
-</div>
-HTML;
-        };
-
-        return $this;
-    }
-
-    protected function script()
-    {
-        $this->buildDots();
-
-        if (! $this->allowBuildRequestScript()) {
-            return;
-        }
-
-        $this->setupFetchScript();
-
-        $this->chart->copy($this);
-    }
-
-    protected function buildDots()
-    {
-        foreach ($this->dots as $dot) {
-            $dot();
-        }
-    }
-
-    /**
-     * Return JsonResponse instance.
-     *
-     * @param array $data
-     *
-     * @return \Illuminate\Http\JsonResponse
-     */
-    public function toJsonResponse(array $data = [])
-    {
-        $this->buildDots();
-
-        return $this->chart->toJsonResponse(
-            true,
-            array_merge($this->buildJsonResponseArray(), $data)
-        );
-    }
-}

+ 0 - 68
src/Widgets/DataCard/LineChartCard.php

@@ -1,68 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Widgets\DataCard;
-
-use Dcat\Admin\Widgets\Sparkline\Line;
-use Illuminate\Contracts\Support\Arrayable;
-
-class LineChartCard extends Card
-{
-    protected $view = 'admin::widgets.data-card.line-chart';
-
-    /**
-     * @var Line
-     */
-    protected $chart;
-
-    public function __construct($title = null, $description = null, $number = null)
-    {
-        parent::__construct($title, $description, $number);
-
-        $this->setupChart();
-    }
-
-    protected function setupChart()
-    {
-        $this->options['chart'] = $this->chart =
-            Line::make()
-            ->height('60px')
-            ->style('display:block');
-    }
-
-    public function chart($builder)
-    {
-        if ($builder instanceof \Closure) {
-            $builder($this->chart);
-        } elseif (is_array($builder) || $builder instanceof Arrayable) {
-            $this->chart->values($builder);
-        }
-
-        return $this;
-    }
-
-    protected function script()
-    {
-        if (! $this->allowBuildRequestScript()) {
-            return;
-        }
-
-        $this->setupFetchScript();
-
-        $this->chart->copy($this);
-    }
-
-    /**
-     * Return JsonResponse instance.
-     *
-     * @param array $data
-     *
-     * @return \Illuminate\Http\JsonResponse
-     */
-    public function toJsonResponse(array $data = [])
-    {
-        return $this->chart->toJsonResponse(
-            true,
-            array_merge($this->buildJsonResponseArray(), $data)
-        );
-    }
-}

+ 0 - 20
src/Widgets/DataCard/PieChartCard.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Widgets\DataCard;
-
-use Dcat\Admin\Widgets\Chart\Pie;
-
-class PieChartCard extends DoughnutChartCard
-{
-    protected function setupChart()
-    {
-        $this->options['chart'] = $this->chart =
-            Pie::make()
-                ->responsive(false)
-                ->height('85px')
-                ->width('85px')
-                ->setHtmlAttribute('width', '85px')
-                ->setHtmlAttribute('height', '85px')
-                ->disableLegend();
-    }
-}

+ 0 - 20
src/Widgets/DataCard/PolarAreaChartCard.php

@@ -1,20 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Widgets\DataCard;
-
-use Dcat\Admin\Widgets\Chart\PolarArea;
-
-class PolarAreaChartCard extends DoughnutChartCard
-{
-    protected function setupChart()
-    {
-        $this->options['chart'] = $this->chart =
-            PolarArea::make()
-                ->responsive(false)
-                ->height('85px')
-                ->width('85px')
-                ->setHtmlAttribute('width', '85px')
-                ->setHtmlAttribute('height', '85px')
-                ->disableLegend();
-    }
-}