Jump to content

ProcessWire Dashboard


Recommended Posts

@MarkE There's currently no direct way to do this — the chart data is passed as a JSON blob, so no functions. I've been looking at setting up charts via JS files or JSON endpoints, but nothing concrete yet. I'll probably end up moving the chart panel to a chartkick.js implementation which would allow all of that.

  • Like 1
Link to comment
Share on other sites

  • 7 months later...

@d'Hinnisdaël - if you're contemplating moving away from chartjs, can I recommend a library that outputs SVG, rather than canvas - perhaps c3js? The reason being that it makes styling the charts with CSS really easy and also modifying them with D3JS is easy.

On a different note, I wonder if you'd consider setting up support for multiple tabs using WireTab? One of my dashboards is getting very long and it would be great to be able to split it up into different views and I think a tabbed interface would be effective.

Link to comment
Share on other sites

3 hours ago, adrian said:

@d'Hinnisdaël - if you're contemplating moving away from chartjs, can I recommend a library that outputs SVG, rather than canvas - perhaps c3js? The reason being that it makes styling the charts with CSS really easy and also modifying them with D3JS is easy.

On a different note, I wonder if you'd consider setting up support for multiple tabs using WireTab? One of my dashboards is getting very long and it would be great to be able to split it up into different views and I think a tabbed interface would be effective.

Good point about making charts styleable via CSS. My experience has been that most clients and most dashboards don't need charts at all, so frankly I don't think I'll be investing too much time here, but if or when I decide to revamp the chart panel I'll keep that in mind.

Adding tabs is definitely on my list. Groups are already supported, so adding tabs should be somewhat trivial. There's possible performance issues to keep in mind when rendering too many panels at once but that shouldn't be a blocker.

  • Like 2
Link to comment
Share on other sites

@adrian I went ahead and added very basic tab support. Thanks for the nudge. If you want to give it a try, feel free to check out the tabs branch of the repo. Theoretically it supports nesting tabs inside groups and vice versa, however it's largely untested so let me know if you run into trouble. I'd like to do some more testing before releasing a new version.

wire()->addHookAfter('Dashboard::getPanels', function ($event) {
    $panels = $event->return;

    $tab1 = $panels->createTab(['title' => 'Lorem ipsum']);
    $tab1->add(/* add panels here */);

    $tab2 = $panels->createTab(['title' => 'Dolor sit amet']);
    $tab2->add(/* add panels here */);

    $panels->add($tab1);
    $panels->add($tab2);
});

 

  • Like 1
Link to comment
Share on other sites

I recently installed the Processwire Dashboard module (https://daun.github.io/processwire-dashboard/#/). After I added the hook code in site/templates/admin.php, even though I can see the dashboard, the 'Pages' page shows this error -

Fatal error: Cannot redeclare _checkForMaxInputVars() (previously declared in wire/core/admin.php:line 96).' 

When I try to add a panel to show the Pagelist or simply try to access the subpages of any parent page, I see this error too. This error disappears when I remove the hook code from sites/templates/admin.php file. The code that the Dashboard module suggests we add to this file is as follows:

wire()->addHookAfter('Dashboard::getPanels'function ($event) {
  /* Get list of panels */
  $panels = $event->return;
 
  /* Add panels */
  $panels->add([
    'panel' => 'collection',
    'title' => 'News items',
    'data' => [
      'collection' => 'template=news-item, limit=10',
      'sortable' => true,
    ],
  ]);
});
 
/* Make sure to add the hook *before* the default admin process */
require $config->paths->adminTemplates . 'controller.php';

Any suggestions on how to solve this?

Thanks.

Link to comment
Share on other sites

  • 2 months later...

I'm using Dashboard to show some changelogs within the dashboard... but somehow repeaters don't respect that they aren't available as they would in normal pages.

<?php namespace Processwire;
$cl = pages()->get('template=dashChangelog');
$cles = $cl->changelogentry->sort('-date');
?>

That's how I get the main page for my Dashboard element and from there I do my usual foreach():

<?php foreach ($cles as $cle): ?>
<div class="cle">
<p><strong>? <?php echo date('Y-m-d', $cle->date); ?></strong></p>
<?php echo $cle->body; ?>
</div>
<?php endforeach; ?>

When I disable a repeater item... it still shows up.

In regular pages this wouldn't happen so... what do I have to change for the Dashboard?

Maybe I skipped a thought or two... but this confuses me.

Link to comment
Share on other sites

On 12/4/2021 at 2:31 PM, d&#x27;Hinnisdaël said:

Is this usually the case in the admin?

I don't know anything about this in regards to the admin area but I found a fix that makes it work as expected. Maybe it's necessary in the admin, never needed it for repeaters in the frontend so far.

<?php namespace Processwire;
$cl = pages()->get('template=dashChangelog');
$cles = $cl->changelogentry->sort('-date')->filter("status=1");
?>

The additional ->filter("status=1") does the trick here.

Link to comment
Share on other sites

2 hours ago, wbmnfktr said:

I don't know anything about this in regards to the admin area but I found a fix that makes it work as expected. Maybe it's necessary in the admin, never needed it for repeaters in the frontend so far.

<?php namespace Processwire;
$cl = pages()->get('template=dashChangelog');
$cles = $cl->changelogentry->sort('-date')->filter("status=1");
?>

The additional ->filter("status=1") does the trick here.

Good catch. Now that I think about it, returning all repeaters makes sense in the admin context — otherwise you wouldn't be able to edit all repeater items on page edit screens. But as you said, you'll have to remember to properly mark/mask unpublished repeaters yourself.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hiya, loving this dashboard for a few more complex projects.

I have a request for the number panel - since I often add a link in the "detail", if the number is zero then the link isn't shown. It would be great if there was a way to show it regardless.

Actually it's hard to tell if it's a bug or intentional. In DashboardPanelNumber.module if I wrap the number in is_numeric it works when zero is passed as the number as below:

public function setup()
    {
        parent::setup();
        $this->locale = $this->data['locale'] ?? setlocale(LC_ALL, 0);
        $this->detail = $this->data['detail'] ?? '';
        $this->number = is_numeric($this->data['number']) ? $this->data['number'] : null;
        if (is_int($this->number) || is_float($this->number)) {
            $this->number = $this->formatNumber($this->number);
        }
    }

 

  • Like 2
Link to comment
Share on other sites

21 hours ago, Pete said:

Hiya, loving this dashboard for a few more complex projects.

I have a request for the number panel - since I often add a link in the "detail", if the number is zero then the link isn't shown. It would be great if there was a way to show it regardless.

Actually it's hard to tell if it's a bug or intentional. In DashboardPanelNumber.module if I wrap the number in is_numeric it works when zero is passed as the number as below:

public function setup()
    {
        parent::setup();
        $this->locale = $this->data['locale'] ?? setlocale(LC_ALL, 0);
        $this->detail = $this->data['detail'] ?? '';
        $this->number = is_numeric($this->data['number']) ? $this->data['number'] : null;
        if (is_int($this->number) || is_float($this->number)) {
            $this->number = $this->formatNumber($this->number);
        }
    }

 

Sounds good, happy to integrate that if you submit a pull request on the GitHub repo.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
39 minutes ago, adrian said:

Hi @d'Hinnisdaël - just wondering if you've had any thoughts about changing the charting library, or at least updating to v3 of ChartJS. The old 2.x branch has lots of limitations with the time axis type.

Realistically speaking, I won't get to refactoring the chart panel until later this year. Updating the chart.js library in the meantime sounds good, though. Do you happen to know if the update contains any breaking changes that would apply to its use in the context of this dashboard? I haven't been actively following along and I'd like to avoid breaking people's existing dashboards if possible.

Link to comment
Share on other sites

I am not a regular ChartJS user so not sure of any breaking changes, although pointing the module's CDN link to the latest version does result in a JS error coming from the module's DashboardPanelChart.js file. I haven't looked into to see what fix is required though.

Link to comment
Share on other sites

1 hour ago, adrian said:

I am not a regular ChartJS user so not sure of any breaking changes, although pointing the module's CDN link to the latest version does result in a JS error coming from the module's DashboardPanelChart.js file. I haven't looked into to see what fix is required though.

Yeah, the migration guide looks pretty daunting. In that case I prefer leaving it as-is for now. If you find a simple fix, let me know and I'll happily review/merge any input.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi @d'Hinnisdaël - I am really loving the new tab option, but I am looking for a way to add a panel above the tabs so that it is available no matter which tab the user is on. If I add the panel directly to $panels, it always appears at the bottom of the page below the tabs. Any ideas how I can make this work?

Thanks so much!

  • Like 1
Link to comment
Share on other sites

5 hours ago, adrian said:

Hi @d'Hinnisdaël - I am really loving the new tab option, but I am looking for a way to add a panel above the tabs so that it is available no matter which tab the user is on. If I add the panel directly to $panels, it always appears at the bottom of the page below the tabs. Any ideas how I can make this work?

If you create a panel group and add the tabs to that, it should work.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...