netcreateorg / netcreate-2018

Please report bugs, problems, ideas in the project Issues page: https://github.com/netcreateorg/netcreate-2018/issues
Other
11 stars 2 forks source link

Node/Edge Option Type Editor #200

Closed benloh closed 2 years ago

benloh commented 2 years ago

Merge after #198!

Branch: dev-bl/typeedit

This hacks the json-editor interface so that we can add some additional functionality around:

In addition to updating the template, the editor will now also update the existing dataset's type options if necessary.


To Test

We recommend making a backup of your dataset and template because these tests will change both template and dataset content.

  1. git fetch && git checkout dev-bl/typeedit
  2. npm run dev
  3. Go to http://localhost:3000

Test Rename

To rename a label, you just type the new name in the "Change To" field. The nice thing about this UI is that the original label is still visible if you're making decisions about naming while reviewing the whole list.

  1. Select "More..." and "Edit Template"
  2. Click on "Edit Node Types"
  3. Rename "Person" to "People"
  4. Click "Save Changes"
  5. Any nodes marked as Person should still be the same color (light blue by default)
  6. Open a known Person node and make sure its type has been changed to "People"
  7. In the terminal, ctrl-c quit NetCreate and start it again.
  8. The fresh reload of the data should still show the changes: Node types have changed to "People" and the color remains the same.

Test Delete

You can simply remove a type option by deleting it. However, deleting a type option will make it an unknown type -- this means that any node that is set to that type will be displayed as black because it will have an unknown type. We expect that most of the time when you want to delete a label, you would also want to remap it (see the next section "Test Delete and Remap").

  1. Select "More..." and "Edit Template"
  2. Click on "Edit Node Types"
  3. Check the "Delete" next to "Place" or some other type that you have on screen.
  4. Click "Save Changes"
  5. Any node that was a "Place" node should now display as black, since "Place" is no longer a type the system recognizes.

Test Delete and Remap

Instead of simply deleting a type option, you can tell the system to change any node with the deleted type to a new type.

  1. Select "More..." and "Edit Template"
  2. Click on "Edit Node Types"
  3. Check the "Delete" next to "Group" or some other type that you have on screen.
  4. In the "Change To" field, enter an existing name to map to, e.g. "People"
  5. Click "Save Changes"
  6. Any node that was a "Group" node should now display as a blue "People" node. The "Group" type is now deleted.

Test Adding

You can add new options.

  1. Select "More..." and "Edit Template"
  2. Click on "Edit Node Types"
  3. Check the "Add row".
  4. In the "Label" field, enter "Race"
  5. Leave the "Change To" field blank.
  6. Select a color
  7. Click "Save Changes"
  8. Set a node to the new type.
  9. You should see the new type listed in the type menu, and once it's set you should see the new color.

Technically we should probably hide the "Change To" field when adding a new field, but having it actually adds another handy feature. Read on...

Remap Inadvertent "Feature"

Another handy power user feature for managing type options is you can use the "Add Row" feature to both add a type AND rename it at the same time. This is handy if you find that you have a node with a stray type that hasn't been added. For example, let's say you found three black nodes set to a type "Race", but you do not currently have "Race" as a type option. And you don't want the type option to be "Race", you want it to be "Ethnicity". You can Add it and change it in one action:

  1. Select "More..." and "Edit Template"
  2. Click on "Edit Node Types"
  3. Check the "Add row".
  4. In the "Label" field, enter "Race"
  5. In the "Change To" field, enter "Ethnicity"
  6. Set the color to Purple.
  7. Click "Save Changes"
  8. Any node that was a "Race" node should now display as a purple "Ethnicity" node.

Under the hood what happens is:

  1. We create a new type option for any "Label" we find in the list.
  2. Then if there is something in the "Change To" field, we will search for nodes with the "Label" type and change them to the "Change To" type.

The UI is a little quirky, especially for someone who is not used to managing lists of items in this way. But the nice thing is we don't need to build a custom UI with a ton of actions to take for every single label.


Wiki

Edit Template

Locking Templates

While editing templates, you cannot edit nodes or edges. This is because changes to the Template can affect how Nodes and Edges behave and are displayed. Changes to the template can also result in changes to the dataset (e.g. one node type is remapped to another node type).

Conversely, when you are editing a node or edge, you are not allowed to edit templates.

There is a warning message displayed on the Node/Edge if this occurs.

Edit Node Types / Edit Edge Types

When editing node types or edge types, if you use the "Change To" field, Net.Create will automatically update your dataset for you: any nodes and edges using the original "Label" type will be updated to use the new "Change To" type. This change is executed as soon as you click "Save Changes". Your dataset file on disk will be updated immediately.

NOTES

benloh commented 2 years ago

@kalanicraig @jdanish Please try out the node and edge types editor. It's a little more powerful than the first iteration with the template PR (#175). This hacks around json-editor to make use of its features to handle the combining and splitting types.

jdanish commented 2 years ago

Tinkering and it looks good so far. FYI, the node type updates, but the key does not until you reload the page.

benloh commented 2 years ago

I believe colors and labels do update as soon as you hit "Save Changes", but if you delete one, the colors are not updated until you reload.

benloh commented 2 years ago

A number of issues still to fix:

benloh commented 2 years ago

New Feature: Network Locking

The previous implementation of Template / Node / Edge locking only worked locally, e.g. trying to edit both a node and a template at the same time on the same computer was prevented. However, it did not work across the network: You could edit a template on one machine, and still be able to edit a node or even the template on a second machine.

The latest changes fix this. Template locking is now coordinated across the network starting with b2d1807bac0cff03e8b0d71e503e7985dc40f251

To Test

  1. git pull
  2. npm run dev
  3. On the first machine...
  4. ...Select "More..." > "Edit Template"
  5. On a second machine...
  6. ...Select "More..." > "Edit Template"
  7. ...Select a node.
  8. ...Click "Edit Node" => The Template editing buttons on both computers should disappear.
  9. ...Select an edge.
  10. ...Click "Edit Edge" => The Template editing buttons should remain gone
  11. ..."Save" the node edit => Template editing should remain disabled
  12. ...Click "Cancel" to cancel the edge edit => The Template editing buttons should be restored.
  13. ...Click "Edit Node Types" => The Node and Edge "Edit" buttons should become disabled.
  14. ...Click "Save Changes" to finish editing the Template => The Node and Edge buttons should be re-enabled again.

With power comes responsibility... If you abandon a template edit, or node/edge edit, the Template may be inadvertently locked out. If that happens:

  1. Open the web console in the browser
  2. Type ncUnlockAll()
  3. Reload the browser This should unlock all the node/edge database locks as well as any template locks.
benloh commented 2 years ago

@jdanish @kalanicraig Please test the network locking for template editing.

benloh commented 2 years ago

Nodes and Edges will now display a warning message if the template is current open for editing. screenshot_981

benloh commented 2 years ago

@jdanish @kalanicraig One more question about Node Type and Edge Type Option editing: Currently the fancy tools that handle dataset remapping when editing types (e.g. using "Change To" map from an old type to a new type), are only available in the Node Type Option and Edge Type Option editors. They are NOT available in the main "Edit Current Template" view. That view just provides a flat list of options to edit without the data conversion tools.

