Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Dashboard Ideas #108

Open
Dejmienwp opened this issue Apr 23, 2021 · 2 comments
Open

New Dashboard Ideas #108

Dejmienwp opened this issue Apr 23, 2021 · 2 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@Dejmienwp
Copy link

Dejmienwp commented Apr 23, 2021

Witam.
Mam w planach trochę rozszerzyć działalność naszego Dashboardu.
Chciałbym zrobić jak to jest w niektórych cms dodawanie Widgetu.
Powiedzmy ze jeśli moduł ma plik "MODULES. $name / widget.php" to wyświetli go w Dashboard automatycznie.
Robiłem to ręcznie natomiast jak skasuje moduł to robi się mega awaria. I pomyślałem o czymś takim.
Czy to będzie większe grzebanie w całym systemie czy tylko w dashboard/admin.php ?
Jak się za to zabrać?

    private function _modulesList()
    {
        $modules = array_column($this->db('modules')->toArray(), 'dir');
        $result = [];

        if ($this->core->getUserInfo('access') != 'all') {
            $modules = array_intersect($modules, explode(',', $this->core->getUserInfo('access')));
        }

        foreach ($modules as $name) {
            $files = [
                'info'  => MODULES.'/'.$name.'/Info.php',
                'admin' => MODULES.'/'.$name.'/Admin.php',
                'widget'  => MODULES.'/'.$name.'/Widget.php',
            ];

            if (file_exists($files['info']) && file_exists($files['admin'])) {
                $details        = $this->core->getModuleInfo($name);
                $features       = $this->core->getModuleNav($name);


                if (empty($features)) {
                    continue;
                }

                if(file_exists($files['widget']) ){
                    $details['widget'] = $this->tpl->draw(MODULES.'/'.$name.'/Widget.html');

                }
                else {
                    continue;
                   }
            

                $details['url'] = url([ADMIN, $name, array_shift($features)]);

                $result[] = $details;
            }
        }
        return $result;
    }

}

Teraz jak zrobić zeby pobierało informacje z bazy danego modułu :D

@michu2k michu2k added help wanted Extra attention is needed question Further information is requested labels Apr 23, 2021
@Dejmienwp
Copy link
Author

Dobra, trochę się zatrzymałem. Fajnie dodaje pliczek html jeśli go znajdzie. Natomiast stoję na przeszkodzie. Pobierania danych z bazy danego widgetu i możliwości go zapętlania. Może ktoś ma jakiś pomysl.

@Dejmienwp
Copy link
Author

Dejmienwp commented Apr 24, 2021

Zrobiłem to po oomacku może ktoś będzie miał pomysł jak zrobić to lepiej.
Dashboard - Admin.php

    private function _modulesList()
    {
        $modules = array_column($this->db('modules')->toArray(), 'dir');
        $result = [];

        if ($this->core->getUserInfo('access') != 'all') {
            $modules = array_intersect($modules, explode(',', $this->core->getUserInfo('access')));
        }

        foreach ($modules as $name) {
            $files = [
                'info'  => MODULES.'/'.$name.'/Info.php',
                'admin' => MODULES.'/'.$name.'/Admin.php',
                'widget'  => MODULES.'/'.$name.'/Widget.html',
            ];

            if (file_exists($files['info']) && file_exists($files['admin'])) {
                $details        = $this->core->getModuleInfo($name);
                $features       = $this->core->getModuleNav($name);


                if(file_exists($files['widget'])){
                    $Widget         = $this->core->getModuleDashWidget($name);
                }
                else{
                    continue;
                }
                if (empty($features)) {
                    continue;
                }

                $details['widget'] = $this->draw(MODULES.'/'.$name.'/Widget.html', $Widget);
                $details['url'] = url([ADMIN, $name, array_shift($features)]);

                $result[] = $details;
            }
        }
        return $result;
    }

}

Core - Admin.php

    public function getModuleDashWidget($dir)
    {
        if ($this->module->has($dir)) {
            return $this->module->{$dir}->Dashboard_Widget();
        }
        return false;
    }

Aby Widget się dodał musi posiadać plik Widget.html oraz w Admin.php trzeba dopisać.

    public function Dashboard_Widget(){
                
        $task = $this->core->db('works')->desc('id')->toArray();
        return [$this->draw('index.html', [
            'tasks' => $task
        ])];
    }

to daje nam wywałenie {loop: $task} oraz $task pobieranie tablicy z bazy.

edit
Tak wygląda mój Dashboard.html


<article class="row">
    <div class="col-md-12">
        <div class="row">

            {loop: $modules}
            <div class="col-md-4">
                {$value.widget}
            </div>
            {/loop}

        </div>
    </div>

    <div class="col-md-4">

    </div>
</article>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants