trueblocks-explorer icon indicating copy to clipboard operation
trueblocks-explorer copied to clipboard

3.0 Inline editing of data on tables

Open tjayrush opened this issue 3 years ago • 15 comments

Some of the tables in some of the sub-views show un-editable data (such as the explorer views, the signatures view, and others.

Some of the tables (such as names / tags) allow the user to edit some of the values in the database.

This is tracks enabling editing values in one of the tables inline. In other words, the user clicks on a value and an editor opens up that he/she can change.

This could be done by opening up an expanded view that changes into a edit form if the user clicks a button or something.

There will need to be some backend work done in the blaze server to accept the user's edited data and prepare it for sending to chifra, but that part, I will do. Before I do that though, I need the front end to send the data.

tjayrush avatar Jun 02 '21 23:06 tjayrush

(Requires some back-end work first, need to set up a server call that accepts certain fields like description, tags, etc. to update a name)

deeayeen avatar Jun 10 '21 16:06 deeayeen

Just for future reference, this script show you how it works (really poorly) from the command line currently: https://github.com/TrueBlocks/trueblocks-core/blob/master/src/other/build_assets/addName.

The backend work would have to be done in this code (go code that handles the server): https://github.com/TrueBlocks/trueblocks-core/blob/master/src/go-apps/flame/server/routes.go#L114.

Currently, that code only handles the GET request. I would have to be expanded to handle a PUT, build the environment variables shown in the shell script above and send a command to chifra with those environment vars.

If this makes sense, and you're (@deeayeen) are at all interested in diving into the back end, please have a go at it. Otherwise, I will try to work on it this weekend. Make a PR of the frontend code and mark it work in progress (WIP) so I can have something to work on.

tjayrush avatar Jun 10 '21 16:06 tjayrush

In order to save the name edit, you can send a POST request to http://localhost:8080/names with an object of this type. If the address exists, it will be edited. If the object does not exist, it will be added.

To delete use http://localhost:8080/monitors?addrs=<address>&delete To undelete use http://localhost:8080/monitors?addrs=<address>&undelete To remove previously deleted: http://localhost:8080/monitors?addrs=<address>&remove

{
      /* A tag from the existing set or a new tag */
      "tags": "36-Compound",

      /* A valid Ethereum address */
      "address": "0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E",

       /* Non empty name */
      "name": "Compound Basic Attention Token",

      /* should default to Etherscan.io if empty */
      "source": "EtherScan.io",

      /* A user supplied description most likely empty and possibly not even needed */
      "description": ""
}

tjayrush avatar Jun 21 '21 01:06 tjayrush

This change requires a re-build of the backend.

tjayrush avatar Jun 21 '21 02:06 tjayrush

I see in the data you put above, "tags" is receiving a single string, "36-Compound", should this be an array of strings instead?

deeayeen avatar Jun 21 '21 22:06 deeayeen

It's a great question. For now, can you send it as a single string possibly separated by something like a '|'? The backend won't accept an array for this even though it should. It's an old issue that's been ignored for a while, but I won't have time to fix it until some future date. We eventually want to replace the database we use to store names with something more robust, just don't have the time.

So -- no -- just send a single string.

tjayrush avatar Jun 22 '21 01:06 tjayrush

We spoke about adding this feature (naming addresses) to the 'names' view, but now that we have named addresses in the transaction history view, it would be really nice to be able to name addresses directly on that screen as well.

tjayrush avatar Jul 06 '21 03:07 tjayrush

@tjayrush I've started a branch on this, I need an example CURL request of editing the name

deeayeen avatar Jul 06 '21 10:07 deeayeen

https://user-images.githubusercontent.com/35680780/124586648-5d174e80-de5f-11eb-9842-2632d6b49476.mov

deeayeen avatar Jul 06 '21 10:07 deeayeen

I use this to play around with adding names: https://github.com/TrueBlocks/addName

tjayrush avatar Jul 06 '21 13:07 tjayrush

@tjayrush That's just an empty create react app

deeayeen avatar Jul 06 '21 13:07 deeayeen

https://github.com/TrueBlocks/trueblocks-explorer/pull/134

deeayeen avatar Jul 06 '21 14:07 deeayeen

@deeayeen

Works excellently.

There's a couple of smaller related issues:

  1. We need an addName button somewhere above the table.
  2. Users should be able to edit and add names from the Monitors tab of the Dashboard view as well, and
  3. On the Dashboard / Account Details tab we allow users to enter new addresses. When they do that, I want to check to see if that new address already has a name and if not, I want to ask the user if they would like to name the address (they should almost always want to - we can explain to them how much better the user experience is if they do that).

Should I close this issue and open new ones, or can you work from here?

tjayrush avatar Jul 06 '21 15:07 tjayrush

Alright I'll take it step by step, I've added a button to the monitors table that allows you to add a new monitor, and it posts to /names with the data, can you hook it up to add it as a monitor somehow?

https://github.com/TrueBlocks/trueblocks-explorer/pull/137

deeayeen avatar Jul 07 '21 09:07 deeayeen

I'm pretty sure all you have to do after updating the backend with the new name (in the same way you would with an edit) is re-direct to the Account Details page with the new address. It should create a new monitor automatically.

tjayrush avatar Jul 07 '21 13:07 tjayrush