aljawaid / PluginManager

Replace the Installed Plugins section with a whole new interface. Plugin Manager provides both users and developers with an improved layout displaying a new section for troubleshooting plugins with a new plugin structure breakdown for each plugin. Install plugins directly or explore new upcoming or untested features from manual plugins.
MIT License
17 stars 3 forks source link

Add Totals for Plugin Types #16

Closed aljawaid closed 2 years ago

aljawaid commented 2 years ago

Based on the new is_type json property, count the totals and display to the user like a legend

Related to: #13 #12

aljawaid commented 2 years ago

I need help. I've tried to do as a helper but the test wont work.

helper:

<?php

namespace Kanboard\Plugin\PluginManager\Helper;

use Kanboard\Core\Base;

class PluginManagerHelper extends Base
{

public function checkPluginType($value='')
    {
        if (isset($plugin['remote_install']) && $plugin['remote_install']) {
            return 'hello'; // this will be an svg icon when it works
        } else {
            return 'none'; // this will be an svg icon when it works
        }
    }
}

calling in template directory.php:

<?php if (isset($plugin['remote_install']) && $plugin['remote_install']): ?>
                    <span id="PluginType" class="plugin-type">
                        <?= $this->helper->pluginManagerHelper->checkPluginType($this->text->e($plugin['remote_install'])) ?>
                    </span>
                <?php endif ?>

@creecros @alfredbuehler any advice what I am doing wrong?

aljawaid commented 2 years ago

it works in the template so I will just do it in there

aljawaid commented 2 years ago

but what about the totals?

creecros commented 2 years ago

at first glance, I don't see where $plugin was ever defined in your helper. I'll take a closer look tomorrow.

creecros commented 2 years ago

pushed type total rough draft for you, you can finish it from there, as i am not a front end person. Only did three as an example and to test: image

to get the other totals, just use: isset($countTypes['multi']) ? $countTypes['multi'] : '0'

in the template.

So that you understand how it works: In the template we define $countTypes using the helper function countTypes, and sending the variable $available_plugins: <?php $countTypes = $this->helper->pluginManagerHelper->countTypes($available_plugins); ?>

Then in the template we can get the totals for each type by using the conditional: isset($countTypes['multi']) ? $countTypes['multi'] : '0'

The return is a number, if it is set, if it is not set, then it is 0.

aljawaid commented 2 years ago

pushed type total rough draft for you, you can finish it from there, as i am not a front end person. Only did three as an example and to test: image

to get the other totals, just use: isset($countTypes['multi']) ? $countTypes['multi'] : '0'

in the template.

So that you understand how it works: In the template we define $countTypes using the helper function countTypes, and sending the variable $available_plugins: <?php $countTypes = $this->helper->pluginManagerHelper->countTypes($available_plugins); ?>

Then in the template we can get the totals for each type by using the conditional: isset($countTypes['multi']) ? $countTypes['multi'] : '0'

The return is a number, if it is set, if it is not set, then it is 0.

above all its nice to see these numbers starting to show up.... done a majore cleanup of that json file and glad that Frederic is still accepting updates.

I will look into the above code tonight, thats for that explanation.... makes more sense when its broken down

aljawaid commented 2 years ago

Fix 26adefe