Jump to content

[deprecated] RockGrid - powerful, performant and beautiful data listing tool


bernhard

Recommended Posts

Important security update!

Hi RockGrid users,

I'm very sorry for that, but I have to announce a security update. If you are using RockGrid on a public site please upgrade to v0.0.22 (Fieldtype) immediately. It is a simple but important update: https://github.com/BernhardBaumrock/FieldtypeRockGrid/commit/0be2086139c84f775937246ed2985ac4c4a3e9c3; The proplem exists on all RockGrid fields with AJAX turned ON. In this case it was theoretically possible to expose the field data to a user that should not be allowed to see this data (in the worst case even a guest user) if the user knew how to do it and he also knew the name of the rockgrid field.

The update now restricts access for AJAX field data to superusers only. You can easily adjust that via simple hooks:

// rockgrid access control
$wire->addHookAfter("InputfieldRockGrid::access", function(HookEvent $event) {
  // all grid data is accessible for all logged in users
  $event->return = $this->user->isLoggedin();
});

Or more granular via the fieldname:

// rockgrid access control
$wire->addHookAfter("InputfieldRockGrid::access", function(HookEvent $event) {
  $field = $event->arguments(0);
  $user = $this->user;
  $access = $event->return;

  switch($field) {
    case 'field1':
    case 'field2':
    case 'field3':
      $access = $user->isLoggedin();
      break;

    case 'field4':
      $access = ($user->name == 'foo');
      break;
  }

  $event->return = $access;
});

Field 1-3 is allowed for logged in users, field4 only for user foo and all other fields only for superusers (default rule).

I'm not totally happy any more with several aspects of RockFinder and RockGrid, but it is the best option I have so far (until I can build something totally new, maybe with tabulator if tests work well).

Special thx to @Zeka for bringing this issue to my attention by coincidence in the other topic!

  • Like 6
  • Thanks 2
Link to comment
Share on other sites

I am trying to figure out how to join pages from two templates into a grid. I will attach a picture of an incorrect result just as a talking point:

rockfinder_join.thumb.png.c85d712768f896aeba2c03a56c3c8427.png

The goal would be to plonk the data from unive into the grid, with rows filled only when code and number match the ones in the main (A-T) grid. The incorrectly repeating result in the screenshot was reached with this:

$finder1 = new RockFinder('template=A-T', ['code', 'nb', 'variation', 'name']);
$finder2 = new RockFinder('template=unive3', ['code', 'nb', 'proverbtype']);
// join finder
$finder1->join($finder2, 'unive', ['code' => 'code']);
$this->setData($finder1);

So how can I match by two fields to get what I want?

Link to comment
Share on other sites

Hi Beluga,

is this a tabulator grid? Is it a custom module or the rockgrid extension you've linked some time ago?

Regarding your join: I think in that case it would be the easiest to join them via plain sql; Something like

$foo = $finder1->getSQL();
$bar = $finder2->getSQL();
$sql = "SELECT * FROM ($foo) AS foo LEFT JOIN ($bar) as bar ON (foo.col1 = bar.col1 AND foo.col2 = bar.col2)";
$this->setData($sql);

PS: Be careful when joining / listing tables that have same name columns! This can lead to different results in the grid than in the resulting sql table. Compare the results to a regular SQL client by copying the resulting sql and executing it in Adminer and similar...

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Woooaw - with your query and renaming the fields of the other template, I got a perfect result!! (You were right that the column names have to be different) Thanks a lot.

This is using my old hacky Tabulator grid ?

  • Like 2
Link to comment
Share on other sites

Glad it worked ?

Yeah, it's good old SQL and RockFinder taking away the complexity of getting all fields related to a page/template and taking into account PW statuses. Though one has to be careful about access control related to fields, related pages, referenced page statuses etc...

Link to comment
Share on other sites

  • 2 weeks later...

Should the page refresh when using the view, edit, delete if i would delete the page through RockGrid?

 

col = RockGrid.colDefs.rowActions(col);
col.pinned = 'left';
col.width = 120;

