joeferner / redis-commander

Redis management tool written in node.js
http://joeferner.github.io/redis-commander/
MIT License
3.6k stars 468 forks source link

Hooks to allow mapping of the data for the UI. #301

Open rquadling opened 5 years ago

rquadling commented 5 years ago

Hi.

Some of the data that is being placed in Redis may not be JSON encoded data. As a consequence, you end up with a LONG string and things get a little difficult to see.

Is there a way to be able to hook into the system such that the value can be processed and made more suitable for displaying?

I have some ideas ...

  1. The value is passed to all registered mappers to see if the mapper can process the value. This should be a quick regex check, rather than the full processing.
  2. If a mapper says it can process the value, it may be that other mappers can too, so potentially a priority could be implemented in some way (though for most use cases, I'd say first-come-first-served is probably fine).
  3. A mapper will advertise if editing of the data is supported. If it can only map from A=>B, but not B=>A, then no editing should be allowed.
  4. If editing is allowed, then the Save option should pass the edited value through the mapper before presenting it back to Redis.

Some pre-built mappers would be ideal. I'm a PHP user, so PHP's serialize, and session serialize would be great options. Both should be writable. Presentation wise, PHP's var_dump or print_r formats would be useful. But other languages standard serializers would be useful to include also.

http://locutus.io/ has JS implementations of the PHP functions I mentioned.

sseide commented 5 years ago

For an faster start you may just implement it this way before an larger framework for edit/dispaly plugin is set up:

Than you have a first usable version for your data and a better architecture to support your more complex use cases with mappers can be drafted...

For us JSON support is enough, maybe HTML may be of some help too ...