Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Async update (AJAX/websocket) #4

Open
Fr33maan opened this issue Apr 18, 2014 · 7 comments
Open

[FEATURE REQUEST] Async update (AJAX/websocket) #4

Fr33maan opened this issue Apr 18, 2014 · 7 comments
Assignees

Comments

@Fr33maan
Copy link

Hello,

I would like to use it with a rest api using mongoDB. Since mongoDB is document model oriented, Treed seems to be perfect for database visualization but i also would like to be able to update the database in real time for testing purposes.

By setting good conventions (like in rails and some others framewroks), it could be totally automatised.

I can do that if your plugin is able to fire an event which can be configurable like :

afterNodeUpdate(callback(node))

function callback(node){
// Ajax request
}

Hope we can do that !

@jaredly
Copy link
Owner

jaredly commented Apr 18, 2014

Glad you're interested! I'm working on this right now, actually. Data storage support will soon be first class (integrated into the model layer w/ a defined API), and there will also be events if you want to go that route.

@jaredly jaredly self-assigned this Apr 18, 2014
@Fr33maan
Copy link
Author

Are you making automated AJAX request to a restful api ? If yes have you a definitive idea of what way you want to do that ? I've some specs to respect ^^ (but i don't want to interfere with your plans)

EDIT: automated update should handle error validation messages

@jaredly
Copy link
Owner

jaredly commented Apr 18, 2014

Right now I've got three persistence layers: Memory, LocalStorate, and Hoodie. The "RestfulPersistenceLayer" would still need to be written.
The PL interface will soon be modified slightly to be completely promise-based instead of just partially is at is now, but you can take a look if you're interested: https://github.com/jaredly/treed/blob/master/lib/mem-pl.js

@Fr33maan
Copy link
Author

so basically i can write this PL and customize save, findAll, find, remove and update functions inside ?

EDIT : Do you pass the entire node (key+value) to the PL ?

@jaredly
Copy link
Owner

jaredly commented Apr 18, 2014

Yup!
The data passed in looks like:

{
  id: "id",
  collapsed: bool,
  parent: "id",
  children: ["id", "id", ...],
  data: {
    name: "Some awesome node", // <-- this is what is actually displayed
    // there might be other stuff here
  }
}

If you want the full hierarchical data, there's a model.dumpData() function, which returns a structure like the flare_data you saw. But saving and updating only deal with individual nodes.

@jaredly
Copy link
Owner

jaredly commented Apr 18, 2014

In the d3 tree example I just call model.dumpData() whenever there's a change. If you're looking to modify a mongo database, that might be what you want.

@solutions018
Copy link

hi, have you got a chance to write code to update node movement in database via ajax?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants