In my last post, I talked about running into limitations with Django and Python, where I had queries I was wanting to do, but the integration between the RawQuerySets and DRF were blocking me from being able to easily build those queries and route the results to the DataTable.. Well,  I spent a day or two this past weekend recreating the entirety of what I had written in Django and Python  using Laravel and PHP, and I have some observations.

The first observation I would like to make is that Yajra DataTables is much friendlier and more powerful than DRF. Where with DRF, I had to rely on JavaScript having to have explicit knowledge of the URLs, Laravel's Blade Templates enabled rendering the URLs with the helpers with less effort. More so, I was able to tell Yajra to generate the buttons and the data on the server side without having to jump through hoops of writing additional code to do the filtering, sorting and pagination. And because of this, I found it simple to encode the CIDR blocks for use by the routes.

Speaking of CIDR, while I am using the same view to generate the heavy hitters data, because of the complexity of the query for that view, with Laravel, it was simple to create a migration to create that view  using a database statement, and the ORM easily supported creating a custom data type with something like the following:

use Illuminate\Database\Schema\Grammars\Grammar;
Grammar::macro('typeCidr', function() {
    return 'cidr';
});
...
        Schema::create('blacklist', function (Blueprint $table) {
            $table->id();
            $table->addColumn('cidr', 'blackhole');
        });

While not as nice as a $table->cidr('blackhole') would be, I could just as easily done any database type supported by the server (in this case, PostgreSQL).

I have not yet implemented the details on a CIDR block, I actually implemented stub methods for creating a new blackhole and several other actions. On thing I had to do was convert the CIDR block text into a form which the URLs/Routes would be happy with. My first thought was some sort of trick like HTML encoding, but the routes still interpreted the slash. So instead of the slash, I did a simple replacement of the slash with a dash, to get something like 192.168.0.0-24, then in the controller, doing the opposite replacement.

Now, for the results. Rather than use Tailwind CSS, which is what Laravel uses by default, or a combination of jQuery UI and jQuery UI themes, I opted for a straight bootstrap implementation, because of the ability to easily style buttons of different colors. But, I had to switch my main content DIV from the `container` class, using `container-flex`, since my screen is much wider than 1440px. And while the header and footer are not what I want (I prefer the styling I get with jQuery UI, but it and bootstrap get a bit 'competitive')... well, see for yourself.  This is the original Django/Python version:

While this is the Laravel/PHP version styled with Bootstrap:

And while the host summary page needs some work to get the memory and CPU totals in the footer, but here is the server side generated table using Django/Python styled by DataTables...

While this is a version using Laravel/PHP and AJAX to pull the data from the server:

It's a bit more crowded due to styling differences, but still workable, and it even has the delete functionality already. And like I said, the footer (not shown) does not have the CPU and RAM totals, but I already have the queries and just need to find the trick to put them into the footer.

So, pretty sure I am going to cross this bridge and switch to using Laravel and PHP.