While it is possible, it will be messy to add the conversion tools to the "Edit Current Template" tool. Also it makes the workflow very convoluted. So here are some assumptions I'm making:

  1. Assume that it's OK that the "Edit Current Template" is focused on the raw template editing and does not provide the data conversion tools.
  2. We could add instructional text to the "Edit Current Template" view informing users to use to use the "Node Type Option" and "Edge Type Option" editors if they need to convert data.
  3. Or, we could remove the Node Type Option and Edge Type Option from the Edit Current Template view altogether (though I don't like this solution as much as it can be more confusing to have it missing).

Any thoughts? Ideas?

jdanish commented 2 years ago

I like / agree with 1 and 2. I think long-long-term we’ll wanna just make all custom editors, but for the short term this works great.

Joshua


Joshua A. Danish (he, him, his) (https://www.mypronouns.org/ https://www.mypronouns.org/)

@.***

http://www.joshuadanish.com

On Feb 8, 2022, at 4:36 PM, benloh @.***> wrote:

@jdanish https://github.com/jdanish @kalanicraig https://github.com/kalanicraig One more question about Node Type and Edge Type Option editing: Currently the fancy tools that handle dataset remapping when editing types (e.g. using "Change To" map from an old type to a new type), are only available in the Node Type Option and Edge Type Option editors. They are NOT available in the main "Edit Current Template" view. That view just provides a flat list of options to edit without the data conversion tools.

While it is possible, it will be messy to add the conversion tools to the "Edit Current Template" tool. Also it makes the workflow very convoluted. So here are some assumptions I'm making:

Assume that it's OK that the "Edit Current Template" is focused on the raw template editing and does not provide the data conversion tools. We could add instructional text to the "Edit Current Template" view informing users to use to use the "Node Type Option" and "Edge Type Option" editors if they need to convert data. Or, we could remove the Node Type Option and Edge Type Option from the Edit Current Template view altogether (though I don't like this solution as much as it can be more confusing to have it missing). Any thoughts? Ideas?

— Reply to this email directly, view it on GitHub https://github.com/netcreateorg/netcreate-2018/pull/200#issuecomment-1033085540, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKGCKXICA6G2M6KFB36ZGLU2GEHTANCNFSM5NIIXDWA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.

benloh commented 2 years ago

Standalone mode should work now. In addition, the "Edit Node" and "Edit Edge" buttons are now hidden in standalone mode.

benloh commented 2 years ago

Looks like nc-multiplex works fine.

benloh commented 2 years ago

@jdanish @kalanicraig Alright, I think the Node/Edge Type Option editors is now completed: locking template editing across the network now works, along with standalone mode fixes, and a confirmation that nc-multiplex still works.

Once you confirm the last few fixes starting with "New Feature: Network Locking" above, we can merge this into dev.

The next step will be to work on importing data.

jdanish commented 2 years ago

I noticed that the "NOTE: We recommend using the "Edit Node Types" feature to edit Node Types. It provides additional dataset migration tools." warning appears in both the edit not type editor, and the edit template editor. The first is a bit confusing since you are already there. Is that something that can be turned on only when it is part of the full editor? Same with edges. Otherwise, my minimal testing all looks good. Kalani can speak to more extensive testing / when it is ready, though.

benloh commented 2 years ago

I think I have to remove the "NOTE: We recommend..." manually. It should be doable.

Also there's still an issue with Template edits propagating across the network: #204

jdanish commented 2 years ago

Also the key updating (I think I filed an issue?).

benloh commented 2 years ago

Also the key updating (I think I filed an issue?).

Weird. I didn't get a notification. It's #206.

BTW, if you add a "Project" and select "Version 1.4" it should show up in the main work board I'm using: https://github.com/netcreateorg/netcreate-2018/projects/3

benloh commented 2 years ago

@jdanish Three fixes:

  1. Template updates now properly propagate across the network (before Template updates only updated things on the local computer, remote computers were not updating).
  2. After selecting "Add Row" in either "Edit Node Types" or "Edit Edge Types", you now enter the new value in the "Change To" field. This makes behavior more consistent across the board: The "Label" field is always static, any text changes always go in "Change To".
  3. Fixed a minor bug where source and targets were not being properly converted.

This should complete all the features needed for this merge request. The network data update changes are pretty fundamental, so it's worth doing a little more extended testing with this to make sure things still work as expected.

jdanish commented 2 years ago

Awesome. One thing I noticed by accident (I can file an issue if you need): If you go to edit a template, then navigate away in some way (e.g., reloading the page), then the network remains locked and there is no way to unlock it without a restart. Can we use the navigate away to trigger the unlock in one manner?

benloh commented 2 years ago

Issue created in #219. Merging.