Art-of-WiFi / UniFi-API-browser

Tool to browse data exposed by Ubiquiti's UniFi Controller API
MIT License
1.1k stars 150 forks source link

Enhancement: Allow query filtering / modification. #71

Closed scyto closed 2 years ago

scyto commented 5 years ago

When i do a default query let me filter by the tag pairs i see in the results.

For example in the list alarms query if i could append to the URI ?archived=false i could return only the alarms not archived (rather than all). (i have thousands of archived events). Maybe there is better / more interactive way to do it but . a free text field would be ok.

I don't have a preference on the implementation.

malle-pietje commented 4 years ago

With the new version 2.0.X, there is a way to add your own sub-menu with your own options where you can do this.

Basically you need add something like this to the bottom of your config.php file:

/**
 * adding a custom sub menu example
 */
$collections = array_merge($collections, [
    [
        'label' => 'Custom Menu', // length is limited here due to dropdown menu width
        'options' => [
            [
                'type' => 'collection', // or divider
                'label' => 'hourly site stats past 24 hours',
                'method' => 'stat_hourly_site',
                'params' => [(time() - (24 * 60 *60)) * 1000, time() * 1000],
                'key' => 'custom_0'
            ],
            [
                'type' => 'collection', // or divider
                'label' => 'daily site stats past 31 days',
                'method' => 'stat_daily_site',
                'params' => [(time() - (31 * 24 * 60 *60)) * 1000, time() * 1000],
                'key' => 'custom_1'
            ],
            [
                'type' => 'divider', // or collection
            ],
            [
                'type' => 'collection', // or divider
                'label' => 'enable the site LEDs',
                'method' => 'site_leds', // don't get too lost in adding such calls, this example is simply to show the flexibility
                'params' => [true],
                'key' => 'custom_2'
            ],
            [
                'type' => 'collection', // or divider
                'label' => 'disable the site LEDs',
                'method' => 'site_leds', // don't get too lost in adding such calls, this example is simply to show the flexibility
                'params' => [false],
                'key' => 'custom_2'
            ],
        ],
    ],
]);

Although this isn't truely interactive this does give a way to create your own calls.

malle-pietje commented 4 years ago

This is what this custom menu looks like: custom_menu