image.png.7962f6743de24484cf2b02eb685a8cca.png

For now it just spins and if i refresh the page it shows that the deletion worked.

 

My console:

[{action: "trash", payload: ["1949"], response: "Trashed 1 pages"}]

Link to comment
Share on other sites

Sorry, didnt think that through ?

I get the same errors i Firefox:

JqueryCore.js?v=1545420649:2 POST http://localhost/celsa/pw/celsacalc/?RockGrid=1&field=Transportzoner net::ERR_CONTENT_DECODING_FAILED 200 (OK)

Could i have some issues with the Module?

image.png.a242f17b66d4f524dae8d01bf03742b3.png

Also shows undefiend: 25

 

Edit: Trashcan also shows as undefined.

Link to comment
Share on other sites

  On 6/30/2018 at 3:38 PM, bernhard said:

Support: Please note that this module might not be as easy and plug&play as many other modules. It needs a good understanding of agGrid (and JavaScript in general) and it likely needs some looks into the code to get all the options. Please understand that I can not provide free support for every request here in the forum. I try to answer all questions that might also help others or that might improve the module but for individual requests I offer paid support for 60€ per hour (excl vat).

Expand  

I'm sorry but I can't help you further than I did with this one. If you want me to have a look at your setup you can contact me via email/PM.

Link to comment
Share on other sites

  On 6/4/2019 at 8:42 AM, gottberg said:

Could i have some issues with the Module?

Expand  

Looking at the error you got, you could fix it by enabling zlib.output_compression in your php.ini.

ps: to be clear, you have a server issue.

 

 

Edited by flydev
ps
Link to comment
Share on other sites

  • 2 weeks later...
  On 6/4/2019 at 8:48 AM, bernhard said:

I'm sorry but I can't help you further than I did with this one. If you want me to have a look at your setup you can contact me via email/PM.

Expand  

Thank you so much for the help you gave! Bernhard helped me through Skype and TeamViewer and solved the issue. I have and had some issues with MAMP.

He also gave me some pointers of how to use RockGrid and best practises etc. Worth every €!!!

I recommend to use RockGrid if you need to list and edit data. I also recommend to contact Bernhard and buy some support if you want to quickly learn how to use RockGrid! ? 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

I am wondering how to optimise a query. It is taking 23 seconds on a server with 4GB of memory. It is live here: https://mattikuusiproverbtypology.fi/references/

I have considered moving to static JS data as the data in the db does not change very often.
The query is:

$finder1 = new RockFinder('template=A-T', ['code', 'nb', 'variation', 'name', 'page1', 'page2', 'page3', 'runningnb', 'additnb', 'abbrevat']);
$finder2 = new RockFinder('template=M6books', ['abbrev', 'author_editor', 'booktitle']);
$at = $finder1->getSQL();
$m6books = $finder2->getSQL();
$sql = "SELECT * FROM ($at) AS at LEFT JOIN ($m6books) as m6books ON (at.abbrevat = m6books.abbrev)";
$this->setData($sql);

I temporarily enabled slow_query_log like so in my.cnf:

long_query_time=1
slow_query_log=1
slow_query_log_file=/var/log/mysql/slow-query.log

(with /var/log/mysql owned by mysql user)

Below is the slow query log - for some reason it contains two identical queries, each taking over 9 seconds. I wonder why that is? Due to ajax? Does this happen to others?
 

  Reveal hidden contents

My MySQL settings on the server are:
 

  Reveal hidden contents

Results from mysqltuner:

  Reveal hidden contents

 

Link to comment
Share on other sites

  On 6/16/2019 at 10:36 AM, Beluga said:

I have considered moving to static JS data as the data in the db does not change very often.

Expand  

So would caching be an (easy) option?

  On 6/16/2019 at 10:36 AM, Beluga said:

Below is the slow query log - for some reason it contains two identical queries, each taking over 9 seconds. I wonder why that is? Due to ajax? Does this happen to others?

Expand  

At the moment this is how RockGrid works: It makes one query to get one row (so the query should have limit=0,1) so that it knows which columns to setup for the grid. Then the second request is to get all data (and this is also used for all subsequent requests when reloading the grid).

This is not the best solution, but I have no plans to change that for RockGrid. I start working on RockTabulator today where it will load all the data at the first request and display it instantly ? 

  • Like 4
Link to comment
Share on other sites

  On 6/17/2019 at 7:10 AM, bernhard said:

So would caching be an (easy) option?

At the moment this is how RockGrid works: It makes one query to get one row (so the query should have limit=0,1) so that it knows which columns to setup for the grid. Then the second request is to get all data (and this is also used for all subsequent requests when reloading the grid).

This is not the best solution, but I have no plans to change that for RockGrid. I start working on RockTabulator today where it will load all the data at the first request and display it instantly ? 

Expand  

Yep, caching might be nice going forward. Anyway, I can solve this right now with the static JS (well, in theory - have not tried yet what the effect on load time is). It is great to hear you have a plan for RockTabulator regarding this!

Link to comment
Share on other sites

  • 2 months later...

The newest version of RockGrid now supports RockFinder2 as data source ?

$finder = new RockFinder2();
$finder->find('template=basic-page');
$finder->addColumns([
  'title',
  'body'
]);
$this->setData($finder);

Data is available on the JS side via the RockFinder2 property in the GridItem object:

xbyUN7Y.png

  • Like 5
Link to comment
Share on other sites

Another little helpful update: Added support for colDef callbacks.

Before:

  col = grid.getColDef('id');
  col = RockGrid.colDefs.rowActions(col);

  col = grid.getColDef('created');
  col.headerName = 'Datum';
  col = RockGrid.colDefs.date(col);

After:


  grid.getColDef('id', function(col) {
    col = RockGrid.colDefs.rowActions(col);
  });
  
  grid.getColDef('created', function(col) {
    col.headerName = 'Datum';
    col = RockGrid.colDefs.date(col);
  });

The benefit is that before if the column did not exist for whatever reason (eg the column is hidden for some users) the JS broke and stopped execution because "col" was undefined and setting options on an undefined column definition doesn't work.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

My first attempt at RockFinder & RockGrid and truly impressed. Well done @bernhard!

Have already created my dataset using joins, changing column headings and the tip for Select Options in my custom php file to display the option's title rather than the value in a column. All good.

Problem arises with the filter for the Select Options field, column is project_status, with column header changed to 'Status'. I've no idea how to change the filter from the PW assigned index value to the text value of the field.  See examples:

1. Full data set

1906379616_Screenshot2019-09-0617_37_47.png.e0c2b7abe08d27c672dcc70a20381c05.png

2. Using a text entry in the filter, eg starting to type 'draft'

1028955936_Screenshot2019-09-0617_38_00.png.4ece236c378671965fc04cf78ee274fd.png

3. Entering the PW assigned select options index for 'draft'

504013311_Screenshot2019-09-0617_38_17.png.3c6ef082e03d65721f3dfa02ea83ff7e.png

I'm guessing it needs a custom filter and would appreciate help and guidance.

TIA

psy

 

Link to comment
Share on other sites

Hi Psy,

In aggrid you have two concepts: valueGetters (https://www.ag-grid.com/javascript-grid-value-getters/) and cellRenderers (https://www.ag-grid.com/javascript-grid-cell-rendering-components/)

The filter filters the RAW VALUE of the cell, not the rendered value. You can either change the valueGetter of the cell or do another "workaround". But that's something conceptional when you are working with aggrid and you have to decide when to take which approach.

Have you tried double-clicking the cell, then it should filter for the value of the cell automatically. A triple click removes the filter from that column.

Link to comment
Share on other sites

  On 9/6/2019 at 8:31 AM, psy said:

My first attempt at RockFinder & RockGrid and truly impressed. Well done @bernhard!

Expand  

Thx, one can do a of great stuff with those tools and I think not many know about that... ? But RockTabulator and RockFinder2 will make things a lot easier (if everything goes well).

  • Like 1
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...